Prev: B278 Up: Map Next: B2C5
B29A: Build the drawing tables
Used by the routine at START.
Fills the fifteen pages from REVERSED up with tables the sprite drawing needs every turn, run at every new game (START).
The fourteen from SHIFTED7 up 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 screen under a sprite's mask and lets its image in. 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.
REVERSED itself is every byte value with its bits in the opposite order, which is how a sprite is mirrored (FIND_SPRITE). The layout is Knight Lore's.
MAKE_TABLES B29A LD L,$00 Every byte value, L from 0
MAKE_TABLES_0 B29C LD D,$00 DE = the value; H on the top page; seven shifts
B29E LD E,L
B29F LD H,$FF
B2A1 LD B,$07
MAKE_TABLES_1 B2A3 SLA E One more place left across D and E
B2A5 RL D
B2A7 LD A,E E complemented, on this page
B2A8 CPL
B2A9 LD (HL),A
B2AA DEC H D complemented, on the page below
B2AB LD A,D
B2AC CPL
B2AD LD (HL),A
B2AE DEC H
B2AF DJNZ MAKE_TABLES_1 The next shift
B2B1 INC L The next value, until L wraps to 0
B2B2 JR NZ,MAKE_TABLES_0
B2B4 LD HL,REVERSED Then the bit reversal
MAKE_TABLES_2 B2B7 LD D,L Eight bits out of the bottom of D into the bottom of E: E is the value reversed
B2B8 LD B,$08
MAKE_TABLES_3 B2BA SRL D
B2BC RL E
B2BE DJNZ MAKE_TABLES_3
B2C0 LD (HL),E Store it; the next value, until L wraps to 0
B2C1 INC L
B2C2 JR NZ,MAKE_TABLES_2
B2C4 RET
Prev: B278 Up: Map Next: B2C5