Prev: 7C17 Up: Map Next: 7C90
7C19: Game Initialisation
Used by the routine at SecurityCheck.
Clears the first 10 bytes of the game variables, selects the main font and then runs the game selection menu. The menu is drawn by GameMenu and the keyboard is scanned for the keys "1" to "6" and "0" until "0" is pressed. Each key changes the control method or the character stored in GameOptions and moves the highlight on the menu, and "0" starts the game at StartGame. The entry point at Game_Restart is also used to return to the menu when a game ends.
Clear the first 10 bytes of the game variables.
GameInitialisation 7C19 LD HL,$5E00 Point HL at the game options at GameOptions.
7C1C LD B,$10 B=10 (the number of bytes to clear).
GameInitialisation_Loop 7C1E LD (HL),$00 Clear a byte of the game variables.
7C20 INC HL Move HL on to the next byte of the game variables.
7C21 DJNZ GameInitialisation_Loop Decrease the byte counter by one and loop back to GameInitialisation_Loop until all 10 bytes have been cleared.
7C23 LD HL,$BE4C Write BE4C (the main font, see MainFont) to FontPointer.
7C26 LD ($5E01),HL
This entry point is used by the routine at GameOver.
Clear the screen and draw the icons for the menu.
Game_Restart 7C29 CALL ClearScreen Call ClearScreen to clear the screen.
7C2C CALL MenuIcons Call MenuIcons to draw the icons of the menu.
Each pass of this loop draws the menu and handles one scan of the keyboard.
GameSelect_Loop 7C2F CALL GameMenu Call GameMenu to show the game selection menu.
7C32 LD A,$F7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
F7 1 2 3 4 5
7C34 OUT ($FD),A
7C36 IN A,($FE)
7C38 CPL Flip the bits, so that a set bit is a key which is pressed.
7C39 LD E,A Keep the keys that are pressed in E.
7C3A LD A,($5E00) Fetch the game options.
Handle "Keyboard" selection.
7C3D BIT 0,E Jump to GameSelect_CheckKempston if key "1" is not being pressed ("KEYBOARD").
7C3F JR Z,GameSelect_CheckKempston
7C41 AND %11111001 Keep only bits 0 and 3-7, so the control method is the keyboard (00).
Handle "Kempston Joystick" selection.
GameSelect_CheckKempston 7C43 BIT 1,E Jump to GameSelect_CheckCursor if key "2" is not being pressed ("KEMPSTON JOYSTICK").
7C45 JR Z,GameSelect_CheckCursor
7C47 AND %11111001 Keep only bits 0 and 3-7.
7C49 OR %00000010 Set the control method to Kempston joystick (02).
Handle "Cursor Joystick" selection.
GameSelect_CheckCursor 7C4B BIT 2,E Jump to GameSelect_CheckKnight if key "3" is not being pressed ("CURSOR JOYSTICK").
7C4D JR Z,GameSelect_CheckKnight
7C4F AND %11111001 Keep only bits 0 and 3-7.
7C51 OR %00000100 Set the control method to cursor joystick (04).
Handle "Knight" selection.
GameSelect_CheckKnight 7C53 BIT 3,E Jump to GameSelect_CheckWizard if key "4" is not being pressed ("KNIGHT").
7C55 JR Z,GameSelect_CheckWizard
7C57 AND %11100111 Keep only bits 0-2 and 5-7, so the character is the knight (00).
Handle "Wizard" selection.
GameSelect_CheckWizard 7C59 BIT 4,E Jump to GameSelect_SecondRow if key "5" is not being pressed ("WIZARD").
7C5B JR Z,GameSelect_SecondRow
7C5D AND %11100111 Keep only bits 0-2 and 5-7.
7C5F OR %00001000 Set the character to the wizard (08).
Save the options so far and read the second row of keys.
GameSelect_SecondRow 7C61 LD D,A Keep the options so far in D.
7C62 LD A,$EF Read from the keyboard;
Port Number Bit
0 1 2 3 4
EF 0 9 8 7 6
7C64 OUT ($FD),A
7C66 IN A,($FE)
7C68 CPL Flip the bits, so that a set bit is a key which is pressed.
7C69 LD E,A Keep the keys that are pressed in E.
7C6A LD A,D Fetch the options so far.
Handle "Serf" selection.
GameSelect_CheckSerf 7C6B BIT 4,E Jump to GameSelect_StoreOptions if key "6" is not being pressed ("SERF").
7C6D JR Z,GameSelect_StoreOptions
7C6F AND %11100111 Keep only bits 0-2 and 5-7.
7C71 OR %00010000 Set the character to the serf (10).
Write the options back and keep a copy in C.
GameSelect_StoreOptions 7C73 LD ($5E00),A Write the options back to GameOptions.
7C76 LD C,A Keep a copy of the options in C.
Handle starting a new game.
GameSelect_Start 7C77 BIT 0,E Jump to StartGame if key "0" is being pressed ("START GAME").
7C79 JP NZ,StartGame
Highlight the selected control method, then the selected character.
7C7C LD HL,$7CEA Point HL at the game select attribute table at GameSelection_Attributes.
7C7F LD B,$03 B=03 (the number of control method entries).
7C81 LD A,C Fetch the options.
7C82 CALL FlashSelection Call FlashSelection to highlight the selected menu entry.
7C85 LD B,$03 B=03 (the number of character entries).
7C87 LD A,C Fetch the options.
7C88 RRCA Rotate A right twice, which brings the character bits into position.
7C89 RRCA
7C8A CALL FlashSelection Call FlashSelection to highlight the selected menu entry.
7C8D JP GameSelect_Loop Jump back to GameSelect_Loop to run the menu again.
View the equivalent code in;
Prev: 7C17 Up: Map Next: 7C90