|  | Routines | 
| Prev: 839F | Up: Map | Next: 8479 | 
| 
Used by the routine at GameInitialise.
 | ||||||||||||||||||||
| 
 
Prints "Select controls".
 | ||||||||||||||||||||
| GameMenu | 83AA | LD HL,$8B31 | HL=Messaging_SelectControls. | |||||||||||||||||
| 83AD | LD DE,$504B | DE=504B (screen buffer location). | ||||||||||||||||||
| 83B0 | CALL Print_String | Call Print_String. | ||||||||||||||||||
| 83B3 | LD HL,$506B | HL=506B (screen buffer location). | ||||||||||||||||||
| 83B6 | LD B,$0F | Underline the header with 0F character blocks of FF. | ||||||||||||||||||
| 83B8 | CALL Underline | |||||||||||||||||||
| 
Prints "1 User defined keys".
 | ||||||||||||||||||||
| 83BB | LD HL,$8B40 | HL=Messaging_UserDefinedKeys. | ||||||||||||||||||
| 83BE | LD DE,$5089 | DE=5089 (screen buffer location). | ||||||||||||||||||
| 83C1 | CALL Print_String | Call Print_String. | ||||||||||||||||||
| 
Prints "2 Kempston joystick".
 | ||||||||||||||||||||
| 83C4 | LD HL,$8B53 | HL=Messaging_KempstonJoystick. | ||||||||||||||||||
| 83C7 | LD DE,$50A9 | DE=50A9 (screen buffer location). | ||||||||||||||||||
| 83CA | CALL Print_String | Call Print_String. | ||||||||||||||||||
| 
Prints "3 Interface 2".
 | ||||||||||||||||||||
| 83CD | LD HL,$8B66 | HL=Messaging_Interface2. | ||||||||||||||||||
| 83D0 | LD DE,$50C9 | DE=50C9 (screen buffer location). | ||||||||||||||||||
| 83D3 | CALL Print_String | Call Print_String. | ||||||||||||||||||
| 
Prints "4 Cursor key type J/S".
 | ||||||||||||||||||||
| 83D6 | LD HL,$8B73 | HL=Messaging_CursorKeys. | ||||||||||||||||||
| 83D9 | LD DE,$50E9 | DE=50E9 (screen buffer location). | ||||||||||||||||||
| 83DC | CALL Print_String | Call Print_String. | ||||||||||||||||||
| 
Handle retrieving the players input.
 | ||||||||||||||||||||
| GameMenu_InputLoop | 83DF | LD BC,$F7FE | Read from the keyboard; 
 | |||||||||||||||||
| 83E2 | IN A,(C) | |||||||||||||||||||
| 83E4 | OR %11100000 | Set bits 5-7 (to fill in the extra bits). | ||||||||||||||||||
| 83E6 | CP $FF | Jump to GameMenu_HandleInput if any of the keys have been pressed. | ||||||||||||||||||
| 83E8 | JR NZ,GameMenu_HandleInput | |||||||||||||||||||
| 83EA | LD B,$05 | Call 8055 with a count of 05. | ||||||||||||||||||
| 83EC | CALL $8055 | |||||||||||||||||||
| 83EF | JR GameMenu_InputLoop | Jump to GameMenu_InputLoop. | ||||||||||||||||||
| 
Process the players input.
 | ||||||||||||||||||||
| GameMenu_HandleInput | 83F1 | CP $FE | Jump to SetUserDefinedKeys if A is equal to FE. | |||||||||||||||||
| 83F3 | JR Z,SetUserDefinedKeys | |||||||||||||||||||
| 
Was Kempston joystick selected?
 | ||||||||||||||||||||
| 83F5 | LD HL,$8E55 | HL=KeyMap_Kempston. | ||||||||||||||||||
| 83F8 | CP $FD | Jump to SetKempstonJoystick if A is equal to FD. | ||||||||||||||||||
| 83FA | JR Z,SetKempstonJoystick | |||||||||||||||||||
| 
Was Interface 2 joystick selected?
 | ||||||||||||||||||||
| 83FC | LD HL,$8E64 | HL=KeyMap_Interface2. | ||||||||||||||||||
| 83FF | CP $FB | Jump to SetNoOperation if A is equal to FB. | ||||||||||||||||||
| 8401 | JR Z,SetNoOperation | |||||||||||||||||||
| 
Was the Cursor joystick selected?
 | ||||||||||||||||||||
| 8403 | LD HL,$8E73 | HL=KeyMap_CursorKeys. | ||||||||||||||||||
| 8406 | CP $F7 | Jump back to GameMenu_InputLoop if the cursor joystick was not selected. | ||||||||||||||||||
| 8408 | JR NZ,GameMenu_InputLoop | |||||||||||||||||||
| 
Self-modifying code. See; HandleControlBits.
 | ||||||||||||||||||||
