Prev: 47818 Up: Map Next: 47892
47850: Print Character
Used by the routines at PrintBCDNumber and PrintText.
Prints a character in the screen buffer, using the font whose address is held in FontPointer. A space is drawn as 61, which is blank in this font. The eight rows are written going down the buffer (see ScreenBuffer), 32 bytes apart, and the address is left at the top of the next character.
Input
A The character
HL Address in the screen buffer of the top row
Output
HL Address of the top row of the next character
Stash the registers and turn a space into the font space.
PrintCharacter 47850 PUSH BC Stash BC, DE and the screen buffer address on the stack.
47851 PUSH DE
47852 PUSH HL
47853 CP 32 Jump to PrintCharacter_Glyph if it is not a space.
47855 JR NZ,PrintCharacter_Glyph
47857 LD A,61 Use the font space (61).
Find the glyph.
PrintCharacter_Glyph 47859 LD L,A Set HL to the character.
47860 LD H,0
47862 ADD HL,HL Multiply the character by eight.
47863 ADD HL,HL
47864 ADD HL,HL
Add the font address.
47865 LD DE,(42802) Fetch FontPointer.
47869 ADD HL,DE Add it to get the glyph address.
47870 EX DE,HL Point DE at the glyph.
47871 POP HL Restore the screen buffer address from the stack.
Copy eight rows down the buffer.
47872 LD B,8 Set a counter of 8 rows.
PrintCharacter_Loop 47874 LD A,(DE) Copy a row of the glyph to the buffer.
47875 LD (HL),A
47876 INC DE Move on to the next row of the glyph.
47877 PUSH BC Stash the row counter on the stack.
47878 LD BC,65504 Move HL down a row.
47881 ADD HL,BC
47882 POP BC Restore the row counter from the stack.
47883 DJNZ PrintCharacter_Loop Jump to PrintCharacter_Loop until all eight rows have been written.
Move on to the next character, eight lines up and one byte to the right.
47885 POP DE Restore DE from the stack.
47886 LD BC,257 Move HL on by 0257.
47889 ADD HL,BC
47890 POP BC Restore BC from the stack.
47891 RET Return.
View the equivalent code in;
Prev: 47818 Up: Map Next: 47892