.WaitFor3xVBlank LDA PPU_STATUS ; Read the PPU_STATUS register, which clears the VBlank ; latch in bit 7, so the following loops will wait for ; three VBlanks in total .wait1 LDA PPU_STATUS ; Wait for the first VBlank to pass, which will set bit BPL wait1 ; 7 of PPU_STATUS (and reading PPU_STATUS clears bit 7, ; ready for the next VBlank) .wait2 LDA PPU_STATUS ; Wait for the second VBlank to pass BPL wait2 ; Fall through into WaitForVBlank to wait for the third ; VBlank before returning from the subroutineName: WaitFor3xVBlank [Show more] Type: Subroutine Category: Utility routines Summary: Wait for three VBlanks to passContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ResetScreen calls WaitFor3xVBlank
[X]
Configuration variable PPU_STATUS = $2002
The PPU status register, which can be checked to see whether VBlank has started, and whether sprite 0 has been hit (so we can detect when the icon bar is being drawn)
[X]
Label wait1 is local to this routine
[X]
Label wait2 is local to this routine