Prev: BB24 Up: Map Next: BB3B
BB29: Add To Score
Used by the routine at ScoreForCreature.
Adds an amount to the score, which is held as three bytes of binary coded decimal, with the most significant byte first, and then draws the new score.
Before After AddToScore and UpdateScreen
add-to-score-before add-to-score-after
Input
BC Amount to add, as four decimal digits
AddToScore BB29 LD HL,$A746 Start at the last byte of the score, Score.
BB2C LD A,(HL) Add the last two digits of the amount to the last two digits of the score.
BB2D ADD A,C
BB2E DAA
BB2F LD (HL),A
BB30 DEC HL Move to the next byte of the score.
BB31 LD A,(HL) Add the next two digits of the amount, and the carry.
BB32 ADC A,B
BB33 DAA
BB34 LD (HL),A
BB35 DEC HL Move to the first byte of the score.
BB36 LD A,(HL) Add the carry to the first two digits of the score.
BB37 ADC A,$00
BB39 DAA
BB3A LD (HL),A
Prev: BB24 Up: Map Next: BB3B