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

Last change on this file since 237 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
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for drawing menu texts by the user.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
[48]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;--------------------------------------------------------------------
[194]17%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[48]18ALIGN JUMP_ALIGN
19MenuText_ClearTitleArea:
[125]20 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
[48]21 call PrepareToDrawTitleArea
22 mov cl, [bp+MENUINIT.bTitleLines]
[194]23 jmp SHORT MenuText_ClearInformationArea.ClearCLlinesOfText
24%endif
25
[48]26ALIGN JUMP_ALIGN
27MenuText_ClearInformationArea:
[125]28 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
[54]29 call MenuText_PrepareToDrawInformationArea
[48]30 mov cl, [bp+MENUINIT.bInfoLines]
[194]31.ClearCLlinesOfText:
[48]32 mov al, [bp+MENUINIT.bWidth]
[54]33 sub al, MENU_HORIZONTAL_BORDER_LINES+(MENU_TEXT_COLUMN_OFFSET/2)
[48]34 mul cl
35 xchg cx, ax
36 mov al, ' '
37 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
[125]38 CALL_DISPLAY_LIBRARY PopDisplayContext
[48]39 ret
40
41
42;--------------------------------------------------------------------
[41]43; MenuText_RefreshTitle
44; MenuText_RefreshInformation
45; Parameters
46; SS:BP: Ptr to MENU
47; Returns:
48; Nothing
49; Corrupts registers:
[48]50; AX, BX, CX, DX, SI, DI
[41]51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53MenuText_RefreshTitle:
54 cmp BYTE [bp+MENUINIT.bTitleLines], 0
55 jz SHORT NothingToRefresh
[48]56 call PrepareToDrawTitleArea
[41]57 jmp MenuEvent_RefreshTitle
58
59ALIGN JUMP_ALIGN
60MenuText_RefreshInformation:
61 cmp BYTE [bp+MENUINIT.bInfoLines], 0
62 jz SHORT NothingToRefresh
[54]63 call MenuText_PrepareToDrawInformationArea
[48]64 jmp MenuEvent_RefreshInformation
[41]65
[48]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
[52]80 jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
[48]81
82ALIGN JUMP_ALIGN
[54]83MenuText_PrepareToDrawInformationArea:
[41]84 mov si, ATTRIBUTE_CHARS.cInformation
85 call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
[52]86FinishPreparationsToDrawTitleOrInformationArea:
87 mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
88 jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
[41]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
[67]129 push ax
[41]130
[67]131 xchg cx, ax
[41]132 call MenuScrollbars_IsItemInCXonVisiblePage
133 jnc SHORT .InvalidItem
[52]134 call MenuText_AdjustDisplayContextForDrawingItemFromCX
[67]135 call ClearPreviousItem
[41]136 call MenuEvent_RefreshItemFromCX
[67]137 call DrawScrollbarCharacterForItemInCXifNecessary
[41]138.InvalidItem:
[67]139 pop ax
[41]140 pop cx
141 ret
142
143;--------------------------------------------------------------------
[52]144; MenuText_AdjustDisplayContextForDrawingItemFromCX
[41]145; Parameters
[52]146; CX: Item to refresh
[41]147; SS:BP: Ptr to MENU
148; Returns:
[52]149; Nothing
[41]150; Corrupts registers:
[52]151; AX, BX, DX, SI, DI
[41]152;--------------------------------------------------------------------
153ALIGN JUMP_ALIGN
[52]154MenuText_AdjustDisplayContextForDrawingItemFromCX:
155 mov ax, cx
156 call GetItemTextAttributeTypeToSIforItemInCX
[41]157 call MenuLocation_GetTextCoordinatesToAXforItemInAX
[52]158 mov dx, MenuCharOut_MenuTeletypeOutput
[133]159 ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
[52]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:
[41]175 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
176
[52]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
[41]185;--------------------------------------------------------------------
[67]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;--------------------------------------------------------------------
[52]210; GetItemTextAttributeTypeToSIforItemInCX
[41]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
[52]220GetItemTextAttributeTypeToSIforItemInCX:
[41]221 mov si, ATTRIBUTE_CHARS.cItem
222 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
223 jnz SHORT .ReturnAttributeTypeInSI
[52]224
225 cmp cx, [bp+MENUINIT.wHighlightedItem]
[41]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;--------------------------------------------------------------------
[67]234; DrawScrollbarCharacterForItemInCXifNecessary
[41]235; Parameters
236; CX: Item to refresh
237; SS:BP: Ptr to MENU
238; Returns:
239; Nothing
240; Corrupts registers:
[67]241; AX, CX, BX, DX, SI, DI
[41]242;--------------------------------------------------------------------
243ALIGN JUMP_ALIGN
[67]244DrawScrollbarCharacterForItemInCXifNecessary:
[41]245 call MenuScrollbars_AreScrollbarsNeeded
246 jc SHORT .DrawScrollbarCharacter
247 ret
248
249ALIGN JUMP_ALIGN
250.DrawScrollbarCharacter:
[48]251 call MenuBorders_AdjustDisplayContextForDrawingBorders
[41]252 mov ax, cx
[104]253
254 call MenuLocation_GetTextCoordinatesToAXforItemInAX
255 add al, [bp+MENUINIT.bWidth]
256 sub al, MENU_TEXT_COLUMN_OFFSET*2
[41]257 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
258
259 mov di, cx
260 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
261 call MenuScrollbars_GetScrollCharacterToALForLineInDI
[67]262 jmp MenuBorders_PrintSingleBorderCharacterFromAL
Note: See TracBrowser for help on using the repository browser.