Prev: 29477 Up: Map Next: 29597
29562: Add Points To Score
Used by the routines at KillLeech, SlugWeaponHit and CollectBonusItem.
Adds a number of points to the score of the active player. The points are given as a two byte BCD number and the score is stored as three BCD bytes with the most significant byte first.
Input
BC Points to add to score
Check the active player.
AddPointsToScore 29562 LD A,(24094) If Current_Player is not zero, jump to AddPointsToScore_2UP.
29565 AND A
29566 JR NZ,AddPointsToScore_2UP
Set the score address for 1UP.
29568 LD HL,24071 HL=1UP_Score_3.
29571 JR AddPointsToScore_Start Jump to AddPointsToScore_Start.
Set the score address for 2UP.
AddPointsToScore_2UP 29573 LD HL,24074 HL=2UP_Score_3.
Process adding the points to the appropriate score.
AddPointsToScore_Start 29576 LD A,(HL) A=score byte #3.
29577 ADD A,C Add C to score byte #3 with BCD conversion.
29578 DAA
29579 LD (HL),A Update score byte #3.
29580 DEC HL Move onto the next score byte.
29581 LD A,(HL) A=score byte #2.
29582 ADC A,B Add (with carry) B to score byte #2 with BCD conversion.
29583 DAA
29584 LD (HL),A Update score byte #2.
29585 DEC HL Move onto the next score byte.
29586 LD A,(HL) A=score byte #1.
29587 ADC A,0 Add 0 (i.e. just the carry flag) to score byte #1 with BCD conversion.
29589 DAA
29590 LD (HL),A Update score byte #1.
Check the active player.
29591 LD A,(24094) If Current_Player is not zero (the active player is 2UP), jump to Score_2UP.
29594 AND A
29595 JR NZ,Score_2UP
Prev: 29477 Up: Map Next: 29597