Prev: B08A Up: Map Next: B0A9
B09A: Add To Score
Input
A Points to add
Preserve HL and load the current score from Score.
AddToScore B09A PUSH HL Stash HL on the stack.
B09B LD HL,($A7C4) Fetch the BCD score from *Score into HL.
Add the points into the low score byte and adjust for BCD.
B09E ADD A,L Add the points in A to the low score byte in L.
B09F DAA Decimal-adjust A for a BCD score digit.
B0A0 LD L,A Store the adjusted low byte back in L.
B0A1 JR NC,AddToScore_Store Jump to AddToScore_Store if the addition did not carry.
The low byte carried, so raise the high score byte.
B0A3 INC H Increase the high score byte in H by one.
Write the updated score back to Score.
AddToScore_Store B0A4 LD ($A7C4),HL Store HL at Score.
B0A7 POP HL Restore HL from the stack.
B0A8 RET Return.
View the equivalent code in;
Prev: B08A Up: Map Next: B0A9