[41] | 1 | ; Project name : Assembly Library
|
---|
| 2 | ; Description : Functions for drawing scroll bars over menu borders.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[491] | 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.
|
---|
[491] | 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
|
---|
[491] | 16 | ; GNU General Public License for more details.
|
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
| 18 | ;
|
---|
| 19 |
|
---|
[491] | 20 |
|
---|
[41] | 21 | ; Section containing code
|
---|
| 22 | SECTION .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:
|
---|
[67] | 32 | ; AX
|
---|
[41] | 33 | ;--------------------------------------------------------------------
|
---|
[369] | 34 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 35 | MenuScrollbars_AreScrollbarsNeeded:
|
---|
[67] | 36 | xchg ax, cx
|
---|
[41] | 37 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
| 38 | cmp cx, [bp+MENUINIT.wItems] ; Set CF if max visible < total items
|
---|
[67] | 39 | xchg cx, ax
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[369] | 53 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 54 | MenuScrollbars_GetScrollCharacterToALForLineInDI:
|
---|
| 55 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
[181] | 56 | ; Get first thumb line to AX
|
---|
| 57 | mov ax, [bp+MENU.wFirstVisibleItem]
|
---|
| 58 | call .CalculateFirstOrLastThumbLineToAX
|
---|
| 59 |
|
---|
[41] | 60 | cmp di, ax ; Before first thumb line?
|
---|
| 61 | jb SHORT .ReturnTrackCharacter
|
---|
| 62 | call .GetLastThumbLineToAX
|
---|
[181] | 63 | cmp ax, di ; After last thumb line?
|
---|
[369] | 64 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 65 | .ReturnTrackCharacter:
|
---|
| 66 | mov al, SCROLL_TRACK_CHARACTER
|
---|
[181] | 67 | jb SHORT .Return
|
---|
| 68 | mov al, SCROLL_THUMB_CHARACTER
|
---|
[369] | 69 | ALIGN MENU_JUMP_ALIGN, ret
|
---|
[181] | 70 | .Return:
|
---|
[41] | 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:
|
---|
[491] | 81 | ; DX
|
---|
[133] | 82 | ;--------------------------------------------------------------------
|
---|
[369] | 83 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 84 | .GetLastThumbLineToAX:
|
---|
| 85 | call MenuScrollbars_GetLastVisibleItemOnPageToAX
|
---|
[181] | 86 | ; Fall to .CalculateFirstOrLastThumbLineToAX
|
---|
[41] | 87 |
|
---|
| 88 | ;--------------------------------------------------------------------
|
---|
[181] | 89 | ; .CalculateFirstOrLastThumbLineToAX
|
---|
[41] | 90 | ; Parameters
|
---|
[181] | 91 | ; AX: Index of first or last visible item on page
|
---|
[41] | 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:
|
---|
[491] | 97 | ; DX
|
---|
[41] | 98 | ;--------------------------------------------------------------------
|
---|
[369] | 99 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[369] | 116 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 117 | MenuScrollbars_MoveHighlightedItemByAX:
|
---|
[181] | 118 | mov dx, [bp+MENUINIT.wItems]
|
---|
[568] | 119 | add ax, [bp+MENUINIT.wHighlightedItem]
|
---|
| 120 | xchg cx, ax
|
---|
[181] | 121 | js SHORT .RotateNegativeItemInCX
|
---|
| 122 | sub cx, dx
|
---|
| 123 | jae SHORT .ScrollPageForNewItemInCX
|
---|
| 124 |
|
---|
[369] | 125 | ALIGN MENU_JUMP_ALIGN
|
---|
[181] | 126 | .RotateNegativeItemInCX:
|
---|
| 127 | add cx, dx
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[369] | 140 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 141 | .ScrollPageForNewItemInCX:
|
---|
| 142 | call MenuScrollbars_IsItemInCXonVisiblePage
|
---|
| 143 | jc SHORT .HighlightNewItemOnCX
|
---|
| 144 |
|
---|
| 145 | mov dx, [bp+MENU.wFirstVisibleItem]
|
---|
[52] | 146 | sub dx, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 147 |
|
---|
[181] | 148 | ; Get MaxFirstVisibleItem to AX
|
---|
[41] | 149 | push cx
|
---|
| 150 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
| 151 | mov ax, [bp+MENUINIT.wItems]
|
---|
| 152 | sub ax, cx
|
---|
| 153 | pop cx
|
---|
| 154 |
|
---|
[181] | 155 | add dx, cx
|
---|
| 156 | jns .DXisPositive
|
---|
| 157 | cwd ; This won't work if MaxFirstVisibleItem > 32767
|
---|
| 158 |
|
---|
[369] | 159 | ALIGN MENU_JUMP_ALIGN
|
---|
[181] | 160 | .DXisPositive:
|
---|
| 161 | cmp ax, dx
|
---|
| 162 | jb .AXisLessThanDX
|
---|
| 163 | xchg dx, ax
|
---|
[41] | 164 |
|
---|
[369] | 165 | ALIGN MENU_JUMP_ALIGN
|
---|
[181] | 166 | .AXisLessThanDX:
|
---|
| 167 | mov [bp+MENU.wFirstVisibleItem], ax
|
---|
| 168 | call MenuText_RefreshAllItems
|
---|
[41] | 169 |
|
---|
[369] | 170 | ALIGN MENU_JUMP_ALIGN
|
---|
[181] | 171 | .HighlightNewItemOnCX:
|
---|
| 172 | jmp MenuEvent_HighlightItemFromCX
|
---|
[41] | 173 |
|
---|
| 174 |
|
---|
| 175 | ;--------------------------------------------------------------------
|
---|
[105] | 176 | ; MenuScrollbars_IsItemInCXonVisiblePage
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[369] | 186 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 187 | MenuScrollbars_IsItemInCXonVisiblePage:
|
---|
[133] | 188 | cmp [bp+MENU.wFirstVisibleItem], cx
|
---|
| 189 | ja SHORT .ItemIsNotVisible
|
---|
[41] | 190 |
|
---|
| 191 | call MenuScrollbars_GetLastVisibleItemOnPageToAX
|
---|
| 192 | cmp cx, ax
|
---|
| 193 | ja SHORT .ItemIsNotVisible
|
---|
| 194 | stc ; Item is visible
|
---|
[369] | 195 | ALIGN MENU_JUMP_ALIGN, ret
|
---|
[41] | 196 | .ItemIsNotVisible:
|
---|
| 197 | ret
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | ;--------------------------------------------------------------------
|
---|
[105] | 201 | ; MenuScrollbars_GetLastVisibleItemOnPageToAX
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[369] | 209 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 210 | MenuScrollbars_GetLastVisibleItemOnPageToAX:
|
---|
[181] | 211 | xchg cx, ax
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[369] | 228 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 229 | MenuScrollbars_GetActualVisibleItemsOnPageToCX:
|
---|
| 230 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
[181] | 231 | cmp cx, [bp+MENUINIT.wItems]
|
---|
| 232 | jb SHORT .Return
|
---|
| 233 | mov cx, [bp+MENUINIT.wItems]
|
---|
[369] | 234 | ALIGN MENU_JUMP_ALIGN, ret
|
---|
[181] | 235 | .Return:
|
---|
[41] | 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 | ;--------------------------------------------------------------------
|
---|
[369] | 248 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 249 | MenuScrollbars_GetMaxVisibleItemsOnPageToCX:
|
---|
[583] | 250 | mov cx, -MENU_VERTICAL_BORDER_LINES & 0FFh
|
---|
| 251 | add cl, [bp+MENUINIT.bHeight]
|
---|
[41] | 252 | sub cl, [bp+MENUINIT.bTitleLines]
|
---|
| 253 | sub cl, [bp+MENUINIT.bInfoLines]
|
---|
| 254 | ret
|
---|