| SetNoOperation | 840A | LD A,$00 | Write 00 (NOP) to *HandleControlBits. | |||||||||||||||||
| SetActiveKeyMap | 840C | LD ($85F4),A | Write A to *HandleControlBits. | |||||||||||||||||
| 840F | LD DE,$EFE0 | Copy 000F bytes from *HL to *ActiveKeyMap. | ||||||||||||||||||
| 8412 | LD BC,$000F | |||||||||||||||||||
| 8415 | LDIR | |||||||||||||||||||
| 8417 | RET | Return. | ||||||||||||||||||
| 
Self-modifying code. See; HandleControlBits.
 
Invert the bits in the controls routine.
 | ||||||||||||||||||||
| SetKempstonJoystick | 8418 | LD A,$2F | A=2F (CPL) to *HandleControlBits. | |||||||||||||||||
| 841A | JR SetActiveKeyMap | Jump to SetActiveKeyMap. | ||||||||||||||||||
| 
Self-modifying code. See; HandleControlBits.
 | ||||||||||||||||||||
| SetUserDefinedKeys | 841C | LD A,$00 | Write 00 (NOP) to *HandleControlBits. | |||||||||||||||||
| 841E | LD ($85F4),A | |||||||||||||||||||
| 8421 | CALL ClearBottomScreenArea | Call ClearBottomScreenArea. | ||||||||||||||||||
| 
Prints "Please select ".
 | ||||||||||||||||||||
| 8424 | LD HL,$8B88 | HL=Messaging_PleaseSelectKeys. | ||||||||||||||||||
| 8427 | LD DE,$50A7 | DE=50A7 (screen buffer location). | ||||||||||||||||||
| 842A | CALL Print_String | Call Print_String. | ||||||||||||||||||
| 
Cycle through each key/ key messaging to collect the user input:
 
Using "right key", "down key", "left key", "up key" and "fire key" strings.
 | ||||||||||||||||||||
| 842D | LD HL,$8B96 | HL=Messaging_RedefineKeys_Right. | ||||||||||||||||||
| 8430 | LD B,$05 | Store a counter in B of 05 for how many strings to print. | ||||||||||||||||||
| 8432 | LD IX,$EFE0 | IX=ActiveKeyMap. | ||||||||||||||||||
| SetKeys_Loop | 8436 | PUSH BC | Stash the string counter and active keymap position on the stack. | |||||||||||||||||
| 8437 | PUSH IX | |||||||||||||||||||
| 8439 | LD DE,$50B5 | DE=50B5 (screen buffer location). | ||||||||||||||||||
| 843C | CALL Print_String | Call Print_String. | ||||||||||||||||||
| 843F | PUSH HL | Stash the messaging pointer on the stack. | ||||||||||||||||||
| GameMenu_0 | 8440 | CALL PauseCheck | Call PauseCheck. | |||||||||||||||||
| GameMenu_1 | 8443 | LD B,$05 | Call 8055 with a count of 05. | |||||||||||||||||
| 8445 | CALL $8055 | |||||||||||||||||||
| 8448 | LD BC,$FEFE | Read from the keyboard; 
 | ||||||||||||||||||
| GameMenu_2 | 844B | IN A,(C) | ||||||||||||||||||
| 844D | OR %11100000 | Set bits 5-7 (to fill in the extra bits). | ||||||||||||||||||
| 844F | CP $FF | Jump to GameMenu_3 if any of the keys have been pressed. | ||||||||||||||||||
| 8451 | JR NZ,GameMenu_3 | |||||||||||||||||||
| 8453 | RLC B | Rotate B left (with carry). | ||||||||||||||||||
| 8455 | JR C,GameMenu_2 | Jump to GameMenu_2 if A is lower. | ||||||||||||||||||
| 8457 | JR GameMenu_1 | Jump to GameMenu_1. | ||||||||||||||||||
| GameMenu_3 | 8459 | CPL | Invert the bits in A. | |||||||||||||||||
| 845A | AND %00011111 | Keep only bits 0-4. | ||||||||||||||||||
| 845C | LD E,A | E=A. | ||||||||||||||||||
| GameMenu_4 | 845D | RRA | RRA. | |||||||||||||||||
| 845E | JR NC,GameMenu_4 | Jump to GameMenu_4 if A is higher. | ||||||||||||||||||
| 8460 | CP $00 | Jump to GameMenu_0 if A is not equal to 00. | ||||||||||||||||||
| 8462 | JR NZ,GameMenu_0 | |||||||||||||||||||
| 8464 | POP HL | Restore the messaging pointer and active keymap position from the stack. | ||||||||||||||||||
| 8465 | POP IX | |||||||||||||||||||
| 8467 | LD (IX+$00),C | Write the keymap data to the current active key. | ||||||||||||||||||
| 846A | LD (IX+$01),B | |||||||||||||||||||
| 846D | LD (IX+$02),E | |||||||||||||||||||
| 8470 | LD BC,$0003 | Add 0003 to IX to move to the next key. | ||||||||||||||||||
| 8473 | ADD IX,BC | |||||||||||||||||||
| 8475 | POP BC | Restore the string counter from the stack. | ||||||||||||||||||
| 8476 | DJNZ SetKeys_Loop | Decrease the string counter by one and loop back to SetKeys_Loop until all keys have been collected. | ||||||||||||||||||
| 8478 | RET | Return. | ||||||||||||||||||
| Prev: 839F | Up: Map | Next: 8479 |