Prev: 876B Up: Map Next: 8822
87C9: Print Proper Character
Used by the routines at 869B and ScrollLine.
Input
A ASCII value
C Bit offset
HL Target screen location
Prints using the custom font.
PrintPropChar 87C9 PUSH AF Push AF, BC, DE and HL on the stack.
87CA PUSH BC
87CB PUSH DE
87CC PUSH HL
Calculate font graphic address, some examples would be;
Letter ASCII * 8 Sum Font Graphic Address
"!" $21 $108 ($21 * 8) + $8722 882A
"A" $41 $208 ($41 * 8) + $8722 892A
"a" $61 $308 ($61 * 8) + $8722 8A2A
87CD LD L,A Store the offset for the font graphic data look-up in HL.
87CE LD H,$00
Calculate font graphic data address.
87D0 ADD HL,HL HL=(HL * 8) + $8722
87D1 ADD HL,HL
87D2 ADD HL,HL
87D3 LD DE,$8722
87D6 ADD HL,DE
87D7 EX DE,HL Store the result in DE, restore the screen location to HL.
87D8 POP HL
87D9 PUSH HL
87DA LD B,$08 Set a counter for $08 lines.
PrintPropChar_Loop 87DC LD A,(DE) A=byte of font graphic data
87DD PUSH BC Stash the counter on the stack temporarily.
87DE DEC C
87DF INC C
87E0 LD B,$FF B=$FF as a mask.
87E2 JR Z,PrintPropChar_SkipShift
PrintPropChar_Shift 87E4 SRL A Shift the font graphic data left.
87E6 SRL B Shift the mask data left.
87E8 DEC C Decrease C by one.
87E9 JR NZ,PrintPropChar_Shift Loop back to PrintPropChar_Shift until we've shifted by the number of bits specified in C.
PrintPropChar_SkipShift 87EB LD C,A Stash the font graphic data in C.
87EC LD A,B A=invert the shifted mask.
87ED CPL
87EE AND (HL) Merge the mask with the existing data in the screen buffer.
87EF OR C OR the font graphic data.
87F0 LD (HL),A Copy the processed font graphic data to the screen.
87F1 POP BC Restore the counter off the stack.
87F2 DEC C
87F3 INC C
87F4 JR Z,PrintPropChar_1
87F6 PUSH BC
87F7 LD A,$08
87F9 SUB C
87FA LD C,A
87FB LD A,(DE)
87FC LD B,$FF
PrintPropChar_0 87FE SLA A
8800 SLA B
8802 DEC C
8803 JR NZ,PrintPropChar_0
8805 LD C,A
8806 LD A,B
8807 CPL
8808 INC HL
8809 AND (HL)
880A OR C
880B LD (HL),A
880C DEC HL
880D POP BC
PrintPropChar_1 880E INC DE
880F INC H
8810 DJNZ PrintPropChar_Loop Decrease counter by one and loop back to PrintPropChar_Loop until counter is zero.
8812 POP HL Restore HL, DE and BC off the stack.
8813 POP DE
8814 POP BC
8815 LD A,C
8816 ADD A,$06
8818 CP $08
881A JR C,PrintPropChar_2
881C SUB $08
881E INC L
PrintPropChar_2 881F LD C,A
8820 POP AF Restore AF off the stack.
8821 RET Return.
Prev: 876B Up: Map Next: 8822