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 | JMP_MENU_LIBRARY RefreshItemFromAX
|
---|
298 |
|
---|
299 | ALIGN JUMP_ALIGN
|
---|
300 | .ModifyItemVisibility:
|
---|
301 | push es
|
---|
302 | push ds
|
---|
303 | ePUSHA
|
---|
304 | call Menupage_GetActiveMenupageToDSDI
|
---|
305 | call [di+MENUPAGE.fnEnter]
|
---|
306 | ePOPA
|
---|
307 | pop ds
|
---|
308 | pop es
|
---|
309 | ret
|
---|
310 |
|
---|
311 |
|
---|
312 | ;--------------------------------------------------------------------
|
---|
313 | ; Menuitem_GetValueToAXfromMenuitemInDSSI
|
---|
314 | ; Parameters:
|
---|
315 | ; DS:SI: Ptr to MENUITEM
|
---|
316 | ; Returns:
|
---|
317 | ; AX: Menuitem value
|
---|
318 | ; Corrupts registers:
|
---|
319 | ; BX
|
---|
320 | ;--------------------------------------------------------------------
|
---|
321 | ALIGN JUMP_ALIGN
|
---|
322 | Menuitem_GetValueToAXfromMenuitemInDSSI:
|
---|
323 | push es
|
---|
324 | push di
|
---|
325 | push bx
|
---|
326 | call GetConfigurationBufferToESDIforMenuitemInDSSI
|
---|
327 | add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
|
---|
328 | mov ax, [es:di]
|
---|
329 |
|
---|
330 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
|
---|
331 | jz SHORT .NoConvertWordToByteValue
|
---|
332 | xor ah, ah ; conversion needs to happen before call to the reader,
|
---|
333 | ; in case the reader unpacks the byte to a word
|
---|
334 |
|
---|
335 | .NoConvertWordToByteValue:
|
---|
336 | mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.fnValueReader]
|
---|
337 | test bx,bx
|
---|
338 | jz SHORT .NoReader
|
---|
339 |
|
---|
340 | call bx
|
---|
341 |
|
---|
342 | .NoReader:
|
---|
343 | pop bx
|
---|
344 | pop di
|
---|
345 | pop es
|
---|
346 |
|
---|
347 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
|
---|
348 | jz SHORT .TestIfFlagValue
|
---|
349 |
|
---|
350 | and ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
|
---|
351 | push cx
|
---|
352 | mov cl, [si+MENUITEM.itemValue+ITEM_VALUE.bFieldPosition]
|
---|
353 | shr ax, cl
|
---|
354 | pop cx
|
---|
355 | ret
|
---|
356 |
|
---|
357 | .TestIfFlagValue:
|
---|
358 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
|
---|
359 | jz SHORT .Return
|
---|
360 |
|
---|
361 | test ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
|
---|
362 | mov ax, TRUE<<1 ; Shift for lookup
|
---|
363 | jnz SHORT .Return
|
---|
364 | xor ax, ax
|
---|
365 |
|
---|
366 | ALIGN JUMP_ALIGN, ret
|
---|
367 | .Return:
|
---|
368 | ret
|
---|
369 |
|
---|
370 |
|
---|
371 | ;--------------------------------------------------------------------
|
---|
372 | ; GetConfigurationBufferToESDIforMenuitemInDSSI
|
---|
373 | ; Parameters:
|
---|
374 | ; DS:SI: Ptr to MENUITEM
|
---|
375 | ; Returns:
|
---|
376 | ; ES:DI: Ptr to configuration buffer
|
---|
377 | ; Corrupts registers:
|
---|
378 | ; Nothing
|
---|
379 | ;--------------------------------------------------------------------
|
---|
380 | ALIGN JUMP_ALIGN
|
---|
381 | GetConfigurationBufferToESDIforMenuitemInDSSI:
|
---|
382 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
|
---|
383 | jnz SHORT .ReturnCfgvarsInESDI
|
---|
384 | jmp Buffers_GetFileBufferToESDI
|
---|
385 | ALIGN JUMP_ALIGN
|
---|
386 | .ReturnCfgvarsInESDI:
|
---|
387 | push cs
|
---|
388 | pop es
|
---|
389 | mov di, g_cfgVars
|
---|
390 | ret
|
---|