source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm@ 372

Last change on this file since 372 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.0 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for drawing scroll bars over menu borders.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; MenuScrollbars_AreScrollbarsNeeded
9; Parameters
10; SS:BP: Ptr to MENU
11; Returns:
12; CF: Set if scroll bars are needed
13; Cleared if no scroll bars needed
14; Corrupts registers:
[67]15; AX
[41]16;--------------------------------------------------------------------
[369]17ALIGN MENU_JUMP_ALIGN
[41]18MenuScrollbars_AreScrollbarsNeeded:
[67]19 xchg ax, cx
[41]20 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
21 cmp cx, [bp+MENUINIT.wItems] ; Set CF if max visible < total items
[67]22 xchg cx, ax
[41]23 ret
24
25
26;--------------------------------------------------------------------
27; MenuScrollbars_GetScrollCharacterToALForLineInDI
28; Parameters
29; DI: Index of item line to draw
30; SS:BP: Ptr to MENU
31; Returns:
32; AL: Scroll track or thumb character
33; Corrupts registers:
34; AH, CX, DX
35;--------------------------------------------------------------------
[369]36ALIGN MENU_JUMP_ALIGN
[41]37MenuScrollbars_GetScrollCharacterToALForLineInDI:
38 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
[181]39 ; Get first thumb line to AX
40 mov ax, [bp+MENU.wFirstVisibleItem]
41 call .CalculateFirstOrLastThumbLineToAX
42
[41]43 cmp di, ax ; Before first thumb line?
44 jb SHORT .ReturnTrackCharacter
45 call .GetLastThumbLineToAX
[181]46 cmp ax, di ; After last thumb line?
[369]47ALIGN MENU_JUMP_ALIGN
[41]48.ReturnTrackCharacter:
49 mov al, SCROLL_TRACK_CHARACTER
[181]50 jb SHORT .Return
51 mov al, SCROLL_THUMB_CHARACTER
[369]52ALIGN MENU_JUMP_ALIGN, ret
[181]53.Return:
[41]54 ret
55
56;--------------------------------------------------------------------
57; .GetLastThumbLineToAX
58; Parameters
59; CX: Max visible items on page
60; SS:BP: Ptr to MENU
61; Returns:
62; AX: Item line for last thumb character
63; Corrupts registers:
64; CX, DX
[133]65;--------------------------------------------------------------------
[369]66ALIGN MENU_JUMP_ALIGN
[41]67.GetLastThumbLineToAX:
68 call MenuScrollbars_GetLastVisibleItemOnPageToAX
[181]69 ; Fall to .CalculateFirstOrLastThumbLineToAX
[41]70
71;--------------------------------------------------------------------
[181]72; .CalculateFirstOrLastThumbLineToAX
[41]73; Parameters
[181]74; AX: Index of first or last visible item on page
[41]75; CX: Max visible items on page
76; SS:BP: Ptr to MENU
77; Returns:
78; AX: Item line for first thumb character
79; Corrupts registers:
80; CX, DX
81;--------------------------------------------------------------------
[369]82ALIGN MENU_JUMP_ALIGN
[41]83.CalculateFirstOrLastThumbLineToAX:
84 mul cx
85 div WORD [bp+MENUINIT.wItems]
86 ret ; (Visible items on page * First visible item on page) / total items
87
88
89;--------------------------------------------------------------------
90; MenuScrollbars_MoveHighlightedItemByAX
91; Parameters
92; AX: Signed offset to new item to be highlighted
93; SS:BP: Ptr to MENU
94; Returns:
95; Nothing
96; Corrupts registers:
97; AX, BX, CX, DX, SI, DI
98;--------------------------------------------------------------------
[369]99ALIGN MENU_JUMP_ALIGN
[41]100MenuScrollbars_MoveHighlightedItemByAX:
[52]101 mov cx, [bp+MENUINIT.wHighlightedItem]
[41]102 add cx, ax
[181]103 ; Fall to .RotateItemInCX
104
105;--------------------------------------------------------------------
106; .RotateItemInCX
107; Parameters
108; CX: Possibly under of overflown item to be rotated
109; SS:BP: Ptr to MENU
110; Returns:
111; CX: Valid item index
112; Corrupts registers:
113; DX
114;--------------------------------------------------------------------
115;.RotateItemInCX:
116 mov dx, [bp+MENUINIT.wItems]
117 test cx, cx
118 js SHORT .RotateNegativeItemInCX
119 sub cx, dx
120 jae SHORT .ScrollPageForNewItemInCX
121
[369]122ALIGN MENU_JUMP_ALIGN
[181]123.RotateNegativeItemInCX:
124 add cx, dx
[41]125 ; Fall to .ScrollPageForNewItemInCX
126
127;--------------------------------------------------------------------
128; .ScrollPageForNewItemInCX
129; Parameters
130; CX: New item to be highlighted
131; SS:BP: Ptr to MENU
132; Returns:
133; Nothing
134; Corrupts registers:
135; AX, BX, CX, DX, SI, DI
136;--------------------------------------------------------------------
[369]137ALIGN MENU_JUMP_ALIGN
[41]138.ScrollPageForNewItemInCX:
139 call MenuScrollbars_IsItemInCXonVisiblePage
140 jc SHORT .HighlightNewItemOnCX
141
142 mov dx, [bp+MENU.wFirstVisibleItem]
[52]143 sub dx, [bp+MENUINIT.wHighlightedItem]
[41]144
[181]145 ; Get MaxFirstVisibleItem to AX
[41]146 push cx
147 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
148 mov ax, [bp+MENUINIT.wItems]
149 sub ax, cx
150 pop cx
151
[181]152 add dx, cx
153 jns .DXisPositive
154 cwd ; This won't work if MaxFirstVisibleItem > 32767
155
[369]156ALIGN MENU_JUMP_ALIGN
[181]157.DXisPositive:
158 cmp ax, dx
159 jb .AXisLessThanDX
160 xchg dx, ax
[41]161
[369]162ALIGN MENU_JUMP_ALIGN
[181]163.AXisLessThanDX:
164 mov [bp+MENU.wFirstVisibleItem], ax
165 call MenuText_RefreshAllItems
[41]166
[369]167ALIGN MENU_JUMP_ALIGN
[181]168.HighlightNewItemOnCX:
169 jmp MenuEvent_HighlightItemFromCX
[41]170
171
172;--------------------------------------------------------------------
[105]173; MenuScrollbars_IsItemInCXonVisiblePage
[41]174; Parameters
175; CX: Item whose visibility is to be checked
176; SS:BP: Ptr to MENU
177; Returns:
178; CF: Set if item is on visible page
179; Cleared if item is not on visible page
180; Corrupts registers:
181; AX
182;--------------------------------------------------------------------
[369]183ALIGN MENU_JUMP_ALIGN
[41]184MenuScrollbars_IsItemInCXonVisiblePage:
[133]185 cmp [bp+MENU.wFirstVisibleItem], cx
186 ja SHORT .ItemIsNotVisible
[41]187
188 call MenuScrollbars_GetLastVisibleItemOnPageToAX
189 cmp cx, ax
190 ja SHORT .ItemIsNotVisible
191 stc ; Item is visible
[369]192ALIGN MENU_JUMP_ALIGN, ret
[41]193.ItemIsNotVisible:
194 ret
195
196
197;--------------------------------------------------------------------
[105]198; MenuScrollbars_GetLastVisibleItemOnPageToAX
[41]199; Parameters
200; SS:BP: Ptr to MENU
201; Returns:
202; AX: Index of last visible item on page
203; Corrupts registers:
204; Nothing
205;--------------------------------------------------------------------
[369]206ALIGN MENU_JUMP_ALIGN
[41]207MenuScrollbars_GetLastVisibleItemOnPageToAX:
[181]208 xchg cx, ax
[41]209 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
210 xchg ax, cx
211 dec ax
212 add ax, [bp+MENU.wFirstVisibleItem]
213 ret
214
215
216;--------------------------------------------------------------------
217; MenuScrollbars_GetActualVisibleItemsOnPageToCX
218; Parameters
219; SS:BP: Ptr to MENU
220; Returns:
221; CX: Currently visible items
222; Corrupts registers:
223; Nothing
224;--------------------------------------------------------------------
[369]225ALIGN MENU_JUMP_ALIGN
[41]226MenuScrollbars_GetActualVisibleItemsOnPageToCX:
227 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
[181]228 cmp cx, [bp+MENUINIT.wItems]
229 jb SHORT .Return
230 mov cx, [bp+MENUINIT.wItems]
[369]231ALIGN MENU_JUMP_ALIGN, ret
[181]232.Return:
[41]233 ret
234
235
236;--------------------------------------------------------------------
237; MenuScrollbars_GetMaxVisibleItemsOnPageToCX
238; Parameters
239; SS:BP: Ptr to MENU
240; Returns:
241; CX: Maximum number of visible items
242; Corrupts registers:
243; Nothing
244;--------------------------------------------------------------------
[369]245ALIGN MENU_JUMP_ALIGN
[41]246MenuScrollbars_GetMaxVisibleItemsOnPageToCX:
[293]247 eMOVZX cx, [bp+MENUINIT.bHeight]
[41]248 sub cl, [bp+MENUINIT.bTitleLines]
249 sub cl, [bp+MENUINIT.bInfoLines]
250 sub cl, MENU_VERTICAL_BORDER_LINES
251 ret
Note: See TracBrowser for help on using the repository browser.