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

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

Initial commit (Work in progress).

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