source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuText.asm@ 187

Last change on this file since 187 was 133, checked in by krille_n_@…, 14 years ago

Size optimizations in various files in the Assembly Library. Also a very small change to a string in XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm

File size: 7.6 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for drawing menu texts by the user.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; MenuText_ClearTitleArea
9; MenuText_ClearInformationArea
10; Parameters
11; SS:BP: Ptr to MENU
12; Returns:
13; Nothing
14; Corrupts registers:
15; AX, BX, CX, DX, SI, DI
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18MenuText_ClearTitleArea:
19 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
20 call PrepareToDrawTitleArea
21 mov cl, [bp+MENUINIT.bTitleLines]
22 jmp SHORT ClearCLlinesOfText
23
24ALIGN JUMP_ALIGN
25MenuText_ClearInformationArea:
26 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
27 call MenuText_PrepareToDrawInformationArea
28 mov cl, [bp+MENUINIT.bInfoLines]
29ClearCLlinesOfText:
30 mov al, [bp+MENUINIT.bWidth]
31 sub al, MENU_HORIZONTAL_BORDER_LINES+(MENU_TEXT_COLUMN_OFFSET/2)
32 mul cl
33 xchg cx, ax
34 mov al, ' '
35 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
36 CALL_DISPLAY_LIBRARY PopDisplayContext
37 ret
38
39
40;--------------------------------------------------------------------
41; MenuText_RefreshTitle
42; MenuText_RefreshInformation
43; Parameters
44; SS:BP: Ptr to MENU
45; Returns:
46; Nothing
47; Corrupts registers:
48; AX, BX, CX, DX, SI, DI
49;--------------------------------------------------------------------
50ALIGN JUMP_ALIGN
51MenuText_RefreshTitle:
52 cmp BYTE [bp+MENUINIT.bTitleLines], 0
53 jz SHORT NothingToRefresh
54 call PrepareToDrawTitleArea
55 jmp MenuEvent_RefreshTitle
56
57ALIGN JUMP_ALIGN
58MenuText_RefreshInformation:
59 cmp BYTE [bp+MENUINIT.bInfoLines], 0
60 jz SHORT NothingToRefresh
61 call MenuText_PrepareToDrawInformationArea
62 jmp MenuEvent_RefreshInformation
63
64;--------------------------------------------------------------------
65; PrepareToDrawTitleArea
66; PrepareToDrawInformationArea
67; Parameters
68; SS:BP: Ptr to MENU
69; Returns:
70; Nothing
71; Corrupts registers:
72; AX, BX, DX, SI, DI
73;--------------------------------------------------------------------
74ALIGN JUMP_ALIGN
75PrepareToDrawTitleArea:
76 mov si, ATTRIBUTE_CHARS.cTitle
77 call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
78 jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
79
80ALIGN JUMP_ALIGN
81MenuText_PrepareToDrawInformationArea:
82 mov si, ATTRIBUTE_CHARS.cInformation
83 call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
84FinishPreparationsToDrawTitleOrInformationArea:
85 mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
86 jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
87
88
89;--------------------------------------------------------------------
90; MenuText_RefreshAllItems
91; Parameters
92; SS:BP: Ptr to MENU
93; Returns:
94; Nothing
95; Corrupts registers:
96; AX, BX, DX, SI, DI
97;--------------------------------------------------------------------
98ALIGN JUMP_ALIGN
99MenuText_RefreshAllItems:
100 push cx
101
102 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
103 mov ax, [bp+MENU.wFirstVisibleItem]
104ALIGN JUMP_ALIGN
105.ItemRefreshLoop:
106 call MenuText_RefreshItemFromAX
107 inc ax
108 loop .ItemRefreshLoop
109
110 pop cx
111NothingToRefresh:
112 ret
113
114;--------------------------------------------------------------------
115; MenuText_RefreshItemFromAX
116; Parameters
117; AX: Item to refresh
118; SS:BP: Ptr to MENU
119; Returns:
120; Nothing
121; Corrupts registers:
122; BX, DX, SI, DI
123;--------------------------------------------------------------------
124ALIGN JUMP_ALIGN
125MenuText_RefreshItemFromAX:
126 push cx
127 push ax
128
129 xchg cx, ax
130 call MenuScrollbars_IsItemInCXonVisiblePage
131 jnc SHORT .InvalidItem
132 call MenuText_AdjustDisplayContextForDrawingItemFromCX
133 call ClearPreviousItem
134 call MenuEvent_RefreshItemFromCX
135 call DrawScrollbarCharacterForItemInCXifNecessary
136.InvalidItem:
137 pop ax
138 pop cx
139 ret
140
141;--------------------------------------------------------------------
142; MenuText_AdjustDisplayContextForDrawingItemFromCX
143; Parameters
144; CX: Item to refresh
145; SS:BP: Ptr to MENU
146; Returns:
147; Nothing
148; Corrupts registers:
149; AX, BX, DX, SI, DI
150;--------------------------------------------------------------------
151ALIGN JUMP_ALIGN
152MenuText_AdjustDisplayContextForDrawingItemFromCX:
153 mov ax, cx
154 call GetItemTextAttributeTypeToSIforItemInCX
155 call MenuLocation_GetTextCoordinatesToAXforItemInAX
156 mov dx, MenuCharOut_MenuTeletypeOutput
157 ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
158
159;--------------------------------------------------------------------
160; AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
161; Parameters
162; AX: Cursor coordinates to set
163; DX: Character output function
164; SI: Attribute type (from ATTRIBUTE_CHARS)
165; SS:BP: Ptr to MENU
166; Returns:
167; Nothing
168; Corrupts registers:
169; AX, BX, DX, SI, DI
170;--------------------------------------------------------------------
171ALIGN JUMP_ALIGN
172AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
173 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
174
175 xchg ax, dx
176 mov bl, ATTRIBUTES_ARE_USED
177 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
178
179 call CharOutLineSplitter_PrepareForPrintingTextLines
180 jmp MenuAttribute_SetToDisplayContextFromTypeInSI
181
182
183;--------------------------------------------------------------------
184; ClearPreviousItem
185; Parameters
186; SS:BP: Ptr to MENU
187; Returns:
188; Nothing
189; Corrupts registers:
190; AX, BX, DX, DI
191;--------------------------------------------------------------------
192ALIGN JUMP_ALIGN
193ClearPreviousItem:
194 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
195 xchg bx, ax
196
197 call MenuBorders_GetNumberOfMiddleCharactersToDX
198 sub dx, BYTE MENU_TEXT_COLUMN_OFFSET
199 mov al, [cs:g_rgbTextBorderCharacters+BORDER_CHARS.cMiddle]
200 call MenuBorders_PrintMultipleBorderCharactersFromAL
201
202 xchg ax, bx
203 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
204 ret
205
206
207;--------------------------------------------------------------------
208; GetItemTextAttributeTypeToSIforItemInCX
209; Parameters
210; CX: Item to refresh
211; SS:BP: Ptr to MENU
212; Returns:
213; SI: Text attribute type (ATTRIBUTE_CHARS)
214; Corrupts registers:
215; Nothing
216;--------------------------------------------------------------------
217ALIGN JUMP_ALIGN
218GetItemTextAttributeTypeToSIforItemInCX:
219 mov si, ATTRIBUTE_CHARS.cItem
220 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
221 jnz SHORT .ReturnAttributeTypeInSI
222
223 cmp cx, [bp+MENUINIT.wHighlightedItem]
224 jne SHORT .ReturnAttributeTypeInSI
225 sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
226ALIGN JUMP_ALIGN, ret
227.ReturnAttributeTypeInSI:
228 ret
229
230
231;--------------------------------------------------------------------
232; DrawScrollbarCharacterForItemInCXifNecessary
233; Parameters
234; CX: Item to refresh
235; SS:BP: Ptr to MENU
236; Returns:
237; Nothing
238; Corrupts registers:
239; AX, CX, BX, DX, SI, DI
240;--------------------------------------------------------------------
241ALIGN JUMP_ALIGN
242DrawScrollbarCharacterForItemInCXifNecessary:
243 call MenuScrollbars_AreScrollbarsNeeded
244 jc SHORT .DrawScrollbarCharacter
245 ret
246
247ALIGN JUMP_ALIGN
248.DrawScrollbarCharacter:
249 call MenuBorders_AdjustDisplayContextForDrawingBorders
250 mov ax, cx
251
252 call MenuLocation_GetTextCoordinatesToAXforItemInAX
253 add al, [bp+MENUINIT.bWidth]
254 sub al, MENU_TEXT_COLUMN_OFFSET*2
255 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
256
257 mov di, cx
258 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
259 call MenuScrollbars_GetScrollCharacterToALForLineInDI
260 jmp MenuBorders_PrintSingleBorderCharacterFromAL
Note: See TracBrowser for help on using the repository browser.