Prev: 6A3A Up: Map Next: 6A73
6A42: Check Weapon Hit
Used by the routines at UpdateLeech, UpdateMidges and UpdateSlug.
Checks whether a bug is touching either of the two weapon objects (the weapon has to be within 0F pixels horizontally and 0C pixels vertically). If it is, the "hit" flag of the weapon (IX+05 of the weapon) is set so that the weapon removes itself. This does not check whether the weapon is active, so the caller does that using the state which is returned in C.
Input
IX Bug object
Output
C The state of the weapon which was checked
E 00 No weapon hit the bug
E 01 A weapon hit the bug
CheckWeaponHit 6A42 LD HL,$5E7C HL=State_Weapon_1 (the first weapon object).
6A45 LD B,$02 Set the weapon counter to 02.
CheckWeaponHit_Loop 6A47 LD A,(IX+$01) A=the X position of the bug.
6A4A LD C,(HL) C=the state of the weapon.
6A4B INC HL Move onto the X position of the weapon.
6A4C SUB (HL) Subtract the X position of the weapon.
6A4D JP P,CheckWeaponHit_Test_X Make sure we have a positive byte.
6A50 NEG
CheckWeaponHit_Test_X 6A52 CP $10 Jump to CheckWeaponHit_Next if the weapon is 10 pixels or more away.
6A54 JR NC,CheckWeaponHit_Next
6A56 LD A,(IX+$02) A=the Y position of the bug.
6A59 INC HL Move onto the Y position of the weapon.
6A5A SUB (HL) Subtract the Y position of the weapon.
6A5B JP P,CheckWeaponHit_Test_Y Make sure we have a positive byte.
6A5E NEG
CheckWeaponHit_Test_Y 6A60 CP $0D Jump to CheckWeaponHit_Next if the weapon is 0D pixels or more away.
6A62 JR NC,CheckWeaponHit_Next
6A64 INC HL Move onto the "hit" flag of the weapon.
6A65 INC HL
6A66 INC HL
6A67 LD E,$01 E=01 (a weapon has hit the bug).
6A69 LD (HL),E Set the "hit" flag of the weapon.
6A6A RET Return.
CheckWeaponHit_Next 6A6B LD HL,$5E84 HL=State_Weapon_2 (the second weapon object).
6A6E DJNZ CheckWeaponHit_Loop Decrease the weapon counter by one and loop back to CheckWeaponHit_Loop until both weapons have been checked.
6A70 LD E,$00 E=00 (no hit).
6A72 RET Return.
Prev: 6A3A Up: Map Next: 6A73