![]() |
Routines |
Prev: 45210 | Up: Map | Next: 45278 |
Prints the players score as a percentage.
|
||||
Print "You have scored ".
|
||||
Print_Scoring | 45225 | LD HL,43726 | HL=Messaging_YouHaveScored. | |
45228 | CALL PrintString | Call PrintString. | ||
45231 | LD HL,(42948) | HL=*Score. | ||
Evaluate the first byte to see if it needs printing at all.
So don't show "058%" - instead show "58%".
This particular check is for the first character "1" to see if the score is printing "100%".
|
||||
45234 | LD A,H | Take the first scoring byte and store it in A. | ||
45235 | AND %00001111 | Keep only bits 0-3 and jump to Scoring_SecondDigit if the result of this is zero. | ||
45237 | JR Z,Scoring_SecondDigit | |||
45239 | ADD A,48 | Convert the number to ASCII by adding 48 and call PrintCharacter. | ||
45241 | CALL PrintCharacter | |||
Scoring_SecondDigit | 45244 | LD A,L | Load the second scoring byte into A. | |
45245 | AND %11110000 | Keep only bits 4-7 and jump to Scoring_PrintTens if the result is non-zero. | ||
45247 | JR NZ,Scoring_PrintTens | |||
The "tens" digit is zero, so check the "hundreds" digit again to avoid printing "05%" - instead show only "5%".
|
||||
45249 | LD A,H | Load the first scoring byte into A again. | ||
45250 | AND A | Jump to Scoring_ThirdDigit if no "hundreds" digit was printed. | ||
45251 | JR Z,Scoring_ThirdDigit | |||
A "hundreds" digit was printed, so force a "0" to be printed.
|
||||
45253 | XOR A | Load 0 into A for printing. | ||
Scoring_PrintTens | 45254 | RRCA | Shift the bits four positions right. This moves the tens digit into the lower part of the byte for printing. | |
45255 | RRCA | |||
45256 | RRCA | |||
45257 | RRCA | |||
45258 | ADD A,48 | Convert the number to ASCII by adding 48 and call PrintCharacter.. | ||
45260 | CALL PrintCharacter | |||
Lastly, always print the "units".
|
||||
Scoring_ThirdDigit | 45263 | LD A,L | Load the second scoring byte into A. | |
45264 | AND %00001111 | Keep only bits 0-3. | ||
45266 | ADD A,48 | Convert the number to ASCII by adding 48 and call PrintCharacter. | ||
45268 | CALL PrintCharacter | |||
Print "%.".
|
||||
45271 | LD HL,43743 | HL=Messaging_Percentage. | ||
45274 | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
45277 | RET | Return. |
Prev: 45210 | Up: Map | Next: 45278 |