Colour — palette cycling: animate without touching a pixel.
The oldest trick in the 2D book. The picture on screen never changes: every tile, every tilemap entry, every scroll register is frozen after init. All that moves is CGRAM — every four frames we rotate eight palette entries by one slot, and the light runs along a neon sign while the coolant flows through a pipe. This is how the SNES animates waterfalls, lava, fire, marquee lights and "loading" shimmers for the cost of a 32-byte CGRAM reload, no VRAM traffic at all.
The scene is a noodle bar's sign and a coolant pipe on a brick wall (res/sign.png, drawn by devtools/art_assets/build.py). It was drawn for the cycle: each letter of NOODLES is painted with its own colour index, 8 to 14 of BG palette 0, and the coolant with indices 8 to 15 of BG palette 1, which follow one another along the pipe. The wall, the frame and the pipe's metal use the other indices, and never change. Rotating entries 8-15 of the two palettes sends a wave of light along the letters and makes the coolant run.
ROM mode: LoROM (project default).
- SNES Concepts
- CGRAM is a live lookup table: rewrite an entry and every pixel that indexes it changes colour this frame — no redraw
- setColor() / dmaCopyCGram() are VBlank-only (CGRAM port is ignored during active display) — the rotation happens right after WaitForVBlank
- Artwork drawn for cycling: the indices that rotate are kept apart from the ones that do not, and laid out in the order the light runs
- A seamless colour loop: the 8 entries wrap (entry 15 → entry 8 is continuous) so the cycle never jumps
- What to Observe
- Boot: the sign's letters light up one after another, and the coolant runs along the pipe. Press START to freeze the cycle — both stop dead, proving nothing on screen actually moved; press again to resume. cycle_pos counts every rotation (probe oracle).
- Modules Used
- console, dma, background, input
- See also
- lib/include/snes/video.h — setColor(), RGB()
-
lib/include/snes/dma.h — dmaCopyCGram()