This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Choplifter and multiple scroll

Choplifter and multiple scroll
by on (#181507)
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?
Re: Choplifter and multiple scroll
by on (#181508)
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.
Re: Choplifter and multiple scroll
by on (#181509)
Wow... ok, thanks.
Re: Choplifter and multiple scroll
by on (#181510)
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.
Re: Choplifter and multiple scroll
by on (#181539)
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?
Re: Choplifter and multiple scroll
by on (#181540)
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
Re: Choplifter and multiple scroll
by on (#181542)
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.
Re: Choplifter and multiple scroll
by on (#181626)
Oh, thanks everybody
Re: Choplifter and multiple scroll
by on (#181634)
The MMC5 mapper can do a crude L / R scroll split.

See topic...
Re: Choplifter and multiple scroll
by on (#181636)
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.
Re: Choplifter and multiple scroll
by on (#181637)
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.
Re: Choplifter and multiple scroll
by on (#181639)
Re: Choplifter and multiple scroll
by on (#181643)
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.