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

Last change on this file since 369 was 369, checked in by gregli@…, 12 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
Line 
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:
15;       AX
16;--------------------------------------------------------------------
17ALIGN MENU_JUMP_ALIGN
18MenuScrollbars_AreScrollbarsNeeded:
19    xchg    ax, cx
20    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
21    cmp     cx, [bp+MENUINIT.wItems]        ; Set CF if max visible < total items
22    xchg    cx, ax
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;--------------------------------------------------------------------
36ALIGN MENU_JUMP_ALIGN
37MenuScrollbars_GetScrollCharacterToALForLineInDI:
38    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
39    ; Get first thumb line to AX
40    mov     ax, [bp+MENU.wFirstVisibleItem]
41    call    .CalculateFirstOrLastThumbLineToAX
42
43    cmp     di, ax              ; Before first thumb line?
44    jb      SHORT .ReturnTrackCharacter
45    call    .GetLastThumbLineToAX
46    cmp     ax, di              ; After last thumb line?
47ALIGN MENU_JUMP_ALIGN
48.ReturnTrackCharacter:
49    mov     al, SCROLL_TRACK_CHARACTER
50    jb      SHORT .Return
51    mov     al, SCROLL_THUMB_CHARACTER
52ALIGN MENU_JUMP_ALIGN, ret
53.Return:
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
65;--------------------------------------------------------------------
66ALIGN MENU_JUMP_ALIGN
67.GetLastThumbLineToAX:
68    call    MenuScrollbars_GetLastVisibleItemOnPageToAX
69    ; Fall to .CalculateFirstOrLastThumbLineToAX
70
71;--------------------------------------------------------------------
72; .CalculateFirstOrLastThumbLineToAX
73;   Parameters
74;       AX:     Index of first or last visible item on page
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;--------------------------------------------------------------------
82ALIGN MENU_JUMP_ALIGN
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;--------------------------------------------------------------------
99ALIGN MENU_JUMP_ALIGN
100MenuScrollbars_MoveHighlightedItemByAX:
101    mov     cx, [bp+MENUINIT.wHighlightedItem]
102    add     cx, ax
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
122ALIGN MENU_JUMP_ALIGN
123.RotateNegativeItemInCX:
124    add     cx, dx
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;--------------------------------------------------------------------
137ALIGN MENU_JUMP_ALIGN
138.ScrollPageForNewItemInCX:
139    call    MenuScrollbars_IsItemInCXonVisiblePage
140    jc      SHORT .HighlightNewItemOnCX
141
142    mov     dx, [bp+MENU.wFirstVisibleItem]
143    sub     dx, [bp+MENUINIT.wHighlightedItem]
144
145    ; Get MaxFirstVisibleItem to AX
146    push    cx
147    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
148    mov     ax, [bp+MENUINIT.wItems]
149    sub     ax, cx
150    pop     cx
151
152    add     dx, cx
153    jns     .DXisPositive
154    cwd     ; This won't work if MaxFirstVisibleItem > 32767
155
156ALIGN MENU_JUMP_ALIGN
157.DXisPositive:
158    cmp     ax, dx
159    jb      .AXisLessThanDX
160    xchg    dx, ax
161
162ALIGN MENU_JUMP_ALIGN
163.AXisLessThanDX:
164    mov     [bp+MENU.wFirstVisibleItem], ax
165    call    MenuText_RefreshAllItems
166
167ALIGN MENU_JUMP_ALIGN
168.HighlightNewItemOnCX:
169    jmp     MenuEvent_HighlightItemFromCX
170
171
172;--------------------------------------------------------------------
173; MenuScrollbars_IsItemInCXonVisiblePage
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;--------------------------------------------------------------------
183ALIGN MENU_JUMP_ALIGN
184MenuScrollbars_IsItemInCXonVisiblePage:
185    cmp     [bp+MENU.wFirstVisibleItem], cx
186    ja      SHORT .ItemIsNotVisible
187
188    call    MenuScrollbars_GetLastVisibleItemOnPageToAX
189    cmp     cx, ax
190    ja      SHORT .ItemIsNotVisible
191    stc     ; Item is visible
192ALIGN MENU_JUMP_ALIGN, ret
193.ItemIsNotVisible:
194    ret
195
196
197;--------------------------------------------------------------------
198; MenuScrollbars_GetLastVisibleItemOnPageToAX
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;--------------------------------------------------------------------
206ALIGN MENU_JUMP_ALIGN
207MenuScrollbars_GetLastVisibleItemOnPageToAX:
208    xchg    cx, ax
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;--------------------------------------------------------------------
225ALIGN MENU_JUMP_ALIGN
226MenuScrollbars_GetActualVisibleItemsOnPageToCX:
227    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
228    cmp     cx, [bp+MENUINIT.wItems]
229    jb      SHORT .Return
230    mov     cx, [bp+MENUINIT.wItems]
231ALIGN MENU_JUMP_ALIGN, ret
232.Return:
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;--------------------------------------------------------------------
245ALIGN MENU_JUMP_ALIGN
246MenuScrollbars_GetMaxVisibleItemsOnPageToCX:
247    eMOVZX  cx, [bp+MENUINIT.bHeight]
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.