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