source: xtideuniversalbios/trunk/Configurator/Src/MenuPageItemFormat.asm@ 32

Last change on this file since 32 was 2, checked in by Tomi Tilli, 15 years ago
File size: 7.8 KB
RevLine 
[2]1; File name : MenuPageItemFormat.asm
2; Project name : XTIDE Univeral BIOS Configurator
3; Created date : 15.4.2010
4; Last update : 30.4.2010
5; Author : Tomi Tilli
6; Description : Functions for formatting
7; menuitem names from MENUPAGEITEM.
8
9; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; Prints lookup string for index values.
14;
15; MenuPageItemFormat_LookupString
16; Parameters:
17; DS:DI: Ptr to MENUPAGEITEM
18; Returns:
19; Nothing
20; Corrupts registers:
21; AX, BX, DX, SI
22;--------------------------------------------------------------------
23ALIGN JUMP_ALIGN
24MenuPageItemFormat_LookupString:
25 mov si, [di+MENUPAGEITEM.rgszLookup] ; Load offset to string lookup table
26 mov bx, [di+MENUPAGEITEM.pValue] ; Ptr to value containing lookup index
27 eMOVZX bx, BYTE [bx] ; BX=lookup index (values are already shifted for WORD lookup)
28 push WORD [bx+si] ; Push offset to string to print
29 mov dh, 4 ; Total of 4 bytes for formatting params
30 mov si, .szStringName ; Offset to format string
31 jmp MenuPageItemFormat_NameWithParamsPushed
32.szStringName: db "+%22s[%7s]",STOP
33
34
35;--------------------------------------------------------------------
36; Prints menuitem name for any MENUPAGEITEM.
37;
38; MenuPageItemFormat_NameForAnyType
39; Parameters:
40; DS:DI: Ptr to MENUPAGEITEM
41; Returns:
42; Nothing
43; Corrupts registers:
44; AX, BX, DX, SI
45;--------------------------------------------------------------------
46ALIGN JUMP_ALIGN
47MenuPageItemFormat_NameForAnyType:
48 eMOVZX bx, BYTE [di+MENUPAGEITEM.bType] ; Load menuitem type
49 jmp [cs:bx+.rgfnPrintBasedOnType]
50ALIGN WORD_ALIGN
51.rgfnPrintBasedOnType:
52 dw MenuPageItemFormat_NameForBackToPreviousSubmenu ; TYPE_MENUPAGEITEM_BACK
53 dw MenuPageItemFormat_NameForNextSubmenu ; TYPE_MENUPAGEITEM_NEXT
54 dw MenuPageItemFormat_NameForSpecialFunction ; TYPE_MENUPAGEITEM_SPECIAL
55 dw MenuPageItemFormat_NameWithUnsignedByteValue ; TYPE_MENUPAGEITEM_UNSIGNED_BYTE
56 dw MenuPageItemFormat_NameWithUnsignedWordValue ; TYPE_MENUPAGEITEM_UNSIGNED_WORD
57 dw MenuPageItemFormat_NameWithByteHexadecimalValue ; TYPE_MENUPAGEITEM_HEX_BYTE
58 dw MenuPageItemFormat_NameWithWordHexadecimalValue ; TYPE_MENUPAGEITEM_HEX_WORD
59 dw MenuPageItemFormat_NameWithFlagValue ; TYPE_MENUPAGEITEM_FLAG
60
61
62;--------------------------------------------------------------------
63; Prints "Back to previous menu" menuitem.
64;
65; MenuPageItemFormat_NameForBackToPreviousSubmenu
66; Parameters:
67; DS:DI: Ptr to MENUPAGEITEM
68; Returns:
69; Nothing
70; Corrupts registers:
71; AX, BX, DX
72;--------------------------------------------------------------------
73ALIGN JUMP_ALIGN
74MenuPageItemFormat_NameForBackToPreviousSubmenu:
75 mov dh, 2 ; Total of 2 bytes for formatting params
76 mov si, .szPrevMenu ; Offset to format string
77 jmp MenuPageItemFormat_NameWithParamsPushed
78.szPrevMenu: db "-%32s",STOP
79
80
81;--------------------------------------------------------------------
82; Prints menuitem name for menuitem that opens new submenu.
83;
84; MenuPageItemFormat_NameForNextSubmenu
85; Parameters:
86; DS:DI: Ptr to MENUPAGEITEM
87; Returns:
88; Nothing
89; Corrupts registers:
90; AX, DX, SI
91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
93MenuPageItemFormat_NameForNextSubmenu:
94 mov dh, 2 ; Total of 2 bytes for formatting params
95 mov si, .szNextMenu ; Offset to format string
96 jmp MenuPageItemFormat_NameWithParamsPushed
97.szNextMenu: db "+%32s",STOP
98
99
100;--------------------------------------------------------------------
101; Prints menuitem name for menuitem with special function.
102;
103; MenuPageItemFormat_NameForSpecialFunction
104; Parameters:
105; DS:DI: Ptr to MENUPAGEITEM
106; Returns:
107; Nothing
108; Corrupts registers:
109; AX, DX, SI
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112MenuPageItemFormat_NameForSpecialFunction:
113 mov dh, 2 ; Total of 2 bytes for formatting params
114 mov si, .szSpecial ; Offset to format string
115 jmp MenuPageItemFormat_NameWithParamsPushed
116.szSpecial: db "*%32s",STOP
117
118
119;--------------------------------------------------------------------
120; Prints menuitem name with unsigned integer value.
121;
122; MenuPageItemFormat_NameWithUnsignedByteValue
123; MenuPageItemFormat_NameWithUnsignedWordValue
124; Parameters:
125; DS:DI: Ptr to MENUPAGEITEM
126; Returns:
127; Nothing
128; Corrupts registers:
129; AX, DX, SI
130;--------------------------------------------------------------------
131ALIGN JUMP_ALIGN
132MenuPageItemFormat_NameWithUnsignedByteValue:
133 mov si, [di+MENUPAGEITEM.pValue] ; DS:SI points to value
134 eMOVZX ax, BYTE [si] ; Load byte to AX
135 push ax ; Push byte
136 jmp SHORT MenuPageItemFormat_NameWithUnsignedValuePushed
137ALIGN JUMP_ALIGN
138MenuPageItemFormat_NameWithUnsignedWordValue:
139 mov si, [di+MENUPAGEITEM.pValue] ; DS:SI points to value
140 push WORD [si] ; Push integer value
141MenuPageItemFormat_NameWithUnsignedValuePushed:
142 mov dh, 4 ; Total of 4 bytes for formatting params
143 mov si, .szIntegerName ; Offset to format string
144 jmp SHORT MenuPageItemFormat_NameWithParamsPushed
145.szIntegerName: db "%25s[%5u]",STOP
146
147
148;--------------------------------------------------------------------
149; Prints menuitem name with hexadecimal value.
150;
151; MenuPageItemFormat_NameWithByteHexadecimalValue
152; MenuPageItemFormat_NameWithWordHexadecimalValue
153; Parameters:
154; DS:DI: Ptr to MENUPAGEITEM
155; Returns:
156; Nothing
157; Corrupts registers:
158; AX, DX, SI
159;--------------------------------------------------------------------
160ALIGN JUMP_ALIGN
161MenuPageItemFormat_NameWithByteHexadecimalValue:
162 mov si, [di+MENUPAGEITEM.pValue] ; DS:SI points to value
163 eMOVZX ax, BYTE [si] ; Load byte to AX
164 push ax ; Push byte
165 jmp SHORT MenuPageItemFormat_NameWithHexadecimalValuePushed
166ALIGN JUMP_ALIGN
167MenuPageItemFormat_NameWithWordHexadecimalValue:
168 mov si, [di+MENUPAGEITEM.pValue] ; DS:SI points to value
169 push WORD [si] ; Push hexadecimal value
170MenuPageItemFormat_NameWithHexadecimalValuePushed:
171 mov dh, 4 ; Total of 4 bytes for formatting params
172 mov si, .szHexName ; Offset to format string
173 jmp SHORT MenuPageItemFormat_NameWithParamsPushed
174.szHexName: db "%25s[%5x]",STOP
175
176
177;--------------------------------------------------------------------
178; Prints menuitem name with Y/N flag value.
179;
180; MenuPageItemFormat_NameWithFlagValue
181; Parameters:
182; DS:DI: Ptr to MENUPAGEITEM
183; Returns:
184; Nothing
185; Corrupts registers:
186; AX, DX, SI
187;--------------------------------------------------------------------
188ALIGN JUMP_ALIGN
189MenuPageItemFormat_NameWithFlagValue:
190 mov dx, 044Eh ; DH=4 bytes in stack, DL='N'
191 mov si, [di+MENUPAGEITEM.pValue] ; DS:SI points to value
192 mov ax, [si] ; Load value
193 test ax, [di+MENUPAGEITEM.wValueMask] ; Flag set?
194 jz SHORT .PushFlagValueChar
195 mov dl, 'Y'
196.PushFlagValueChar:
197 push dx
198 mov si, .szFlagName ; Offset to format string
199 jmp SHORT MenuPageItemFormat_NameWithParamsPushed
200.szFlagName: db "%25s[%5c]",STOP
201
202
203;--------------------------------------------------------------------
204; Prints formatted menuitem name.
205;
206; MenuPageItemFormat_NameWithParamsPushed
207; Parameters:
208; DH: Number of bytes pushed to stack + 2 for name string
209; SI: Offset to formatting string
210; DS:DI: Ptr to MENUPAGEITEM
211; DS: String segment
212; Stack: Formatting parameters except menuitem name
213; Returns:
214; Nothing
215; Corrupts registers:
216; AX, SI
217;--------------------------------------------------------------------
218ALIGN JUMP_ALIGN
219MenuPageItemFormat_NameWithParamsPushed:
220 push WORD [di+MENUPAGEITEM.szName]
221 mov dl, ' ' ; Min length character
222 call Print_Format
223 eMOVZX ax, dh
224 add sp, ax ; Clear format parameters from stack
225 ret
Note: See TracBrowser for help on using the repository browser.