Skip to main content

with_lcd_off

Function with_lcd_off 

Source
pub fn with_lcd_off<R>(f: impl FnOnce(Access<'_>) -> R) -> R
Expand description

Turn the LCD off for the length of f.

The screen goes blank, and in exchange video memory stays reachable for as long as f runs rather than the roughly 1140 M-cycles Vblank::with allows, or 2280 in CGB double speed mode. A program with more tiles than one VBlank fits loads them this way.

Unlike Vblank::with, the wait here is a poll and needs no interrupt, so this runs before a program has turned them on.

Vblank::wait does not return inside f, since no VBlank arrives with the LCD off. An LCD that was already off is left that way and f runs at once.

Turning it back on restarts the PPU at line 0, and the screen stays blank through that first frame. See https://gbdev.io/pandocs/LCDC.html.