Neil's thread about mid-screen palette changes got me thinking about mid-screen scroll changes (also discussed in that thread), and I was wondering if you guys had anything to say about this.
I already know how to write to $2006, $2005, $2005, $2006 (in that order) in order to set the scroll to any part of the name tables I want, but I'm not sure what would be the best time to do that during rendering (so far I have only done this after extending VBlank, before turning rendering back on).
Of course I want the whole thing to take effect during HBlank, so that the next scanline is displayed correctly, but there are a few things to consider:
1. The vertical scroll is incremented by the PPU at cycle 251;
2. The horizontal scroll is reset by the PPU at cycle 257;
3. At the end of HBlank (what cycle?) the PPU starts fetching tiles for the next scanline;
I am thinking about making the writes approximately at the following times:
$2006: close to the end of the scanline, with pixels still rendering;
$2005: close to the end of the scanline, with pixels still rendering;
$2005: during HBlank, because the fine X scroll changes right away;
$2006: during HBlank, before the PPU starts fetching tiles;
I'll of course have some wiggling room, so the first two writes might happen closer to or during HBlank, but the third one definitely happens after HBlank starts.
Am I right to guess that there is nothing wrong in messing with T (temporary VRAM address) as the PPU finishes rendering pixels and enters HBlank? Or is this not as simple as I'm assuming, and disabling rendering is a necessity?
I already know how to write to $2006, $2005, $2005, $2006 (in that order) in order to set the scroll to any part of the name tables I want, but I'm not sure what would be the best time to do that during rendering (so far I have only done this after extending VBlank, before turning rendering back on).
Of course I want the whole thing to take effect during HBlank, so that the next scanline is displayed correctly, but there are a few things to consider:
1. The vertical scroll is incremented by the PPU at cycle 251;
2. The horizontal scroll is reset by the PPU at cycle 257;
3. At the end of HBlank (what cycle?) the PPU starts fetching tiles for the next scanline;
I am thinking about making the writes approximately at the following times:
$2006: close to the end of the scanline, with pixels still rendering;
$2005: close to the end of the scanline, with pixels still rendering;
$2005: during HBlank, because the fine X scroll changes right away;
$2006: during HBlank, before the PPU starts fetching tiles;
I'll of course have some wiggling room, so the first two writes might happen closer to or during HBlank, but the third one definitely happens after HBlank starts.
Am I right to guess that there is nothing wrong in messing with T (temporary VRAM address) as the PPU finishes rendering pixels and enters HBlank? Or is this not as simple as I'm assuming, and disabling rendering is a necessity?