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

Last change on this file since 580 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 8.4 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-2013 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 JMP_DISPLAY_LIBRARY PopDisplayContext
56
57
58;--------------------------------------------------------------------
59; MenuText_RefreshTitle
60; MenuText_RefreshInformation
61; Parameters
62; SS:BP: Ptr to MENU
63; Returns:
64; Nothing
65; Corrupts registers:
66; AX, BX, CX, DX, SI, DI
67;--------------------------------------------------------------------
68ALIGN MENU_JUMP_ALIGN
69MenuText_RefreshTitle:
70 cmp BYTE [bp+MENUINIT.bTitleLines], 0
71 jz SHORT NothingToRefresh
72 call PrepareToDrawTitleArea
73 jmp MenuEvent_RefreshTitle
74
75ALIGN MENU_JUMP_ALIGN
76MenuText_RefreshInformation:
77 cmp BYTE [bp+MENUINIT.bInfoLines], 0
78 jz SHORT NothingToRefresh
79 call MenuText_PrepareToDrawInformationArea
80 jmp MenuEvent_RefreshInformation
81
82;--------------------------------------------------------------------
83; PrepareToDrawTitleArea
84; PrepareToDrawInformationArea
85; Parameters
86; SS:BP: Ptr to MENU
87; Returns:
88; Nothing
89; Corrupts registers:
90; AX, BX, DX, SI, DI
91;--------------------------------------------------------------------
92ALIGN MENU_JUMP_ALIGN
93PrepareToDrawTitleArea:
94 mov si, ATTRIBUTE_CHARS.cTitle
95 call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
96 jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
97
98ALIGN MENU_JUMP_ALIGN
99MenuText_PrepareToDrawInformationArea:
100 mov si, ATTRIBUTE_CHARS.cInformation
101 call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
102FinishPreparationsToDrawTitleOrInformationArea:
103 mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
104 jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
105
106
107;--------------------------------------------------------------------
108; MenuText_RefreshAllItems
109; Parameters
110; SS:BP: Ptr to MENU
111; Returns:
112; Nothing
113; Corrupts registers:
114; AX, BX, DX, SI, DI
115;--------------------------------------------------------------------
116ALIGN MENU_JUMP_ALIGN
117MenuText_RefreshAllItems:
118 push cx
119
120 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
121 mov ax, [bp+MENU.wFirstVisibleItem]
122ALIGN MENU_JUMP_ALIGN
123.ItemRefreshLoop:
124 call MenuText_RefreshItemFromAX
125 inc ax
126 loop .ItemRefreshLoop
127
128 pop cx
129NothingToRefresh:
130 ret
131
132;--------------------------------------------------------------------
133; MenuText_RefreshItemFromAX
134; Parameters
135; AX: Item to refresh
136; SS:BP: Ptr to MENU
137; Returns:
138; Nothing
139; Corrupts registers:
140; BX, DX, SI, DI
141;--------------------------------------------------------------------
142ALIGN MENU_JUMP_ALIGN
143MenuText_RefreshItemFromAX:
144 push cx
145 push ax
146
147 xchg cx, ax
148 call MenuScrollbars_IsItemInCXonVisiblePage
149 jnc SHORT .InvalidItem
150 call MenuText_AdjustDisplayContextForDrawingItemFromCX
151 call ClearPreviousItem
152 call MenuEvent_RefreshItemFromCX
153 call DrawScrollbarCharacterForItemInCXifNecessary
154.InvalidItem:
155 pop ax
156 pop cx
157 ret
158
159;--------------------------------------------------------------------
160; MenuText_AdjustDisplayContextForDrawingItemFromCX
161; Parameters
162; CX: Item to refresh
163; SS:BP: Ptr to MENU
164; Returns:
165; Nothing
166; Corrupts registers:
167; AX, BX, DX, SI, DI
168;--------------------------------------------------------------------
169ALIGN MENU_JUMP_ALIGN
170MenuText_AdjustDisplayContextForDrawingItemFromCX:
171 mov ax, cx
172 call GetItemTextAttributeTypeToSIforItemInCX
173 call MenuLocation_GetTextCoordinatesToAXforItemInAX
174 mov dx, MenuCharOut_MenuTeletypeOutput
175 ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
176
177;--------------------------------------------------------------------
178; AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
179; Parameters
180; AX: Cursor coordinates to set
181; DX: Character output function
182; SI: Attribute type (from ATTRIBUTE_CHARS)
183; SS:BP: Ptr to MENU
184; Returns:
185; Nothing
186; Corrupts registers:
187; AX, BX, DX, SI, DI
188;--------------------------------------------------------------------
189ALIGN MENU_JUMP_ALIGN
190AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
191 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
192
193 xchg ax, dx
194 mov bl, ATTRIBUTES_ARE_USED
195 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
196
197 call CharOutLineSplitter_PrepareForPrintingTextLines
198 jmp MenuAttribute_SetToDisplayContextFromTypeInSI
199
200
201;--------------------------------------------------------------------
202; ClearPreviousItem
203; Parameters
204; SS:BP: Ptr to MENU
205; Returns:
206; Nothing
207; Corrupts registers:
208; AX, BX, DX, DI
209;--------------------------------------------------------------------
210ALIGN MENU_JUMP_ALIGN
211ClearPreviousItem:
212 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
213 xchg bx, ax
214
215 call MenuBorders_GetNumberOfMiddleCharactersToDX
216 sub dx, BYTE MENU_TEXT_COLUMN_OFFSET
217 mov al, [cs:g_rgbTextBorderCharacters+BORDER_CHARS.cMiddle]
218 call MenuBorders_PrintMultipleBorderCharactersFromAL
219
220 xchg ax, bx
221 JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
222
223
224;--------------------------------------------------------------------
225; GetItemTextAttributeTypeToSIforItemInCX
226; Parameters
227; CX: Item to refresh
228; SS:BP: Ptr to MENU
229; Returns:
230; SI: Text attribute type (ATTRIBUTE_CHARS)
231; Corrupts registers:
232; Nothing
233;--------------------------------------------------------------------
234ALIGN MENU_JUMP_ALIGN
235GetItemTextAttributeTypeToSIforItemInCX:
236 mov si, ATTRIBUTE_CHARS.cItem
237 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
238 jnz SHORT .ReturnAttributeTypeInSI
239
240 cmp cx, [bp+MENUINIT.wHighlightedItem]
241 jne SHORT .ReturnAttributeTypeInSI
242 sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
243ALIGN MENU_JUMP_ALIGN, ret
244.ReturnAttributeTypeInSI:
245 ret
246
247
248;--------------------------------------------------------------------
249; DrawScrollbarCharacterForItemInCXifNecessary
250; Parameters
251; CX: Item to refresh
252; SS:BP: Ptr to MENU
253; Returns:
254; Nothing
255; Corrupts registers:
256; AX, CX, BX, DX, SI, DI
257;--------------------------------------------------------------------
258ALIGN MENU_JUMP_ALIGN
259DrawScrollbarCharacterForItemInCXifNecessary:
260 call MenuScrollbars_AreScrollbarsNeeded
261 jc SHORT .DrawScrollbarCharacter
262 ret
263
264ALIGN MENU_JUMP_ALIGN
265.DrawScrollbarCharacter:
266 call MenuBorders_AdjustDisplayContextForDrawingBorders
267 mov ax, cx
268
269 call MenuLocation_GetTextCoordinatesToAXforItemInAX
270 add al, [bp+MENUINIT.bWidth]
271 sub al, MENU_TEXT_COLUMN_OFFSET*2
272 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
273
274 mov di, cx
275 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
276 call MenuScrollbars_GetScrollCharacterToALForLineInDI
277 jmp MenuBorders_PrintSingleBorderCharacterFromAL
Note: See TracBrowser for help on using the repository browser.