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

Last change on this file since 582 was 568, checked in by krille_n_@…, 10 years ago

Changes:

  • SerDrive: Using named pipe mode (serdrive -p) now works under Windows XP/2000/Server 2003.
  • checksum.pl: Added a compatibility fix for 3Com 3C503 cards.
  • XTIDECFG will now scan every possible segment address to find and load the BIOS and/or its settings from EEPROM. This should simplify things for people using combined option ROMs.
  • Fixed a bug from r521 in BootSector.asm where the BIOS would not display a timeout error if it failed to load the boot sector from harddrive.
  • Fixed a bug from r541 in CompatibleDPT.asm where CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI would generate an invalid checksum in the DPTE.
  • Optimizations and other fixes.
File size: 7.3 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for drawing scroll bars over menu borders.
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; MenuScrollbars_AreScrollbarsNeeded
26; Parameters
27; SS:BP: Ptr to MENU
28; Returns:
29; CF: Set if scroll bars are needed
30; Cleared if no scroll bars needed
31; Corrupts registers:
32; AX
33;--------------------------------------------------------------------
34ALIGN MENU_JUMP_ALIGN
35MenuScrollbars_AreScrollbarsNeeded:
36 xchg ax, cx
37 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
38 cmp cx, [bp+MENUINIT.wItems] ; Set CF if max visible < total items
39 xchg cx, ax
40 ret
41
42
43;--------------------------------------------------------------------
44; MenuScrollbars_GetScrollCharacterToALForLineInDI
45; Parameters
46; DI: Index of item line to draw
47; SS:BP: Ptr to MENU
48; Returns:
49; AL: Scroll track or thumb character
50; Corrupts registers:
51; AH, CX, DX
52;--------------------------------------------------------------------
53ALIGN MENU_JUMP_ALIGN
54MenuScrollbars_GetScrollCharacterToALForLineInDI:
55 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
56 ; Get first thumb line to AX
57 mov ax, [bp+MENU.wFirstVisibleItem]
58 call .CalculateFirstOrLastThumbLineToAX
59
60 cmp di, ax ; Before first thumb line?
61 jb SHORT .ReturnTrackCharacter
62 call .GetLastThumbLineToAX
63 cmp ax, di ; After last thumb line?
64ALIGN MENU_JUMP_ALIGN
65.ReturnTrackCharacter:
66 mov al, SCROLL_TRACK_CHARACTER
67 jb SHORT .Return
68 mov al, SCROLL_THUMB_CHARACTER
69ALIGN MENU_JUMP_ALIGN, ret
70.Return:
71 ret
72
73;--------------------------------------------------------------------
74; .GetLastThumbLineToAX
75; Parameters
76; CX: Max visible items on page
77; SS:BP: Ptr to MENU
78; Returns:
79; AX: Item line for last thumb character
80; Corrupts registers:
81; DX
82;--------------------------------------------------------------------
83ALIGN MENU_JUMP_ALIGN
84.GetLastThumbLineToAX:
85 call MenuScrollbars_GetLastVisibleItemOnPageToAX
86 ; Fall to .CalculateFirstOrLastThumbLineToAX
87
88;--------------------------------------------------------------------
89; .CalculateFirstOrLastThumbLineToAX
90; Parameters
91; AX: Index of first or last visible item on page
92; CX: Max visible items on page
93; SS:BP: Ptr to MENU
94; Returns:
95; AX: Item line for first thumb character
96; Corrupts registers:
97; DX
98;--------------------------------------------------------------------
99ALIGN MENU_JUMP_ALIGN
100.CalculateFirstOrLastThumbLineToAX:
101 mul cx
102 div WORD [bp+MENUINIT.wItems]
103 ret ; (Visible items on page * First visible item on page) / total items
104
105
106;--------------------------------------------------------------------
107; MenuScrollbars_MoveHighlightedItemByAX
108; Parameters
109; AX: Signed offset to new item to be highlighted
110; SS:BP: Ptr to MENU
111; Returns:
112; Nothing
113; Corrupts registers:
114; AX, BX, CX, DX, SI, DI
115;--------------------------------------------------------------------
116ALIGN MENU_JUMP_ALIGN
117MenuScrollbars_MoveHighlightedItemByAX:
118 mov dx, [bp+MENUINIT.wItems]
119 add ax, [bp+MENUINIT.wHighlightedItem]
120 xchg cx, ax
121 js SHORT .RotateNegativeItemInCX
122 sub cx, dx
123 jae SHORT .ScrollPageForNewItemInCX
124
125ALIGN MENU_JUMP_ALIGN
126.RotateNegativeItemInCX:
127 add cx, dx
128 ; Fall to .ScrollPageForNewItemInCX
129
130;--------------------------------------------------------------------
131; .ScrollPageForNewItemInCX
132; Parameters
133; CX: New item to be highlighted
134; SS:BP: Ptr to MENU
135; Returns:
136; Nothing
137; Corrupts registers:
138; AX, BX, CX, DX, SI, DI
139;--------------------------------------------------------------------
140ALIGN MENU_JUMP_ALIGN
141.ScrollPageForNewItemInCX:
142 call MenuScrollbars_IsItemInCXonVisiblePage
143 jc SHORT .HighlightNewItemOnCX
144
145 mov dx, [bp+MENU.wFirstVisibleItem]
146 sub dx, [bp+MENUINIT.wHighlightedItem]
147
148 ; Get MaxFirstVisibleItem to AX
149 push cx
150 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
151 mov ax, [bp+MENUINIT.wItems]
152 sub ax, cx
153 pop cx
154
155 add dx, cx
156 jns .DXisPositive
157 cwd ; This won't work if MaxFirstVisibleItem > 32767
158
159ALIGN MENU_JUMP_ALIGN
160.DXisPositive:
161 cmp ax, dx
162 jb .AXisLessThanDX
163 xchg dx, ax
164
165ALIGN MENU_JUMP_ALIGN
166.AXisLessThanDX:
167 mov [bp+MENU.wFirstVisibleItem], ax
168 call MenuText_RefreshAllItems
169
170ALIGN MENU_JUMP_ALIGN
171.HighlightNewItemOnCX:
172 jmp MenuEvent_HighlightItemFromCX
173
174
175;--------------------------------------------------------------------
176; MenuScrollbars_IsItemInCXonVisiblePage
177; Parameters
178; CX: Item whose visibility is to be checked
179; SS:BP: Ptr to MENU
180; Returns:
181; CF: Set if item is on visible page
182; Cleared if item is not on visible page
183; Corrupts registers:
184; AX
185;--------------------------------------------------------------------
186ALIGN MENU_JUMP_ALIGN
187MenuScrollbars_IsItemInCXonVisiblePage:
188 cmp [bp+MENU.wFirstVisibleItem], cx
189 ja SHORT .ItemIsNotVisible
190
191 call MenuScrollbars_GetLastVisibleItemOnPageToAX
192 cmp cx, ax
193 ja SHORT .ItemIsNotVisible
194 stc ; Item is visible
195ALIGN MENU_JUMP_ALIGN, ret
196.ItemIsNotVisible:
197 ret
198
199
200;--------------------------------------------------------------------
201; MenuScrollbars_GetLastVisibleItemOnPageToAX
202; Parameters
203; SS:BP: Ptr to MENU
204; Returns:
205; AX: Index of last visible item on page
206; Corrupts registers:
207; Nothing
208;--------------------------------------------------------------------
209ALIGN MENU_JUMP_ALIGN
210MenuScrollbars_GetLastVisibleItemOnPageToAX:
211 xchg cx, ax
212 call MenuScrollbars_GetActualVisibleItemsOnPageToCX
213 xchg ax, cx
214 dec ax
215 add ax, [bp+MENU.wFirstVisibleItem]
216 ret
217
218
219;--------------------------------------------------------------------
220; MenuScrollbars_GetActualVisibleItemsOnPageToCX
221; Parameters
222; SS:BP: Ptr to MENU
223; Returns:
224; CX: Currently visible items
225; Corrupts registers:
226; Nothing
227;--------------------------------------------------------------------
228ALIGN MENU_JUMP_ALIGN
229MenuScrollbars_GetActualVisibleItemsOnPageToCX:
230 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
231 cmp cx, [bp+MENUINIT.wItems]
232 jb SHORT .Return
233 mov cx, [bp+MENUINIT.wItems]
234ALIGN MENU_JUMP_ALIGN, ret
235.Return:
236 ret
237
238
239;--------------------------------------------------------------------
240; MenuScrollbars_GetMaxVisibleItemsOnPageToCX
241; Parameters
242; SS:BP: Ptr to MENU
243; Returns:
244; CX: Maximum number of visible items
245; Corrupts registers:
246; Nothing
247;--------------------------------------------------------------------
248ALIGN MENU_JUMP_ALIGN
249MenuScrollbars_GetMaxVisibleItemsOnPageToCX:
250 eMOVZX cx, [bp+MENUINIT.bHeight]
251 sub cl, [bp+MENUINIT.bTitleLines]
252 sub cl, [bp+MENUINIT.bInfoLines]
253 sub cl, MENU_VERTICAL_BORDER_LINES
254 ret
Note: See TracBrowser for help on using the repository browser.