![]() |
Routines |
Prev: B09A | Up: Map | Next: B0DE |
Prints the players score as a percentage.
|
||||
Print "You have scored ".
|
||||
Print_Scoring | B0A9 | LD HL,$AACE | HL=Messaging_YouHaveScored. | |
B0AC | CALL PrintString | Call PrintString. | ||
B0AF | LD HL,($A7C4) | 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%".
|
||||
B0B2 | LD A,H | Take the first scoring byte and store it in A. | ||
B0B3 | AND %00001111 | Keep only bits 0-3 and jump to Scoring_SecondDigit if the result of this is zero. | ||
B0B5 | JR Z,Scoring_SecondDigit | |||
B0B7 | ADD A,$30 | Convert the number to ASCII by adding 30 and call PrintCharacter. | ||
B0B9 | CALL PrintCharacter | |||
Scoring_SecondDigit | B0BC | LD A,L | Load the second scoring byte into A. | |
B0BD | AND %11110000 | Keep only bits 4-7 and jump to Scoring_PrintTens if the result is non-zero. | ||
B0BF | JR NZ,Scoring_PrintTens | |||
The "tens" digit is zero, so check the "hundreds" digit again to avoid printing "05%" - instead show only "5%".
|
||||
B0C1 | LD A,H | Load the first scoring byte into A again. | ||
B0C2 | AND A | Jump to Scoring_ThirdDigit if no "hundreds" digit was printed. | ||
B0C3 | JR Z,Scoring_ThirdDigit | |||
A "hundreds" digit was printed, so force a "0" to be printed.
|
||||
B0C5 | XOR A | Load 00 into A for printing. | ||
Scoring_PrintTens | B0C6 | RRCA | Shift the bits four positions right. This moves the tens digit into the lower part of the byte for printing. | |
B0C7 | RRCA | |||
B0C8 | RRCA | |||
B0C9 | RRCA | |||
B0CA | ADD A,$30 | Convert the number to ASCII by adding 30 and call PrintCharacter.. | ||
B0CC | CALL PrintCharacter | |||
Lastly, always print the "units".
|
||||
Scoring_ThirdDigit | B0CF | LD A,L | Load the second scoring byte into A. | |
B0D0 | AND %00001111 | Keep only bits 0-3. | ||
B0D2 | ADD A,$30 | Convert the number to ASCII by adding 30 and call PrintCharacter. | ||
B0D4 | CALL PrintCharacter | |||
Print "%.".
|
||||
B0D7 | LD HL,$AADF | HL=Messaging_Percentage. | ||
B0DA | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
B0DD | RET | Return. |
Prev: B09A | Up: Map | Next: B0DE |