Prev: 35853 Up: Map Next: 38544
38498: Add Score
Adds points to the score of the current player, which is kept as six digits in three bytes of binary coded decimal, and awards an extra life each time the score passes a multiple of 5000 points (see 54809). It then prints the new score.
add-score-before add-score-after
Input
B The highest two digits of the points, in binary coded decimal
C The lowest two digits of the points, in binary coded decimal
AddScore 38498 LD A,(57083) Fetch the highest two digits of the score and keep them in D.
38501 LD D,A
38502 LD A,(57082) Fetch the middle two digits of the score.
38505 LD E,0 Clear the flag in E, which will show whether the score was already past the 5000 point mark.
38507 CP 80 Jump to AddScore_Add if they are below 80.
38509 JR C,AddScore_Add
38511 INC E Set the flag.
AddScore_Add 38512 LD HL,57081 Point HL at the score.
38515 LD A,C Fetch the lowest two digits of the points.
38516 ADD A,(HL) Add the lowest two digits of the score.
38517 DAA Adjust the result to binary coded decimal.
38518 LD (HL),A Store the new lowest two digits.
38519 INC HL Move onto the middle two digits.
38520 LD A,B Fetch the middle two digits of the points.
38521 ADC A,(HL) Add the middle two digits of the score, with the carry.
38522 DAA Adjust the result to binary coded decimal.
38523 LD (HL),A Store the new middle two digits.
38524 INC HL Move onto the highest two digits.
38525 LD A,0 A is 0.
38527 ADC A,(HL) Add the highest two digits of the score, with the carry.
38528 DAA Adjust the result to binary coded decimal.
38529 LD (HL),A Store the new highest two digits.
38530 LD A,E Fetch the flag.
38531 AND A Test it.
38532 JR NZ,PrintScore Jump to PrintScore if the score was already past the 5000 point mark.
38534 LD A,(57082) Fetch the middle two digits of the score.
38537 CP 80 Compare them with 80.
38539 CALL NC,CollectItem_ExtraLife Call 54809 to award an extra life if the score has now passed the 20480 mark.
38542 JR PrintScore_Digits Jump to PrintScore_Digits to print the score.
Prev: 35853 Up: Map Next: 38544