Prev: 34667 Up: Map Next: 34850
34761: Print: Proportional Character
Used by the routines at PrintWriteACharacterToTheScreen and ScrollLine.
Draws one character with the game's own font.
Input
A ASCII value
C Bit offset
HL Target screen location
Prints using the custom font.
Print_ProportionalCharacter 34761 PUSH AF Save AF, BC, DE and HL, and put A in HL.
34762 PUSH BC
34763 PUSH DE
34764 PUSH HL
Calculate font graphic address, some examples would be;
Letter ASCII * 8 Sum Font Graphic Address
"!" 033 264 (033*8)+34594 34858
"A" 065 520 (065*8)+34594 35114
"a" 097 776 (097*8)+34594 35370
34765 LD L,A
34766 LD H,0
Calculate font graphic data address.
34768 ADD HL,HL Multiply the offset by 8 and add the table base.
34769 ADD HL,HL
34770 ADD HL,HL
34771 LD DE,34594
34774 ADD HL,DE
34775 EX DE,HL Store the result in DE, restore the screen location to HL.
34776 POP HL
34777 PUSH HL
34778 LD B,8 Set a counter for 8 lines.
Print_ProportionalCharacter_Loop 34780 LD A,(DE) Read the next byte of the font graphic data.
34781 PUSH BC Jump to Print_ProportionalCharacter_SkipShift if the count in C is zero.
34782 DEC C
34783 INC C
34784 LD B,255
34786 JR Z,Print_ProportionalCharacter_SkipShift
Print_ProportionalCharacter_Shift 34788 SRL A Shift the font graphic data right.
34790 SRL B Shift the mask data right.
34792 DEC C Drop one from the count.
34793 JR NZ,Print_ProportionalCharacter_Shift Loop back to Print_ProportionalCharacter_Shift until the count in C runs out.
Print_ProportionalCharacter_SkipShift 34795 LD C,A Stash the font graphic data in C.
34796 LD A,B Take the mask that was built in B.
34797 CPL Invert the mask so the new pixels replace the old ones.
34798 AND (HL) Merge the mask with the existing data in the screen buffer.
34799 OR C OR the font graphic data.
34800 LD (HL),A Copy the processed font graphic data to the screen.
34801 POP BC Jump to Print_ProportionalCharacter_StepDownARow if the count in C is zero.
34802 DEC C
34803 INC C
34804 JR Z,Print_ProportionalCharacter_StepDownARow
34806 PUSH BC Eight pixel bits in a character row. Subtract how many have already been shifted.
34807 LD A,8
34809 SUB C Take the shift count off 8.
34810 LD C,A Copy the result into C.
34811 LD A,(DE) Read the font byte.
34812 LD B,255 Start the mask with every bit set.
Print_ProportionalCharacter_ShiftTheMask 34814 SLA A Shift the character byte and the mask, and loop until C is zero.
34816 SLA B
34818 DEC C
34819 JR NZ,Print_ProportionalCharacter_ShiftTheMask
34821 LD C,A Copy the result into C.
34822 LD A,B Take the mask into A.
34823 CPL Complement A.
34824 INC HL Step to the next screen byte.
34825 AND (HL) Mask the screen byte and merge the character bits.
34826 OR C
34827 LD (HL),A Store the merged byte on screen.
34828 DEC HL Step back one byte through the text.
34829 POP BC
Print_ProportionalCharacter_StepDownARow 34830 INC DE Step to the next byte beside it.
34831 INC H Step the screen address down one pixel row.
34832 DJNZ Print_ProportionalCharacter_Loop Decrease counter by one and loop back to Print_ProportionalCharacter_Loop until counter is zero.
34834 POP HL Jump to Print_ProportionalCharacter_StoreTheColumn if the column plus 6 is below 8.
34835 POP DE
34836 POP BC
34837 LD A,C
34838 ADD A,6
34840 CP 8
34842 JR C,Print_ProportionalCharacter_StoreTheColumn
34844 SUB 8 Take 8 off the column plus 6.
34846 INC L Step to the next character cell on this line.
Print_ProportionalCharacter_StoreTheColumn 34847 LD C,A Copy the result into C.
34848 POP AF Restore AF from the stack.
34849 RET Return.
View the equivalent code in;
Prev: 34667 Up: Map Next: 34850