Prev: 36870 Up: Map Next: 36932
36880: Initialise Print Tables
Builds two lookup tables used by the print engine: the column pixel table at Column_Pixel_Lookup_Table (256 two-byte entries mapping each pixel column to a scan-line byte offset and bit mask) and the row address table at 35840 (96 entries mapping pixel rows to scan-line base screen addresses).
InitialisePrintTables 36880 LD HL,35328 HL=Column_Pixel_Lookup_Table (start of the column lookup table).
36883 LD C,128 C=128 (bit mask seed).
36885 XOR A A=0 (initial byte offset).
Each entry is two bytes: the byte offset within the scan line, and the bit mask for that pixel column. Indices 0-255 written to Column_Pixel_Lookup_Table.
InitialisePrintTables_ColLookupLoop 36886 LD (HL),A Write the column lookup table entry: byte offset (A) and bit mask (C).
36887 INC HL
36888 LD (HL),C
36889 INC HL
36890 RRC C Rotate the bit mask right (C) with carry advancing the byte offset (A).
36892 ADC A,0
36894 CP 32 Loop back to InitialisePrintTables_ColLookupLoop until all 256 column lookup table entries are built.
36896 JR NZ,InitialisePrintTables_ColLookupLoop
36898 LD A,64 A=64 (initial screen row high byte).
36900 LD BC,8192 BC=8192 (B=32 row stride, C=32 initial low byte).
36903 LD DE,16456 DE=16456 (D=64 base, E=72 inner loop endpoint).
Scan-line base addresses, low byte then high byte, written to 35840. The loop sweeps 96 entries covering the full screen height.
InitialisePrintTables_RowLookupLoop 36906 LD (HL),C Write the row lookup table entry (low byte C, high byte A).
36907 INC HL
36908 LD (HL),A
36909 INC HL
36910 INC A Increment the high byte and loop back to InitialisePrintTables_RowLookupLoop while less than E.
36911 CP E
36912 JR NZ,InitialisePrintTables_RowLookupLoop
36914 LD A,C Advance the row low byte by the stride.
36915 ADD A,B
36916 LD C,A
36917 LD A,D A=D (reload the high-byte base for the next inner pass).
36918 JR NZ,InitialisePrintTables_RowLookupLoop Loop back to InitialisePrintTables_RowLookupLoop while the row low byte is non-zero.
36920 LD D,E D=E (save the current row endpoint).
36921 LD A,E Compute the next endpoint as E + 8 into A.
36922 ADD A,8
36924 CP 96 Compare the endpoint with 96.
This entry point is used by the routine at 36963.
InitialisePrintTables_RowLookupDone 36926 JR Z,ResetPrintState Jump to ResetPrintState if all rows are built.
36928 LD E,A E=A (update the inner loop endpoint).
36929 LD A,D A=D (reload the high-byte base for the inner loop).
36930 JR InitialisePrintTables_RowLookupLoop Jump back to InitialisePrintTables_RowLookupLoop.
Prev: 36870 Up: Map Next: 36932