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

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

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 8.5 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for drawing menu texts by the user.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20
21; Section containing code
22SECTION .text
23
24;--------------------------------------------------------------------
25; MenuText_ClearTitleArea
26; MenuText_ClearInformationArea
27; Parameters
28; SS:BP: Ptr to MENU
29; Returns:
30; Nothing
31; Corrupts registers:
32; AX, BX, CX, DX, SI, DI
33;--------------------------------------------------------------------
34%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
35ALIGN MENU_JUMP_ALIGN
36MenuText_ClearTitleArea:
37 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
38 call PrepareToDrawTitleArea
39 mov cl, [bp+MENUINIT.bTitleLines]
40 jmp SHORT MenuText_ClearInformationArea.ClearCLlinesOfText
41%endif
42
43ALIGN MENU_JUMP_ALIGN
44MenuText_ClearInformationArea:
45 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
46 call MenuText_PrepareToDrawInformationArea
47 mov cl, [bp+MENUINIT.bInfoLines]
48.ClearCLlinesOfText:
49 mov al, [bp+MENUINIT.bWidth]
50 sub al, MENU_HORIZONTAL_BORDER_LINES+(MENU_TEXT_COLUMN_OFFSET/2)
51 mul cl
52 xchg cx, ax
53 mov al, ' '
54 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
55 CALL_DISPLAY_LIBRARY PopDisplayContext
56 ret
57
58
59;--------------------------------------------------------------------
60; MenuText_RefreshTitle
61; MenuText_RefreshInformation
62; Parameters
63; SS:BP: Ptr to MENU
64; Returns:
65; Nothing
66; Corrupts registers:
67; AX, BX, CX, DX, SI, DI
68;--------------------------------------------------------------------
69ALIGN MENU_JUMP_ALIGN
70MenuText_RefreshTitle:
71 cmp BYTE [bp+MENUINIT.bTitleLines], 0
72 jz SHORT NothingToRefresh
73 call PrepareToDrawTitleArea
74 jmp MenuEvent_RefreshTitle
75
76ALIGN MENU_JUMP_ALIGN
77MenuText_RefreshInformation:
78 cmp BYTE [bp+MENUINIT.bInfoLines], 0
79 jz SHORT NothingToRefresh
80 call MenuText_PrepareToDrawInformationArea
81 jmp MenuEvent_RefreshInformation
82
83;--------------------------------------------------------------------
84; PrepareToDrawTitleArea
85; PrepareToDrawInformationArea
86; Parameters
87; SS:BP: Ptr to MENU
88; Returns:
89; Nothing
90; Corrupts registers:
91; AX, BX, DX, SI, DI
92;--------------------------------------------------------------------
93ALIGN MENU_JUMP_ALIGN
94PrepareToDrawTitleArea:
95 mov si, ATTRIBUTE_CHARS.cTitle
96 call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
97 jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
98
99ALIGN MENU_JUMP_ALIGN
100MenuText_PrepareToDrawInformationArea:
101 mov si, ATTRIBUTE_CHARS.cInformation
102 call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
103FinishPreparationsToDrawTitleOrInformationArea:
104 mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
105 jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
106
107
108;--------------------------------------------------------------------
109; MenuText_RefreshAllItems
110; Parameters
111; SS:BP: Ptr to MENU
112; Returns:
113; Nothing
114; Corrupts registers:
115; AX, BX, DX, SI, DI
116;--------------------------------------------------------------------
117ALIGN MENU_JUMP_ALIGN
118MenuText_RefreshAllItems:
119 push cx
120
121 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
122 mov ax, [bp+MENU.wFirstVisibleItem]
123ALIGN MENU_JUMP_ALIGN
124.ItemRefreshLoop:
125 call MenuText_RefreshItemFromAX
126 inc ax
127 loop .ItemRefreshLoop
128
129 pop cx
130NothingToRefresh:
131 ret
132
133;--------------------------------------------------------------------
134; MenuText_RefreshItemFromAX
135; Parameters
136; AX: Item to refresh
137; SS:BP: Ptr to MENU
138; Returns:
139; Nothing
140; Corrupts registers:
141; BX, DX, SI, DI
142;--------------------------------------------------------------------
143ALIGN MENU_JUMP_ALIGN
144MenuText_RefreshItemFromAX:
145 push cx
146 push ax
147
148 xchg cx, ax
149 call MenuScrollbars_IsItemInCXonVisiblePage
150 jnc SHORT .InvalidItem
151 call MenuText_AdjustDisplayContextForDrawingItemFromCX
152 call ClearPreviousItem
153 call MenuEvent_RefreshItemFromCX
154 call DrawScrollbarCharacterForItemInCXifNecessary
155.InvalidItem:
156 pop ax
157 pop cx
158 ret
159
160;--------------------------------------------------------------------
161; MenuText_AdjustDisplayContextForDrawingItemFromCX
162; Parameters
163; CX: Item to refresh
164; SS:BP: Ptr to MENU
165; Returns:
166; Nothing
167; Corrupts registers:
168; AX, BX, DX, SI, DI
169;--------------------------------------------------------------------
170ALIGN MENU_JUMP_ALIGN
171MenuText_AdjustDisplayContextForDrawingItemFromCX:
172 mov ax, cx
173 call GetItemTextAttributeTypeToSIforItemInCX
174 call MenuLocation_GetTextCoordinatesToAXforItemInAX
175 mov dx, MenuCharOut_MenuTeletypeOutput
176 ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
177
178;--------------------------------------------------------------------
179; AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
180; Parameters
181; AX: Cursor coordinates to set
182; DX: Character output function
183; SI: Attribute type (from ATTRIBUTE_CHARS)
184; SS:BP: Ptr to MENU
185; Returns:
186; Nothing
187; Corrupts registers:
188; AX, BX, DX, SI, DI
189;--------------------------------------------------------------------
190ALIGN MENU_JUMP_ALIGN
191AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
192 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
193
194 xchg ax, dx
195 mov bl, ATTRIBUTES_ARE_USED
196 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
197
198 call CharOutLineSplitter_PrepareForPrintingTextLines
199 jmp MenuAttribute_SetToDisplayContextFromTypeInSI
200
201
202;--------------------------------------------------------------------
203; ClearPreviousItem
204; Parameters
205; SS:BP: Ptr to MENU
206; Returns:
207; Nothing
208; Corrupts registers:
209; AX, BX, DX, DI
210;--------------------------------------------------------------------
211ALIGN MENU_JUMP_ALIGN
212ClearPreviousItem:
213 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
214 xchg bx, ax
215
216 call MenuBorders_GetNumberOfMiddleCharactersToDX
217 sub dx, BYTE MENU_TEXT_COLUMN_OFFSET
218 mov al, [cs:g_rgbTextBorderCharacters+BORDER_CHARS.cMiddle]
219 call MenuBorders_PrintMultipleBorderCharactersFromAL
220
221 xchg ax, bx
222 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
223 ret
224
225
226;--------------------------------------------------------------------
227; GetItemTextAttributeTypeToSIforItemInCX
228; Parameters
229; CX: Item to refresh
230; SS:BP: Ptr to MENU
231; Returns:
232; SI: Text attribute type (ATTRIBUTE_CHARS)
233; Corrupts registers:
234; Nothing
235;--------------------------------------------------------------------
236ALIGN MENU_JUMP_ALIGN
237GetItemTextAttributeTypeToSIforItemInCX:
238 mov si, ATTRIBUTE_CHARS.cItem
239 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
240 jnz SHORT .ReturnAttributeTypeInSI
241
242 cmp cx, [bp+MENUINIT.wHighlightedItem]
243 jne SHORT .ReturnAttributeTypeInSI
244 sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
245ALIGN MENU_JUMP_ALIGN, ret
246.ReturnAttributeTypeInSI:
247 ret
248
249
250;--------------------------------------------------------------------
251; DrawScrollbarCharacterForItemInCXifNecessary
252; Parameters
253; CX: Item to refresh
254; SS:BP: Ptr to MENU
255; Returns:
256; Nothing
257; Corrupts registers:
258; AX, CX, BX, DX, SI, DI
259;--------------------------------------------------------------------
260ALIGN MENU_JUMP_ALIGN
261DrawScrollbarCharacterForItemInCXifNecessary:
262 call MenuScrollbars_AreScrollbarsNeeded
263 jc SHORT .DrawScrollbarCharacter
264 ret
265
266ALIGN MENU_JUMP_ALIGN
267.DrawScrollbarCharacter:
268 call MenuBorders_AdjustDisplayContextForDrawingBorders
269 mov ax, cx
270
271 call MenuLocation_GetTextCoordinatesToAXforItemInAX
272 add al, [bp+MENUINIT.bWidth]
273 sub al, MENU_TEXT_COLUMN_OFFSET*2
274 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
275
276 mov di, cx
277 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
278 call MenuScrollbars_GetScrollCharacterToALForLineInDI
279 jmp MenuBorders_PrintSingleBorderCharacterFromAL
Note: See TracBrowser for help on using the repository browser.