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

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

Commit 1/2 (Library, Configurators and Serial Server):

  • Changed Emulate.inc so that making 286 and 386 versions now works. Additionally, only one processor type define is needed in the makefile.
  • Minor optimizations.
  • Fixed spelling and did some cleaning.
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 jmp [cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
155.InvalidItemType:
156 ret
157
158ALIGN WORD_ALIGN
159.rgfnJumpToStoreValueBasedOnItemType:
160 dw .InvalidItemType ; TYPE_MENUITEM_PAGEBACK
161 dw .InvalidItemType ; TYPE_MENUITEM_PAGENEXT
162 dw .InvalidItemType ; TYPE_MENUITEM_ACTION
163 dw .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_MULTICHOICE
164 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_UNSIGNED
165 dw .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI ; TYPE_MENUITEM_HEX
166
167;--------------------------------------------------------------------
168; .StoreMultichoiceValueFromAXtoESDIwithItemInDSSI
169; Parameters:
170; AX: Multichoice selection (index)
171; DS:SI: Ptr to MENUITEM
172; ES:DI: Ptr to value variable
173; SS:BP: Menu handle
174; Returns:
175; Nothing
176; Corrupts registers:
177; AX, BX, DI
178;--------------------------------------------------------------------
179ALIGN JUMP_ALIGN
180.StoreMultichoiceValueFromAXtoESDIwithItemInDSSI:
181 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MASKVALUE
182 jnz SHORT .ClearBitsUsingMask
183 test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
184 jz SHORT .TranslateChoiceToValueUsingLookupTable
185
186 test ax, ax ; Setting item flag?
187 mov ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
188 jnz SHORT .SetFlagFromAX
189 not ax
190 and [es:di], ax ; Clear flag
191 jmp SHORT .SetUnsavedChanges
192ALIGN JUMP_ALIGN
193.SetFlagFromAX:
194 or [es:di], ax
195 jmp SHORT .SetUnsavedChanges
196
197ALIGN JUMP_ALIGN
198.ClearBitsUsingMask:
199 mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
200 not bx
201 and [es:di], bx
202 ; Fall to .TranslateChoiceToValueUsingLookupTable
203
204
205ALIGN JUMP_ALIGN
206.TranslateChoiceToValueUsingLookupTable:
207;
208; if the lookup pointer is NULL, no translation is needed
209;
210 mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiceToValueLookup]
211 test bx, bx
212 jz .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
213
214 shl ax, 1 ; Shift for WORD lookup
215 add bx, ax
216 mov ax, [bx] ; Lookup complete
217 ; Fall to .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
218
219;--------------------------------------------------------------------
220; .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
221; Parameters:
222; AX: Value to store
223; DS:SI: Ptr to MENUITEM
224; ES:DI: Ptr to value variable
225; SS:BP: Menu handle
226; Returns:
227; Nothing
228; Corrupts registers:
229; AX, DI
230;--------------------------------------------------------------------
231ALIGN JUMP_ALIGN
232.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI:
233 push bx
234 mov bx,[si+MENUITEM.itemValue+ITEM_VALUE.fnValueWriter]
235 test bx,bx
236 jz SHORT .NoWriter
237
238 call bx
239
240.NoWriter:
241 pop bx
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.