Prev: 62694 Up: Map Next: 63257
63135: Handler: Projectiles
Used by the routine at RunHandlers.
Handler_Projectiles 63135 LD B,6 B=6 (number of possible projectiles).
63137 LD HL,54029 HL=Table_Projectiles.
Handler_Projectiles_Loop 63140 PUSH BC Stash current projectile on the stack.
63141 LD A,(HL) Jump to Collision_Projectiles_Next if this projectile is not active.
63142 AND A
63143 JR Z,Collision_Projectiles_Next
This projectile is active so let's process it.
63145 INC A Increment A by one.
63146 LD (HL),A Write A to *HL.
63147 LD E,A E=A.
63148 INC HL Increment HL by one.
63149 LD B,(HL) B=*HL.
63150 PUSH HL Stash HL on the stack.
63151 INC HL Increment HL by one.
63152 LD C,(HL) C=*HL.
63153 CP 65 Jump to Handler_Projectiles_0 if A is higher than 65.
63155 JR NC,Handler_Projectiles_0
63157 LD HL,51369 HL=51369.
63160 JR Handler_Projectiles_1 Jump to Handler_Projectiles_1.
Handler_Projectiles_0 63162 LD HL,51350 HL=51350.
Handler_Projectiles_1 63165 LD A,1 Write 1 to *54271.
63167 LD (54271),A
63170 LD A,E A=E.
63171 AND %00111111 Keep only bits 0-5.
63173 DEC A Decrease A by one.
63174 CALL 60250 Call 60250.
63177 EX AF,AF' Exchange the AF register with the shadow AF register.
63178 BIT 4,A Jump to Handler_Projectiles_2 if bit 4 of A is not set.
63180 JR Z,Handler_Projectiles_2
63182 INC B Increment B by one.
Handler_Projectiles_2 63183 XOR A Write 0 to *54271.
63184 LD (54271),A
63187 POP HL Restore HL from the stack.
63188 LD A,C A=C.
63189 CP 32 Jump to RemoveProjectile if A is higher than 32.
63191 JR NC,RemoveProjectile
63193 LD A,B A=B.
63194 CP 24 Jump to RemoveProjectile if A is higher than 24.
63196 JR NC,RemoveProjectile
63198 PUSH HL Stash HL on the stack.
63199 CALL GetSpriteID Call GetSpriteID.
63202 AND A Jump to DrawProjectile if A is zero.
63203 JR Z,DrawProjectile
63205 CP 193 Jump to DrawProjectile if A is higher than 193.
63207 JR NC,DrawProjectile
63209 AND %00111111 Keep only bits 0-5.
63211 CP 50 Jump to DrawProjectile if A is higher than 50.
63213 JR NC,DrawProjectile
There's been a hit, find out which monster.
63215 LD A,(HL) A=*HL.
63216 CALL Convert_To_MonsterData Call Convert_To_MonsterData.
Take off two hit points from the monsters energy.
63219 LD A,2 A=2 (damage).
63221 CALL Handler_DecreaseEnergy Call Handler_DecreaseEnergy.
63224 JR Audio_Projectiles_Hit Jump to Audio_Projectiles_Hit.
Draw the projectile to the buffer.
DrawProjectile 63226 POP HL Restore HL from the stack.
63227 LD (HL),B Update the co-ordinates in the projectile table data.
63228 INC HL
63229 LD (HL),C
63230 PUSH HL Stash HL on the stack.
63231 LD A,246 A=sprite ID 246.
ID Sprite
246 sprite-246-left
63233 CALL PrintSprite Call PrintSprite.
63236 POP HL Restore HL from the stack.
63237 JR Collision_Projectiles_Skip Jump to Collision_Projectiles_Skip.
The projectile has either made a hit, or not, either way the journey is over - so remove it.
RemoveProjectile 63239 DEC HL Decrease HL by one.
63240 LD (HL),0 Write 0 to the projectile state.
63242 LD A,(54266) Decrease *NumberProjectiles by one.
63245 DEC A
63246 LD (54266),A
Collision_Projectiles_Next 63249 INC HL Move onto the next projectile table data.
63250 INC HL
Collision_Projectiles_Skip 63251 INC HL
63252 POP BC Restore projectile ID from the stack.
63253 DEC B Decrease projectile ID by one.
63254 JR NZ,Handler_Projectiles_Loop Jump to Handler_Projectiles_Loop until all projectiles have been processed.
63256 RET Return.
Prev: 62694 Up: Map Next: 63257