Direct color — the pixel byte IS the color (CGWSEL bit 0).
Effects arc 4/7 (#109). In direct color mode the PPU stops looking 8bpp BG pixels up in CGRAM: each pixel byte is read as BBGGGRRR and expanded straight to 15-bit BGR. This example builds a 16x16 chart of all 256 pixel codes procedurally (zero assets, 256 solid-color tiles generated at init) and loads a deliberately DIFFERENT CGRAM palette — a grayscale ramp — so one button press flips the SAME VRAM bytes between two readings:
- direct ON (boot state): the BBGGGRRR color cube — red ramps left-to-right within each block row, green down the chart, blue in four broad bands;
- direct OFF: the CGRAM grayscale ramp of the very same tile data.
ROM mode: LoROM (project default).
- SNES Concepts
- CGWSEL bit 0 via colorMathSetDirectColor() — the colormath module shadows the register, so this composes with any blending setup
- BBGGGRRR expansion and the tilemap-palette-bits low-bit extension (2048 colors max — this chart uses pal bits 0, the base 256)
- Mode 3: BG1 is 8bpp; 8bpp tile format = 4 interleaved bitplane pairs (64 bytes/tile), built here byte by byte in C
- What to Observe
- Boot shows the color cube. Press A to re-read the same VRAM as grayscale (CGRAM mode), press again to return. Nothing is uploaded on toggle — one register bit changes the meaning of every pixel.
- Modules Used
- console, dma, background, colormath, input
- See also
- lib/include/snes/colormath.h — colorMathSetDirectColor()