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 | ;--------------------------------------------------------------------
|
---|
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 | %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
|
---|
18 | ALIGN JUMP_ALIGN
|
---|
19 | MenuText_ClearTitleArea:
|
---|
20 | CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
|
---|
21 | call PrepareToDrawTitleArea
|
---|
22 | mov cl, [bp+MENUINIT.bTitleLines]
|
---|
23 | jmp SHORT MenuText_ClearInformationArea.ClearCLlinesOfText
|
---|
24 | %endif
|
---|
25 |
|
---|
26 | ALIGN JUMP_ALIGN
|
---|
27 | MenuText_ClearInformationArea:
|
---|
28 | CALL_DISPLAY_LIBRARY PushDisplayContext ; Save cursor coordinates
|
---|
29 | call MenuText_PrepareToDrawInformationArea
|
---|
30 | mov cl, [bp+MENUINIT.bInfoLines]
|
---|
31 | .ClearCLlinesOfText:
|
---|
32 | mov al, [bp+MENUINIT.bWidth]
|
---|
33 | sub al, MENU_HORIZONTAL_BORDER_LINES+(MENU_TEXT_COLUMN_OFFSET/2)
|
---|
34 | mul cl
|
---|
35 | xchg cx, ax
|
---|
36 | mov al, ' '
|
---|
37 | CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
|
---|
38 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
39 | ret
|
---|
40 |
|
---|
41 |
|
---|
42 | ;--------------------------------------------------------------------
|
---|
43 | ; MenuText_RefreshTitle
|
---|
44 | ; MenuText_RefreshInformation
|
---|
45 | ; Parameters
|
---|
46 | ; SS:BP: Ptr to MENU
|
---|
47 | ; Returns:
|
---|
48 | ; Nothing
|
---|
49 | ; Corrupts registers:
|
---|
50 | ; AX, BX, CX, DX, SI, DI
|
---|
51 | ;--------------------------------------------------------------------
|
---|
52 | ALIGN JUMP_ALIGN
|
---|
53 | MenuText_RefreshTitle:
|
---|
54 | cmp BYTE [bp+MENUINIT.bTitleLines], 0
|
---|
55 | jz SHORT NothingToRefresh
|
---|
56 | call PrepareToDrawTitleArea
|
---|
57 | jmp MenuEvent_RefreshTitle
|
---|
58 |
|
---|
59 | ALIGN JUMP_ALIGN
|
---|
60 | MenuText_RefreshInformation:
|
---|
61 | cmp BYTE [bp+MENUINIT.bInfoLines], 0
|
---|
62 | jz SHORT NothingToRefresh
|
---|
63 | call MenuText_PrepareToDrawInformationArea
|
---|
64 | jmp MenuEvent_RefreshInformation
|
---|
65 |
|
---|
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 | ;--------------------------------------------------------------------
|
---|
76 | ALIGN JUMP_ALIGN
|
---|
77 | PrepareToDrawTitleArea:
|
---|
78 | mov si, ATTRIBUTE_CHARS.cTitle
|
---|
79 | call MenuLocation_GetTitleTextTopLeftCoordinatesToAX
|
---|
80 | jmp SHORT FinishPreparationsToDrawTitleOrInformationArea
|
---|
81 |
|
---|
82 | ALIGN JUMP_ALIGN
|
---|
83 | MenuText_PrepareToDrawInformationArea:
|
---|
84 | mov si, ATTRIBUTE_CHARS.cInformation
|
---|
85 | call MenuLocation_GetInformationTextTopLeftCoordinatesToAX
|
---|
86 | FinishPreparationsToDrawTitleOrInformationArea:
|
---|
87 | mov dx, MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
|
---|
88 | jmp SHORT AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
|
---|
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 | ;--------------------------------------------------------------------
|
---|
100 | ALIGN JUMP_ALIGN
|
---|
101 | MenuText_RefreshAllItems:
|
---|
102 | push cx
|
---|
103 |
|
---|
104 | call MenuScrollbars_GetActualVisibleItemsOnPageToCX
|
---|
105 | mov ax, [bp+MENU.wFirstVisibleItem]
|
---|
106 | ALIGN JUMP_ALIGN
|
---|
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 | ;--------------------------------------------------------------------
|
---|
126 | ALIGN JUMP_ALIGN
|
---|
127 | MenuText_RefreshItemFromAX:
|
---|
128 | push cx
|
---|
129 | push ax
|
---|
130 |
|
---|
131 | xchg cx, ax
|
---|
132 | call MenuScrollbars_IsItemInCXonVisiblePage
|
---|
133 | jnc SHORT .InvalidItem
|
---|
134 | call MenuText_AdjustDisplayContextForDrawingItemFromCX
|
---|
135 | call ClearPreviousItem
|
---|
136 | call MenuEvent_RefreshItemFromCX
|
---|
137 | call DrawScrollbarCharacterForItemInCXifNecessary
|
---|
138 | .InvalidItem:
|
---|
139 | pop ax
|
---|
140 | pop cx
|
---|
141 | ret
|
---|
142 |
|
---|
143 | ;--------------------------------------------------------------------
|
---|
144 | ; MenuText_AdjustDisplayContextForDrawingItemFromCX
|
---|
145 | ; Parameters
|
---|
146 | ; CX: Item to refresh
|
---|
147 | ; SS:BP: Ptr to MENU
|
---|
148 | ; Returns:
|
---|
149 | ; Nothing
|
---|
150 | ; Corrupts registers:
|
---|
151 | ; AX, BX, DX, SI, DI
|
---|
152 | ;--------------------------------------------------------------------
|
---|
153 | ALIGN JUMP_ALIGN
|
---|
154 | MenuText_AdjustDisplayContextForDrawingItemFromCX:
|
---|
155 | mov ax, cx
|
---|
156 | call GetItemTextAttributeTypeToSIforItemInCX
|
---|
157 | call MenuLocation_GetTextCoordinatesToAXforItemInAX
|
---|
158 | mov dx, MenuCharOut_MenuTeletypeOutput
|
---|
159 | ; Fall to AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX
|
---|
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 | ;--------------------------------------------------------------------
|
---|
173 | ALIGN JUMP_ALIGN
|
---|
174 | AdjustDisplayContextForDrawingTextsAtCoordsInAXwithAttrTypeInSIandCharOutFunctionInDX:
|
---|
175 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
176 |
|
---|
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 |
|
---|
185 | ;--------------------------------------------------------------------
|
---|
186 | ; ClearPreviousItem
|
---|
187 | ; Parameters
|
---|
188 | ; SS:BP: Ptr to MENU
|
---|
189 | ; Returns:
|
---|
190 | ; Nothing
|
---|
191 | ; Corrupts registers:
|
---|
192 | ; AX, BX, DX, DI
|
---|
193 | ;--------------------------------------------------------------------
|
---|
194 | ALIGN JUMP_ALIGN
|
---|
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 | ;--------------------------------------------------------------------
|
---|
210 | ; GetItemTextAttributeTypeToSIforItemInCX
|
---|
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 | ;--------------------------------------------------------------------
|
---|
219 | ALIGN JUMP_ALIGN
|
---|
220 | GetItemTextAttributeTypeToSIforItemInCX:
|
---|
221 | mov si, ATTRIBUTE_CHARS.cItem
|
---|
222 | test BYTE [bp+MENU.bFlags], FLG_MENU_NOHIGHLIGHT
|
---|
223 | jnz SHORT .ReturnAttributeTypeInSI
|
---|
224 |
|
---|
225 | cmp cx, [bp+MENUINIT.wHighlightedItem]
|
---|
226 | jne SHORT .ReturnAttributeTypeInSI
|
---|
227 | sub si, BYTE ATTRIBUTE_CHARS.cItem - ATTRIBUTE_CHARS.cHighlightedItem
|
---|
228 | ALIGN JUMP_ALIGN, ret
|
---|
229 | .ReturnAttributeTypeInSI:
|
---|
230 | ret
|
---|
231 |
|
---|
232 |
|
---|
233 | ;--------------------------------------------------------------------
|
---|
234 | ; DrawScrollbarCharacterForItemInCXifNecessary
|
---|
235 | ; Parameters
|
---|
236 | ; CX: Item to refresh
|
---|
237 | ; SS:BP: Ptr to MENU
|
---|
238 | ; Returns:
|
---|
239 | ; Nothing
|
---|
240 | ; Corrupts registers:
|
---|
241 | ; AX, CX, BX, DX, SI, DI
|
---|
242 | ;--------------------------------------------------------------------
|
---|
243 | ALIGN JUMP_ALIGN
|
---|
244 | DrawScrollbarCharacterForItemInCXifNecessary:
|
---|
245 | call MenuScrollbars_AreScrollbarsNeeded
|
---|
246 | jc SHORT .DrawScrollbarCharacter
|
---|
247 | ret
|
---|
248 |
|
---|
249 | ALIGN JUMP_ALIGN
|
---|
250 | .DrawScrollbarCharacter:
|
---|
251 | call MenuBorders_AdjustDisplayContextForDrawingBorders
|
---|
252 | mov ax, cx
|
---|
253 |
|
---|
254 | call MenuLocation_GetTextCoordinatesToAXforItemInAX
|
---|
255 | add al, [bp+MENUINIT.bWidth]
|
---|
256 | sub al, MENU_TEXT_COLUMN_OFFSET*2
|
---|
257 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
258 |
|
---|
259 | mov di, cx
|
---|
260 | sub di, [bp+MENU.wFirstVisibleItem] ; Item to line
|
---|
261 | call MenuScrollbars_GetScrollCharacterToALForLineInDI
|
---|
262 | jmp MenuBorders_PrintSingleBorderCharacterFromAL
|
---|