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