Prev: 56713 Up: Map Next: 56768
56727: Handler: Add Points To Score
Used by the routines at 62544, 62694 and Handler_CollisionMonsters.
Input
A Monster ID
D Points to add to score digit
E Digit to update
Derive pointer to monster score messaging from the given ID.
Handler_AddPoints 56727 CP 1 Jump to AddPoints_CheckLizzy if A is not targeting George (1).
56729 JR NZ,AddPoints_CheckLizzy
George:
56731 LD HL,53350 HL=Messaging_GeorgeScore.
56734 JR AddPointsToScore Jump to AddPointsToScore.
Ralph:
AddPoints_CheckLizzy 56736 LD HL,53378 HL=Messaging_RalphScore.
56739 CP 2 Jump to AddPointsToScore if A is not targeting Lizzy (2) (i.e. keep Ralph which was set above).
56741 JR NZ,AddPointsToScore
Lizzy:
56743 LD HL,53364 HL=Messaging_LizzyScore.
Apply points to score.
AddPointsToScore 56746 LD A,E Work out which digit to update.
56747 XOR %00000111
56749 DEC A
56750 LD E,A
56751 LD A,D A=points to add.
56752 LD D,0 Move HL to the appropriate score digit.
56754 ADD HL,DE
AddPointsToScore_Loop 56755 ADD A,(HL) A=*HL+point value held in A.
56756 LD (HL),A Write A to *HL.
56757 CP 58 Return if A is lower than 58 (ASCII 57 is "9").
56759 RET C
This digit is higher than "9" so subtract 10 to make it a valid number again.
56760 SUB 10 A-=10.
56762 LD (HL),A Update the current score digit.
We work backwards here, as the smaller units are on the right-hand side. So now we want to add "1" to the next digit. At it's simplest; 19+01 would first set "10" then move the pointer to the "tens" and add one to it to equal 20.
56763 DEC HL Decrease the score pointer by one.
56764 LD A,1 A=1.
56766 JR AddPointsToScore_Loop Jump to AddPointsToScore_Loop.
Prev: 56713 Up: Map Next: 56768