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