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

Last change on this file since 95 was 67, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

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