Prev: 40822 Up: Map Next: 41179
41137: 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 41137 PUSH DE Save the address of the character code.
41138 LD A,(DE) Fetch the character code.
41139 PUSH HL Save the screen address.
41140 LD L,A Multiply the character code by eight...
41141 LD H,0
41143 ADD HL,HL
41144 ADD HL,HL
41145 ADD HL,HL
41146 LD E,A ...and subtract the character code to get seven times the code.
41147 LD D,0
41149 AND A
41150 SBC HL,DE
41152 LD DE,40822 Add the address of the font to get the address of the glyph.
41155 ADD HL,DE
41156 EX DE,HL Put the address of the glyph in DE.
41157 POP HL Fetch the screen address.
41158 PUSH HL Save it again.
41159 LD B,7 Set the number of rows of the glyph to seven.
PrintCharacter_Mode 41161 JR PrintCharacter_Mode Jump to PrintCharacter_Row for narrow characters, or to PrintWideCharacter for wide ones.
PrintCharacter_Row 41163 LD A,(DE) Fetch a row of the glyph.
41164 LD (HL),A Draw it.
41165 INC DE Move on to the next row of the glyph.
41166 CALL MoveUpARow Move up a row of the screen.
41169 DJNZ PrintCharacter_Row Loop back to PrintCharacter_Row for each of the seven rows.
41171 EXX Switch to the attribute registers.
41172 LD (HL),B Set the attribute of the character.
41173 INC HL Move on to the next attribute cell.
41174 EXX Switch back to the screen registers.
41175 POP HL Restore the screen address.
41176 INC HL Move on to the next character cell.
41177 POP DE Restore the address of the character code.
41178 RET Return.
View the equivalent code in;
Prev: 40822 Up: Map Next: 41179