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

Last change on this file since 616 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
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_XUB OR EXCLUDE_FROM_XTIDECFG
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 inc si ; SI = 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.