Prev: A03D Up: Map Next: A068
A045: Add Points To Score
Used by the routines at Destroy_Creature and Handle_Collectable.
Adds to the score (see Score) and prints the new score at the top of the screen.
The amount is a pair of BCD bytes: B holds the hundreds and C the units. One is taken off C before it is added, so when C is not zero the score goes up by B hundreds plus C minus one. When C is 00 it goes up by B hundreds plus 99.
Before After AddPointsToScore
add-points-before add-points-after
Input
B Hundreds to add, as two BCD digits
C Units to add, as two BCD digits (see above)
AddPointsToScore A045 LD HL,$8EF5 Point at the low byte of the score (Score_Low_Byte).
A048 XOR A Clear A (which also clears the carry flag).
A049 LD A,C Fetch the low byte of the amount.
A04A DEC A Subtract one, in BCD.
A04B DAA
A04C ADD A,(HL) Add the low byte of the score and adjust the result to a BCD value.
A04D DAA
A04E LD (HL),A Store the new low byte of the score.
A04F DEC HL Move on to the middle byte of the score.
A050 LD A,(HL) Fetch the middle byte of the score.
A051 ADC A,B Add the high byte of the amount and the carry.
A052 DAA Adjust the result to a BCD value.
A053 LD (HL),A Store the new middle byte of the score.
A054 DEC HL Move on to the high byte of the score.
A055 LD A,(HL) Fetch the high byte of the score.
A056 ADC A,$00 Add the carry.
A058 DAA Adjust the result to a BCD value.
A059 LD (HL),A Store the new high byte of the score.
A05A LD HL,$0030 Set the x position to 30 and the y position to 00 (30).
A05D LD DE,$8EF3 Point at the score (Score).
A060 LD B,$03 Set the number of digits to print to 03.
A062 CALL ScreenAddress Convert the position into a screen address.
A065 JP Print_Status_Panel_Digits Jump to Print_Status_Panel_Digits to print the digits.
Prev: A03D Up: Map Next: A068