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