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
|
---|
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, SI, DI
|
---|
48 | ;--------------------------------------------------------------------
|
---|
49 | ALIGN JUMP_ALIGN
|
---|
50 | MenuBorders_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 | ;--------------------------------------------------------------------
|
---|
73 | ALIGN JUMP_ALIGN
|
---|
74 | MenuBorders_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 | ;--------------------------------------------------------------------
|
---|
92 | ALIGN JUMP_ALIGN
|
---|
93 | GetNumberOfMiddleCharactersToDX:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
109 | ALIGN JUMP_ALIGN
|
---|
110 | RefreshTitleBorders:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
125 | ALIGN JUMP_ALIGN
|
---|
126 | RefreshInformationBorders:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
141 | ALIGN JUMP_ALIGN
|
---|
142 | RefreshItemBorders:
|
---|
143 | call DrawSeparationBorderLine
|
---|
144 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
145 | DrawTextBorderLinesByCXtimes:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
161 | DrawBorderLinesByCXtimes:
|
---|
162 | jcxz .Return
|
---|
163 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
185 | ALIGN JUMP_ALIGN
|
---|
186 | DrawTopBorderLine:
|
---|
187 | mov si, g_rgbTopBorderCharacters
|
---|
188 | call PrintBorderCharactersFromCSSI
|
---|
189 | jmp SHORT PrintNewlineToEndBorderLine
|
---|
190 |
|
---|
191 | ALIGN JUMP_ALIGN
|
---|
192 | DrawSeparationBorderLine:
|
---|
193 | mov si, g_rgbSeparationBorderCharacters
|
---|
194 | jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
195 |
|
---|
196 | ALIGN JUMP_ALIGN
|
---|
197 | DrawBottomBorderLine:
|
---|
198 | mov si, g_rgbBottomBorderCharacters
|
---|
199 | jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
200 |
|
---|
201 | ALIGN JUMP_ALIGN
|
---|
202 | DrawBottomShadowLine:
|
---|
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 |
|
---|
213 | ALIGN JUMP_ALIGN
|
---|
214 | DrawTextBorderLine:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
229 | ALIGN JUMP_ALIGN
|
---|
230 | PrintBorderCharactersFromCSSIandShadowCharacter:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
247 | ALIGN JUMP_ALIGN
|
---|
248 | PrintNewlineToEndBorderLine:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
263 | ALIGN JUMP_ALIGN
|
---|
264 | PrintShadowCharactersByDXtimes:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
290 | ALIGN JUMP_ALIGN
|
---|
291 | PrintBorderCharactersFromCSSI:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
317 | ALIGN JUMP_ALIGN
|
---|
318 | MenuBorders_PrintSingleBorderCharacterFromAL:
|
---|
319 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL
|
---|
320 | ret
|
---|
321 |
|
---|
322 | ALIGN JUMP_ALIGN
|
---|
323 | PrintMultipleBorderCharactersFromAL:
|
---|
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
|
---|
333 | g_rgbTopBorderCharacters:
|
---|
334 | istruc 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
|
---|
338 | iend
|
---|
339 |
|
---|
340 | g_rgbSeparationBorderCharacters:
|
---|
341 | istruc 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
|
---|
345 | iend
|
---|
346 |
|
---|
347 | g_rgbBottomBorderCharacters:
|
---|
348 | istruc 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
|
---|
352 | iend
|
---|
353 |
|
---|
354 | g_rgbTextBorderCharacters:
|
---|
355 | istruc BORDER_CHARS
|
---|
356 | at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL
|
---|
357 | at BORDER_CHARS.cMiddle, db ' '
|
---|
358 | at BORDER_CHARS.cRight, db DOUBLE_VERTICAL
|
---|
359 | iend
|
---|