Prev: 5F00 Up: Map Next: 5F6C
5F07: Game Initialisation
Blank the game configs.
GameInitialisation 5F07 LD HL,$5E00 Write 00 to A3 bytes starting from 5E00.
5F0A LD DE,$5E01
5F0D LD BC,$00A3
5F10 LD (HL),$00
5F12 LDIR
5F14 LD HL,$FFFF Write FFFF to BestTime - this isn't used anywhere until Flag_BestTime is set.
5F17 LD ($5E00),HL
This entry point is used by the routine at GameOver.
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 Call SetDayAttributes.
5F26 CALL CreateWindow Call CreateWindow.
GameSelect_Loop 5F29 CALL GameMenu Call 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) D=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.
Handle keyboard selection.
GameSelect_CheckKeyboard 5F3E BIT 0,A Has key "1" been pressed? ("1 KEYBOARD").
5F40 JR Z,GameSelect_CheckJoystick If not jump to GameSelect_CheckJoystick.
5F42 RES 1,D Set control method = keyboard.
Handle joystick selection.
GameSelect_CheckJoystick 5F44 BIT 1,A Has key "2" been pressed? ("2 JOYSTICK").
5F46 JR Z,GameSelect_CheckStart If not jump to GameSelect_CheckStart.
5F48 SET 1,D Set control method = joystick.
Handle starting a new game.
GameSelect_CheckStart 5F4A BIT 2,A Has key "3" been pressed? ("3 START GAME").
5F4C JP NZ,StartGame If it has then jump to StartGame.
Handle flashing each selection.
5F4F LD A,D Write D to GameOptions.
5F50 LD ($5E3E),A
5F53 LD HL,$5FA8 HL=GameSelection_Attributes + 01 (i.e. ignoring "Game Selection" as it doesn't flash).
5F56 LD A,($5E3E) C=GameOptions.
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 onto the next menu attribute.
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