Backgrounds — Mode 4: a 256-colour layer with offset-per-tile.
Mode 4 is the cartridge-game mode of offset-per-tile: an 8bpp (256 colour) BG1, a 2bpp BG2, and BG3 as an offset table like Mode 2. The difference is in that table: Mode 4 reads only one row of it, so each column gets one offset word that is either horizontal or vertical, chosen by bit 15 of the word.
Here BG1 is a diagonal 256-colour gradient. A sine wave is written into the single offset row each frame: as vertical words, the columns ripple up and down; press A and the same wave is written as horizontal words, and the columns slide sideways instead (8 pixels at a time — the low 3 bits of a horizontal offset are ignored).
- SNES Concepts
- Mode 4: setMode(BG_MODE4, 0), BG1 8bpp + BG2 2bpp, BG3 = offset map
- The Mode 4 offset word: bit 15 = 1 vertical / 0 horizontal, bit 13 = apply to BG1 (bit 14 = BG2), value in bits 0-9; one row of 32 words
- Column 0 is never offset: word 0 applies to the second visible column
- 8bpp tiles built at run time (tileEncode8bpp), a 256-entry palette
- What to Observe
- The gradient's columns ripple vertically as a travelling wave; the leftmost column stays put.
- Press A: the columns now shift horizontally, in 8-pixel steps.
- Modules Used
- console, dma, background, input, math, tile
- See also
- backgrounds/mode2 (the two-row table), docs/tutorials/graphics.md