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

Last change on this file since 187 was 181, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

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