![]() |
Routines |
| Prev: 24320 | Up: Map | Next: 24428 |
|
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 | 24327 | LD HL,24064 | Write 0 to the 164 bytes from 24064 to 24227. | |||||||||||||||||
| 24330 | LD DE,24065 | |||||||||||||||||||
| 24333 | LD BC,163 | |||||||||||||||||||
| 24336 | LD (HL),0 | |||||||||||||||||||
| 24338 | LDIR | |||||||||||||||||||
| 24340 | LD HL,65535 | Write 65535 to BestTime_1 (the best time) - this isn't used anywhere until Flag_BestTime is set. | ||||||||||||||||||
| 24343 | LD (24064),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 | 24346 | LD HL,65535 | Write 65535 to PlayerWorldPosition. | |||||||||||||||||
| 24349 | LD (24116),HL | |||||||||||||||||||
| 24352 | LD SP,24064 | Set the stack pointer to 24064. | ||||||||||||||||||
| 24355 | CALL SetDayAttributes | Set the day time attributes using SetDayAttributes. | ||||||||||||||||||
| 24358 | CALL CreateWindow | Create the game window using CreateWindow. | ||||||||||||||||||
|
Print the menu, then check the keyboard for the player's choice.
|
||||||||||||||||||||
| GameSelect_Loop | 24361 | 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.
|
||||||||||||||||||||
| 24364 | LD A,(24067) | If Flag_BestTime is not zero, call DisplayBestTime. | ||||||||||||||||||
| 24367 | AND A | |||||||||||||||||||
| 24368 | CALL NZ,DisplayBestTime | |||||||||||||||||||
| 24371 | LD A,(24126) | Take a copy of the control options from GameOptions. | ||||||||||||||||||
| 24374 | LD D,A | |||||||||||||||||||
| 24375 | LD A,247 | Read from the keyboard;
|
||||||||||||||||||
| 24377 | OUT (253),A | |||||||||||||||||||
| 24379 | IN A,(254) | |||||||||||||||||||
| 24381 | CPL | Flip the bits, so a pressed key is now a set bit. | ||||||||||||||||||
|
Handle keyboard selection.
|
||||||||||||||||||||
| GameSelect_CheckKeyboard | 24382 | BIT 0,A | Jump to GameSelect_CheckJoystick if key "1" has not been pressed ("1 KEYBOARD"). | |||||||||||||||||
| 24384 | JR Z,GameSelect_CheckJoystick | |||||||||||||||||||
| 24386 | RES 1,D | Reset bit 1 of the options in D, to select the keyboard. | ||||||||||||||||||
|
Handle joystick selection.
|
||||||||||||||||||||
| GameSelect_CheckJoystick | 24388 | BIT 1,A | Jump to GameSelect_CheckStart if key "2" has not been pressed ("2 JOYSTICK"). | |||||||||||||||||
| 24390 | JR Z,GameSelect_CheckStart | |||||||||||||||||||
| 24392 | SET 1,D | Set bit 1 of the options in D, to select the joystick. | ||||||||||||||||||
|
Handle starting a new game.
|
||||||||||||||||||||
| GameSelect_CheckStart | 24394 | BIT 2,A | Jump to StartGame if key "3" has been pressed ("3 START GAME"). | |||||||||||||||||
| 24396 | JP NZ,StartGame | |||||||||||||||||||
|
Store the choice, then flash the selected menu line.
|
||||||||||||||||||||
| 24399 | LD A,D | Save the control options back to GameOptions. | ||||||||||||||||||
| 24400 | LD (24126),A | |||||||||||||||||||
| 24403 | LD HL,24488 | Point HL at the colour of the first selectable menu line (GameSelection_Attributes_Options), which skips the title. | ||||||||||||||||||
| 24406 | LD A,(24126) | Fetch the control options from GameOptions into C. | ||||||||||||||||||
| 24409 | LD C,A | |||||||||||||||||||
| 24410 | BIT 1,C | If the joystick option is selected, jump to MenuAttributeSetSecond. | ||||||||||||||||||
| 24412 | JR NZ,MenuAttributeSetSecond | |||||||||||||||||||
|
Set the first menu item, unset the second.
|
||||||||||||||||||||
| MenuAttributeSetFirst | 24414 | SET 7,(HL) | Set the FLASH attribute for the first selection. | |||||||||||||||||
| 24416 | INC HL | Move on to the colour of the second menu line. | ||||||||||||||||||
| 24417 | RES 7,(HL) | Unset the FLASH attribute for the second selection. | ||||||||||||||||||
| 24419 | JR GameSelect_Loop | Jump to GameSelect_Loop. | ||||||||||||||||||
|
Unset the first menu item, set the second.
|
||||||||||||||||||||
| MenuAttributeSetSecond | 24421 | RES 7,(HL) | Unset the FLASH attribute for the first selection. | |||||||||||||||||
| 24423 | INC HL | Move onto the next menu attribute. | ||||||||||||||||||
| 24424 | SET 7,(HL) | Set the FLASH attribute for the second selection. | ||||||||||||||||||
| 24426 | JR GameSelect_Loop | Jump to GameSelect_Loop. | ||||||||||||||||||
|
View the equivalent code in;
|
||||||||||||||||||||
| Prev: 24320 | Up: Map | Next: 24428 |