1 | ; File name : LibraryTests.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 27.6.2010
|
---|
4 | ; Last update : 27.9.2010
|
---|
5 | ; Author : Tomi Tilli
|
---|
6 | ; Description : Tests for Assembly Library.
|
---|
7 | ; This file should not be included when using the library on
|
---|
8 | ; some other project.
|
---|
9 |
|
---|
10 | ; Include .inc files
|
---|
11 | %define INCLUDE_MENU_DIALOGS
|
---|
12 | %include "AssemblyLibrary.inc" ; Assembly Library. Must be included first!
|
---|
13 |
|
---|
14 |
|
---|
15 | ; Section containing code
|
---|
16 | SECTION .text
|
---|
17 |
|
---|
18 | ; Program first instruction.
|
---|
19 | ORG 100h ; Code starts at offset 100h (DOS .COM)
|
---|
20 | Start:
|
---|
21 | jmp LibraryTests_Start
|
---|
22 |
|
---|
23 | ; Include library sources
|
---|
24 | %include "AssemblyLibrary.asm"
|
---|
25 |
|
---|
26 |
|
---|
27 | ;--------------------------------------------------------------------
|
---|
28 | ; Program start
|
---|
29 | ;--------------------------------------------------------------------
|
---|
30 | ALIGN JUMP_ALIGN
|
---|
31 | LibraryTests_Start:
|
---|
32 | CALL_DISPLAY_LIBRARY InitializeDisplayContext
|
---|
33 | CALL_DISPLAY_LIBRARY ClearScreen
|
---|
34 |
|
---|
35 | ;call LibraryTests_Sort
|
---|
36 | ;call LibraryTests_ForDisplayLibrary
|
---|
37 | ;call LibraryTests_ForKeyboardLibrary
|
---|
38 | call LibraryTests_ForMenuLibrary
|
---|
39 |
|
---|
40 | ; Exit to DOS
|
---|
41 | ;mov ax, CURSOR_XY(1, 1)
|
---|
42 | ;CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
43 | CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware
|
---|
44 | mov ax, 4C00h ; Exit to DOS
|
---|
45 | int 21h
|
---|
46 |
|
---|
47 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
48 | ALIGN JUMP_ALIGN
|
---|
49 | LibraryTests_ForMenuLibrary:
|
---|
50 | mov [cs:g_dialogInputOutput+DIALOG_INPUT.fszTitle+2], cs
|
---|
51 | mov [cs:g_dialogInputOutput+DIALOG_INPUT.fszItems+2], cs
|
---|
52 | mov [cs:g_dialogInputOutput+DIALOG_INPUT.fszInfo+2], cs
|
---|
53 |
|
---|
54 | mov bx, .MenuEventHandler
|
---|
55 | call MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX
|
---|
56 | ret
|
---|
57 |
|
---|
58 | ALIGN JUMP_ALIGN
|
---|
59 | .MenuEventHandler:
|
---|
60 | jmp [cs:bx+.rgfnMenuEvents]
|
---|
61 | .NotHandled:
|
---|
62 | clc ; Not handled so clear
|
---|
63 | ret
|
---|
64 |
|
---|
65 | ALIGN JUMP_ALIGN
|
---|
66 | .InitializeMenu:
|
---|
67 | mov WORD [si+MENUINIT.wTimeoutTicks], 10000 / 55 ; 10 seconds
|
---|
68 | mov WORD [si+MENUINIT.wItems], 51
|
---|
69 | mov BYTE [si+MENUINIT.bWidth], 40
|
---|
70 | mov BYTE [si+MENUINIT.bHeight], 20
|
---|
71 | mov BYTE [si+MENUINIT.bTitleLines], TEST_MENU_TITLE_LINES
|
---|
72 | mov BYTE [si+MENUINIT.bInfoLines], TEST_MENU_INFO_LINES
|
---|
73 | mov ax, 1
|
---|
74 | CALL_MENU_LIBRARY HighlightItemFromAX
|
---|
75 | stc
|
---|
76 | ret
|
---|
77 |
|
---|
78 | ALIGN JUMP_ALIGN
|
---|
79 | .RefreshTitle:
|
---|
80 | mov si, .szMenuTitle
|
---|
81 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
82 | stc
|
---|
83 | ret
|
---|
84 | .szMenuTitle:
|
---|
85 | db "Simple test program for Assembly Library. Can be used to find bugs.",NULL
|
---|
86 |
|
---|
87 | ALIGN JUMP_ALIGN
|
---|
88 | .RefreshInformation:
|
---|
89 | push bp
|
---|
90 | mov bp, sp
|
---|
91 | mov si, .szInfoTitle
|
---|
92 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
93 | pop bp
|
---|
94 | stc
|
---|
95 | ret
|
---|
96 | .szInfoTitle:
|
---|
97 | db "Information line 1,",CR,LF,
|
---|
98 | db "Information line 2. ",
|
---|
99 | db "This comes (12) right after Information line 2.",NULL
|
---|
100 |
|
---|
101 | ALIGN JUMP_ALIGN
|
---|
102 | .RefreshItemFromCX:
|
---|
103 | cmp cx, TEST_MENU_VALID_ITEMS
|
---|
104 | jb SHORT .PrintKnownItem
|
---|
105 |
|
---|
106 | push bp
|
---|
107 | mov si, .szItem
|
---|
108 | mov bp, sp
|
---|
109 | push cx ; Item index
|
---|
110 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
111 | pop bp
|
---|
112 | stc
|
---|
113 | ret
|
---|
114 | .szItem:
|
---|
115 | db "This is item %d.",NULL
|
---|
116 | .PrintKnownItem:
|
---|
117 | mov si, cx
|
---|
118 | shl si, 1
|
---|
119 | mov si, [cs:si+.rgszItems]
|
---|
120 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
121 | stc
|
---|
122 | ret
|
---|
123 |
|
---|
124 | ALIGN JUMP_ALIGN
|
---|
125 | .ItemSelectedFromCX:
|
---|
126 | push cs
|
---|
127 | pop ds
|
---|
128 | cmp cx, TEST_MENU_VALID_ITEMS
|
---|
129 | jae SHORT .ReturnWithoutHandling
|
---|
130 | mov bx, cx
|
---|
131 | shl bx, 1
|
---|
132 | jmp [bx+.rgfnSelectionHandler]
|
---|
133 | .ReturnWithoutHandling:
|
---|
134 | stc
|
---|
135 | ret
|
---|
136 |
|
---|
137 | ALIGN WORD_ALIGN
|
---|
138 | .rgfnSelectionHandler:
|
---|
139 | dw .ExitMenu
|
---|
140 | dw .ToggleTitle
|
---|
141 | dw .ToggleInfo
|
---|
142 | dw .ShowMessageDialogWithUnformattedText
|
---|
143 | dw .AskWordFromUser
|
---|
144 | dw .AskStringFromUser
|
---|
145 | dw .AskSelectionFromUser
|
---|
146 | dw .AskFileFromUser
|
---|
147 | dw .TestProgressBar
|
---|
148 |
|
---|
149 |
|
---|
150 | ALIGN JUMP_ALIGN
|
---|
151 | .ExitMenu:
|
---|
152 | CALL_MENU_LIBRARY Close
|
---|
153 | stc
|
---|
154 | ret
|
---|
155 |
|
---|
156 | ALIGN JUMP_ALIGN
|
---|
157 | .ToggleTitle:
|
---|
158 | mov al, [bp+MENUINIT.bTitleLines]
|
---|
159 | xor al, TEST_MENU_TITLE_LINES
|
---|
160 | CALL_MENU_LIBRARY SetTitleHeightFromAL
|
---|
161 | jmp SHORT .RefreshMenuWindow
|
---|
162 | ALIGN JUMP_ALIGN
|
---|
163 | .ToggleInfo:
|
---|
164 | mov al, [bp+MENUINIT.bInfoLines]
|
---|
165 | xor al, TEST_MENU_INFO_LINES
|
---|
166 | CALL_MENU_LIBRARY SetInformationHeightFromAL
|
---|
167 | .RefreshMenuWindow:
|
---|
168 | CALL_MENU_LIBRARY RestartTimeout
|
---|
169 | CALL_MENU_LIBRARY RefreshWindow
|
---|
170 | stc
|
---|
171 | ret
|
---|
172 |
|
---|
173 | ALIGN JUMP_ALIGN
|
---|
174 | .ShowMessageDialogWithUnformattedText:
|
---|
175 | mov di, g_szVeryLongString
|
---|
176 | jmp .ShowDialogWithStringInCSDI
|
---|
177 |
|
---|
178 | ALIGN JUMP_ALIGN
|
---|
179 | .AskWordFromUser:
|
---|
180 | mov si, g_dialogInputOutput
|
---|
181 | mov BYTE [si+WORD_DIALOG_IO.bNumericBase], 10
|
---|
182 | mov WORD [si+WORD_DIALOG_IO.wMin], 10
|
---|
183 | mov WORD [si+WORD_DIALOG_IO.wMax], 20
|
---|
184 | CALL_MENU_LIBRARY GetWordWithIoInDSSI
|
---|
185 |
|
---|
186 | mov ax, [si+WORD_DIALOG_IO.wReturnWord]
|
---|
187 | mov di, g_szBuffer
|
---|
188 | call .FormatWordFromAXtoStringBufferInCSDI
|
---|
189 | call .ShowDialogWithStringInCSDI
|
---|
190 | stc
|
---|
191 | ret
|
---|
192 |
|
---|
193 | ALIGN JUMP_ALIGN
|
---|
194 | .AskStringFromUser:
|
---|
195 | mov si, g_dialogInputOutput
|
---|
196 | mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
|
---|
197 | mov WORD [si+STRING_DIALOG_IO.wBufferSize], 17
|
---|
198 | mov WORD [si+STRING_DIALOG_IO.fpReturnBuffer], g_szBuffer
|
---|
199 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], cs
|
---|
200 | CALL_MENU_LIBRARY GetStringWithIoInDSSI
|
---|
201 |
|
---|
202 | mov di, g_szBuffer
|
---|
203 | call .ShowDialogWithStringInCSDI
|
---|
204 | stc
|
---|
205 | ret
|
---|
206 |
|
---|
207 | ALIGN JUMP_ALIGN
|
---|
208 | .AskSelectionFromUser:
|
---|
209 | mov si, g_dialogInputOutput
|
---|
210 | mov WORD [si+DIALOG_INPUT.fszItems], .szSelections
|
---|
211 | CALL_MENU_LIBRARY GetSelectionToAXwithInputInDSSI
|
---|
212 |
|
---|
213 | mov di, g_szBuffer
|
---|
214 | call .FormatWordFromAXtoStringBufferInCSDI
|
---|
215 | call .ShowDialogWithStringInCSDI
|
---|
216 | stc
|
---|
217 | ret
|
---|
218 | .szSelections:
|
---|
219 | db "Cancel",LF
|
---|
220 | db "Yes",LF
|
---|
221 | db "No",NULL
|
---|
222 |
|
---|
223 | ALIGN JUMP_ALIGN
|
---|
224 | .AskFileFromUser:
|
---|
225 | mov si, g_dialogInputOutput
|
---|
226 | mov WORD [si+FILE_DIALOG_IO.fszItemBuffer], g_szBuffer
|
---|
227 | mov BYTE [si+FILE_DIALOG_IO.bDialogFlags], FLG_FILEDIALOG_DIRECTORY | FLG_FILEDIALOG_NEW | FLG_FILEDIALOG_DRIVES
|
---|
228 | mov BYTE [si+FILE_DIALOG_IO.bFileAttributes], FLG_FILEATTR_DIRECTORY | FLG_FILEATTR_ARCHIVE
|
---|
229 | mov WORD [si+FILE_DIALOG_IO.fpFileFilterString], .szAllFiles
|
---|
230 | mov [si+FILE_DIALOG_IO.fpFileFilterString+2], cs
|
---|
231 | CALL_MENU_LIBRARY GetFileNameWithIoInDSSI
|
---|
232 | cmp BYTE [g_dialogInputOutput+FILE_DIALOG_IO.bUserCancellation], TRUE
|
---|
233 | je SHORT .FileSelectionCancelled
|
---|
234 |
|
---|
235 | mov di, g_dialogInputOutput + FILE_DIALOG_IO.szFile
|
---|
236 | call .ShowDialogWithStringInCSDI
|
---|
237 | .FileSelectionCancelled:
|
---|
238 | stc
|
---|
239 | ret
|
---|
240 | .szAllFiles:
|
---|
241 | db "*.*",NULL
|
---|
242 |
|
---|
243 |
|
---|
244 | ALIGN JUMP_ALIGN
|
---|
245 | .FormatWordFromAXtoStringBufferInCSDI:
|
---|
246 | push bp
|
---|
247 | push di
|
---|
248 | mov si, di
|
---|
249 | xchg cx, ax
|
---|
250 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
251 |
|
---|
252 | mov bx, cs
|
---|
253 | mov ax, si
|
---|
254 | CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
|
---|
255 | mov bl, ATTRIBUTES_NOT_USED
|
---|
256 | mov ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
|
---|
257 | CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
|
---|
258 | lea ax, [si+STRING_BUFFER_SIZE]
|
---|
259 | CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
|
---|
260 |
|
---|
261 | mov si, .szFormatWord
|
---|
262 | mov bp, sp
|
---|
263 | push cx
|
---|
264 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
265 | mov al, NULL
|
---|
266 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL ; Terminate buffer with NULL
|
---|
267 |
|
---|
268 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
269 | pop di
|
---|
270 | pop bp
|
---|
271 | ret
|
---|
272 | .szFormatWord:
|
---|
273 | db "Integer %d selected!",NULL
|
---|
274 |
|
---|
275 |
|
---|
276 | ALIGN JUMP_ALIGN
|
---|
277 | .ShowDialogWithStringInCSDI:
|
---|
278 | push cs
|
---|
279 | pop ds
|
---|
280 | mov si, g_dialogInputOutput
|
---|
281 | mov WORD [si+DIALOG_INPUT.fszItems], di
|
---|
282 | CALL_MENU_LIBRARY DisplayMessageWithInputInDSSI
|
---|
283 | stc
|
---|
284 | ret
|
---|
285 |
|
---|
286 |
|
---|
287 | ALIGN JUMP_ALIGN
|
---|
288 | .TestProgressBar:
|
---|
289 | push cs
|
---|
290 | pop ds
|
---|
291 | mov si, g_dialogInputOutput
|
---|
292 | mov WORD [si+PROGRESS_DIALOG_IO.wCurrentProgressValue], 0
|
---|
293 | mov WORD [si+PROGRESS_DIALOG_IO.wMaxProgressValue], 500
|
---|
294 | mov WORD [si+PROGRESS_DIALOG_IO.wMinProgressValue], 0
|
---|
295 | mov WORD [si+PROGRESS_DIALOG_IO.fnTaskWithParamInDSSI], .ProgressTaskWithParamInDSSI
|
---|
296 | mov ax, 500 ; Counter for progress task
|
---|
297 | CALL_MENU_LIBRARY StartProgressTaskWithIoInDSSIandParamInDXAX
|
---|
298 | stc
|
---|
299 | ret
|
---|
300 |
|
---|
301 | ALIGN JUMP_ALIGN
|
---|
302 | .ProgressTaskWithParamInDSSI:
|
---|
303 | mov ax, 50000 ; 50 millisec delay
|
---|
304 | call Delay_MicrosecondsFromAX
|
---|
305 | dec si
|
---|
306 | CALL_MENU_LIBRARY SetUserDataFromDSSI
|
---|
307 | mov ax, 500
|
---|
308 | sub ax, si
|
---|
309 | push si
|
---|
310 | CALL_MENU_LIBRARY SetProgressValueFromAX
|
---|
311 | pop si
|
---|
312 | test si, si
|
---|
313 | jnz .ProgressTaskWithParamInDSSI
|
---|
314 | ret
|
---|
315 |
|
---|
316 |
|
---|
317 |
|
---|
318 | ALIGN WORD_ALIGN
|
---|
319 | .rgfnMenuEvents:
|
---|
320 | dw .InitializeMenu ; .InitializeMenuinitToDSSI
|
---|
321 | dw .NotHandled ; .ExitMenu
|
---|
322 | dw .NotHandled ; .IdleProcessing
|
---|
323 | dw .NotHandled ; .ItemHighlightedFromCX
|
---|
324 | dw .ItemSelectedFromCX ; .ItemSelectedFromCX
|
---|
325 | dw .NotHandled ; .KeyStrokeInDX
|
---|
326 | dw .RefreshTitle ; .RefreshTitle
|
---|
327 | dw .RefreshInformation ; .RefreshInformation
|
---|
328 | dw .RefreshItemFromCX ; .RefreshItemFromCX
|
---|
329 |
|
---|
330 | .rgszItems:
|
---|
331 | dw .szExitMenu
|
---|
332 | dw .szToggleTitle
|
---|
333 | dw .szToggleInfo
|
---|
334 | dw .szShowMessage
|
---|
335 | dw .szAskWord
|
---|
336 | dw .szAskString
|
---|
337 | dw .szAskSelection
|
---|
338 | dw .szAskFile
|
---|
339 | dw .szTestProgress
|
---|
340 | .szExitMenu: db "Exit menu",NULL
|
---|
341 | .szToggleTitle: db "Toggle title",NULL
|
---|
342 | .szToggleInfo: db "Toggle information",NULL
|
---|
343 | .szShowMessage: db "Display unformatted message",NULL
|
---|
344 | .szAskWord: db "Input word",NULL
|
---|
345 | .szAskString: db "Input string",NULL
|
---|
346 | .szAskSelection:db "Display selection dialog",NULL
|
---|
347 | .szAskFile: db "Display file dialog",NULL
|
---|
348 | .szTestProgress:db "Display progress bar",NULL
|
---|
349 | TEST_MENU_VALID_ITEMS EQU 9
|
---|
350 | TEST_MENU_TITLE_LINES EQU 2
|
---|
351 | TEST_MENU_INFO_LINES EQU 3
|
---|
352 |
|
---|
353 |
|
---|
354 |
|
---|
355 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
356 | ALIGN JUMP_ALIGN
|
---|
357 | LibraryTests_ForKeyboardLibrary:
|
---|
358 | mov ax, CURSOR_XY(0, 6)
|
---|
359 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
360 | call ReadUnsignedDecimalInteger
|
---|
361 | call ReadHexadecimalWord
|
---|
362 | ret
|
---|
363 |
|
---|
364 |
|
---|
365 | ReadUnsignedDecimalInteger:
|
---|
366 | mov si, .szEnterUnsignedWord
|
---|
367 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
368 | CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware ; Move hardware cursor
|
---|
369 |
|
---|
370 | mov bx, 10 ; Numeric base
|
---|
371 | call Keyboard_ReadUserInputtedWordWhilePrinting
|
---|
372 |
|
---|
373 | mov si, .szWordEntered
|
---|
374 | mov bp, sp
|
---|
375 | push ax
|
---|
376 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
377 | ret
|
---|
378 | .szWordEntered:
|
---|
379 | db ". Word entered: %u",LF,CR,NULL
|
---|
380 | .szEnterUnsignedWord:
|
---|
381 | db "Enter unsigned word: ",NULL
|
---|
382 |
|
---|
383 |
|
---|
384 | ReadHexadecimalWord:
|
---|
385 | mov si, .szEnterHexadecimalWord
|
---|
386 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
387 | CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware ; Move hardware cursor
|
---|
388 |
|
---|
389 | mov bx, 16 ; Numeric base
|
---|
390 | call Keyboard_ReadUserInputtedWordWhilePrinting
|
---|
391 |
|
---|
392 | mov si, .szWordEntered
|
---|
393 | mov bp, sp
|
---|
394 | push ax
|
---|
395 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
396 | ret
|
---|
397 | .szWordEntered:
|
---|
398 | db ". Word entered: %x",LF,CR,NULL
|
---|
399 | .szEnterHexadecimalWord:
|
---|
400 | db "Enter hexadecimal word: ",NULL
|
---|
401 |
|
---|
402 |
|
---|
403 |
|
---|
404 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
405 | ALIGN JUMP_ALIGN
|
---|
406 | LibraryTests_ForDisplayLibrary:
|
---|
407 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
408 | call PrintHorizontalRuler
|
---|
409 | call PrintVerticalRuler
|
---|
410 |
|
---|
411 | mov al, COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)
|
---|
412 | CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
|
---|
413 |
|
---|
414 | mov ax, CURSOR_XY(0, 1)
|
---|
415 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
416 | call PrintFormattedStrings
|
---|
417 |
|
---|
418 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
419 | ret
|
---|
420 |
|
---|
421 |
|
---|
422 | PrintHorizontalRuler:
|
---|
423 | mov ax, CURSOR_XY(0, 0)
|
---|
424 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
425 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
426 | eMOVZX cx, al
|
---|
427 | mov bx, 10<<8 ; Divider 10 to BH
|
---|
428 | .ColumnNumberLoop:
|
---|
429 | eMOVZX ax, bl ; Column index to AX (0...79)
|
---|
430 | div bh ; AH = 0...9, AL = attribute
|
---|
431 | mov dx, ax
|
---|
432 | inc ax ; Increment attribute for non-black foreground
|
---|
433 | CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
|
---|
434 | xchg ax, dx
|
---|
435 | mov al, '0'
|
---|
436 | add al, ah ; AL = '0'...'9'
|
---|
437 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL
|
---|
438 | inc bx ; Increment column index
|
---|
439 | loop .ColumnNumberLoop
|
---|
440 | ret
|
---|
441 |
|
---|
442 |
|
---|
443 | PrintVerticalRuler:
|
---|
444 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
445 | eMOVZX cx, ah ; Number of rows to CX
|
---|
446 | dec ax ; Last column
|
---|
447 | xor ah, ah
|
---|
448 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
449 |
|
---|
450 | dec cx ; Decrement rows to print last row outside loop
|
---|
451 | mov bx, 10<<8 ; BH = 10 (divider), BL = 0 (row index)
|
---|
452 | mov si, .szVerticalRulerCharacter
|
---|
453 | .RowNumberLoop:
|
---|
454 | call .PrintRowNumberFromBL
|
---|
455 | inc bx ; Increment row index
|
---|
456 | loop .RowNumberLoop
|
---|
457 |
|
---|
458 | ; Last row
|
---|
459 | mov si, .szLastVerticalRulerCharacter
|
---|
460 | .PrintRowNumberFromBL:
|
---|
461 | eMOVZX ax, bl ; Row index to AX (0...24)
|
---|
462 | div bh ; AH = 0...9, AL = attribute
|
---|
463 | add al, COLOR_GRAY ; Start from color GRAY
|
---|
464 | mov bp, sp ; Prepare BP for string formatting
|
---|
465 | push ax ; Push attribute
|
---|
466 | eMOVZX ax, ah
|
---|
467 | push ax ; Push row index
|
---|
468 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
469 | ret
|
---|
470 |
|
---|
471 | .szVerticalRulerCharacter:
|
---|
472 | db "%A%u",LF,NULL
|
---|
473 | .szLastVerticalRulerCharacter:
|
---|
474 | db "%A%u",NULL
|
---|
475 |
|
---|
476 |
|
---|
477 | PrintFormattedStrings:
|
---|
478 | call .PrintIntegers
|
---|
479 | call .PrintHexadecimals
|
---|
480 | call .PrintCharacters
|
---|
481 | call .PrintStrings
|
---|
482 | call .RepeatChar
|
---|
483 | ret
|
---|
484 |
|
---|
485 | .PrintIntegers:
|
---|
486 | mov si, .szIntegers
|
---|
487 | mov bp, sp
|
---|
488 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
489 | ePUSH_T ax, -32768
|
---|
490 | ePUSH_T ax, -1
|
---|
491 | ePUSH_T ax, 0
|
---|
492 | ePUSH_T ax, 1
|
---|
493 | ePUSH_T ax, 65535
|
---|
494 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
495 | ret
|
---|
496 | .szIntegers:
|
---|
497 | db "Integers -32768, -1, 0, 1, 65535: %A|%6-d|%6-d|%6-d|%6-d|%6-u|",LF,CR,NULL
|
---|
498 |
|
---|
499 | .PrintHexadecimals:
|
---|
500 | mov si, .szHexadecimals
|
---|
501 | mov bp, sp
|
---|
502 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
503 | ePUSH_T ax, 0CACAh
|
---|
504 | ePUSH_T ax, 0FFFFh
|
---|
505 | ePUSH_T ax, 0
|
---|
506 | ePUSH_T ax, 5A5Ah
|
---|
507 | ePUSH_T ax, 0A5A5h
|
---|
508 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
509 | ret
|
---|
510 | .szHexadecimals:
|
---|
511 | db "Hexadecimals CACAh, FFFFh, 0, 5A5Ah, A5A5h:%A|%6-x|%6-x|%6-x|%6-x|%6-x|",LF,CR,NULL
|
---|
512 |
|
---|
513 | .PrintCharacters:
|
---|
514 | mov si, .szCharacters
|
---|
515 | mov bp, sp
|
---|
516 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
517 | ePUSH_T ax, 'a'
|
---|
518 | ePUSH_T ax, 'B'
|
---|
519 | ePUSH_T ax, 'c'
|
---|
520 | ePUSH_T ax, 'D'
|
---|
521 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
522 | ret
|
---|
523 | .szCharacters:
|
---|
524 | db "Characters a, B, c, D, percent: %A|%6c|%6c|%6c|%6c|%6%|",LF,CR,NULL
|
---|
525 |
|
---|
526 | .PrintStrings:
|
---|
527 | mov si, .szStrings
|
---|
528 | mov bp, sp
|
---|
529 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
530 | ePUSH_T ax, .szCSSI
|
---|
531 | ePUSH_T ax, .szFar
|
---|
532 | push cs
|
---|
533 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
534 | ret
|
---|
535 | .szStrings:
|
---|
536 | db "Strings ",'"',"Hello CSSI",'"'," and ",'"',"Far",'"',": %A|%20s|%13S|",LF,CR,NULL
|
---|
537 | .szCSSI:
|
---|
538 | db "Hello CSSI",NULL
|
---|
539 | .szFar:
|
---|
540 | db "Far",NULL
|
---|
541 |
|
---|
542 | .RepeatChar:
|
---|
543 | mov si, .szRepeat
|
---|
544 | mov bp, sp
|
---|
545 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
546 | ePUSH_T ax, '-'
|
---|
547 | ePUSH_T ax, 36
|
---|
548 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
549 | ret
|
---|
550 | .szRepeat:
|
---|
551 | db "Repeating character '-': %A%t",LF,CR,NULL
|
---|
552 |
|
---|
553 |
|
---|
554 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
555 | LibraryTests_Sort:
|
---|
556 | call .PrintWords
|
---|
557 | push cs
|
---|
558 | pop ds
|
---|
559 | mov si, .rgwItems
|
---|
560 | mov dx, 7
|
---|
561 | mov cx, 2
|
---|
562 | mov bx, .Comparator
|
---|
563 | call Sort_ItemsFromDSSIwithCountInDXsizeInCXandComparatorInBX
|
---|
564 | call .PrintWords
|
---|
565 | ret
|
---|
566 |
|
---|
567 |
|
---|
568 | .Comparator:
|
---|
569 | push ax
|
---|
570 | mov ax, [si]
|
---|
571 | DISPLAY_DEBUG_CHARACTER 'I'
|
---|
572 | DISPLAY_DEBUG_WORD_AND_WAIT_ANY_KEY ax, 16
|
---|
573 | DISPLAY_DEBUG_CHARACTER ','
|
---|
574 | DISPLAY_DEBUG_WORD_AND_WAIT_ANY_KEY [es:di], 16
|
---|
575 | DISPLAY_DEBUG_CHARACTER ' '
|
---|
576 | cmp ax, [es:di]
|
---|
577 | pop ax
|
---|
578 | ret
|
---|
579 |
|
---|
580 | .PrintWords:
|
---|
581 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters
|
---|
582 | mov cx, 7
|
---|
583 | push cs
|
---|
584 | pop ds
|
---|
585 | mov si, .rgwItems
|
---|
586 | mov bx, 16
|
---|
587 | .Loop:
|
---|
588 | lodsw
|
---|
589 | CALL_DISPLAY_LIBRARY PrintSignedWordFromAXWithBaseInBX
|
---|
590 | CALL_DISPLAY_LIBRARY PrintNewlineCharacters
|
---|
591 | loop .Loop
|
---|
592 | ret
|
---|
593 |
|
---|
594 |
|
---|
595 | .rgwItems:
|
---|
596 | dw '['
|
---|
597 | dw 'n'
|
---|
598 | dw '5'
|
---|
599 | dw '.'
|
---|
600 | dw ']'
|
---|
601 | dw 'a'
|
---|
602 | dw 'A'
|
---|
603 |
|
---|
604 |
|
---|
605 |
|
---|
606 | ; Section containing initialized data
|
---|
607 | ;SECTION .data
|
---|
608 |
|
---|
609 | g_szDialogTitle:
|
---|
610 | db "This is a generic title for all dialogs.",NULL
|
---|
611 | g_szDialogInfo:
|
---|
612 | db "This is a generic information for all dialogs.",NULL
|
---|
613 | g_szVeryLongString:
|
---|
614 | db "This is a very long string containing multiple lines of text. This is needed "
|
---|
615 | db "so scroll bars and message dialog can be tested. This string does not use "
|
---|
616 | db "formatting so it should be simple to display this correctly. This string "
|
---|
617 | db "does, however, use newline characters. Lets change line right now!",CR,LF,
|
---|
618 | db "Well did it work? Let's try line feed alone",LF,"Well? "
|
---|
619 | db "We could also see what two spaces does _ _. There was two spaces between "
|
---|
620 | db "underscores. Lets try three this time _ _. Well, did they work correctly? "
|
---|
621 | db "What next, I guess that was all, no wait. Let's see what TAB does! Here it "
|
---|
622 | db "goes:",TAB,"Well did it work? Just one more time:",TAB,"Well are we good? "
|
---|
623 | db "No since LF is the only supported control character, unfortunately. "
|
---|
624 | db "This is the last sentence of this long string!",NULL
|
---|
625 |
|
---|
626 | g_dialogInputOutput:
|
---|
627 | istruc DIALOG_INPUT
|
---|
628 | at DIALOG_INPUT.fszTitle, dw g_szDialogTitle
|
---|
629 | at DIALOG_INPUT.fszInfo, dw g_szDialogInfo
|
---|
630 | iend
|
---|
631 | times 20 db 0
|
---|
632 |
|
---|
633 |
|
---|
634 | ; Section containing uninitialized data
|
---|
635 | SECTION .bss
|
---|
636 |
|
---|
637 | STRING_BUFFER_SIZE EQU 100
|
---|
638 | g_szBuffer:
|
---|