Routines |
Prev: DD89 | Up: Map | Next: DDC0 |
|
||||||||||||
Derive pointer to monster score messaging from the given ID.
|
||||||||||||
Handler_AddPoints | DD97 | CP $01 | Jump to AddPoints_CheckLizzy if A is not targeting George (01). | |||||||||
DD99 | JR NZ,AddPoints_CheckLizzy | |||||||||||
George:
|
||||||||||||
DD9B | LD HL,$D066 | HL=Messaging_GeorgeScore. | ||||||||||
DD9E | JR AddPointsToScore | Jump to AddPointsToScore. | ||||||||||
Ralph:
|
||||||||||||
AddPoints_CheckLizzy | DDA0 | LD HL,$D082 | HL=Messaging_RalphScore. | |||||||||
DDA3 | CP $02 | Jump to AddPointsToScore if A is not targeting Lizzy (02) (i.e. keep Ralph which was set above). | ||||||||||
DDA5 | JR NZ,AddPointsToScore | |||||||||||
Lizzy:
|
||||||||||||
DDA7 | LD HL,$D074 | HL=Messaging_LizzyScore. | ||||||||||
Apply points to score.
|
||||||||||||
AddPointsToScore | DDAA | LD A,E | Work out which digit to update. | |||||||||
DDAB | XOR %00000111 | |||||||||||
DDAD | DEC A | |||||||||||
DDAE | LD E,A | |||||||||||
DDAF | LD A,D | A=points to add. | ||||||||||
DDB0 | LD D,$00 | Move HL to the appropriate score digit. | ||||||||||
DDB2 | ADD HL,DE | |||||||||||
AddPointsToScore_Loop | DDB3 | ADD A,(HL) | A=*HL+point value held in A. | |||||||||
DDB4 | LD (HL),A | Write A to *HL. | ||||||||||
DDB5 | CP $3A | Return if A is lower than 3A (ASCII 39 is "9"). | ||||||||||
DDB7 | RET C | |||||||||||
This digit is higher than "9" so subtract 10 to make it a valid number again.
|
||||||||||||
DDB8 | SUB $0A | A-=0A. | ||||||||||
DDBA | 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.
|
||||||||||||
DDBB | DEC HL | Decrease the score pointer by one. | ||||||||||
DDBC | LD A,$01 | A=01. | ||||||||||
DDBE | JR AddPointsToScore_Loop | Jump to AddPointsToScore_Loop. |
Prev: DD89 | Up: Map | Next: DDC0 |