Prev: 44340 Up: Map Next: 44408
44355: Print Scoring
Used by the routines at Action_OfferSave, Action_PrintScore and GameOver.
Prints the players score as a percentage.
Print "You have scored ".
Print_Scoring 44355 LD HL,36 HL=Messaging_YouHaveScored.
44358 CALL PrintCompressedString Call PrintCompressedString.
44361 LD HL,(41223) 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%".
44364 LD A,H Take the first scoring byte and store it in A.
44365 AND %00001111 Keep the hundreds digit and jump to Scoring_SecondDigit if it is zero.
44367 JR Z,Scoring_SecondDigit
44369 ADD A,48 Convert the number to ASCII by adding 48 and call PrintCharacter.
44371 CALL PrintCharacter
Scoring_SecondDigit 44374 LD A,L Load the second scoring byte into A.
44375 AND %11110000 Keep the tens digit and jump to Scoring_PrintTens if it is non-zero.
44377 JR NZ,Scoring_PrintTens
The "tens" digit is zero, so check the "hundreds" digit again to avoid printing "05%" - instead show only "5%".
44379 LD A,H Load the first scoring byte into A again.
44380 AND A Jump to Scoring_ThirdDigit if no "hundreds" digit was printed.
44381 JR Z,Scoring_ThirdDigit
A "hundreds" digit was printed, so force a "0" to be printed.
44383 XOR A Load 0 into A for printing.
Scoring_PrintTens 44384 RRCA Shift the bits four positions right. This moves the tens digit into the lower part of the byte for printing.
44385 RRCA
44386 RRCA
44387 RRCA
44388 ADD A,48 Convert the number to ASCII by adding 48 and call PrintCharacter.
44390 CALL PrintCharacter
Lastly, always print the "units".
Scoring_ThirdDigit 44393 LD A,L Load the second scoring byte into A.
44394 AND %00001111 Keep the units digit in bits 0-3.
44396 ADD A,48 Convert the number to ASCII by adding 48 and call PrintCharacter.
44398 CALL PrintCharacter
Print "%.".
44401 LD HL,37 HL=Messaging_Percentage.
44404 CALL PrintCompressedStringAndNewline Call PrintCompressedStringAndNewline.
44407 RET Return.
View the equivalent code in;
Prev: 44340 Up: Map Next: 44408