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

Last change on this file since 93 was 59, checked in by Tomi Tilli, 14 years ago

Changes to Configuration Program v2:

  • Menu structure should now be complete.
File size: 9.4 KB
Line 
1; File name : Menuitem.asm
2; Project name : XTIDE Universal BIOS Configurator v2
3; Created date : 5.10.2010
4; Last update : 19.11.2010
5; Author : Tomi Tilli
6; Description : Functions for accessing MENUITEM structs.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Menuitem_DisplayHelpMessageFromDSSI
13; Parameters:
14; DS:SI: Ptr to MENUITEM
15; Returns:
16; Nothing
17; Corrupts registers:
18; AX, DX, DI
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21Menuitem_DisplayHelpMessageFromDSSI:
22 mov di, [si+MENUITEM.szName]
23 mov dx, [si+MENUITEM.szHelp]
24 jmp Dialogs_DisplayHelpFromCSDXwithTitleInCSDI
25
26
27;--------------------------------------------------------------------
28; Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
29; Parameters:
30; DS:SI: Ptr to MENUITEM
31; Returns:
32; Nothing
33; Corrupts registers:
34; AX, BX, CX, SI, DI, ES
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI:
38 call Registers_CopyDSSItoESDI
39
40 mov cx, DIALOG_INPUT_size
41 call Memory_ReserveCXbytesFromStackToDSSI
42 call InitializeDialogInputInDSSIfromMenuitemInESDI
43 mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szMultichoise]
44 mov [si+DIALOG_INPUT.fszItems], ax
45 push di
46 CALL_MENU_LIBRARY GetSelectionToAXwithInputInDSSI
47 pop di
48
49 cmp ax, BYTE NO_ITEM_SELECTED
50 je SHORT .NothingToChange
51 call Registers_CopyESDItoDSSI
52 call Menuitem_StoreValueFromAXtoMenuitemInDSSI
53.NothingToChange:
54 add sp, BYTE DIALOG_INPUT_size
55 ret
56
57
58;--------------------------------------------------------------------
59; Menuitem_ActivateHexInputForMenuitemInDSSI
60; Parameters:
61; DS:SI: Ptr to MENUITEM
62; Returns:
63; Nothing
64; Corrupts registers:
65; AX, BX, CX, SI, DI, ES
66;--------------------------------------------------------------------
67ALIGN JUMP_ALIGN
68Menuitem_ActivateHexInputForMenuitemInDSSI:
69 call Registers_CopyDSSItoESDI
70
71 mov cx, WORD_DIALOG_IO_size
72 call Memory_ReserveCXbytesFromStackToDSSI
73 call InitializeDialogInputInDSSIfromMenuitemInESDI
74 mov BYTE [si+WORD_DIALOG_IO.bNumericBase], 16
75 jmp SHORT ContinueWordInput
76
77;--------------------------------------------------------------------
78; Menuitem_ActivateUnsignedInputForMenuitemInDSSI
79; Parameters:
80; DS:SI: Ptr to MENUITEM
81; Returns:
82; Nothing
83; Corrupts registers:
84; AX, BX, CX, SI, DI, ES
85;--------------------------------------------------------------------
86ALIGN JUMP_ALIGN
87Menuitem_ActivateUnsignedInputForMenuitemInDSSI:
88 call Registers_CopyDSSItoESDI
89
90 mov cx, WORD_DIALOG_IO_size
91 call Memory_ReserveCXbytesFromStackToDSSI
92 call InitializeDialogInputInDSSIfromMenuitemInESDI
93 mov BYTE [si+WORD_DIALOG_IO.bNumericBase], 10
94ContinueWordInput:
95 mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMinValue]
96 mov [si+WORD_DIALOG_IO.wMin], ax
97 mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMaxValue]
98 mov [si+WORD_DIALOG_IO.wMax], ax
99 push di
100 CALL_MENU_LIBRARY GetWordWithIoInDSSI
101 pop di
102
103 cmp BYTE [si+WORD_DIALOG_IO.bUserCancellation], TRUE
104 je SHORT .NothingToChange
105 mov ax, [si+WORD_DIALOG_IO.wReturnWord]
106 call Registers_CopyESDItoDSSI
107 call Menuitem_StoreValueFromAXtoMenuitemInDSSI
108.NothingToChange:
109 add sp, BYTE WORD_DIALOG_IO_size
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;--------------------------------------------------------------------
123ALIGN JUMP_ALIGN
124InitializeDialogInputInDSSIfromMenuitemInESDI:
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 multichoise 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;--------------------------------------------------------------------
147ALIGN JUMP_ALIGN
148Menuitem_StoreValueFromAXtoMenuitemInDSSI:
149 eMOVZX bx, BYTE [si+MENUITEM.bType]
150 cmp bl, TYPE_MENUITEM_HEX
151 ja SHORT .InvalidItemType
152
153 call GetConfigurationBufferToESDIforMenuitemInDSSI
154 add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
155 jmp [cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
156.InvalidItemType:
157 ret
158
159ALIGN WORD_ALIGN
160.rgfnJumpToStoreValueBasedOnItemType:
161 dw .InvalidItemType ; TYPE_MENUITEM_PAGEBACK
162 dw .InvalidItemType ; TYPE_MENUITEM_PAGENEXT
163 dw .InvalidItemType ; TYPE_MENUITEM_ACTION
164 dw .StoreMultichoiseValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_MULTICHOISE
165 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_UNSIGNED
166 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_HEX
167
168;--------------------------------------------------------------------
169; .StoreMultichoiseValueFromAXtoESDIwithItemInDSSI
170; Parameters:
171; AX: Multichoise selection (index)
172; DS:SI: Ptr to MENUITEM
173; ES:DI: Ptr to value variable
174; SS:BP: Menu handle
175; Returns:
176; Nothing
177; Corrupts registers:
178; AX, BX, DI
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
181.StoreMultichoiseValueFromAXtoESDIwithItemInDSSI:
182 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
183 jz SHORT .TranslateChoiseToValueUsingLookupTable
184
185 test ax, ax ; Setting item flag?
186 mov ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
187 jnz SHORT .SetFlagFromAX
188 not ax
189 and [es:di], ax ; Clear flag
190 jmp SHORT .SetUnsavedChanges
191ALIGN JUMP_ALIGN
192.SetFlagFromAX:
193 or [es:di], ax
194 jmp SHORT .SetUnsavedChanges
195
196ALIGN JUMP_ALIGN
197.TranslateChoiseToValueUsingLookupTable:
198 shl ax, 1 ; Shift for WORD lookup
199 add ax, [si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiseToValueLookup]
200 xchg 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 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
219 jnz SHORT .StoreByteFromAL
220
221 mov [es:di+1], ah
222ALIGN JUMP_ALIGN
223.StoreByteFromAL:
224 mov [es:di], al
225 ; Fall to .SetUnsavedChanges
226
227;--------------------------------------------------------------------
228; .SetUnsavedChanges
229; Parameters:
230; DS:SI: Ptr to MENUITEM
231; SS:BP: Menu handle
232; Returns:
233; Nothing
234; Corrupts registers:
235; AX, DI
236;--------------------------------------------------------------------
237ALIGN JUMP_ALIGN
238.SetUnsavedChanges:
239 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
240 jnz SHORT .NoUnsavedChangesForProgramVariables
241 call Buffers_SetUnsavedChanges
242.NoUnsavedChangesForProgramVariables:
243 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MODIFY_MENU
244 jnz SHORT .ModifyItemVisibility
245 CALL_MENU_LIBRARY RefreshTitle
246 CALL_MENU_LIBRARY GetHighlightedItemToAX
247 CALL_MENU_LIBRARY RefreshItemFromAX
248 ret
249
250ALIGN JUMP_ALIGN
251.ModifyItemVisibility:
252 push es
253 push ds
254 ePUSHA
255 call Menupage_GetActiveMenupageToDSDI
256 call [di+MENUPAGE.fnEnter]
257 ePOPA
258 pop ds
259 pop es
260 ret
261
262
263;--------------------------------------------------------------------
264; Menuitem_GetValueToAXfromMenuitemInDSSI
265; Parameters:
266; DS:SI: Ptr to MENUITEM
267; Returns:
268; AX: Menuitem value
269; Corrupts registers:
270; BX
271;--------------------------------------------------------------------
272ALIGN JUMP_ALIGN
273Menuitem_GetValueToAXfromMenuitemInDSSI:
274 call .GetMenuitemValueToAX
275 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
276 jnz SHORT .ConvertWordToByteValue
277 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
278 jnz SHORT .ConvertWordToFlagValue
279 ret
280
281ALIGN JUMP_ALIGN
282.GetMenuitemValueToAX:
283 push es
284 push di
285 call GetConfigurationBufferToESDIforMenuitemInDSSI
286 add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
287 mov ax, [es:di]
288 pop di
289 pop es
290 ret
291
292ALIGN JUMP_ALIGN
293.ConvertWordToByteValue:
294 xor ah, ah
295 ret
296
297ALIGN JUMP_ALIGN
298.ConvertWordToFlagValue:
299 test ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
300 jnz SHORT .ReturnTrue
301 xor ax, ax
302 ret
303ALIGN JUMP_ALIGN
304.ReturnTrue:
305 mov ax, TRUE<<1 ; Shift for lookup
306 ret
307
308
309;--------------------------------------------------------------------
310; GetConfigurationBufferToESDIforMenuitemInDSSI
311; Parameters:
312; DS:SI: Ptr to MENUITEM
313; Returns:
314; ES:DI: Ptr to configuration buffer
315; Corrupts registers:
316; Nothing
317;--------------------------------------------------------------------
318ALIGN JUMP_ALIGN
319GetConfigurationBufferToESDIforMenuitemInDSSI:
320 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
321 jnz SHORT .ReturnCfgvarsInESDI
322 jmp Buffers_GetFileBufferToESDI
323ALIGN JUMP_ALIGN
324.ReturnCfgvarsInESDI:
325 push cs
326 pop es
327 mov di, g_cfgVars
328 ret
Note: See TracBrowser for help on using the repository browser.