Colour, rung 6c.2 — shadow & tint: recolour a whole scene at once.
Colour math against a fixed colour is how a game changes mood without touching a single tile or palette entry. Subtract a grey and the scene darkens — dusk, a dungeon, nightfall. Add a colour and the scene takes that cast — the blue of being underwater, the orange of a sunset or lava glow, the red flash of taking a hit. One register pair does it to every pixel of a layer, every frame, for free.
The scene here is a 4x4 chart of sixteen game-world colours (sky, water, foliage, earth, stone, accents) built procedurally — zero assets — so you can watch the effect land on every hue at once. Press A to cycle:
none -> shadow (darken) -> underwater tint -> sunset tint -> none
ROM mode: LoROM (project default).
- SNES Concepts
- Colour math with the FIXED-colour source (COLDATA $2132): result is main-screen ± a constant, applied per enabled layer
- colorMathShadow() = subtract grey (darken); colorMathTint() = add a colour (cast) — the two share the fixed-colour register and the add/subtract bit, so only one is active at a time
- The effect is a PPU pass over the final image: no VRAM, CGRAM or OAM traffic, so it costs nothing per frame and scales to the whole screen
- What to Observe
- Boot: the plain colour chart. Press A to darken it (shadow), then wash it blue (underwater), then warm it (sunset), then back to plain. Every swatch shifts together. fx_state is the probe oracle (0..3).
- Modules Used
- console, dma, background, colormath, input
- See also
- lib/include/snes/colormath.h — colorMathShadow(), colorMathTint()