Prev: BACA Up: Map Next: BB14
BAEA: 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 3D, which is blank in this font. The eight rows are written going down the buffer (see ScreenBuffer), 20 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 BAEA PUSH BC Stash BC, DE and the screen buffer address on the stack.
BAEB PUSH DE
BAEC PUSH HL
BAED CP $20 Jump to PrintCharacter_Glyph if it is not a space.
BAEF JR NZ,PrintCharacter_Glyph
BAF1 LD A,$3D Use the font space (3D).
Find the glyph.
PrintCharacter_Glyph BAF3 LD L,A Set HL to the character.
BAF4 LD H,$00
BAF6 ADD HL,HL Multiply the character by eight.
BAF7 ADD HL,HL
BAF8 ADD HL,HL
Add the font address.
BAF9 LD DE,($A732) Fetch FontPointer.
BAFD ADD HL,DE Add it to get the glyph address.
BAFE EX DE,HL Point DE at the glyph.
BAFF POP HL Restore the screen buffer address from the stack.
Copy eight rows down the buffer.
BB00 LD B,$08 Set a counter of 08 rows.
PrintCharacter_Loop BB02 LD A,(DE) Copy a row of the glyph to the buffer.
BB03 LD (HL),A
BB04 INC DE Move on to the next row of the glyph.
BB05 PUSH BC Stash the row counter on the stack.
BB06 LD BC,$FFE0 Move HL down a row.
BB09 ADD HL,BC
BB0A POP BC Restore the row counter from the stack.
BB0B 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.
BB0D POP DE Restore DE from the stack.
BB0E LD BC,$0101 Move HL on by 0101.
BB11 ADD HL,BC
BB12 POP BC Restore BC from the stack.
BB13 RET Return.
View the equivalent code in;
Prev: BACA Up: Map Next: BB14