I've looked at your code from the other thread and yes, you're running the game logic over and over in the same frame, causing things to move too fast. This has nothing to do with a short vblank handler. You jump to a label called "wait" but... there's no waiting at all, the program simply reads the controller again and performs the movement again, over and over, without ever waiting for the next frame to start.
What you need to do is set up a way to make your program wait for the vblank handler to run, so it knows that one frame is complete and it can proceed to processing the next one. The simplest way to do this is to increment a counter anywhere in your NMI handler:
And wait for this counter to change in your main loop:
Code: Select all
LDA FrameCounter
Wait:
CMP FrameCounter
BEQ Wait
Another thing you're not doing is backing up registers before you use them in the NMI handler. Remember, this code is going to interrupt the main loop, and if you change the registers without restoring them to their original values, when you return from the NMI the program will not be able to resume whatever it was doing, resulting in bugs and possibly even crashes. Most people have their NMI handlers save and restore all 3 registers, like this:
Code: Select all
NMI:
PHA ;save A
TXA
PHA ;save X
TYA
PHA ;save Y
;(NMI logic here)
PLA ;restore Y
TAY
PLA ;restore X
TAX
PLA ;restore A
RTI
EDIT: Corrected mistake pointed out by tepples.