[41] | 1 | ; Project name : Assembly Library
|
---|
| 2 | ; Description : Functions for drawing scroll bars over menu borders.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
| 17 | ALIGN JUMP_ALIGN
|
---|
| 18 | MenuScrollbars_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 | ;--------------------------------------------------------------------
|
---|
| 36 | ALIGN JUMP_ALIGN
|
---|
| 37 | MenuScrollbars_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?
|
---|
[41] | 47 | ALIGN JUMP_ALIGN
|
---|
| 48 | .ReturnTrackCharacter:
|
---|
| 49 | mov al, SCROLL_TRACK_CHARACTER
|
---|
[181] | 50 | jb SHORT .Return
|
---|
| 51 | mov al, SCROLL_THUMB_CHARACTER
|
---|
| 52 | ALIGN JUMP_ALIGN, ret
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
[41] | 66 | ALIGN JUMP_ALIGN
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
| 82 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
| 99 | ALIGN JUMP_ALIGN
|
---|
| 100 | MenuScrollbars_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 |
|
---|
| 122 | ALIGN JUMP_ALIGN
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
[181] | 137 | ALIGN 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 |
|
---|
[41] | 156 | ALIGN JUMP_ALIGN
|
---|
[181] | 157 | .DXisPositive:
|
---|
| 158 | cmp ax, dx
|
---|
| 159 | jb .AXisLessThanDX
|
---|
| 160 | xchg dx, ax
|
---|
[41] | 161 |
|
---|
| 162 | ALIGN JUMP_ALIGN
|
---|
[181] | 163 | .AXisLessThanDX:
|
---|
| 164 | mov [bp+MENU.wFirstVisibleItem], ax
|
---|
| 165 | call MenuText_RefreshAllItems
|
---|
[41] | 166 |
|
---|
| 167 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
| 183 | ALIGN JUMP_ALIGN
|
---|
| 184 | MenuScrollbars_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
|
---|
[133] | 192 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
| 206 | ALIGN JUMP_ALIGN
|
---|
| 207 | MenuScrollbars_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 | ;--------------------------------------------------------------------
|
---|
| 225 | ALIGN JUMP_ALIGN
|
---|
| 226 | MenuScrollbars_GetActualVisibleItemsOnPageToCX:
|
---|
| 227 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
[181] | 228 | cmp cx, [bp+MENUINIT.wItems]
|
---|
| 229 | jb SHORT .Return
|
---|
| 230 | mov cx, [bp+MENUINIT.wItems]
|
---|
| 231 | ALIGN JUMP_ALIGN, ret
|
---|
| 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 | ;--------------------------------------------------------------------
|
---|
| 245 | ALIGN JUMP_ALIGN
|
---|
| 246 | MenuScrollbars_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
|
---|