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

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

Changes to Assembly Library:
Added functions to clear Menu Title and Information areas.
Implemented automatic line change when writing Menu Title and Information areas.
CGA snow related functions have been moved to CgaSnow.asm.
Keyboard input functions no longer produce beep for backspace.

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 : 7.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 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
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 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 mov ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
79 call AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
80 call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
81 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
82 ret
83
84ALIGN JUMP_ALIGN
85PrepareToDrawInformationArea:
86 mov si, ATTRIBUTE_CHARS.cInformation
87 mov ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
88 call AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
89 call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
90 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
91 ret
92
93
94;--------------------------------------------------------------------
95; MenuText_RefreshAllItems
96; Parameters
97; SS:BP: Ptr to MENU
98; Returns:
99; Nothing
100; Corrupts registers:
101; AX, BX, DX, SI, DI
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
104MenuText_RefreshAllItems:
105 push cx
106
107 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
108 mov ax, [bp+MENU.wFirstVisibleItem]
109ALIGN JUMP_ALIGN
110.ItemRefreshLoop:
111 call MenuText_RefreshItemFromAX
112 inc ax
113 loop .ItemRefreshLoop
114
115 pop cx
116NothingToRefresh:
117 ret
118
119;--------------------------------------------------------------------
120; MenuText_RefreshItemFromAX
121; Parameters
122; AX: Item to refresh
123; SS:BP: Ptr to MENU
124; Returns:
125; Nothing
126; Corrupts registers:
127; BX, DX, SI, DI
128;--------------------------------------------------------------------
129ALIGN JUMP_ALIGN
130MenuText_RefreshItemFromAX:
131 push cx
132 mov cx, ax ; Backup item to CX
133
134 call MenuScrollbars_IsItemInCXonVisiblePage
135 jnc SHORT .InvalidItem
136 mov ax, cx
137 call MenuText_AdjustDisplayContextForDrawingItemFromAX
138 call MenuEvent_RefreshItemFromCX
139 call DrawScrollbarIfNecessary
140.InvalidItem:
141 xchg ax, cx ; Restore AX
142 pop cx
143 ret
144
145;--------------------------------------------------------------------
146; MenuText_AdjustDisplayContextForDrawingItemFromAX
147; Parameters
148; AX: Item to refresh
149; SS:BP: Ptr to MENU
150; Returns:
151; CX: Item to refresh
152; Corrupts registers:
153; AX, SI, DI
154;--------------------------------------------------------------------
155ALIGN JUMP_ALIGN
156MenuText_AdjustDisplayContextForDrawingItemFromAX:
157 mov cx, ax
158 call MenuLocation_GetTextCoordinatesToAXforItemInAX
159 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
160 call .GetItemTextAttributeTypeToSIforItemInCX
161 mov ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute
162 jmp SHORT AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
163
164;--------------------------------------------------------------------
165; .GetItemTextAttributeTypeToSIforItemInCX
166; Parameters
167; CX: Item to refresh
168; SS:BP: Ptr to MENU
169; Returns:
170; SI: Text attribute type (ATTRIBUTE_CHARS)
171; Corrupts registers:
172; Nothing
173;--------------------------------------------------------------------
174ALIGN JUMP_ALIGN
175.GetItemTextAttributeTypeToSIforItemInCX:
176 mov si, ATTRIBUTE_CHARS.cItem
177 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
178 jnz SHORT .ReturnAttributeTypeInSI
179 cmp cx, [bp+MENU.wHighlightedItem]
180 jne SHORT .ReturnAttributeTypeInSI
181 sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
182ALIGN JUMP_ALIGN, ret
183.ReturnAttributeTypeInSI:
184 ret
185
186
187;--------------------------------------------------------------------
188; DrawScrollbarIfNecessary
189; Parameters
190; CX: Item to refresh
191; SS:BP: Ptr to MENU
192; Returns:
193; Nothing
194; Corrupts registers:
195; AX, BX, DX, SI, DI
196;--------------------------------------------------------------------
197ALIGN JUMP_ALIGN
198DrawScrollbarIfNecessary:
199 push cx
200 call .DrawSpacesBeforeScrollbarCharacter
201 call MenuScrollbars_AreScrollbarsNeeded
202 pop cx
203 jc SHORT .DrawScrollbarCharacter
204 ret
205
206;--------------------------------------------------------------------
207; .DrawSpacesBeforeScrollbarCharacter
208; Parameters
209; CX: Item to refresh
210; SS:BP: Ptr to MENU
211; Returns:
212; Nothing
213; Corrupts registers:
214; AX, CX, DX, DI
215;--------------------------------------------------------------------
216ALIGN JUMP_ALIGN
217.DrawSpacesBeforeScrollbarCharacter:
218 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
219 xchg dx, ax ; Current coordinates to DX
220 mov ax, cx
221 call MenuLocation_GetScrollbarCoordinatesToAXforItemInAX
222 sub al, dl
223 sub al, MENU_TEXT_COLUMN_OFFSET/2
224
225 eMOVZX cx, al
226 jcxz .NoSpacesNeeded
227 mov al, ' '
228 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
229ALIGN JUMP_ALIGN, ret
230.NoSpacesNeeded:
231 ret
232
233;--------------------------------------------------------------------
234; .DrawScrollbarCharacter
235; Parameters
236; CX: Item to refresh
237; SS:BP: Ptr to MENU
238; Returns:
239; Nothing
240; Corrupts registers:
241; AX, BX, DX, SI, DI
242;--------------------------------------------------------------------
243ALIGN JUMP_ALIGN
244.DrawScrollbarCharacter:
245 push cx
246
247 call MenuBorders_AdjustDisplayContextForDrawingBorders
248
249 mov ax, cx
250 call MenuLocation_GetScrollbarCoordinatesToAXforItemInAX
251 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
252
253 mov di, cx
254 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
255 call MenuScrollbars_GetScrollCharacterToALForLineInDI
256 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
257
258 pop cx
259 ret
260
261
262;--------------------------------------------------------------------
263; AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
264; Parameters
265; AX: Character output function
266; SI: Attribute type (from ATTRIBUTE_CHARS)
267; SS:BP: Ptr to MENU
268; Returns:
269; Nothing
270; Corrupts registers:
271; AX, BX, SI, DI
272;--------------------------------------------------------------------
273ALIGN JUMP_ALIGN
274AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX:
275 mov bl, ATTRIBUTES_ARE_USED
276 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
277
278 mov ax, bp
279 CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
280
281 jmp MenuAttribute_SetToDisplayContextFromTypeInSI
Note: See TracBrowser for help on using the repository browser.