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

Last change on this file since 500 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 13.5 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for drawing menu borders.
3
[376]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
[41]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;--------------------------------------------------------------------
[369]41ALIGN MENU_JUMP_ALIGN
[41]42MenuBorders_RefreshAll:
[223]43%ifndef USE_186
[41]44 call MenuBorders_AdjustDisplayContextForDrawingBorders
[67]45 call MenuBorders_GetNumberOfMiddleCharactersToDX
[41]46 call RefreshTitleBorders
47 call RefreshItemBorders
48 call RefreshInformationBorders
49 call DrawBottomBorderLine
[60]50 jmp DrawBottomShadowLine
[223]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
[41]60
61
62;--------------------------------------------------------------------
[60]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;--------------------------------------------------------------------
[369]71ALIGN MENU_JUMP_ALIGN
[60]72MenuBorders_RedrawBottomBorderLine:
73 call MenuBorders_AdjustDisplayContextForDrawingBorders
74 call MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
75 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
[67]76 call MenuBorders_GetNumberOfMiddleCharactersToDX
[62]77 jmp SHORT DrawBottomBorderLine
[60]78
79
80;--------------------------------------------------------------------
[104]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;--------------------------------------------------------------------
[194]89%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]90ALIGN MENU_JUMP_ALIGN
[104]91MenuBorders_RefreshItemBorders:
92 call MenuBorders_AdjustDisplayContextForDrawingBorders
93 call MenuLocation_GetItemBordersTopLeftCoordinatesToAX
94 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
95
96 call MenuBorders_GetNumberOfMiddleCharactersToDX
97 jmp SHORT RefreshItemBorders
[194]98%endif
[104]99
[223]100
[104]101;--------------------------------------------------------------------
[41]102; MenuBorders_AdjustDisplayContextForDrawingBorders
103; Parameters
104; SS:BP: Ptr to MENU
105; Returns:
106; Nothing
107; Corrupts registers:
[45]108; AX, BX, SI, DI
[41]109;--------------------------------------------------------------------
[369]110ALIGN MENU_JUMP_ALIGN
[41]111MenuBorders_AdjustDisplayContextForDrawingBorders:
[45]112 mov bl, ATTRIBUTES_ARE_USED
[52]113 mov ax, MenuCharOut_MenuTeletypeOutput
[45]114 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
[41]115
[52]116 call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
[41]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;--------------------------------------------------------------------
[67]127; MenuBorders_GetNumberOfMiddleCharactersToDX
[41]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;--------------------------------------------------------------------
[369]135ALIGN MENU_JUMP_ALIGN
[67]136MenuBorders_GetNumberOfMiddleCharactersToDX:
[293]137 eMOVZX dx, [bp+MENUINIT.bWidth]
[41]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;--------------------------------------------------------------------
[369]152ALIGN MENU_JUMP_ALIGN
[41]153RefreshTitleBorders:
154 call DrawTopBorderLine
[293]155 eMOVZX cx, [bp+MENUINIT.bTitleLines]
[41]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;--------------------------------------------------------------------
[369]168ALIGN MENU_JUMP_ALIGN
[41]169RefreshInformationBorders:
170 call DrawSeparationBorderLine
[293]171 eMOVZX cx, [bp+MENUINIT.bInfoLines]
[41]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;--------------------------------------------------------------------
[369]184ALIGN MENU_JUMP_ALIGN
[41]185RefreshItemBorders:
186 call DrawSeparationBorderLine
187 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
[104]188 ; Fall to DrawTextBorderLinesByCXtimes
[41]189
190;--------------------------------------------------------------------
[104]191; DrawTextBorderLinesByCXtimes
[41]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;--------------------------------------------------------------------
[104]201DrawTextBorderLinesByCXtimes:
202 jcxz .NoBorderLinesToDraw
[369]203ALIGN MENU_JUMP_ALIGN
[41]204.DrawBordersWithFunctionInBX:
[104]205 call DrawTextBorderLine
[41]206 loop .DrawBordersWithFunctionInBX
[104]207.NoBorderLinesToDraw:
[41]208 ret
209
210
211;--------------------------------------------------------------------
212; DrawTopBorderLine
213; DrawSeparationBorderLine
214; DrawBottomBorderLine
[60]215; DrawTimeoutCounterOverBottomBorderLine
[41]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;--------------------------------------------------------------------
[369]226ALIGN MENU_JUMP_ALIGN
[41]227DrawTopBorderLine:
228 mov si, g_rgbTopBorderCharacters
229 call PrintBorderCharactersFromCSSI
230 jmp SHORT PrintNewlineToEndBorderLine
231
[369]232ALIGN MENU_JUMP_ALIGN
[41]233DrawSeparationBorderLine:
234 mov si, g_rgbSeparationBorderCharacters
235 jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
236
[369]237ALIGN MENU_JUMP_ALIGN
[41]238DrawBottomBorderLine:
239 mov si, g_rgbBottomBorderCharacters
[62]240 test BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
241 jz SHORT PrintBorderCharactersFromCSSIandShadowCharacter
[41]242
[62]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
[60]248 ret
249
[369]250ALIGN MENU_JUMP_ALIGN
[41]251DrawBottomShadowLine:
[104]252 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
253 inc ax ; Move one column left
254 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
[41]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
[369]262ALIGN MENU_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]278ALIGN MENU_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]296ALIGN MENU_JUMP_ALIGN
[41]297PrintNewlineToEndBorderLine:
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;--------------------------------------------------------------------
[369]312ALIGN MENU_JUMP_ALIGN
[41]313PrintShadowCharactersByDXtimes:
314 CALL_DISPLAY_LIBRARY PushDisplayContext
315
316 mov si, ATTRIBUTE_CHARS.cShadow
317 call MenuAttribute_SetToDisplayContextFromTypeInSI
318
[45]319 push bx
320 mov bl, ATTRIBUTES_ARE_USED
[41]321 mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
[45]322 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
323 pop bx
[41]324
[67]325 call MenuBorders_PrintMultipleBorderCharactersFromAL ; AL does not matter
[41]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;--------------------------------------------------------------------
[369]342ALIGN MENU_JUMP_ALIGN
[41]343PrintBorderCharactersFromCSSI:
[223]344 cs lodsb ; Load from [cs:si+BORDER_CHARS.cLeft] to AL
[41]345 call MenuBorders_PrintSingleBorderCharacterFromAL
346
[223]347 cs lodsb ; Load from [cs:si+BORDER_CHARS.cMiddle] to AL
[67]348 call MenuBorders_PrintMultipleBorderCharactersFromAL
[41]349
[223]350 cs lodsb ; Load from [cs:si+BORDER_CHARS.cRight] to AL
[41]351 ; Fall to MenuBorders_PrintSingleBorderCharacterFromAL
352
353;--------------------------------------------------------------------
354; MenuBorders_PrintSingleBorderCharacterFromAL
[67]355; MenuBorders_PrintMultipleBorderCharactersFromAL
[41]356; Parameters
357; AL: Character to print
[67]358; DX: Repeat count (MenuBorders_PrintMultipleBorderCharactersFromAL)
[41]359; SS:BP: Ptr to MENU
360; Returns:
361; Nothing
362; Corrupts registers:
363; AX, DI
364;--------------------------------------------------------------------
[369]365ALIGN MENU_JUMP_ALIGN
[41]366MenuBorders_PrintSingleBorderCharacterFromAL:
367 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
368 ret
369
[369]370ALIGN MENU_JUMP_ALIGN
[67]371MenuBorders_PrintMultipleBorderCharactersFromAL:
[41]372 push cx
373 mov cx, dx
374 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
375 pop cx
376 ret
377
378
[60]379;--------------------------------------------------------------------
[62]380; DrawTimeoutCounterString
[60]381; Parameters
[62]382; SS:BP: Ptr to MENU
383; Returns:
384; Nothing
385; Corrupts registers:
386; AX, SI, DI
387;--------------------------------------------------------------------
[369]388ALIGN MENU_JUMP_ALIGN
[62]389DrawTimeoutCounterString:
390 call MenuTime_GetTimeoutSecondsLeftToAX
391 ; Fall to .PrintTimeoutStringWithSecondsInAX
392
393;--------------------------------------------------------------------
394; .PrintTimeoutStringWithSecondsInAX
395; Parameters
[60]396; AX: Seconds to print
397; SS:BP: Ptr to MENU
398; Returns:
399; Nothing
400; Corrupts registers:
401; AX, SI, DI
402;--------------------------------------------------------------------
[62]403.PrintTimeoutStringWithSecondsInAX:
[104]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
[60]411 push bp
412 mov bp, sp
[182]413 mov si, g_szSelectionTimeout
[60]414 push ax ; Push attribute
415 push di ; Push seconds
416 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
417 pop bp
[62]418 ret
[60]419
[41]420; Lookup tables for border characters
421g_rgbTopBorderCharacters:
422istruc 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
426iend
427
428g_rgbSeparationBorderCharacters:
429istruc 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
433iend
434
435g_rgbBottomBorderCharacters:
436istruc 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
440iend
441
[62]442g_BottomBorderWithTimeoutCharacters:
443istruc 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
447iend
448
[41]449g_rgbTextBorderCharacters:
450istruc BORDER_CHARS
451 at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL
452 at BORDER_CHARS.cMiddle, db ' '
453 at BORDER_CHARS.cRight, db DOUBLE_VERTICAL
454iend
Note: See TracBrowser for help on using the repository browser.