Backgrounds — offset-per-tile in Mode 2 and Mode 4: per-column scroll from BG3.
More...
Backgrounds — offset-per-tile in Mode 2 and Mode 4: per-column scroll from BG3.
Modes 2, 4 and 6 have a trick no other mode does: offset-per-tile (OPT). BG3 stops being a drawable layer and becomes an offset table — for each 8-pixel column of BG1/BG2 the PPU reads a scroll offset out of BG3's tilemap. That lets each column scroll independently, which is how you get a flag rippling in the wind, heat-haze, or per-column parallax without a scanline of HDMA.
The example boots in Mode 2 on the Rue basse under the rain (4bpp, the picture of backgrounds/mode1): a sine table written into BG3 gives every column its own vertical offset, a few lines up or down, and the air shimmers over the street like the heat above a steam vent. B switches to Mode 4 and the canal at night (8bpp, 256 colours, the picture of backgrounds/mode3), with the same wave in Mode 4's single offset row — as vertical words, or as horizontal ones after A, when the columns slide sideways in 8-pixel steps. B again goes back to Mode 2. The two pictures do not fit in VRAM together (28 KB and 50 KB), so a switch reloads the scene in force blank: one dark frame.
ROM mode: LoROM (project default).
- SNES Concepts
- Mode 2 OPT: setMode(BG_MODE2, 0); BG3's tilemap is the offset source, not a picture
- Mode 2: per column N≥1 the PPU reads BG3 tile-row 0 for the H offset word and tile-row 1 for the V offset word; column 0 cannot be offset
- Mode 4: ONE row; bit 15 of a word says vertical (1) or horizontal (0)
- Offset word: bit 0x2000 = apply to BG1 (0x4000 = BG2); V value in bits 0-9, H value in bits 3-9 (whole tiles)
- An offset word replaces the layer's scroll register for its column, so it is the raw value: the -1 the lib adds to a vertical scroll is not there, and a word of 0x3FF (-1) lines a column up with column 0
- Mode 4's BG1 is 8bpp (256 colours), Mode 2's is 4bpp
- What to Observe
- The street shimmers as a travelling wave, each 8-pixel column a few lines higher or lower, all from one small BG3 table; column 0, at the left edge, stays still. B: the canal in 256 colours ripples the same way; A there: its columns slide sideways instead, by whole tiles. wave_phase is the probe oracle.
- Modules Used
- console, dma, background, input, math
- See also
- lib/include/snes/video.h — setMode(BG_MODE2), setMode(BG_MODE4)