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