Prev: 9234 Up: Map Next: 929C
925E: Add To Score
Adds points to the score of player one and prints the new score. The score is held as three bytes of binary coded decimal at CurrentPlayerState.
Input
BC Points (binary coded decimal)
AddToScore 925E LD HL,$F5E7 Use the score.
9261 LD A,C Add the low byte of the points.
9262 ADD A,(HL)
9263 DAA Adjust for decimal.
9264 LD (HL),A Store the result.
9265 INC HL Move on to the next byte.
9266 LD A,B Add the middle byte of the points.
9267 ADC A,(HL)
9268 DAA Adjust for decimal.
9269 LD (HL),A Store the result.
926A INC HL Move on to the last byte.
926B LD A,$00 Add the carry.
926D ADC A,(HL)
926E DAA Adjust for decimal.
926F LD (HL),A Store the result.
9270 LD DE,$C9F0 Use the text record for the score at HUDText_Player1Score.
9273 LD B,$03 Set a counter for three bytes.
AddToScore_Digits 9275 LD A,(HL) Fetch a byte of the score.
9276 RRCA Shift the top four bits into the bottom four.
9277 RRCA
9278 RRCA
9279 RRCA
927A AND %00001111 Keep them.
927C ADD A,$1A Add 1A to make the character code of the digit.
927E LD (DE),A Store it in the text record.
927F INC DE
9280 LD A,(HL) Fetch the byte of the score again.
9281 AND %00001111 Keep the bottom four bits.
9283 ADD A,$1A Add 1A to make the character code of the digit.
9285 LD (DE),A Store it in the text record.
9286 INC DE
9287 DEC HL Move back to the previous byte of the score.
9288 DJNZ AddToScore_Digits Decrease the counter by one and loop back to AddToScore_Digits until none remain.
928A LD DE,$C9EC Use the text record.
928D EXX Switch registers.
928E PUSH HL Save the registers.
928F PUSH DE
9290 PUSH BC
9291 LD DE,$C9EC Use the text record.
9294 CALL PrintText Print the score.
9297 POP BC Restore the registers.
9298 POP DE
9299 POP HL
929A EXX Switch registers back.
929B RET Return.
Prev: 9234 Up: Map Next: 929C