![]() |
Routines |
| Prev: CF85 | Up: Map | Next: CFD2 |
|
Used by the routine at AFTER_GAME.
Fills the fifteen pages from MIRROR_TABLE up with tables the sprite drawing needs every turn, run at the start of every game before the menu (AFTER_GAME).
The fourteen above MIRROR_TABLE are the shifted bytes, in pairs: for each shift s from 1 to 7, page $F0 + 2s holds every byte value shifted right s places, and the page above it the bits that fall out into the next byte. Both are stored complemented, so that one value both clears the buffer under a sprite's mask and lets its image in (SPRITE_SHIFTED_RUN). The loop builds them the other way about: it shifts each value left across two bytes, one place at a time, and stores the pair after each shift from the top page down, so shift s is the value shifted left 8 - s.
MIRROR_TABLE itself is every byte value with its bits in the opposite order, which is how a sprite is mirrored (VFLIP_SPRITE_DATA). The layout is Knight Lore's build_lookup_tbls.
|
||||
| BUILD_LOOKUP_TBLS | CFA7 | LD L,$00 | Every byte value, L from 0 | |
| SHIFT_TBL_VALUE | CFA9 | LD D,$00 | DE = the value; H on the top page; seven shifts | |
| CFAB | LD E,L | |||
| CFAC | LD H,$FF | |||
| CFAE | LD B,$07 | |||
| SHIFT_TBL_ENTRY | CFB0 | SLA E | One more place left across D and E | |
| CFB2 | RL D | |||
| CFB4 | LD A,E | E complemented, on this page | ||
| CFB5 | CPL | |||
| CFB6 | LD (HL),A | |||
| CFB7 | DEC H | |||
| CFB8 | LD A,D | D complemented, on the page below | ||
| CFB9 | CPL | |||
| CFBA | LD (HL),A | |||
| CFBB | DEC H | |||
| CFBC | DJNZ SHIFT_TBL_ENTRY | The next shift | ||
| CFBE | INC L | The next value, until L wraps to 0 | ||
| CFBF | JR NZ,SHIFT_TBL_VALUE | |||
| CFC1 | LD HL,MIRROR_TABLE | Then the bit reversal | ||
| REVERSE_TBL_VALUE | CFC4 | LD D,L | Eight bits out of the bottom of D into the bottom of E: E is the value reversed | |
| CFC5 | LD B,$08 | |||
| REVERSE_TBL_BIT | CFC7 | SRL D | ||
| CFC9 | RL E | |||
| CFCB | DJNZ REVERSE_TBL_BIT | |||
| CFCD | LD (HL),E | Store it; the next value, until L wraps to 0 | ||
| CFCE | INC L | |||
| CFCF | JR NZ,REVERSE_TBL_VALUE | |||
| CFD1 | RET | |||
| Prev: CF85 | Up: Map | Next: CFD2 |