Prev: 5F00 Up: Map Next: 5F6C
5F07: Game Initialisation
Clears the game variables, builds the day time game window and then runs the game selection menu until the player chooses to start a game.
Blank the game variables.
GameInitialisation 5F07 LD HL,$5E00 Write 00 to the A4 bytes from 5E00 to 5EA3.
5F0A LD DE,$5E01
5F0D LD BC,$00A3
5F10 LD (HL),$00
5F12 LDIR
5F14 LD HL,$FFFF Write FFFF to BestTime_1 (the best time) - this isn't used anywhere until Flag_BestTime is set.
5F17 LD ($5E00),HL
This entry point is used by the routine at GameOver.
Entered again when a game is over, to return to the game selection menu.
Game_Restart 5F1A LD HL,$FFFF Write FFFF to PlayerWorldPosition.
5F1D LD ($5E34),HL
5F20 LD SP,$5E00 Set the stack pointer to 5E00.
5F23 CALL SetDayAttributes Set the day time attributes using SetDayAttributes.
5F26 CALL CreateWindow Create the game window using CreateWindow.
Print the menu, then check the keyboard for the player's choice.
GameSelect_Loop 5F29 CALL GameMenu Print the game selection menu using GameMenu.
The "Best Time Today" banner only shows when one is set. The flag at Flag_BestTime toggles it on/ off.
5F2C LD A,($5E03) If Flag_BestTime is not zero, call DisplayBestTime.
5F2F AND A
5F30 CALL NZ,DisplayBestTime
5F33 LD A,($5E3E) Take a copy of the control options from GameOptions.
5F36 LD D,A
5F37 LD A,$F7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
F7 1 2 3 4 5
5F39 OUT ($FD),A
5F3B IN A,($FE)
5F3D CPL Flip the bits, so a pressed key is now a set bit.
Handle keyboard selection.
GameSelect_CheckKeyboard 5F3E BIT 0,A Jump to GameSelect_CheckJoystick if key "1" has not been pressed ("1 KEYBOARD").
5F40 JR Z,GameSelect_CheckJoystick
5F42 RES 1,D Reset bit 1 of the options in D, to select the keyboard.
Handle joystick selection.
GameSelect_CheckJoystick 5F44 BIT 1,A Jump to GameSelect_CheckStart if key "2" has not been pressed ("2 JOYSTICK").
5F46 JR Z,GameSelect_CheckStart
5F48 SET 1,D Set bit 1 of the options in D, to select the joystick.
Handle starting a new game.
GameSelect_CheckStart 5F4A BIT 2,A Jump to StartGame if key "3" has been pressed ("3 START GAME").
5F4C JP NZ,StartGame
Store the choice, then flash the selected menu line.
5F4F LD A,D Save the control options back to GameOptions.
5F50 LD ($5E3E),A
5F53 LD HL,$5FA8 Point HL at the colour of the first selectable menu line (GameSelection_Attributes_Options), which skips the title.
5F56 LD A,($5E3E) Fetch the control options from GameOptions into C.
5F59 LD C,A
5F5A BIT 1,C If the joystick option is selected, jump to MenuAttributeSetSecond.
5F5C JR NZ,MenuAttributeSetSecond
Set the first menu item, unset the second.
MenuAttributeSetFirst 5F5E SET 7,(HL) Set the FLASH attribute for the first selection.
5F60 INC HL Move on to the colour of the second menu line.
5F61 RES 7,(HL) Unset the FLASH attribute for the second selection.
5F63 JR GameSelect_Loop Jump to GameSelect_Loop.
Unset the first menu item, set the second.
MenuAttributeSetSecond 5F65 RES 7,(HL) Unset the FLASH attribute for the first selection.
5F67 INC HL Move onto the next menu attribute.
5F68 SET 7,(HL) Set the FLASH attribute for the second selection.
5F6A JR GameSelect_Loop Jump to GameSelect_Loop.
View the equivalent code in;
Prev: 5F00 Up: Map Next: 5F6C