Skip to main content

Module bg

Module bg 

Source
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, placed by set_scroll and wrapping at either edge. What fills the grid is map’s business; this is where it sits.

The scroll registers are re-read as the PPU fetches each tile, so writing them part way down a frame moves the rest of it, which gives a background its wobble or its parallax. See https://gbdev.io/pandocs/Scrolling.html.

Functions§

enabled
LCDC bit 0, which means different things on the two machines.
map
Which grid the background reads, from LCDC bit 3.
scroll
Where the screen sits on the grid, as (x, y).
set_enabled
Set LCDC bit 0. See enabled for 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.