Prev: B6E8 Up: Map Next: B72C
B6F4: Check Weapon Record Hit
Used by the routine at Check_Weapon_Hit.
Checks whether a weapon is touching an object. The weapon hits the object if it is in the same room, less than 10 pixels away horizontally and less than 10 pixels away vertically (allowing 04 pixels for the difference in their sizes). When it hits, bit 0 of byte 07 of the weapon is set, which makes Move_Thrown_Weapon remove the weapon.
Input
HL Weapon record
IX Object record
Output
D FF if the weapon hits the object, otherwise 00
E Type of the weapon
Check_Weapon_Record_Hit B6F4 LD D,$00 Clear the hit flag in D.
B6F6 LD A,(HL) Fetch the type of the weapon.
B6F7 AND A Copy it to E, testing it for zero.
B6F8 LD E,A
B6F9 RET Z Return if the record is empty.
B6FA INC HL Move to the x position of the weapon.
B6FB LD A,(HL) Fetch the x position of the weapon.
B6FC SUB (IX+$01) Subtract the x position of the object.
B6FF ADD A,$04 Add 04.
B701 JP P,Check_Weapon_Record_Hit_Test_X Jump to Check_Weapon_Record_Hit_Test_X if the result is positive.
B704 NEG Make the result positive.
Check_Weapon_Record_Hit_Test_X B706 CP $10 Return if they are 10 or more pixels apart horizontally.
B708 RET NC
B709 INC HL Move to the room x of the weapon.
B70A LD A,(HL) Fetch the room x of the weapon.
B70B CP (IX+$02) Return if it is not the room x of the object.
B70E RET NZ
B70F INC HL Move to the y position of the weapon.
B710 LD A,(HL) Fetch the y position of the weapon.
B711 SUB (IX+$03) Subtract the y position of the object.
B714 ADD A,$04 Add 04.
B716 JP P,Check_Weapon_Record_Hit_Test_Y Jump to Check_Weapon_Record_Hit_Test_Y if the result is positive.
B719 NEG Make the result positive.
Check_Weapon_Record_Hit_Test_Y B71B CP $10 Return if they are 10 or more pixels apart vertically.
B71D RET NC
B71E INC HL Move to the room y of the weapon.
B71F LD A,(HL) Fetch the room y of the weapon.
B720 CP (IX+$04) Return if it is not the room y of the object.
B723 RET NZ
B724 LD D,$FF Flag a hit by setting D to FF.
B726 INC HL Move to byte 07.
B727 INC HL
B728 INC HL
B729 LD (HL),$01 Set bit 0 of byte 07 so that the weapon will be removed.
B72B RET Return.
Prev: B6E8 Up: Map Next: B72C