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