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

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

Changes to Assembly Library:
Drive selection moved to own dialog from File Dialog.
File Dialog now displays loading text for better usability in slow systems.
Moved some functions from Memory.asm to new Registers.asm.

File size: 7.9 KB
Line 
1; File name : MenuText.asm
2; Project name : Assembly Library
3; Created date : 21.7.2010
4; Last update : 24.10.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 mov cx, ax ; Backup item to CX
129
130 call MenuScrollbars_IsItemInCXonVisiblePage
131 jnc SHORT .InvalidItem
132 call MenuText_AdjustDisplayContextForDrawingItemFromCX
133 call MenuEvent_RefreshItemFromCX
134 call DrawScrollbarIfNecessary
135.InvalidItem:
136 xchg ax, cx ; Restore AX
137 pop cx
138 ret
139
140;--------------------------------------------------------------------
141; MenuText_AdjustDisplayContextForDrawingItemFromCX
142; Parameters
143; CX: Item to refresh
144; SS:BP: Ptr to MENU
145; Returns:
146; Nothing
147; Corrupts registers:
148; AX, BX, DX, SI, DI
149;--------------------------------------------------------------------
150ALIGN JUMP_ALIGN
151MenuText_AdjustDisplayContextForDrawingItemFromCX:
152 mov ax, cx
153 call GetItemTextAttributeTypeToSIforItemInCX
154 call MenuLocation_GetTextCoordinatesToAXforItemInAX
155 mov dx, MenuCharOut_MenuTeletypeOutput
156 ; Fall to AdjustDisplayContextForDrawingTextsAtCoordinatesInAXwithAttributeTypeInSI
157
158;--------------------------------------------------------------------
159; AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
160; Parameters
161; AX: Cursor coordinates to set
162; DX: Character output function
163; SI: Attribute type (from ATTRIBUTE_CHARS)
164; SS:BP: Ptr to MENU
165; Returns:
166; Nothing
167; Corrupts registers:
168; AX, BX, DX, SI, DI
169;--------------------------------------------------------------------
170ALIGN JUMP_ALIGN
171AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
172 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
173
174 xchg ax, dx
175 mov bl, ATTRIBUTES_ARE_USED
176 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
177
178 call CharOutLineSplitter_PrepareForPrintingTextLines
179 jmp MenuAttribute_SetToDisplayContextFromTypeInSI
180
181
182;--------------------------------------------------------------------
183; GetItemTextAttributeTypeToSIforItemInCX
184; Parameters
185; CX: Item to refresh
186; SS:BP: Ptr to MENU
187; Returns:
188; SI: Text attribute type (ATTRIBUTE_CHARS)
189; Corrupts registers:
190; Nothing
191;--------------------------------------------------------------------
192ALIGN JUMP_ALIGN
193GetItemTextAttributeTypeToSIforItemInCX:
194 mov si, ATTRIBUTE_CHARS.cItem
195 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
196 jnz SHORT .ReturnAttributeTypeInSI
197
198 cmp cx, [bp+MENUINIT.wHighlightedItem]
199 jne SHORT .ReturnAttributeTypeInSI
200 sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
201ALIGN JUMP_ALIGN, ret
202.ReturnAttributeTypeInSI:
203 ret
204
205
206;--------------------------------------------------------------------
207; DrawScrollbarIfNecessary
208; Parameters
209; CX: Item to refresh
210; SS:BP: Ptr to MENU
211; Returns:
212; Nothing
213; Corrupts registers:
214; AX, BX, DX, SI, DI
215;--------------------------------------------------------------------
216ALIGN JUMP_ALIGN
217DrawScrollbarIfNecessary:
218 push cx
219 call .DrawSpacesBeforeScrollbarCharacter
220 call MenuScrollbars_AreScrollbarsNeeded
221 pop cx
222 jc SHORT .DrawScrollbarCharacter
223 ret
224
225;--------------------------------------------------------------------
226; .DrawSpacesBeforeScrollbarCharacter
227; Parameters
228; CX: Item to refresh
229; SS:BP: Ptr to MENU
230; Returns:
231; Nothing
232; Corrupts registers:
233; AX, CX, DX, DI
234;--------------------------------------------------------------------
235ALIGN JUMP_ALIGN
236.DrawSpacesBeforeScrollbarCharacter:
237 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
238 xchg dx, ax ; Current coordinates to DX
239 mov ax, cx
240 call MenuLocation_GetScrollbarCoordinatesToAXforItemInAX
241 sub al, dl
242 sub al, MENU_TEXT_COLUMN_OFFSET/2
243
244 eMOVZX cx, al
245 jcxz .NoSpacesNeeded
246 mov al, ' '
247 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
248ALIGN JUMP_ALIGN, ret
249.NoSpacesNeeded:
250 ret
251
252;--------------------------------------------------------------------
253; .DrawScrollbarCharacter
254; Parameters
255; CX: Item to refresh
256; SS:BP: Ptr to MENU
257; Returns:
258; Nothing
259; Corrupts registers:
260; AX, BX, DX, SI, DI
261;--------------------------------------------------------------------
262ALIGN JUMP_ALIGN
263.DrawScrollbarCharacter:
264 push cx
265
266 call MenuBorders_AdjustDisplayContextForDrawingBorders
267
268 mov ax, cx
269 call MenuLocation_GetScrollbarCoordinatesToAXforItemInAX
270 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
271
272 mov di, cx
273 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
274 call MenuScrollbars_GetScrollCharacterToALForLineInDI
275 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
276
277 pop cx
278 ret
Note: See TracBrowser for help on using the repository browser.