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

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

ifdef'd out more unused code. Also added a tool for looking through the listing and the output of the precompiler to aid in finding dead code. Some changes in the files are to add annotations for the tool to avoid false positives.

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