[41] | 1 | ; File name : MenuText.asm |
---|
| 2 | ; Project name : Assembly Library |
---|
| 3 | ; Created date : 21.7.2010 |
---|
| 4 | ; Last update : 11.8.2010 |
---|
| 5 | ; Author : Tomi Tilli |
---|
| 6 | ; Description : Functions for drawing menu texts by the user. |
---|
| 7 | |
---|
| 8 | ; Section containing code |
---|
| 9 | SECTION .text |
---|
| 10 | |
---|
| 11 | ;-------------------------------------------------------------------- |
---|
| 12 | ; MenuText_RefreshTitle |
---|
| 13 | ; MenuText_RefreshInformation |
---|
| 14 | ; Parameters |
---|
| 15 | ; SS:BP: Ptr to MENU |
---|
| 16 | ; Returns: |
---|
| 17 | ; Nothing |
---|
| 18 | ; Corrupts registers: |
---|
| 19 | ; AX, BX, DX, SI, DI |
---|
| 20 | ;-------------------------------------------------------------------- |
---|
| 21 | ALIGN JUMP_ALIGN |
---|
| 22 | MenuText_RefreshTitle: |
---|
| 23 | cmp BYTE [bp+MENUINIT.bTitleLines], 0 |
---|
| 24 | jz SHORT NothingToRefresh |
---|
| 25 | |
---|
| 26 | mov si, ATTRIBUTE_CHARS.cTitle |
---|
| 27 | call AdjustDisplayContextForDrawingTexts |
---|
| 28 | call MenuLocation_GetTitleTextTopLeftCoordinatesToAX |
---|
| 29 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
| 30 | jmp MenuEvent_RefreshTitle |
---|
| 31 | |
---|
| 32 | ALIGN JUMP_ALIGN |
---|
| 33 | MenuText_RefreshInformation: |
---|
| 34 | cmp BYTE [bp+MENUINIT.bInfoLines], 0 |
---|
| 35 | jz SHORT NothingToRefresh |
---|
| 36 | |
---|
| 37 | mov si, ATTRIBUTE_CHARS.cInformation |
---|
| 38 | call AdjustDisplayContextForDrawingTexts |
---|
| 39 | call MenuLocation_GetInformationTextTopLeftCoordinatesToAX |
---|
| 40 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
| 41 | jmp MenuEvent_RefreshInformation |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | ;-------------------------------------------------------------------- |
---|
| 45 | ; MenuText_RefreshAllItems |
---|
| 46 | ; Parameters |
---|
| 47 | ; SS:BP: Ptr to MENU |
---|
| 48 | ; Returns: |
---|
| 49 | ; Nothing |
---|
| 50 | ; Corrupts registers: |
---|
| 51 | ; AX, BX, DX, SI, DI |
---|
| 52 | ;-------------------------------------------------------------------- |
---|
| 53 | ALIGN JUMP_ALIGN |
---|
| 54 | MenuText_RefreshAllItems: |
---|
| 55 | push cx |
---|
| 56 | |
---|
| 57 | call MenuScrollbars_GetActualVisibleItemsOnPageToCX |
---|
| 58 | mov ax, [bp+MENU.wFirstVisibleItem] |
---|
| 59 | ALIGN JUMP_ALIGN |
---|
| 60 | .ItemRefreshLoop: |
---|
| 61 | call MenuText_RefreshItemFromAX |
---|
| 62 | inc ax |
---|
| 63 | loop .ItemRefreshLoop |
---|
| 64 | |
---|
| 65 | pop cx |
---|
| 66 | NothingToRefresh: |
---|
| 67 | ret |
---|
| 68 | |
---|
| 69 | ;-------------------------------------------------------------------- |
---|
| 70 | ; MenuText_RefreshItemFromAX |
---|
| 71 | ; Parameters |
---|
| 72 | ; AX: Item to refresh |
---|
| 73 | ; SS:BP: Ptr to MENU |
---|
| 74 | ; Returns: |
---|
| 75 | ; Nothing |
---|
| 76 | ; Corrupts registers: |
---|
| 77 | ; BX, DX, SI, DI |
---|
| 78 | ;-------------------------------------------------------------------- |
---|
| 79 | ALIGN JUMP_ALIGN |
---|
| 80 | MenuText_RefreshItemFromAX: |
---|
| 81 | push cx |
---|
| 82 | mov cx, ax ; Backup item to CX |
---|
| 83 | |
---|
| 84 | call MenuScrollbars_IsItemInCXonVisiblePage |
---|
| 85 | jnc SHORT .InvalidItem |
---|
| 86 | mov ax, cx |
---|
| 87 | call MenuText_AdjustDisplayContextForDrawingItemFromAX |
---|
| 88 | call MenuEvent_RefreshItemFromCX |
---|
| 89 | call DrawScrollbarIfNecessary |
---|
| 90 | .InvalidItem: |
---|
| 91 | xchg ax, cx ; Restore AX |
---|
| 92 | pop cx |
---|
| 93 | ret |
---|
| 94 | |
---|
| 95 | ;-------------------------------------------------------------------- |
---|
| 96 | ; MenuText_AdjustDisplayContextForDrawingItemFromAX |
---|
| 97 | ; Parameters |
---|
| 98 | ; AX: Item to refresh |
---|
| 99 | ; SS:BP: Ptr to MENU |
---|
| 100 | ; Returns: |
---|
| 101 | ; CX: Item to refresh |
---|
| 102 | ; Corrupts registers: |
---|
| 103 | ; AX, SI, DI |
---|
| 104 | ;-------------------------------------------------------------------- |
---|
| 105 | ALIGN JUMP_ALIGN |
---|
| 106 | MenuText_AdjustDisplayContextForDrawingItemFromAX: |
---|
| 107 | mov cx, ax |
---|
| 108 | call MenuLocation_GetTextCoordinatesToAXforItemInAX |
---|
| 109 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
| 110 | call .GetItemTextAttributeTypeToSIforItemInCX |
---|
| 111 | jmp SHORT AdjustDisplayContextForDrawingTexts |
---|
| 112 | |
---|
| 113 | ;-------------------------------------------------------------------- |
---|
| 114 | ; .GetItemTextAttributeTypeToSIforItemInCX |
---|
| 115 | ; Parameters |
---|
| 116 | ; CX: Item to refresh |
---|
| 117 | ; SS:BP: Ptr to MENU |
---|
| 118 | ; Returns: |
---|
| 119 | ; SI: Text attribute type (ATTRIBUTE_CHARS) |
---|
| 120 | ; Corrupts registers: |
---|
| 121 | ; Nothing |
---|
| 122 | ;-------------------------------------------------------------------- |
---|
| 123 | ALIGN JUMP_ALIGN |
---|
| 124 | .GetItemTextAttributeTypeToSIforItemInCX: |
---|
| 125 | mov si, ATTRIBUTE_CHARS.cItem |
---|
| 126 | test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT |
---|
| 127 | jnz SHORT .ReturnAttributeTypeInSI |
---|
| 128 | cmp cx, [bp+MENU.wHighlightedItem] |
---|
| 129 | jne SHORT .ReturnAttributeTypeInSI |
---|
| 130 | sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem |
---|
| 131 | ALIGN JUMP_ALIGN, ret |
---|
| 132 | .ReturnAttributeTypeInSI: |
---|
| 133 | ret |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | ;-------------------------------------------------------------------- |
---|
| 137 | ; DrawScrollbarIfNecessary |
---|
| 138 | ; Parameters |
---|
| 139 | ; CX: Item to refresh |
---|
| 140 | ; SS:BP: Ptr to MENU |
---|
| 141 | ; Returns: |
---|
| 142 | ; Nothing |
---|
| 143 | ; Corrupts registers: |
---|
| 144 | ; AX, DX, SI, DI |
---|
| 145 | ;-------------------------------------------------------------------- |
---|
| 146 | ALIGN JUMP_ALIGN |
---|
| 147 | DrawScrollbarIfNecessary: |
---|
| 148 | push cx |
---|
| 149 | call .DrawSpacesBeforeScrollbarCharacter |
---|
| 150 | call MenuScrollbars_AreScrollbarsNeeded |
---|
| 151 | pop cx |
---|
| 152 | jc SHORT .DrawScrollbarCharacter |
---|
| 153 | ret |
---|
| 154 | |
---|
| 155 | ;-------------------------------------------------------------------- |
---|
| 156 | ; .DrawSpacesBeforeScrollbarCharacter |
---|
| 157 | ; Parameters |
---|
| 158 | ; CX: Item to refresh |
---|
| 159 | ; SS:BP: Ptr to MENU |
---|
| 160 | ; Returns: |
---|
| 161 | ; Nothing |
---|
| 162 | ; Corrupts registers: |
---|
| 163 | ; AX, CX, DX, DI |
---|
| 164 | ;-------------------------------------------------------------------- |
---|
| 165 | ALIGN JUMP_ALIGN |
---|
| 166 | .DrawSpacesBeforeScrollbarCharacter: |
---|
| 167 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX |
---|
| 168 | xchg dx, ax ; Current coordinates to DX |
---|
| 169 | mov ax, cx |
---|
| 170 | call MenuLocation_GetScrollbarCoordinatesToAXforItemInAX |
---|
| 171 | sub al, dl |
---|
| 172 | sub al, MENU_TEXT_COLUMN_OFFSET/2 |
---|
| 173 | |
---|
| 174 | eMOVZX cx, al |
---|
| 175 | jcxz .NoSpacesNeeded |
---|
| 176 | mov al, ' ' |
---|
| 177 | CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX |
---|
| 178 | ALIGN JUMP_ALIGN, ret |
---|
| 179 | .NoSpacesNeeded: |
---|
| 180 | ret |
---|
| 181 | |
---|
| 182 | ;-------------------------------------------------------------------- |
---|
| 183 | ; .DrawScrollbarCharacter |
---|
| 184 | ; Parameters |
---|
| 185 | ; CX: Item to refresh |
---|
| 186 | ; SS:BP: Ptr to MENU |
---|
| 187 | ; Returns: |
---|
| 188 | ; Nothing |
---|
| 189 | ; Corrupts registers: |
---|
| 190 | ; AX, DX, SI, DI |
---|
| 191 | ;-------------------------------------------------------------------- |
---|
| 192 | ALIGN JUMP_ALIGN |
---|
| 193 | .DrawScrollbarCharacter: |
---|
| 194 | push cx |
---|
| 195 | |
---|
| 196 | mov si, ATTRIBUTE_CHARS.cBordersAndBackground |
---|
| 197 | call MenuAttribute_SetToDisplayContextFromTypeInSI |
---|
| 198 | |
---|
| 199 | mov ax, cx |
---|
| 200 | call MenuLocation_GetScrollbarCoordinatesToAXforItemInAX |
---|
| 201 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
| 202 | |
---|
| 203 | mov di, cx |
---|
| 204 | sub di, [bp+MENU.wFirstVisibleItem] ; Item to line |
---|
| 205 | call MenuScrollbars_GetScrollCharacterToALForLineInDI |
---|
| 206 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL |
---|
| 207 | |
---|
| 208 | pop cx |
---|
| 209 | ret |
---|
| 210 | |
---|
| 211 | |
---|
| 212 | ;-------------------------------------------------------------------- |
---|
| 213 | ; AdjustDisplayContextForDrawingTexts |
---|
| 214 | ; Parameters |
---|
| 215 | ; SI: Attribute type (from ATTRIBUTE_CHARS) |
---|
| 216 | ; SS:BP: Ptr to MENU |
---|
| 217 | ; Returns: |
---|
| 218 | ; Nothing |
---|
| 219 | ; Corrupts registers: |
---|
| 220 | ; AX, SI, DI |
---|
| 221 | ;-------------------------------------------------------------------- |
---|
| 222 | ALIGN JUMP_ALIGN |
---|
| 223 | AdjustDisplayContextForDrawingTexts: |
---|
| 224 | mov ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute |
---|
| 225 | CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX |
---|
| 226 | |
---|
| 227 | mov ax, bp |
---|
| 228 | CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX |
---|
| 229 | |
---|
| 230 | jmp MenuAttribute_SetToDisplayContextFromTypeInSI |
---|