pub fn wait_vblank()Expand description
Block until the next VBlank IRQ.
This is the display-sync primitive: a frame that finishes early sleeps
until the blank, and a slow frame snaps to the next one, so presentation
quantizes to whole display periods. (psx_gpu::vsync() cannot do this:
it reconfigures Timer 1 on every call, and a mode write resets the
counter, so it busy-waits a fixed 242 HBlanks from the call site
instead of syncing to the display.)
Installs the VBlank counter on first use if the game has not already
called install_vblank_counter, but only while the exception vector is
still the one the program booted with. A game that has put its own
handler there keeps it: this function never overwrites it. Such a game
calls install_vblank_counter first and then wraps psx-rt’s handler,
or its handler chains to psx-rt’s, which is what advances the count this
waits on. The wait is bounded: after about four million reads
without the count moving it returns (and asserts in a debug build) instead
of hanging, as it would inside a critical section or without the handler.
try_wait_vblank takes the bound.