source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm@ 209

Last change on this file since 209 was 199, checked in by gregli@…, 13 years ago

Adding proper serial port support to the Configurator, which required some minor changes elsewhere. Also added an option, off by default, to automatically scan for serial drives at the end of normal drive detection (no ALT key required, although that is still available if the option is off).

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