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