Prev: 9F76 Up: Map Next: A0DB
A0B1: Print Character
Used by the routine at PrintText.
Prints one character of text. The character is drawn from the bottom row to the top, so the screen address moves up the screen. The instruction at PrintCharacter_Mode is changed by PrintText to either carry straight on or to jump to PrintWideCharacter, which prints wide characters.
Input
B' Attribute
DE Address of the character code
HL Screen address
HL' Attribute address
Output
HL Screen address of the next character
HL' Attribute address of the next character
PrintCharacter A0B1 PUSH DE Save the address of the character code.
A0B2 LD A,(DE) Fetch the character code.
A0B3 PUSH HL Save the screen address.
A0B4 LD L,A Multiply the character code by eight...
A0B5 LD H,$00
A0B7 ADD HL,HL
A0B8 ADD HL,HL
A0B9 ADD HL,HL
A0BA LD E,A ...and subtract the character code to get seven times the code.
A0BB LD D,$00
A0BD AND A
A0BE SBC HL,DE
A0C0 LD DE,$9F76 Add the address of the font to get the address of the glyph.
A0C3 ADD HL,DE
A0C4 EX DE,HL Put the address of the glyph in DE.
A0C5 POP HL Fetch the screen address.
A0C6 PUSH HL Save it again.
A0C7 LD B,$07 Set the number of rows of the glyph to seven.
PrintCharacter_Mode A0C9 JR PrintCharacter_Mode Jump to PrintCharacter_Row for narrow characters, or to PrintWideCharacter for wide ones.
PrintCharacter_Row A0CB LD A,(DE) Fetch a row of the glyph.
A0CC LD (HL),A Draw it.
A0CD INC DE Move on to the next row of the glyph.
A0CE CALL MoveUpARow Move up a row of the screen.
A0D1 DJNZ PrintCharacter_Row Loop back to PrintCharacter_Row for each of the seven rows.
A0D3 EXX Switch to the attribute registers.
A0D4 LD (HL),B Set the attribute of the character.
A0D5 INC HL Move on to the next attribute cell.
A0D6 EXX Switch back to the screen registers.
A0D7 POP HL Restore the screen address.
A0D8 INC HL Move on to the next character cell.
A0D9 POP DE Restore the address of the character code.
A0DA RET Return.
View the equivalent code in;
Prev: 9F76 Up: Map Next: A0DB