Prev: 53125 Up: Map Next: 53202
53159: Build Lookup Tables
Used by the routine at InitialiseGame.
Builds the two tables that the sprite routines use. The first is the set of tables of shifted bytes (ShiftedByteTables) in pages 242 to 255: for each shift of one to seven bits there is a page with the inverse of every byte shifted, and a page after it with the inverse of the bits that are pushed out into the next byte. The second is the table of every byte with its bits reversed (ReversedByteTable).
Build the tables of shifted bytes.
BuildLookupTables 53159 LD L,0 Set L to 0.
BuildLookupTables_Shift 53161 LD D,0 Set D to 0.
53163 LD E,L Copy L to E.
53164 LD H,255 Set H to 255.
53166 LD B,7 Set B to 7.
BuildLookupTables_ShiftStep 53168 SLA E Shift E left.
53170 RL D Rotate D left.
53172 LD A,E Fetch E.
53173 CPL Invert it.
53174 LD (HL),A Write it.
53175 DEC H Decrement H.
53176 LD A,D Fetch D.
53177 CPL Invert it.
53178 LD (HL),A Write it.
53179 DEC H Decrement H.
53180 DJNZ BuildLookupTables_ShiftStep Jump to BuildLookupTables_ShiftStep until B is zero.
53182 INC L Increment L.
53183 JR NZ,BuildLookupTables_Shift Jump to BuildLookupTables_Shift if L is not zero.
Build the table of reversed bytes.
53185 LD HL,61696 Point HL at ReversedByteTable.
BuildLookupTables_Reverse 53188 LD D,L Copy L to D.
53189 LD B,8 Set B to 8.
BuildLookupTables_ReverseBit 53191 SRL D Shift D right.
53193 RL E Rotate E left.
53195 DJNZ BuildLookupTables_ReverseBit Jump to BuildLookupTables_ReverseBit until B is zero.
53197 LD (HL),E Write E.
53198 INC L Increment L.
53199 JR NZ,BuildLookupTables_Reverse Jump to BuildLookupTables_Reverse if L is not zero.
53201 RET Return.
View the equivalent code in;
Prev: 53125 Up: Map Next: 53202