![]() |
Routines |
| Prev: 655C | Up: Map | Next: 659B |
|
Used by the routines at Lose_Life, Start_Level, MainMenu, PrintScore, SetUp_NextLevel and PrintMessage_Loop.
|
||||||||||
| PrintCharacter | 6581 | PUSH HL | Stash the screen buffer pointer on the stack. | |||||||
| 6582 | LD DE,($5C36) | DE=*CHARS. | ||||||||
|
Font data starts at character 20 (ASCII "SPACE"), so this allows us to reference the data from a zero index.
|
||||||||||
| 6586 | SUB $20 | Subtract 20 from the ASCII character input. | ||||||||
|
CHARS points 0100 bytes before the actual font data, so incrementing D adds 0100 to compensate.
|
||||||||||
| 6588 | INC D | Increment D by one (add 0100 to DE). | ||||||||
| 6589 | LD L,A | Set the ASCII character to print in HL. | ||||||||
| 658A | LD H,$00 | |||||||||
|
Each ASCII character is 08 bytes of data, so this translates the character ID into the offset.
|
||||||||||
| 658C | ADD HL,HL | Multiply HL by 08 and add the base font address. | ||||||||
| 658D | ADD HL,HL | |||||||||
| 658E | ADD HL,HL | |||||||||
| 658F | ADD HL,DE | |||||||||
| 6590 | EX DE,HL | DE now points to the character font data. | ||||||||
| 6591 | POP HL | Restore the screen buffer pointer from the stack into HL. | ||||||||
| 6592 | LD B,$08 | Set a line counter in B (08 lines in a UDG). | ||||||||
| PrintCharacter_LineLoop | 6594 | LD A,(DE) | Copy the UDG data to the screen buffer. | |||||||
| 6595 | LD (HL),A | |||||||||
| 6596 | INC H | Move down one pixel line in the screen buffer. | ||||||||
| 6597 | INC DE | Move to the next UDG graphic data byte. | ||||||||
| 6598 | DJNZ PrintCharacter_LineLoop | Decrease the line counter by one and loop back to PrintCharacter_LineLoop until all 08 lines of the UDG character have been drawn. | ||||||||
| 659A | RET | Return. | ||||||||
| Prev: 655C | Up: Map | Next: 659B |