Prev: 46937 Up: Map Next: 47093
46945: Game Over
Used by the routines at UpdateLightYears, HandleValve and LoseLife.
Ends the game. UpdateSpecialObjects is called, and then if GameCompletedFlag is set the completed message is shown first (see GameCompleted). The game over screen shows "GAME OVER", a rating that depends on the rooms visited (32 rooms to each of four ratings) and on GameCompletedFlag, and the statistics. When a key has been pressed the screen is cleared and the objects of an ending scene are placed (see PlaceSceneObjects). If the game was not completed this is the scene of the robot being beaten up, otherwise it is the scene of the robot ending its journey. The main loop is then entered at RunGame_Frame to run the scene.
Game over screen
game-over
Update the valves and test whether the game is finished.
GameOver 46945 CALL UpdateSpecialObjects Call UpdateSpecialObjects.
46948 LD A,(23331) Fetch GameCompletedFlag.
46951 AND A Jump to GameCompleted if it is not zero.
46952 JP NZ,GameCompleted
This entry point is used by the routine at GameCompleted.
Show the game over screen.
GameOver_ShowStatistics 46955 CALL ClearScreenBuffer Call ClearScreenBuffer.
46958 CALL ClearScreen Call ClearScreen.
46961 LD DE,47439 Point DE at GameOverColours.
46964 EXX Switch to the shadow registers.
46965 LD HL,47446 Point HL at GameOverCoordinates.
46968 LD DE,47460 Point DE at GameOverText.
46971 LD B,7 Set the number of lines to 7.
46973 CALL DisplayTextList Call DisplayTextList.
Work out the rating from the rooms visited and from GameCompletedFlag.
46976 CALL CountRoomsVisited Call CountRoomsVisited.
46979 RLCA Rotate the count.
46980 AND %11000000 Keep only bits 6 and 7.
46982 LD C,A Keep it in C.
46983 LD A,(23331) Fetch GameCompletedFlag.
46986 AND %00000001 Keep only bit 0.
46988 OR C Combine it with the room count.
46989 RLCA Rotate the result three times.
46990 RLCA
46991 RLCA
46992 AND %00001110 Keep only bits 1 to 3.
46994 LD L,A Keep it in L.
46995 LD H,0 Set H to 0.
46997 LD BC,47581 Point BC at RatingMessages.
47000 ADD HL,BC Add the table address.
47001 LD E,(HL) Fetch the address of the message.
47002 INC HL
47003 LD D,(HL)
47004 LD HL,10072 Set the position of the message to 10072.
47007 CALL PrintTextStandardFont Call PrintTextStandardFont.
Print the statistics.
47010 CALL CountStatistics Call CountStatistics.
47013 CALL PrintStatistics Call PrintStatistics.
47016 CALL PrintBorder Call PrintBorder.
47019 CALL UpdateScreen Call UpdateScreen.
Play the tune and wait for a key.
GameOver_WaitForKeysReleased 47022 XOR A Select all of the keyboard rows.
47023 CALL ReadKeyboardPort Call ReadKeyboardPort.
47026 JR NZ,GameOver_WaitForKeysReleased Jump to GameOver_WaitForKeysReleased if a key is pressed.
47028 LD DE,46071 Point DE at GameOverTune.
47031 CALL PlayMusic_WaitKey Call PlayMusic_WaitKey.
47034 LD B,8 Set the length of the wait to 8.
47036 CALL WaitForKeyPress Call WaitForKeyPress.
Start the ending scene.
47039 LD A,1 Write 1 to *GameOverFlag.
47041 LD (23332),A
47044 CALL ClearScreenBuffer Call ClearScreenBuffer.
47047 CALL PrintBorder Call PrintBorder.
47050 CALL UpdateScreen Call UpdateScreen.
47053 CALL ClearObjects Call ClearObjects.
47056 CALL ClearAttributes Call ClearAttributes.
47059 LD A,(23331) Fetch GameCompletedFlag.
47062 AND A Jump to GameOver_CompletedScene if it is not zero.
47063 JR NZ,GameOver_CompletedScene
The game was not completed.
47065 LD HL,40776 Set the position of the message to 40776.
47068 LD DE,47093 Point DE at ReprogrammingMessage.
47071 CALL PrintTextStandardFont Call PrintTextStandardFont.
47074 LD DE,47146 Point DE at GameOverScene.
Place the objects of the scene and run it.
GameOver_StartScene 47077 CALL PlaceSceneObjects Call PlaceSceneObjects.
47080 LD A,1 Write 1 to *RedrawPanelFlag.
47082 LD (23319),A
47085 JP RunGame_Frame Jump to RunGame_Frame.
The game was completed.
GameOver_CompletedScene 47088 LD DE,47187 Point DE at GameCompletedScene.
47091 JR GameOver_StartScene Jump to GameOver_StartScene.
Prev: 46937 Up: Map Next: 47093