Prev: AD34 Up: Map Next: AD78
AD43: Print Scoring
Used by the routines at Action_OfferSave, Action_PrintScore and GameOver.
Prints the player's BCD score from Score as a percentage, skipping leading zeros so "058%" becomes "58%" and "005%" becomes "5%".
Print "You have scored ".
Print_Scoring AD43 LD HL,$0024 HL=Messaging_YouHaveScored.
AD46 CALL PrintCompressedString Call PrintCompressedString to print that compressed string.
AD49 LD HL,($A107) Fetch the BCD score from *Score into HL.
Print the hundreds digit from the high score byte when it is non-zero.
AD4C LD A,H Copy the high score byte into A.
AD4D AND %00001111 Keep the hundreds digit and jump to Scoring_SecondDigit if it is zero.
AD4F JR Z,Scoring_SecondDigit
AD51 ADD A,$30 Convert the digit to ASCII by adding 30 and call PrintCharacter to print it.
AD53 CALL PrintCharacter
Print the tens digit from the low score byte, or a forced zero when hundreds already printed.
Scoring_SecondDigit AD56 LD A,L Copy the low score byte into A.
AD57 AND %11110000 Keep the tens digit and jump to Scoring_PrintTens if it is non-zero.
AD59 JR NZ,Scoring_PrintTens
The tens digit is zero, so skip it unless a hundreds digit was printed (avoid "05%"; show only "5%").
AD5B LD A,H Copy the high score byte into A again.
AD5C AND A Jump to Scoring_ThirdDigit if no hundreds digit was printed.
AD5D JR Z,Scoring_ThirdDigit
A hundreds digit was printed, so force a "0" tens digit.
AD5F XOR A Load 00 into A for printing.
Scoring_PrintTens AD60 RRCA Shift the tens digit into bits 0-3 for printing.
AD61 RRCA
AD62 RRCA
AD63 RRCA
AD64 ADD A,$30 Convert the digit to ASCII by adding 30 and call PrintCharacter to print it.
AD66 CALL PrintCharacter
Always print the units digit.
Scoring_ThirdDigit AD69 LD A,L Copy the low score byte into A.
AD6A AND %00001111 Keep the units digit in bits 0-3.
AD6C ADD A,$30 Convert the digit to ASCII by adding 30 and call PrintCharacter to print it.
AD6E CALL PrintCharacter
Print "%.".
AD71 LD HL,$0025 HL=Messaging_Percentage.
AD74 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline to print that compressed string and a newline.
AD77 RET Return.
View the equivalent code in;
Prev: AD34 Up: Map Next: AD78