Prev: 613B Up: Map Next: 6332
6298: Game Initialisation
Used by the routine at SecurityCheck.
Blank the 1UP, 2UP and HI scores.
GameInitialisation 6298 LD HL,$5F09 Write 00 to 0B bytes from HighScore_1 to 5F13.
629B LD BC,$0B00
GameInitialisation_Loop 629E LD (HL),C
629F INC HL
62A0 DJNZ GameInitialisation_Loop
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 HL=BEEPER.
62A5 LD B,$43 B=43 (counter).
62A7 XOR A A=00.
Mute_Loop 62A8 ADD A,(HL) Add the byte at HL to A.
62A9 INC HL Increment HL by one.
62AA DJNZ Mute_Loop Decrease counter by one and loop back to Mute_Loop until counter is zero.
62AC ADD A,$68 A=A + 68.
62AE LD ($5F0D),A Store this number at Sound_Enable.
62B1 XOR A Write 00 to BORDCR.
62B2 LD ($5C48),A
This entry point is used by the routine at GameOver_1UP.
Game_Restart 62B5 DI Disable interrupts.
62B6 LD SP,$5F00 Set the stack pointer to SecurityCheck.
62B9 CALL CreateWindow Call CreateWindow.
GameSelect_Loop 62BC CALL GameMenu Call 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.
62C6 LD E,A E=A.
62C7 LD A,($5F0C) A=GameOptions.
Handle 1UP selection.
62CA BIT 0,E Has key "1" been pressed? ("1 PLAYER GAME").
62CC JR Z,GameSelect_CheckP2 If not jump to GameSelect_CheckP2.
62CE RES 0,A Set player count = 1.
Handle 2UP selection.
GameSelect_CheckP2 62D0 BIT 1,E Has key "2" been pressed? ("2 PLAYER GAME").
62D2 JR Z,GameSelect_CheckKeyboard If not jump to GameSelect_CheckKeyboard.
62D4 SET 0,A Set player count = 2.
Handle Keyboard selection.
GameSelect_CheckKeyboard 62D6 BIT 2,E Has key "3" been pressed? ("KEYBOARD").
62D8 JR Z,GameSelect_CheckKempston If not jump to GameSelect_CheckKempston.
62DA AND %11111001 Keep only bits 0, 3-7.
Handle Kempston Joystick selection.
GameSelect_CheckKempston 62DC BIT 3,E Has key "4" been pressed? ("KEMPSTON JOYSTICK").
62DE JR Z,GameSelect_CheckCursor If not jump to GameSelect_CheckCursor.
62E0 AND %11111001 Keep only bits.
62E2 OR %00000010 Set bit 1.
Handle Cursor Joystick selection.
GameSelect_CheckCursor 62E4 BIT 4,E Has key "5" been pressed? ("CURSOR JOYSTICK").
62E6 JR Z,GameSelect_CheckStart If not jump to GameSelect_CheckStart.
62E8 AND %11111001 Keep only bits 0, 3-7.
62EA OR %00000100 Set bit 2.
GameSelect_CheckStart 62EC LD ($5F0C),A Store A 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.
Handle starting a new game.
62F6 BIT 0,A Has key "0" been pressed? ("START GAME").
62F8 JP NZ,StartGame If so, jump to StartGame.
Handle flashing each selection.
62FB LD HL,$635F HL=GameSelection_Attributes+01 (i.e. ignoring "Game Selection" as it doesn't flash).
62FE LD A,($5F0C) C=GameOptions.
6301 LD C,A
6302 BIT 0,C If a 1UP game is selected, jump to MenuAttrHandleJoystick.
6304 JR NZ,MenuAttrHandleJoystick
6306 CALL MenuAttributeSetUnset Call MenuAttributeSetUnset.
MenuAttrHandler 6309 LD B,$03 B=03.
630B LD A,C A=C.
630C RRCA
MenuAttrHandler_Loop 630D AND %00000011 Keep only bits 0-1.
630F JR Z,MenuAttrHandle2UP
6311 CALL MenuAttributeUnSetFirst Call MenuAttributeUnSetFirst.
GameInitialisation_0 6314 DEC A Decrease A by one.
6315 DJNZ MenuAttrHandler_Loop Decrease counter by one and loop back to MenuAttrHandler_Loop until counter is zero.
6317 JP GameSelect_Loop Jump back to GameSelect_Loop.
Handle flashing 2UP.
MenuAttrHandle2UP 631A CALL MenuAttributeSetFirst Call MenuAttributeSetFirst.
631D JR GameInitialisation_0 Jump to GameInitialisation_0.
Handle flashing joystick.
MenuAttrHandleJoystick 631F CALL MenuAttributeUnsetSet Call MenuAttributeUnsetSet.
6322 JR MenuAttrHandler Jump to MenuAttrHandler.
Set the first menu item, unset the second.
MenuAttributeSetUnset 6324 SET 7,(HL) Set the FLASH attribute for the menu attribute.
6326 INC HL Move onto the next menu attribute.
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.
Unset the first menu item, set the second.
MenuAttributeUnsetSet 632B RES 7,(HL) Unset the FLASH attribute for the menu attribute.
632D INC HL Move onto the next menu attribute.
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