Prev: 995A Up: Map Next: 99AA
9960: Game Initialisation
Clears the game variables, the screen and the attribute buffer, builds the lookup table used when drawing sprites (BuildShiftTable) and colours and draws the banner and score line. The game selection menu (HandlerGameMenu) is shown, then the game variables are cleared again, the scores are printed, the start-up jingle (the music data at MusicData_GameInitialisation) is played and InitialiseGame sets up both players and the first room before the main loop at MainLoop is entered.
game-start
jungle-strip
GameInitialisation 9960 CALL ClearBuffers Clear the game variables.
9963 XOR A Set the border to BLACK.
9964 OUT ($FE),A
9966 CALL ResetAttributes Clear the attribute buffer.
9969 CALL ResetScreen Reset the screen buffer.
996C CALL BuildShiftTable Build the shift table used when drawing sprites.
Set the attributes for the top banner (the whole line is INK:WHITE, PAPER:BLACK (BRIGHT)).
996F LD HL,$5800 Set the attribute pointer in HL to the start of the attribute buffer at 5800.
9972 LD BC,$2047 Set the column counter in B to 20 and the banner colour in C to INK:WHITE, PAPER:BLACK (BRIGHT).
CreateWindow_Loop_Banner 9975 LD (HL),C Write the banner colour to the attribute buffer.
9976 INC L Move onto the next column.
9977 DJNZ CreateWindow_Loop_Banner Decrease the column counter by one and loop back to CreateWindow_Loop_Banner until all 20 columns have been coloured.
9979 CALL PrintBanner Print the banner.
Set the attributes for the score line (the whole line is INK:YELLOW, PAPER:BLACK (BRIGHT)).
997C LD HL,$5820 Set the attribute pointer in HL to the start of the score line at 5820.
997F LD BC,$2046 Set the column counter in B to 20 and the score line colour in C to INK:YELLOW, PAPER:BLACK (BRIGHT).
CreateWindow_Loop_Score 9982 LD (HL),C Write the score line colour to the attribute buffer.
9983 INC L Move onto the next column.
9984 DJNZ CreateWindow_Loop_Score Decrease the column counter by one and loop back to CreateWindow_Loop_Score until all 20 columns have been coloured.
Print the 1UP, 2UP and HI scores on the score line.
9986 CALL Score_1UP Print the 1UP score.
9989 CALL Score_2UP Print the 2UP score.
998C CALL Score_HI Print the high score.
This entry point is used by the routine at GameOver_ControllerRestart.
Show the game selection menu and wait for a game to be chosen. This is also where the game restarts when a game is over.
Game_Restart 998F CALL HandlerGameMenu Show the game menu.
Write 00 to every address from 1UP_Score_1 to 9959 (the scores, the player data, the actor table and the other game variables).
9992 LD HL,$9698 Set the start of the game variables in HL to 1UP_Score_1.
9995 LD BC,$02C2 Set the number of bytes to clear in BC to 02C2.
9998 CALL ClearBuffers_Loop Clear the game variables.
Print the (now zero) 1UP and 2UP scores.
999B CALL Score_1UP Print the 1UP score.
999E CALL Score_2UP Print the 2UP score.
Play the start-up jingle.
99A1 LD DE,$BD45 Point DE at MusicData_GameInitialisation.
99A4 CALL PlayMusic Play the start-up tune.
Set up both players and the first room, then carry on into the main loop.
99A7 CALL InitialiseGame Set up the players and the first room.
Continue on to MainLoop.
View the equivalent code in;
Prev: 995A Up: Map Next: 99AA