A vBlank flag is a PPU status bit that indicates whether the NES display has entered or reached vertical blanking. Startup code polls this flag before sending hardware commands. section 5.12
A typical startup sequence uses the flag in two stages:
- Test PPU_STATUS once, then loop until the vBlank flag changes. section 5.12
- Clear RAM and place sprites offscreen while the PPU is becoming ready. section 5.12
- Poll PPU_STATUS again before enabling NMI and transferring control to the main program. section 5.12
Listing 5.13 Waiting for the first vBlank (example.s)
#1
bit PPU_STATUS
wait_vblank:
bit PPU_STATUS
bpl wait_vblank
The polling pattern tests PPU_STATUS and branches back with BPL until the vBlank status condition is reached. section 5.12
Waiting for vBlank
Use BIT PPU_STATUS before the loop, then repeatedly execute BIT PPU_STATUS and branch back with BPL wait_vblank. The same pattern is repeated for the second vBlank. section 5.12
