[41] | 1 | ; Project name : Assembly Library
|
---|
| 2 | ; Description : Functions for drawing menu texts by the user.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[505] | 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.
|
---|
[505] | 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
|
---|
[505] | 16 | ; GNU General Public License for more details.
|
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
| 18 | ;
|
---|
| 19 |
|
---|
[505] | 20 |
|
---|
[41] | 21 | ; Section containing code
|
---|
| 22 | SECTION .text
|
---|
| 23 |
|
---|
| 24 | ;--------------------------------------------------------------------
|
---|
[48] | 25 | ; MenuText_ClearTitleArea
|
---|
| 26 | ; MenuText_ClearInformationArea
|
---|
| 27 | ; Parameters
|
---|
| 28 | ; SS:BP: Ptr to MENU
|
---|
| 29 | ; Returns:
|
---|
| 30 | ; Nothing
|
---|
| 31 | ; Corrupts registers:
|
---|
| 32 | ; AX, BX, CX, DX, SI, DI
|
---|
| 33 | ;--------------------------------------------------------------------
|
---|
[194] | 34 | %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
|
---|
[369] | 35 | ALIGN MENU_JUMP_ALIGN
|
---|
[48] | 36 | MenuText_ClearTitleArea:
|
---|
[125] | 37 | CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
|
---|
[48] | 38 | call PrepareToDrawTitleArea
|
---|
| 39 | mov cl, [bp+MENUINIT.bTitleLines]
|
---|
[194] | 40 | jmp SHORT MenuText_ClearInformationArea.ClearCLlinesOfText
|
---|
| 41 | %endif
|
---|
[505] | 42 |
|
---|
[369] | 43 | ALIGN MENU_JUMP_ALIGN
|
---|
[48] | 44 | MenuText_ClearInformationArea:
|
---|
[125] | 45 | CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
|
---|
[54] | 46 | call MenuText_PrepareToDrawInformationArea
|
---|
[48] | 47 | mov cl, [bp+MENUINIT.bInfoLines]
|
---|
[194] | 48 | .ClearCLlinesOfText:
|
---|
[48] | 49 | mov al, [bp+MENUINIT.bWidth]
|
---|
[54] | 50 | sub al, MENU_HORIZONTAL_BORDER_LINES+(MENU_TEXT_COLUMN_OFFSET/2)
|
---|
[48] | 51 | mul cl
|
---|
| 52 | xchg cx, ax
|
---|
| 53 | mov al, ' '
|
---|
| 54 | CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
|
---|
[505] | 55 | JMP_DISPLAY_LIBRARY PopDisplayContext
|
---|
[48] | 56 |
|
---|
| 57 |
|
---|
| 58 | ;--------------------------------------------------------------------
|
---|
[41] | 59 | ; MenuText_RefreshTitle
|
---|
| 60 | ; MenuText_RefreshInformation
|
---|
| 61 | ; Parameters
|
---|
| 62 | ; SS:BP: Ptr to MENU
|
---|
| 63 | ; Returns:
|
---|
| 64 | ; Nothing
|
---|
| 65 | ; Corrupts registers:
|
---|
[48] | 66 | ; AX, BX, CX, DX, SI, DI
|
---|
[41] | 67 | ;--------------------------------------------------------------------
|
---|
[369] | 68 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 69 | MenuText_RefreshTitle:
|
---|
| 70 | cmp BYTE [bp+MENUINIT.bTitleLines], 0
|
---|
| 71 | jz SHORT NothingToRefresh
|
---|
[48] | 72 | call PrepareToDrawTitleArea
|
---|
[41] | 73 | jmp MenuEvent_RefreshTitle
|
---|
| 74 |
|
---|
[369] | 75 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 76 | MenuText_RefreshInformation:
|
---|
| 77 | cmp BYTE [bp+MENUINIT.bInfoLines], 0
|
---|
| 78 | jz SHORT NothingToRefresh
|
---|
[54] | 79 | call MenuText_PrepareToDrawInformationArea
|
---|
[48] | 80 | jmp MenuEvent_RefreshInformation
|
---|
[41] | 81 |
|
---|
[48] | 82 | ;--------------------------------------------------------------------
|
---|
| 83 | ; PrepareToDrawTitleArea
|
---|
| 84 | ; PrepareToDrawInformationArea
|
---|
| 85 | ; Parameters
|
---|
| 86 | ; SS:BP: Ptr to MENU
|
---|
| 87 | ; Returns:
|
---|
| 88 | ; Nothing
|
---|
| 89 | ; Corrupts registers:
|
---|
| 90 | ; AX, BX, DX, SI, DI
|
---|
| 91 | ;--------------------------------------------------------------------
|
---|
[369] | 92 | ALIGN MENU_JUMP_ALIGN
|
---|
[48] | 93 | PrepareToDrawTitleArea:
|
---|
| 94 | mov si, ATTRIBUTE_CHARS.cTitle
|
---|
| 95 | call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
|
---|
[52] | 96 | jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
|
---|
[48] | 97 |
|
---|
[369] | 98 | ALIGN MENU_JUMP_ALIGN
|
---|
[54] | 99 | MenuText_PrepareToDrawInformationArea:
|
---|
[41] | 100 | mov si, ATTRIBUTE_CHARS.cInformation
|
---|
| 101 | call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
|
---|
[52] | 102 | FinishPreparationsToDrawTitleOrInformationArea:
|
---|
| 103 | mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
|
---|
| 104 | jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
|
---|
[41] | 105 |
|
---|
| 106 |
|
---|
| 107 | ;--------------------------------------------------------------------
|
---|
| 108 | ; MenuText_RefreshAllItems
|
---|
| 109 | ; Parameters
|
---|
| 110 | ; SS:BP: Ptr to MENU
|
---|
| 111 | ; Returns:
|
---|
| 112 | ; Nothing
|
---|
| 113 | ; Corrupts registers:
|
---|
| 114 | ; AX, BX, DX, SI, DI
|
---|
| 115 | ;--------------------------------------------------------------------
|
---|
[369] | 116 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 117 | MenuText_RefreshAllItems:
|
---|
| 118 | push cx
|
---|
| 119 |
|
---|
| 120 | call MenuScrollbars_GetActualVisibleItemsOnPageToCX
|
---|
| 121 | mov ax, [bp+MENU.wFirstVisibleItem]
|
---|
[369] | 122 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 123 | .ItemRefreshLoop:
|
---|
| 124 | call MenuText_RefreshItemFromAX
|
---|
| 125 | inc ax
|
---|
| 126 | loop .ItemRefreshLoop
|
---|
| 127 |
|
---|
| 128 | pop cx
|
---|
| 129 | NothingToRefresh:
|
---|
| 130 | ret
|
---|
| 131 |
|
---|
| 132 | ;--------------------------------------------------------------------
|
---|
| 133 | ; MenuText_RefreshItemFromAX
|
---|
| 134 | ; Parameters
|
---|
| 135 | ; AX: Item to refresh
|
---|
| 136 | ; SS:BP: Ptr to MENU
|
---|
| 137 | ; Returns:
|
---|
| 138 | ; Nothing
|
---|
| 139 | ; Corrupts registers:
|
---|
| 140 | ; BX, DX, SI, DI
|
---|
| 141 | ;--------------------------------------------------------------------
|
---|
[369] | 142 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 143 | MenuText_RefreshItemFromAX:
|
---|
| 144 | push cx
|
---|
[67] | 145 | push ax
|
---|
[41] | 146 |
|
---|
[67] | 147 | xchg cx, ax
|
---|
[41] | 148 | call MenuScrollbars_IsItemInCXonVisiblePage
|
---|
| 149 | jnc SHORT .InvalidItem
|
---|
[52] | 150 | call MenuText_AdjustDisplayContextForDrawingItemFromCX
|
---|
[67] | 151 | call ClearPreviousItem
|
---|
[41] | 152 | call MenuEvent_RefreshItemFromCX
|
---|
[67] | 153 | call DrawScrollbarCharacterForItemInCXifNecessary
|
---|
[41] | 154 | .InvalidItem:
|
---|
[67] | 155 | pop ax
|
---|
[41] | 156 | pop cx
|
---|
| 157 | ret
|
---|
| 158 |
|
---|
| 159 | ;--------------------------------------------------------------------
|
---|
[52] | 160 | ; MenuText_AdjustDisplayContextForDrawingItemFromCX
|
---|
[41] | 161 | ; Parameters
|
---|
[52] | 162 | ; CX: Item to refresh
|
---|
[41] | 163 | ; SS:BP: Ptr to MENU
|
---|
| 164 | ; Returns:
|
---|
[52] | 165 | ; Nothing
|
---|
[41] | 166 | ; Corrupts registers:
|
---|
[52] | 167 | ; AX, BX, DX, SI, DI
|
---|
[41] | 168 | ;--------------------------------------------------------------------
|
---|
[369] | 169 | ALIGN MENU_JUMP_ALIGN
|
---|
[52] | 170 | MenuText_AdjustDisplayContextForDrawingItemFromCX:
|
---|
| 171 | mov ax, cx
|
---|
| 172 | call GetItemTextAttributeTypeToSIforItemInCX
|
---|
[41] | 173 | call MenuLocation_GetTextCoordinatesToAXforItemInAX
|
---|
[52] | 174 | mov dx, MenuCharOut_MenuTeletypeOutput
|
---|
[133] | 175 | ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
|
---|
[52] | 176 |
|
---|
| 177 | ;--------------------------------------------------------------------
|
---|
| 178 | ; AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
|
---|
| 179 | ; Parameters
|
---|
| 180 | ; AX: Cursor coordinates to set
|
---|
| 181 | ; DX: Character output function
|
---|
| 182 | ; SI: Attribute type (from ATTRIBUTE_CHARS)
|
---|
| 183 | ; SS:BP: Ptr to MENU
|
---|
| 184 | ; Returns:
|
---|
| 185 | ; Nothing
|
---|
| 186 | ; Corrupts registers:
|
---|
| 187 | ; AX, BX, DX, SI, DI
|
---|
| 188 | ;--------------------------------------------------------------------
|
---|
[369] | 189 | ALIGN MENU_JUMP_ALIGN
|
---|
[52] | 190 | AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
|
---|
[41] | 191 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
| 192 |
|
---|
[52] | 193 | xchg ax, dx
|
---|
| 194 | mov bl, ATTRIBUTES_ARE_USED
|
---|
| 195 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
|
---|
| 196 |
|
---|
| 197 | call CharOutLineSplitter_PrepareForPrintingTextLines
|
---|
| 198 | jmp MenuAttribute_SetToDisplayContextFromTypeInSI
|
---|
| 199 |
|
---|
| 200 |
|
---|
[41] | 201 | ;--------------------------------------------------------------------
|
---|
[67] | 202 | ; ClearPreviousItem
|
---|
| 203 | ; Parameters
|
---|
| 204 | ; SS:BP: Ptr to MENU
|
---|
| 205 | ; Returns:
|
---|
| 206 | ; Nothing
|
---|
| 207 | ; Corrupts registers:
|
---|
| 208 | ; AX, BX, DX, DI
|
---|
| 209 | ;--------------------------------------------------------------------
|
---|
[369] | 210 | ALIGN MENU_JUMP_ALIGN
|
---|
[67] | 211 | ClearPreviousItem:
|
---|
| 212 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
|
---|
| 213 | xchg bx, ax
|
---|
| 214 |
|
---|
| 215 | call MenuBorders_GetNumberOfMiddleCharactersToDX
|
---|
| 216 | sub dx, BYTE MENU_TEXT_COLUMN_OFFSET
|
---|
| 217 | mov al, [cs:g_rgbTextBorderCharacters+BORDER_CHARS.cMiddle]
|
---|
| 218 | call MenuBorders_PrintMultipleBorderCharactersFromAL
|
---|
| 219 |
|
---|
| 220 | xchg ax, bx
|
---|
[505] | 221 | JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
[67] | 222 |
|
---|
| 223 |
|
---|
| 224 | ;--------------------------------------------------------------------
|
---|
[52] | 225 | ; GetItemTextAttributeTypeToSIforItemInCX
|
---|
[41] | 226 | ; Parameters
|
---|
| 227 | ; CX: Item to refresh
|
---|
| 228 | ; SS:BP: Ptr to MENU
|
---|
| 229 | ; Returns:
|
---|
| 230 | ; SI: Text attribute type (ATTRIBUTE_CHARS)
|
---|
| 231 | ; Corrupts registers:
|
---|
| 232 | ; Nothing
|
---|
| 233 | ;--------------------------------------------------------------------
|
---|
[369] | 234 | ALIGN MENU_JUMP_ALIGN
|
---|
[52] | 235 | GetItemTextAttributeTypeToSIforItemInCX:
|
---|
[41] | 236 | mov si, ATTRIBUTE_CHARS.cItem
|
---|
| 237 | test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
|
---|
| 238 | jnz SHORT .ReturnAttributeTypeInSI
|
---|
[52] | 239 |
|
---|
| 240 | cmp cx, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 241 | jne SHORT .ReturnAttributeTypeInSI
|
---|
[583] | 242 | inc si ; SI = ATTRIBUTE_CHARS.cHighlightedItem
|
---|
[369] | 243 | ALIGN MENU_JUMP_ALIGN, ret
|
---|
[41] | 244 | .ReturnAttributeTypeInSI:
|
---|
| 245 | ret
|
---|
| 246 |
|
---|
| 247 |
|
---|
| 248 | ;--------------------------------------------------------------------
|
---|
[67] | 249 | ; DrawScrollbarCharacterForItemInCXifNecessary
|
---|
[41] | 250 | ; Parameters
|
---|
| 251 | ; CX: Item to refresh
|
---|
| 252 | ; SS:BP: Ptr to MENU
|
---|
| 253 | ; Returns:
|
---|
| 254 | ; Nothing
|
---|
| 255 | ; Corrupts registers:
|
---|
[67] | 256 | ; AX, CX, BX, DX, SI, DI
|
---|
[41] | 257 | ;--------------------------------------------------------------------
|
---|
[369] | 258 | ALIGN MENU_JUMP_ALIGN
|
---|
[67] | 259 | DrawScrollbarCharacterForItemInCXifNecessary:
|
---|
[41] | 260 | call MenuScrollbars_AreScrollbarsNeeded
|
---|
| 261 | jc SHORT .DrawScrollbarCharacter
|
---|
| 262 | ret
|
---|
| 263 |
|
---|
[369] | 264 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 265 | .DrawScrollbarCharacter:
|
---|
[48] | 266 | call MenuBorders_AdjustDisplayContextForDrawingBorders
|
---|
[41] | 267 | mov ax, cx
|
---|
[104] | 268 |
|
---|
| 269 | call MenuLocation_GetTextCoordinatesToAXforItemInAX
|
---|
| 270 | add al, [bp+MENUINIT.bWidth]
|
---|
| 271 | sub al, MENU_TEXT_COLUMN_OFFSET*2
|
---|
[41] | 272 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
| 273 |
|
---|
| 274 | mov di, cx
|
---|
| 275 | sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
|
---|
| 276 | call MenuScrollbars_GetScrollCharacterToALForLineInDI
|
---|
[67] | 277 | jmp MenuBorders_PrintSingleBorderCharacterFromAL
|
---|