source: xtideuniversalbios/tags/Assembly_Library_for_v2.0.0beta1/Src/Menu/MenuBorders.asm@ 579

Last change on this file since 579 was 293, checked in by krille_n_@…, 12 years ago

Commit 1/2 (Library, Configurators and Serial Server):

  • Changed Emulate.inc so that making 286 and 386 versions now works. Additionally, only one processor type define is needed in the makefile.
  • Minor optimizations.
  • Fixed spelling and did some cleaning.
File size: 12.7 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%ifndef USE_186
27 call MenuBorders_AdjustDisplayContextForDrawingBorders
28 call MenuBorders_GetNumberOfMiddleCharactersToDX
29 call RefreshTitleBorders
30 call RefreshItemBorders
31 call RefreshInformationBorders
32 call DrawBottomBorderLine
33 jmp DrawBottomShadowLine
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
43
44
45;--------------------------------------------------------------------
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;--------------------------------------------------------------------
54ALIGN JUMP_ALIGN
55MenuBorders_RedrawBottomBorderLine:
56 call MenuBorders_AdjustDisplayContextForDrawingBorders
57 call MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
58 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
59 call MenuBorders_GetNumberOfMiddleCharactersToDX
60 jmp SHORT DrawBottomBorderLine
61
62
63;--------------------------------------------------------------------
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;--------------------------------------------------------------------
72%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
73ALIGN JUMP_ALIGN
74MenuBorders_RefreshItemBorders:
75 call MenuBorders_AdjustDisplayContextForDrawingBorders
76 call MenuLocation_GetItemBordersTopLeftCoordinatesToAX
77 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
78
79 call MenuBorders_GetNumberOfMiddleCharactersToDX
80 jmp SHORT RefreshItemBorders
81%endif
82
83
84;--------------------------------------------------------------------
85; MenuBorders_AdjustDisplayContextForDrawingBorders
86; Parameters
87; SS:BP: Ptr to MENU
88; Returns:
89; Nothing
90; Corrupts registers:
91; AX, BX, SI, DI
92;--------------------------------------------------------------------
93ALIGN JUMP_ALIGN
94MenuBorders_AdjustDisplayContextForDrawingBorders:
95 mov bl, ATTRIBUTES_ARE_USED
96 mov ax, MenuCharOut_MenuTeletypeOutput
97 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
98
99 call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
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;--------------------------------------------------------------------
110; MenuBorders_GetNumberOfMiddleCharactersToDX
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;--------------------------------------------------------------------
118ALIGN JUMP_ALIGN
119MenuBorders_GetNumberOfMiddleCharactersToDX:
120 eMOVZX dx, [bp+MENUINIT.bWidth]
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;--------------------------------------------------------------------
135ALIGN JUMP_ALIGN
136RefreshTitleBorders:
137 call DrawTopBorderLine
138 eMOVZX cx, [bp+MENUINIT.bTitleLines]
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;--------------------------------------------------------------------
151ALIGN JUMP_ALIGN
152RefreshInformationBorders:
153 call DrawSeparationBorderLine
154 eMOVZX cx, [bp+MENUINIT.bInfoLines]
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;--------------------------------------------------------------------
167ALIGN JUMP_ALIGN
168RefreshItemBorders:
169 call DrawSeparationBorderLine
170 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
171 ; Fall to DrawTextBorderLinesByCXtimes
172
173;--------------------------------------------------------------------
174; DrawTextBorderLinesByCXtimes
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;--------------------------------------------------------------------
184DrawTextBorderLinesByCXtimes:
185 jcxz .NoBorderLinesToDraw
186ALIGN JUMP_ALIGN
187.DrawBordersWithFunctionInBX:
188 call DrawTextBorderLine
189 loop .DrawBordersWithFunctionInBX
190.NoBorderLinesToDraw:
191 ret
192
193
194;--------------------------------------------------------------------
195; DrawTopBorderLine
196; DrawSeparationBorderLine
197; DrawBottomBorderLine
198; DrawTimeoutCounterOverBottomBorderLine
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;--------------------------------------------------------------------
209ALIGN JUMP_ALIGN
210DrawTopBorderLine:
211 mov si, g_rgbTopBorderCharacters
212 call PrintBorderCharactersFromCSSI
213 jmp SHORT PrintNewlineToEndBorderLine
214
215ALIGN JUMP_ALIGN
216DrawSeparationBorderLine:
217 mov si, g_rgbSeparationBorderCharacters
218 jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
219
220ALIGN JUMP_ALIGN
221DrawBottomBorderLine:
222 mov si, g_rgbBottomBorderCharacters
223 test BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
224 jz SHORT PrintBorderCharactersFromCSSIandShadowCharacter
225
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
231 ret
232
233ALIGN JUMP_ALIGN
234DrawBottomShadowLine:
235 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
236 inc ax ; Move one column left
237 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
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
245ALIGN JUMP_ALIGN
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;--------------------------------------------------------------------
261ALIGN JUMP_ALIGN
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;--------------------------------------------------------------------
279ALIGN JUMP_ALIGN
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;--------------------------------------------------------------------
295ALIGN JUMP_ALIGN
296PrintShadowCharactersByDXtimes:
297 CALL_DISPLAY_LIBRARY PushDisplayContext
298
299 mov si, ATTRIBUTE_CHARS.cShadow
300 call MenuAttribute_SetToDisplayContextFromTypeInSI
301
302 push bx
303 mov bl, ATTRIBUTES_ARE_USED
304 mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
305 CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
306 pop bx
307
308 call MenuBorders_PrintMultipleBorderCharactersFromAL ; AL does not matter
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;--------------------------------------------------------------------
325ALIGN JUMP_ALIGN
326PrintBorderCharactersFromCSSI:
327 cs lodsb ; Load from [cs:si+BORDER_CHARS.cLeft] to AL
328 call MenuBorders_PrintSingleBorderCharacterFromAL
329
330 cs lodsb ; Load from [cs:si+BORDER_CHARS.cMiddle] to AL
331 call MenuBorders_PrintMultipleBorderCharactersFromAL
332
333 cs lodsb ; Load from [cs:si+BORDER_CHARS.cRight] to AL
334 ; Fall to MenuBorders_PrintSingleBorderCharacterFromAL
335
336;--------------------------------------------------------------------
337; MenuBorders_PrintSingleBorderCharacterFromAL
338; MenuBorders_PrintMultipleBorderCharactersFromAL
339; Parameters
340; AL: Character to print
341; DX: Repeat count (MenuBorders_PrintMultipleBorderCharactersFromAL)
342; SS:BP: Ptr to MENU
343; Returns:
344; Nothing
345; Corrupts registers:
346; AX, DI
347;--------------------------------------------------------------------
348ALIGN JUMP_ALIGN
349MenuBorders_PrintSingleBorderCharacterFromAL:
350 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
351 ret
352
353ALIGN JUMP_ALIGN
354MenuBorders_PrintMultipleBorderCharactersFromAL:
355 push cx
356 mov cx, dx
357 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
358 pop cx
359 ret
360
361
362;--------------------------------------------------------------------
363; DrawTimeoutCounterString
364; Parameters
365; SS:BP: Ptr to MENU
366; Returns:
367; Nothing
368; Corrupts registers:
369; AX, SI, DI
370;--------------------------------------------------------------------
371ALIGN JUMP_ALIGN
372DrawTimeoutCounterString:
373 call MenuTime_GetTimeoutSecondsLeftToAX
374 ; Fall to .PrintTimeoutStringWithSecondsInAX
375
376;--------------------------------------------------------------------
377; .PrintTimeoutStringWithSecondsInAX
378; Parameters
379; AX: Seconds to print
380; SS:BP: Ptr to MENU
381; Returns:
382; Nothing
383; Corrupts registers:
384; AX, SI, DI
385;--------------------------------------------------------------------
386.PrintTimeoutStringWithSecondsInAX:
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
394 push bp
395 mov bp, sp
396 mov si, g_szSelectionTimeout
397 push ax ; Push attribute
398 push di ; Push seconds
399 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
400 pop bp
401 ret
402
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
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
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.