Prev: F4E6 Up: Map Next: F719
F69F: Handler: Projectiles
Used by the routine at RunHandlers.
Handler_Projectiles F69F LD B,$06 B=06 (number of possible projectiles).
F6A1 LD HL,$D30D HL=Table_Projectiles.
Handler_Projectiles_Loop F6A4 PUSH BC Stash current projectile on the stack.
F6A5 LD A,(HL) Jump to Collision_Projectiles_Next if this projectile is not active.
F6A6 AND A
F6A7 JR Z,Collision_Projectiles_Next
This projectile is active so let's process it.
F6A9 INC A Increment A by one.
F6AA LD (HL),A Write A to *HL.
F6AB LD E,A E=A.
F6AC INC HL Increment HL by one.
F6AD LD B,(HL) B=*HL.
F6AE PUSH HL Stash HL on the stack.
F6AF INC HL Increment HL by one.
F6B0 LD C,(HL) C=*HL.
F6B1 CP $41 Jump to Handler_Projectiles_0 if A is higher than 41.
F6B3 JR NC,Handler_Projectiles_0
F6B5 LD HL,$C8A9 HL=C8A9.
F6B8 JR Handler_Projectiles_1 Jump to Handler_Projectiles_1.
Handler_Projectiles_0 F6BA LD HL,$C896 HL=C896.
Handler_Projectiles_1 F6BD LD A,$01 Write 01 to *D3FF.
F6BF LD ($D3FF),A
F6C2 LD A,E A=E.
F6C3 AND %00111111 Keep only bits 0-5.
F6C5 DEC A Decrease A by one.
F6C6 CALL $EB5A Call EB5A.
F6C9 EX AF,AF' Exchange the AF register with the shadow AF register.
F6CA BIT 4,A Jump to Handler_Projectiles_2 if bit 4 of A is not set.
F6CC JR Z,Handler_Projectiles_2
F6CE INC B Increment B by one.
Handler_Projectiles_2 F6CF XOR A Write 00 to *D3FF.
F6D0 LD ($D3FF),A
F6D3 POP HL Restore HL from the stack.
F6D4 LD A,C A=C.
F6D5 CP $20 Jump to RemoveProjectile if A is higher than 20.
F6D7 JR NC,RemoveProjectile
F6D9 LD A,B A=B.
F6DA CP $18 Jump to RemoveProjectile if A is higher than 18.
F6DC JR NC,RemoveProjectile
F6DE PUSH HL Stash HL on the stack.
F6DF CALL GetSpriteID Call GetSpriteID.
F6E2 AND A Jump to DrawProjectile if A is zero.
F6E3 JR Z,DrawProjectile
F6E5 CP $C1 Jump to DrawProjectile if A is higher than C1.
F6E7 JR NC,DrawProjectile
F6E9 AND %00111111 Keep only bits 0-5.
F6EB CP $32 Jump to DrawProjectile if A is higher than 32.
F6ED JR NC,DrawProjectile
There's been a hit, find out which monster.
F6EF LD A,(HL) A=*HL.
F6F0 CALL Convert_To_MonsterData Call Convert_To_MonsterData.
Take off two hit points from the monsters energy.
F6F3 LD A,$02 A=02 (damage).
F6F5 CALL Handler_DecreaseEnergy Call Handler_DecreaseEnergy.
F6F8 JR Audio_Projectiles_Hit Jump to Audio_Projectiles_Hit.
Draw the projectile to the buffer.
DrawProjectile F6FA POP HL Restore HL from the stack.
F6FB LD (HL),B Update the co-ordinates in the projectile table data.
F6FC INC HL
F6FD LD (HL),C
F6FE PUSH HL Stash HL on the stack.
F6FF LD A,$F6 A=sprite ID F6.
ID Sprite
F6 sprite-246-left
F701 CALL PrintSprite Call PrintSprite.
F704 POP HL Restore HL from the stack.
F705 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 F707 DEC HL Decrease HL by one.
F708 LD (HL),$00 Write 00 to the projectile state.
F70A LD A,($D3FA) Decrease *NumberProjectiles by one.
F70D DEC A
F70E LD ($D3FA),A
Collision_Projectiles_Next F711 INC HL Move onto the next projectile table data.
F712 INC HL
Collision_Projectiles_Skip F713 INC HL
F714 POP BC Restore projectile ID from the stack.
F715 DEC B Decrease projectile ID by one.
F716 JR NZ,Handler_Projectiles_Loop Jump to Handler_Projectiles_Loop until all projectiles have been processed.
F718 RET Return.
Prev: F4E6 Up: Map Next: F719