1 | ; Project name : XTIDE Universal BIOS Configurator v2
|
---|
2 | ; Description : Menu event handling.
|
---|
3 |
|
---|
4 | ;
|
---|
5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
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.
|
---|
12 | ;
|
---|
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
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
18 | ;
|
---|
19 |
|
---|
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 | JMP_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
|
---|
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
|
---|
53 | jmp [cs:bx+.rgfnEventSpecificHandlers]
|
---|
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 |
|
---|
86 | mov WORD [si+MENUINIT.wItems], ax
|
---|
87 | mov WORD [si+MENUINIT.bTitleLines], TITLE_LINES_IN_MENU
|
---|
88 | mov WORD [si+MENUINIT.bInfoLines], INFO_LINES_IN_MENU
|
---|
89 | mov BYTE [si+MENUINIT.bWidth], MENU_WIDTH
|
---|
90 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
91 | mov [si+MENUINIT.bHeight], ah
|
---|
92 | call MainMenu_EnterMenuOrModifyItemVisibility
|
---|
93 | stc
|
---|
94 | ret
|
---|
95 |
|
---|
96 |
|
---|
97 | ; Parameters:
|
---|
98 | ; None
|
---|
99 | ; Returns:
|
---|
100 | ; CF: Set to exit menu
|
---|
101 | ; Clear to cancel exit
|
---|
102 | ALIGN JUMP_ALIGN
|
---|
103 | .ExitMenu:
|
---|
104 | call Menupage_GetActiveMenupageToDSDI
|
---|
105 | mov si, [di+MENUPAGE.fnBack]
|
---|
106 | cmp si, ExitToDosFromBackButton
|
---|
107 | je SHORT .QuitProgram
|
---|
108 | call si ; Back to previous menu
|
---|
109 | clc
|
---|
110 | ret
|
---|
111 |
|
---|
112 | ALIGN JUMP_ALIGN
|
---|
113 | .QuitProgram:
|
---|
114 | call Dialogs_DisplayQuitDialog
|
---|
115 | jz SHORT .ExitToDOS
|
---|
116 | clc
|
---|
117 | ret
|
---|
118 | .ExitToDOS:
|
---|
119 | call Buffers_SaveChangesIfFileLoaded
|
---|
120 | CALL_MENU_LIBRARY Close
|
---|
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
|
---|
153 | jne SHORT .EventNotHandled
|
---|
154 |
|
---|
155 | ;ALIGN JUMP_ALIGN
|
---|
156 | ;.DisplayHelp:
|
---|
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:
|
---|
171 | cmp cx, NO_ITEM_HIGHLIGHTED
|
---|
172 | je SHORT .NothingToRefresh
|
---|
173 | call Menupage_GetActiveMenupageToDSDI
|
---|
174 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
|
---|
175 | jnc SHORT .NothingToRefresh
|
---|
176 | call MenuitemPrint_NameWithPossibleValueFromDSSI
|
---|
177 | .NothingToRefresh:
|
---|
178 | stc
|
---|
179 | ret
|
---|
180 |
|
---|
181 |
|
---|
182 | ; Parameters:
|
---|
183 | ; CX: Index of highlighted item
|
---|
184 | ; Cursor has been positioned to the beginning of first line
|
---|
185 | ALIGN JUMP_ALIGN
|
---|
186 | .RefreshInformation:
|
---|
187 | cmp cx, NO_ITEM_HIGHLIGHTED
|
---|
188 | je SHORT .NothingToRefresh
|
---|
189 | call Menupage_GetActiveMenupageToDSDI
|
---|
190 | call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
|
---|
191 | call MenuitemPrint_PrintQuickInfoFromDSSI
|
---|
192 | stc
|
---|
193 | ret
|
---|
194 |
|
---|
195 |
|
---|
196 | ; Parameters:
|
---|
197 | ; CX: Index of highlighted item
|
---|
198 | ; Cursor has been positioned to the beginning of first line
|
---|
199 | ALIGN JUMP_ALIGN
|
---|
200 | .RefreshTitle:
|
---|
201 | call .PrintProgramName
|
---|
202 | call .PrintLoadStatus
|
---|
203 | call .PrintStatusOfUnsavedChanges
|
---|
204 | stc
|
---|
205 | .ReturnSinceNothingToPrint:
|
---|
206 | ret
|
---|
207 |
|
---|
208 | ALIGN JUMP_ALIGN
|
---|
209 | .PrintProgramName:
|
---|
210 | mov si, g_szProgramTitle
|
---|
211 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
212 |
|
---|
213 | ALIGN JUMP_ALIGN
|
---|
214 | .PrintLoadStatus:
|
---|
215 | mov ax, [g_cfgVars+CFGVARS.wFlags]
|
---|
216 | test ax, FLG_CFGVARS_FILELOADED
|
---|
217 | jnz SHORT .PrintNameOfLoadedFile
|
---|
218 | test ax, FLG_CFGVARS_ROMLOADED
|
---|
219 | mov si, g_szEEPROM
|
---|
220 | jnz SHORT .PrintNameOfLoadedFileOrEeprom
|
---|
221 | ; Fall to .PrintNothingLoaded
|
---|
222 |
|
---|
223 | .PrintNothingLoaded:
|
---|
224 | mov si, g_szBiosIsNotLoaded
|
---|
225 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
226 |
|
---|
227 | ALIGN JUMP_ALIGN
|
---|
228 | .PrintNameOfLoadedFile:
|
---|
229 | mov si, g_cfgVars+CFGVARS.szOpenedFile
|
---|
230 | ; Fall to .PrintNameOfLoadedFileOrEeprom
|
---|
231 |
|
---|
232 | ALIGN JUMP_ALIGN
|
---|
233 | .PrintNameOfLoadedFileOrEeprom:
|
---|
234 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
235 | ; Fall to .PrintTypeOfLoadedBios
|
---|
236 |
|
---|
237 | .PrintTypeOfLoadedBios:
|
---|
238 | mov si, g_szSourceAndTypeSeparator
|
---|
239 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
240 | call Buffers_IsXtideUniversalBiosLoaded
|
---|
241 | jne SHORT .PrintUnidentifiedType
|
---|
242 |
|
---|
243 | call Buffers_GetFileBufferToESDI
|
---|
244 | mov bx, es
|
---|
245 | lea si, [di+ROMVARS.szVersion]
|
---|
246 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
|
---|
247 |
|
---|
248 | ALIGN JUMP_ALIGN
|
---|
249 | .PrintUnidentifiedType:
|
---|
250 | mov si, g_szUnidentified
|
---|
251 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
252 |
|
---|
253 | ALIGN JUMP_ALIGN
|
---|
254 | .PrintStatusOfUnsavedChanges:
|
---|
255 | test WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
|
---|
256 | jz SHORT .ReturnSinceNothingToPrint
|
---|
257 | mov si, g_szUnsaved
|
---|
258 | JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|