source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm@ 329

Last change on this file since 329 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: 8.0 KB
Line 
1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : Functions for printing MENUITEM name and value.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; MenuitemPrint_PrintQuickInfoFromDSSI
9; Parameters:
10; DS:SI: Ptr to MENUITEM
11; Returns:
12; Nothing
13; Corrupts registers:
14; AX, DI
15;--------------------------------------------------------------------
16ALIGN JUMP_ALIGN
17MenuitemPrint_PrintQuickInfoFromDSSI:
18 push si
19
20 mov si, [si+MENUITEM.szQuickInfo]
21 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
22
23 pop si
24 ret
25
26
27;--------------------------------------------------------------------
28; MenuitemPrint_NameWithPossibleValueFromDSSI
29; Parameters:
30; DS:SI: Ptr to MENUITEM
31; Returns:
32; Nothing
33; Corrupts registers:
34; AX, BX, DX, DI
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37MenuitemPrint_NameWithPossibleValueFromDSSI:
38 eMOVZX bx, [si+MENUITEM.bType]
39 cmp bl, TYPE_MENUITEM_ACTION
40 ja SHORT .PrintNameAndValueFromDSSI
41 ; Fall to .PrintNameWithoutValueFromDSSI
42
43;--------------------------------------------------------------------
44; .PrintNameWithoutValueFromDSSI
45; Parameters:
46; BX: Menuitem type (MENUITEM.bType)
47; DS:SI: Ptr to MENUITEM
48; Returns:
49; Nothing
50; Corrupts registers:
51; AX, DI
52;--------------------------------------------------------------------
53.PrintNameWithoutValueFromDSSI:
54 push bp
55 push si
56
57 mov bp, sp ; BP = SP before pushing parameters
58 push WORD [cs:bx+.rgwMenuitemTypeCharacter]
59 push WORD [si+MENUITEM.szName]
60 mov si, g_szFormatItemWithoutValue
61 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
62
63 pop si
64 pop bp
65 ret
66.rgwMenuitemTypeCharacter:
67 dw '-' ; TYPE_MENUITEM_PAGEBACK
68 dw '+' ; TYPE_MENUITEM_PAGENEXT
69 dw '*' ; TYPE_MENUITEM_ACTION
70
71
72;--------------------------------------------------------------------
73; .PrintNameAndValueFromDSSI
74; Parameters:
75; DS:SI: Ptr to MENUITEM
76; SS:BP: Ptr to buffer for item value
77; Returns:
78; Nothing
79; Corrupts registers:
80; AX, BX, DX, DI
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83.PrintNameAndValueFromDSSI:
84 eENTER_STRUCT MAX_VALUE_STRING_LENGTH+2 ; +2 for NULL and alignment
85 call .FormatValueStringFromItemInDSSItoBufferInSSBP
86 call .FormatNameFromItemInDSSIandValueFromSSBP
87 eLEAVE_STRUCT MAX_VALUE_STRING_LENGTH+2
88 ret
89
90;--------------------------------------------------------------------
91; .FormatValueStringFromItemInDSSItoBufferInSSBP
92; Parameters:
93; DS:SI: Ptr to MENUITEM
94; SS:BP: Ptr to buffer for item value
95; Returns:
96; Nothing
97; Corrupts registers:
98; AX, BX, DX, DI
99;--------------------------------------------------------------------
100ALIGN JUMP_ALIGN
101.FormatValueStringFromItemInDSSItoBufferInSSBP:
102 push es
103 call Registers_CopySSBPtoESDI
104 mov al, '['
105 stosb
106 call [si+MENUITEM.fnFormatValue]
107 mov ax, ']'
108 stosw ; Also terminate with NULL
109 pop es
110 ret
111
112;--------------------------------------------------------------------
113; .FormatNameFromItemInDSSIandValueFromSSBP
114; Parameters:
115; DS:SI: Ptr to MENUITEM
116; SS:BP: Ptr to value string
117; Returns:
118; Nothing
119; Corrupts registers:
120; AX, BX, DX
121;--------------------------------------------------------------------
122ALIGN JUMP_ALIGN
123.FormatNameFromItemInDSSIandValueFromSSBP:
124 push si
125
126 mov bx, bp
127 mov bp, sp ; BP = SP before pushing parameters
128 push WORD [si+MENUITEM.szName]
129 push bx
130 push ss
131 mov si, g_szFormatItemNameWithValue
132 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
133
134 mov bp, bx
135 pop si
136 ret
137
138
139;--------------------------------------------------------------------
140; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
141; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
142; Parameters:
143; DS:SI: Ptr to MENUITEM
144; ES:DI: Ptr to destination buffer
145; Returns:
146; DI: Updated
147; Corrupts registers:
148; AX, BX, CX
149;--------------------------------------------------------------------
150ALIGN JUMP_ALIGN
151MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI:
152 call Menuitem_GetValueToAXfromMenuitemInDSSI
153 shl ax, 1
154 jmp SHORT PrintLookupValueFromAXtoBufferInESDI
155
156ALIGN JUMP_ALIGN
157MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI:
158MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI:
159 call Menuitem_GetValueToAXfromMenuitemInDSSI
160 ; Fall to PrintLookupValueFromAXtoBufferInESDI
161
162;--------------------------------------------------------------------
163; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
164; Parameters:
165; AX: Value to print
166; DS:SI: Ptr to MENUITEM
167; ES:DI: Ptr to destination buffer
168; Returns:
169; DI: Updated
170; Corrupts registers:
171; AX, BX, CX
172;--------------------------------------------------------------------
173ALIGN JUMP_ALIGN
174PrintLookupValueFromAXtoBufferInESDI:
175 push si
176 test byte [si+MENUITEM.bFlags], FLG_MENUITEM_CHOICESTRINGS
177 jnz .lookupChoice
178
179 add ax, [si+MENUITEM.itemValue+ITEM_VALUE.rgszValueToStringLookup]
180 xchg bx, ax
181.found:
182 mov si, [bx]
183.errorReturn:
184 call String_CopyDSSItoESDIandGetLengthToCX
185 pop si
186 ret
187
188;
189; With FLG_MENUITEM_CHOICESTRINGS, the array at .rgszChoiceToStringLookup is based on the
190; Choice number (offset within .rgwChoiceToValueLookup) instead of the value stored.
191; Here, we scan the .rgwChoiceToValueLookup array until we find the value there, and then
192; use the same offset in .rgszChoiceToStringLookup. If we don't find the value, we
193; return an "Error!" string instead.
194;
195; Note that the pointer array at .rgszChoiceToStringLookup must be NULL terminated. Since the
196; value could be zero, we don't use the .rgwChoiceToValueLookup array to find the end.
197;
198.lookupChoice:
199 mov bx,[si+MENUITEM.itemValue+ITEM_VALUE.rgszChoiceToStringLookup]
200 mov si,[si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiceToValueLookup]
201
202.wordLoop:
203 cmp ax,[si]
204 jz .found
205 inc si
206 inc si
207 inc bx
208 inc bx
209 cmp word [bx],0
210 jnz .wordLoop
211
212 mov si,g_szValueUnknownError
213 jmp .errorReturn
214
215;--------------------------------------------------------------------
216; MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
217; Parameters:
218; DS:SI: Ptr to MENUITEM
219; ES:DI: Ptr to destination buffer
220; Returns:
221; DI: Updated
222; Corrupts registers:
223; AX, BX, CX
224;--------------------------------------------------------------------
225ALIGN JUMP_ALIGN
226MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI:
227 mov bx, di
228 mov cx, MAX_VALUE_STRING_LENGTH
229 CALL_DISPLAY_LIBRARY PushDisplayContext
230 CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
231
232 call Menuitem_GetValueToAXfromMenuitemInDSSI
233 mov bx, 10
234 CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
235 jmp SHORT MenuitemPrint_FinishPrintingUnsignedOrHexValue
236
237;--------------------------------------------------------------------
238; MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
239; Parameters:
240; DS:SI: Ptr to MENUITEM
241; ES:DI: Ptr to destination buffer
242; Returns:
243; DI: Updated
244; Corrupts registers:
245; AX, BX, CX
246;--------------------------------------------------------------------
247ALIGN JUMP_ALIGN
248MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI:
249 mov bx, di
250 mov cx, MAX_VALUE_STRING_LENGTH
251 CALL_DISPLAY_LIBRARY PushDisplayContext
252 CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
253
254 call Menuitem_GetValueToAXfromMenuitemInDSSI
255 mov bx, 16
256 CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
257 mov al, 'h'
258 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
259ALIGN JUMP_ALIGN
260MenuitemPrint_FinishPrintingUnsignedOrHexValue:
261 CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
262 xchg bx, ax
263
264 CALL_DISPLAY_LIBRARY PopDisplayContext
265 mov di, bx
266 ret
267
268
269; Section containing initialized data
270SECTION .data
271
272ALIGN WORD_ALIGN
273g_rgszValueToStringLookupForFlagBooleans:
274 dw g_szNo
275 dw g_szYes
Note: See TracBrowser for help on using the repository browser.