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

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

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

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