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

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

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 11.1 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-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
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 or [es:di], ax
261 jmp SHORT .SetUnsavedChanges
262
263.StoreByteOrWord:
264 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
265 jnz SHORT .StoreByteFromAL
266
267 mov [es:di+1], ah
268ALIGN JUMP_ALIGN
269.StoreByteFromAL:
270 mov [es:di], al
271 ; Fall to .SetUnsavedChanges
272
273;--------------------------------------------------------------------
274; .SetUnsavedChanges
275; Parameters:
276; DS:SI: Ptr to MENUITEM
277; SS:BP: Menu handle
278; Returns:
279; Nothing
280; Corrupts registers:
281; AX, DI
282;--------------------------------------------------------------------
283ALIGN JUMP_ALIGN
284.SetUnsavedChanges:
285 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
286 jnz SHORT .NoUnsavedChangesForProgramVariables
287 call Buffers_SetUnsavedChanges
288.NoUnsavedChangesForProgramVariables:
289 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MODIFY_MENU
290 jnz SHORT .ModifyItemVisibility
291 CALL_MENU_LIBRARY RefreshTitle
292 CALL_MENU_LIBRARY GetHighlightedItemToAX
293 CALL_MENU_LIBRARY RefreshItemFromAX
294 ret
295
296ALIGN JUMP_ALIGN
297.ModifyItemVisibility:
298 push es
299 push ds
300 ePUSHA
301 call Menupage_GetActiveMenupageToDSDI
302 call [di+MENUPAGE.fnEnter]
303 ePOPA
304 pop ds
305 pop es
306 ret
307
308
309;--------------------------------------------------------------------
310; Menuitem_GetValueToAXfromMenuitemInDSSI
311; Parameters:
312; DS:SI: Ptr to MENUITEM
313; Returns:
314; AX: Menuitem value
315; Corrupts registers:
316; BX
317;--------------------------------------------------------------------
318ALIGN JUMP_ALIGN
319Menuitem_GetValueToAXfromMenuitemInDSSI:
320 push es
321 push di
322 push bx
323 call GetConfigurationBufferToESDIforMenuitemInDSSI
324 add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
325 mov ax, [es:di]
326
327 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
328 jz SHORT .NoConvertWordToByteValue
329 xor ah, ah ; conversion needs to happen before call to the reader,
330 ; in case the reader unpacks the byte to a word
331
332.NoConvertWordToByteValue:
333 mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.fnValueReader]
334 test bx,bx
335 jz SHORT .NoReader
336
337 call bx
338
339.NoReader:
340 pop bx
341 pop di
342 pop es
343
344 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
345 jz SHORT .TestIfFlagValue
346 and ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
347 ret
348
349.TestIfFlagValue:
350 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
351 jz SHORT .Return
352
353 test ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
354 mov ax, TRUE<<1 ; Shift for lookup
355 jnz SHORT .Return
356 xor ax, ax
357
358ALIGN JUMP_ALIGN, ret
359.Return:
360 ret
361
362
363;--------------------------------------------------------------------
364; GetConfigurationBufferToESDIforMenuitemInDSSI
365; Parameters:
366; DS:SI: Ptr to MENUITEM
367; Returns:
368; ES:DI: Ptr to configuration buffer
369; Corrupts registers:
370; Nothing
371;--------------------------------------------------------------------
372ALIGN JUMP_ALIGN
373GetConfigurationBufferToESDIforMenuitemInDSSI:
374 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
375 jnz SHORT .ReturnCfgvarsInESDI
376 jmp Buffers_GetFileBufferToESDI
377ALIGN JUMP_ALIGN
378.ReturnCfgvarsInESDI:
379 push cs
380 pop es
381 mov di, g_cfgVars
382 ret
Note: See TracBrowser for help on using the repository browser.