[57] | 1 | ; Project name : XTIDE Universal BIOS Configurator v2 |
---|
| 2 | ; Description : Menu event handling. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[505] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
[526] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[376] | 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
[505] | 12 | ; |
---|
[376] | 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[505] | 16 | ; GNU General Public License for more details. |
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
[505] | 18 | ; |
---|
[376] | 19 | |
---|
[57] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; MenuEvents_DisplayMenu |
---|
| 25 | ; Parameters: |
---|
| 26 | ; Nothing |
---|
| 27 | ; Returns: |
---|
| 28 | ; Nothing |
---|
| 29 | ; Corrupts registers: |
---|
| 30 | ; All, except segments |
---|
| 31 | ;-------------------------------------------------------------------- |
---|
| 32 | ALIGN JUMP_ALIGN |
---|
| 33 | MenuEvents_DisplayMenu: |
---|
| 34 | mov bx, MenuEventHandler |
---|
[525] | 35 | JMP_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX |
---|
[57] | 36 | |
---|
| 37 | |
---|
| 38 | ;-------------------------------------------------------------------- |
---|
| 39 | ; MenuEventHandler |
---|
| 40 | ; Common parameters for all events: |
---|
| 41 | ; BX: Menu event (anything from MENUEVENT struct) |
---|
| 42 | ; SS:BP: Menu library handle |
---|
| 43 | ; Common return values for all events: |
---|
| 44 | ; CF: Set if event processed |
---|
| 45 | ; Cleared if event not processed |
---|
| 46 | ; Corrupts registers: |
---|
| 47 | ; All |
---|
| 48 | ;-------------------------------------------------------------------- |
---|
| 49 | ALIGN JUMP_ALIGN |
---|
| 50 | MenuEventHandler: |
---|
| 51 | cmp bx, MENUEVENT.RefreshItemFromCX ; Above last supported item? |
---|
| 52 | ja SHORT .EventNotHandled |
---|
[138] | 53 | jmp [cs:bx+.rgfnEventSpecificHandlers] |
---|
[57] | 54 | .EventNotHandled: |
---|
| 55 | .IdleProcessing: |
---|
| 56 | clc |
---|
| 57 | ret |
---|
| 58 | |
---|
| 59 | ALIGN WORD_ALIGN |
---|
| 60 | .rgfnEventSpecificHandlers: |
---|
| 61 | dw .InitializeMenuinitFromDSSI |
---|
| 62 | dw .ExitMenu |
---|
| 63 | dw .IdleProcessing |
---|
| 64 | dw .ItemHighlightedFromCX |
---|
| 65 | dw .ItemSelectedFromCX |
---|
| 66 | dw .KeyStrokeInAX |
---|
| 67 | dw .RefreshTitle |
---|
| 68 | dw .RefreshInformation |
---|
| 69 | dw .RefreshItemFromCX |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | ; Parameters: |
---|
| 73 | ; DS:SI: Ptr to MENUINIT struct to initialize |
---|
| 74 | ; Returns: |
---|
| 75 | ; DS:SI: Ptr to initialized MENUINIT struct |
---|
| 76 | ALIGN JUMP_ALIGN |
---|
| 77 | .InitializeMenuinitFromDSSI: |
---|
| 78 | push ds |
---|
| 79 | push cs |
---|
| 80 | pop ds |
---|
| 81 | mov di, g_MenupageForMainMenu |
---|
| 82 | call Menupage_SetActiveMenupageFromDSDI |
---|
| 83 | call Menupage_GetVisibleMenuitemsToAXfromDSDI |
---|
| 84 | pop ds |
---|
| 85 | |
---|
[592] | 86 | mov [si+MENUINIT.wItems], ax |
---|
| 87 | mov WORD [si+MENUINIT.wTitleAndInfoLines], INFO_LINES_IN_MENU << 8 | TITLE_LINES_IN_MENU |
---|
[138] | 88 | mov BYTE [si+MENUINIT.bWidth], MENU_WIDTH |
---|
[57] | 89 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
| 90 | mov [si+MENUINIT.bHeight], ah |
---|
[109] | 91 | call MainMenu_EnterMenuOrModifyItemVisibility |
---|
[57] | 92 | stc |
---|
| 93 | ret |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | ; Parameters: |
---|
| 97 | ; None |
---|
[59] | 98 | ; Returns: |
---|
| 99 | ; CF: Set to exit menu |
---|
| 100 | ; Clear to cancel exit |
---|
[57] | 101 | ALIGN JUMP_ALIGN |
---|
| 102 | .ExitMenu: |
---|
[59] | 103 | call Menupage_GetActiveMenupageToDSDI |
---|
| 104 | mov si, [di+MENUPAGE.fnBack] |
---|
[206] | 105 | cmp si, ExitToDosFromBackButton |
---|
[59] | 106 | je SHORT .QuitProgram |
---|
| 107 | call si ; Back to previous menu |
---|
| 108 | clc |
---|
| 109 | ret |
---|
| 110 | |
---|
| 111 | ALIGN JUMP_ALIGN |
---|
| 112 | .QuitProgram: |
---|
[592] | 113 | mov bx, g_szDlgExitToDos |
---|
| 114 | call Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX |
---|
[59] | 115 | jz SHORT .ExitToDOS |
---|
| 116 | clc |
---|
| 117 | ret |
---|
| 118 | .ExitToDOS: |
---|
| 119 | call Buffers_SaveChangesIfFileLoaded |
---|
[206] | 120 | CALL_MENU_LIBRARY Close |
---|
[57] | 121 | stc |
---|
| 122 | ret |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | ; Parameters: |
---|
| 126 | ; CX: Index of new highlighted item |
---|
| 127 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED |
---|
| 128 | ALIGN JUMP_ALIGN |
---|
| 129 | .ItemHighlightedFromCX: |
---|
| 130 | CALL_MENU_LIBRARY ClearInformationArea |
---|
| 131 | CALL_MENU_LIBRARY RefreshInformation |
---|
| 132 | stc |
---|
| 133 | ret |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | ; Parameters: |
---|
| 137 | ; CX: Index of selected item |
---|
| 138 | ALIGN JUMP_ALIGN |
---|
| 139 | .ItemSelectedFromCX: |
---|
| 140 | call Menupage_GetActiveMenupageToDSDI |
---|
| 141 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI |
---|
| 142 | call [si+MENUITEM.fnActivate] |
---|
| 143 | stc |
---|
| 144 | ret |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | ; Parameters: |
---|
| 148 | ; AL: ASCII character for the key |
---|
| 149 | ; AH: Keyboard library scan code for the key |
---|
| 150 | ALIGN JUMP_ALIGN |
---|
| 151 | .KeyStrokeInAX: |
---|
| 152 | cmp ah, KEY_DISPLAY_ITEM_HELP |
---|
[181] | 153 | jne SHORT .EventNotHandled |
---|
[57] | 154 | |
---|
[181] | 155 | ;ALIGN JUMP_ALIGN |
---|
| 156 | ;.DisplayHelp: |
---|
[57] | 157 | call Menupage_GetActiveMenupageToDSDI |
---|
| 158 | CALL_MENU_LIBRARY GetHighlightedItemToAX |
---|
| 159 | xchg cx, ax |
---|
| 160 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI |
---|
| 161 | call Menuitem_DisplayHelpMessageFromDSSI |
---|
| 162 | stc |
---|
| 163 | ret |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | ; Parameters: |
---|
| 167 | ; CX: Index of item to refresh |
---|
| 168 | ; Cursor has been positioned to the beginning of item line |
---|
| 169 | ALIGN JUMP_ALIGN |
---|
| 170 | .RefreshItemFromCX: |
---|
[592] | 171 | inc cx ; NO_ITEM_HIGHLIGHTED ? |
---|
| 172 | jz SHORT .NothingToRefresh |
---|
| 173 | dec cx |
---|
[57] | 174 | call Menupage_GetActiveMenupageToDSDI |
---|
| 175 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI |
---|
| 176 | jnc SHORT .NothingToRefresh |
---|
| 177 | call MenuitemPrint_NameWithPossibleValueFromDSSI |
---|
| 178 | .NothingToRefresh: |
---|
| 179 | stc |
---|
| 180 | ret |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | ; Parameters: |
---|
| 184 | ; CX: Index of highlighted item |
---|
| 185 | ; Cursor has been positioned to the beginning of first line |
---|
| 186 | ALIGN JUMP_ALIGN |
---|
| 187 | .RefreshInformation: |
---|
[592] | 188 | inc cx ; NO_ITEM_HIGHLIGHTED ? |
---|
| 189 | jz SHORT .NothingToRefresh |
---|
| 190 | dec cx |
---|
[57] | 191 | call Menupage_GetActiveMenupageToDSDI |
---|
| 192 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI |
---|
| 193 | call MenuitemPrint_PrintQuickInfoFromDSSI |
---|
| 194 | stc |
---|
| 195 | ret |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | ; Parameters: |
---|
| 199 | ; CX: Index of highlighted item |
---|
| 200 | ; Cursor has been positioned to the beginning of first line |
---|
| 201 | ALIGN JUMP_ALIGN |
---|
| 202 | .RefreshTitle: |
---|
| 203 | call .PrintProgramName |
---|
| 204 | call .PrintLoadStatus |
---|
| 205 | call .PrintStatusOfUnsavedChanges |
---|
| 206 | stc |
---|
[505] | 207 | .ReturnSinceNothingToPrint: |
---|
[57] | 208 | ret |
---|
| 209 | |
---|
| 210 | ALIGN JUMP_ALIGN |
---|
| 211 | .PrintProgramName: |
---|
| 212 | mov si, g_szProgramTitle |
---|
[505] | 213 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI |
---|
[57] | 214 | |
---|
| 215 | ALIGN JUMP_ALIGN |
---|
| 216 | .PrintLoadStatus: |
---|
[592] | 217 | mov al, [g_cfgVars+CFGVARS.wFlags] |
---|
| 218 | test al, FLG_CFGVARS_FILELOADED |
---|
[57] | 219 | jnz SHORT .PrintNameOfLoadedFile |
---|
[592] | 220 | test al, FLG_CFGVARS_ROMLOADED |
---|
[525] | 221 | mov si, g_szEEPROM |
---|
| 222 | jnz SHORT .PrintNameOfLoadedFileOrEeprom |
---|
[57] | 223 | ; Fall to .PrintNothingLoaded |
---|
| 224 | |
---|
| 225 | .PrintNothingLoaded: |
---|
| 226 | mov si, g_szBiosIsNotLoaded |
---|
[505] | 227 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI |
---|
[57] | 228 | |
---|
| 229 | ALIGN JUMP_ALIGN |
---|
| 230 | .PrintNameOfLoadedFile: |
---|
| 231 | mov si, g_cfgVars+CFGVARS.szOpenedFile |
---|
[525] | 232 | ; Fall to .PrintNameOfLoadedFileOrEeprom |
---|
[57] | 233 | |
---|
| 234 | ALIGN JUMP_ALIGN |
---|
[525] | 235 | .PrintNameOfLoadedFileOrEeprom: |
---|
[57] | 236 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI |
---|
| 237 | ; Fall to .PrintTypeOfLoadedBios |
---|
| 238 | |
---|
| 239 | .PrintTypeOfLoadedBios: |
---|
| 240 | mov si, g_szSourceAndTypeSeparator |
---|
| 241 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI |
---|
| 242 | call Buffers_IsXtideUniversalBiosLoaded |
---|
| 243 | jne SHORT .PrintUnidentifiedType |
---|
| 244 | |
---|
| 245 | call Buffers_GetFileBufferToESDI |
---|
| 246 | mov bx, es |
---|
| 247 | lea si, [di+ROMVARS.szVersion] |
---|
[505] | 248 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI |
---|
[57] | 249 | |
---|
| 250 | ALIGN JUMP_ALIGN |
---|
| 251 | .PrintUnidentifiedType: |
---|
| 252 | mov si, g_szUnidentified |
---|
[505] | 253 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI |
---|
[57] | 254 | |
---|
| 255 | ALIGN JUMP_ALIGN |
---|
| 256 | .PrintStatusOfUnsavedChanges: |
---|
[592] | 257 | test BYTE [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED |
---|
[57] | 258 | jz SHORT .ReturnSinceNothingToPrint |
---|
| 259 | mov si, g_szUnsaved |
---|
[505] | 260 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI |
---|