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

Last change on this file since 167 was 105, checked in by Tomi Tilli, 13 years ago

Changes to Assembly Library:

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