| ← BBE2 | Map | BC23 → |
BC01: Horizontally mirror the object sprite bank in place
|
Flips the object sprite bank left-to-right in place so every sprite faces the active play side. The mirror is its own inverse.
|
|||
| mirror_sprite_bank | BC01 | LD HL,sprite_mirror_lut | Hold the bit-reverse table's page in the alternate bank for byte translation. |
| BC04 | EXX | ||
| BC05 | LD HL,slot_visor_1 | Mirror the sprite bank in place, from its base. | |
| BC08 | LD BC,$0590 | Walk the whole sprite bank, two bytes at a time. | |
| mirror_row | BC0B | LD D,(HL) | Read the row's two bytes. |
| BC0C | INC HL | ||
| BC0D | LD E,(HL) | ||
| BC0E | DEC HL | ||
| BC0F | PUSH DE | Pass the pair into the alternate bank for table lookup. | |
| BC10 | EXX | ||
| BC11 | POP DE | ||
|
The bit-reverse table is 256 bytes in the page at the tile-glyph base. The lowest tile codes are never written to the tile map, so those bytes are free for it. The tile glyphs begin one page higher.
|
|||
| BC12 | LD L,D | Mirror each byte through the bit-reverse table. | |
| BC13 | LD D,(HL) | ||
| BC14 | LD L,E | ||
| BC15 | LD E,(HL) | ||
| BC16 | PUSH DE | Carry the mirrored bytes back into the sprite bank. | |
| BC17 | EXX | ||
| BC18 | POP DE | ||
| BC19 | LD (HL),E | Write the mirrored bytes back in swapped order and advance to the next row. | |
| BC1A | INC HL | ||
| BC1B | LD (HL),D | ||
| BC1C | INC HL | ||
| BC1D | DEC BC | Loop until all rows are mirrored. | |
| BC1E | LD A,B | ||
| BC1F | OR C | ||
| BC20 | JR NZ,mirror_row | ||
| BC22 | RET | ||
| ← BBE2 | Map | BC23 → |
