Choplifter and multiple scroll

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
Diskover
Posts: 219
Joined: Thu Nov 24, 2011 7:16 am
Contact:

Choplifter and multiple scroll

Post by Diskover »

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
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Choplifter and multiple scroll

Post by tepples »

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.
User avatar
Diskover
Posts: 219
Joined: Thu Nov 24, 2011 7:16 am
Contact:

Re: Choplifter and multiple scroll

Post by Diskover »

Wow... ok, thanks.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Choplifter and multiple scroll

Post by rainwarrior »

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.
User avatar
Diskover
Posts: 219
Joined: Thu Nov 24, 2011 7:16 am
Contact:

Re: Choplifter and multiple scroll

Post by Diskover »

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?
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Choplifter and multiple scroll

Post by rainwarrior »

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
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Choplifter and multiple scroll

Post by tokumaru »

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.
User avatar
Diskover
Posts: 219
Joined: Thu Nov 24, 2011 7:16 am
Contact:

Re: Choplifter and multiple scroll

Post by Diskover »

Oh, thanks everybody
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Choplifter and multiple scroll

Post by dougeff »

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
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Choplifter and multiple scroll

Post by Dwedit »

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!
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Choplifter and multiple scroll

Post by tepples »

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.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Choplifter and multiple scroll

Post by rainwarrior »

BPS?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Choplifter and multiple scroll

Post by tepples »

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.
Post Reply