1 | ; Project name : XTIDE Universal BIOS Configurator v2
|
---|
2 | ; Description : Functions for accessing MENUITEM structs.
|
---|
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 | ; Menuitem_DisplayHelpMessageFromDSSI
|
---|
25 | ; Parameters:
|
---|
26 | ; DS:SI: Ptr to MENUITEM
|
---|
27 | ; Returns:
|
---|
28 | ; Nothing
|
---|
29 | ; Corrupts registers:
|
---|
30 | ; AX, DX, DI
|
---|
31 | ;--------------------------------------------------------------------
|
---|
32 | ALIGN JUMP_ALIGN
|
---|
33 | Menuitem_DisplayHelpMessageFromDSSI:
|
---|
34 | mov di, [si+MENUITEM.szName]
|
---|
35 | mov dx, [si+MENUITEM.szHelp]
|
---|
36 | jmp Dialogs_DisplayHelpFromCSDXwithTitleInCSDI
|
---|
37 |
|
---|
38 |
|
---|
39 | ;--------------------------------------------------------------------
|
---|
40 | ; Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
|
---|
41 | ; Parameters:
|
---|
42 | ; DS:SI: Ptr to MENUITEM
|
---|
43 | ; Returns:
|
---|
44 | ; Nothing
|
---|
45 | ; Corrupts registers:
|
---|
46 | ; AX, BX, CX, SI, DI, ES
|
---|
47 | ;--------------------------------------------------------------------
|
---|
48 | ALIGN JUMP_ALIGN
|
---|
49 | Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI:
|
---|
50 | call Registers_CopyDSSItoESDI
|
---|
51 |
|
---|
52 | mov cx, DIALOG_INPUT_size
|
---|
53 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
54 | call InitializeDialogInputInDSSIfromMenuitemInESDI
|
---|
55 | mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szMultichoice]
|
---|
56 | mov [si+DIALOG_INPUT.fszItems], ax
|
---|
57 | push di
|
---|
58 | CALL_MENU_LIBRARY GetSelectionToAXwithInputInDSSI
|
---|
59 | pop di
|
---|
60 |
|
---|
61 | cmp ax, BYTE NO_ITEM_SELECTED
|
---|
62 | je SHORT .NothingToChange
|
---|
63 | call Registers_CopyESDItoDSSI
|
---|
64 | call Menuitem_StoreValueFromAXtoMenuitemInDSSI
|
---|
65 | .NothingToChange:
|
---|
66 | add sp, BYTE DIALOG_INPUT_size
|
---|
67 | ret
|
---|
68 |
|
---|
69 |
|
---|
70 | ;--------------------------------------------------------------------
|
---|
71 | ; Menuitem_ActivateHexInputForMenuitemInDSSI
|
---|
72 | ; Parameters:
|
---|
73 | ; DS:SI: Ptr to MENUITEM
|
---|
74 | ; Returns:
|
---|
75 | ; Nothing
|
---|
76 | ; Corrupts registers:
|
---|
77 | ; AX, BX, CX, SI, DI, ES
|
---|
78 | ;--------------------------------------------------------------------
|
---|
79 | ALIGN JUMP_ALIGN
|
---|
80 | Menuitem_ActivateHexInputForMenuitemInDSSI:
|
---|
81 | call Registers_CopyDSSItoESDI
|
---|
82 |
|
---|
83 | mov cx, WORD_DIALOG_IO_size
|
---|
84 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
85 | call InitializeDialogInputInDSSIfromMenuitemInESDI
|
---|
86 | mov BYTE [si+WORD_DIALOG_IO.bNumericBase], 16
|
---|
87 | jmp SHORT ContinueWordInput
|
---|
88 |
|
---|
89 | ;--------------------------------------------------------------------
|
---|
90 | ; Menuitem_ActivateUnsignedInputForMenuitemInDSSI
|
---|
91 | ; Parameters:
|
---|
92 | ; DS:SI: Ptr to MENUITEM
|
---|
93 | ; Returns:
|
---|
94 | ; CF: Cleared if value inputted
|
---|
95 | ; Set if user cancellation
|
---|
96 | ; Corrupts registers:
|
---|
97 | ; AX, BX, CX, SI, DI, ES
|
---|
98 | ;--------------------------------------------------------------------
|
---|
99 | ALIGN JUMP_ALIGN
|
---|
100 | Menuitem_ActivateUnsignedInputForMenuitemInDSSI:
|
---|
101 | call Registers_CopyDSSItoESDI
|
---|
102 |
|
---|
103 | mov cx, WORD_DIALOG_IO_size
|
---|
104 | call Memory_ReserveCXbytesFromStackToDSSI
|
---|
105 | call InitializeDialogInputInDSSIfromMenuitemInESDI
|
---|
106 | mov BYTE [si+WORD_DIALOG_IO.bNumericBase], 10
|
---|
107 | ContinueWordInput:
|
---|
108 | mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMinValue]
|
---|
109 | mov [si+WORD_DIALOG_IO.wMin], ax
|
---|
110 | mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMaxValue]
|
---|
111 | mov [si+WORD_DIALOG_IO.wMax], ax
|
---|
112 | push di
|
---|
113 | CALL_MENU_LIBRARY GetWordWithIoInDSSI
|
---|
114 | pop di
|
---|
115 |
|
---|
116 | mov cl, [si+WORD_DIALOG_IO.bUserCancellation]
|
---|
117 | cmp cl, TRUE
|
---|
118 | je SHORT .NothingToChange
|
---|
119 | mov ax, [si+WORD_DIALOG_IO.wReturnWord]
|
---|
120 | call Registers_CopyESDItoDSSI
|
---|
121 | call Menuitem_StoreValueFromAXtoMenuitemInDSSI
|
---|
122 | .NothingToChange:
|
---|
123 | add sp, BYTE WORD_DIALOG_IO_size
|
---|
124 | shr cl, 1
|
---|
125 | ret
|
---|
126 |
|
---|
127 |
|
---|
128 | ;--------------------------------------------------------------------
|
---|
129 | ; InitializeDialogInputInDSSIfromMenuitemInESDI
|
---|
130 | ; Parameters:
|
---|
131 | ; DS:SI: Ptr to DIALOG_INPUT
|
---|
132 | ; ES:DI: Ptr to MENUITEM
|
---|
133 | ; Returns:
|
---|
134 | ; Nothing
|
---|
135 | ; Corrupts registers:
|
---|
136 | ; AX
|
---|
137 | ;--------------------------------------------------------------------
|
---|
138 | ALIGN JUMP_ALIGN
|
---|
139 | InitializeDialogInputInDSSIfromMenuitemInESDI:
|
---|
140 | mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szDialogTitle]
|
---|
141 | mov [si+DIALOG_INPUT.fszTitle], ax
|
---|
142 | mov [si+DIALOG_INPUT.fszTitle+2], cs
|
---|
143 |
|
---|
144 | mov [si+DIALOG_INPUT.fszItems+2], cs
|
---|
145 |
|
---|
146 | mov ax, [es:di+MENUITEM.szQuickInfo]
|
---|
147 | mov [si+DIALOG_INPUT.fszInfo], ax
|
---|
148 | mov [si+DIALOG_INPUT.fszInfo+2], cs
|
---|
149 | ret
|
---|
150 |
|
---|
151 | ;--------------------------------------------------------------------
|
---|
152 | ; Menuitem_StoreValueFromAXtoMenuitemInDSSI
|
---|
153 | ; Parameters:
|
---|
154 | ; AX: Value or multichoice selection to store
|
---|
155 | ; DS:SI: Ptr to MENUITEM
|
---|
156 | ; SS:BP: Menu handle
|
---|
157 | ; Returns:
|
---|
158 | ; Nothing
|
---|
159 | ; Corrupts registers:
|
---|
160 | ; AX, BX, DI, ES
|
---|
161 | ;--------------------------------------------------------------------
|
---|
162 | ALIGN JUMP_ALIGN
|
---|
163 | Menuitem_StoreValueFromAXtoMenuitemInDSSI:
|
---|
164 | eMOVZX bx, [si+MENUITEM.bType]
|
---|
165 | cmp bl, TYPE_MENUITEM_HEX
|
---|
166 | ja SHORT .InvalidItemType
|
---|
167 |
|
---|
168 | call GetConfigurationBufferToESDIforMenuitemInDSSI
|
---|
169 | add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
|
---|
170 |
|
---|
171 | push bx
|
---|
172 | mov bx,[si+MENUITEM.itemValue+ITEM_VALUE.fnValueWriter]
|
---|
173 | test bx,bx
|
---|
174 | jz SHORT .NoWriter
|
---|
175 | call bx
|
---|
176 | .NoWriter:
|
---|
177 | pop bx
|
---|
178 |
|
---|
179 | jmp [cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
|
---|
180 | .InvalidItemType:
|
---|
181 | ret
|
---|
182 |
|
---|
183 | ALIGN WORD_ALIGN
|
---|
184 | .rgfnJumpToStoreValueBasedOnItemType:
|
---|
185 | dw .InvalidItemType ; TYPE_MENUITEM_PAGEBACK
|
---|
186 | dw .InvalidItemType ; TYPE_MENUITEM_PAGENEXT
|
---|
187 | dw .InvalidItemType ; TYPE_MENUITEM_ACTION
|
---|
188 | dw .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_MULTICHOICE
|
---|
189 | dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_UNSIGNED
|
---|
190 | dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_HEX
|
---|
191 |
|
---|
192 | ;--------------------------------------------------------------------
|
---|
193 | ; .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI
|
---|
194 | ; Parameters:
|
---|
195 | ; AX: Multichoice selection (index)
|
---|
196 | ; DS:SI: Ptr to MENUITEM
|
---|
197 | ; ES:DI: Ptr to value variable
|
---|
198 | ; SS:BP: Menu handle
|
---|
199 | ; Returns:
|
---|
200 | ; Nothing
|
---|
201 | ; Corrupts registers:
|
---|
202 | ; AX, BX, DI
|
---|
203 | ;--------------------------------------------------------------------
|
---|
204 | ALIGN JUMP_ALIGN
|
---|
205 | .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI:
|
---|
206 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
|
---|
207 | jnz SHORT .ClearBitsUsingMask
|
---|
208 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
|
---|
209 | jz SHORT .TranslateChoiceToValueUsingLookupTable
|
---|
210 |
|
---|
211 | test ax, ax ; Setting item flag?
|
---|
212 | mov ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
|
---|
213 | jnz SHORT .SetFlagFromAX
|
---|
214 | not ax
|
---|
215 | and [es:di], ax ; Clear flag
|
---|
216 | jmp SHORT .SetUnsavedChanges
|
---|
217 | ALIGN JUMP_ALIGN
|
---|
218 | .SetFlagFromAX:
|
---|
219 | or [es:di], ax
|
---|
220 | jmp SHORT .SetUnsavedChanges
|
---|
221 |
|
---|
222 | ALIGN JUMP_ALIGN
|
---|
223 | .ClearBitsUsingMask:
|
---|
224 | mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
|
---|
225 | not bx
|
---|
226 | and [es:di], bx
|
---|
227 | ; Fall to .TranslateChoiceToValueUsingLookupTable
|
---|
228 |
|
---|
229 |
|
---|
230 | ALIGN JUMP_ALIGN
|
---|
231 | .TranslateChoiceToValueUsingLookupTable:
|
---|
232 | ;
|
---|
233 | ; if the lookup pointer is NULL, no translation is needed
|
---|
234 | ;
|
---|
235 | mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiceToValueLookup]
|
---|
236 | test bx, bx
|
---|
237 | jz .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
|
---|
238 |
|
---|
239 | shl ax, 1 ; Shift for WORD lookup
|
---|
240 | add bx, ax
|
---|
241 | mov ax, [bx] ; Lookup complete
|
---|
242 | ; Fall to .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
|
---|
243 |
|
---|
244 | ;--------------------------------------------------------------------
|
---|
245 | ; .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
|
---|
246 | ; Parameters:
|
---|
247 | ; AX: Value to store
|
---|
248 | ; DS:SI: Ptr to MENUITEM
|
---|
249 | ; ES:DI: Ptr to value variable
|
---|
250 | ; SS:BP: Menu handle
|
---|
251 | ; Returns:
|
---|
252 | ; Nothing
|
---|
253 | ; Corrupts registers:
|
---|
254 | ; AX, DI
|
---|
255 | ;--------------------------------------------------------------------
|
---|
256 | ALIGN JUMP_ALIGN
|
---|
257 | .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI:
|
---|
258 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
|
---|
259 | jz SHORT .StoreByteOrWord
|
---|
260 | push cx
|
---|
261 | mov cl, [si+MENUITEM.itemValue+ITEM_VALUE.bFieldPosition]
|
---|
262 | shl ax, cl
|
---|
263 | pop cx
|
---|
264 | or [es:di], ax
|
---|
265 | jmp SHORT .SetUnsavedChanges
|
---|
266 |
|
---|
267 | .StoreByteOrWord:
|
---|
268 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
|
---|
269 | jnz SHORT .StoreByteFromAL
|
---|
270 |
|
---|
271 | mov [es:di+1], ah
|
---|
272 | ALIGN JUMP_ALIGN
|
---|
273 | .StoreByteFromAL:
|
---|
274 | mov [es:di], al
|
---|
275 | ; Fall to .SetUnsavedChanges
|
---|
276 |
|
---|
277 | ;--------------------------------------------------------------------
|
---|
278 | ; .SetUnsavedChanges
|
---|
279 | ; Parameters:
|
---|
280 | ; DS:SI: Ptr to MENUITEM
|
---|
281 | ; SS:BP: Menu handle
|
---|
282 | ; Returns:
|
---|
283 | ; Nothing
|
---|
284 | ; Corrupts registers:
|
---|
285 | ; AX, DI
|
---|
286 | ;--------------------------------------------------------------------
|
---|
287 | ALIGN JUMP_ALIGN
|
---|
288 | .SetUnsavedChanges:
|
---|
289 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
|
---|
290 | jnz SHORT .NoUnsavedChangesForProgramVariables
|
---|
291 | call Buffers_SetUnsavedChanges
|
---|
292 | .NoUnsavedChangesForProgramVariables:
|
---|
293 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MODIFY_MENU
|
---|
294 | jnz SHORT .ModifyItemVisibility
|
---|
295 | CALL_MENU_LIBRARY RefreshTitle
|
---|
296 | CALL_MENU_LIBRARY GetHighlightedItemToAX
|
---|
297 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
298 | ret
|
---|
299 |
|
---|
300 | ALIGN JUMP_ALIGN
|
---|
301 | .ModifyItemVisibility:
|
---|
302 | push es
|
---|
303 | push ds
|
---|
304 | ePUSHA
|
---|
305 | call Menupage_GetActiveMenupageToDSDI
|
---|
306 | call [di+MENUPAGE.fnEnter]
|
---|
307 | ePOPA
|
---|
308 | pop ds
|
---|
309 | pop es
|
---|
310 | ret
|
---|
311 |
|
---|
312 |
|
---|
313 | ;--------------------------------------------------------------------
|
---|
314 | ; Menuitem_GetValueToAXfromMenuitemInDSSI
|
---|
315 | ; Parameters:
|
---|
316 | ; DS:SI: Ptr to MENUITEM
|
---|
317 | ; Returns:
|
---|
318 | ; AX: Menuitem value
|
---|
319 | ; Corrupts registers:
|
---|
320 | ; BX
|
---|
321 | ;--------------------------------------------------------------------
|
---|
322 | ALIGN JUMP_ALIGN
|
---|
323 | Menuitem_GetValueToAXfromMenuitemInDSSI:
|
---|
324 | push es
|
---|
325 | push di
|
---|
326 | push bx
|
---|
327 | call GetConfigurationBufferToESDIforMenuitemInDSSI
|
---|
328 | add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
|
---|
329 | mov ax, [es:di]
|
---|
330 |
|
---|
331 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
|
---|
332 | jz SHORT .NoConvertWordToByteValue
|
---|
333 | xor ah, ah ; conversion needs to happen before call to the reader,
|
---|
334 | ; in case the reader unpacks the byte to a word
|
---|
335 |
|
---|
336 | .NoConvertWordToByteValue:
|
---|
337 | mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.fnValueReader]
|
---|
338 | test bx,bx
|
---|
339 | jz SHORT .NoReader
|
---|
340 |
|
---|
341 | call bx
|
---|
342 |
|
---|
343 | .NoReader:
|
---|
344 | pop bx
|
---|
345 | pop di
|
---|
346 | pop es
|
---|
347 |
|
---|
348 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
|
---|
349 | jz SHORT .TestIfFlagValue
|
---|
350 |
|
---|
351 | and ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
|
---|
352 | push cx
|
---|
353 | mov cl, [si+MENUITEM.itemValue+ITEM_VALUE.bFieldPosition]
|
---|
354 | shr ax, cl
|
---|
355 | pop cx
|
---|
356 | ret
|
---|
357 |
|
---|
358 | .TestIfFlagValue:
|
---|
359 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
|
---|
360 | jz SHORT .Return
|
---|
361 |
|
---|
362 | test ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
|
---|
363 | mov ax, TRUE<<1 ; Shift for lookup
|
---|
364 | jnz SHORT .Return
|
---|
365 | xor ax, ax
|
---|
366 |
|
---|
367 | ALIGN JUMP_ALIGN, ret
|
---|
368 | .Return:
|
---|
369 | ret
|
---|
370 |
|
---|
371 |
|
---|
372 | ;--------------------------------------------------------------------
|
---|
373 | ; GetConfigurationBufferToESDIforMenuitemInDSSI
|
---|
374 | ; Parameters:
|
---|
375 | ; DS:SI: Ptr to MENUITEM
|
---|
376 | ; Returns:
|
---|
377 | ; ES:DI: Ptr to configuration buffer
|
---|
378 | ; Corrupts registers:
|
---|
379 | ; Nothing
|
---|
380 | ;--------------------------------------------------------------------
|
---|
381 | ALIGN JUMP_ALIGN
|
---|
382 | GetConfigurationBufferToESDIforMenuitemInDSSI:
|
---|
383 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
|
---|
384 | jnz SHORT .ReturnCfgvarsInESDI
|
---|
385 | jmp Buffers_GetFileBufferToESDI
|
---|
386 | ALIGN JUMP_ALIGN
|
---|
387 | .ReturnCfgvarsInESDI:
|
---|
388 | push cs
|
---|
389 | pop es
|
---|
390 | mov di, g_cfgVars
|
---|
391 | ret
|
---|