Prev: C036 Up: Map Next: C0BC
C049: Check Sheriff Lost
Used by the routine at InitialiseGame.
Called every frame. If ObjectSlot_01, which holds the sheriff, and ObjectSlot_15, which holds the crosshair, are both empty, then a stage is starting or the sheriff has been lost. The routine takes a life away. When there is no life left it shows "GAME OVER" and works out the top score, or if there are two players it moves on to the other player. Otherwise it makes the sheriff arrive in the town, or the crosshair in the duel and the bonus stage.
Fetch the type of the first object slot.
CheckSheriffLost C049 LD A,($A27D) Fetch ObjectSlot_01 and keep it in C.
C04C LD C,A
Fetch the type of the last object slot.
C04D LD A,($A35D) Fetch ObjectSlot_15.
C050 OR C Return if either of the slots is in use.
C051 RET NZ
Clear the delay before the next shot.
C052 LD ($A245),A Set FireTimer.
Clear the flag which shows that the revolver is being reloaded.
C055 LD ($A246),A Set ReloadingFlag.
Fetch the options.
C058 LD A,($A21C) Fetch Options.
See whether there are two players.
C05B BIT 0,A Jump to CheckSheriffLost_TwoPlayers if there are.
C05D JR NZ,CheckSheriffLost_TwoPlayers
CheckSheriffLost_TakeLife C05F LD HL,$A263 Point HL at Lives.
C062 DEC (HL) Take one off.
There are no lives left.
C063 JP M,CheckSheriffLost_GameOver Jump to CheckSheriffLost_GameOver if there are none.
Clear the flag that a stage is starting.
C066 XOR A Write 00 to StageRunningFlag.
C067 LD ($A240),A
Fetch the kind of stage.
C06A LD A,($A265) Fetch StageKind.
The stage has a crosshair.
C06D AND A Jump to CreateCrosshair if it has.
C06E JP NZ,CreateCrosshair
Copy the sheriff template into the first slot.
C071 LD HL,$C0BC Point HL at SheriffTemplate.
C074 LD DE,$A27D Point DE at ObjectSlot_01.
C077 LD BC,$0010 Set the size of an object slot in BC.
C07A LDIR Copy the template into the slot.
Set the top speed of the sheriff.
C07C LD A,$0A Set TopSpeed to 0A.
C07E LD ($A21F),A
Draw the lives.
C081 JP DrawLives Jump to DrawLives.
Fetch the flag which shows that a stage is starting.
CheckSheriffLost_TwoPlayers C084 LD A,($A240) Fetch StageRunningFlag.
Take a life if a stage is starting.
C087 AND A Jump to CheckSheriffLost_TakeLife if it is.
C088 JR NZ,CheckSheriffLost_TakeLife
Fetch the number of lives.
C08A LD A,($A263) Fetch Lives.
The player has lives left.
C08D AND A Jump to CheckSheriffLost_LivesLeft if there are any.
C08E JR NZ,CheckSheriffLost_LivesLeft
Show "GAME OVER" for this player.
C090 CALL ShowGameOver Call ShowGameOver.
Fetch the number of the current player.
C093 LD A,($A23F) Fetch CurrentPlayer.
Check the top score if the second player has finished.
C096 AND A Jump to CheckTopScore if the second player has finished.
C097 JP NZ,CheckTopScore
Switch to the other player.
CheckSheriffLost_ChangePlayer C09A XOR %00000001 Switch to the other player.
Set the number of the current player.
C09C LD ($A23F),A Set CurrentPlayer.
Remove all of the objects.
C09F CALL RemoveAllObjects Call RemoveAllObjects.
Swap the states of the two players.
C0A2 CALL SwapPlayerStates Call SwapPlayerStates.
Show the number of the player.
C0A5 CALL ShowPlayerNumber Call ShowPlayerNumber.
Fetch the colour of the screen.
C0A8 LD A,($A266) Fetch ScreenAttribute and keep it in E.
C0AB LD E,A
Draw the screen furniture.
C0AC CALL DrawGameScreen Call DrawGameScreen.
Take a life.
C0AF JR CheckSheriffLost_TakeLife Jump to CheckSheriffLost_TakeLife.
Fetch the number of the current player.
CheckSheriffLost_LivesLeft C0B1 LD A,($A23F) Fetch CurrentPlayer.
Change to the other player.
C0B4 JR CheckSheriffLost_ChangePlayer Jump to CheckSheriffLost_ChangePlayer.
Show "GAME OVER".
CheckSheriffLost_GameOver C0B6 CALL ShowGameOver Call ShowGameOver.
Work out the top score.
C0B9 JP CheckTopScore_SkipSwap Jump to CheckTopScore_SkipSwap.
Prev: C036 Up: Map Next: C0BC