|
| static const u16 | ball_pal [3] = { 0, RGB(31, 28, 4), RGB(31, 16, 2) } |
| | OBJ palette 1 (CGRAM 144-159): transparent, yellow, orange.
|
| u16 | ball_x |
| static u8 | ballpx [256] |
| | The ball, 16 x 16 pixels, and one encoded 8 x 8 tile.
|
| static const u16 | bg_pal [5] |
| | CGRAM 0-4 (BG2 and BG1), 131-132 (the pillar as BG1 reads it).
|
| u8 | extbg_on |
| | Probe oracles: EXTBG on, the ball's x.
|
| static FAR u8 | m7map [128 *128] |
| | The 128 x 128 Mode 7 tilemap, built at run time (16 KB: FAR).
|
| static u8 | m7tiles [3 *64] |
| | Three 8bpp Mode 7 tiles: floor A, floor B, pillar.
|
| static u8 | px [64] |
| static u8 | tilebuf [32] |
Mode 7 EXTBG: one plane split in two layers, a sprite between them.
Mode 7 has a single layer — unless SETINI bit 6 (EXTBG) is set. Then BG2 shows the same plane as BG1 (same tilemap, same pixels, same transform), but reads each pixel's bit 7 as a priority bit and bits 0-6 as its colour. Front to back: sprites 3, sprites 2, BG2 pixels with bit 7 set, sprites 1, BG1, sprites 0, BG2 pixels with bit 7 clear. A priority-1 sprite therefore slides over the floor (bit 7 clear) and under the pillars (bit 7 set) of one and the same Mode 7 plane.
The ball crosses a row of pillars on its own; press A to switch EXTBG off (BG1 shown instead: one layer, the ball in front of everything) and on.
- SNES Concepts
- SETINI ($2133) bit 6 through mode7SetExtBg()
- Mode 7 EXTBG priority: BG2's high pixels above priority-1 sprites, its low pixels below every sprite and below BG1 (hence BG2 alone on screen)
- One pixel, two colours: 0x83 is colour 3 on BG2 (7-bit) and colour 131 on BG1 (8-bit)
- Mode 7 VRAM interleave (dmaCopyVramMode7), a plane and its tiles built at run time in a FAR buffer
- What to Observe
- The yellow ball passes in front of the green floor and behind the grey pillars — the same Mode 7 plane, split by bit 7 of its pixels.
- Press A: EXTBG off, BG1 on screen, the ball now covers the pillars too.
- Modules Used
- console, dma, sprite, input, mode7, tile
- See also
- mode7.h (mode7SetExtBg), docs/tutorials/mode7.md