How did Zelda 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

calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

How did Zelda scroll?

Post by calima »

I'm having trouble understanding how Zelda scrolls. The docs state mid-screen Y split was not discovered during the commercial era, and my debugging seems to confirm this.

I watched all writes to 2005 and 2006 during screen transitions. Scrolling does not change at any point, not during vblank, not at the bottom of the status bar. When going up/down, there are 32 writes to vram, writing a row of the new tiles, over two frames.

The Zelda commented disassembly online (computerarcheology.com) does not comment on this. I searched nesdev and found nothing more than guesses. Google has nothing.

--

So, it does not scroll, and it does not rewrite an entire nametable. It does not have a mid-screen split. How the heck does it work?

edit: I confirmed the watchpoint also catches (indirect),y writes, so it's not writing to 2005 like that either.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: How did Zelda scroll?

Post by thefox »

Pretty sure it changes the scroll with $2006. At least I seem to have debugged it at some point in the past: viewtopic.php?p=153799#p153799

They were able to do Y splits back in the day, just not pixel perfect. (If we discount rare cases like Battletoads, which seems to have managed in some way.)
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: How did Zelda scroll?

Post by calima »

I did check for the wiki's "two 2006 writes" technique too. The values written to 2006 were constant, despite the screen clearly changing.
niconii
Posts: 219
Joined: Sun Mar 27, 2016 7:56 pm

Re: How did Zelda scroll?

Post by niconii »

How are you going about checking which values are written to $2005 and $2006? If you're trying to use something like the Watch feature in Mesen to watch [$2005] and [$2006], keep in mind those are write-only registers, so trying to read from them won't get you anywhere.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: How did Zelda scroll?

Post by thefox »

Put a breakpoint at $8560. It's writing to $2006 at scanline 63.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: How did Zelda scroll?

Post by rainwarrior »

calima wrote:The docs state mid-screen Y split was not discovered during the commercial era, and my debugging seems to confirm this.
What docs say that? There's tons of games that clearly know how to Y split. (Super Mario 3, Rad Racer, Battletoads...)
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How did Zelda scroll?

Post by tokumaru »

The $2006/5/5/6 trick wasn't widely known (or at all?), but $2006-only scroll changes were frequently used, which means that games would usually set the scroll to the very top of a tile, and if they wanted pixel precision, they'd use timed code or IRQs to vary the pixel count BEFORE the split.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: How did Zelda scroll?

Post by calima »

Nicole wrote:How are you going about checking which values are written to $2005 and $2006? If you're trying to use something like the Watch feature in Mesen to watch [$2005] and [$2006], keep in mind those are write-only registers, so trying to read from them won't get you anywhere.
Mednafen shows the contents of registers. For a sta write, I look at the A register.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: How did Zelda scroll?

Post by calima »

thefox wrote:Put a breakpoint at $8560. It's writing to $2006 at scanline 63.
Yes, that's the target address for the 32 tiles write.
edit: Sample values for that are $22a0, $22c0... Normal nametable addresses that do not make sense with the wiki's two-write 2006 formula. Those were taken from a vertical transition on successive frames.

According to the wiki, that would cause a 2-pixel fine Y scroll. Yet the tiles in Zelda are perfectly 8-aligned.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: How did Zelda scroll?

Post by lidnariq »

calima wrote:According to the wiki, that would cause a 2-pixel fine Y scroll. Yet the tiles in Zelda are perfectly 8-aligned.
You sure about that? I'm pretty certain I see an offset during the vertical scrolling.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: How did Zelda scroll?

Post by calima »

Took fresh screenshots, and there's indeed an offset - 5 pixels. Which is not possible according to the wiki, which says the high fine Y bit is cleared, or to the written value which would result in a 2-pixel offset.

Okay, then it's indeed that write and I'm just confused. But why the offset discrepancy?
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: How did Zelda scroll?

Post by thefox »

I can't be bothered to do the math, but note that those two $2007 reads also affect the address (and thus, scroll).
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: How did Zelda scroll?

Post by calima »

I've been thinking about how the writes are an exact match to nametable addresses. Did the Zelda programmers believe it should be a nametable address, and take the fine Y offset as an unavoidable quirk?

Have official NES docs been leaked? Or, do other double-2006 games also write nametable addresses, ie the high nibble being 2?
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: How did Zelda scroll?

Post by thefox »

calima wrote:I've been thinking about how the writes are an exact match to nametable addresses. Did the Zelda programmers believe it should be a nametable address, and take the fine Y offset as an unavoidable quirk?
I'm guessing a fair bit of trial and error was involved. There are some bugs which they could've avoided. E.g., when the screen starts to scroll up, it first yanks downwards for one frame. Likewise, when the screen scrolls down, at the end of the scroll it scrolls a bit too far, and then corrects itself.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: How did Zelda scroll?

Post by tepples »

And 1-frame jank tends to have been more likely when engineers lacked access to the frame-stepping tools available in the emulator era.
Post Reply