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

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

Initial commit for Assembly Library.

File size: 10.0 KB
RevLine 
[41]1; File name : MenuBorders.asm
2; Project name : Assembly Library
3; Created date : 14.7.2010
4; Last update : 7.9.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 GetNumberOfMiddleCharactersToDX
32 call RefreshTitleBorders
33 call RefreshItemBorders
34 call RefreshInformationBorders
35 call DrawBottomBorderLine
36 call DrawBottomShadowLine
37 jmp MenuTime_DrawWithoutUpdating
38
39
40;--------------------------------------------------------------------
41; MenuBorders_AdjustDisplayContextForDrawingBorders
42; Parameters
43; SS:BP: Ptr to MENU
44; Returns:
45; Nothing
46; Corrupts registers:
47; AX, SI, DI
48;--------------------------------------------------------------------
49ALIGN JUMP_ALIGN
50MenuBorders_AdjustDisplayContextForDrawingBorders:
51 mov ax, MenuCharOut_MenuBorderTeletypeOutputWithAttribute
52 CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
53
54 mov ax, bp
55 CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
56
57 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
58 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
59
60 mov si, ATTRIBUTE_CHARS.cBordersAndBackground
61 jmp MenuAttribute_SetToDisplayContextFromTypeInSI
62
63
64;--------------------------------------------------------------------
65; MenuBorders_RefreshItemBorders
66; Parameters
67; SS:BP: Ptr to MENU
68; Returns:
69; Nothing
70; Corrupts registers:
71; AX, BX, CX, DX, SI, DI
72;--------------------------------------------------------------------
73ALIGN JUMP_ALIGN
74MenuBorders_RefreshItemBorders:
75 call MenuBorders_AdjustDisplayContextForDrawingBorders
76 call MenuLocation_GetItemBordersTopLeftCoordinatesToAX
77 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
78
79 call GetNumberOfMiddleCharactersToDX
80 jmp SHORT RefreshItemBorders
81
82
83;--------------------------------------------------------------------
84; GetNumberOfMiddleCharactersToDX
85; Parameters
86; SS:BP: Ptr to MENU
87; Returns:
88; DX: Number of middle border characters when drawing border lines
89; Corrupts registers:
90; Nothing
91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
93GetNumberOfMiddleCharactersToDX:
94 eMOVZX dx, BYTE [bp+MENUINIT.bWidth]
95 sub dx, BYTE MENU_HORIZONTAL_BORDER_LINES
96 ret
97
98
99;--------------------------------------------------------------------
100; RefreshTitleBorders
101; Parameters
102; DX: Number of times to repeat middle character
103; SS:BP: Ptr to MENU
104; Returns:
105; Nothing
106; Corrupts registers:
107; AX, BX, CX, SI, DI
108;--------------------------------------------------------------------
109ALIGN JUMP_ALIGN
110RefreshTitleBorders:
111 call DrawTopBorderLine
112 eMOVZX cx, BYTE [bp+MENUINIT.bTitleLines]
113 jmp SHORT DrawTextBorderLinesByCXtimes
114
115;--------------------------------------------------------------------
116; RefreshInformationBorders
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
126RefreshInformationBorders:
127 call DrawSeparationBorderLine
128 eMOVZX cx, BYTE [bp+MENUINIT.bInfoLines]
129 jmp SHORT DrawTextBorderLinesByCXtimes
130
131;--------------------------------------------------------------------
132; RefreshItemBorders
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
142RefreshItemBorders:
143 call DrawSeparationBorderLine
144 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
145DrawTextBorderLinesByCXtimes:
146 mov bx, DrawTextBorderLine
147 ; Fall to DrawBorderLinesByCXtimes
148
149;--------------------------------------------------------------------
150; DrawBorderLinesByCXtimes
151; Parameters
152; BX: Offset to border drawing function
153; CX: Number of border lines to draw
154; DX: Number of times to repeat middle character
155; SS:BP: Ptr to MENU
156; Returns:
157; Nothing
158; Corrupts registers:
159; AX, CX, SI, DI
160;--------------------------------------------------------------------
161DrawBorderLinesByCXtimes:
162 jcxz .Return
163ALIGN JUMP_ALIGN
164.DrawBordersWithFunctionInBX:
165 call bx
166 loop .DrawBordersWithFunctionInBX
167.Return:
168 ret
169
170
171;--------------------------------------------------------------------
172; DrawTopBorderLine
173; DrawSeparationBorderLine
174; DrawBottomBorderLine
175; DrawBottomShadowLine
176; DrawTextBorderLine
177; Parameters
178; DX: Number of times to repeat middle character
179; SS:BP: Ptr to MENU
180; Returns:
181; Nothing
182; Corrupts registers:
183; AX, SI, DI
184;--------------------------------------------------------------------
185ALIGN JUMP_ALIGN
186DrawTopBorderLine:
187 mov si, g_rgbTopBorderCharacters
188 call PrintBorderCharactersFromCSSI
189 jmp SHORT PrintNewlineToEndBorderLine
190
191ALIGN JUMP_ALIGN
192DrawSeparationBorderLine:
193 mov si, g_rgbSeparationBorderCharacters
194 jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
195
196ALIGN JUMP_ALIGN
197DrawBottomBorderLine:
198 mov si, g_rgbBottomBorderCharacters
199 jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
200
201ALIGN JUMP_ALIGN
202DrawBottomShadowLine:
203 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
204 inc ax ; Increment column
205 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
206 inc dx ; Increment repeat count...
207 inc dx ; ...for both corner characters
208 call PrintShadowCharactersByDXtimes
209 dec dx ; Restore...
210 dec dx ; ...DX
211 ret
212
213ALIGN JUMP_ALIGN
214DrawTextBorderLine:
215 mov si, g_rgbTextBorderCharacters
216 ; Fall to PrintBorderCharactersFromCSSIandShadowCharacter
217
218;--------------------------------------------------------------------
219; PrintBorderCharactersFromCSSIandShadowCharacter
220; Parameters
221; DX: Number of times to repeat middle character
222; CS:SI: Ptr to BORDER_CHARS
223; SS:BP: Ptr to MENU
224; Returns:
225; Nothing
226; Corrupts registers:
227; AX, SI, DI
228;--------------------------------------------------------------------
229ALIGN JUMP_ALIGN
230PrintBorderCharactersFromCSSIandShadowCharacter:
231 call PrintBorderCharactersFromCSSI
232 push dx
233 mov dx, 1
234 call PrintShadowCharactersByDXtimes
235 pop dx
236 ; Fall to PrintNewlineToEndBorderLine
237
238;--------------------------------------------------------------------
239; PrintNewlineToEndBorderLine
240; Parameters
241; SS:BP: Ptr to MENU
242; Returns:
243; Nothing
244; Corrupts registers:
245; AX, DI
246;--------------------------------------------------------------------
247ALIGN JUMP_ALIGN
248PrintNewlineToEndBorderLine:
249 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
250 ret
251
252
253;--------------------------------------------------------------------
254; PrintShadowCharactersByDXtimes
255; Parameters
256; DX: Number of shadow characters to print
257; SS:BP: Ptr to MENU
258; Returns:
259; Nothing
260; Corrupts registers:
261; AX, SI, DI
262;--------------------------------------------------------------------
263ALIGN JUMP_ALIGN
264PrintShadowCharactersByDXtimes:
265 CALL_DISPLAY_LIBRARY PushDisplayContext
266
267 mov si, ATTRIBUTE_CHARS.cShadow
268 call MenuAttribute_SetToDisplayContextFromTypeInSI
269
270 mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
271 CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
272
273 call PrintMultipleBorderCharactersFromAL ; AL does not matter
274
275 CALL_DISPLAY_LIBRARY PopDisplayContext
276 ret
277
278
279;--------------------------------------------------------------------
280; PrintBorderCharactersFromCSSI
281; Parameters
282; DX: Number of times to repeat middle character
283; CS:SI: Ptr to BORDER_CHARS
284; SS:BP: Ptr to MENU
285; Returns:
286; Nothing
287; Corrupts registers:
288; AX, SI, DI
289;--------------------------------------------------------------------
290ALIGN JUMP_ALIGN
291PrintBorderCharactersFromCSSI:
292 cld
293 eSEG cs
294 lodsb ; Load from [si+BORDER_CHARS.cLeft] to AL
295 call MenuBorders_PrintSingleBorderCharacterFromAL
296
297 eSEG cs
298 lodsb ; Load from [si+BORDER_CHARS.cMiddle] to AL
299 call PrintMultipleBorderCharactersFromAL
300
301 eSEG cs
302 lodsb ; Load from [si+BORDER_CHARS.cRight] to AL
303 ; Fall to MenuBorders_PrintSingleBorderCharacterFromAL
304
305;--------------------------------------------------------------------
306; MenuBorders_PrintSingleBorderCharacterFromAL
307; PrintMultipleBorderCharactersFromAL
308; Parameters
309; AL: Character to print
310; DX: Repeat count (PrintMultipleBorderCharactersFromAL)
311; SS:BP: Ptr to MENU
312; Returns:
313; Nothing
314; Corrupts registers:
315; AX, DI
316;--------------------------------------------------------------------
317ALIGN JUMP_ALIGN
318MenuBorders_PrintSingleBorderCharacterFromAL:
319 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
320 ret
321
322ALIGN JUMP_ALIGN
323PrintMultipleBorderCharactersFromAL:
324 push cx
325 mov cx, dx
326 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
327 pop cx
328 ret
329
330
331
332; Lookup tables for border characters
333g_rgbTopBorderCharacters:
334istruc BORDER_CHARS
335 at BORDER_CHARS.cLeft, db DOUBLE_TOP_LEFT_CORNER
336 at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
337 at BORDER_CHARS.cRight, db DOUBLE_TOP_RIGHT_CORNER
338iend
339
340g_rgbSeparationBorderCharacters:
341istruc BORDER_CHARS
342 at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL_TO_RIGHT_SINGLE
343 at BORDER_CHARS.cMiddle, db SINGLE_HORIZONTAL
344 at BORDER_CHARS.cRight, db DOUBLE_VERTICAL_TO_LEFT_SINGLE
345iend
346
347g_rgbBottomBorderCharacters:
348istruc BORDER_CHARS
349 at BORDER_CHARS.cLeft, db DOUBLE_BOTTOM_LEFT_CORNER
350 at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
351 at BORDER_CHARS.cRight, db DOUBLE_BOTTOM_RIGHT_CORNER
352iend
353
354g_rgbTextBorderCharacters:
355istruc BORDER_CHARS
356 at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL
357 at BORDER_CHARS.cMiddle, db ' '
358 at BORDER_CHARS.cRight, db DOUBLE_VERTICAL
359iend
Note: See TracBrowser for help on using the repository browser.