Prev: 51472 Up: Map Next: 51559
51504: Handle Sheriff
Used by the routine at HandleMountedSheriff.
Type 1: the sheriff in the town. It counts down ProtectionTimer, calls ReloadRevolver, reads the controls, then turns, moves and fires. The sprites are written to SheriffSpriteList.
Input
IX The address of the sheriff
Count down ProtectionTimer.
HandleSheriff 51504 LD HL,41480 Point HL at ProtectionTimer.
51507 LD A,(HL) Jump to HandleSheriff_Reload if ProtectionTimer is zero.
51508 AND A
51509 JR Z,HandleSheriff_Reload
51511 DEC (HL) Count ProtectionTimer down.
Reload the revolver and read the controls.
HandleSheriff_Reload 51512 CALL ReloadRevolver Call ReloadRevolver.
51515 CALL ReadControls Call ReadControls.
51518 LD A,(41500) Fetch Options.
51521 RRCA Move the bits for the controls into the lowest bits.
51522 AND %00000011 Keep the two bits.
51524 JR NZ,HandleSheriff_Act Jump to HandleSheriff_Act if the controls are not the keyboard.
Copy the keyboard fire bit into bit 3.
51526 LD A,C Fetch the controls.
51527 RRCA Move bit 4 into bit 3.
51528 AND %00001000 Keep only that bit.
51530 OR C Combine it with the controls.
51531 LD C,A
This entry point is used by the routine at HandleSheriffEntrance.
Turn, move, fire and draw. C is the controls, and is zero when the sheriff has just arrived.
HandleSheriff_Act 51532 LD E,C Copy the controls into E.
51533 CALL CheckRotateKey Call CheckRotateKey.
51536 CALL TurnSheriff Call TurnSheriff.
51539 PUSH DE Stash the controls on the stack.
51540 CALL MovePlayer Call MovePlayer.
51543 POP DE Restore the controls from the stack.
51544 CALL FireRevolver Call FireRevolver.
51547 CALL ChooseFigureSprites Call ChooseFigureSprites.
51550 LD HL,41512 Point HL at SheriffSpriteList.
51553 CALL BuildFigureSpriteList Call BuildFigureSpriteList.
51556 JP ShowFiringPose Jump to ShowFiringPose.
Prev: 51472 Up: Map Next: 51559