![]() |
Routines |
| Prev: 876B | Up: Map | Next: 8822 |
|
Used by the routines at PrintWriteACharacterToTheScreen and ScrollLine.
Draws one character with the game's own font.
|
||||||||||||
|
Prints using the custom font.
|
||||||||||||
| Print_ProportionalCharacter | 87C9 | PUSH AF | Save AF, BC, DE and HL, and put A in HL. | |||||||||
| 87CA | PUSH BC | |||||||||||
| 87CB | PUSH DE | |||||||||||
| 87CC | PUSH HL | |||||||||||
| 87CD | LD L,A | |||||||||||
| 87CE | LD H,$00 | |||||||||||
|
Calculate font graphic data address.
|
||||||||||||
| 87D0 | ADD HL,HL | Multiply the offset by 08 and add the table base. | ||||||||||
| 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. | ||||||||||
| Print_ProportionalCharacter_Loop | 87DC | LD A,(DE) | Read the next byte of the font graphic data. | |||||||||
| 87DD | PUSH BC | Jump to Print_ProportionalCharacter_SkipShift if the count in C is zero. | ||||||||||
| 87DE | DEC C | |||||||||||
| 87DF | INC C | |||||||||||
| 87E0 | LD B,$FF | |||||||||||
| 87E2 | JR Z,Print_ProportionalCharacter_SkipShift | |||||||||||
| Print_ProportionalCharacter_Shift | 87E4 | SRL A | Shift the font graphic data right. | |||||||||
| 87E6 | SRL B | Shift the mask data right. | ||||||||||
| 87E8 | DEC C | Drop one from the count. | ||||||||||
| 87E9 | JR NZ,Print_ProportionalCharacter_Shift | Loop back to Print_ProportionalCharacter_Shift until the count in C runs out. | ||||||||||
| Print_ProportionalCharacter_SkipShift | 87EB | LD C,A | Stash the font graphic data in C. | |||||||||
| 87EC | LD A,B | Take the mask that was built in B. | ||||||||||
| 87ED | CPL | Invert the mask so the new pixels replace the old ones. | ||||||||||
| 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 | Jump to Print_ProportionalCharacter_StepDownARow if the count in C is zero. | ||||||||||
| 87F2 | DEC C | |||||||||||
| 87F3 | INC C | |||||||||||
| 87F4 | JR Z,Print_ProportionalCharacter_StepDownARow | |||||||||||
| 87F6 | PUSH BC | Eight pixel bits in a character row. Subtract how many have already been shifted. | ||||||||||
| 87F7 | LD A,$08 | |||||||||||
| 87F9 | SUB C | Take the shift count off 08. | ||||||||||
| 87FA | LD C,A | Copy the result into C. | ||||||||||
| 87FB | LD A,(DE) | Read the font byte. | ||||||||||
| 87FC | LD B,$FF | Start the mask with every bit set. | ||||||||||
| Print_ProportionalCharacter_ShiftTheMask | 87FE | SLA A | Shift the character byte and the mask, and loop until C is zero. | |||||||||
| 8800 | SLA B | |||||||||||
| 8802 | DEC C | |||||||||||
| 8803 | JR NZ,Print_ProportionalCharacter_ShiftTheMask | |||||||||||
| 8805 | LD C,A | Copy the result into C. | ||||||||||
| 8806 | LD A,B | Take the mask into A. | ||||||||||
| 8807 | CPL | Complement A. | ||||||||||
| 8808 | INC HL | Step to the next screen byte. | ||||||||||
| 8809 | AND (HL) | Mask the screen byte and merge the character bits. | ||||||||||
| 880A | OR C | |||||||||||
| 880B | LD (HL),A | Store the merged byte on screen. | ||||||||||
| 880C | DEC HL | Step back one byte through the text. | ||||||||||
| 880D | POP BC | |||||||||||
| Print_ProportionalCharacter_StepDownARow | 880E | INC DE | Step to the next byte beside it. | |||||||||
| 880F | INC H | Step the screen address down one pixel row. | ||||||||||
| 8810 | DJNZ Print_ProportionalCharacter_Loop | Decrease counter by one and loop back to Print_ProportionalCharacter_Loop until counter is zero. | ||||||||||
| 8812 | POP HL | Jump to Print_ProportionalCharacter_StoreTheColumn if the column plus 06 is below 08. | ||||||||||
| 8813 | POP DE | |||||||||||
| 8814 | POP BC | |||||||||||
| 8815 | LD A,C | |||||||||||
| 8816 | ADD A,$06 | |||||||||||
| 8818 | CP $08 | |||||||||||
| 881A | JR C,Print_ProportionalCharacter_StoreTheColumn | |||||||||||
| 881C | SUB $08 | Take 08 off the column plus 06. | ||||||||||
| 881E | INC L | Step to the next character cell on this line. | ||||||||||
| Print_ProportionalCharacter_StoreTheColumn | 881F | LD C,A | Copy the result into C. | |||||||||
| 8820 | POP AF | Restore AF from the stack. | ||||||||||
| 8821 | RET | Return. | ||||||||||
|
View the equivalent code in;
|
||||||||||||
| Prev: 876B | Up: Map | Next: 8822 |