Indirect HDMA — 32-band backdrop gradient from a pointer table. More...
Macros | |
| #define | BAND_LINES 7 |
| Scanlines per band (non-repeat count in each table entry). | |
| #define | NBANDS 32 |
| Gradient bands (krom: 32 bands x 7 scanlines = 224 lines). | |
Functions | |
| int | main (void) |
| Entry point — static 32-band red gradient, zero per-frame CPU. | |
Variables | |
| static u8 | band_data [32][4] |
| Indirect payload blocks, one per band: [0][0][color_lo][color_hi]. | |
| static u8 | itable [32 *3+1] |
| The indirect table: [count][ptr_lo][ptr_hi] per band + terminator. | |
Indirect HDMA — 32-band backdrop gradient from a pointer table.
The indirect-HDMA counterpart of gradient_colors: instead of a table carrying the color DATA inline, the table carries [count][pointer] entries and the PPU fetches each band's 4-byte payload through the pointer ($43x7 selects the data bank). The payload blocks live in a separate WRAM array the CPU can edit freely — the classic layout for dynamic per-scanline palettes (the HiColor building block).
C port of "SNES Red Space Indirect HDMA Demo" by krom (Peter Lemon), github.com/PeterLemon/SNES, PPU/HDMA/RedSpaceIndirectHDMA — same configuration: no BG layers at all (main screen = 0), the gradient IS the backdrop, rewritten every 7 scanlines through CGRAM color 0. No assets, static image, zero per-frame CPU.
| #define BAND_LINES 7 |
Scanlines per band (non-repeat count in each table entry).
| #define NBANDS 32 |
Gradient bands (krom: 32 bands x 7 scanlines = 224 lines).
| int main | ( | void | ) |
Entry point — static 32-band red gradient, zero per-frame CPU.
Faithful to krom's register sequence: DMAP0=%01000011 (indirect | 2REG_2X), BBAD0=$21, A1T0=table, A1B0=$00, DASB0=$00, HDMAEN=ch0, TM=0, screen on. After hdmaEnable() the CPU idles — the PPU rebuilds the gradient from the pointer table on every frame by itself.
|
static |
Indirect payload blocks, one per band: [0][0][color_lo][color_hi].
In HDMA_MODE_2REG_2X the four bytes stream as $2121,$2121,$2122,$2122: CGADD is set to 0 (twice), then the 16-bit BGR555 color is written to CGDATA — i.e. CGRAM color 0, the backdrop. WRAM (bank $00), so the CPU could animate the colors at any time without touching the table.
|
static |
The indirect table: [count][ptr_lo][ptr_hi] per band + terminator.