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