Prev: ACFC Up: Map Next: AD78
AD43: Print Scoring
Used by the routines at ABBD, ABDF and GameOver.
Prints the players score as a percentage.
Print "You have scored ".
Print_Scoring AD43 LD HL,$0024 HL=Messaging_YouHaveScored.
AD46 CALL PrintCompressedString Call PrintCompressedString.
AD49 LD HL,($A107) 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%".
AD4C LD A,H Take the first scoring byte and store it in A.
AD4D AND %00001111 Keep only bits 0-3 and jump to Scoring_SecondDigit if the result of this is zero.
AD4F JR Z,Scoring_SecondDigit
AD51 ADD A,$30 Convert the number to ASCII by adding 30 and call PrintCharacter.
AD53 CALL PrintCharacter
Scoring_SecondDigit AD56 LD A,L Load the second scoring byte into A.
AD57 AND %11110000 Keep only bits 4-7 and jump to Scoring_PrintTens if the result is non-zero.
AD59 JR NZ,Scoring_PrintTens
The "tens" digit is zero, so check the "hundreds" digit again to avoid printing "05%" - instead show only "5%".
AD5B LD A,H Load the first scoring 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" to be printed.
AD5F XOR A Load 00 into A for printing.
Scoring_PrintTens AD60 RRCA Shift the bits four positions right. This moves the tens digit into the lower part of the byte for printing.
AD61 RRCA
AD62 RRCA
AD63 RRCA
AD64 ADD A,$30 Convert the number to ASCII by adding 30 and call PrintCharacter.
AD66 CALL PrintCharacter
Lastly, always print the "units".
Scoring_ThirdDigit AD69 LD A,L Load the second scoring byte into A.
AD6A AND %00001111 Keep only bits 0-3.
AD6C ADD A,$30 Convert the number to ASCII by adding 30 and call PrintCharacter.
AD6E CALL PrintCharacter
Print "%.".
AD71 LD HL,$0025 HL=Messaging_Percentage.
AD74 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline.
AD77 RET Return.
Prev: ACFC Up: Map Next: AD78