Prev: 39125 Up: Map Next: 39174
39135: Print Character
Used by the routines at PrintStringColour and Print_Status_Panel.
Draws a character at a screen address and moves on to the next cell to the right. The attribute is not changed.
The shape of the character comes from the font at Font, which has eight bytes for each code. The address is worked out as 60708 plus eight times the code, so the glyph for code 48 (the digit 0) is the first one of the font. A space (32) is replaced by code 61 which is the blank character of the font.
Before After PrintScreen
character-before character-after
Input
A Character code
HL Screen address
Output
HL Screen address of the cell to the right
PrintScreen 39135 PUSH AF Stash AF on the stack.
39136 PUSH BC Stash BC on the stack.
39137 PUSH DE Stash DE on the stack.
39138 PUSH HL Stash HL on the stack.
39139 CP 32 Jump to PrintScreen_Not_Space if it is not a space.
39141 JR NZ,PrintScreen_Not_Space
39143 LD A,61 Use the code of the blank character (61) instead.
PrintScreen_Not_Space 39145 LD L,A Copy the character code to L.
39146 LD H,0 Clear the high byte of the character code.
39148 ADD HL,HL Multiply the character code by eight.
39149 ADD HL,HL
39150 ADD HL,HL
39151 LD DE,60708 Point at the character set (less 384 as the character codes start at 32).
39154 ADD HL,DE Add the address of the character set.
39155 EX DE,HL Exchange the registers so that DE points at the shape of the character.
39156 POP HL Restore the screen address into HL.
PrintScreen_Write 39157 LD B,8 Set the number of pixel lines in a character to 8.
PrintScreen_Loop 39159 LD A,(DE) Fetch a line of the character.
39160 LD (HL),A Write it to the screen.
39161 INC DE Move on to the next line of the character.
39162 INC H Move down one pixel line.
39163 DJNZ PrintScreen_Loop Decrease the line counter and loop back until all eight lines are done.
39165 POP DE Restore DE from the stack.
39166 POP BC Restore BC from the stack.
39167 LD A,H Fetch the high byte of the screen address.
39168 SUB 8 Subtract 8 to move back to the top of the cell.
39170 LD H,A Store the high byte of the address.
39171 INC L Move on to the next cell to the right.
39172 POP AF Restore AF from the stack.
39173 RET Return.
Prev: 39125 Up: Map Next: 39174