Prev: C37D Up: Map Next: C415
C388: Print Character
Used by the routines at PrintDateBar, C1FC, C249, C271, C2BA and C316.
Input
A Character to print
HL Screen buffer address
PrintCharacter C388 PUSH AF Stash AF, BC, DE and HL on the stack.
C389 PUSH BC
C38A PUSH DE
C38B PUSH HL
C38C LD L,A Load the character into HL.
C38D LD H,$00
C38F ADD HL,HL Multiply by 08 (each font character is 08 bytes of data).
C390 ADD HL,HL
C391 ADD HL,HL
C392 LD DE,$3C00 DE+=3C00 (CHARSET-0100).
C395 ADD HL,DE
C396 EX DE,HL
C397 POP HL Restore the screen buffer address from the stack.
C398 PUSH HL But stash a copy of it back on the stack.
C399 LD B,$08 Set a counter in B for 08 bytes of the font data.
PrintCharacter_0 C39B LD A,(DE) A=*DE.
C39C PUSH BC Stash BC and AF on the stack.
C39D PUSH AF
C39E DEC C Decrease C by one.
C39F INC C Increment C by one.
C3A0 LD B,$FF B=FF.
C3A2 JR Z,PrintCharacter_2 Jump to PrintCharacter_2 if C is zero.
PrintCharacter_1 C3A4 SRL A Shift A right.
C3A6 SRL B Shift B right.
C3A8 DEC C Decrease C by one.
C3A9 JR NZ,PrintCharacter_1 Jump to PrintCharacter_1 if C is not zero.
PrintCharacter_2 C3AB LD C,A C=A.
C3AC LD A,B A=B.
C3AD CPL Invert the bits in A.
C3AE AND (HL) Merge the bits from *HL.
C3AF OR C Set the bits from C.
C3B0 LD (HL),A Write A to *HL.
C3B1 POP AF Restore AF and BC from the stack.
C3B2 POP BC
C3B3 DEC C Decrease C by one.
C3B4 INC C Increment C by one.
C3B5 JR Z,PrintCharacter_4 Jump to PrintCharacter_4 if C is equal to C.
C3B7 PUSH BC Stash BC and AF on the stack.
C3B8 PUSH AF
C3B9 LD A,$08 A=08.
C3BB SUB C A-=C.
C3BC LD C,A C=A.
C3BD POP AF Restore AF from the stack.
C3BE LD B,$FF B=FF.
PrintCharacter_3 C3C0 SLA A Shift A left (with carry).
C3C2 SLA B Shift B left (with carry).
C3C4 DEC C Decrease C by one.
C3C5 JR NZ,PrintCharacter_3 Jump to PrintCharacter_3 if C is not equal to C.
C3C7 LD C,A C=A.
C3C8 LD A,B A=B.
C3C9 CPL Invert the bits in A.
C3CA INC HL Increment HL by one.
C3CB AND (HL) Merge the bits from *HL.
C3CC OR C Set the bits from C.
C3CD LD (HL),A Write A to *HL.
C3CE DEC HL Decrease HL by one.
C3CF POP BC Restore BC from the stack.
PrintCharacter_4 C3D0 INC DE Increment DE by one.
C3D1 INC H Increment H by one.
C3D2 DJNZ PrintCharacter_0 Decrease counter by one and loop back to PrintCharacter_0 until counter is zero.
C3D4 POP HL Restore HL, DE and BC from the stack.
C3D5 POP DE
C3D6 POP BC
C3D7 LD A,C A=C.
C3D8 ADD A,$07 A+=07.
C3DA CP $08 Compare A with 08.
C3DC JR C,PrintCharacter_5 Jump to PrintCharacter_5 if A is less than 08.
C3DE SUB $08 A-=08.
C3E0 INC L Increment L by one.
PrintCharacter_5 C3E1 LD C,A C=A.
C3E2 POP AF Restore AF from the stack.
C3E3 RET Return.
This entry point is used by the routine at C316.
PrintCharacter_6 C3E4 LD A,($A008) A=*A008.
C3E7 AND A Set flags.
C3E8 RET Z Return if L is equal to A.
C3E9 PUSH HL Stash HL, DE and BC on the stack.
C3EA PUSH DE
C3EB PUSH BC
C3EC LD HL,$4000 HL=4000.
C3EF LD B,$08 B=08.
PrintCharacter_7 C3F1 PUSH BC Stash BC and HL on the stack.
C3F2 PUSH HL
C3F3 CALL PrintCharacter_8 Call PrintCharacter_8.
C3F6 POP HL Restore HL from the stack.
C3F7 INC H Increment H by one.
C3F8 POP BC Restore BC from the stack.
C3F9 DJNZ PrintCharacter_7 Decrease counter by one and loop back to PrintCharacter_7 until counter is zero.
C3FB LD A,$04 A=04.
C3FD OUT ($FB),A OUT FB
C3FF POP BC Restore BC, DE and HL from the stack.
C400 POP DE
C401 POP HL
C402 RET Return.
PrintCharacter_8 C403 LD A,B A=B.
C404 CP $03 Compare A with 03.
C406 SBC A,A A-=A.
C407 AND %00000010 Keep only bits 1.
C409 OUT ($FB),A OUT FB
C40B LD D,A D=A.
PrintCharacter_9 C40C IN A,($FB) A=byte from port FB.
C40E ADD A,A A+=A.
C40F RET M Return if A is lower than 03.
C410 JR NC,PrintCharacter_9 Jump to PrintCharacter_9 if A is greater than or equal to 03.
C412 JP $0F12 Jump to COPY_LINE#0F12.
Prev: C37D Up: Map Next: C415