![]() |
Routines |
| Prev: 45899 | Up: Map | Next: 45995 |
|
Used by the routines at PrintWages and GameOver.
|
||||||||||||
| PrintEarnings | 45900 | PUSH HL | Stash HL, BC and DE on the stack. | |||||||||
| 45901 | PUSH BC | |||||||||||
| 45902 | PUSH DE | |||||||||||
|
Print (or don't print) the equals sign:
|
||||||||||||
| 45903 | LD A,61 | A=61. | ||||||||||
| 45905 | CALL PrintStringColour | Call PrintStringColour. | ||||||||||
|
Move one character block to the right.
|
||||||||||||
| 45908 | INC E | Increment E by one. | ||||||||||
|
Print the GBP pounds sign.
|
||||||||||||
| 45909 | LD C,66 | C=66 (INK: RED, PAPER: BLACK (BRIGHT) ). | ||||||||||
| 45911 | LD A,38 | A=38. | ||||||||||
| 45913 | CALL PrintStringColour | Call PrintStringColour. | ||||||||||
|
Move one character block to the right.
|
||||||||||||
| 45916 | INC E | Increment E by one. | ||||||||||
|
Initialise the leading zero suppression flag. See Flag_MoneyHelper for details.
|
||||||||||||
| 45917 | XOR A | Write 0 to Flag_MoneyHelper. | ||||||||||
| 45918 | LD (45899),A | |||||||||||
|
Set the attribute for all the money digits.
|
||||||||||||
| 45921 | LD C,69 | C=69 (INK: CYAN, PAPER: BLACK (BRIGHT) ). | ||||||||||
|
Money is stored as two digits.
|
||||||||||||
| 45923 | LD B,2 | B=2 (counter). | ||||||||||
|
Fetch the money digit.
|
||||||||||||
| PrintEarnings_Loop | 45925 | LD A,(HL) | A=*HL. | |||||||||
| 45926 | SRL A | Shift and rotate the upper bits to be the lower bits. | ||||||||||
| 45928 | SRL A | |||||||||||
| 45930 | SRL A | |||||||||||
| 45932 | SRL A | |||||||||||
|
Convert the number into ASCII ready for printing to the screen.
Add ASCII "0" - so for example 1 ends up being 1 + 48 = 49 (e.g. "1" in ASCII).
|
||||||||||||
| 45934 | ADD A,48 | A+=48. | ||||||||||
|
If the resulting number is not zero, then it needs to be printed to the screen.
|
||||||||||||
| 45936 | CP 48 | If A is not 48 jump to PrintEarnings_Print_Upper. | ||||||||||
| 45938 | JR NZ,PrintEarnings_Print_Upper | |||||||||||
|
And, if it is zero - print it, unless the leading zero suppression flag says otherwise.
|
||||||||||||
| 45940 | LD A,(45899) | If Flag_MoneyHelper is zero jump to PrintEarnings_Skip. | ||||||||||
| 45943 | OR A | |||||||||||
| 45944 | JR Z,PrintEarnings_Skip | |||||||||||
|
Set the following printed character to be zero:
|
||||||||||||
| 45946 | LD A,48 | A=48. | ||||||||||
| PrintEarnings_Print_Upper | 45948 | CALL PrintStringColour | Call PrintStringColour. | |||||||||
|
Indicate that we have written a digit.
|
||||||||||||
| 45951 | LD A,1 | Write 1 to Flag_MoneyHelper. | ||||||||||
| 45953 | LD (45899),A | |||||||||||
|
Move one character block to the right.
|
||||||||||||
| PrintEarnings_Skip | 45956 | INC E | Increment E by one. | |||||||||
|
Refresh the money byte. We've processed the upper bits already and now we want to process the lower bits.
|
||||||||||||
| 45957 | LD A,(HL) | A=*HL. | ||||||||||
| 45958 | AND %00001111 | Keep only bits 0-3. | ||||||||||
|
As above; add ASCII "0".
|
||||||||||||
| 45960 | ADD A,48 | A+=48. | ||||||||||
|
If the resulting number is not zero, then it needs to be printed to the screen.
|
||||||||||||
| 45962 | CP 48 | If A is not 48 jump to PrintEarnings_Print_Lower. | ||||||||||
| 45964 | JR NZ,PrintEarnings_Print_Lower | |||||||||||
|
Force some output if everything is zero.
|
||||||||||||
| 45966 | LD A,B | If B (the counter) is 1 jump to PrintEarnings_Print_Zero. | ||||||||||
| 45967 | CP 1 | |||||||||||
| 45969 | JR Z,PrintEarnings_Print_Zero | |||||||||||
|
If nothing has been printed yet just skip to the next money byte.
|
||||||||||||
| 45971 | LD A,(45899) | If Flag_MoneyHelper is zero jump to PrintEarnings_NextByte. | ||||||||||
| 45974 | OR A | |||||||||||
| 45975 | JR Z,PrintEarnings_NextByte | |||||||||||
|
||||||||||||
| PrintEarnings_Print_Zero | 45977 | LD A,48 | A=48. | |||||||||
| PrintEarnings_Print_Lower | 45979 | CALL PrintStringColour | Call PrintStringColour. | |||||||||
| 45982 | LD A,1 | Write 1 to Flag_MoneyHelper. | ||||||||||
| 45984 | LD (45899),A | |||||||||||
|
Move one character block to the right.
|
||||||||||||
| PrintEarnings_NextByte | 45987 | INC E | Increment E by one. | |||||||||
|
Move onto the next money byte.
|
||||||||||||
| 45988 | INC HL | Increment HL by one. | ||||||||||
| 45989 | DJNZ PrintEarnings_Loop | Decrease counter by one and loop back to PrintEarnings_Loop until counter is zero. | ||||||||||
|
Restore all the previous registers and return.
|
||||||||||||
| 45991 | POP DE | Restore DE, BC and HL from the stack. | ||||||||||
| 45992 | POP BC | |||||||||||
| 45993 | POP HL | |||||||||||
| 45994 | RET | Return. | ||||||||||
| Prev: 45899 | Up: Map | Next: 45995 |