![]() |
Routines |
| Prev: AD25 | Up: Map | Next: AD43 |
|
Used by the routine at Action_AddToScore.
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.
|
||||||||
|
Preserve HL and load the current score from Score.
|
||||||||
| AddToScore | AD34 | PUSH HL | Stash HL on the stack. | |||||
| AD35 | LD HL,($A107) | Fetch the BCD score from *Score into HL. | ||||||
|
Add the points into the low score byte and adjust for BCD.
|
||||||||
| AD38 | ADD A,L | Add the points in A to the low score byte in L. | ||||||
| AD39 | DAA | Decimal-adjust A for a BCD score digit. | ||||||
| AD3A | LD L,A | Store the adjusted low byte back in L. | ||||||
| AD3B | JR NC,AddToScore_Store | Jump to AddToScore_Store if the addition did not carry. | ||||||
|
The low byte carried, so raise the high score byte.
|
||||||||
| AD3D | INC H | Increase the high score byte in H by one. | ||||||
|
Write the updated score back to Score.
|
||||||||
| AddToScore_Store | AD3E | LD ($A107),HL | Store HL at Score. | |||||
| AD41 | POP HL | Restore HL from the stack. | ||||||
| AD42 | RET | Return. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: AD25 | Up: Map | Next: AD43 |