It is currently Fri Dec 15, 2017 4:52 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Sat Oct 29, 2016 3:13 pm 
Offline

Joined: Thu Nov 24, 2011 7:16 am
Posts: 170
Choplifter playing, I noticed that several pieces of the background move at different speeds.
Given that the sprite zero is located in the hub, how do the other pieces to move at different speeds?

https://www.youtube.com/watch?v=ybzHtVEvPKA


Top
 Profile  
 
PostPosted: Sat Oct 29, 2016 3:34 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19348
Location: NE Indiana, USA (NTSC)
If the cartridge has no programmable interval timer, there are three possibilities for multiple splits:

  1. Time the first split with sprite overflow and the second with sprite 0. That's not what's happening in this particular game, as you said sprite 0 is before the first split.
  2. Spin using 100% CPU to count cycles from sprite 0. The horizontal scrolling test in the NES version of 240p test suite does this, as does the road in Rad Racer.
  3. (Ab)use the DMC as a crude interval timer. I've made a demo of this called DPCM Letterbox. I seem to remember Time Lord and Fire Hawk doing this.


Top
 Profile  
 
PostPosted: Sat Oct 29, 2016 3:42 pm 
Offline

Joined: Thu Nov 24, 2011 7:16 am
Posts: 170
Wow... ok, thanks.


Top
 Profile  
 
PostPosted: Sat Oct 29, 2016 4:48 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5898
Location: Canada
Choplifter was one of my favourite SMS games. I didn't know there was a Famicom port of it, so I didn't mind spending a little time checking this out...

Sprite 0 is placed over the bottom left corner of the status bar, an execution breakpoint at $9255 will hit when this is detected.

From here (scanline 33) it seems to do a series of carefully timed (cycle counted code) tasks, eventually updating the scroll position at scanlines 100 and 150 as well.

It looks to me like each task does a little bit of work before calling a common delay routine at $9E2D with a parameter A that I guess is used to align the tasks to some common coarse time unit? (Doesn't seem to be aligned to a scanline.) Like it's a series of short tasks interspersed with long delays from that routine.

The scroll splits are on consistent scanlines but kind of have an inconsistent timing position within those scanlines. I expect the cycle counted code is slightly approximated / incorrect, and maybe that parameterized variable delay function was just a way to tweak timings easily until it seemed to work.

Edit: The particular split points seem to change from level to level, too.


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 3:24 am 
Offline

Joined: Thu Nov 24, 2011 7:16 am
Posts: 170
Mmm. . . ok, more questions.

With sprite_zero we can move the planes in the X-axis coordinates

Is it possible to move the Y-axis static leaving the rest of the screen?


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 3:30 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5898
Location: Canada
Sprite 0 is just a means for timing the split.

You can change both X and Y scroll values at any split. It's simpler to only change X, but the technique for changing Y scroll mid-screen is well understood.

On our wiki: PPU scrolling: Split X/Y scroll


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 4:27 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
You can't split the screen horizontally though (e.g. the left side of the screen scrolls at a different speed than the right side), because the screen is rendered from top to bottom.

Like rainwarrior said, the sprite 0 hit is just a means for the CPU to know that the PPU has reached a certain point of the screen as it renders the picture, so the program can change something in order to create a "split". You can change the scroll, the emphasis bits, the monochrome bit, switch CHR banks, or anything else you want (such as palettes or OAM) if you're willing to temporarily turn rendering off (which means blank scanlines on screen) in order to modify VRAM, although this is trickier to pull off.

Other means to time splits are the sprite overflow, timed code (from the NMI, from the end of vblank or from a previous split), APU IRQs and mapper IRQs. Some games (e.g. Super Cars, IIRC) even snoop into the sprite evaluation process by reading $2004 to know which part of the screen the PPU is currently rendering.


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 7:48 am 
Offline

Joined: Thu Nov 24, 2011 7:16 am
Posts: 170
Oh, thanks everybody


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 12:28 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1868
Location: DIGDUG
The MMC5 mapper can do a crude L / R scroll split.

https://youtu.be/yLiKOePb4bQ

See topic...
viewtopic.php?f=10&t=14083

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 12:48 pm 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3968
I bet you could do that split vertical effect without a mapper, since it's coarse scrolling and at a low framerate. Easily enough PPU time to blast out that much within a few frames, then swap to another nametable.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 1:01 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19348
Location: NE Indiana, USA (NTSC)
That specific split vertical effect with a 10-tile-wide scrolling window is possible without a mapper. I'd provide proof, but BPS would object.


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 2:36 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5898
Location: Canada
BPS?


Top
 Profile  
 
PostPosted: Sun Oct 30, 2016 3:47 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19348
Location: NE Indiana, USA (NTSC)
The demo of soft scrolling that I mentioned is a game that I made back in 2009, but which I later pulled from the Internet after Blue Planet Software aka The Tetris Company started winning lawsuits.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group