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

Last change on this file since 371 was 369, checked in by gregli@…, 12 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 12.8 KB
RevLine 
[41]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
5struc BORDER_CHARS
6 .cLeft resb 1
7 .cMiddle resb 1
8 .cRight resb 1
9endstruc
10
11
12; Section containing code
13SECTION .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;--------------------------------------------------------------------
[369]24ALIGN MENU_JUMP_ALIGN
[41]25MenuBorders_RefreshAll:
[223]26%ifndef USE_186
[41]27 call MenuBorders_AdjustDisplayContextForDrawingBorders
[67]28 call MenuBorders_GetNumberOfMiddleCharactersToDX
[41]29 call RefreshTitleBorders
30 call RefreshItemBorders
31 call RefreshInformationBorders
32 call DrawBottomBorderLine
[60]33 jmp DrawBottomShadowLine
[223]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
[41]43
44
45;--------------------------------------------------------------------
[60]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;--------------------------------------------------------------------
[369]54ALIGN MENU_JUMP_ALIGN
[60]55MenuBorders_RedrawBottomBorderLine:
56 call MenuBorders_AdjustDisplayContextForDrawingBorders
57 call MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
58 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
[67]59 call MenuBorders_GetNumberOfMiddleCharactersToDX
[62]60 jmp SHORT DrawBottomBorderLine
[60]61
62
63;--------------------------------------------------------------------
[104]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;--------------------------------------------------------------------
[194]72%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]73ALIGN MENU_JUMP_ALIGN
[104]74MenuBorders_RefreshItemBorders:
75 call MenuBorders_AdjustDisplayContextForDrawingBorders
76 call MenuLocation_GetItemBordersTopLeftCoordinatesToAX
77 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
78
79 call MenuBorders_GetNumberOfMiddleCharactersToDX
80 jmp SHORT RefreshItemBorders
[194]81%endif
[104]82
[223]83
[104]84;--------------------------------------------------------------------
[41]85; MenuBorders_AdjustDisplayContextForDrawingBorders
86; Parameters
87; SS:BP: Ptr to MENU
88; Returns:
89; Nothing
90; Corrupts registers:
[45]91; AX, BX, SI, DI
[41]92;--------------------------------------------------------------------
[369]93ALIGN MENU_JUMP_ALIGN
[41]94MenuBorders_AdjustDisplayContextForDrawingBorders:
[45]95 mov bl, ATTRIBUTES_ARE_USED
[52]96 mov ax, MenuCharOut_MenuTeletypeOutput
[45]97 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
[41]98
[52]99 call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
[41]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;--------------------------------------------------------------------
[67]110; MenuBorders_GetNumberOfMiddleCharactersToDX
[41]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;--------------------------------------------------------------------
[369]118ALIGN MENU_JUMP_ALIGN
[67]119MenuBorders_GetNumberOfMiddleCharactersToDX:
[293]120 eMOVZX dx, [bp+MENUINIT.bWidth]
[41]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;--------------------------------------------------------------------
[369]135ALIGN MENU_JUMP_ALIGN
[41]136RefreshTitleBorders:
137 call DrawTopBorderLine
[293]138 eMOVZX cx, [bp+MENUINIT.bTitleLines]
[41]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;--------------------------------------------------------------------
[369]151ALIGN MENU_JUMP_ALIGN
[41]152RefreshInformationBorders:
153 call DrawSeparationBorderLine
[293]154 eMOVZX cx, [bp+MENUINIT.bInfoLines]
[41]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;--------------------------------------------------------------------
[369]167ALIGN MENU_JUMP_ALIGN
[41]168RefreshItemBorders:
169 call DrawSeparationBorderLine
170 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
[104]171 ; Fall to DrawTextBorderLinesByCXtimes
[41]172
173;--------------------------------------------------------------------
[104]174; DrawTextBorderLinesByCXtimes
[41]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;--------------------------------------------------------------------
[104]184DrawTextBorderLinesByCXtimes:
185 jcxz .NoBorderLinesToDraw
[369]186ALIGN MENU_JUMP_ALIGN
[41]187.DrawBordersWithFunctionInBX:
[104]188 call DrawTextBorderLine
[41]189 loop .DrawBordersWithFunctionInBX
[104]190.NoBorderLinesToDraw:
[41]191 ret
192
193
194;--------------------------------------------------------------------
195; DrawTopBorderLine
196; DrawSeparationBorderLine
197; DrawBottomBorderLine
[60]198; DrawTimeoutCounterOverBottomBorderLine
[41]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;--------------------------------------------------------------------
[369]209ALIGN MENU_JUMP_ALIGN
[41]210DrawTopBorderLine:
211 mov si, g_rgbTopBorderCharacters
212 call PrintBorderCharactersFromCSSI
213 jmp SHORT PrintNewlineToEndBorderLine
214
[369]215ALIGN MENU_JUMP_ALIGN
[41]216DrawSeparationBorderLine:
217 mov si, g_rgbSeparationBorderCharacters
218 jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
219
[369]220ALIGN MENU_JUMP_ALIGN
[41]221DrawBottomBorderLine:
222 mov si, g_rgbBottomBorderCharacters
[62]223 test BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
224 jz SHORT PrintBorderCharactersFromCSSIandShadowCharacter
[41]225
[62]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
[60]231 ret
232
[369]233ALIGN MENU_JUMP_ALIGN
[41]234DrawBottomShadowLine:
[104]235 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
236 inc ax ; Move one column left
237 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
[41]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
[369]245ALIGN MENU_JUMP_ALIGN
[41]246DrawTextBorderLine:
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;--------------------------------------------------------------------
[369]261ALIGN MENU_JUMP_ALIGN
[41]262PrintBorderCharactersFromCSSIandShadowCharacter:
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;--------------------------------------------------------------------
[369]279ALIGN MENU_JUMP_ALIGN
[41]280PrintNewlineToEndBorderLine:
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;--------------------------------------------------------------------
[369]295ALIGN MENU_JUMP_ALIGN
[41]296PrintShadowCharactersByDXtimes:
297 CALL_DISPLAY_LIBRARY PushDisplayContext
298
299 mov si, ATTRIBUTE_CHARS.cShadow
300 call MenuAttribute_SetToDisplayContextFromTypeInSI
301
[45]302 push bx
303 mov bl, ATTRIBUTES_ARE_USED
[41]304 mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
[45]305 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
306 pop bx
[41]307
[67]308 call MenuBorders_PrintMultipleBorderCharactersFromAL ; AL does not matter
[41]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;--------------------------------------------------------------------
[369]325ALIGN MENU_JUMP_ALIGN
[41]326PrintBorderCharactersFromCSSI:
[223]327 cs lodsb ; Load from [cs:si+BORDER_CHARS.cLeft] to AL
[41]328 call MenuBorders_PrintSingleBorderCharacterFromAL
329
[223]330 cs lodsb ; Load from [cs:si+BORDER_CHARS.cMiddle] to AL
[67]331 call MenuBorders_PrintMultipleBorderCharactersFromAL
[41]332
[223]333 cs lodsb ; Load from [cs:si+BORDER_CHARS.cRight] to AL
[41]334 ; Fall to MenuBorders_PrintSingleBorderCharacterFromAL
335
336;--------------------------------------------------------------------
337; MenuBorders_PrintSingleBorderCharacterFromAL
[67]338; MenuBorders_PrintMultipleBorderCharactersFromAL
[41]339; Parameters
340; AL: Character to print
[67]341; DX: Repeat count (MenuBorders_PrintMultipleBorderCharactersFromAL)
[41]342; SS:BP: Ptr to MENU
343; Returns:
344; Nothing
345; Corrupts registers:
346; AX, DI
347;--------------------------------------------------------------------
[369]348ALIGN MENU_JUMP_ALIGN
[41]349MenuBorders_PrintSingleBorderCharacterFromAL:
350 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
351 ret
352
[369]353ALIGN MENU_JUMP_ALIGN
[67]354MenuBorders_PrintMultipleBorderCharactersFromAL:
[41]355 push cx
356 mov cx, dx
357 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
358 pop cx
359 ret
360
361
[60]362;--------------------------------------------------------------------
[62]363; DrawTimeoutCounterString
[60]364; Parameters
[62]365; SS:BP: Ptr to MENU
366; Returns:
367; Nothing
368; Corrupts registers:
369; AX, SI, DI
370;--------------------------------------------------------------------
[369]371ALIGN MENU_JUMP_ALIGN
[62]372DrawTimeoutCounterString:
373 call MenuTime_GetTimeoutSecondsLeftToAX
374 ; Fall to .PrintTimeoutStringWithSecondsInAX
375
376;--------------------------------------------------------------------
377; .PrintTimeoutStringWithSecondsInAX
378; Parameters
[60]379; AX: Seconds to print
380; SS:BP: Ptr to MENU
381; Returns:
382; Nothing
383; Corrupts registers:
384; AX, SI, DI
385;--------------------------------------------------------------------
[62]386.PrintTimeoutStringWithSecondsInAX:
[104]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
[60]394 push bp
395 mov bp, sp
[182]396 mov si, g_szSelectionTimeout
[60]397 push ax ; Push attribute
398 push di ; Push seconds
399 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
400 pop bp
[62]401 ret
[60]402
[41]403; Lookup tables for border characters
404g_rgbTopBorderCharacters:
405istruc 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
409iend
410
411g_rgbSeparationBorderCharacters:
412istruc 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
416iend
417
418g_rgbBottomBorderCharacters:
419istruc 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
423iend
424
[62]425g_BottomBorderWithTimeoutCharacters:
426istruc 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
430iend
431
[41]432g_rgbTextBorderCharacters:
433istruc BORDER_CHARS
434 at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL
435 at BORDER_CHARS.cMiddle, db ' '
436 at BORDER_CHARS.cRight, db DOUBLE_VERTICAL
437iend
Note: See TracBrowser for help on using the repository browser.