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