Prev: 24891 Up: Map Next: 25394
25240: Game Initialisation
Used by the routine at SecurityCheck.
Blanks the high score and the scores for both players, and works out whether the sound should be muted. It then runs the game selection menu, which is shown until "0" is pressed to start the game.
The game comes back to Game_Restart to show the menu again when a game is over.
Blank the high score, the 1UP score and the 2UP score.
GameInitialisation 25240 LD HL,24329 Point HL at the high score.
25243 LD BC,2816 Set the counter to 11 (the high score, the game options, the sound flag and both scores) and the byte to write to 0.
GameInitialisation_Loop 25246 LD (HL),C Blank a byte.
25247 INC HL Move onto the next byte.
25248 DJNZ GameInitialisation_Loop Decrease the byte counter by one and loop back to GameInitialisation_Loop until everything has been blanked.
This calculates a "checksum" of the BEEPER routine. The expected value at the end is 0 and if Sound_Enable does not contain 0 then the game is muted.
25250 LD HL,949 Point HL at the start of the BEEPER routine.
25253 LD B,67 Set the counter to 67 (the number of bytes to add).
25255 XOR A Clear the checksum.
Mute_Loop 25256 ADD A,(HL) Add a byte of the routine to the checksum.
25257 INC HL Move onto the next byte.
25258 DJNZ Mute_Loop Decrease the byte counter by one and loop back to Mute_Loop until the whole routine has been added.
25260 ADD A,104 Add 104 which makes the checksum zero in the original ROM.
25262 LD (24333),A Store the result as the sound mute flag at Sound_Enable.
25265 XOR A Write 0 to BORDCR.
25266 LD (23624),A
This entry point is used by the routine at GameOver_ControllerRestart.
This is where the game restarts after a game is over.
Game_Restart 25269 DI Disable interrupts.
25270 LD SP,24320 Set the stack pointer to SecurityCheck.
25273 CALL CreateWindow Draw the window using CreateWindow.
This is the game selection loop. It draws the menu, reads the keys which change the options and then updates the flashing of the menu.
GameSelect_Loop 25276 CALL GameMenu Print the game selection menu using GameMenu.
25279 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
25281 OUT (253),A
25283 IN A,(254)
25285 CPL Flip the bits, so that a pressed key is a set bit.
25286 LD E,A Keep the pressed keys in E.
25287 LD A,(24332) Fetch the game options.
Handle 1UP selection.
25290 BIT 0,E Jump to GameSelect_CheckP2 if key "1" has not been pressed ("1 PLAYER GAME").
25292 JR Z,GameSelect_CheckP2
25294 RES 0,A Select a one player game by resetting bit 0.
Handle 2UP selection.
GameSelect_CheckP2 25296 BIT 1,E Jump to GameSelect_CheckKeyboard if key "2" has not been pressed ("2 PLAYER GAME").
25298 JR Z,GameSelect_CheckKeyboard
25300 SET 0,A Set bit 0, which selects a two player game.
Handle Keyboard selection.
GameSelect_CheckKeyboard 25302 BIT 2,E Jump to GameSelect_CheckKempston if key "3" has not been pressed ("KEYBOARD").
25304 JR Z,GameSelect_CheckKempston
25306 AND %11111001 Keep only bits 0, 3-7, which selects the keyboard.
Handle Kempston Joystick selection.
GameSelect_CheckKempston 25308 BIT 3,E Jump to GameSelect_CheckCursor if key "4" has not been pressed ("KEMPSTON JOYSTICK").
25310 JR Z,GameSelect_CheckCursor
25312 AND %11111001 Keep only bits 0, 3-7.
25314 OR %00000010 Set bit 1, which selects the Kempston joystick.
Handle Cursor Joystick selection.
GameSelect_CheckCursor 25316 BIT 4,E Jump to GameSelect_CheckStart if key "5" has not been pressed ("CURSOR JOYSTICK").
25318 JR Z,GameSelect_CheckStart
25320 AND %11111001 Keep only bits 0, 3-7.
25322 OR %00000100 Set bit 2, which selects the cursor joystick.
GameSelect_CheckStart 25324 LD (24332),A Update the game options at GameOptions.
"0" for "Start Game" is on a different port.
25327 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
25329 OUT (253),A
25331 IN A,(254)
25333 CPL Flip the bits, so that a pressed key is a set bit.
Handle starting a new game.
25334 BIT 0,A Jump to StartGame if key "0" has been pressed ("START GAME").
25336 JP NZ,StartGame
Handle flashing each selection. The first line of the menu is the title, so the attributes for the options start at 25439.
25339 LD HL,25439 Point HL at GameSelection_Attributes_Options.
25342 LD A,(24332) Fetch the game options and keep a copy of the options in C.
25345 LD C,A
25346 BIT 0,C Jump to MenuAttributeFlashTwoPlayer if a two player game is selected.
25348 JR NZ,MenuAttributeFlashTwoPlayer
25350 CALL MenuAttributeSetUnset Flash the "1 PLAYER GAME" line, and stop the "2 PLAYER GAME" line flashing, using MenuAttributeSetUnset.
MenuAttributeHandler 25353 LD B,3 Set the control line counter to 3 (keyboard, Kempston joystick and cursor joystick).
25355 LD A,C Fetch the game options.
25356 RRCA Shift the control selection into bits 0-1.
MenuAttributeHandler_Loop 25357 AND %00000011 Keep only bits 0-1 (the selected control).
25359 JR Z,MenuAttributeFlashControl Jump to MenuAttributeFlashControl if this line is the selected control.
25361 CALL MenuAttributeUnSetFirst Stop this control line flashing using MenuAttributeUnSetFirst.
MenuAttributeHandler_Next 25364 DEC A Move on to the next control.
25365 DJNZ MenuAttributeHandler_Loop Decrease the control line counter by one and loop back to MenuAttributeHandler_Loop until all three lines have been done.
25367 JP GameSelect_Loop Jump back to GameSelect_Loop to print the menu again.
Flash the line of the selected control.
MenuAttributeFlashControl 25370 CALL MenuAttributeSetFirst Flash the selected control line using MenuAttributeSetFirst.
25373 JR MenuAttributeHandler_Next Jump back to MenuAttributeHandler_Next.
A two player game is selected, so flash that line instead of the one player line.
MenuAttributeFlashTwoPlayer 25375 CALL MenuAttributeUnsetSet Flash the "2 PLAYER GAME" line, and stop the "1 PLAYER GAME" line flashing, using MenuAttributeUnsetSet.
25378 JR MenuAttributeHandler Jump back to MenuAttributeHandler.
Set FLASH on the first menu line, and clear it on the second.
MenuAttributeSetUnset 25380 SET 7,(HL) Set the FLASH attribute for the menu attribute.
25382 INC HL Move onto the next menu attribute.
Clear FLASH on a menu line.
MenuAttributeUnSetFirst 25383 RES 7,(HL) Unset the FLASH attribute for the menu attribute.
25385 INC HL Move onto the next menu attribute.
25386 RET Return.
Clear FLASH on the first menu line, and set it on the second.
MenuAttributeUnsetSet 25387 RES 7,(HL) Unset the FLASH attribute for the menu attribute.
25389 INC HL Move onto the next menu attribute.
Set FLASH on a menu line.
MenuAttributeSetFirst 25390 SET 7,(HL) Set the FLASH attribute for the menu attribute.
25392 INC HL Move onto the next menu attribute.
25393 RET Return.
View the equivalent code in;
Prev: 24891 Up: Map Next: 25394