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

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

Changes to assembly library:
Changed SetCharOutputFunctionFromAXwithAttribFlagInDL to SetCharOutputFunctionFromAXwithAttribFlagInBL since DX register gets corrupted by Display_FunctionFromDI.
Implemented quicksort.

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