1 | ; Project name : Assembly Library |
---|
2 | ; Description : Functions for drawing menu borders. |
---|
3 | |
---|
4 | ; Struct containing border characters for different types of menu window lines |
---|
5 | struc BORDER_CHARS |
---|
6 | .cLeft resb 1 |
---|
7 | .cMiddle resb 1 |
---|
8 | .cRight resb 1 |
---|
9 | endstruc |
---|
10 | |
---|
11 | |
---|
12 | ; Section containing code |
---|
13 | SECTION .text |
---|
14 | |
---|
15 | ;-------------------------------------------------------------------- |
---|
16 | ; MenuBorders_RefreshAll |
---|
17 | ; Parameters |
---|
18 | ; SS:BP: Ptr to MENU |
---|
19 | ; Returns: |
---|
20 | ; Nothing |
---|
21 | ; Corrupts registers: |
---|
22 | ; AX, BX, CX, DX, SI, DI |
---|
23 | ;-------------------------------------------------------------------- |
---|
24 | ALIGN MENU_JUMP_ALIGN |
---|
25 | MenuBorders_RefreshAll: |
---|
26 | %ifndef USE_186 |
---|
27 | call MenuBorders_AdjustDisplayContextForDrawingBorders |
---|
28 | call MenuBorders_GetNumberOfMiddleCharactersToDX |
---|
29 | call RefreshTitleBorders |
---|
30 | call RefreshItemBorders |
---|
31 | call RefreshInformationBorders |
---|
32 | call DrawBottomBorderLine |
---|
33 | jmp DrawBottomShadowLine |
---|
34 | %else |
---|
35 | push DrawBottomShadowLine |
---|
36 | push DrawBottomBorderLine |
---|
37 | push RefreshInformationBorders |
---|
38 | push RefreshItemBorders |
---|
39 | push RefreshTitleBorders |
---|
40 | push MenuBorders_GetNumberOfMiddleCharactersToDX |
---|
41 | jmp MenuBorders_AdjustDisplayContextForDrawingBorders |
---|
42 | %endif |
---|
43 | |
---|
44 | |
---|
45 | ;-------------------------------------------------------------------- |
---|
46 | ; MenuBorders_RedrawBottomBorderLine |
---|
47 | ; Parameters |
---|
48 | ; SS:BP: Ptr to MENU |
---|
49 | ; Returns: |
---|
50 | ; Nothing |
---|
51 | ; Corrupts registers: |
---|
52 | ; AX, BX, DX, SI, DI |
---|
53 | ;-------------------------------------------------------------------- |
---|
54 | ALIGN MENU_JUMP_ALIGN |
---|
55 | MenuBorders_RedrawBottomBorderLine: |
---|
56 | call MenuBorders_AdjustDisplayContextForDrawingBorders |
---|
57 | call MenuLocation_GetBottomBordersTopLeftCoordinatesToAX |
---|
58 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
59 | call MenuBorders_GetNumberOfMiddleCharactersToDX |
---|
60 | jmp SHORT DrawBottomBorderLine |
---|
61 | |
---|
62 | |
---|
63 | ;-------------------------------------------------------------------- |
---|
64 | ; MenuBorders_RefreshItemBorders |
---|
65 | ; Parameters |
---|
66 | ; SS:BP: Ptr to MENU |
---|
67 | ; Returns: |
---|
68 | ; Nothing |
---|
69 | ; Corrupts registers: |
---|
70 | ; AX, BX, CX, DX, SI, DI |
---|
71 | ;-------------------------------------------------------------------- |
---|
72 | %ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS |
---|
73 | ALIGN MENU_JUMP_ALIGN |
---|
74 | MenuBorders_RefreshItemBorders: |
---|
75 | call MenuBorders_AdjustDisplayContextForDrawingBorders |
---|
76 | call MenuLocation_GetItemBordersTopLeftCoordinatesToAX |
---|
77 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
78 | |
---|
79 | call MenuBorders_GetNumberOfMiddleCharactersToDX |
---|
80 | jmp SHORT RefreshItemBorders |
---|
81 | %endif |
---|
82 | |
---|
83 | |
---|
84 | ;-------------------------------------------------------------------- |
---|
85 | ; MenuBorders_AdjustDisplayContextForDrawingBorders |
---|
86 | ; Parameters |
---|
87 | ; SS:BP: Ptr to MENU |
---|
88 | ; Returns: |
---|
89 | ; Nothing |
---|
90 | ; Corrupts registers: |
---|
91 | ; AX, BX, SI, DI |
---|
92 | ;-------------------------------------------------------------------- |
---|
93 | ALIGN MENU_JUMP_ALIGN |
---|
94 | MenuBorders_AdjustDisplayContextForDrawingBorders: |
---|
95 | mov bl, ATTRIBUTES_ARE_USED |
---|
96 | mov ax, MenuCharOut_MenuTeletypeOutput |
---|
97 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL |
---|
98 | |
---|
99 | call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX |
---|
100 | CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX |
---|
101 | |
---|
102 | call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX |
---|
103 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
104 | |
---|
105 | mov si, ATTRIBUTE_CHARS.cBordersAndBackground |
---|
106 | jmp MenuAttribute_SetToDisplayContextFromTypeInSI |
---|
107 | |
---|
108 | |
---|
109 | ;-------------------------------------------------------------------- |
---|
110 | ; MenuBorders_GetNumberOfMiddleCharactersToDX |
---|
111 | ; Parameters |
---|
112 | ; SS:BP: Ptr to MENU |
---|
113 | ; Returns: |
---|
114 | ; DX: Number of middle border characters when drawing border lines |
---|
115 | ; Corrupts registers: |
---|
116 | ; Nothing |
---|
117 | ;-------------------------------------------------------------------- |
---|
118 | ALIGN MENU_JUMP_ALIGN |
---|
119 | MenuBorders_GetNumberOfMiddleCharactersToDX: |
---|
120 | eMOVZX dx, [bp+MENUINIT.bWidth] |
---|
121 | sub dx, BYTE MENU_HORIZONTAL_BORDER_LINES |
---|
122 | ret |
---|
123 | |
---|
124 | |
---|
125 | ;-------------------------------------------------------------------- |
---|
126 | ; RefreshTitleBorders |
---|
127 | ; Parameters |
---|
128 | ; DX: Number of times to repeat middle character |
---|
129 | ; SS:BP: Ptr to MENU |
---|
130 | ; Returns: |
---|
131 | ; Nothing |
---|
132 | ; Corrupts registers: |
---|
133 | ; AX, BX, CX, SI, DI |
---|
134 | ;-------------------------------------------------------------------- |
---|
135 | ALIGN MENU_JUMP_ALIGN |
---|
136 | RefreshTitleBorders: |
---|
137 | call DrawTopBorderLine |
---|
138 | eMOVZX cx, [bp+MENUINIT.bTitleLines] |
---|
139 | jmp SHORT DrawTextBorderLinesByCXtimes |
---|
140 | |
---|
141 | ;-------------------------------------------------------------------- |
---|
142 | ; RefreshInformationBorders |
---|
143 | ; Parameters |
---|
144 | ; DX: Number of times to repeat middle character |
---|
145 | ; SS:BP: Ptr to MENU |
---|
146 | ; Returns: |
---|
147 | ; Nothing |
---|
148 | ; Corrupts registers: |
---|
149 | ; AX, BX, CX, SI, DI |
---|
150 | ;-------------------------------------------------------------------- |
---|
151 | ALIGN MENU_JUMP_ALIGN |
---|
152 | RefreshInformationBorders: |
---|
153 | call DrawSeparationBorderLine |
---|
154 | eMOVZX cx, [bp+MENUINIT.bInfoLines] |
---|
155 | jmp SHORT DrawTextBorderLinesByCXtimes |
---|
156 | |
---|
157 | ;-------------------------------------------------------------------- |
---|
158 | ; RefreshItemBorders |
---|
159 | ; Parameters |
---|
160 | ; DX: Number of times to repeat middle character |
---|
161 | ; SS:BP: Ptr to MENU |
---|
162 | ; Returns: |
---|
163 | ; Nothing |
---|
164 | ; Corrupts registers: |
---|
165 | ; AX, BX, CX, SI, DI |
---|
166 | ;-------------------------------------------------------------------- |
---|
167 | ALIGN MENU_JUMP_ALIGN |
---|
168 | RefreshItemBorders: |
---|
169 | call DrawSeparationBorderLine |
---|
170 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX |
---|
171 | ; Fall to DrawTextBorderLinesByCXtimes |
---|
172 | |
---|
173 | ;-------------------------------------------------------------------- |
---|
174 | ; DrawTextBorderLinesByCXtimes |
---|
175 | ; Parameters |
---|
176 | ; CX: Number of border lines to draw |
---|
177 | ; DX: Number of times to repeat middle character |
---|
178 | ; SS:BP: Ptr to MENU |
---|
179 | ; Returns: |
---|
180 | ; Nothing |
---|
181 | ; Corrupts registers: |
---|
182 | ; AX, CX, SI, DI |
---|
183 | ;-------------------------------------------------------------------- |
---|
184 | DrawTextBorderLinesByCXtimes: |
---|
185 | jcxz .NoBorderLinesToDraw |
---|
186 | ALIGN MENU_JUMP_ALIGN |
---|
187 | .DrawBordersWithFunctionInBX: |
---|
188 | call DrawTextBorderLine |
---|
189 | loop .DrawBordersWithFunctionInBX |
---|
190 | .NoBorderLinesToDraw: |
---|
191 | ret |
---|
192 | |
---|
193 | |
---|
194 | ;-------------------------------------------------------------------- |
---|
195 | ; DrawTopBorderLine |
---|
196 | ; DrawSeparationBorderLine |
---|
197 | ; DrawBottomBorderLine |
---|
198 | ; DrawTimeoutCounterOverBottomBorderLine |
---|
199 | ; DrawBottomShadowLine |
---|
200 | ; DrawTextBorderLine |
---|
201 | ; Parameters |
---|
202 | ; DX: Number of times to repeat middle character |
---|
203 | ; SS:BP: Ptr to MENU |
---|
204 | ; Returns: |
---|
205 | ; Nothing |
---|
206 | ; Corrupts registers: |
---|
207 | ; AX, SI, DI |
---|
208 | ;-------------------------------------------------------------------- |
---|
209 | ALIGN MENU_JUMP_ALIGN |
---|
210 | DrawTopBorderLine: |
---|
211 | mov si, g_rgbTopBorderCharacters |
---|
212 | call PrintBorderCharactersFromCSSI |
---|
213 | jmp SHORT PrintNewlineToEndBorderLine |
---|
214 | |
---|
215 | ALIGN MENU_JUMP_ALIGN |
---|
216 | DrawSeparationBorderLine: |
---|
217 | mov si, g_rgbSeparationBorderCharacters |
---|
218 | jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter |
---|
219 | |
---|
220 | ALIGN MENU_JUMP_ALIGN |
---|
221 | DrawBottomBorderLine: |
---|
222 | mov si, g_rgbBottomBorderCharacters |
---|
223 | test BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN |
---|
224 | jz SHORT PrintBorderCharactersFromCSSIandShadowCharacter |
---|
225 | |
---|
226 | call DrawTimeoutCounterString |
---|
227 | sub dx, BYTE MENU_TIMEOUT_STRING_CHARACTERS |
---|
228 | mov si, g_BottomBorderWithTimeoutCharacters |
---|
229 | call PrintBorderCharactersFromCSSIandShadowCharacter |
---|
230 | add dx, BYTE MENU_TIMEOUT_STRING_CHARACTERS |
---|
231 | ret |
---|
232 | |
---|
233 | ALIGN MENU_JUMP_ALIGN |
---|
234 | DrawBottomShadowLine: |
---|
235 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX |
---|
236 | inc ax ; Move one column left |
---|
237 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
238 | inc dx ; Increment repeat count... |
---|
239 | inc dx ; ...for both corner characters |
---|
240 | call PrintShadowCharactersByDXtimes |
---|
241 | dec dx ; Restore... |
---|
242 | dec dx ; ...DX |
---|
243 | ret |
---|
244 | |
---|
245 | ALIGN MENU_JUMP_ALIGN |
---|
246 | DrawTextBorderLine: |
---|
247 | mov si, g_rgbTextBorderCharacters |
---|
248 | ; Fall to PrintBorderCharactersFromCSSIandShadowCharacter |
---|
249 | |
---|
250 | ;-------------------------------------------------------------------- |
---|
251 | ; PrintBorderCharactersFromCSSIandShadowCharacter |
---|
252 | ; Parameters |
---|
253 | ; DX: Number of times to repeat middle character |
---|
254 | ; CS:SI: Ptr to BORDER_CHARS |
---|
255 | ; SS:BP: Ptr to MENU |
---|
256 | ; Returns: |
---|
257 | ; Nothing |
---|
258 | ; Corrupts registers: |
---|
259 | ; AX, SI, DI |
---|
260 | ;-------------------------------------------------------------------- |
---|
261 | ALIGN MENU_JUMP_ALIGN |
---|
262 | PrintBorderCharactersFromCSSIandShadowCharacter: |
---|
263 | call PrintBorderCharactersFromCSSI |
---|
264 | push dx |
---|
265 | mov dx, 1 |
---|
266 | call PrintShadowCharactersByDXtimes |
---|
267 | pop dx |
---|
268 | ; Fall to PrintNewlineToEndBorderLine |
---|
269 | |
---|
270 | ;-------------------------------------------------------------------- |
---|
271 | ; PrintNewlineToEndBorderLine |
---|
272 | ; Parameters |
---|
273 | ; SS:BP: Ptr to MENU |
---|
274 | ; Returns: |
---|
275 | ; Nothing |
---|
276 | ; Corrupts registers: |
---|
277 | ; AX, DI |
---|
278 | ;-------------------------------------------------------------------- |
---|
279 | ALIGN MENU_JUMP_ALIGN |
---|
280 | PrintNewlineToEndBorderLine: |
---|
281 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters |
---|
282 | ret |
---|
283 | |
---|
284 | |
---|
285 | ;-------------------------------------------------------------------- |
---|
286 | ; PrintShadowCharactersByDXtimes |
---|
287 | ; Parameters |
---|
288 | ; DX: Number of shadow characters to print |
---|
289 | ; SS:BP: Ptr to MENU |
---|
290 | ; Returns: |
---|
291 | ; Nothing |
---|
292 | ; Corrupts registers: |
---|
293 | ; AX, SI, DI |
---|
294 | ;-------------------------------------------------------------------- |
---|
295 | ALIGN MENU_JUMP_ALIGN |
---|
296 | PrintShadowCharactersByDXtimes: |
---|
297 | CALL_DISPLAY_LIBRARY PushDisplayContext |
---|
298 | |
---|
299 | mov si, ATTRIBUTE_CHARS.cShadow |
---|
300 | call MenuAttribute_SetToDisplayContextFromTypeInSI |
---|
301 | |
---|
302 | push bx |
---|
303 | mov bl, ATTRIBUTES_ARE_USED |
---|
304 | mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY |
---|
305 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL |
---|
306 | pop bx |
---|
307 | |
---|
308 | call MenuBorders_PrintMultipleBorderCharactersFromAL ; AL does not matter |
---|
309 | |
---|
310 | CALL_DISPLAY_LIBRARY PopDisplayContext |
---|
311 | ret |
---|
312 | |
---|
313 | |
---|
314 | ;-------------------------------------------------------------------- |
---|
315 | ; PrintBorderCharactersFromCSSI |
---|
316 | ; Parameters |
---|
317 | ; DX: Number of times to repeat middle character |
---|
318 | ; CS:SI: Ptr to BORDER_CHARS |
---|
319 | ; SS:BP: Ptr to MENU |
---|
320 | ; Returns: |
---|
321 | ; Nothing |
---|
322 | ; Corrupts registers: |
---|
323 | ; AX, SI, DI |
---|
324 | ;-------------------------------------------------------------------- |
---|
325 | ALIGN MENU_JUMP_ALIGN |
---|
326 | PrintBorderCharactersFromCSSI: |
---|
327 | cs lodsb ; Load from [cs:si+BORDER_CHARS.cLeft] to AL |
---|
328 | call MenuBorders_PrintSingleBorderCharacterFromAL |
---|
329 | |
---|
330 | cs lodsb ; Load from [cs:si+BORDER_CHARS.cMiddle] to AL |
---|
331 | call MenuBorders_PrintMultipleBorderCharactersFromAL |
---|
332 | |
---|
333 | cs lodsb ; Load from [cs:si+BORDER_CHARS.cRight] to AL |
---|
334 | ; Fall to MenuBorders_PrintSingleBorderCharacterFromAL |
---|
335 | |
---|
336 | ;-------------------------------------------------------------------- |
---|
337 | ; MenuBorders_PrintSingleBorderCharacterFromAL |
---|
338 | ; MenuBorders_PrintMultipleBorderCharactersFromAL |
---|
339 | ; Parameters |
---|
340 | ; AL: Character to print |
---|
341 | ; DX: Repeat count (MenuBorders_PrintMultipleBorderCharactersFromAL) |
---|
342 | ; SS:BP: Ptr to MENU |
---|
343 | ; Returns: |
---|
344 | ; Nothing |
---|
345 | ; Corrupts registers: |
---|
346 | ; AX, DI |
---|
347 | ;-------------------------------------------------------------------- |
---|
348 | ALIGN MENU_JUMP_ALIGN |
---|
349 | MenuBorders_PrintSingleBorderCharacterFromAL: |
---|
350 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL |
---|
351 | ret |
---|
352 | |
---|
353 | ALIGN MENU_JUMP_ALIGN |
---|
354 | MenuBorders_PrintMultipleBorderCharactersFromAL: |
---|
355 | push cx |
---|
356 | mov cx, dx |
---|
357 | CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX |
---|
358 | pop cx |
---|
359 | ret |
---|
360 | |
---|
361 | |
---|
362 | ;-------------------------------------------------------------------- |
---|
363 | ; DrawTimeoutCounterString |
---|
364 | ; Parameters |
---|
365 | ; SS:BP: Ptr to MENU |
---|
366 | ; Returns: |
---|
367 | ; Nothing |
---|
368 | ; Corrupts registers: |
---|
369 | ; AX, SI, DI |
---|
370 | ;-------------------------------------------------------------------- |
---|
371 | ALIGN MENU_JUMP_ALIGN |
---|
372 | DrawTimeoutCounterString: |
---|
373 | call MenuTime_GetTimeoutSecondsLeftToAX |
---|
374 | ; Fall to .PrintTimeoutStringWithSecondsInAX |
---|
375 | |
---|
376 | ;-------------------------------------------------------------------- |
---|
377 | ; .PrintTimeoutStringWithSecondsInAX |
---|
378 | ; Parameters |
---|
379 | ; AX: Seconds to print |
---|
380 | ; SS:BP: Ptr to MENU |
---|
381 | ; Returns: |
---|
382 | ; Nothing |
---|
383 | ; Corrupts registers: |
---|
384 | ; AX, SI, DI |
---|
385 | ;-------------------------------------------------------------------- |
---|
386 | .PrintTimeoutStringWithSecondsInAX: |
---|
387 | ; Get attribute to AX |
---|
388 | xchg di, ax |
---|
389 | mov si, ATTRIBUTE_CHARS.cNormalTimeout |
---|
390 | cmp di, BYTE MENU_TIMEOUT_SECONDS_FOR_HURRY |
---|
391 | eCMOVB si, ATTRIBUTE_CHARS.cHurryTimeout |
---|
392 | call MenuAttribute_GetToAXfromTypeInSI |
---|
393 | |
---|
394 | push bp |
---|
395 | mov bp, sp |
---|
396 | mov si, g_szSelectionTimeout |
---|
397 | push ax ; Push attribute |
---|
398 | push di ; Push seconds |
---|
399 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI |
---|
400 | pop bp |
---|
401 | ret |
---|
402 | |
---|
403 | ; Lookup tables for border characters |
---|
404 | g_rgbTopBorderCharacters: |
---|
405 | istruc BORDER_CHARS |
---|
406 | at BORDER_CHARS.cLeft, db DOUBLE_TOP_LEFT_CORNER |
---|
407 | at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL |
---|
408 | at BORDER_CHARS.cRight, db DOUBLE_TOP_RIGHT_CORNER |
---|
409 | iend |
---|
410 | |
---|
411 | g_rgbSeparationBorderCharacters: |
---|
412 | istruc BORDER_CHARS |
---|
413 | at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL_TO_RIGHT_SINGLE |
---|
414 | at BORDER_CHARS.cMiddle, db SINGLE_HORIZONTAL |
---|
415 | at BORDER_CHARS.cRight, db DOUBLE_VERTICAL_TO_LEFT_SINGLE |
---|
416 | iend |
---|
417 | |
---|
418 | g_rgbBottomBorderCharacters: |
---|
419 | istruc BORDER_CHARS |
---|
420 | at BORDER_CHARS.cLeft, db DOUBLE_BOTTOM_LEFT_CORNER |
---|
421 | at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL |
---|
422 | at BORDER_CHARS.cRight, db DOUBLE_BOTTOM_RIGHT_CORNER |
---|
423 | iend |
---|
424 | |
---|
425 | g_BottomBorderWithTimeoutCharacters: |
---|
426 | istruc BORDER_CHARS |
---|
427 | at BORDER_CHARS.cLeft, db DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL |
---|
428 | at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL |
---|
429 | at BORDER_CHARS.cRight, db DOUBLE_BOTTOM_RIGHT_CORNER |
---|
430 | iend |
---|
431 | |
---|
432 | g_rgbTextBorderCharacters: |
---|
433 | istruc BORDER_CHARS |
---|
434 | at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL |
---|
435 | at BORDER_CHARS.cMiddle, db ' ' |
---|
436 | at BORDER_CHARS.cRight, db DOUBLE_VERTICAL |
---|
437 | iend |
---|