![]() |
Routines |
| Prev: 50061 | Up: Map | Next: 51978 |
|
||||||||||||
| PrintNumbers | 51891 | LD A,0 | A=0. | |||||||||
| 51893 | RLD | Extract the first digit into A. | ||||||||||
| 51895 | PUSH AF | Stash the result on the stack. | ||||||||||
| 51896 | CP 0 | Jump to PrintNumbers_BigNumber if A is not 0. | ||||||||||
| 51898 | JR NZ,PrintNumbers_BigNumber | |||||||||||
|
The highest digit is zero, so instead of printing an ASCII zero, print an ASCII space character instead.
|
||||||||||||
| 51900 | LD A,32 | A=ASCII "space" character (32). | ||||||||||
| 51902 | CALL PrintNumbers_Print | Call PrintNumbers_Print. | ||||||||||
|
Move onto the next digit extraction.
|
||||||||||||
| 51905 | POP AF | Restore AF from the stack. | ||||||||||
| 51906 | RLD | Extract the next digit into A. | ||||||||||
| 51908 | PUSH AF | Stash the result on the stack. | ||||||||||
| 51909 | CP 0 | Jump to PrintNumbers_LittleNumber if A is not 0. | ||||||||||
| 51911 | JR NZ,PrintNumbers_LittleNumber | |||||||||||
|
The next digit is also zero, so again print an ASCII space character.
|
||||||||||||
| 51913 | LD A,32 | A=ASCII "space" character (32). | ||||||||||
| 51915 | CALL PrintNumbers_Print | Call PrintNumbers_Print. | ||||||||||
|
Housekeeping, and loop control.
|
||||||||||||
| 51918 | POP AF | Restore AF from the stack. | ||||||||||
| 51919 | RLD | Restore the original byte value back to *HL. | ||||||||||
| 51921 | DEC HL | Decrease the string pointer by one - move to the next number character. | ||||||||||
| 51922 | DJNZ PrintNumbers | Decrease the length counter by one and loop back to PrintNumbers until the counter is zero. | ||||||||||
| 51924 | RET | Return. | ||||||||||
|
Note; the above doesn't jump straight to this, as it's already processing the first RLD result.
|
||||||||||||
| PrintNumbers_Loop | 51925 | LD A,0 | A=0. | |||||||||
| 51927 | RLD | Extract the first digit into A. | ||||||||||
| 51929 | PUSH AF | Stash the result on the stack. | ||||||||||
| PrintNumbers_BigNumber | 51930 | ADD A,48 | A contains the number character to be printed - add ASCII zero to it (48). | |||||||||
| 51932 | CALL PrintNumbers_Print | Call PrintNumbers_Print. | ||||||||||
| 51935 | POP AF | Restore AF from the stack. | ||||||||||
| 51936 | RLD | Extract the next digit into A. | ||||||||||
| 51938 | PUSH AF | Stash the result on the stack. | ||||||||||
| PrintNumbers_LittleNumber | 51939 | ADD A,48 | A contains the number character to be printed - add ASCII zero to it (48). | |||||||||
| 51941 | CALL PrintNumbers_Print | Call PrintNumbers_Print. | ||||||||||
| 51944 | POP AF | Restore AF from the stack. | ||||||||||
| 51945 | RLD | Restore the original byte value back to *HL. | ||||||||||
| 51947 | DEC HL | Decrease the string pointer by one - move to the next number character. | ||||||||||
| 51948 | DJNZ PrintNumbers_Loop | Decrease the length counter by one and loop back to PrintNumbers_Loop until the counter is zero. | ||||||||||
| 51950 | RET | Return. | ||||||||||
|
This is similar in functionality to PrintString. It differs as it doesn't use a terminator rather the length is known.
|
||||||||||||
| PrintNumbers_Print | 51951 | PUSH HL | Stash pointer to the string and the length counter on the stack. | |||||||||
| 51952 | PUSH BC | |||||||||||
|
Create an offset in HL using A - which contains the number value we want to print.
|
||||||||||||
| 51953 | LD L,A | HL=A*$08 (as each font character is made up of 8 bytes). | ||||||||||
| 51954 | LD H,0 | |||||||||||
| 51956 | ADD HL,HL | |||||||||||
| 51957 | ADD HL,HL | |||||||||||
| 51958 | ADD HL,HL | |||||||||||
| 51959 | LD BC,58391 | BC=Font. | ||||||||||
| 51962 | DEC B | Decrease B by one. | ||||||||||
| 51963 | ADD HL,BC | HL+=BC. | ||||||||||
| 51964 | PUSH DE | Stash the current screen buffer pointer on the stack. | ||||||||||
| 51965 | LD B,8 | B=8 (because each font character is 8 bytes). | ||||||||||
| PrintNumbers_Print_Loop | 51967 | LD A,(HL) | Fetch a byte from the custom font. | |||||||||
| 51968 | LD (DE),A | Write the byte to the screen buffer. | ||||||||||
| 51969 | INC HL | Move onto the next byte of the custom font. | ||||||||||
| 51970 | INC D | Adjust the screen buffer position down one row. | ||||||||||
| 51971 | DJNZ PrintNumbers_Print_Loop | Decrease the byte counter by one and loop back to PrintNumbers_Print_Loop until the counter is zero (all 8 bytes have been copied to the screen buffer). | ||||||||||
| 51973 | POP DE | Restore the original screen buffer pointer from the stack. | ||||||||||
| 51974 | INC DE | Move the screen buffer pointer right one character block ready for printing the next character. | ||||||||||
| 51975 | POP BC | Restore the length counter and pointer to the string from the stack. | ||||||||||
| 51976 | POP HL | |||||||||||
| 51977 | RET | Return. | ||||||||||
| Prev: 50061 | Up: Map | Next: 51978 |