pubby wrote:
To align the writes to hblank, it helps to use this library:
http://forums.nesdev.com/viewtopic.php?t=6589This is an amazing library that opens up even more possibilities: Doing almost-perfectly aligned writes anywhere in the screen. But IIRC it only works if you have constant cycles in your NMI before you start the effect. This isn't practical for most games.
And what's more, it's just way overkill for scrolling tricks, where an IRQ or sprite#0 hit will work just fine, as long as you make sure to align your writes and keep the number of instructions down.
Memblers wrote:
Here's some code I use for vertical scaling [...]
One tiny improvement on this code: I'd move the "lda vram_addr_lo,x" before the "sta $2005", as this should give you slightly more headroom if your writes aren't perfectly aligned.
(because first two writes to $2006/$2005 only affect the temporary latches, while the next two writes to $2005/$2006 do affect rendering output)
Memblers wrote:
The ADC #$55 trick lets you spend .666 cycles (IIRC, loopy came up with that one).
Indeed Loopy thought up that trick, and my variables are still called "_666" all around my code. "irrational_counter" is quite a neat neame though.
But more importantly, Loopy's the one who figured out how to set any X/Y scrolling value, which was never done by any commercial games. It sure was exciting learning this could be done back when it was first discovered, opening up the NES to neat effects we only saw in the later SNES era. I always refer to this as "loopy scrolling" to give Loopy credit for it... and because it's also such a catchy name, whereas "2006/2005/2005/2006 write sequence" sounds way too dulll and technical.
And yes, do check out Mesen's new event viewer. It's an amazing tool for perfecting tricks like these.