Prev: 51305 Up: Map Next: 51447
51400: 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 51400 LD IY,41805 Point IY at ObjectSlot_14.
51404 LD A,(IY+0) Return if ObjectSlot_14 is free.
51407 AND A
51408 RET Z
Test the horizontal distance.
51409 LD A,(IX+8) Add the horizontal sizes into C.
51412 ADD A,(IY+8)
51415 LD C,A
51416 LD A,(IX+2) Subtract the horizontal positions.
51419 SUB (IY+2)
51422 JR NC,CheckShotHit_Horizontal Jump to CheckShotHit_Horizontal if it is not negative.
51424 NEG Make it positive.
CheckShotHit_Horizontal 51426 CP C Return if the shot is too far away.
51427 RET NC
Test the vertical distance.
51428 LD A,(IX+9) Add the vertical sizes into C.
51431 ADD A,(IY+9)
51434 LD C,A
51435 LD A,(IX+4) Subtract the vertical positions.
51438 SUB (IY+4)
51441 JR NC,CheckShotHit_Vertical Jump to CheckShotHit_Vertical if it is not negative.
51443 NEG Make it positive.
CheckShotHit_Vertical 51445 CP C Set carry if the shot is touching and return.
51446 RET
Prev: 51305 Up: Map Next: 51447