Prev: 613B Up: Map Next: 6332
6298: 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 6298 LD HL,$5F09 Point HL at the high score.
629B LD BC,$0B00 Set the counter to 0B (the high score, the game options, the sound flag and both scores) and the byte to write to 00.
GameInitialisation_Loop 629E LD (HL),C Blank a byte.
629F INC HL Move onto the next byte.
62A0 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 00 and if Sound_Enable does not contain 00 then the game is muted.
62A2 LD HL,$03B5 Point HL at the start of the BEEPER routine.
62A5 LD B,$43 Set the counter to 43 (the number of bytes to add).
62A7 XOR A Clear the checksum.
Mute_Loop 62A8 ADD A,(HL) Add a byte of the routine to the checksum.
62A9 INC HL Move onto the next byte.
62AA DJNZ Mute_Loop Decrease the byte counter by one and loop back to Mute_Loop until the whole routine has been added.
62AC ADD A,$68 Add 68 which makes the checksum zero in the original ROM.
62AE LD ($5F0D),A Store the result as the sound mute flag at Sound_Enable.
62B1 XOR A Write 00 to BORDCR.
62B2 LD ($5C48),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 62B5 DI Disable interrupts.
62B6 LD SP,$5F00 Set the stack pointer to SecurityCheck.
62B9 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 62BC CALL GameMenu Print the game selection menu using GameMenu.
62BF LD A,$F7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
F7 1 2 3 4 5
62C1 OUT ($FD),A
62C3 IN A,($FE)
62C5 CPL Flip the bits, so that a pressed key is a set bit.
62C6 LD E,A Keep the pressed keys in E.
62C7 LD A,($5F0C) Fetch the game options.
Handle 1UP selection.
62CA BIT 0,E Jump to GameSelect_CheckP2 if key "1" has not been pressed ("1 PLAYER GAME").
62CC JR Z,GameSelect_CheckP2
62CE RES 0,A Select a one player game by resetting bit 0.
Handle 2UP selection.
GameSelect_CheckP2 62D0 BIT 1,E Jump to GameSelect_CheckKeyboard if key "2" has not been pressed ("2 PLAYER GAME").
62D2 JR Z,GameSelect_CheckKeyboard
62D4 SET 0,A Set bit 0, which selects a two player game.
Handle Keyboard selection.
GameSelect_CheckKeyboard 62D6 BIT 2,E Jump to GameSelect_CheckKempston if key "3" has not been pressed ("KEYBOARD").
62D8 JR Z,GameSelect_CheckKempston
62DA AND %11111001 Keep only bits 0, 3-7, which selects the keyboard.
Handle Kempston Joystick selection.
GameSelect_CheckKempston 62DC BIT 3,E Jump to GameSelect_CheckCursor if key "4" has not been pressed ("KEMPSTON JOYSTICK").
62DE JR Z,GameSelect_CheckCursor
62E0 AND %11111001 Keep only bits 0, 3-7.
62E2 OR %00000010 Set bit 1, which selects the Kempston joystick.
Handle Cursor Joystick selection.
GameSelect_CheckCursor 62E4 BIT 4,E Jump to GameSelect_CheckStart if key "5" has not been pressed ("CURSOR JOYSTICK").
62E6 JR Z,GameSelect_CheckStart
62E8 AND %11111001 Keep only bits 0, 3-7.
62EA OR %00000100 Set bit 2, which selects the cursor joystick.
GameSelect_CheckStart 62EC LD ($5F0C),A Update the game options at GameOptions.
"0" for "Start Game" is on a different port.
62EF LD A,$EF Read from the keyboard;
Port Number Bit
0 1 2 3 4
EF 0 9 8 7 6
62F1 OUT ($FD),A
62F3 IN A,($FE)
62F5 CPL Flip the bits, so that a pressed key is a set bit.
Handle starting a new game.
62F6 BIT 0,A Jump to StartGame if key "0" has been pressed ("START GAME").
62F8 JP NZ,StartGame
Handle flashing each selection. The first line of the menu is the title, so the attributes for the options start at 635F.
62FB LD HL,$635F Point HL at GameSelection_Attributes_Options.
62FE LD A,($5F0C) Fetch the game options and keep a copy of the options in C.
6301 LD C,A
6302 BIT 0,C Jump to MenuAttributeFlashTwoPlayer if a two player game is selected.
6304 JR NZ,MenuAttributeFlashTwoPlayer
6306 CALL MenuAttributeSetUnset Flash the "1 PLAYER GAME" line, and stop the "2 PLAYER GAME" line flashing, using MenuAttributeSetUnset.
MenuAttributeHandler 6309 LD B,$03 Set the control line counter to 03 (keyboard, Kempston joystick and cursor joystick).
630B LD A,C Fetch the game options.
630C RRCA Shift the control selection into bits 0-1.
MenuAttributeHandler_Loop 630D AND %00000011 Keep only bits 0-1 (the selected control).
630F JR Z,MenuAttributeFlashControl Jump to MenuAttributeFlashControl if this line is the selected control.
6311 CALL MenuAttributeUnSetFirst Stop this control line flashing using MenuAttributeUnSetFirst.
MenuAttributeHandler_Next 6314 DEC A Move on to the next control.
6315 DJNZ MenuAttributeHandler_Loop Decrease the control line counter by one and loop back to MenuAttributeHandler_Loop until all three lines have been done.
6317 JP GameSelect_Loop Jump back to GameSelect_Loop to print the menu again.
Flash the line of the selected control.
MenuAttributeFlashControl 631A CALL MenuAttributeSetFirst Flash the selected control line using MenuAttributeSetFirst.
631D 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 631F CALL MenuAttributeUnsetSet Flash the "2 PLAYER GAME" line, and stop the "1 PLAYER GAME" line flashing, using MenuAttributeUnsetSet.
6322 JR MenuAttributeHandler Jump back to MenuAttributeHandler.
Set FLASH on the first menu line, and clear it on the second.
MenuAttributeSetUnset 6324 SET 7,(HL) Set the FLASH attribute for the menu attribute.
6326 INC HL Move onto the next menu attribute.
Clear FLASH on a menu line.
MenuAttributeUnSetFirst 6327 RES 7,(HL) Unset the FLASH attribute for the menu attribute.
6329 INC HL Move onto the next menu attribute.
632A RET Return.
Clear FLASH on the first menu line, and set it on the second.
MenuAttributeUnsetSet 632B RES 7,(HL) Unset the FLASH attribute for the menu attribute.
632D INC HL Move onto the next menu attribute.
Set FLASH on a menu line.
MenuAttributeSetFirst 632E SET 7,(HL) Set the FLASH attribute for the menu attribute.
6330 INC HL Move onto the next menu attribute.
6331 RET Return.
View the equivalent code in;
Prev: 613B Up: Map Next: 6332