[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
|
---|
[376] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
|
---|
| 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
|
---|
| 35 | CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
|
---|
| 36 | ret
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | ;--------------------------------------------------------------------
|
---|
| 40 | ; MenuEventHandler
|
---|
| 41 | ; Common parameters for all events:
|
---|
| 42 | ; BX: Menu event (anything from MENUEVENT struct)
|
---|
| 43 | ; SS:BP: Menu library handle
|
---|
| 44 | ; Common return values for all events:
|
---|
| 45 | ; CF: Set if event processed
|
---|
| 46 | ; Cleared if event not processed
|
---|
| 47 | ; Corrupts registers:
|
---|
| 48 | ; All
|
---|
| 49 | ;--------------------------------------------------------------------
|
---|
| 50 | ALIGN JUMP_ALIGN
|
---|
| 51 | MenuEventHandler:
|
---|
| 52 | cmp bx, MENUEVENT.RefreshItemFromCX ; Above last supported item?
|
---|
| 53 | ja SHORT .EventNotHandled
|
---|
[138] | 54 | jmp [cs:bx+.rgfnEventSpecificHandlers]
|
---|
[57] | 55 | .EventNotHandled:
|
---|
| 56 | .IdleProcessing:
|
---|
| 57 | clc
|
---|
| 58 | ret
|
---|
| 59 |
|
---|
| 60 | ALIGN WORD_ALIGN
|
---|
| 61 | .rgfnEventSpecificHandlers:
|
---|
| 62 | dw .InitializeMenuinitFromDSSI
|
---|
| 63 | dw .ExitMenu
|
---|
| 64 | dw .IdleProcessing
|
---|
| 65 | dw .ItemHighlightedFromCX
|
---|
| 66 | dw .ItemSelectedFromCX
|
---|
| 67 | dw .KeyStrokeInAX
|
---|
| 68 | dw .RefreshTitle
|
---|
| 69 | dw .RefreshInformation
|
---|
| 70 | dw .RefreshItemFromCX
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | ; Parameters:
|
---|
| 74 | ; DS:SI: Ptr to MENUINIT struct to initialize
|
---|
| 75 | ; Returns:
|
---|
| 76 | ; DS:SI: Ptr to initialized MENUINIT struct
|
---|
| 77 | ALIGN JUMP_ALIGN
|
---|
| 78 | .InitializeMenuinitFromDSSI:
|
---|
| 79 | push ds
|
---|
| 80 | push cs
|
---|
| 81 | pop ds
|
---|
| 82 | mov di, g_MenupageForMainMenu
|
---|
| 83 | call Menupage_SetActiveMenupageFromDSDI
|
---|
| 84 | call Menupage_GetVisibleMenuitemsToAXfromDSDI
|
---|
| 85 | pop ds
|
---|
| 86 |
|
---|
| 87 | mov WORD [si+MENUINIT.wItems], ax
|
---|
| 88 | mov WORD [si+MENUINIT.bTitleLines], TITLE_LINES_IN_MENU
|
---|
| 89 | mov WORD [si+MENUINIT.bInfoLines], INFO_LINES_IN_MENU
|
---|
[138] | 90 | mov BYTE [si+MENUINIT.bWidth], MENU_WIDTH
|
---|
[57] | 91 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
| 92 | mov [si+MENUINIT.bHeight], ah
|
---|
[109] | 93 | call MainMenu_EnterMenuOrModifyItemVisibility
|
---|
[57] | 94 | stc
|
---|
| 95 | ret
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | ; Parameters:
|
---|
| 99 | ; None
|
---|
[59] | 100 | ; Returns:
|
---|
| 101 | ; CF: Set to exit menu
|
---|
| 102 | ; Clear to cancel exit
|
---|
[57] | 103 | ALIGN JUMP_ALIGN
|
---|
| 104 | .ExitMenu:
|
---|
[59] | 105 | call Menupage_GetActiveMenupageToDSDI
|
---|
| 106 | mov si, [di+MENUPAGE.fnBack]
|
---|
[206] | 107 | cmp si, ExitToDosFromBackButton
|
---|
[59] | 108 | je SHORT .QuitProgram
|
---|
| 109 | call si ; Back to previous menu
|
---|
| 110 | clc
|
---|
| 111 | ret
|
---|
| 112 |
|
---|
| 113 | ALIGN JUMP_ALIGN
|
---|
| 114 | .QuitProgram:
|
---|
| 115 | call Dialogs_DisplayQuitDialog
|
---|
| 116 | jz SHORT .ExitToDOS
|
---|
| 117 | clc
|
---|
| 118 | ret
|
---|
| 119 | .ExitToDOS:
|
---|
| 120 | call Buffers_SaveChangesIfFileLoaded
|
---|
[206] | 121 | CALL_MENU_LIBRARY Close
|
---|
[57] | 122 | stc
|
---|
| 123 | ret
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | ; Parameters:
|
---|
| 127 | ; CX: Index of new highlighted item
|
---|
| 128 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
| 129 | ALIGN JUMP_ALIGN
|
---|
| 130 | .ItemHighlightedFromCX:
|
---|
| 131 | CALL_MENU_LIBRARY ClearInformationArea
|
---|
| 132 | CALL_MENU_LIBRARY RefreshInformation
|
---|
| 133 | stc
|
---|
| 134 | ret
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | ; Parameters:
|
---|
| 138 | ; CX: Index of selected item
|
---|
| 139 | ALIGN JUMP_ALIGN
|
---|
| 140 | .ItemSelectedFromCX:
|
---|
| 141 | call Menupage_GetActiveMenupageToDSDI
|
---|
| 142 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
|
---|
| 143 | call [si+MENUITEM.fnActivate]
|
---|
| 144 | stc
|
---|
| 145 | ret
|
---|
| 146 |
|
---|
| 147 |
|
---|
| 148 | ; Parameters:
|
---|
| 149 | ; AL: ASCII character for the key
|
---|
| 150 | ; AH: Keyboard library scan code for the key
|
---|
| 151 | ALIGN JUMP_ALIGN
|
---|
| 152 | .KeyStrokeInAX:
|
---|
| 153 | cmp ah, KEY_DISPLAY_ITEM_HELP
|
---|
[181] | 154 | jne SHORT .EventNotHandled
|
---|
[57] | 155 |
|
---|
[181] | 156 | ;ALIGN JUMP_ALIGN
|
---|
| 157 | ;.DisplayHelp:
|
---|
[57] | 158 | call Menupage_GetActiveMenupageToDSDI
|
---|
| 159 | CALL_MENU_LIBRARY GetHighlightedItemToAX
|
---|
| 160 | xchg cx, ax
|
---|
| 161 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
|
---|
| 162 | call Menuitem_DisplayHelpMessageFromDSSI
|
---|
| 163 | stc
|
---|
| 164 | ret
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 | ; Parameters:
|
---|
| 168 | ; CX: Index of item to refresh
|
---|
| 169 | ; Cursor has been positioned to the beginning of item line
|
---|
| 170 | ALIGN JUMP_ALIGN
|
---|
| 171 | .RefreshItemFromCX:
|
---|
| 172 | cmp cx, NO_ITEM_HIGHLIGHTED
|
---|
| 173 | je SHORT .NothingToRefresh
|
---|
| 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:
|
---|
| 188 | cmp cx, NO_ITEM_HIGHLIGHTED
|
---|
| 189 | je SHORT .NothingToRefresh
|
---|
| 190 | call Menupage_GetActiveMenupageToDSDI
|
---|
| 191 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
|
---|
| 192 | call MenuitemPrint_PrintQuickInfoFromDSSI
|
---|
| 193 | stc
|
---|
| 194 | ret
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 | ; Parameters:
|
---|
| 198 | ; CX: Index of highlighted item
|
---|
| 199 | ; Cursor has been positioned to the beginning of first line
|
---|
| 200 | ALIGN JUMP_ALIGN
|
---|
| 201 | .RefreshTitle:
|
---|
| 202 | call .PrintProgramName
|
---|
| 203 | call .PrintLoadStatus
|
---|
| 204 | call .PrintStatusOfUnsavedChanges
|
---|
| 205 | stc
|
---|
[505] | 206 | .ReturnSinceNothingToPrint:
|
---|
[57] | 207 | ret
|
---|
| 208 |
|
---|
| 209 | ALIGN JUMP_ALIGN
|
---|
| 210 | .PrintProgramName:
|
---|
| 211 | mov si, g_szProgramTitle
|
---|
[505] | 212 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
[57] | 213 |
|
---|
| 214 | ALIGN JUMP_ALIGN
|
---|
| 215 | .PrintLoadStatus:
|
---|
| 216 | mov ax, [g_cfgVars+CFGVARS.wFlags]
|
---|
| 217 | test ax, FLG_CFGVARS_FILELOADED
|
---|
| 218 | jnz SHORT .PrintNameOfLoadedFile
|
---|
| 219 | test ax, FLG_CFGVARS_ROMLOADED
|
---|
| 220 | jnz SHORT .PrintLoadedEeprom
|
---|
| 221 | ; Fall to .PrintNothingLoaded
|
---|
| 222 |
|
---|
| 223 | .PrintNothingLoaded:
|
---|
| 224 | mov si, g_szBiosIsNotLoaded
|
---|
[505] | 225 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
[57] | 226 |
|
---|
| 227 | ALIGN JUMP_ALIGN
|
---|
| 228 | .PrintNameOfLoadedFile:
|
---|
| 229 | mov si, g_cfgVars+CFGVARS.szOpenedFile
|
---|
| 230 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
| 231 | jmp SHORT .PrintTypeOfLoadedBios
|
---|
| 232 |
|
---|
| 233 | ALIGN JUMP_ALIGN
|
---|
| 234 | .PrintLoadedEeprom:
|
---|
| 235 | mov si, g_szEEPROM
|
---|
| 236 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
| 237 | ; Fall to .PrintTypeOfLoadedBios
|
---|
| 238 |
|
---|
| 239 | ALIGN JUMP_ALIGN
|
---|
| 240 | .PrintTypeOfLoadedBios:
|
---|
| 241 | mov si, g_szSourceAndTypeSeparator
|
---|
| 242 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
| 243 | call Buffers_IsXtideUniversalBiosLoaded
|
---|
| 244 | jne SHORT .PrintUnidentifiedType
|
---|
| 245 |
|
---|
| 246 | call Buffers_GetFileBufferToESDI
|
---|
| 247 | mov bx, es
|
---|
| 248 | lea si, [di+ROMVARS.szVersion]
|
---|
[505] | 249 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
|
---|
[57] | 250 |
|
---|
| 251 | ALIGN JUMP_ALIGN
|
---|
| 252 | .PrintUnidentifiedType:
|
---|
| 253 | mov si, g_szUnidentified
|
---|
[505] | 254 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
[57] | 255 |
|
---|
| 256 | ALIGN JUMP_ALIGN
|
---|
| 257 | .PrintStatusOfUnsavedChanges:
|
---|
| 258 | test WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
|
---|
| 259 | jz SHORT .ReturnSinceNothingToPrint
|
---|
| 260 | mov si, g_szUnsaved
|
---|
[505] | 261 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|