Prev: 45879 Up: Map Next: 45995
45895: Handle Pointer
Type 11: a pointing hand which hovers next to the sheriff and points to the outlaw. It works out whether the outlaw is further away across or up the screen, and which way, and so chooses one of two sprites and whether to flip it. It goes away when the sheriff is more than two cells away from it.
Slow down the changes of sprite, and remove the pointer if it is too far from the sheriff.
HandlePointer 45895 LD A,4 Set the new value of the counter.
45897 CALL CountDownDelay Count down the counter.
45900 LD C,2 Set the distance to two cells.
45902 CALL CheckDistance Check how close the sheriff is.
45905 JP NC,HandleBody_Remove Remove the pointer if the sheriff has moved away.
Find how far away the outlaw is horizontally.
45908 LD IY,41661 Point IY at ObjectSlot_05.
45912 CALL GetHorizontalPosition Fetch the horizontal position of the outlaw.
45915 EX DE,HL Swap it into DE.
45916 LD IY,41597 Point IY at ObjectSlot_01.
45920 CALL GetHorizontalPosition Fetch the horizontal position of the sheriff.
45923 LD A,(41576) Fetch the view number and keep it in B.
45926 LD B,A
45927 LD C,0 Set the direction flags to zero.
45929 AND A Subtract the horizontal position of the sheriff.
45930 SBC HL,DE
45932 JR NC,HandlePointer_Vertical Jump to HandlePointer_Vertical if the outlaw is not to the left.
45934 CALL NegateHL Make the distance positive.
45937 INC C Set bit 0 of the direction flags.
Find how far away the outlaw is vertically.
HandlePointer_Vertical 45938 PUSH HL Stash the horizontal distance on the stack.
45939 LD IY,41661 Point IY at ObjectSlot_05.
45943 CALL GetVerticalPosition Fetch the vertical position of the outlaw.
45946 EX DE,HL Swap it into DE.
45947 LD IY,41597 Point IY at ObjectSlot_01.
45951 CALL GetVerticalPosition Fetch the vertical position of the sheriff.
45954 AND A Subtract the vertical position of the sheriff.
45955 SBC HL,DE
45957 JR NC,HandlePointer_Compare Jump to HandlePointer_Compare if the outlaw is not above.
45959 CALL NegateHL Make the distance positive.
45962 INC C Add two to the direction flags.
45963 INC C
Compare the two distances, and choose the sprite.
HandlePointer_Compare 45964 POP DE Retrieve the horizontal distance.
45965 AND A Subtract it from the vertical distance.
45966 SBC HL,DE
45968 JR C,HandlePointer_Flip Jump to HandlePointer_Flip if the outlaw is further away horizontally.
45970 RES 6,(IX+7) Do not flip the sprite.
45974 LD A,C Fetch the direction flags.
45975 CPL Invert them.
45976 RRCA Move bit 1 into bit 0.
HandlePointer_ChooseSprite 45977 AND %00000001 Keep bit 0.
45979 XOR B Combine it with bit 0 of the view number.
45980 ADD A,48 Add 48 to give the number of the sprite.
45982 LD (45997),A Store it in the sprite list.
45985 JP HandleBystander_CheckHit Check for bullets and the sheriff, and draw the pointer.
The outlaw is further away horizontally, so flip the sprite.
HandlePointer_Flip 45988 SET 6,(IX+7) Flip the sprite.
45992 LD A,C Fetch the direction flags.
45993 JR HandlePointer_ChooseSprite Choose the sprite.
Prev: 45879 Up: Map Next: 45995