Expand description
The background: a tilemap seen through a window the size of the screen.
The grid is 256 by 256 pixels and the screen shows 160 by 144 of it. You
choose which part with set_scroll, and it wraps at either edge. Fill the
grid itself through map.
The PPU re-reads the scroll registers as it fetches each tile, so writing them part way down a frame moves the rest of it. That is how you get a wobbling or parallaxing background. See https://gbdev.io/pandocs/Scrolling.html.
Functionsยง
- enabled
LCDCbit 0, which means different things on the two machines.- map
- Which grid the background reads, from
LCDCbit 3. - scroll
- Where the screen sits on the grid, as
(x, y). - set_
enabled - Set
LCDCbit 0. Seeenabledfor what it does on each machine. - set_map
- Point the background at a grid.
- set_
scroll - Move the screen to
(x, y)on the grid. - set_
scroll_ x - Move the screen horizontally.
- set_
scroll_ y - Move the screen vertically.