Prev: 62712 Up: Map Next: 62917
62749: 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 62749 LD A,(62978) If Kempston is already selected (Flag_KempstonJoystickEnabled), skip the KEYS highlight at MainMenu_SelectOptions_KeyLoop.
62752 OR A
62753 JR NZ,MainMenu_SelectOptions_KeyLoop
62755 LD A,104 Highlight the KEYS option (104) and pulse the menu timing.
62757 CALL Print_ControlKeyLabels
62760 CALL Pulse_MenuTiming
Poll the controls menu for KEYS, JOYSTICK, REDEFINE or CONTINUE.
MainMenu_SelectOptions_KeyLoop 62763 CALL Wait_KeyWithMenuMusic Call Wait_KeyWithMenuMusic for one menu-music wait tick.
62766 CALL Read_KeyboardControls Call Read_KeyboardControls to read a key code.
62769 CP 75 Was K (KEYS) pressed? If so, select keyboard at MainMenu_SelectOptions_Keys.
62771 JR Z,MainMenu_SelectOptions_Keys
62773 CP 74 Was J (JOYSTICK) pressed? If so, select Kempston at MainMenu_SelectOptions_Joystick.
62775 JR Z,MainMenu_SelectOptions_Joystick
62777 CP 82 Was R (REDEFINE) pressed? If so, redefine keys at MainMenu_SelectOptions_Redefine.
62779 JR Z,MainMenu_SelectOptions_Redefine
62781 CP 67 Was C (CONTINUE) pressed? If so, return to MainMenu_ChoosePass.
62783 RET Z
62784 JR MainMenu_SelectOptions_KeyLoop Jump to MainMenu_SelectOptions_KeyLoop to keep waiting.
Select keyboard controls and refresh the highlights.
MainMenu_SelectOptions_Keys 62786 XOR A Select keyboard controls (clear Flag_KempstonJoystickEnabled) and refresh the menu highlights at MainMenu_SelectOptions_Refresh.
62787 LD (62978),A
62790 JR MainMenu_SelectOptions_Refresh
Select Kempston and click the menu.
MainMenu_SelectOptions_Joystick 62792 LD A,1 Select Kempston (1 at Flag_KempstonJoystickEnabled) and clear the KEYS column labels.
62794 LD (62978),A
62797 XOR A
62798 CALL Print_ControlKeyLabels_Short
62801 JR MainMenu_SelectOptions_KeyLoop
Clear the key table to ? prompt for seven new keys, and print each choice.
MainMenu_SelectOptions_Redefine 62803 XOR A Select keyboard mode (clear Flag_KempstonJoystickEnabled) before redefine.
62804 LD (62978),A
62807 LD A,63 Fill all seven control-key slots at Table_ControlKeyCodes with ? placeholders.
62809 LD HL,62971
62812 LD B,7
Fill the seven control-key slots at Table_ControlKeyCodes with ? placeholders.
MainMenu_SelectOptions_ClearKeys 62814 LD (HL),A Write the placeholder into this slot and step HL onto the next key slot until all seven are cleared.
62815 INC HL
62816 DJNZ MainMenu_SelectOptions_ClearKeys
62818 LD A,199 Print the redefine placeholders in attribute 199 and pulse the menu timing.
62820 CALL Print_ControlKeyLabels
62823 CALL Pulse_MenuTiming
62826 LD A,79 Set the text attribute to 79 for newly typed key labels.
62828 LD (29447),A
62831 LD IX,62971 Point IX at Table_ControlKeyCodes.
62835 LD HL,22796 Point HL at the first key's attribute cell (22796 (attribute buffer)), then remember it in Pointer_ControlKeyDefinitionCursor.
62838 LD (62969),HL
62841 LD B,7 Load B with 7 keys to redefine.
Prompt for the next of seven redefine-key presses.
MainMenu_SelectOptions_RedefineLoop 62843 PUSH BC Stash BC and IX on the stack.
Wait until a fresh key is pressed during redefine.
MainMenu_SelectOptions_WaitUniqueKey 62844 PUSH IX
62846 CALL Wait_KeyWithMenuMusic Call Wait_KeyWithMenuMusic for one menu-music wait tick.
62849 POP IX Restore IX from the stack.
62851 CALL Read_KeyboardControls Call Read_KeyboardControls to read a key code.
62854 OR A Was a key pressed? If not, keep waiting at MainMenu_SelectOptions_WaitUniqueKey.
62855 JR Z,MainMenu_SelectOptions_WaitUniqueKey
62857 LD HL,62971 Point HL at Table_ControlKeyCodes.
62860 LD B,7 Load B with 7 to scan for duplicates.
Reject the key if it already appears in Table_ControlKeyCodes; otherwise store and print it.
MainMenu_SelectOptions_CheckDuplicate 62862 CP (HL) Does this code already appear in the table? If so, reject it and wait again at MainMenu_SelectOptions_WaitUniqueKey.
62863 JR Z,MainMenu_SelectOptions_WaitUniqueKey
62865 INC HL Advance to the next slot.
62866 DJNZ MainMenu_SelectOptions_CheckDuplicate Loop until all slots are checked.
62868 LD (IX+0),A Store the new key code at IX.
62871 INC IX Advance IX onto the next slot.
62873 PUSH IX Stash IX and AF on the stack.
62875 PUSH AF
62876 CALL ColourCycle_MainMenuLogo Call ColourCycle_MainMenuLogo to colour-cycle the logo (menu acknowledge).
62879 POP AF Restore AF and IX from the stack.
62880 POP IX
62882 LD HL,(62969) Fetch the current label attribute address (Pointer_ControlKeyDefinitionCursor). Keep the key code in E. Clear D. Call Print_Character to print that character.
62885 LD E,A
62886 LD D,0
62888 CALL Print_Character
62891 LD BC,64 Advance the key-label attribute address by one menu row (0064) and store it in Pointer_ControlKeyDefinitionCursor.
62894 ADD HL,BC
62895 LD (62969),HL
62898 POP BC Restore BC from the stack.
62899 DJNZ MainMenu_SelectOptions_RedefineLoop Loop until all seven keys are redefined.
Refresh both highlight attributes and return to the key loop.
MainMenu_SelectOptions_Refresh 62901 LD A,199 Reprint all seven key labels in attribute 199.
62903 CALL Print_ControlKeyLabels
62906 LD A,104 Reprint the KEYS column highlight in attribute 104.
62908 CALL Print_ControlKeyLabels
62911 CALL Pulse_MenuTiming Call Pulse_MenuTiming to pulse the menu timing.
62914 JP MainMenu_SelectOptions_KeyLoop Jump to MainMenu_SelectOptions_KeyLoop to wait for the next KEYS / JOYSTICK / REDEFINE / CONTINUE choice.
Prev: 62712 Up: Map Next: 62917