Prev: C869 Up: Map Next: C8F7
C8C8: Check Shot Hit
Used by the routine at HandleBag.
Tests whether the object is touching the shot in ObjectSlot_14. The distances between the positions must both be less than the sum of the sizes.
Input
IX The address of the object
Output
F The carry flag is set if the shot is touching the object
Return unless there is a shot in ObjectSlot_14.
CheckShotHit C8C8 LD IY,$A34D Point IY at ObjectSlot_14.
C8CC LD A,(IY+$00) Return if ObjectSlot_14 is free.
C8CF AND A
C8D0 RET Z
Test the horizontal distance.
C8D1 LD A,(IX+$08) Add the horizontal sizes into C.
C8D4 ADD A,(IY+$08)
C8D7 LD C,A
C8D8 LD A,(IX+$02) Subtract the horizontal positions.
C8DB SUB (IY+$02)
C8DE JR NC,CheckShotHit_Horizontal Jump to CheckShotHit_Horizontal if it is not negative.
C8E0 NEG Make it positive.
CheckShotHit_Horizontal C8E2 CP C Return if the shot is too far away.
C8E3 RET NC
Test the vertical distance.
C8E4 LD A,(IX+$09) Add the vertical sizes into C.
C8E7 ADD A,(IY+$09)
C8EA LD C,A
C8EB LD A,(IX+$04) Subtract the vertical positions.
C8EE SUB (IY+$04)
C8F1 JR NC,CheckShotHit_Vertical Jump to CheckShotHit_Vertical if it is not negative.
C8F3 NEG Make it positive.
CheckShotHit_Vertical C8F5 CP C Set carry if the shot is touching and return.
C8F6 RET
Prev: C869 Up: Map Next: C8F7