Prev: 46975 Up: Map Next: 47006
46991: Add To Score
Used by the routines at Handler_ChangeRoom and Action_Dig.
Adds the points in A to the two-byte BCD score at Score. The low byte is adjusted with DAA; when that addition carries, the high byte increases by one.
Input
A Points to add
Preserve HL and load the current score from Score.
AddToScore 46991 PUSH HL Stash HL on the stack.
46992 LD HL,(44750) Fetch the BCD score from *Score into HL.
Add the points into the low score byte and adjust for BCD.
46995 ADD A,L Add the points in A to the low score byte in L.
46996 DAA Decimal-adjust A for a BCD score digit.
46997 LD L,A Store the adjusted low byte back in L.
46998 JR NC,AddToScore_Store Jump to AddToScore_Store if the addition did not carry.
The low byte carried, so raise the high score byte.
47000 INC H Increase the high score byte in H by one.
Write the updated score back to Score.
AddToScore_Store 47001 LD (44750),HL Store HL at Score.
47004 POP HL Restore HL from the stack.
47005 RET Return.
View the equivalent code in;
Prev: 46975 Up: Map Next: 47006