Prev: 49206 Up: Map Next: 49340
49225: 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 49225 LD A,(41597) Fetch ObjectSlot_01 and keep it in C.
49228 LD C,A
Fetch the type of the last object slot.
49229 LD A,(41821) Fetch ObjectSlot_15.
49232 OR C Return if either of the slots is in use.
49233 RET NZ
Clear the delay before the next shot.
49234 LD (41541),A Set FireTimer.
Clear the flag which shows that the revolver is being reloaded.
49237 LD (41542),A Set ReloadingFlag.
Fetch the options.
49240 LD A,(41500) Fetch Options.
See whether there are two players.
49243 BIT 0,A Jump to CheckSheriffLost_TwoPlayers if there are.
49245 JR NZ,CheckSheriffLost_TwoPlayers
CheckSheriffLost_TakeLife 49247 LD HL,41571 Point HL at Lives.
49250 DEC (HL) Take one off.
There are no lives left.
49251 JP M,CheckSheriffLost_GameOver Jump to CheckSheriffLost_GameOver if there are none.
Clear the flag that a stage is starting.
49254 XOR A Write 0 to StageRunningFlag.
49255 LD (41536),A
Fetch the kind of stage.
49258 LD A,(41573) Fetch StageKind.
The stage has a crosshair.
49261 AND A Jump to CreateCrosshair if it has.
49262 JP NZ,CreateCrosshair
Copy the sheriff template into the first slot.
49265 LD HL,49340 Point HL at SheriffTemplate.
49268 LD DE,41597 Point DE at ObjectSlot_01.
49271 LD BC,16 Set the size of an object slot in BC.
49274 LDIR Copy the template into the slot.
Set the top speed of the sheriff.
49276 LD A,10 Set TopSpeed to 10.
49278 LD (41503),A
Draw the lives.
49281 JP DrawLives Jump to DrawLives.
Fetch the flag which shows that a stage is starting.
CheckSheriffLost_TwoPlayers 49284 LD A,(41536) Fetch StageRunningFlag.
Take a life if a stage is starting.
49287 AND A Jump to CheckSheriffLost_TakeLife if it is.
49288 JR NZ,CheckSheriffLost_TakeLife
Fetch the number of lives.
49290 LD A,(41571) Fetch Lives.
The player has lives left.
49293 AND A Jump to CheckSheriffLost_LivesLeft if there are any.
49294 JR NZ,CheckSheriffLost_LivesLeft
Show "GAME OVER" for this player.
49296 CALL ShowGameOver Call ShowGameOver.
Fetch the number of the current player.
49299 LD A,(41535) Fetch CurrentPlayer.
Check the top score if the second player has finished.
49302 AND A Jump to CheckTopScore if the second player has finished.
49303 JP NZ,CheckTopScore
Switch to the other player.
CheckSheriffLost_ChangePlayer 49306 XOR %00000001 Switch to the other player.
Set the number of the current player.
49308 LD (41535),A Set CurrentPlayer.
Remove all of the objects.
49311 CALL RemoveAllObjects Call RemoveAllObjects.
Swap the states of the two players.
49314 CALL SwapPlayerStates Call SwapPlayerStates.
Show the number of the player.
49317 CALL ShowPlayerNumber Call ShowPlayerNumber.
Fetch the colour of the screen.
49320 LD A,(41574) Fetch ScreenAttribute and keep it in E.
49323 LD E,A
Draw the screen furniture.
49324 CALL DrawGameScreen Call DrawGameScreen.
Take a life.
49327 JR CheckSheriffLost_TakeLife Jump to CheckSheriffLost_TakeLife.
Fetch the number of the current player.
CheckSheriffLost_LivesLeft 49329 LD A,(41535) Fetch CurrentPlayer.
Change to the other player.
49332 JR CheckSheriffLost_ChangePlayer Jump to CheckSheriffLost_ChangePlayer.
Show "GAME OVER".
CheckSheriffLost_GameOver 49334 CALL ShowGameOver Call ShowGameOver.
Work out the top score.
49337 JP CheckTopScore_SkipSwap Jump to CheckTopScore_SkipSwap.
Prev: 49206 Up: Map Next: 49340