Prev: F4F8 Up: Map Next: F5C5
F51D: Main Menu Select Options
Handle KEYS / JOYSTICK / REDEFINE / CONTINUE on the controls menu. Returns to the caller of Print_ControlsMenu (the Learner/Super pass at MainMenu_ChoosePass) when CONTINUE (C) is chosen.
If keyboard mode is selected, highlight the KEYS option first.
MainMenu_SelectOptions F51D LD A,($F602) If Kempston is already selected (Flag_KempstonJoystickEnabled), skip the KEYS highlight at MainMenu_SelectOptions_KeyLoop.
F520 OR A
F521 JR NZ,MainMenu_SelectOptions_KeyLoop
F523 LD A,$68 Highlight the KEYS option (68) and pulse the menu timing.
F525 CALL Print_ControlKeyLabels
F528 CALL Pulse_MenuTiming
Poll the controls menu for KEYS, JOYSTICK, REDEFINE or CONTINUE.
MainMenu_SelectOptions_KeyLoop F52B CALL Wait_KeyWithMenuMusic Call Wait_KeyWithMenuMusic for one menu-music wait tick.
F52E CALL Read_KeyboardControls Call Read_KeyboardControls to read a key code.
F531 CP $4B Was K (KEYS) pressed? If so, select keyboard at MainMenu_SelectOptions_Keys.
F533 JR Z,MainMenu_SelectOptions_Keys
F535 CP $4A Was J (JOYSTICK) pressed? If so, select Kempston at MainMenu_SelectOptions_Joystick.
F537 JR Z,MainMenu_SelectOptions_Joystick
F539 CP $52 Was R (REDEFINE) pressed? If so, redefine keys at MainMenu_SelectOptions_Redefine.
F53B JR Z,MainMenu_SelectOptions_Redefine
F53D CP $43 Was C (CONTINUE) pressed? If so, return to MainMenu_ChoosePass.
F53F RET Z
F540 JR MainMenu_SelectOptions_KeyLoop Jump to MainMenu_SelectOptions_KeyLoop to keep waiting.
Select keyboard controls and refresh the highlights.
MainMenu_SelectOptions_Keys F542 XOR A Select keyboard controls (clear Flag_KempstonJoystickEnabled) and refresh the menu highlights at MainMenu_SelectOptions_Refresh.
F543 LD ($F602),A
F546 JR MainMenu_SelectOptions_Refresh
Select Kempston and click the menu.
MainMenu_SelectOptions_Joystick F548 LD A,$01 Select Kempston (01 at Flag_KempstonJoystickEnabled) and clear the KEYS column labels.
F54A LD ($F602),A
F54D XOR A
F54E CALL Print_ControlKeyLabels_Short
F551 JR MainMenu_SelectOptions_KeyLoop
Clear the key table to ? prompt for seven new keys, and print each choice.
MainMenu_SelectOptions_Redefine F553 XOR A Select keyboard mode (clear Flag_KempstonJoystickEnabled) before redefine.
F554 LD ($F602),A
F557 LD A,$3F Fill all seven control-key slots at Table_ControlKeyCodes with ? placeholders.
F559 LD HL,$F5FB
F55C LD B,$07
Fill the seven control-key slots at Table_ControlKeyCodes with ? placeholders.
MainMenu_SelectOptions_ClearKeys F55E LD (HL),A Write the placeholder into this slot and step HL onto the next key slot until all seven are cleared.
F55F INC HL
F560 DJNZ MainMenu_SelectOptions_ClearKeys
F562 LD A,$C7 Print the redefine placeholders in attribute C7 and pulse the menu timing.
F564 CALL Print_ControlKeyLabels
F567 CALL Pulse_MenuTiming
F56A LD A,$4F Set the text attribute to 4F for newly typed key labels.
F56C LD ($7307),A
F56F LD IX,$F5FB Point IX at Table_ControlKeyCodes.
F573 LD HL,$590C Point HL at the first key's attribute cell (590C (attribute buffer)), then remember it in Pointer_ControlKeyDefinitionCursor.
F576 LD ($F5F9),HL
F579 LD B,$07 Load B with 07 keys to redefine.
Prompt for the next of seven redefine-key presses.
MainMenu_SelectOptions_RedefineLoop F57B PUSH BC Stash BC and IX on the stack.
Wait until a fresh key is pressed during redefine.
MainMenu_SelectOptions_WaitUniqueKey F57C PUSH IX
F57E CALL Wait_KeyWithMenuMusic Call Wait_KeyWithMenuMusic for one menu-music wait tick.
F581 POP IX Restore IX from the stack.
F583 CALL Read_KeyboardControls Call Read_KeyboardControls to read a key code.
F586 OR A Was a key pressed? If not, keep waiting at MainMenu_SelectOptions_WaitUniqueKey.
F587 JR Z,MainMenu_SelectOptions_WaitUniqueKey
F589 LD HL,$F5FB Point HL at Table_ControlKeyCodes.
F58C LD B,$07 Load B with 07 to scan for duplicates.
Reject the key if it already appears in Table_ControlKeyCodes; otherwise store and print it.
MainMenu_SelectOptions_CheckDuplicate F58E CP (HL) Does this code already appear in the table? If so, reject it and wait again at MainMenu_SelectOptions_WaitUniqueKey.
F58F JR Z,MainMenu_SelectOptions_WaitUniqueKey
F591 INC HL Advance to the next slot.
F592 DJNZ MainMenu_SelectOptions_CheckDuplicate Loop until all slots are checked.
F594 LD (IX+$00),A Store the new key code at IX.
F597 INC IX Advance IX onto the next slot.
F599 PUSH IX Stash IX and AF on the stack.
F59B PUSH AF
F59C CALL ColourCycle_MainMenuLogo Call ColourCycle_MainMenuLogo to colour-cycle the logo (menu acknowledge).
F59F POP AF Restore AF and IX from the stack.
F5A0 POP IX
F5A2 LD HL,($F5F9) Fetch the current label attribute address (Pointer_ControlKeyDefinitionCursor). Keep the key code in E. Clear D. Call Print_Character to print that character.
F5A5 LD E,A
F5A6 LD D,$00
F5A8 CALL Print_Character
F5AB LD BC,$0040 Advance the key-label attribute address by one menu row (0040) and store it in Pointer_ControlKeyDefinitionCursor.
F5AE ADD HL,BC
F5AF LD ($F5F9),HL
F5B2 POP BC Restore BC from the stack.
F5B3 DJNZ MainMenu_SelectOptions_RedefineLoop Loop until all seven keys are redefined.
Refresh both highlight attributes and return to the key loop.
MainMenu_SelectOptions_Refresh F5B5 LD A,$C7 Reprint all seven key labels in attribute C7.
F5B7 CALL Print_ControlKeyLabels
F5BA LD A,$68 Reprint the KEYS column highlight in attribute 68.
F5BC CALL Print_ControlKeyLabels
F5BF CALL Pulse_MenuTiming Call Pulse_MenuTiming to pulse the menu timing.
F5C2 JP MainMenu_SelectOptions_KeyLoop Jump to MainMenu_SelectOptions_KeyLoop to wait for the next KEYS / JOYSTICK / REDEFINE / CONTINUE choice.
Prev: F4F8 Up: Map Next: F5C5