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 "First line for menu title.",CR,LF,
|
---|
86 | db "This is the second line.",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,",CR,LF,
|
---|
99 | db "Information line 2,",CR,LF,
|
---|
100 | db "This is the last information line.",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 .ExitMenu
|
---|
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 | .ExitMenu:
|
---|
153 | CALL_MENU_LIBRARY Close
|
---|
154 | stc
|
---|
155 | ret
|
---|
156 |
|
---|
157 | ALIGN JUMP_ALIGN
|
---|
158 | .ToggleTitle:
|
---|
159 | mov al, [bp+MENUINIT.bTitleLines]
|
---|
160 | xor al, TEST_MENU_TITLE_LINES
|
---|
161 | CALL_MENU_LIBRARY SetTitleHeightFromAL
|
---|
162 | jmp SHORT .RefreshMenuWindow
|
---|
163 | ALIGN JUMP_ALIGN
|
---|
164 | .ToggleInfo:
|
---|
165 | mov al, [bp+MENUINIT.bInfoLines]
|
---|
166 | xor al, TEST_MENU_INFO_LINES
|
---|
167 | CALL_MENU_LIBRARY SetInformationHeightFromAL
|
---|
168 | .RefreshMenuWindow:
|
---|
169 | CALL_MENU_LIBRARY RestartTimeout
|
---|
170 | CALL_MENU_LIBRARY RefreshWindow
|
---|
171 | stc
|
---|
172 | ret
|
---|
173 |
|
---|
174 | ALIGN JUMP_ALIGN
|
---|
175 | .ShowMessageDialogWithUnformattedText:
|
---|
176 | mov di, g_szVeryLongString
|
---|
177 | jmp .ShowDialogWithStringInCSDI
|
---|
178 |
|
---|
179 | ALIGN JUMP_ALIGN
|
---|
180 | .AskWordFromUser:
|
---|
181 | mov si, g_dialogInputOutput
|
---|
182 | mov BYTE [si+WORD_DIALOG_IO.bNumericBase], 10
|
---|
183 | mov WORD [si+WORD_DIALOG_IO.wMin], 10
|
---|
184 | mov WORD [si+WORD_DIALOG_IO.wMax], 20
|
---|
185 | CALL_MENU_LIBRARY GetWordWithIoInDSSI
|
---|
186 |
|
---|
187 | mov ax, [si+WORD_DIALOG_IO.wReturnWord]
|
---|
188 | mov di, g_szBuffer
|
---|
189 | call .FormatWordFromAXtoStringBufferInCSDI
|
---|
190 | call .ShowDialogWithStringInCSDI
|
---|
191 | stc
|
---|
192 | ret
|
---|
193 |
|
---|
194 | ALIGN JUMP_ALIGN
|
---|
195 | .AskStringFromUser:
|
---|
196 | mov si, g_dialogInputOutput
|
---|
197 | mov WORD [si+STRING_DIALOG_IO.fnCharFilter], NULL
|
---|
198 | mov WORD [si+STRING_DIALOG_IO.wBufferSize], 17
|
---|
199 | mov WORD [si+STRING_DIALOG_IO.fpReturnBuffer], g_szBuffer
|
---|
200 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], cs
|
---|
201 | CALL_MENU_LIBRARY GetStringWithIoInDSSI
|
---|
202 |
|
---|
203 | mov di, g_szBuffer
|
---|
204 | call .ShowDialogWithStringInCSDI
|
---|
205 | stc
|
---|
206 | ret
|
---|
207 |
|
---|
208 | ALIGN JUMP_ALIGN
|
---|
209 | .AskSelectionFromUser:
|
---|
210 | mov si, g_dialogInputOutput
|
---|
211 | mov WORD [si+DIALOG_INPUT.fszItems], .szSelections
|
---|
212 | CALL_MENU_LIBRARY GetSelectionToAXwithInputInDSSI
|
---|
213 |
|
---|
214 | mov di, g_szBuffer
|
---|
215 | call .FormatWordFromAXtoStringBufferInCSDI
|
---|
216 | call .ShowDialogWithStringInCSDI
|
---|
217 | stc
|
---|
218 | ret
|
---|
219 | .szSelections:
|
---|
220 | db "Cancel",LF
|
---|
221 | db "Yes",LF
|
---|
222 | db "No",NULL
|
---|
223 |
|
---|
224 | ALIGN JUMP_ALIGN
|
---|
225 | .AskFileFromUser:
|
---|
226 | mov si, g_dialogInputOutput
|
---|
227 | mov WORD [si+DIALOG_INPUT.fszItems], g_szBuffer
|
---|
228 | mov BYTE [si+FILE_DIALOG_IO.bDialogFlags], FLG_FILEDIALOG_DIRECTORY | FLG_FILEDIALOG_NEW | FLG_FILEDIALOG_DRIVES
|
---|
229 | mov BYTE [si+FILE_DIALOG_IO.bFileAttributes], FLG_FILEATTR_DIRECTORY | FLG_FILEATTR_ARCHIVE
|
---|
230 | mov WORD [si+FILE_DIALOG_IO.fpFileFilterString], .szAllFiles
|
---|
231 | mov [si+FILE_DIALOG_IO.fpFileFilterString+2], cs
|
---|
232 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+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 .NotHandled ; .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!",CR,LF,
|
---|
620 | db "Well did it work? Let's try line feed alone",LF,"Well? "
|
---|
621 | db "We could also see what two spaces does _ _. There was two spaces between "
|
---|
622 | db "underscores. Lets try three this time _ _. Well, did they work correctly? "
|
---|
623 | db "What next, I guess that was all, no wait. Let's see what TAB does! Here it "
|
---|
624 | db "goes:",TAB,"Well did it work? Just one more time:",TAB,"Well are we good? "
|
---|
625 | db "No since LF is the only supported control character, unfortunately. "
|
---|
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:
|
---|