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

Last change on this file since 141 was 108, checked in by krille_n_@…, 14 years ago

Fixed a spelling mistake and cleaned the source some. No changes to the actual code.

File size: 9.3 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.InvalidItemType:
153 ret
154
155ALIGN WORD_ALIGN
156.rgfnJumpToStoreValueBasedOnItemType:
157 dw .InvalidItemType ; TYPE_MENUITEM_PAGEBACK
158 dw .InvalidItemType ; TYPE_MENUITEM_PAGENEXT
159 dw .InvalidItemType ; TYPE_MENUITEM_ACTION
160 dw .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_MULTICHOICE
161 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_UNSIGNED
162 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_HEX
163
164;--------------------------------------------------------------------
165; .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI
166; Parameters:
167; AX: Multichoice selection (index)
168; DS:SI: Ptr to MENUITEM
169; ES:DI: Ptr to value variable
170; SS:BP: Menu handle
171; Returns:
172; Nothing
173; Corrupts registers:
174; AX, BX, DI
175;--------------------------------------------------------------------
176ALIGN JUMP_ALIGN
177.StoreMultichoiceValueFromAXtoESDIwithItemInDSSI:
178 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
179 jz SHORT .TranslateChoiceToValueUsingLookupTable
180
181 test ax, ax ; Setting item flag?
182 mov ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
183 jnz SHORT .SetFlagFromAX
184 not ax
185 and [es:di], ax ; Clear flag
186 jmp SHORT .SetUnsavedChanges
187ALIGN JUMP_ALIGN
188.SetFlagFromAX:
189 or [es:di], ax
190 jmp SHORT .SetUnsavedChanges
191
192ALIGN JUMP_ALIGN
193.TranslateChoiceToValueUsingLookupTable:
194 shl ax, 1 ; Shift for WORD lookup
195 add ax, [si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiceToValueLookup]
196 xchg bx, ax
197 mov ax, [bx] ; Lookup complete
198 ; Fall to .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
199
200;--------------------------------------------------------------------
201; .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
202; Parameters:
203; AX: Value to store
204; DS:SI: Ptr to MENUITEM
205; ES:DI: Ptr to value variable
206; SS:BP: Menu handle
207; Returns:
208; Nothing
209; Corrupts registers:
210; AX, DI
211;--------------------------------------------------------------------
212ALIGN JUMP_ALIGN
213.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI:
214 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
215 jnz SHORT .StoreByteFromAL
216
217 mov [es:di+1], ah
218ALIGN JUMP_ALIGN
219.StoreByteFromAL:
220 mov [es:di], al
221 ; Fall to .SetUnsavedChanges
222
223;--------------------------------------------------------------------
224; .SetUnsavedChanges
225; Parameters:
226; DS:SI: Ptr to MENUITEM
227; SS:BP: Menu handle
228; Returns:
229; Nothing
230; Corrupts registers:
231; AX, DI
232;--------------------------------------------------------------------
233ALIGN JUMP_ALIGN
234.SetUnsavedChanges:
235 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
236 jnz SHORT .NoUnsavedChangesForProgramVariables
237 call Buffers_SetUnsavedChanges
238.NoUnsavedChangesForProgramVariables:
239 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MODIFY_MENU
240 jnz SHORT .ModifyItemVisibility
241 CALL_MENU_LIBRARY RefreshTitle
242 CALL_MENU_LIBRARY GetHighlightedItemToAX
243 CALL_MENU_LIBRARY RefreshItemFromAX
244 ret
245
246ALIGN JUMP_ALIGN
247.ModifyItemVisibility:
248 push es
249 push ds
250 ePUSHA
251 call Menupage_GetActiveMenupageToDSDI
252 call [di+MENUPAGE.fnEnter]
253 ePOPA
254 pop ds
255 pop es
256 ret
257
258
259;--------------------------------------------------------------------
260; Menuitem_GetValueToAXfromMenuitemInDSSI
261; Parameters:
262; DS:SI: Ptr to MENUITEM
263; Returns:
264; AX: Menuitem value
265; Corrupts registers:
266; BX
267;--------------------------------------------------------------------
268ALIGN JUMP_ALIGN
269Menuitem_GetValueToAXfromMenuitemInDSSI:
270 call .GetMenuitemValueToAX
271 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
272 jnz SHORT .ConvertWordToByteValue
273 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
274 jnz SHORT .ConvertWordToFlagValue
275 ret
276
277ALIGN JUMP_ALIGN
278.GetMenuitemValueToAX:
279 push es
280 push di
281 call GetConfigurationBufferToESDIforMenuitemInDSSI
282 add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
283 mov ax, [es:di]
284 pop di
285 pop es
286 ret
287
288ALIGN JUMP_ALIGN
289.ConvertWordToByteValue:
290 xor ah, ah
291 ret
292
293ALIGN JUMP_ALIGN
294.ConvertWordToFlagValue:
295 test ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
296 jnz SHORT .ReturnTrue
297 xor ax, ax
298 ret
299ALIGN JUMP_ALIGN
300.ReturnTrue:
301 mov ax, TRUE<<1 ; Shift for lookup
302 ret
303
304
305;--------------------------------------------------------------------
306; GetConfigurationBufferToESDIforMenuitemInDSSI
307; Parameters:
308; DS:SI: Ptr to MENUITEM
309; Returns:
310; ES:DI: Ptr to configuration buffer
311; Corrupts registers:
312; Nothing
313;--------------------------------------------------------------------
314ALIGN JUMP_ALIGN
315GetConfigurationBufferToESDIforMenuitemInDSSI:
316 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
317 jnz SHORT .ReturnCfgvarsInESDI
318 jmp Buffers_GetFileBufferToESDI
319ALIGN JUMP_ALIGN
320.ReturnCfgvarsInESDI:
321 push cs
322 pop es
323 mov di, g_cfgVars
324 ret
Note: See TracBrowser for help on using the repository browser.