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

Last change on this file since 247 was 194, checked in by gregli@…, 13 years ago

ifdef'd out more unused code. Also added a tool for looking through the listing and the output of the precompiler to aid in finding dead code. Some changes in the files are to add annotations for the tool to avoid false positives.

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