How did Zelda scroll?
Moderator: Moderators
How did Zelda scroll?
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.
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.
Re: How did Zelda scroll?
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.)
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
Re: How did Zelda scroll?
I did check for the wiki's "two 2006 writes" technique too. The values written to 2006 were constant, despite the screen clearly changing.
Re: How did Zelda scroll?
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.
Re: How did Zelda scroll?
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
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: How did Zelda scroll?
What docs say that? There's tons of games that clearly know how to Y split. (Super Mario 3, Rad Racer, Battletoads...)calima wrote:The docs state mid-screen Y split was not discovered during the commercial era, and my debugging seems to confirm this.
Re: How did Zelda scroll?
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.
Re: How did Zelda scroll?
Mednafen shows the contents of registers. For a sta write, I look at the A register.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.
Re: How did Zelda scroll?
Yes, that's the target address for the 32 tiles write.thefox wrote:Put a breakpoint at $8560. It's writing to $2006 at scanline 63.
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.
Re: How did Zelda scroll?
You sure about that? I'm pretty certain I see an offset during the vertical scrolling.calima wrote:According to the wiki, that would cause a 2-pixel fine Y scroll. Yet the tiles in Zelda are perfectly 8-aligned.
Re: How did Zelda scroll?
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?
Okay, then it's indeed that write and I'm just confused. But why the offset discrepancy?
Re: How did Zelda scroll?
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
Re: How did Zelda scroll?
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?
Have official NES docs been leaked? Or, do other double-2006 games also write nametable addresses, ie the high nibble being 2?
Re: How did Zelda scroll?
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.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?
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
Re: How did Zelda scroll?
And 1-frame jank tends to have been more likely when engineers lacked access to the frame-stepping tools available in the emulator era.