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

Last change on this file since 579 was 567, checked in by krille_n_@…, 11 years ago

Changes:

  • Renamed MODULE_FEATURE_SETS to MODULE_POWER_MANAGEMENT.
  • Renamed MODULE_VERY_LATE_INITIALIZATION to MODULE_VERY_LATE_INIT and removed it from the official builds.
  • Removed the code that skips detection of slave drives on XT-CF controllers since slave drives can be used with Lo-tech ISA CompactFlash boards.
  • Added autodetection of the SVC ADP50L controller to XTIDECFG.
  • The autodetection of XT-CF controllers now requires MODULE_8BIT_IDE_ADVANCED in the loaded BIOS.
  • Fixed a bug in XTIDECFG from r502 where the "Base (cmd block) address" menu option would be displayed when a serial device was selected as the IDE controller.
  • XTIDECFG would display the "Enable interrupt" menu option for the XTIDE r1 but not for the XTIDE r2. It's now displayed for both controller types.
  • Disabled the "Internal Write Cache" menu option in the Master/Slave Drive menus for serial device type drives.
  • Optimizations and other fixes.
File size: 11.7 KB
Line 
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
21SECTION .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;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33Menuitem_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;--------------------------------------------------------------------
48ALIGN JUMP_ALIGN
49Menuitem_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;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80Menuitem_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;--------------------------------------------------------------------
99ALIGN JUMP_ALIGN
100Menuitem_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
107ContinueWordInput:
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;--------------------------------------------------------------------
138ALIGN JUMP_ALIGN
139InitializeDialogInputInDSSIfromMenuitemInESDI:
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;--------------------------------------------------------------------
162ALIGN JUMP_ALIGN
163Menuitem_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
183ALIGN 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;--------------------------------------------------------------------
204ALIGN 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
217ALIGN JUMP_ALIGN
218.SetFlagFromAX:
219 or [es:di], ax
220 jmp SHORT .SetUnsavedChanges
221
222ALIGN 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
230ALIGN 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;--------------------------------------------------------------------
256ALIGN 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
272ALIGN 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;--------------------------------------------------------------------
287ALIGN 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
299ALIGN 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;--------------------------------------------------------------------
321ALIGN JUMP_ALIGN
322Menuitem_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
366ALIGN 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;--------------------------------------------------------------------
380ALIGN JUMP_ALIGN
381GetConfigurationBufferToESDIforMenuitemInDSSI:
382 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
383 jnz SHORT .ReturnCfgvarsInESDI
384 jmp Buffers_GetFileBufferToESDI
385ALIGN JUMP_ALIGN
386.ReturnCfgvarsInESDI:
387 push cs
388 pop es
389 mov di, g_cfgVars
390 ret
391
392
393;--------------------------------------------------------------------
394; EnableMenuitemFromCSBX
395; DisableMenuitemFromCSBX
396; Parameters:
397; CS:BX: Ptr to MENUITEM
398; Returns:
399; Nothing
400; Corrupts registers:
401; Nothing
402;--------------------------------------------------------------------
403ALIGN JUMP_ALIGN
404EnableMenuitemFromCSBX:
405 or BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
406 ret
407
408ALIGN JUMP_ALIGN
409DisableMenuitemFromCSBX:
410 and BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
411 ret
Note: See TracBrowser for help on using the repository browser.