source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuBorders.asm@ 527

Last change on this file since 527 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 13.4 KB
Line 
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-2013 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
22struc BORDER_CHARS
23 .cLeft resb 1
24 .cMiddle resb 1
25 .cRight resb 1
26endstruc
27
28
29; Section containing code
30SECTION .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;--------------------------------------------------------------------
41ALIGN MENU_JUMP_ALIGN
42MenuBorders_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;--------------------------------------------------------------------
71ALIGN MENU_JUMP_ALIGN
72MenuBorders_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
90ALIGN MENU_JUMP_ALIGN
91MenuBorders_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;--------------------------------------------------------------------
110ALIGN MENU_JUMP_ALIGN
111MenuBorders_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;--------------------------------------------------------------------
135ALIGN MENU_JUMP_ALIGN
136MenuBorders_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;--------------------------------------------------------------------
152ALIGN MENU_JUMP_ALIGN
153RefreshTitleBorders:
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;--------------------------------------------------------------------
168ALIGN MENU_JUMP_ALIGN
169RefreshInformationBorders:
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;--------------------------------------------------------------------
184ALIGN MENU_JUMP_ALIGN
185RefreshItemBorders:
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;--------------------------------------------------------------------
201DrawTextBorderLinesByCXtimes:
202 jcxz .NoBorderLinesToDraw
203ALIGN 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;--------------------------------------------------------------------
226ALIGN MENU_JUMP_ALIGN
227DrawTopBorderLine:
228 mov si, g_rgbTopBorderCharacters
229 call PrintBorderCharactersFromCSSI
230 jmp SHORT PrintNewlineToEndBorderLine
231
232ALIGN MENU_JUMP_ALIGN
233DrawSeparationBorderLine:
234 mov si, g_rgbSeparationBorderCharacters
235 jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
236
237ALIGN MENU_JUMP_ALIGN
238DrawBottomBorderLine:
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
250ALIGN MENU_JUMP_ALIGN
251DrawBottomShadowLine:
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
262ALIGN MENU_JUMP_ALIGN
263DrawTextBorderLine:
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;--------------------------------------------------------------------
278ALIGN MENU_JUMP_ALIGN
279PrintBorderCharactersFromCSSIandShadowCharacter:
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;--------------------------------------------------------------------
296ALIGN MENU_JUMP_ALIGN
297PrintNewlineToEndBorderLine:
298 JMP_DISPLAY_LIBRARY PrintNewlineCharacters
299
300
301;--------------------------------------------------------------------
302; PrintShadowCharactersByDXtimes
303; Parameters
304; DX: Number of shadow characters to print
305; SS:BP: Ptr to MENU
306; Returns:
307; Nothing
308; Corrupts registers:
309; AX, SI, DI
310;--------------------------------------------------------------------
311ALIGN MENU_JUMP_ALIGN
312PrintShadowCharactersByDXtimes:
313 CALL_DISPLAY_LIBRARY PushDisplayContext
314
315 mov si, ATTRIBUTE_CHARS.cShadow
316 call MenuAttribute_SetToDisplayContextFromTypeInSI
317
318 push bx
319 mov bl, ATTRIBUTES_ARE_USED
320 mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
321 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
322 pop bx
323
324 call MenuBorders_PrintMultipleBorderCharactersFromAL ; AL does not matter
325
326 JMP_DISPLAY_LIBRARY PopDisplayContext
327
328
329;--------------------------------------------------------------------
330; PrintBorderCharactersFromCSSI
331; Parameters
332; DX: Number of times to repeat middle character
333; CS:SI: Ptr to BORDER_CHARS
334; SS:BP: Ptr to MENU
335; Returns:
336; Nothing
337; Corrupts registers:
338; AX, SI, DI
339;--------------------------------------------------------------------
340ALIGN MENU_JUMP_ALIGN
341PrintBorderCharactersFromCSSI:
342 cs lodsb ; Load from [cs:si+BORDER_CHARS.cLeft] to AL
343 call MenuBorders_PrintSingleBorderCharacterFromAL
344
345 cs lodsb ; Load from [cs:si+BORDER_CHARS.cMiddle] to AL
346 call MenuBorders_PrintMultipleBorderCharactersFromAL
347
348 cs lodsb ; Load from [cs:si+BORDER_CHARS.cRight] to AL
349 ; Fall to MenuBorders_PrintSingleBorderCharacterFromAL
350
351;--------------------------------------------------------------------
352; MenuBorders_PrintSingleBorderCharacterFromAL
353; MenuBorders_PrintMultipleBorderCharactersFromAL
354; Parameters
355; AL: Character to print
356; DX: Repeat count (MenuBorders_PrintMultipleBorderCharactersFromAL)
357; SS:BP: Ptr to MENU
358; Returns:
359; Nothing
360; Corrupts registers:
361; AX, DI
362;--------------------------------------------------------------------
363ALIGN MENU_JUMP_ALIGN
364MenuBorders_PrintSingleBorderCharacterFromAL:
365 JMP_DISPLAY_LIBRARY PrintCharacterFromAL
366
367ALIGN MENU_JUMP_ALIGN
368MenuBorders_PrintMultipleBorderCharactersFromAL:
369 push cx
370 mov cx, dx
371 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
372 pop cx
373 ret
374
375
376;--------------------------------------------------------------------
377; DrawTimeoutCounterString
378; Parameters
379; SS:BP: Ptr to MENU
380; Returns:
381; Nothing
382; Corrupts registers:
383; AX, SI, DI
384;--------------------------------------------------------------------
385ALIGN MENU_JUMP_ALIGN
386DrawTimeoutCounterString:
387 call MenuTime_GetTimeoutSecondsLeftToAX
388 ; Fall to .PrintTimeoutStringWithSecondsInAX
389
390;--------------------------------------------------------------------
391; .PrintTimeoutStringWithSecondsInAX
392; Parameters
393; AX: Seconds to print
394; SS:BP: Ptr to MENU
395; Returns:
396; Nothing
397; Corrupts registers:
398; AX, SI, DI
399;--------------------------------------------------------------------
400.PrintTimeoutStringWithSecondsInAX:
401 ; Get attribute to AX
402 xchg di, ax
403 mov si, ATTRIBUTE_CHARS.cNormalTimeout
404 cmp di, BYTE MENU_TIMEOUT_SECONDS_FOR_HURRY
405 eCMOVB si, ATTRIBUTE_CHARS.cHurryTimeout
406 call MenuAttribute_GetToAXfromTypeInSI
407
408 push bp
409 mov bp, sp
410 mov si, g_szSelectionTimeout
411 push ax ; Push attribute
412 push di ; Push seconds
413 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
414 pop bp
415 ret
416
417; Lookup tables for border characters
418g_rgbTopBorderCharacters:
419istruc BORDER_CHARS
420 at BORDER_CHARS.cLeft, db DOUBLE_TOP_LEFT_CORNER
421 at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
422 at BORDER_CHARS.cRight, db DOUBLE_TOP_RIGHT_CORNER
423iend
424
425g_rgbSeparationBorderCharacters:
426istruc BORDER_CHARS
427 at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL_TO_RIGHT_SINGLE
428 at BORDER_CHARS.cMiddle, db SINGLE_HORIZONTAL
429 at BORDER_CHARS.cRight, db DOUBLE_VERTICAL_TO_LEFT_SINGLE
430iend
431
432g_rgbBottomBorderCharacters:
433istruc BORDER_CHARS
434 at BORDER_CHARS.cLeft, db DOUBLE_BOTTOM_LEFT_CORNER
435 at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
436 at BORDER_CHARS.cRight, db DOUBLE_BOTTOM_RIGHT_CORNER
437iend
438
439g_BottomBorderWithTimeoutCharacters:
440istruc BORDER_CHARS
441 at BORDER_CHARS.cLeft, db DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL
442 at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
443 at BORDER_CHARS.cRight, db DOUBLE_BOTTOM_RIGHT_CORNER
444iend
445
446g_rgbTextBorderCharacters:
447istruc BORDER_CHARS
448 at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL
449 at BORDER_CHARS.cMiddle, db ' '
450 at BORDER_CHARS.cRight, db DOUBLE_VERTICAL
451iend
Note: See TracBrowser for help on using the repository browser.