[41] | 1 | ; File name : LibraryTests.asm
|
---|
| 2 | ; Project name : Assembly Library
|
---|
| 3 | ; Created date : 27.6.2010
|
---|
| 4 | ; Last update : 15.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_ForDisplayLibrary
|
---|
| 36 | ;call LibraryTests_ForKeyboardLibrary
|
---|
| 37 | call LibraryTests_ForMenuLibrary
|
---|
| 38 |
|
---|
| 39 | ; Exit to DOS
|
---|
| 40 | ;mov ax, CURSOR_XY(1, 1)
|
---|
| 41 | ;CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
| 42 | CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware
|
---|
| 43 | mov ax, 4C00h ; Exit to DOS
|
---|
| 44 | int 21h
|
---|
| 45 |
|
---|
| 46 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
---|
| 47 | ALIGN JUMP_ALIGN
|
---|
| 48 | LibraryTests_ForMenuLibrary:
|
---|
| 49 | mov [cs:g_dialogInputOutput+DIALOG_INPUT.fszTitle+2], cs
|
---|
| 50 | mov [cs:g_dialogInputOutput+DIALOG_INPUT.fszItems+2], cs
|
---|
| 51 | mov [cs:g_dialogInputOutput+DIALOG_INPUT.fszInfo+2], cs
|
---|
| 52 |
|
---|
| 53 | mov bx, .MenuEventHandler
|
---|
| 54 | call MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX
|
---|
| 55 | ret
|
---|
| 56 |
|
---|
| 57 | ALIGN JUMP_ALIGN
|
---|
| 58 | .MenuEventHandler:
|
---|
| 59 | jmp [cs:bx+.rgfnMenuEvents]
|
---|
| 60 | .NotHandled:
|
---|
| 61 | clc ; Not handled so clear
|
---|
| 62 | ret
|
---|
| 63 |
|
---|
| 64 | ALIGN JUMP_ALIGN
|
---|
| 65 | .InitializeMenu:
|
---|
| 66 | mov WORD [si+MENUINIT.wTimeoutTicks], 10000 / 55 ; 10 seconds
|
---|
| 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 ax, 1
|
---|
| 73 | CALL_MENU_LIBRARY HighlightItemFromAX
|
---|
| 74 | stc
|
---|
| 75 | ret
|
---|
| 76 |
|
---|
| 77 | ALIGN JUMP_ALIGN
|
---|
| 78 | .RefreshTitle:
|
---|
| 79 | mov si, .szMenuTitle
|
---|
| 80 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
|
---|
| 81 | stc
|
---|
| 82 | ret
|
---|
| 83 | .szMenuTitle:
|
---|
| 84 | db "First line for menu title.",CR,LF,
|
---|
| 85 | db "This is the second line.",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,",CR,LF,
|
---|
| 99 | db "This is the last information line.",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+DIALOG_INPUT.fszItems], 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 | mov [si+STRING_DIALOG_IO.fpReturnBuffer+2], cs
|
---|
| 232 | CALL_MENU_LIBRARY GetFileNameWithIoInDSSI
|
---|
| 233 | cmp BYTE [g_dialogInputOutput+FILE_DIALOG_IO.bUserCancellation], TRUE
|
---|
| 234 | je SHORT .FileSelectionCancelled
|
---|
| 235 |
|
---|
| 236 | mov di, g_dialogInputOutput + FILE_DIALOG_IO.szFile
|
---|
| 237 | call .ShowDialogWithStringInCSDI
|
---|
| 238 | .FileSelectionCancelled:
|
---|
| 239 | stc
|
---|
| 240 | ret
|
---|
| 241 | .szAllFiles:
|
---|
| 242 | db "*.*",NULL
|
---|
| 243 |
|
---|
| 244 |
|
---|
| 245 | ALIGN JUMP_ALIGN
|
---|
| 246 | .FormatWordFromAXtoStringBufferInCSDI:
|
---|
| 247 | push bp
|
---|
| 248 | push di
|
---|
| 249 | mov si, di
|
---|
| 250 | xchg cx, ax
|
---|
| 251 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
| 252 |
|
---|
| 253 | mov bx, cs
|
---|
| 254 | mov ax, si
|
---|
| 255 | CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
|
---|
| 256 | mov ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
|
---|
| 257 | CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
|
---|
| 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 ax, CURSOR_XY(0, 1)
|
---|
| 412 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
| 413 | mov al, COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)
|
---|
| 414 | CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
|
---|
| 415 | call PrintFormattedStrings
|
---|
| 416 |
|
---|
| 417 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
| 418 | ret
|
---|
| 419 |
|
---|
| 420 |
|
---|
| 421 | PrintHorizontalRuler:
|
---|
| 422 | mov ax, CURSOR_XY(0, 0)
|
---|
| 423 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
| 424 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
| 425 | eMOVZX cx, al
|
---|
| 426 | mov bx, 10<<8 ; Divider 10 to BH
|
---|
| 427 | .ColumnNumberLoop:
|
---|
| 428 | eMOVZX ax, bl ; Column index to AX (0...79)
|
---|
| 429 | div bh ; AH = 0...9, AL = attribute
|
---|
| 430 | mov dx, ax
|
---|
| 431 | inc ax ; Increment attribute for non-black foreground
|
---|
| 432 | CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
|
---|
| 433 | xchg ax, dx
|
---|
| 434 | mov al, '0'
|
---|
| 435 | add al, ah ; AL = '0'...'9'
|
---|
| 436 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL
|
---|
| 437 | inc bx ; Increment column index
|
---|
| 438 | loop .ColumnNumberLoop
|
---|
| 439 | ret
|
---|
| 440 |
|
---|
| 441 |
|
---|
| 442 | PrintVerticalRuler:
|
---|
| 443 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
|
---|
| 444 | eMOVZX cx, ah ; Number of rows to CX
|
---|
| 445 | dec ax ; Last column
|
---|
| 446 | xor ah, ah
|
---|
| 447 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
|
---|
| 448 |
|
---|
| 449 | dec cx ; Decrement rows to print last row outside loop
|
---|
| 450 | mov bx, 10<<8 ; BH = 10 (divider), BL = 0 (row index)
|
---|
| 451 | mov si, .szVerticalRulerCharacter
|
---|
| 452 | .RowNumberLoop:
|
---|
| 453 | call .PrintRowNumberFromBL
|
---|
| 454 | inc bx ; Increment row index
|
---|
| 455 | loop .RowNumberLoop
|
---|
| 456 |
|
---|
| 457 | ; Last row
|
---|
| 458 | mov si, .szLastVerticalRulerCharacter
|
---|
| 459 | .PrintRowNumberFromBL:
|
---|
| 460 | eMOVZX ax, bl ; Row index to AX (0...24)
|
---|
| 461 | div bh ; AH = 0...9, AL = attribute
|
---|
| 462 | add al, COLOR_GRAY ; Start from color GRAY
|
---|
| 463 | mov bp, sp ; Prepare BP for string formatting
|
---|
| 464 | push ax ; Push attribute
|
---|
| 465 | eMOVZX ax, ah
|
---|
| 466 | push ax ; Push row index
|
---|
| 467 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 468 | ret
|
---|
| 469 |
|
---|
| 470 | .szVerticalRulerCharacter:
|
---|
| 471 | db "%A%u",LF,NULL
|
---|
| 472 | .szLastVerticalRulerCharacter:
|
---|
| 473 | db "%A%u",NULL
|
---|
| 474 |
|
---|
| 475 |
|
---|
| 476 | PrintFormattedStrings:
|
---|
| 477 | call .PrintIntegers
|
---|
| 478 | call .PrintHexadecimals
|
---|
| 479 | call .PrintCharacters
|
---|
| 480 | call .PrintStrings
|
---|
| 481 | call .RepeatChar
|
---|
| 482 | ret
|
---|
| 483 |
|
---|
| 484 | .PrintIntegers:
|
---|
| 485 | mov si, .szIntegers
|
---|
| 486 | mov bp, sp
|
---|
| 487 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
| 488 | ePUSH_T ax, -32768
|
---|
| 489 | ePUSH_T ax, -1
|
---|
| 490 | ePUSH_T ax, 0
|
---|
| 491 | ePUSH_T ax, 1
|
---|
| 492 | ePUSH_T ax, 65535
|
---|
| 493 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 494 | ret
|
---|
| 495 | .szIntegers:
|
---|
| 496 | db "Integers -32768, -1, 0, 1, 65535: %A|%6d|%6d|%6d|%6d|%6u|",LF,CR,NULL
|
---|
| 497 |
|
---|
| 498 | .PrintHexadecimals:
|
---|
| 499 | mov si, .szHexadecimals
|
---|
| 500 | mov bp, sp
|
---|
| 501 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
| 502 | ePUSH_T ax, 0CACAh
|
---|
| 503 | ePUSH_T ax, 0FFFFh
|
---|
| 504 | ePUSH_T ax, 0
|
---|
| 505 | ePUSH_T ax, 5A5Ah
|
---|
| 506 | ePUSH_T ax, 0A5A5h
|
---|
| 507 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 508 | ret
|
---|
| 509 | .szHexadecimals:
|
---|
| 510 | db "Hexadecimals CACAh, FFFFh, 0, 5A5Ah, A5A5h:%A|%6x|%6x|%6x|%6x|%6x|",LF,CR,NULL
|
---|
| 511 |
|
---|
| 512 | .PrintCharacters:
|
---|
| 513 | mov si, .szCharacters
|
---|
| 514 | mov bp, sp
|
---|
| 515 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
| 516 | ePUSH_T ax, 'a'
|
---|
| 517 | ePUSH_T ax, 'B'
|
---|
| 518 | ePUSH_T ax, 'c'
|
---|
| 519 | ePUSH_T ax, 'D'
|
---|
| 520 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 521 | ret
|
---|
| 522 | .szCharacters:
|
---|
| 523 | db "Characters a, B, c, D, percent: %A|%6c|%6c|%6c|%6c|%6%|",LF,CR,NULL
|
---|
| 524 |
|
---|
| 525 | .PrintStrings:
|
---|
| 526 | mov si, .szStrings
|
---|
| 527 | mov bp, sp
|
---|
| 528 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
| 529 | ePUSH_T ax, .szCSSI
|
---|
| 530 | ePUSH_T ax, .szFar
|
---|
| 531 | push cs
|
---|
| 532 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 533 | ret
|
---|
| 534 | .szStrings:
|
---|
| 535 | db "Strings ",'"',"Hello CSSI",'"'," and ",'"',"Far",'"',": %A|%20s|%13S|",LF,CR,NULL
|
---|
| 536 | .szCSSI:
|
---|
| 537 | db "Hello CSSI",NULL
|
---|
| 538 | .szFar:
|
---|
| 539 | db "Far",NULL
|
---|
| 540 |
|
---|
| 541 | .RepeatChar:
|
---|
| 542 | mov si, .szRepeat
|
---|
| 543 | mov bp, sp
|
---|
| 544 | ePUSH_T ax, COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLACK)
|
---|
| 545 | ePUSH_T ax, '-'
|
---|
| 546 | ePUSH_T ax, 36
|
---|
| 547 | CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
|
---|
| 548 | ret
|
---|
| 549 | .szRepeat:
|
---|
| 550 | db "Repeating character '-': %A%t",LF,CR,NULL
|
---|
| 551 |
|
---|
| 552 |
|
---|
| 553 |
|
---|
| 554 | ; Section containing initialized data
|
---|
| 555 | ;SECTION .data
|
---|
| 556 |
|
---|
| 557 | g_szDialogTitle:
|
---|
| 558 | db "This is a generic title for all dialogs.",NULL
|
---|
| 559 | g_szDialogInfo:
|
---|
| 560 | db "This is a generic information for all dialogs.",NULL
|
---|
| 561 | g_szVeryLongString:
|
---|
| 562 | db "This is a very long string containing multiple lines of text. This is needed "
|
---|
| 563 | db "so scroll bars and message dialog can be tested. This string does not use "
|
---|
| 564 | db "formatting so it should be simple to display this correctly. This string "
|
---|
| 565 | db "does, however, use newline characters. Lets change line right now!",CR,LF,
|
---|
| 566 | db "Well did it work? Let's try line feed alone",LF,"Well? "
|
---|
| 567 | db "We could also see what two spaces does _ _. There was two spaces between "
|
---|
| 568 | db "underscores. Lets try three this time _ _. Well, did they work correctly? "
|
---|
| 569 | db "What next, I guess that was all, no wait. Let's see what TAB does! Here it "
|
---|
| 570 | db "goes:",TAB,"Well did it work? Just one more time:",TAB,"Well are we good? "
|
---|
| 571 | db "No since LF is the only supported control character, unfortunately. "
|
---|
| 572 | db "This is the last sentence of this long string!",NULL
|
---|
| 573 |
|
---|
| 574 | g_dialogInputOutput:
|
---|
| 575 | istruc DIALOG_INPUT
|
---|
| 576 | at DIALOG_INPUT.fszTitle, dw g_szDialogTitle
|
---|
| 577 | at DIALOG_INPUT.fszInfo, dw g_szDialogInfo
|
---|
| 578 | iend
|
---|
| 579 | times 20 db 0
|
---|
| 580 |
|
---|
| 581 |
|
---|
| 582 | ; Section containing uninitialized data
|
---|
| 583 | SECTION .bss
|
---|
| 584 |
|
---|
| 585 | STRING_BUFFER_SIZE EQU 100
|
---|
| 586 | g_szBuffer:
|
---|