Prev: 58064 Up: Map Next: 58166
58106: Character/text printing
Used by the routine at 58064.
Input
A Offset for letter to print, e.g. 0 = A, 1 = B (see 27940)
This routine is used at 57538 to print a single text character. It allows for text to be printed at any pixel line (rather than starting from the top of an 8x8 pixel square).
The character set text graphics are stored at 27940.
58106 LD HL,27940 Start address of character set ('A')
58109 LD D,0 Load DE with offset of character (0 = A, 1 = B, 2 = C etc.)
58111 LD E,A Outer loop counter
58112 LD B,8 8 bytes in each character
58114 ADD HL,DE Add offset to base address
58115 DJNZ 58114 ...and repeat 8 times (x8) to find the address of the character to print
58117 EX DE,HL Character address now stored in DE
58118 LD HL,(60068) ...Get screen display address (???) to print text at
58121 LD C,H Store high byte in C for retrieval later
58122 LD B,8 8 pixel row bytes to print
58124 LD A,(DE) Get first byte of letter graphic
58125 INC DE Move to the next byte for later
58126 LD (HL),A Print byte onto screen
58127 LD A,H Get the high byte of the screen address
58128 AND 7 Look at the pixel row of the line (0-7)
58130 INC A Increment and check if it's gone over to the next character row
58131 CP 8
58133 JR NZ,58145
58135 LD A,H Get the high byte of the display address
58136 AND 248 Sets the pixel line in the character row to 0 as we're into a new character row
58138 LD H,A ...and restore back to H (high byte of display address)
58139 LD A,L Move the low byte of the display address to the next character row down, and store
58140 ADD A,32
58142 LD L,A
58143 JR 58146 INC H in next line of code can now be skipped as HL contains the correct display address position
Jump in from 58133, where the pixel row is still 0-7 (same character row) so can just increment the high byte of display address (H register) to get to the right place:
58145 INC H
58146 DJNZ 58124 Repeat printing pixel rows until all 8 bytes of the character are printed on screen
58148 LD A,L Restore L (the low byte of the screen address) to its starting column position + 1, i.e. 1 character to the right, ready to print the next letter
58149 SUB 31
58151 LD L,A
58152 LD H,C ..and also restore H (the high byte) to its starting position
58153 LD (60068),HL ...and store display address position ready to print next character.
Letter/character has been printed
58156 LD A,(60067) Decrement the 'number-of-letters-to-print' counter (columns) (I think)
58159 DEC A
58160 LD (60067),A
58163 JR NZ,58080 Continue printing until finished
58165 RET
Prev: 58064 Up: Map Next: 58166