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

Last change on this file since 76 was 67, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

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