Prev: 9006 Up: Map Next: 9044
9010: Initialise Print Tables
Builds two lookup tables used by the print engine: the column pixel table at Column_Pixel_Lookup_Table (0100 two-byte entries mapping each pixel column to a scan-line byte offset and bit mask) and the row address table at 8C00 (60 entries mapping pixel rows to scan-line base screen addresses).
InitialisePrintTables 9010 LD HL,$8A00 HL=Column_Pixel_Lookup_Table (start of the column lookup table).
9013 LD C,$80 C=80 (bit mask seed).
9015 XOR A A=00 (initial byte offset).
Each entry is two bytes: the byte offset within the scan line, and the bit mask for that pixel column. Indices 00-FF written to Column_Pixel_Lookup_Table.
InitialisePrintTables_ColLookupLoop 9016 LD (HL),A Write the column lookup table entry: byte offset (A) and bit mask (C).
9017 INC HL
9018 LD (HL),C
9019 INC HL
901A RRC C Rotate the bit mask right (C) with carry advancing the byte offset (A).
901C ADC A,$00
901E CP $20 Loop back to InitialisePrintTables_ColLookupLoop until all 0100 column lookup table entries are built.
9020 JR NZ,InitialisePrintTables_ColLookupLoop
9022 LD A,$40 A=40 (initial screen row high byte).
9024 LD BC,$2000 BC=2000 (B=20 row stride, C=20 initial low byte).
9027 LD DE,$4048 DE=4048 (D=40 base, E=48 inner loop endpoint).
Scan-line base addresses, low byte then high byte, written to 8C00. The loop sweeps 60 entries covering the full screen height.
InitialisePrintTables_RowLookupLoop 902A LD (HL),C Write the row lookup table entry (low byte C, high byte A).
902B INC HL
902C LD (HL),A
902D INC HL
902E INC A Increment the high byte and loop back to InitialisePrintTables_RowLookupLoop while less than E.
902F CP E
9030 JR NZ,InitialisePrintTables_RowLookupLoop
9032 LD A,C Advance the row low byte by the stride.
9033 ADD A,B
9034 LD C,A
9035 LD A,D A=D (reload the high-byte base for the next inner pass).
9036 JR NZ,InitialisePrintTables_RowLookupLoop Loop back to InitialisePrintTables_RowLookupLoop while the row low byte is non-zero.
9038 LD D,E D=E (save the current row endpoint).
9039 LD A,E Compute the next endpoint as E + 08 into A.
903A ADD A,$08
903C CP $60 Compare the endpoint with 60.
This entry point is used by the routine at 9063.
InitialisePrintTables_RowLookupDone 903E JR Z,ResetPrintState Jump to ResetPrintState if all rows are built.
9040 LD E,A E=A (update the inner loop endpoint).
9041 LD A,D A=D (reload the high-byte base for the inner loop).
9042 JR InitialisePrintTables_RowLookupLoop Jump back to InitialisePrintTables_RowLookupLoop.
Prev: 9006 Up: Map Next: 9044