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

Last change on this file since 607 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
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for drawing menu texts by the user.
3
[376]4;
[505]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[505]12;
[376]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
[505]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
[505]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;--------------------------------------------------------------------
[592]34%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG
[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
[505]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
[505]55 JMP_DISPLAY_LIBRARY PopDisplayContext
[48]56
57
58;--------------------------------------------------------------------
[41]59; MenuText_RefreshTitle
60; MenuText_RefreshInformation
61; Parameters
62; SS:BP: Ptr to MENU
63; Returns:
64; Nothing
65; Corrupts registers:
[48]66; AX, BX, CX, DX, SI, DI
[41]67;--------------------------------------------------------------------
[369]68ALIGN MENU_JUMP_ALIGN
[41]69MenuText_RefreshTitle:
70 cmp BYTE [bp+MENUINIT.bTitleLines], 0
71 jz SHORT NothingToRefresh
[48]72 call PrepareToDrawTitleArea
[41]73 jmp MenuEvent_RefreshTitle
74
[369]75ALIGN MENU_JUMP_ALIGN
[41]76MenuText_RefreshInformation:
77 cmp BYTE [bp+MENUINIT.bInfoLines], 0
78 jz SHORT NothingToRefresh
[54]79 call MenuText_PrepareToDrawInformationArea
[48]80 jmp MenuEvent_RefreshInformation
[41]81
[48]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;--------------------------------------------------------------------
[369]92ALIGN MENU_JUMP_ALIGN
[48]93PrepareToDrawTitleArea:
94 mov si, ATTRIBUTE_CHARS.cTitle
95 call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
[52]96 jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
[48]97
[369]98ALIGN MENU_JUMP_ALIGN
[54]99MenuText_PrepareToDrawInformationArea:
[41]100 mov si, ATTRIBUTE_CHARS.cInformation
101 call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
[52]102FinishPreparationsToDrawTitleOrInformationArea:
103 mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
104 jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
[41]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;--------------------------------------------------------------------
[369]116ALIGN MENU_JUMP_ALIGN
[41]117MenuText_RefreshAllItems:
118 push cx
119
120 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
121 mov ax, [bp+MENU.wFirstVisibleItem]
[369]122ALIGN MENU_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]142ALIGN MENU_JUMP_ALIGN
[41]143MenuText_RefreshItemFromAX:
144 push cx
[67]145 push ax
[41]146
[67]147 xchg cx, ax
[41]148 call MenuScrollbars_IsItemInCXonVisiblePage
149 jnc SHORT .InvalidItem
[52]150 call MenuText_AdjustDisplayContextForDrawingItemFromCX
[67]151 call ClearPreviousItem
[41]152 call MenuEvent_RefreshItemFromCX
[67]153 call DrawScrollbarCharacterForItemInCXifNecessary
[41]154.InvalidItem:
[67]155 pop ax
[41]156 pop cx
157 ret
158
159;--------------------------------------------------------------------
[52]160; MenuText_AdjustDisplayContextForDrawingItemFromCX
[41]161; Parameters
[52]162; CX: Item to refresh
[41]163; SS:BP: Ptr to MENU
164; Returns:
[52]165; Nothing
[41]166; Corrupts registers:
[52]167; AX, BX, DX, SI, DI
[41]168;--------------------------------------------------------------------
[369]169ALIGN MENU_JUMP_ALIGN
[52]170MenuText_AdjustDisplayContextForDrawingItemFromCX:
171 mov ax, cx
172 call GetItemTextAttributeTypeToSIforItemInCX
[41]173 call MenuLocation_GetTextCoordinatesToAXforItemInAX
[52]174 mov dx, MenuCharOut_MenuTeletypeOutput
[133]175 ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
[52]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;--------------------------------------------------------------------
[369]189ALIGN MENU_JUMP_ALIGN
[52]190AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
[41]191 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
192
[52]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
[41]201;--------------------------------------------------------------------
[67]202; ClearPreviousItem
203; Parameters
204; SS:BP: Ptr to MENU
205; Returns:
206; Nothing
207; Corrupts registers:
208; AX, BX, DX, DI
209;--------------------------------------------------------------------
[369]210ALIGN MENU_JUMP_ALIGN
[67]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
[505]221 JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
[67]222
223
224;--------------------------------------------------------------------
[52]225; GetItemTextAttributeTypeToSIforItemInCX
[41]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;--------------------------------------------------------------------
[369]234ALIGN MENU_JUMP_ALIGN
[52]235GetItemTextAttributeTypeToSIforItemInCX:
[41]236 mov si, ATTRIBUTE_CHARS.cItem
237 test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
238 jnz SHORT .ReturnAttributeTypeInSI
[52]239
240 cmp cx, [bp+MENUINIT.wHighlightedItem]
[41]241 jne SHORT .ReturnAttributeTypeInSI
[583]242 inc si ; SI = ATTRIBUTE_CHARS.cHighlightedItem
[369]243ALIGN MENU_JUMP_ALIGN, ret
[41]244.ReturnAttributeTypeInSI:
245 ret
246
247
248;--------------------------------------------------------------------
[67]249; DrawScrollbarCharacterForItemInCXifNecessary
[41]250; Parameters
251; CX: Item to refresh
252; SS:BP: Ptr to MENU
253; Returns:
254; Nothing
255; Corrupts registers:
[67]256; AX, CX, BX, DX, SI, DI
[41]257;--------------------------------------------------------------------
[369]258ALIGN MENU_JUMP_ALIGN
[67]259DrawScrollbarCharacterForItemInCXifNecessary:
[41]260 call MenuScrollbars_AreScrollbarsNeeded
261 jc SHORT .DrawScrollbarCharacter
262 ret
263
[369]264ALIGN MENU_JUMP_ALIGN
[41]265.DrawScrollbarCharacter:
[48]266 call MenuBorders_AdjustDisplayContextForDrawingBorders
[41]267 mov ax, cx
[104]268
269 call MenuLocation_GetTextCoordinatesToAXforItemInAX
270 add al, [bp+MENUINIT.bWidth]
271 sub al, MENU_TEXT_COLUMN_OFFSET*2
[41]272 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
273
274 mov di, cx
275 sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
276 call MenuScrollbars_GetScrollCharacterToALForLineInDI
[67]277 jmp MenuBorders_PrintSingleBorderCharacterFromAL
Note: See TracBrowser for help on using the repository browser.