Prev: B337 Up: Map Next: B3AB
B347: Handle Pointer
Type 0B: 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 B347 LD A,$04 Set the new value of the counter.
B349 CALL CountDownDelay Count down the counter.
B34C LD C,$02 Set the distance to two cells.
B34E CALL CheckDistance Check how close the sheriff is.
B351 JP NC,HandleBody_Remove Remove the pointer if the sheriff has moved away.
Find how far away the outlaw is horizontally.
B354 LD IY,$A2BD Point IY at ObjectSlot_05.
B358 CALL GetHorizontalPosition Fetch the horizontal position of the outlaw.
B35B EX DE,HL Swap it into DE.
B35C LD IY,$A27D Point IY at ObjectSlot_01.
B360 CALL GetHorizontalPosition Fetch the horizontal position of the sheriff.
B363 LD A,($A268) Fetch the view number and keep it in B.
B366 LD B,A
B367 LD C,$00 Set the direction flags to zero.
B369 AND A Subtract the horizontal position of the sheriff.
B36A SBC HL,DE
B36C JR NC,HandlePointer_Vertical Jump to HandlePointer_Vertical if the outlaw is not to the left.
B36E CALL NegateHL Make the distance positive.
B371 INC C Set bit 0 of the direction flags.
Find how far away the outlaw is vertically.
HandlePointer_Vertical B372 PUSH HL Stash the horizontal distance on the stack.
B373 LD IY,$A2BD Point IY at ObjectSlot_05.
B377 CALL GetVerticalPosition Fetch the vertical position of the outlaw.
B37A EX DE,HL Swap it into DE.
B37B LD IY,$A27D Point IY at ObjectSlot_01.
B37F CALL GetVerticalPosition Fetch the vertical position of the sheriff.
B382 AND A Subtract the vertical position of the sheriff.
B383 SBC HL,DE
B385 JR NC,HandlePointer_Compare Jump to HandlePointer_Compare if the outlaw is not above.
B387 CALL NegateHL Make the distance positive.
B38A INC C Add two to the direction flags.
B38B INC C
Compare the two distances, and choose the sprite.
HandlePointer_Compare B38C POP DE Retrieve the horizontal distance.
B38D AND A Subtract it from the vertical distance.
B38E SBC HL,DE
B390 JR C,HandlePointer_Flip Jump to HandlePointer_Flip if the outlaw is further away horizontally.
B392 RES 6,(IX+$07) Do not flip the sprite.
B396 LD A,C Fetch the direction flags.
B397 CPL Invert them.
B398 RRCA Move bit 1 into bit 0.
HandlePointer_ChooseSprite B399 AND %00000001 Keep bit 0.
B39B XOR B Combine it with bit 0 of the view number.
B39C ADD A,$30 Add 30 to give the number of the sprite.
B39E LD ($B3AD),A Store it in the sprite list.
B3A1 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 B3A4 SET 6,(IX+$07) Flip the sprite.
B3A8 LD A,C Fetch the direction flags.
B3A9 JR HandlePointer_ChooseSprite Choose the sprite.
Prev: B337 Up: Map Next: B3AB