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

Last change on this file since 399 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
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for drawing menu texts by the user.
3
[376]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
[41]21; Section containing code
22SECTION .text
23
24;--------------------------------------------------------------------
[48]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;--------------------------------------------------------------------
[194]34%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]35ALIGN MENU_JUMP_ALIGN
[48]36MenuText_ClearTitleArea:
[125]37 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
[48]38 call PrepareToDrawTitleArea
39 mov cl, [bp+MENUINIT.bTitleLines]
[194]40 jmp SHORT MenuText_ClearInformationArea.ClearCLlinesOfText
41%endif
42
[369]43ALIGN MENU_JUMP_ALIGN
[48]44MenuText_ClearInformationArea:
[125]45 CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
[54]46 call MenuText_PrepareToDrawInformationArea
[48]47 mov cl, [bp+MENUINIT.bInfoLines]
[194]48.ClearCLlinesOfText:
[48]49 mov al, [bp+MENUINIT.bWidth]
[54]50 sub al, MENU_HORIZONTAL_BORDER_LINES+(MENU_TEXT_COLUMN_OFFSET/2)
[48]51 mul cl
52 xchg cx, ax
53 mov al, ' '
54 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
[125]55 CALL_DISPLAY_LIBRARY PopDisplayContext
[48]56 ret
57
58
59;--------------------------------------------------------------------
[41]60; MenuText_RefreshTitle
61; MenuText_RefreshInformation
62; Parameters
63; SS:BP: Ptr to MENU
64; Returns:
65; Nothing
66; Corrupts registers:
[48]67; AX, BX, CX, DX, SI, DI
[41]68;--------------------------------------------------------------------
[369]69ALIGN MENU_JUMP_ALIGN
[41]70MenuText_RefreshTitle:
71 cmp BYTE [bp+MENUINIT.bTitleLines], 0
72 jz SHORT NothingToRefresh
[48]73 call PrepareToDrawTitleArea
[41]74 jmp MenuEvent_RefreshTitle
75
[369]76ALIGN MENU_JUMP_ALIGN
[41]77MenuText_RefreshInformation:
78 cmp BYTE [bp+MENUINIT.bInfoLines], 0
79 jz SHORT NothingToRefresh
[54]80 call MenuText_PrepareToDrawInformationArea
[48]81 jmp MenuEvent_RefreshInformation
[41]82
[48]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;--------------------------------------------------------------------
[369]93ALIGN MENU_JUMP_ALIGN
[48]94PrepareToDrawTitleArea:
95 mov si, ATTRIBUTE_CHARS.cTitle
96 call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
[52]97 jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
[48]98
[369]99ALIGN MENU_JUMP_ALIGN
[54]100MenuText_PrepareToDrawInformationArea:
[41]101 mov si, ATTRIBUTE_CHARS.cInformation
102 call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
[52]103FinishPreparationsToDrawTitleOrInformationArea:
104 mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
105 jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
[41]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;--------------------------------------------------------------------
[369]117ALIGN MENU_JUMP_ALIGN
[41]118MenuText_RefreshAllItems:
119 push cx
120
121 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
122 mov ax, [bp+MENU.wFirstVisibleItem]
[369]123ALIGN MENU_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]143ALIGN MENU_JUMP_ALIGN
[41]144MenuText_RefreshItemFromAX:
145 push cx
[67]146 push ax
[41]147
[67]148 xchg cx, ax
[41]149 call MenuScrollbars_IsItemInCXonVisiblePage
150 jnc SHORT .InvalidItem
[52]151 call MenuText_AdjustDisplayContextForDrawingItemFromCX
[67]152 call ClearPreviousItem
[41]153 call MenuEvent_RefreshItemFromCX
[67]154 call DrawScrollbarCharacterForItemInCXifNecessary
[41]155.InvalidItem:
[67]156 pop ax
[41]157 pop cx
158 ret
159
160;--------------------------------------------------------------------
[52]161; MenuText_AdjustDisplayContextForDrawingItemFromCX
[41]162; Parameters
[52]163; CX: Item to refresh
[41]164; SS:BP: Ptr to MENU
165; Returns:
[52]166; Nothing
[41]167; Corrupts registers:
[52]168; AX, BX, DX, SI, DI
[41]169;--------------------------------------------------------------------
[369]170ALIGN MENU_JUMP_ALIGN
[52]171MenuText_AdjustDisplayContextForDrawingItemFromCX:
172 mov ax, cx
173 call GetItemTextAttributeTypeToSIforItemInCX
[41]174 call MenuLocation_GetTextCoordinatesToAXforItemInAX
[52]175 mov dx, MenuCharOut_MenuTeletypeOutput
[133]176 ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
[52]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;--------------------------------------------------------------------
[369]190ALIGN MENU_JUMP_ALIGN
[52]191AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
[41]192 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
193
[52]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
[41]202;--------------------------------------------------------------------
[67]203; ClearPreviousItem
204; Parameters
205; SS:BP: Ptr to MENU
206; Returns:
207; Nothing
208; Corrupts registers:
209; AX, BX, DX, DI
210;--------------------------------------------------------------------
[369]211ALIGN MENU_JUMP_ALIGN
[67]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;--------------------------------------------------------------------
[52]227; GetItemTextAttributeTypeToSIforItemInCX
[41]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;--------------------------------------------------------------------
[369]236ALIGN MENU_JUMP_ALIGN
[52]237GetItemTextAttributeTypeToSIforItemInCX:
[41]238 mov si, ATTRIBUTE_CHARS.cItem
239 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
240 jnz SHORT .ReturnAttributeTypeInSI
[52]241
242 cmp cx, [bp+MENUINIT.wHighlightedItem]
[41]243 jne SHORT .ReturnAttributeTypeInSI
244 sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
[369]245ALIGN MENU_JUMP_ALIGN, ret
[41]246.ReturnAttributeTypeInSI:
247 ret
248
249
250;--------------------------------------------------------------------
[67]251; DrawScrollbarCharacterForItemInCXifNecessary
[41]252; Parameters
253; CX: Item to refresh
254; SS:BP: Ptr to MENU
255; Returns:
256; Nothing
257; Corrupts registers:
[67]258; AX, CX, BX, DX, SI, DI
[41]259;--------------------------------------------------------------------
[369]260ALIGN MENU_JUMP_ALIGN
[67]261DrawScrollbarCharacterForItemInCXifNecessary:
[41]262 call MenuScrollbars_AreScrollbarsNeeded
263 jc SHORT .DrawScrollbarCharacter
264 ret
265
[369]266ALIGN MENU_JUMP_ALIGN
[41]267.DrawScrollbarCharacter:
[48]268 call MenuBorders_AdjustDisplayContextForDrawingBorders
[41]269 mov ax, cx
[104]270
271 call MenuLocation_GetTextCoordinatesToAXforItemInAX
272 add al, [bp+MENUINIT.bWidth]
273 sub al, MENU_TEXT_COLUMN_OFFSET*2
[41]274 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
275
276 mov di, cx
277 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
278 call MenuScrollbars_GetScrollCharacterToALForLineInDI
[67]279 jmp MenuBorders_PrintSingleBorderCharacterFromAL
Note: See TracBrowser for help on using the repository browser.