Code: Select all
nmi_handler: ; point vector $FFFA here
This is a direct alternative to polling $2002 - just poll nmis
instead. Clean and simple.
However, this method of time keeping still has the disadvantage that you don't get the opportunity to run vblank tasks that can't be delayed - there are important things that are usually timed from vblank, such as status bars or sound engines, and you'll end up with visible or audible glitches if you miss the start of vblank, because these things won't be processed for a frame.
This is fine if you know for sure that your game engine never lags (easy to guarantee in simpler games with a limited number of active objects, but hard otherwise), or if you just don't care about music slowdowns or whatever, but if you're looking for a more robust way to handle vblanks, you should be handling NMIs the same way you're handling IRQs: use some sort of indirection so you can switch between different handlers in different parts of the game, and have each handler decide which tasks are critical and must be performed even during lag frames, and which will have to wait until the next vblank.