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

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

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 10.4 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; CF: Cleared if value inputted
79; Set if user cancellation
80; Corrupts registers:
81; AX, BX, CX, SI, DI, ES
82;--------------------------------------------------------------------
83ALIGN JUMP_ALIGN
84Menuitem_ActivateUnsignedInputForMenuitemInDSSI:
85 call Registers_CopyDSSItoESDI
86
87 mov cx, WORD_DIALOG_IO_size
88 call Memory_ReserveCXbytesFromStackToDSSI
89 call InitializeDialogInputInDSSIfromMenuitemInESDI
90 mov BYTE [si+WORD_DIALOG_IO.bNumericBase], 10
91ContinueWordInput:
92 mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMinValue]
93 mov [si+WORD_DIALOG_IO.wMin], ax
94 mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMaxValue]
95 mov [si+WORD_DIALOG_IO.wMax], ax
96 push di
97 CALL_MENU_LIBRARY GetWordWithIoInDSSI
98 pop di
99
100 mov cl, [si+WORD_DIALOG_IO.bUserCancellation]
101 cmp cl, TRUE
102 je SHORT .NothingToChange
103 mov ax, [si+WORD_DIALOG_IO.wReturnWord]
104 call Registers_CopyESDItoDSSI
105 call Menuitem_StoreValueFromAXtoMenuitemInDSSI
106.NothingToChange:
107 add sp, BYTE WORD_DIALOG_IO_size
108 shr cl, 1
109 ret
110
111
112;--------------------------------------------------------------------
113; InitializeDialogInputInDSSIfromMenuitemInESDI
114; Parameters:
115; DS:SI: Ptr to DIALOG_INPUT
116; ES:DI: Ptr to MENUITEM
117; Returns:
118; Nothing
119; Corrupts registers:
120; AX
121;--------------------------------------------------------------------
122ALIGN JUMP_ALIGN
123InitializeDialogInputInDSSIfromMenuitemInESDI:
124 mov ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szDialogTitle]
125 mov [si+DIALOG_INPUT.fszTitle], ax
126 mov [si+DIALOG_INPUT.fszTitle+2], cs
127
128 mov [si+DIALOG_INPUT.fszItems+2], cs
129
130 mov ax, [es:di+MENUITEM.szQuickInfo]
131 mov [si+DIALOG_INPUT.fszInfo], ax
132 mov [si+DIALOG_INPUT.fszInfo+2], cs
133 ret
134
135;--------------------------------------------------------------------
136; Menuitem_StoreValueFromAXtoMenuitemInDSSI
137; Parameters:
138; AX: Value or multichoice selection to store
139; DS:SI: Ptr to MENUITEM
140; SS:BP: Menu handle
141; Returns:
142; Nothing
143; Corrupts registers:
144; AX, BX, DI, ES
145;--------------------------------------------------------------------
146ALIGN JUMP_ALIGN
147Menuitem_StoreValueFromAXtoMenuitemInDSSI:
148 eMOVZX bx, [si+MENUITEM.bType]
149 cmp bl, TYPE_MENUITEM_HEX
150 ja SHORT .InvalidItemType
151
152 call GetConfigurationBufferToESDIforMenuitemInDSSI
153 add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
154
155 push bx
156 mov bx,[si+MENUITEM.itemValue+ITEM_VALUE.fnValueWriter]
157 test bx,bx
158 jz SHORT .NoWriter
159 call bx
160.NoWriter:
161 pop bx
162
163 jmp [cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
164.InvalidItemType:
165 ret
166
167ALIGN WORD_ALIGN
168.rgfnJumpToStoreValueBasedOnItemType:
169 dw .InvalidItemType ; TYPE_MENUITEM_PAGEBACK
170 dw .InvalidItemType ; TYPE_MENUITEM_PAGENEXT
171 dw .InvalidItemType ; TYPE_MENUITEM_ACTION
172 dw .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_MULTICHOICE
173 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_UNSIGNED
174 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_HEX
175
176;--------------------------------------------------------------------
177; .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI
178; Parameters:
179; AX: Multichoice selection (index)
180; DS:SI: Ptr to MENUITEM
181; ES:DI: Ptr to value variable
182; SS:BP: Menu handle
183; Returns:
184; Nothing
185; Corrupts registers:
186; AX, BX, DI
187;--------------------------------------------------------------------
188ALIGN JUMP_ALIGN
189.StoreMultichoiceValueFromAXtoESDIwithItemInDSSI:
190 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
191 jnz SHORT .ClearBitsUsingMask
192 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
193 jz SHORT .TranslateChoiceToValueUsingLookupTable
194
195 test ax, ax ; Setting item flag?
196 mov ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
197 jnz SHORT .SetFlagFromAX
198 not ax
199 and [es:di], ax ; Clear flag
200 jmp SHORT .SetUnsavedChanges
201ALIGN JUMP_ALIGN
202.SetFlagFromAX:
203 or [es:di], ax
204 jmp SHORT .SetUnsavedChanges
205
206ALIGN JUMP_ALIGN
207.ClearBitsUsingMask:
208 mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
209 not bx
210 and [es:di], bx
211 ; Fall to .TranslateChoiceToValueUsingLookupTable
212
213
214ALIGN JUMP_ALIGN
215.TranslateChoiceToValueUsingLookupTable:
216;
217; if the lookup pointer is NULL, no translation is needed
218;
219 mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiceToValueLookup]
220 test bx, bx
221 jz .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
222
223 shl ax, 1 ; Shift for WORD lookup
224 add bx, ax
225 mov ax, [bx] ; Lookup complete
226 ; Fall to .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
227
228;--------------------------------------------------------------------
229; .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
230; Parameters:
231; AX: Value to store
232; DS:SI: Ptr to MENUITEM
233; ES:DI: Ptr to value variable
234; SS:BP: Menu handle
235; Returns:
236; Nothing
237; Corrupts registers:
238; AX, DI
239;--------------------------------------------------------------------
240ALIGN JUMP_ALIGN
241.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI:
242 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
243 jz SHORT .StoreByteOrWord
244 or [es:di], ax
245 jmp SHORT .SetUnsavedChanges
246
247.StoreByteOrWord:
248 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
249 jnz SHORT .StoreByteFromAL
250
251 mov [es:di+1], ah
252ALIGN JUMP_ALIGN
253.StoreByteFromAL:
254 mov [es:di], al
255 ; Fall to .SetUnsavedChanges
256
257;--------------------------------------------------------------------
258; .SetUnsavedChanges
259; Parameters:
260; DS:SI: Ptr to MENUITEM
261; SS:BP: Menu handle
262; Returns:
263; Nothing
264; Corrupts registers:
265; AX, DI
266;--------------------------------------------------------------------
267ALIGN JUMP_ALIGN
268.SetUnsavedChanges:
269 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
270 jnz SHORT .NoUnsavedChangesForProgramVariables
271 call Buffers_SetUnsavedChanges
272.NoUnsavedChangesForProgramVariables:
273 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MODIFY_MENU
274 jnz SHORT .ModifyItemVisibility
275 CALL_MENU_LIBRARY RefreshTitle
276 CALL_MENU_LIBRARY GetHighlightedItemToAX
277 CALL_MENU_LIBRARY RefreshItemFromAX
278 ret
279
280ALIGN JUMP_ALIGN
281.ModifyItemVisibility:
282 push es
283 push ds
284 ePUSHA
285 call Menupage_GetActiveMenupageToDSDI
286 call [di+MENUPAGE.fnEnter]
287 ePOPA
288 pop ds
289 pop es
290 ret
291
292
293;--------------------------------------------------------------------
294; Menuitem_GetValueToAXfromMenuitemInDSSI
295; Parameters:
296; DS:SI: Ptr to MENUITEM
297; Returns:
298; AX: Menuitem value
299; Corrupts registers:
300; BX
301;--------------------------------------------------------------------
302ALIGN JUMP_ALIGN
303Menuitem_GetValueToAXfromMenuitemInDSSI:
304 push es
305 push di
306 push bx
307 call GetConfigurationBufferToESDIforMenuitemInDSSI
308 add di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
309 mov ax, [es:di]
310
311 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
312 jz SHORT .NoConvertWordToByteValue
313 xor ah, ah ; conversion needs to happen before call to the reader,
314 ; in case the reader unpacks the byte to a word
315
316.NoConvertWordToByteValue:
317 mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.fnValueReader]
318 test bx,bx
319 jz SHORT .NoReader
320
321 call bx
322
323.NoReader:
324 pop bx
325 pop di
326 pop es
327
328 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
329 jz SHORT .TestIfFlagValue
330 and ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
331 ret
332
333.TestIfFlagValue:
334 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
335 jz SHORT .Return
336
337 test ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
338 mov ax, TRUE<<1 ; Shift for lookup
339 jnz SHORT .Return
340 xor ax, ax
341
342ALIGN JUMP_ALIGN, ret
343.Return:
344 ret
345
346
347;--------------------------------------------------------------------
348; GetConfigurationBufferToESDIforMenuitemInDSSI
349; Parameters:
350; DS:SI: Ptr to MENUITEM
351; Returns:
352; ES:DI: Ptr to configuration buffer
353; Corrupts registers:
354; Nothing
355;--------------------------------------------------------------------
356ALIGN JUMP_ALIGN
357GetConfigurationBufferToESDIforMenuitemInDSSI:
358 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_PROGRAMVAR
359 jnz SHORT .ReturnCfgvarsInESDI
360 jmp Buffers_GetFileBufferToESDI
361ALIGN JUMP_ALIGN
362.ReturnCfgvarsInESDI:
363 push cs
364 pop es
365 mov di, g_cfgVars
366 ret
Note: See TracBrowser for help on using the repository browser.