Interactive showcase of all four HDMA library helper effects.
Demonstrates the four high-level HDMA helper functions provided by the OpenSNES library: brightness gradient, color gradient, iris wipe, and water ripple. Each effect uses one or two HDMA channels to modify PPU registers per-scanline without CPU intervention. The brightness gradient writes INIDISP ($2100), the color gradient rewrites CGRAM color 0 via CGADD/CGDATA, the iris wipe programs window registers (WH0/WH1) with TMW masking, and the water ripple offsets BG1HOFS per scanline using a sine-based displacement table. Effects can be toggled and their parameters adjusted in real time using the controller.
- SNES Concepts
- HDMA brightness gradient (INIDISP per-scanline dimming)
- HDMA color gradient (CGRAM color 0 rewrite per scanline group)
- HDMA iris wipe (window registers WH0/WH1 + TMW masking)
- HDMA water ripple (BG1HOFS sine displacement per scanline)
- Safe HDMA channel management (stop previous before starting new)
- What to Observe
- Press A: brightness gradient (screen fades to black at bottom)
- Press B: color gradient (backdrop shifts from deep blue to orange)
- Press X: iris wipe (circular window reveals the background)
- Press Y: water ripple (sinusoidal horizontal distortion animates)
- D-pad UP/DOWN: adjust the active effect's parameter (radius, amplitude, etc.)
- START: stop the current effect and restore normal display
- Modules Used
- console, sprite, dma, input, background, hdma
- See also
- hdma.h, input.h, background.h, video.h
Entry point – interactive showcase of four HDMA helper effects.
Loads a background image and enters an interactive loop where each button activates a different HDMA effect:
- A: brightness gradient (INIDISP per-scanline dimming)
- B: color gradient (CGRAM color 0 rewrite per scanline group)
- X: iris wipe (window registers WH0/WH1 with TMW masking)
- Y: water ripple (BG1HOFS sine displacement per scanline)
- D-pad UP/DOWN: adjust the active effect's parameter
- START: stop the current effect and restore normal display
Before activating a new effect, the previous one is always stopped first to avoid HDMA channel conflicts and stale PPU register values.
- Returns
- Does not return (infinite loop).
< Newly pressed buttons this frame (edge-detected)