Prev: 98D5 Up: Map Next: 9906
98DF: 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 ED24 plus eight times the code, so the glyph for code 30 (the digit 0) is the first one of the font. A space (20) is replaced by code 3D 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 98DF PUSH AF Stash AF on the stack.
98E0 PUSH BC Stash BC on the stack.
98E1 PUSH DE Stash DE on the stack.
98E2 PUSH HL Stash HL on the stack.
98E3 CP $20 Jump to PrintScreen_Not_Space if it is not a space.
98E5 JR NZ,PrintScreen_Not_Space
98E7 LD A,$3D Use the code of the blank character (3D) instead.
PrintScreen_Not_Space 98E9 LD L,A Copy the character code to L.
98EA LD H,$00 Clear the high byte of the character code.
98EC ADD HL,HL Multiply the character code by eight.
98ED ADD HL,HL
98EE ADD HL,HL
98EF LD DE,$ED24 Point at the character set (less 0180 as the character codes start at 20).
98F2 ADD HL,DE Add the address of the character set.
98F3 EX DE,HL Exchange the registers so that DE points at the shape of the character.
98F4 POP HL Restore the screen address into HL.
PrintScreen_Write 98F5 LD B,$08 Set the number of pixel lines in a character to 08.
PrintScreen_Loop 98F7 LD A,(DE) Fetch a line of the character.
98F8 LD (HL),A Write it to the screen.
98F9 INC DE Move on to the next line of the character.
98FA INC H Move down one pixel line.
98FB DJNZ PrintScreen_Loop Decrease the line counter and loop back until all eight lines are done.
98FD POP DE Restore DE from the stack.
98FE POP BC Restore BC from the stack.
98FF LD A,H Fetch the high byte of the screen address.
9900 SUB $08 Subtract 08 to move back to the top of the cell.
9902 LD H,A Store the high byte of the address.
9903 INC L Move on to the next cell to the right.
9904 POP AF Restore AF from the stack.
9905 RET Return.
Prev: 98D5 Up: Map Next: 9906