Prev: BACA Up: Map Next: BB14
BAEA: Print a character into the screen buffer
Used by the routines at ADD_SCORE and TEXT_ATTR_ADDR.
A character is eight bytes from FONT_BASE plus eight times its code, the top row first; they overwrite eight rows of the buffer going down from HL (32 bytes a row, down being towards the start of the buffer). HL comes back one byte to the right, on the same top row, ready for the next character. A space is printed as code $3D.
For text FONT_BASE is 384 bytes below the font (PRINT_TEXT_SINGLE_COLOUR), so the codes $30 to $5A land in it; for numbers it is the font itself (PRINT_BCD, in ADD_SCORE), so that digits are codes 0 to 9.
Input
A the code
HL the buffer address of the character's top row
Output
HL one byte to the right
PRINT_CHAR BAEA PUSH BC
BAEB PUSH DE
BAEC PUSH HL
BAED CP $20 a space is code $3D
BAEF JR NZ,PRINT_CHAR_0
BAF1 LD A,$3D
PRINT_CHAR_0 BAF3 LD L,A DE = FONT_BASE + 8 * the code
BAF4 LD H,$00
BAF6 ADD HL,HL
BAF7 ADD HL,HL
BAF8 ADD HL,HL
BAF9 LD DE,(FONT_BASE)
BAFD ADD HL,DE
BAFE EX DE,HL
BAFF POP HL
BB00 LD B,$08 eight rows, each written 32 bytes below the one before
PRINT_CHAR_1 BB02 LD A,(DE)
BB03 LD (HL),A
BB04 INC DE
BB05 PUSH BC
BB06 LD BC,$FFE0
BB09 ADD HL,BC
BB0A POP BC
BB0B DJNZ PRINT_CHAR_1
BB0D POP DE
BB0E LD BC,$0101 back up the eight rows and one byte right
BB11 ADD HL,BC
BB12 POP BC
BB13 RET
Prev: BACA Up: Map Next: BB14