1 | ; File name : MenuBorders.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 14.7.2010
|
---|
4 | ; Last update : 27.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
|
---|
9 | struc BORDER_CHARS
|
---|
10 | .cLeft resb 1
|
---|
11 | .cMiddle resb 1
|
---|
12 | .cRight resb 1
|
---|
13 | endstruc
|
---|
14 |
|
---|
15 |
|
---|
16 | ; Section containing code
|
---|
17 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
28 | ALIGN JUMP_ALIGN
|
---|
29 | MenuBorders_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, DX, SI, DI
|
---|
48 | ;--------------------------------------------------------------------
|
---|
49 | ALIGN JUMP_ALIGN
|
---|
50 | MenuBorders_AdjustDisplayContextForDrawingBorders:
|
---|
51 | mov dl, ATTRIBUTES_ARE_USED
|
---|
52 | mov ax, MenuCharOut_MenuBorderTeletypeOutputWithAttribute
|
---|
53 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInDL
|
---|
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 | ;--------------------------------------------------------------------
|
---|
74 | ALIGN JUMP_ALIGN
|
---|
75 | MenuBorders_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 | ;--------------------------------------------------------------------
|
---|
93 | ALIGN JUMP_ALIGN
|
---|
94 | GetNumberOfMiddleCharactersToDX:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
110 | ALIGN JUMP_ALIGN
|
---|
111 | RefreshTitleBorders:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
126 | ALIGN JUMP_ALIGN
|
---|
127 | RefreshInformationBorders:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
142 | ALIGN JUMP_ALIGN
|
---|
143 | RefreshItemBorders:
|
---|
144 | call DrawSeparationBorderLine
|
---|
145 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
146 | DrawTextBorderLinesByCXtimes:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
162 | DrawBorderLinesByCXtimes:
|
---|
163 | jcxz .Return
|
---|
164 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
186 | ALIGN JUMP_ALIGN
|
---|
187 | DrawTopBorderLine:
|
---|
188 | mov si, g_rgbTopBorderCharacters
|
---|
189 | call PrintBorderCharactersFromCSSI
|
---|
190 | jmp SHORT PrintNewlineToEndBorderLine
|
---|
191 |
|
---|
192 | ALIGN JUMP_ALIGN
|
---|
193 | DrawSeparationBorderLine:
|
---|
194 | mov si, g_rgbSeparationBorderCharacters
|
---|
195 | jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
196 |
|
---|
197 | ALIGN JUMP_ALIGN
|
---|
198 | DrawBottomBorderLine:
|
---|
199 | mov si, g_rgbBottomBorderCharacters
|
---|
200 | jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
201 |
|
---|
202 | ALIGN JUMP_ALIGN
|
---|
203 | DrawBottomShadowLine:
|
---|
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 |
|
---|
214 | ALIGN JUMP_ALIGN
|
---|
215 | DrawTextBorderLine:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
230 | ALIGN JUMP_ALIGN
|
---|
231 | PrintBorderCharactersFromCSSIandShadowCharacter:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
248 | ALIGN JUMP_ALIGN
|
---|
249 | PrintNewlineToEndBorderLine:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
264 | ALIGN JUMP_ALIGN
|
---|
265 | PrintShadowCharactersByDXtimes:
|
---|
266 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
267 |
|
---|
268 | mov si, ATTRIBUTE_CHARS.cShadow
|
---|
269 | call MenuAttribute_SetToDisplayContextFromTypeInSI
|
---|
270 |
|
---|
271 | push dx
|
---|
272 | mov dl, ATTRIBUTES_ARE_USED
|
---|
273 | mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
|
---|
274 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInDL
|
---|
275 | pop dx
|
---|
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 | ;--------------------------------------------------------------------
|
---|
294 | ALIGN JUMP_ALIGN
|
---|
295 | PrintBorderCharactersFromCSSI:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
321 | ALIGN JUMP_ALIGN
|
---|
322 | MenuBorders_PrintSingleBorderCharacterFromAL:
|
---|
323 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL
|
---|
324 | ret
|
---|
325 |
|
---|
326 | ALIGN JUMP_ALIGN
|
---|
327 | PrintMultipleBorderCharactersFromAL:
|
---|
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
|
---|
337 | g_rgbTopBorderCharacters:
|
---|
338 | istruc 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
|
---|
342 | iend
|
---|
343 |
|
---|
344 | g_rgbSeparationBorderCharacters:
|
---|
345 | istruc 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
|
---|
349 | iend
|
---|
350 |
|
---|
351 | g_rgbBottomBorderCharacters:
|
---|
352 | istruc 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
|
---|
356 | iend
|
---|
357 |
|
---|
358 | g_rgbTextBorderCharacters:
|
---|
359 | istruc BORDER_CHARS
|
---|
360 | at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL
|
---|
361 | at BORDER_CHARS.cMiddle, db ' '
|
---|
362 | at BORDER_CHARS.cRight, db DOUBLE_VERTICAL
|
---|
363 | iend
|
---|