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
|
---|
5 | struc BORDER_CHARS
|
---|
6 | .cLeft resb 1
|
---|
7 | .cMiddle resb 1
|
---|
8 | .cRight resb 1
|
---|
9 | endstruc
|
---|
10 |
|
---|
11 |
|
---|
12 | ; Section containing code
|
---|
13 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
24 | ALIGN JUMP_ALIGN
|
---|
25 | MenuBorders_RefreshAll:
|
---|
26 | call MenuBorders_AdjustDisplayContextForDrawingBorders
|
---|
27 | call MenuBorders_GetNumberOfMiddleCharactersToDX
|
---|
28 | call RefreshTitleBorders
|
---|
29 | call RefreshItemBorders
|
---|
30 | call RefreshInformationBorders
|
---|
31 | call DrawBottomBorderLine
|
---|
32 | jmp DrawBottomShadowLine
|
---|
33 |
|
---|
34 |
|
---|
35 | ;--------------------------------------------------------------------
|
---|
36 | ; MenuBorders_RedrawBottomBorderLine
|
---|
37 | ; Parameters
|
---|
38 | ; SS:BP: Ptr to MENU
|
---|
39 | ; Returns:
|
---|
40 | ; Nothing
|
---|
41 | ; Corrupts registers:
|
---|
42 | ; AX, BX, DX, SI, DI
|
---|
43 | ;--------------------------------------------------------------------
|
---|
44 | ALIGN JUMP_ALIGN
|
---|
45 | MenuBorders_RedrawBottomBorderLine:
|
---|
46 | call MenuBorders_AdjustDisplayContextForDrawingBorders
|
---|
47 | call MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
|
---|
48 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
49 | call MenuBorders_GetNumberOfMiddleCharactersToDX
|
---|
50 | jmp SHORT DrawBottomBorderLine
|
---|
51 |
|
---|
52 |
|
---|
53 | ;--------------------------------------------------------------------
|
---|
54 | ; MenuBorders_RefreshItemBorders
|
---|
55 | ; Parameters
|
---|
56 | ; SS:BP: Ptr to MENU
|
---|
57 | ; Returns:
|
---|
58 | ; Nothing
|
---|
59 | ; Corrupts registers:
|
---|
60 | ; AX, BX, CX, DX, SI, DI
|
---|
61 | ;--------------------------------------------------------------------
|
---|
62 | ALIGN JUMP_ALIGN
|
---|
63 | MenuBorders_RefreshItemBorders:
|
---|
64 | call MenuBorders_AdjustDisplayContextForDrawingBorders
|
---|
65 | call MenuLocation_GetItemBordersTopLeftCoordinatesToAX
|
---|
66 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
67 |
|
---|
68 | call MenuBorders_GetNumberOfMiddleCharactersToDX
|
---|
69 | jmp SHORT RefreshItemBorders
|
---|
70 |
|
---|
71 |
|
---|
72 | ;--------------------------------------------------------------------
|
---|
73 | ; MenuBorders_AdjustDisplayContextForDrawingBorders
|
---|
74 | ; Parameters
|
---|
75 | ; SS:BP: Ptr to MENU
|
---|
76 | ; Returns:
|
---|
77 | ; Nothing
|
---|
78 | ; Corrupts registers:
|
---|
79 | ; AX, BX, SI, DI
|
---|
80 | ;--------------------------------------------------------------------
|
---|
81 | ALIGN JUMP_ALIGN
|
---|
82 | MenuBorders_AdjustDisplayContextForDrawingBorders:
|
---|
83 | mov bl, ATTRIBUTES_ARE_USED
|
---|
84 | mov ax, MenuCharOut_MenuTeletypeOutput
|
---|
85 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
|
---|
86 |
|
---|
87 | call CharOutLineSplitter_GetFirstBorderLineColumnOffsetToAX
|
---|
88 | CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
|
---|
89 |
|
---|
90 | call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
|
---|
91 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
92 |
|
---|
93 | mov si, ATTRIBUTE_CHARS.cBordersAndBackground
|
---|
94 | jmp MenuAttribute_SetToDisplayContextFromTypeInSI
|
---|
95 |
|
---|
96 |
|
---|
97 | ;--------------------------------------------------------------------
|
---|
98 | ; MenuBorders_GetNumberOfMiddleCharactersToDX
|
---|
99 | ; Parameters
|
---|
100 | ; SS:BP: Ptr to MENU
|
---|
101 | ; Returns:
|
---|
102 | ; DX: Number of middle border characters when drawing border lines
|
---|
103 | ; Corrupts registers:
|
---|
104 | ; Nothing
|
---|
105 | ;--------------------------------------------------------------------
|
---|
106 | ALIGN JUMP_ALIGN
|
---|
107 | MenuBorders_GetNumberOfMiddleCharactersToDX:
|
---|
108 | eMOVZX dx, BYTE [bp+MENUINIT.bWidth]
|
---|
109 | sub dx, BYTE MENU_HORIZONTAL_BORDER_LINES
|
---|
110 | ret
|
---|
111 |
|
---|
112 |
|
---|
113 | ;--------------------------------------------------------------------
|
---|
114 | ; RefreshTitleBorders
|
---|
115 | ; Parameters
|
---|
116 | ; DX: Number of times to repeat middle character
|
---|
117 | ; SS:BP: Ptr to MENU
|
---|
118 | ; Returns:
|
---|
119 | ; Nothing
|
---|
120 | ; Corrupts registers:
|
---|
121 | ; AX, BX, CX, SI, DI
|
---|
122 | ;--------------------------------------------------------------------
|
---|
123 | ALIGN JUMP_ALIGN
|
---|
124 | RefreshTitleBorders:
|
---|
125 | call DrawTopBorderLine
|
---|
126 | eMOVZX cx, BYTE [bp+MENUINIT.bTitleLines]
|
---|
127 | jmp SHORT DrawTextBorderLinesByCXtimes
|
---|
128 |
|
---|
129 | ;--------------------------------------------------------------------
|
---|
130 | ; RefreshInformationBorders
|
---|
131 | ; Parameters
|
---|
132 | ; DX: Number of times to repeat middle character
|
---|
133 | ; SS:BP: Ptr to MENU
|
---|
134 | ; Returns:
|
---|
135 | ; Nothing
|
---|
136 | ; Corrupts registers:
|
---|
137 | ; AX, BX, CX, SI, DI
|
---|
138 | ;--------------------------------------------------------------------
|
---|
139 | ALIGN JUMP_ALIGN
|
---|
140 | RefreshInformationBorders:
|
---|
141 | call DrawSeparationBorderLine
|
---|
142 | eMOVZX cx, BYTE [bp+MENUINIT.bInfoLines]
|
---|
143 | jmp SHORT DrawTextBorderLinesByCXtimes
|
---|
144 |
|
---|
145 | ;--------------------------------------------------------------------
|
---|
146 | ; RefreshItemBorders
|
---|
147 | ; Parameters
|
---|
148 | ; DX: Number of times to repeat middle character
|
---|
149 | ; SS:BP: Ptr to MENU
|
---|
150 | ; Returns:
|
---|
151 | ; Nothing
|
---|
152 | ; Corrupts registers:
|
---|
153 | ; AX, BX, CX, SI, DI
|
---|
154 | ;--------------------------------------------------------------------
|
---|
155 | ALIGN JUMP_ALIGN
|
---|
156 | RefreshItemBorders:
|
---|
157 | call DrawSeparationBorderLine
|
---|
158 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
159 | ; Fall to DrawTextBorderLinesByCXtimes
|
---|
160 |
|
---|
161 | ;--------------------------------------------------------------------
|
---|
162 | ; DrawTextBorderLinesByCXtimes
|
---|
163 | ; Parameters
|
---|
164 | ; CX: Number of border lines to draw
|
---|
165 | ; DX: Number of times to repeat middle character
|
---|
166 | ; SS:BP: Ptr to MENU
|
---|
167 | ; Returns:
|
---|
168 | ; Nothing
|
---|
169 | ; Corrupts registers:
|
---|
170 | ; AX, CX, SI, DI
|
---|
171 | ;--------------------------------------------------------------------
|
---|
172 | DrawTextBorderLinesByCXtimes:
|
---|
173 | jcxz .NoBorderLinesToDraw
|
---|
174 | ALIGN JUMP_ALIGN
|
---|
175 | .DrawBordersWithFunctionInBX:
|
---|
176 | call DrawTextBorderLine
|
---|
177 | loop .DrawBordersWithFunctionInBX
|
---|
178 | .NoBorderLinesToDraw:
|
---|
179 | ret
|
---|
180 |
|
---|
181 |
|
---|
182 | ;--------------------------------------------------------------------
|
---|
183 | ; DrawTopBorderLine
|
---|
184 | ; DrawSeparationBorderLine
|
---|
185 | ; DrawBottomBorderLine
|
---|
186 | ; DrawTimeoutCounterOverBottomBorderLine
|
---|
187 | ; DrawBottomShadowLine
|
---|
188 | ; DrawTextBorderLine
|
---|
189 | ; Parameters
|
---|
190 | ; DX: Number of times to repeat middle character
|
---|
191 | ; SS:BP: Ptr to MENU
|
---|
192 | ; Returns:
|
---|
193 | ; Nothing
|
---|
194 | ; Corrupts registers:
|
---|
195 | ; AX, SI, DI
|
---|
196 | ;--------------------------------------------------------------------
|
---|
197 | ALIGN JUMP_ALIGN
|
---|
198 | DrawTopBorderLine:
|
---|
199 | mov si, g_rgbTopBorderCharacters
|
---|
200 | call PrintBorderCharactersFromCSSI
|
---|
201 | jmp SHORT PrintNewlineToEndBorderLine
|
---|
202 |
|
---|
203 | ALIGN JUMP_ALIGN
|
---|
204 | DrawSeparationBorderLine:
|
---|
205 | mov si, g_rgbSeparationBorderCharacters
|
---|
206 | jmp SHORT PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
207 |
|
---|
208 | ALIGN JUMP_ALIGN
|
---|
209 | DrawBottomBorderLine:
|
---|
210 | mov si, g_rgbBottomBorderCharacters
|
---|
211 | test BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN
|
---|
212 | jz SHORT PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
213 |
|
---|
214 | call DrawTimeoutCounterString
|
---|
215 | sub dx, BYTE MENU_TIMEOUT_STRING_CHARACTERS
|
---|
216 | mov si, g_BottomBorderWithTimeoutCharacters
|
---|
217 | call PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
218 | add dx, BYTE MENU_TIMEOUT_STRING_CHARACTERS
|
---|
219 | ret
|
---|
220 |
|
---|
221 | ALIGN JUMP_ALIGN
|
---|
222 | DrawBottomShadowLine:
|
---|
223 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
|
---|
224 | inc ax ; Move one column left
|
---|
225 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
226 | inc dx ; Increment repeat count...
|
---|
227 | inc dx ; ...for both corner characters
|
---|
228 | call PrintShadowCharactersByDXtimes
|
---|
229 | dec dx ; Restore...
|
---|
230 | dec dx ; ...DX
|
---|
231 | ret
|
---|
232 |
|
---|
233 | ALIGN JUMP_ALIGN
|
---|
234 | DrawTextBorderLine:
|
---|
235 | mov si, g_rgbTextBorderCharacters
|
---|
236 | ; Fall to PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
237 |
|
---|
238 | ;--------------------------------------------------------------------
|
---|
239 | ; PrintBorderCharactersFromCSSIandShadowCharacter
|
---|
240 | ; Parameters
|
---|
241 | ; DX: Number of times to repeat middle character
|
---|
242 | ; CS:SI: Ptr to BORDER_CHARS
|
---|
243 | ; SS:BP: Ptr to MENU
|
---|
244 | ; Returns:
|
---|
245 | ; Nothing
|
---|
246 | ; Corrupts registers:
|
---|
247 | ; AX, SI, DI
|
---|
248 | ;--------------------------------------------------------------------
|
---|
249 | ALIGN JUMP_ALIGN
|
---|
250 | PrintBorderCharactersFromCSSIandShadowCharacter:
|
---|
251 | call PrintBorderCharactersFromCSSI
|
---|
252 | push dx
|
---|
253 | mov dx, 1
|
---|
254 | call PrintShadowCharactersByDXtimes
|
---|
255 | pop dx
|
---|
256 | ; Fall to PrintNewlineToEndBorderLine
|
---|
257 |
|
---|
258 | ;--------------------------------------------------------------------
|
---|
259 | ; PrintNewlineToEndBorderLine
|
---|
260 | ; Parameters
|
---|
261 | ; SS:BP: Ptr to MENU
|
---|
262 | ; Returns:
|
---|
263 | ; Nothing
|
---|
264 | ; Corrupts registers:
|
---|
265 | ; AX, DI
|
---|
266 | ;--------------------------------------------------------------------
|
---|
267 | ALIGN JUMP_ALIGN
|
---|
268 | PrintNewlineToEndBorderLine:
|
---|
269 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters
|
---|
270 | ret
|
---|
271 |
|
---|
272 |
|
---|
273 | ;--------------------------------------------------------------------
|
---|
274 | ; PrintShadowCharactersByDXtimes
|
---|
275 | ; Parameters
|
---|
276 | ; DX: Number of shadow characters to print
|
---|
277 | ; SS:BP: Ptr to MENU
|
---|
278 | ; Returns:
|
---|
279 | ; Nothing
|
---|
280 | ; Corrupts registers:
|
---|
281 | ; AX, SI, DI
|
---|
282 | ;--------------------------------------------------------------------
|
---|
283 | ALIGN JUMP_ALIGN
|
---|
284 | PrintShadowCharactersByDXtimes:
|
---|
285 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
286 |
|
---|
287 | mov si, ATTRIBUTE_CHARS.cShadow
|
---|
288 | call MenuAttribute_SetToDisplayContextFromTypeInSI
|
---|
289 |
|
---|
290 | push bx
|
---|
291 | mov bl, ATTRIBUTES_ARE_USED
|
---|
292 | mov ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
|
---|
293 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
|
---|
294 | pop bx
|
---|
295 |
|
---|
296 | call MenuBorders_PrintMultipleBorderCharactersFromAL ; AL does not matter
|
---|
297 |
|
---|
298 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
299 | ret
|
---|
300 |
|
---|
301 |
|
---|
302 | ;--------------------------------------------------------------------
|
---|
303 | ; PrintBorderCharactersFromCSSI
|
---|
304 | ; Parameters
|
---|
305 | ; DX: Number of times to repeat middle character
|
---|
306 | ; CS:SI: Ptr to BORDER_CHARS
|
---|
307 | ; SS:BP: Ptr to MENU
|
---|
308 | ; Returns:
|
---|
309 | ; Nothing
|
---|
310 | ; Corrupts registers:
|
---|
311 | ; AX, SI, DI
|
---|
312 | ;--------------------------------------------------------------------
|
---|
313 | ALIGN JUMP_ALIGN
|
---|
314 | PrintBorderCharactersFromCSSI:
|
---|
315 | eSEG cs
|
---|
316 | lodsb ; Load from [cs:si+BORDER_CHARS.cLeft] to AL
|
---|
317 | call MenuBorders_PrintSingleBorderCharacterFromAL
|
---|
318 |
|
---|
319 | eSEG cs
|
---|
320 | lodsb ; Load from [cs:si+BORDER_CHARS.cMiddle] to AL
|
---|
321 | call MenuBorders_PrintMultipleBorderCharactersFromAL
|
---|
322 |
|
---|
323 | eSEG cs
|
---|
324 | lodsb ; Load from [cs:si+BORDER_CHARS.cRight] to AL
|
---|
325 | ; Fall to MenuBorders_PrintSingleBorderCharacterFromAL
|
---|
326 |
|
---|
327 | ;--------------------------------------------------------------------
|
---|
328 | ; MenuBorders_PrintSingleBorderCharacterFromAL
|
---|
329 | ; MenuBorders_PrintMultipleBorderCharactersFromAL
|
---|
330 | ; Parameters
|
---|
331 | ; AL: Character to print
|
---|
332 | ; DX: Repeat count (MenuBorders_PrintMultipleBorderCharactersFromAL)
|
---|
333 | ; SS:BP: Ptr to MENU
|
---|
334 | ; Returns:
|
---|
335 | ; Nothing
|
---|
336 | ; Corrupts registers:
|
---|
337 | ; AX, DI
|
---|
338 | ;--------------------------------------------------------------------
|
---|
339 | ALIGN JUMP_ALIGN
|
---|
340 | MenuBorders_PrintSingleBorderCharacterFromAL:
|
---|
341 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL
|
---|
342 | ret
|
---|
343 |
|
---|
344 | ALIGN JUMP_ALIGN
|
---|
345 | MenuBorders_PrintMultipleBorderCharactersFromAL:
|
---|
346 | push cx
|
---|
347 | mov cx, dx
|
---|
348 | CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
|
---|
349 | pop cx
|
---|
350 | ret
|
---|
351 |
|
---|
352 |
|
---|
353 | ;--------------------------------------------------------------------
|
---|
354 | ; DrawTimeoutCounterString
|
---|
355 | ; Parameters
|
---|
356 | ; SS:BP: Ptr to MENU
|
---|
357 | ; Returns:
|
---|
358 | ; Nothing
|
---|
359 | ; Corrupts registers:
|
---|
360 | ; AX, SI, DI
|
---|
361 | ;--------------------------------------------------------------------
|
---|
362 | ALIGN JUMP_ALIGN
|
---|
363 | DrawTimeoutCounterString:
|
---|
364 | call MenuTime_GetTimeoutSecondsLeftToAX
|
---|
365 | ; Fall to .PrintTimeoutStringWithSecondsInAX
|
---|
366 |
|
---|
367 | ;--------------------------------------------------------------------
|
---|
368 | ; .PrintTimeoutStringWithSecondsInAX
|
---|
369 | ; Parameters
|
---|
370 | ; AX: Seconds to print
|
---|
371 | ; SS:BP: Ptr to MENU
|
---|
372 | ; Returns:
|
---|
373 | ; Nothing
|
---|
374 | ; Corrupts registers:
|
---|
375 | ; AX, SI, DI
|
---|
376 | ;--------------------------------------------------------------------
|
---|
377 | .PrintTimeoutStringWithSecondsInAX:
|
---|
378 | ; Get attribute to AX
|
---|
379 | xchg di, ax
|
---|
380 | mov si, ATTRIBUTE_CHARS.cNormalTimeout
|
---|
381 | cmp di, BYTE MENU_TIMEOUT_SECONDS_FOR_HURRY
|
---|
382 | eCMOVB si, ATTRIBUTE_CHARS.cHurryTimeout
|
---|
383 | call MenuAttribute_GetToAXfromTypeInSI
|
---|
384 |
|
---|
385 | push bp
|
---|
386 | mov bp, sp
|
---|
387 | mov si, .szSelectionTimeout
|
---|
388 | push ax ; Push attribute
|
---|
389 | push di ; Push seconds
|
---|
390 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
391 | pop bp
|
---|
392 | ret
|
---|
393 | .szSelectionTimeout:
|
---|
394 | db DOUBLE_BOTTOM_LEFT_CORNER
|
---|
395 | db DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL
|
---|
396 | db "%ASelection in %2u s",NULL
|
---|
397 |
|
---|
398 |
|
---|
399 | ; Lookup tables for border characters
|
---|
400 | g_rgbTopBorderCharacters:
|
---|
401 | istruc BORDER_CHARS
|
---|
402 | at BORDER_CHARS.cLeft, db DOUBLE_TOP_LEFT_CORNER
|
---|
403 | at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
|
---|
404 | at BORDER_CHARS.cRight, db DOUBLE_TOP_RIGHT_CORNER
|
---|
405 | iend
|
---|
406 |
|
---|
407 | g_rgbSeparationBorderCharacters:
|
---|
408 | istruc BORDER_CHARS
|
---|
409 | at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL_TO_RIGHT_SINGLE
|
---|
410 | at BORDER_CHARS.cMiddle, db SINGLE_HORIZONTAL
|
---|
411 | at BORDER_CHARS.cRight, db DOUBLE_VERTICAL_TO_LEFT_SINGLE
|
---|
412 | iend
|
---|
413 |
|
---|
414 | g_rgbBottomBorderCharacters:
|
---|
415 | istruc BORDER_CHARS
|
---|
416 | at BORDER_CHARS.cLeft, db DOUBLE_BOTTOM_LEFT_CORNER
|
---|
417 | at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
|
---|
418 | at BORDER_CHARS.cRight, db DOUBLE_BOTTOM_RIGHT_CORNER
|
---|
419 | iend
|
---|
420 |
|
---|
421 | g_BottomBorderWithTimeoutCharacters:
|
---|
422 | istruc BORDER_CHARS
|
---|
423 | at BORDER_CHARS.cLeft, db DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL
|
---|
424 | at BORDER_CHARS.cMiddle, db DOUBLE_HORIZONTAL
|
---|
425 | at BORDER_CHARS.cRight, db DOUBLE_BOTTOM_RIGHT_CORNER
|
---|
426 | iend
|
---|
427 |
|
---|
428 | g_rgbTextBorderCharacters:
|
---|
429 | istruc BORDER_CHARS
|
---|
430 | at BORDER_CHARS.cLeft, db DOUBLE_VERTICAL
|
---|
431 | at BORDER_CHARS.cMiddle, db ' '
|
---|
432 | at BORDER_CHARS.cRight, db DOUBLE_VERTICAL
|
---|
433 | iend
|
---|