1 ; **************************************************************************** 2 ; cgaplay2.s - TRDOS 386 (TRDOS v2.0.9) WAV PLAYER - Video Mode 13h 3 ; ---------------------------------------------------------------------------- 4 ; CGAPLAY2.PRG ! Sound Blaster 16 .WAV PLAYER program by Erdogan TAN 5 ; 6 ; 06/01/2025 - play music from multiple wav files - 7 ; 8 ; [ Last Modification: 05/02/2025 ] 9 ; 10 ; Modified from CGAPLAY.PRG .wav player program by Erdogan Tan, 01/01/2025 11 ; SB16PLAY.PRG, 20/12/2024 12 ; 13 ; **************************************************************************** 14 ; nasm cgaplay2.s -l cgaplay2.txt -o CGAPLAY2.PRG -Z error.txt 15 16 ; 02/01/2025 17 ; cgaplay2.asm - CGAPLAY2.COM - Sound Blaster 16 18 ; 01/01/2025 19 ; cgaplay.s - CGAPLAY.PRG - AC97 - Video Mode 13h (320*200, 256 colors) 20 ; 26/12/2024 21 ; vgaplay.s - VGAPLAY.PRG - AC97 - VESA Mode 101h (640*480, 256 colors) 22 ; 20/12/2024 23 ; sb16play.s : Video Mode 03h (Text Mode) 24 25 ; 07/12/2024 - playwav9.s - interrupt (srb) + tuneloop version 26 ; ------------------------------------------------------------ 27 ; INTERRUPT (SRB) + TUNELOOP version ; 24/11/2024 (PLAYWAV9.ASM) 28 ; (running in DOSBOX, VIRTUALBOX, QEMU is ok) 29 ; Signal Response Byte = message/signal to user about an event/interrupt 30 ; as requested (TuneLoop procedure continuously checks this SRB) 31 ; (TRDOS 386 v2 feature is used here as very simple interrupt handler output) 32 33 ; ------------------------------------------------------------ 34 35 ; 30/11/2024 36 ; 20/08/2024 ; TRDOS 386 v2.0.9 37 ; 29/04/2016 38 _ver equ 0 39 _exit equ 1 40 _fork equ 2 41 _read equ 3 42 _write equ 4 43 _open equ 5 44 _close equ 6 45 _wait equ 7 46 _creat equ 8 47 _link equ 9 48 _unlink equ 10 49 _exec equ 11 50 _chdir equ 12 51 _time equ 13 52 _mkdir equ 14 53 _chmod equ 15 54 _chown equ 16 55 _break equ 17 56 _stat equ 18 57 _seek equ 19 58 _tell equ 20 59 _mount equ 21 60 _umount equ 22 61 _setuid equ 23 62 _getuid equ 24 63 _stime equ 25 64 _quit equ 26 65 _intr equ 27 66 _fstat equ 28 67 _emt equ 29 68 _mdate equ 30 69 _video equ 31 70 _audio equ 32 71 _timer equ 33 72 _sleep equ 34 73 _msg equ 35 74 _geterr equ 36 75 _fpsave equ 37 76 _pri equ 38 77 _rele equ 39 78 _fff equ 40 79 _fnf equ 41 80 _alloc equ 42 81 _dalloc equ 43 82 _calbac equ 44 83 _dma equ 45 84 _stdio equ 46 85 86 ; ------------------------------------------------------------ 87 88 %macro sys 1-4 89 ; 29/04/2016 - TRDOS 386 (TRDOS v2.0) 90 ; 03/09/2015 91 ; 13/04/2015 92 ; Retro UNIX 386 v1 system call. 93 %if %0 >= 2 94 mov ebx, %2 95 %if %0 >= 3 96 mov ecx, %3 97 %if %0 = 4 98 mov edx, %4 99 %endif 100 %endif 101 %endif 102 mov eax, %1 103 ;int 30h 104 int 40h ; TRDOS 386 (TRDOS v2.0) 105 %endmacro 106 107 ; Retro UNIX 386 v1 system call format: 108 ; sys systemcall (eax) , , 109 110 ; ------------------------------------------------------------ 111 112 ; player internal variables and other equates. 113 BUFFERSIZE equ 32768 ; audio (half) buffer size 114 ENDOFFILE equ 1 ; flag for knowing end of file 115 ; 06/01/2025 116 DMABUFFERSIZE equ BUFFERSIZE*2 117 118 ; ------------------------------------------------------------ 119 120 [BITS 32] ; 32-bit intructions 121 122 [ORG 0] 123 124 START_CODE: 125 ; Prints the Credits Text. 126 sys _msg, Credits, 255, 0Bh 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000000 BB[EB0C0000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000005 B9FF000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 0000000A BA0B000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000000F B823000000 <1> mov eax, %1 103 <1> 104 00000014 CD40 <1> int 40h 127 128 ; clear bss 129 00000016 BF[78120000] mov edi, bss_start 130 0000001B B962230000 mov ecx, (bss_end - bss_start)/4 131 00000020 31C0 xor eax, eax 132 00000022 F3AB rep stosd 133 134 ; ------------------------------------------------------------- 135 136 ; 02/01/2025 137 ; 24/11/2024 138 ; Detect (& Reset) Sound Blaster 16 Audio Device 139 00000024 E8C1040000 call DetectSB16 140 ;jnc short GetFileName 141 ; 06/01/2025 142 00000029 731B jnc short get_audio_info 143 144 ; 30/11/2024 145 ; 30/05/2024 146 _dev_not_ready: 147 ; couldn't find the audio device! 148 sys _msg, noDevMsg, 255, 0Fh 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 0000002B BB[8B0D0000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000030 B9FF000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000035 BA0F000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000003A B823000000 <1> mov eax, %1 103 <1> 104 0000003F CD40 <1> int 40h 149 00000041 E984020000 jmp Exit 150 151 ; ------------------------------------------------------------- 152 153 ; 06/01/2025 (cgaplay2.s) 154 get_audio_info: 155 ; 20/12/2024 (playwavx.s, sb16play.s) 156 ; 07/12/2024 (playwav9.s) 157 ; 06/06/2017 158 sys _audio, 0E00h ; get audio controller info 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000046 BB000E0000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000004B B820000000 <1> mov eax, %1 103 <1> 104 00000050 CD40 <1> int 40h 159 00000052 0F82BA020000 jc error_exit ; 25/11/2023 160 ; 20/12/2024 161 00000058 8915[78170000] mov [audio_io_base], edx 162 0000005E A2[7C170000] mov [audio_intr], al 163 164 ; ------------------------------------------------------------- 165 166 ; 06/01/2025 167 ; 30/12/2024 168 ;;; 169 ; DIRECT VGA MEMORY ACCESS 170 ; bl = 0, bh = 5 171 ; Direct access/map to VGA memory (0A0000h) 172 173 sys _video, 0500h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000063 BB00050000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000068 B81F000000 <1> mov eax, %1 103 <1> 104 0000006D CD40 <1> int 40h 174 0000006F 3D00000A00 cmp eax, 0A0000h 175 00000074 7405 je short set_video_mode_13h 176 177 ; 30/12/2024 178 00000076 E99C020000 jmp trdos386_error 179 180 set_video_mode_13h: 181 ;; Set Video Mode to 13h 182 ;sys _video, 0813h 183 ;cmp eax, 14h 184 ;je short mode_13h_set_ok 185 186 ; set VGA mode by using int 31h 187 0000007B 66B81300 mov ax, 13h ; mode 13h ; 188 0000007F CD31 int 31h ; real mode: int 10h 189 190 ; ------------------------------------------------------------- 191 192 mode_13h_set_ok: 193 ; 30/12/2024 194 ; 24/12/2024 (setting for wave lighting points) 195 ;mov eax, 0A0000h 196 ;;add eax, 12*8*320 197 ;add eax, (13*8*320)+(2*320) 198 ; wave graphics start (top) line/row 199 ; 64 volume levels 200 ;mov [graphstart], eax 201 ;; 30/12/2024 202 ;;mov dword [graphstart], 0A0000h+(13*8*320)+(4*320) 203 ; 06/01/2025 204 ; 01/01/2025 205 ;mov dword [graphstart], 0A0000h+(11*8*320)+(4*320) 206 207 ; ------------------------------------------------------------- 208 209 ; 25/12/2024 210 ; 28/11/2024 211 Player_InitalizePSP: 212 ; 30/11/2024 213 ; (TRDOS 386 -Retro UNIX 386- argument transfer method) 214 ; (stack: argc,argv0addr,argv1addr,argv2addr .. 215 ; .. argv0text, argv1text ..) 216 ; ---- argc, argv[] ---- 217 00000081 89E6 mov esi, esp 218 00000083 AD lodsd 219 00000084 83F802 cmp eax, 2 ; two arguments 220 ; (program file name & mod file name) 221 00000087 0F824B020000 jb pmsg_usage ; nothing to do 222 ;mov [argc], al 223 0000008D C1E002 shl eax, 2 ; *4 224 00000090 01E0 add eax, esp 225 ; eax = last argument's address pointer 226 00000092 A3[BC170000] mov [argvl], eax ; last wav file (argument) 227 00000097 8935[B4170000] mov [argv], esi ; current argument (PRG file name) 228 0000009D AD lodsd ; skip program (PRG) file name 229 0000009E 8935[B8170000] mov [argvf], esi ; 1st wav file (argument) 230 231 ; 30/12/2024 232 Player_ParseParameters: 233 000000A4 EB2A jmp short Player_ParseNextParameter 234 ; 25/12/2024 235 check_p_command: 236 ; 07/12/2024 237 000000A6 8B35[B4170000] mov esi, [argv] 238 ; 239 000000AC 803D[80170000]50 cmp byte [command], 'P' 240 000000B3 7410 je short Player_ParsePreviousParameter 241 242 ; 07/12/2024 243 ; 30/11/2024 244 ;mov esi, [argv] ; current argument (wav file) ptr 245 000000B5 83C604 add esi, 4 246 000000B8 3B35[BC170000] cmp esi, [argvl] ; last argument (wav file) ptr 247 000000BE 7610 jna short Player_ParseNextParameter 248 jmp_Player_Quit: 249 000000C0 E9D6020000 jmp Player_Quit 250 251 Player_ParsePreviousParameter: 252 ; 29/11/2024 253 ;mov byte [command], 0 254 ; 30/11/2024 255 ;mov esi, [argv] ; 07/12/2024 256 000000C5 3B35[B8170000] cmp esi, [argvf] ; first argument (wav file) ptr 257 000000CB 7603 jna short Player_ParseNextParameter 258 000000CD 83EE04 sub esi, 4 259 Player_ParseNextParameter: 260 ; 30/11/2024 261 000000D0 8935[B4170000] mov [argv], esi ; set as current argument 262 263 ; 01/12/2024 264 000000D6 8B36 mov esi, [esi] 265 266 ; 30/12/2024 267 ; 29/11/2024 268 000000D8 E83C000000 call GetFileName 269 ;jcxz jmp_Player_Quit 270 000000DD E3E1 jecxz jmp_Player_Quit ; 30/11/2024 271 272 ; 30/12/2024 273 ; open existing file 274 ; 28/11/2024 275 000000DF BA[C0170000] mov edx, wav_file_name 276 000000E4 E84A040000 call openFile ; no error? ok. 277 000000E9 7376 jnc getwavparms ; 14/11/2024 278 279 ; 29/11/2024 280 000000EB 803D[81170000]00 cmp byte [filecount], 0 281 000000F2 77B2 ja short check_p_command 282 283 ; 25/12/2024 284 ; 21/12/2024 285 000000F4 E89A020000 call set_text_mode 286 ; file not found! 287 ; 30/11/2024 288 sys _msg, noFileErrMsg, 255, 0Ch 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000000F9 BB[C20D0000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 000000FE B9FF000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000103 BA0C000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000108 B823000000 <1> mov eax, %1 103 <1> 104 0000010D CD40 <1> int 40h 289 0000010F E9B6010000 jmp Exit 290 291 _exit_: 292 00000114 E976010000 jmp terminate 293 294 ; ------------------------------------------------------------- 295 296 ; 26/12/2024 297 ; 25/12/2024 298 ; 30/11/2024 (32bit) 299 ; 29/11/2024 300 ; 30/05/2024 301 GetFileName: 302 00000119 BF[C0170000] mov edi, wav_file_name 303 ; 30/11/2024 304 ;mov esi, [argv] 305 0000011E 31C9 xor ecx, ecx ; 0 306 ScanName: 307 00000120 AC lodsb 308 ;test al, al 309 ;jz short a_4 310 ; 29/11/2024 311 00000121 3C0D cmp al, 0Dh 312 00000123 7638 jna short a_4 313 00000125 3C20 cmp al, 20h 314 00000127 74F7 je short ScanName ; scan start of name. 315 00000129 AA stosb 316 0000012A B4FF mov ah, 0FFh 317 ;;; 318 ; 14/11/2024 319 ; (max. path length = 64 bytes for MSDOS ?) (*) 320 ;xor ecx, ecx ; 0 321 ;;; 322 a_0: 323 0000012C FEC4 inc ah 324 a_1: 325 ;;; 326 ; 14/11/2024 327 0000012E 41 inc ecx 328 ;;; 329 0000012F AC lodsb 330 00000130 AA stosb 331 00000131 3C2E cmp al, '.' 332 00000133 74F7 je short a_0 333 ; 29/11/2024 334 00000135 3C20 cmp al, 20h 335 ;and al, al 336 ;jnz short a_1 337 ;;; 338 ; 14/11/2024 339 00000137 7613 jna short a_3 340 00000139 20E4 and ah, ah 341 0000013B 7406 jz short a_2 342 0000013D 3C2F cmp al, '/' ; 14/12/2024 343 0000013F 7502 jne short a_2 344 00000141 B400 mov ah, 0 345 a_2: 346 00000143 80F94B cmp cl, 75 ; 64+8+'.'+3 -> offset 75 is the last chr 347 00000146 72E6 jb short a_1 348 ; 29/11/2024 349 00000148 29C9 sub ecx, ecx 350 0000014A EB11 jmp short a_4 351 a_3: 352 ; 29/11/2024 353 0000014C 4F dec edi 354 ;;; 355 0000014D 08E4 or ah, ah ; if period NOT found, 356 0000014F 750C jnz short a_4 ; then add a .WAV extension. 357 SetExt: 358 ; 29/11/2024 359 ;dec edi 360 00000151 C7072E574156 mov dword [edi], '.WAV' 361 ; ! 64+12 is DOS limit 362 ; but writing +4 must not 363 ; destroy the following data 364 ;mov byte [edi+4], 0 ; so, 80 bytes path + 0 is possible here 365 ; 29/11/2024 366 00000157 83C104 add ecx, 4 367 0000015A 83C704 add edi, 4 368 a_4: 369 0000015D C60700 mov byte [edi], 0 370 ; 30/11/2024 371 00000160 C3 retn 372 373 ; ------------------------------------------------------------- 374 375 getwavparms: 376 ; 14/11/2024 377 00000161 E8FF030000 call getWAVParameters 378 00000166 72AC jc short _exit_ ; nothing to do 379 380 ; 07/01/2025 381 00000168 803D[2C180000]00 cmp byte [allocated], 0 382 0000016F 7744 ja short StartPlay 383 384 ; ------------------------------------------------------------- 385 386 ; 06/01/2025 (cgaplay2.s) 387 388 ; 16/12/2024 (sb16play.s) 389 ; 07/12/2024 (playwav9.s) -ac97- 390 ; Allocate Audio Buffer (for user) 391 sys _audio, 0200h, BUFFERSIZE, audio_buffer 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000171 BB00020000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000176 B900800000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 0000017B BA[00200000] <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000180 B820000000 <1> mov eax, %1 103 <1> 104 00000185 CD40 <1> int 40h 392 00000187 0F8285010000 jc error_exit 393 394 ; 17/12/2024 395 0000018D FE05[2C180000] inc byte [allocated] 396 397 ; 17/12/2024 398 ; Initialize Audio Device (bh = 3) 399 sys _audio, 301h, 0, audio_int_handler 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000193 BB01030000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000198 B900000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 0000019D BA[A7050000] <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000001A2 B820000000 <1> mov eax, %1 103 <1> 104 000001A7 CD40 <1> int 40h 400 000001A9 0F8263010000 jc error_exit 401 402 ; 17/12/2024 403 000001AF FE05[2D180000] inc byte [interrupt] 404 405 ; 08/01/2025 406 ;; 17/12/2024 407 ;; 16/12/2024 408 ;; Map DMA Buffer to User (for wave graphics) 409 ;sys _audio, 0D00h, BUFFERSIZE*2, dma_buffer 410 ;jc error_exit 411 412 ; ------------------------------------------------------------- 413 414 StartPlay: 415 ; 30/12/2024 416 000001B5 C605[7F170000]01 mov byte [wpoints], 1 417 418 ; 08/01/2025 419 %if 0 420 ;;; 421 ; 06/01/2025 422 movzx eax, word [WAVE_SampleRate] 423 ;mov ax, [WAVE_SampleRate] 424 mov ecx, 10 425 mul ecx 426 mov cl, 182 427 div ecx 428 ; ax = samples per 1/18.2 second 429 mov cl, byte [WAVE_BlockAlign] 430 mul ecx 431 mov [wpoints_dif], eax ; buffer read differential (distance) 432 ; for wave volume leds update 433 ; (byte stream per 1/18.2 second) 434 %else 435 ; 08/01/2025 436 000001BC 31C9 xor ecx, ecx 437 000001BE 8A0D[A4170000] mov cl, byte [WAVE_BlockAlign] 438 %endif 439 ; 08/01/2025 440 000001C4 B840010000 mov eax, 320 441 000001C9 F7E1 mul ecx 442 000001CB A3[68120000] mov [sd_count], eax 443 ;;; 444 445 ; ------------------------------------------------------------- 446 447 ; 06/01/2025 (cgaplay2.s) 448 ; 02/01/2025 (cgaplay2.asm) 449 ;;; 450 ; 23/11/2024 (sb16play.asm, [turn_on_leds]) 451 000001D0 803D[9A170000]01 cmp byte [WAVE_NumChannels], 1 452 000001D7 771F ja short stolp_s 453 stolp_m: 454 000001D9 803D[A6170000]08 cmp byte [WAVE_BitsPerSample], 8 455 000001E0 770B ja short stolp_m16 456 stolp_m8: 457 000001E2 66C705[28180000]- mov word [UpdateWavePoints], UpdateWavePoints_8m 457 000001E9 [3709] 458 000001EB EB2A jmp short stolp_ok 459 stolp_m16: 460 000001ED 66C705[28180000]- mov word [UpdateWavePoints], UpdateWavePoints_16m 460 000001F4 [9C08] 461 000001F6 EB1F jmp short stolp_ok 462 stolp_s: 463 000001F8 803D[A6170000]08 cmp byte [WAVE_BitsPerSample], 8 464 000001FF 770B ja short stolp_s16 465 stolp_s8: 466 00000201 66C705[28180000]- mov word [UpdateWavePoints], UpdateWavePoints_8s 466 00000208 [E708] 467 0000020A EB0B jmp short stolp_ok 468 stolp_s16: 469 0000020C 66C705[28180000]- mov word [UpdateWavePoints], UpdateWavePoints_16s 469 00000213 [4808] 470 00000215 EB00 jmp short stolp_ok 471 stolp_ok: 472 ;;; 473 474 ; ------------------------------------------------------------- 475 476 ; 25/12/2024 477 00000217 FE05[81170000] inc byte [filecount] 478 0000021D C605[80170000]00 mov byte [command], 0 479 ; 30/12/2024 480 00000224 C605[75120000]FF mov byte [pbprev], -1 481 482 ; 06/01/2025 483 484 ; ------------------------------------------------------------- 485 486 ; 30/12/2024 487 Player_Template: 488 ; 21/12/2024 489 0000022B E810010000 call clearscreen 490 00000230 E81A010000 call drawplayingscreen 491 492 ; 14/11/2024 493 00000235 E8DE070000 call SetTotalTime 494 0000023A E8AB080000 call UpdateFileInfo 495 496 ; ------------------------------------------------------------- 497 498 ; 06/01/2025 (cgaplay2.s) -SB16- 499 ; 02/01/2025 (cgaplay2.asm) -SB16- 500 ; 01/01/2025 (cgaplay.asm) -AC97- 501 ; 30/12/2024 (cgaplay.s) -AC97- 502 ; 29/12/2024 (vgaplay3.s) -AC97- 503 ; 20/12/2024 (sb16play.asm) 504 ; 18/12/2024 (ac97play.s) 505 PlayNow: 506 ; 01/12/2024 (32bit) 507 ; 14/11/2024 508 ;;mov al, 3 ; 0 = max, 31 = min 509 ; 24/11/2024 510 ;mov al, 5 ; 15 = max, 0 = min 511 ; 27/11/2024 512 ;mov [volume], al 513 ; 14/12/2024 514 0000023F A0[FB090000] mov al, [volume] 515 ;call SetPCMOutVolume@ 516 ; 02/01/2025 517 00000244 E88C020000 call SetMasterVolume@ 518 ; 15/11/2024 519 ;call SetMasterVolume 520 ;;call SetPCMOutVolume 521 522 ;;; 523 ; 14/11/2024 524 00000249 E8A2090000 call UpdateProgressBar 525 ;;; 526 527 ; 30/05/2024 528 ; playwav4.asm 529 _2: 530 0000024E E845070000 call check4keyboardstop ; flush keyboard buffer 531 00000253 72F9 jc short _2 ; 07/11/2023 532 533 ; play the .wav file. Most of the good stuff is in here. 534 535 00000255 E846010000 call PlayWav 536 537 ; 30/12/2024 538 ; 29/12/2024 (vgaplay3.s) 539 ; 27/12/2024 (vgaplay.s) 540 _3: 541 542 ; close the .wav file and exit. 543 544 ; 25/12/2024 545 0000025A E8EF020000 call closeFile 546 547 ; 25/12/2024 548 ;;; 549 ; reset file loading and EOF parameters 550 ; 18/12/2024 551 0000025F C705[1C180000]0000- mov dword [count], 0 551 00000267 0000 552 00000269 C705[20180000]0000- mov dword [LoadedDataBytes], 0 552 00000271 0000 553 00000273 C605[12180000]00 mov byte [flags], 0 554 0000027A C605[7D170000]00 mov byte [stopped], 0 555 ; 08/01/2025 556 ; 29/12/2024 557 ;mov dword [pbuf_s], 0 558 ;;; 559 560 00000281 803D[80170000]51 cmp byte [command], 'Q' 561 00000288 7405 je short terminate 562 0000028A E917FEFFFF jmp check_p_command 563 564 terminate: 565 0000028F E8FF000000 call set_text_mode 566 ; 06/01/2025 567 Exit@: 568 ; 17/12/2024 569 00000294 803D[2D180000]00 cmp byte [interrupt], 0 570 0000029B 760C jna short skip_cb_cancel 571 572 ; Cancel callback service (for user) 573 sys _audio, 0900h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 0000029D BB00090000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000002A2 B820000000 <1> mov eax, %1 103 <1> 104 000002A7 CD40 <1> int 40h 574 575 skip_cb_cancel: 576 ; 17/12/2024 577 000002A9 803D[2C180000]00 cmp byte [allocated], 0 578 000002B0 760C jna short skip_ab_dalloc 579 580 ; Deallocate Audio Buffer (for user) 581 sys _audio, 0A00h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000002B2 BB000A0000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000002B7 B820000000 <1> mov eax, %1 103 <1> 104 000002BC CD40 <1> int 40h 582 583 skip_ab_dalloc: 584 ; Disable Audio Device 585 sys _audio, 0C00h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000002BE BB000C0000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000002C3 B820000000 <1> mov eax, %1 103 <1> 104 000002C8 CD40 <1> int 40h 586 ;;; 587 Exit: 588 ;mov ax, 4C00h ; bye ! 589 ;int 21h 590 ; 01/12/2024 591 sys _exit, 0 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000002CA BB00000000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000002CF B801000000 <1> mov eax, %1 103 <1> 104 000002D4 CD40 <1> int 40h 592 halt: 593 000002D6 EBFE jmp short halt 594 595 ; ------------------------------------------------------------- 596 597 ; 30/05/2024 598 pmsg_usage: 599 ; 21/12/2024 600 000002D8 E8B6000000 call set_text_mode 601 ; 01/12/2024 602 sys _msg, msg_usage, 255, 0Fh 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000002DD BB[5B0D0000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 000002E2 B9FF000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 000002E7 BA0F000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000002EC B823000000 <1> mov eax, %1 103 <1> 104 000002F1 CD40 <1> int 40h 603 000002F3 EBD5 jmp short Exit 604 605 ; ------------------------------------------------------------- 606 607 ; 30/05/2024 608 init_err: 609 ; 21/12/2024 610 000002F5 E899000000 call set_text_mode 611 ; 01/12/2024 612 sys _msg, msg_init_err, 255, 0Fh 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000002FA BB[FB0D0000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 000002FF B9FF000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000304 BA0F000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000309 B823000000 <1> mov eax, %1 103 <1> 104 0000030E CD40 <1> int 40h 613 00000310 EBB8 jmp short Exit 614 615 ; ------------------------------------------------------------- 616 617 ; 07/12/2024 618 error_exit: 619 ; 21/12/2024 620 00000312 E87C000000 call set_text_mode 621 trdos386_error: 622 sys _msg, trdos386_err_msg, 255, 0Eh 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000317 BB[DB0D0000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 0000031C B9FF000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000321 BA0E000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000326 B823000000 <1> mov eax, %1 103 <1> 104 0000032B CD40 <1> int 40h 623 0000032D EB9B jmp short Exit 624 625 ; ------------------------------------------------------------- 626 627 ; 21/12/2024 628 print_msg: 629 0000032F B40E mov ah, 0Eh 630 00000331 BB07000000 mov ebx, 7 631 ;mov bl, 7 ; char attribute & color 632 p_next_chr: 633 00000336 AC lodsb 634 00000337 08C0 or al, al 635 00000339 7404 jz short p_retn ; retn 636 0000033B CD31 int 31h 637 0000033D EBF7 jmp short p_next_chr 638 p_retn: 639 0000033F C3 retn 640 641 ; ------------------------------------------------------------- 642 643 ; 30/12/2024 644 clearscreen: 645 ; fast clear 646 ; 320*200, 256 colors 647 00000340 BF00000A00 mov edi, 0A0000h 648 00000345 B9803E0000 mov ecx, (320*200*1)/4 649 0000034A 31C0 xor eax, eax 650 0000034C F3AB rep stosd 651 0000034E C3 retn 652 653 ; ------------------------------------------------------------- 654 655 ; 30/12/2024 (VGA Mode 13h, 320*200 pixels, 256 colors) 656 ; 26/12/2024 657 ; 21/12/2024 658 drawplayingscreen: 659 0000034F BD[940E0000] mov ebp, PlayingScreen 660 ;mov esi, 0 ; row 0, column 0 661 00000354 BE00000200 mov esi, 00020000h ; row 2, column 0 ; top margin = 2 662 p_d_x: 663 00000359 C605[74120000]28 mov byte [columns], 40 664 00000360 B601 mov dh, 01h ; 8x8 system font 665 p_d_x_n: 666 00000362 8A5500 mov dl, [ebp] 667 00000365 20D2 and dl, dl 668 00000367 7429 jz short p_d_x_ok 669 670 ; sysvideo system call 671 ; BH = 01h = VGA graphics (0A0000h) data transfers 672 ; BL = 0Fh = write character/font 673 ; DH = 01h = 8*8 system font 674 ; CL = 0Fh = color (white) 675 ; ESI = cursor/writing position (pixels) 676 ; HW = row, SI = column 677 678 sys _video, 010Fh, 0Fh 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000369 BB0F010000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 0000036E B90F000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000373 B81F000000 <1> mov eax, %1 103 <1> 104 00000378 CD40 <1> int 40h 679 680 0000037A 45 inc ebp 681 0000037B 6683C608 add si, 8 ; next char pos 682 0000037F FE0D[74120000] dec byte [columns] 683 00000385 75DB jnz short p_d_x_n ; next column 684 00000387 6631F6 xor si, si 685 0000038A 81C600000800 add esi, 00080000h ; next row ; 8*8 686 00000390 EBC7 jmp short p_d_x 687 p_d_x_ok: 688 00000392 C3 retn 689 690 ; ------------------------------------------------------------- 691 692 ; 21/12/2024 693 set_text_mode: 694 00000393 30E4 xor ah, ah 695 00000395 B003 mov al, 3 696 ;int 10h ; al = 03h text mode, int 10 video 697 00000397 CD31 int 31h ; TRDOS 386 - Video interrupt 698 00000399 C3 retn 699 700 ; ------------------------------------------------------------- 701 702 ; 02/12/2024 703 Player_Quit@: 704 0000039A 58 pop eax ; return addr (call PlayWav@) 705 706 ; 29/11/2024 707 Player_Quit: 708 0000039B E9EFFEFFFF jmp terminate 709 710 ; ------------------------------------------------------------- 711 712 ; 06/01/2025 (cgaplay2.s) 713 ; 02/01/2025 (cgaplay2.asm) 714 ; 20/12/2024 715 ; 15/12/2024 (sb16play.s) 716 ; ref: playwav4.s, 18/08/2020 717 ; 24/11/2024 (sb16play.asm) 718 PlayWav: 719 ; load 32768 bytes into audio buffer 720 ;mov edi, audio_buffer ; 16/12/2024 721 000003A0 E816020000 call loadFromFile 722 ; 18/12/2024 723 ;jc error_exit 724 ;mov byte [half_buff], 1 ; (DMA) Buffer 1 725 726 000003A5 A1[1C180000] mov eax, [count] 727 000003AA 0105[20180000] add [LoadedDataBytes], eax 728 729 000003B0 F605[12180000]01 test byte [flags], ENDOFFILE ; end of file ? 730 000003B7 751C jnz short _pw1 ; yes 731 ; bypass filling dma half buffer 2 732 733 ; bh = 16 : update (current, first) dma half buffer 734 ; bl = 0 : then switch to the next (second) half buffer 735 sys _audio, 1000h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000003B9 BB00100000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000003BE B820000000 <1> mov eax, %1 103 <1> 104 000003C3 CD40 <1> int 40h 736 737 ; [audio_flag] = 1 (in TRDOS 386 kernel) 738 739 ; audio_buffer must be filled again after above system call 740 ; (Because audio interrupt will be generated by sound hardware 741 ; at the end of the first half of dma buffer.. so, 742 ; the second half must be ready. 'sound_play' will use it.) 743 744 ;mov edi, audio_buffer ; 16/12/2024 745 000003C5 E8F1010000 call loadFromFile 746 ;jc short p_return 747 748 000003CA A1[1C180000] mov eax, [count] 749 000003CF 0105[20180000] add [LoadedDataBytes], eax 750 751 ; 06/01/2025 752 _pw1: 753 ; 07/01/2025 754 ; 20/12/2024 755 ; 25/11/2024 756 000003D5 E80E030000 call SB16Init_play ; initialize SB16 card 757 ; set sample rate, start to play 758 000003DA 0F8215FFFFFF jc init_err 759 760 ; 08/01/2025 761 ; 20/12/2024 762 000003E0 F605[12180000]01 test byte [flags], ENDOFFILE ; end of file 763 000003E7 7510 jnz short _pw2 ; yes 764 765 ; 20/12/2024 766 ;mov edi, audio_buffer 767 000003E9 E8CD010000 call loadFromFile 768 ;jc short p_return 769 ;xor byte [half_buffer], 1 770 771 000003EE A1[1C180000] mov eax, [count] 772 000003F3 0105[20180000] add [LoadedDataBytes], eax 773 _pw2: 774 000003F9 C605[13180000]00 mov byte [SRB], 0 775 776 ; ------------------------------------------- 777 778 ; 07/01/2025 779 ; 06/01/2025 (cgaplay2.s) 780 ; 30/12/2024 (cgaplay.s) 781 ; 29/12/2024 (vgaplay3.s) 782 ; 18/12/2024 (ac97play.s) 783 ; 01/12/2024 (32bit) 784 ; 29/11/2024 785 ; 16/12/2024 (TRDOS 386) 786 ; 29/11/2024 787 ; 27/11/2024 788 ; 24/11/2024 789 TuneLoop: 790 ; 30/05/2024 791 ; 18/11/2023 (ich_wav4.asm) 792 ; 08/11/2023 793 ; 06/11/2023 794 795 ; 20/12/2024 796 00000400 E8EB070000 call UpdateProgressBar 797 798 tLWait: 799 ; 07/12/2024 (playwav9.s) 800 ; 18/11/2024 801 00000405 803D[7D170000]00 cmp byte [stopped], 0 802 ; 24/11/2024 803 0000040C 7639 jna short tL1 804 805 ;;; 806 ; 09/12/2024 (ac97play.s) 807 0000040E 803D[7D170000]03 cmp byte [stopped], 3 808 00000415 7375 jnb _exitt_ 809 ;;; 810 00000417 E80A030000 call checkUpdateEvents 811 0000041C 726E jc _exitt_ 812 ;;; 813 ; 29/11/2024 814 0000041E 803D[80170000]4E cmp byte [command], 'N' 815 00000425 7465 je _exitt_ 816 00000427 803D[80170000]50 cmp byte [command], 'P' 817 0000042E 745C je _exitt_ 818 ;;; 819 00000430 803D[7E170000]30 cmp byte [tLO], '0' 820 00000437 74CC je short tLWait 821 00000439 E858000000 call tLZ 822 0000043E C605[7E170000]30 mov byte [tLO], '0' 823 00000445 EBBE jmp short tLWait 824 825 tL1: 826 ; 16/12/2024 827 ; 07/12/2024 (playwav9.s) 828 ; 27/11/2024 829 ; Check audio interrupt status 830 00000447 803D[13180000]00 cmp byte [SRB], 0 831 0000044E 7709 ja short tL3 832 tL2: 833 00000450 E8D1020000 call checkUpdateEvents 834 00000455 7235 jc _exitt_ 835 00000457 EBAC jmp short tLWait 836 tL3: 837 ; 07/01/2025 838 00000459 8035[66120000]01 xor byte [half_buffer], 1 839 ; 07/12/2024 840 00000460 C605[13180000]00 mov byte [SRB], 0 841 842 ; 16/12/2024 843 ;mov edi, audio_buffer 844 00000467 E84F010000 call loadFromFile 845 0000046C 721E jc short _exitt_ ; end of file 846 847 ; 26/11/2024 848 0000046E A0[66120000] mov al, [half_buffer] 849 00000473 0431 add al, '1' 850 ; 19/11/2024 851 00000475 A2[7E170000] mov [tLO], al 852 0000047A E819000000 call tL0 853 ; 16/12/2024 (TRDOS 386) 854 ; 24/11/2024 855 ; 14/11/2024 856 0000047F A1[1C180000] mov eax, [count] 857 00000484 0105[20180000] add [LoadedDataBytes], eax 858 859 ; 27/11/2024 860 0000048A EBC4 jmp short tL2 861 862 _exitt_: 863 ; 24/11/2024 864 0000048C E866000000 call sb16_stop 865 866 ;;; 867 ; 14/11/2024 868 00000491 E85A070000 call UpdateProgressBar 869 ;;; 870 871 872 ; 18/11/2024 873 tLZ: 874 ; 30/05/2024 875 00000496 B030 mov al, '0' 876 877 ;add al, '0' 878 ;call tL0 879 ; 880 ;retn 881 ; 06/11/2023 882 ;jmp short tL0 883 ;retn 884 885 tL0: 886 ; 30/12/2024 (cgaplay.s) 887 ; 29/05/2024 (TRDOS 386) 888 ; 08/11/2023 889 ; 05/11/2023 890 ; 17/02/2017 - Buffer switch test (temporary) 891 ; 06/11/2023 892 ; al = buffer indicator ('1', '2' or '0' -stop- ) 893 894 ; 30/12/2024 (video mode 13h modification) 895 ; (320*200, 256 colors) 896 ;;; 897 00000498 88C2 mov dl, al ; character 898 0000049A BF00000A00 mov edi, 0A0000h 899 900 0000049F BB08000000 mov ebx, 8 ; 8 pixels (8*8 pixels font) 901 902 000004A4 B00C mov al, 0Ch ; red 903 tL0_1: 904 ;mov ecx, 8 ; 8 pixels (8*8 pixels font) 905 000004A6 B907000000 mov ecx, 7 906 tL0_2: 907 000004AB AA stosb 908 000004AC 49 dec ecx 909 000004AD 75FC jnz short tL0_2 910 000004AF 4B dec ebx 911 000004B0 7408 jz short tL0_3 912 ;add edi, 320-8 ; next line 913 000004B2 81C739010000 add edi, 320-7 914 000004B8 EBEC jmp short tL0_1 915 tL0_3: 916 ; write system font 917 000004BA B601 mov dh, 01h 918 ;mov dl, al ; character 919 000004BC 31F6 xor esi, esi ; = row 0, column 0 920 sys _video, 010Fh, 0Eh ; yellow 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000004BE BB0F010000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 000004C3 B90E000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000004C8 B81F000000 <1> mov eax, %1 103 <1> 104 000004CD CD40 <1> int 40h 921 ;;; 922 923 000004CF C3 retn 924 925 ; ------------------------------------------- 926 927 ; 06/01/2025 (cgaplay2.s) -TRDOS386- 928 ; 02/01/2025 (cgaplay2.asm) -DOS- 929 ; 18/12/2024 930 ; 16/12/2024 (sb16play.s) 931 ; 07/12/2024 (playwav9.s) 932 933 SetMasterVolume: 934 ;cmp al, 31 935 ;ja short setvolume_ok 936 000004D0 A2[FB090000] mov [volume], al ; max = 0, min = 31 937 SetMasterVolume@: 938 ; al = [volume] 939 000004D5 B41F mov ah, 31 940 000004D7 28C4 sub ah, al 941 000004D9 88E0 mov al, ah 942 943 ; Set Master Volume Level (BL=0 or 80h) 944 ; for next playing (BL>=80h) 945 ;sys _audio, 0B80h, eax 946 sys _audio, 0B00h, eax 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000004DB BB000B0000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 000004E0 89C1 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000004E2 B820000000 <1> mov eax, %1 103 <1> 104 000004E7 CD40 <1> int 40h 947 948 setvolume_ok: 949 000004E9 C3 retn 950 951 ; ------------------------------------------- 952 953 ; 16/12/2024 (sb16play.s) 954 ; Ref: playwav4.s (18/08/2020) 955 ; Detect (BH=1) SB16 (BL=1) Audio Card (or Emulator) 956 DetectSB16: 957 sys _audio, 101h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000004EA BB01010000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000004EF B820000000 <1> mov eax, %1 103 <1> 104 000004F4 CD40 <1> int 40h 958 000004F6 C3 retn 959 960 ; -------------------------------------------- 961 962 ; 16/12/2024 (sb16play.s) 963 ; 07/12/2024 (playwav9.s) 964 ; Ref: TRDOS 386 v2.0.9, trdosk8.s (18/09/2024) 965 ; 'sysaudio' system call (23/08/2024) 966 ; 18/11/2024 967 ; Ref: TRDOS 386 v2.0.9, audio.s, Erdogan Tan, 06/06/2024 968 969 sb16_stop: 970 ; 18/11/2024 971 000004F7 C605[7D170000]02 mov byte [stopped], 2 972 ; 07/12/2024 973 sys _audio, 0700h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000004FE BB00070000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000503 B820000000 <1> mov eax, %1 103 <1> 104 00000508 CD40 <1> int 40h 974 0000050A C3 retn 975 976 sb16_pause: 977 ; 18/11/2024 978 0000050B C605[7D170000]01 mov byte [stopped], 1 ; paused 979 ; 07/12/2024 980 sys _audio, 0500h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000512 BB00050000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000517 B820000000 <1> mov eax, %1 103 <1> 104 0000051C CD40 <1> int 40h 981 0000051E C3 retn 982 983 sb16_play: 984 sb16_continue: 985 ; continue to play (after pause) 986 ; 18/11/2024 987 0000051F C605[7D170000]00 mov byte [stopped], 0 988 ; 07/12/2024 989 sys _audio, 0600h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000526 BB00060000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000052B B820000000 <1> mov eax, %1 103 <1> 104 00000530 CD40 <1> int 40h 990 00000532 C3 retn 991 992 ; ---------------------------------- 993 994 ; 26/12/2024 995 ; 07/12/2024 996 ; 01/12/2024 997 ; 14/11/2024 998 ; INPUT: ds:dx = file name address 999 ; OUTPUT: [filehandle] = ; -1 = not open 1000 openFile: 1001 ; 26/12/2024 1002 ; 01/12/2024 1003 sys _open, edx, 0 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000533 89D3 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000535 B900000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000053A B805000000 <1> mov eax, %1 103 <1> 104 0000053F CD40 <1> int 40h 1004 ; 07/12/2024 1005 ;sys _open, wav_file_name, 0 1006 00000541 7305 jnc short _of1 1007 1008 00000543 B8FFFFFFFF mov eax, -1 1009 ; cf = 1 -> not found or access error 1010 _of1: 1011 00000548 A3[B0170000] mov [filehandle], eax 1012 0000054D C3 retn 1013 1014 ; ---------------------------------- 1015 1016 ; close the currently open file 1017 1018 ; 01/12/2024 1019 ; 14/11/2024 1020 ; INPUT: [filehandle] ; -1 = not open 1021 ; OUTPUT: none 1022 closeFile: 1023 0000054E 833D[B0170000]FF cmp dword [filehandle], -1 1024 00000555 740D jz short _cf1 1025 ; 01/12/2024 1026 sys _close, [filehandle] 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000557 8B1D[B0170000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000055D B806000000 <1> mov eax, %1 103 <1> 104 00000562 CD40 <1> int 40h 1027 ;mov dword [filehandle], -1 1028 _cf1: 1029 00000564 C3 retn 1030 1031 ; ---------------------------------- 1032 1033 ; 05/02/2025 1034 ; 01/12/2024 1035 ; 14/11/2024 - Erdogan Tan 1036 getWAVParameters: 1037 ; reads WAV file header(s) (44 bytes) from the .wav file. 1038 ; entry: none - assumes file is already open 1039 ; exit: ax = sample rate (11025, 22050, 44100, 48000) 1040 ; cx = number of channels (mono=1, stereo=2) 1041 ; dx = bits per sample (8, 16) 1042 ; bx = number of bytes per sample (1 to 4) 1043 1044 ;mov dx, WAVFILEHEADERbuff 1045 ;mov bx, [filehandle] 1046 ;mov cx, 44 ; 44 bytes 1047 ;mov ah, 3Fh 1048 ;int 21h 1049 ;jc short gwavp_retn 1050 ; 01/12/2024 (TRDOS 386) 1051 sys _read, [filehandle], WAVFILEHEADERbuff, 44 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000565 8B1D[B0170000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 0000056B B9[84170000] <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000570 BA2C000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000575 B803000000 <1> mov eax, %1 103 <1> 104 0000057A CD40 <1> int 40h 1052 0000057C 7228 jc short gwavp_retn 1053 1054 0000057E 83F82C cmp eax, 44 1055 00000581 7223 jb short gwavp_retn 1056 1057 00000583 813D[8C170000]5741- cmp dword [RIFF_Format], 'WAVE' 1057 0000058B 5645 1058 0000058D 7516 jne short gwavp_stc_retn 1059 1060 0000058F 66833D[98170000]01 cmp word [WAVE_AudioFormat], 1 ; Offset 20, must be 1 (= PCM) 1061 ; 05/02/2025 1062 00000597 750C jne short gwavp_stc_retn 1063 ;je short gwavp_retn ; 15/11/2024 1064 1065 ; 05/02/2025 1066 ; (Open MPT creates wav files with a new type header, 1067 ; this program can not use the new type 1068 ; because of 'data' offset is not at DATA_SubchunkID.) 1069 ; ((GoldWave creates common type wav file.)) 1070 00000599 813D[A8170000]6461- cmp dword [DATA_SubchunkID], 'data' 1070 000005A1 7461 1071 000005A3 7401 je short gwavp_retn 1072 1073 ; 15/11/2024 1074 ;mov cx, [WAVE_NumChannels] ; return num of channels in CX 1075 ;mov ax, [WAVE_SampleRate] ; return sample rate in AX 1076 ;mov dx, [WAVE_BitsPerSample] 1077 ; return bits per sample value in DX 1078 ;mov bx, [WAVE_BlockAlign] ; return bytes per sample in BX 1079 ;gwavp_retn: 1080 ;retn 1081 1082 gwavp_stc_retn: 1083 000005A5 F9 stc 1084 gwavp_retn: 1085 000005A6 C3 retn 1086 1087 ; ///// 1088 1089 ; 16/12/2024 (sb16play.s) 1090 ; -------------------------------------------------------- 1091 ; 07/12/2024 (playwav9.s) 1092 ; -------------------------------------------------------- 1093 ; ref: playwav8.s (04/06/2024) 1094 1095 audio_int_handler: 1096 ; 18/08/2020 (14/10/2020, 'wavplay2.s') 1097 1098 ; 07/12/2024 1099 ;mov al, [stopped] 1100 ;cmp al, 2 1101 ;je short _callback_retn 1102 1103 ; 18/08/2020 1104 ;mov byte [SRB], 1 1105 ; 07/12/2024 1106 000005A7 FE05[13180000] inc byte [SRB] 1107 1108 ;_callback_retn: 1109 sys _rele ; return from callback service 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000005AD B827000000 <1> mov eax, %1 103 <1> 104 000005B2 CD40 <1> int 40h 1110 ; we must not come here ! 1111 sys _exit 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000005B4 B801000000 <1> mov eax, %1 103 <1> 104 000005B9 CD40 <1> int 40h 1112 ; -------------------------------------------------------- 1113 ; 07/12/2024 1114 ; -------------------------------------------------------- 1115 1116 ; ///// 1117 ; 16/12/2024 (sb16play.s) 1118 ; 14/12/2024 (playwav9.s) 1119 ; 07/12/2024 1120 ; 01/12/2024 1121 ; 24/11/2024 (SB16 version of playwav8.asm -> playwav9.asm) 1122 ; 30/05/2024 (ich_wav4.asm, 19/05/2024) 1123 loadFromFile: 1124 ; 18/12/2024 1125 000005BB C705[1C180000]0000- mov dword [count], 0 1125 000005C3 0000 1126 1127 ; 07/11/2023 1128 000005C5 F605[12180000]01 test byte [flags], ENDOFFILE ; have we already read the 1129 ; last of the file? 1130 000005CC 7402 jz short lff_0 ; no 1131 000005CE F9 stc 1132 000005CF C3 retn 1133 1134 lff_0: 1135 ; 16/12/2024 1136 000005D0 BF[00200000] mov edi, audio_buffer 1137 1138 ; 14/12/2024 (playwav9.s) 1139 ;sys _read, [filehandle], esi, [loadsize] 1140 ; 16/12/2024 1141 sys _read, [filehandle], edi, BUFFERSIZE 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000005D5 8B1D[B0170000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 000005DB 89F9 <1> mov ecx, %3 97 <1> %if %0 = 4 98 000005DD BA00800000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000005E2 B803000000 <1> mov eax, %1 103 <1> 104 000005E7 CD40 <1> int 40h 1142 000005E9 7226 jc short lff_4 ; error ! 1143 1144 ; 20/12/2024 1145 000005EB A3[1C180000] mov [count], eax 1146 1147 ; 16/12/2024 1148 000005F0 39D0 cmp eax, edx 1149 000005F2 741C je short endLFF 1150 ; edi = buffer address 1151 000005F4 01C7 add edi, eax 1152 lff_3: 1153 ; 20/12/2024 1154 000005F6 89D1 mov ecx, edx ; BUFFERSIZE 1155 ;call padfill ; blank pad the remainder 1156 ;;; 1157 ; 20/12/2024 1158 padfill: 1159 ; 16/12/2024 (sb16play.s) 1160 ; edi = buffer offset 1161 ; ecx = buffer size 1162 ; eax = loaded bytes 1163 ; 24/11/2024 (sb16play.asm) 1164 ; di = offset (to be filled with ZEROs) 1165 ; es = ds = cs 1166 ; ax = di = number of bytes loaded 1167 ; cx = buffer size (> loaded bytes) 1168 000005F8 29C1 sub ecx, eax 1169 000005FA 31C0 xor eax, eax 1170 000005FC 803D[A6170000]08 cmp byte [WAVE_BitsPerSample], 8 1171 00000603 7702 ja short padfill@ 1172 00000605 B080 mov al, 80h 1173 padfill@: 1174 00000607 F3AA rep stosb 1175 ;retn 1176 ;;; 1177 1178 ;clc ; don't exit with CY yet. 1179 00000609 800D[12180000]01 or byte [flags], ENDOFFILE ; end of file flag 1180 endLFF: 1181 00000610 C3 retn 1182 lff_4: 1183 ; 08/11/2023 1184 00000611 B021 mov al, '!' ; error 1185 00000613 E880FEFFFF call tL0 1186 1187 ; 16/12/2024 1188 00000618 29C0 sub eax, eax 1189 ;mov ecx, edx ; BUFFERSIZE 1190 0000061A EBDA jmp short lff_3 1191 1192 ; ///// 1193 1194 ; -------------------------------------------------------- 1195 ; -------------------------------------------------------- 1196 1197 write_audio_dev_info: 1198 ; 30/05/2024 1199 ;sys_msg msgAudioCardInfo, 0Fh 1200 ; 01/12/2024 1201 sys _msg, msgAudioCardInfo, 255, 0Fh 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 0000061C BB[360D0000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000621 B9FF000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000626 BA0F000000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000062B B823000000 <1> mov eax, %1 103 <1> 104 00000630 CD40 <1> int 40h 1202 00000632 C3 retn 1203 1204 ; -------------------------------------------------------- 1205 1206 ; 20/12/2024 (playwavx.s, sb16play.s) 1207 write_sb16_dev_info: 1208 ; 27/11/2024 1209 ; 24/11/2024 (sb16play.asm) 1210 1211 00000633 A1[78170000] mov eax, [audio_io_base] 1212 00000638 31DB xor ebx, ebx 1213 0000063A 88C3 mov bl, al 1214 0000063C 88DA mov dl, bl 1215 0000063E 80E30F and bl, 0Fh 1216 00000641 8A83[300E0000] mov al, [ebx+hex_chars] 1217 00000647 A2[790E0000] mov [msgBasePort+2], al 1218 0000064C 88D3 mov bl, dl 1219 0000064E C0EB04 shr bl, 4 1220 00000651 8A83[300E0000] mov al, [ebx+hex_chars] 1221 00000657 A2[780E0000] mov [msgBasePort+1], al 1222 0000065C 88E3 mov bl, ah 1223 ;and bl, 0Fh 1224 0000065E 8A83[300E0000] mov al, [ebx+hex_chars] 1225 00000664 A2[770E0000] mov [msgBasePort], al 1226 1227 ;xor eax, eax 1228 ; 27/11/2024 1229 00000669 A0[7C170000] mov al, [audio_intr] 1230 ;mov cl, 10 1231 ;div cl 1232 ;add ah, 30h 1233 ;mov [msgIRQ], ah 1234 ; 25/11/2024 1235 0000066E 0430 add al, 30h 1236 00000670 A2[8E0E0000] mov [msgIRQ], al 1237 1238 00000675 E85D060000 call clear_window 1239 ;mov dh, 13 1240 ; 02/01/2025 1241 0000067A B60C mov dh, 12 1242 0000067C B200 mov dl, 0 1243 0000067E E879030000 call setCursorPosition 1244 1245 ; 07/01/2025 1246 00000683 BD[410E0000] mov ebp, msgSB16Info ; message 1247 ;mov cl, 07h ; color 1248 ;call sys_gmsg 1249 ;retn 1250 ;;; 1251 1252 ; -------------------------------------------------------- 1253 1254 ; 30/12/2024 (Video Mode 13h) 1255 ; (write message in VGA/CGA mode) 1256 ; 22/12/2024 1257 ; 21/12/2024 1258 ; (write message in VGA/VESA-VBE mode) 1259 sys_gmsg: 1260 00000688 8A4500 mov al, [ebp] 1261 0000068B 20C0 and al, al 1262 0000068D 7458 jz short sys_gmsg_ok 1263 0000068F 3C20 cmp al, 20h 1264 00000691 731E jnb short sys_gmsg_3 1265 00000693 3C0D cmp al, 13 1266 00000695 750C jne short sys_gmsg_2 1267 ; carriege return, move cursor to column 0 1268 00000697 66C705[6C120000]00- mov word [screenpos], 0 1268 0000069F 00 1269 sys_gmsg_1: 1270 000006A0 45 inc ebp 1271 000006A1 EBE5 jmp short sys_gmsg 1272 sys_gmsg_2: 1273 000006A3 3C0A cmp al, 10 1274 000006A5 7540 jne short sys_gmsg_ok ; 22/12/2024 1275 ; line feed, move cursor to next row 1276 ;add word [screenpos+2], 16 1277 ; 30/12/2024 1278 000006A7 668305[6E120000]08 add word [screenpos+2], 8 1279 000006AF EBEF jmp short sys_gmsg_1 1280 sys_gmsg_3: 1281 000006B1 8B35[6C120000] mov esi, [screenpos] 1282 ; hw = (cursor) row 1283 ; si = (cursor) column 1284 000006B7 B907000000 mov ecx, 07h ; gray (light) 1285 000006BC E8F5040000 call write_character 1286 000006C1 83C608 add esi, 8 1287 ;;; 1288 ;cmp si, 640 1289 ; 30/12/2024 (cgaplay.s) 1290 000006C4 6681FE4001 cmp si, 320 1291 000006C9 7213 jb short sys_gmsg_5 1292 000006CB C1EE10 shr esi, 16 1293 ;add si, 16 1294 ;cmp si, 480 1295 ; 30/12/2024 1296 000006CE 6683C608 add si, 8 1297 000006D2 6681FEC800 cmp si, 200 1298 000006D7 7202 jb short sys_gmsg_4 1299 000006D9 31F6 xor esi, esi 1300 sys_gmsg_4: 1301 000006DB C1E610 shl esi, 16 1302 ;;; 1303 sys_gmsg_5: 1304 000006DE 8935[6C120000] mov [screenpos], esi 1305 000006E4 45 inc ebp 1306 000006E5 EBA1 jmp short sys_gmsg 1307 sys_gmsg_ok: 1308 000006E7 C3 retn 1309 ;;; 1310 1311 ; -------------------------------------------------------- 1312 1313 ; -------------------------------------------------------- 1314 ; 16/12/2024 - Sound Blaster 16 initialization & play 1315 ; -------------------------------------------------------- 1316 1317 ; 16/12/2024 - sb16play.s (TRDOS 386) 1318 ; 18/08/2024 - playwav4.s (TRDOS 386) 1319 SB16Init_play: 1320 SB16_play@: 1321 ; 16/12/2024 1322 000006E8 B91F000000 mov ecx, 31 ; 1Fh 1323 000006ED 2A0D[FB090000] sub cl, [volume] ; initial value = 2 1324 ; cl = 1Dh (initial) 1325 000006F3 88CD mov ch, cl 1326 1327 ; Set Master Volume Level (BL=0 or 80h) 1328 ; for next playing (BL>=80h) 1329 ;;sys _audio, 0B80h, 1D1Dh 1330 ;sys _audio, 0B00h, 1D1Dh 1331 ; 16/12/2024 1332 sys _audio, 0B00h 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000006F5 BB000B0000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 000006FA B820000000 <1> mov eax, %1 103 <1> 104 000006FF CD40 <1> int 40h 1333 1334 ; 16/12/2024 1335 ; Start to play 1336 00000701 A0[A6170000] mov al, [WAVE_BitsPerSample] 1337 00000706 C0E804 shr al, 4 ; 8 -> 0, 16 -> 1 1338 00000709 D0E0 shl al, 1 ; 16 -> 2, 8 -> 0 1339 0000070B 8A1D[9A170000] mov bl, [WAVE_NumChannels] 1340 00000711 FECB dec bl 1341 00000713 08C3 or bl, al 1342 00000715 668B0D[9C170000] mov cx, [WAVE_SampleRate] 1343 0000071C B704 mov bh, 4 ; start to play 1344 sys _audio 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 0000071E B820000000 <1> mov eax, %1 103 <1> 104 00000723 CD40 <1> int 40h 1345 1346 _init_err: 1347 c4ue_ok: 1348 00000725 C3 retn 1349 1350 ; -------------------------------------------------------- 1351 ; 14/11/2024 - Erdogan Tan 1352 ; -------------------------------------------------------- 1353 1354 ; 06/01/2025 (cgaplay2.s) 1355 ; 18/12/2024 1356 ; 16/12/2024 (sb16play.s) 1357 ; 07/12/2024 1358 ; 01/12/2024 (32bit registers) 1359 ; 29/11/2024 1360 checkUpdateEvents: 1361 00000726 E86D020000 call check4keyboardstop 1362 0000072B 72F8 jc short c4ue_ok 1363 1364 ; 18/11/2024 1365 0000072D 50 push eax ; * 1366 0000072E 09C0 or eax, eax 1367 00000730 0F84C6000000 jz c4ue_cpt 1368 1369 ; 18/11/2024 1370 00000736 3C20 cmp al, 20h ; SPACE (spacebar) ; pause/play 1371 00000738 7540 jne short c4ue_chk_s 1372 0000073A 803D[7D170000]00 cmp byte [stopped], 0 1373 00000741 770A ja short c4ue_chk_ps 1374 ; 24/11/2024 1375 ; pause 1376 00000743 E8C3FDFFFF call sb16_pause 1377 00000748 E9AF000000 jmp c4ue_cpt 1378 c4ue_chk_ps: 1379 0000074D 803D[7D170000]01 cmp byte [stopped], 1 1380 00000754 770A ja short c4ue_replay 1381 ; continue to play (after a pause) 1382 00000756 E8C4FDFFFF call sb16_play ; 24/11/2024 1383 0000075B E99C000000 jmp c4ue_cpt 1384 c4ue_replay: 1385 ; 19/11/2024 1386 00000760 58 pop eax ; * 1387 00000761 58 pop eax ; return address 1388 ; 07/02/2024 1389 ;mov al, [volume] 1390 ;call SetmasterVolume 1391 00000762 C605[7D170000]00 mov byte [stopped], 0 1392 ; 24/11/2024 1393 00000769 C605[66120000]01 mov byte [half_buffer], 1 1394 00000770 E833050000 call move_to_beginning 1395 00000775 E926FCFFFF jmp PlayWav 1396 1397 c4ue_chk_s: 1398 0000077A 3C53 cmp al, 'S' ; stop 1399 0000077C 7517 jne short c4ue_chk_fb 1400 0000077E 803D[7D170000]00 cmp byte [stopped], 0 1401 00000785 7775 ja c4ue_cpt ; Already stopped/paused 1402 00000787 E86BFDFFFF call sb16_stop ; 24/11/2024 1403 ; 19/11/2024 1404 0000078C C605[7E170000]00 mov byte [tLO], 0 1405 00000793 EB67 jmp c4ue_cpt 1406 1407 c4ue_chk_fb: 1408 ; 17/11/2024 1409 00000795 3C46 cmp al, 'F' 1410 00000797 7507 jne short c4ue_chk_b 1411 00000799 E8E2040000 call Player_ProcessKey_Forwards 1412 0000079E EB5C jmp c4ue_cpt 1413 1414 c4ue_chk_b: 1415 000007A0 3C42 cmp al, 'B' 1416 ;;jne short c4ue_cpt 1417 ; 19/11/2024 1418 ;jne short c4ue_chk_h 1419 ; 25/12/2024 1420 ; 29/11/2024 1421 000007A2 7507 jne short c4ue_chk_n 1422 000007A4 E8D3040000 call Player_ProcessKey_Backwards 1423 000007A9 EB51 jmp short c4ue_cpt 1424 1425 ;;; 1426 ; 25/12/2024 1427 ; 29/11/2024 1428 c4ue_chk_n: 1429 000007AB 3C4E cmp al, 'N' 1430 000007AD 7404 je short c4ue_nps 1431 c4ue_chk_p: 1432 000007AF 3C50 cmp al, 'P' 1433 000007B1 7509 jne short c4ue_chk_h 1434 c4ue_nps: 1435 000007B3 C605[7D170000]03 mov byte [stopped], 3 1436 000007BA EB40 jmp short c4ue_cpt 1437 ;;; 1438 1439 c4ue_chk_h: 1440 ; 19/11/2024 1441 000007BC 3C48 cmp al, 'H' 1442 000007BE 750E jne short c4ue_chk_cr 1443 000007C0 C605[7F170000]00 mov byte [wpoints], 0 1444 ; 20/12/2024 1445 ; 18/12/2024 1446 000007C7 E867FEFFFF call write_sb16_dev_info 1447 ; 30/12/2024 1448 000007CC EB2E jmp short c4ue_cpt 1449 c4ue_chk_cr: 1450 ;;; 1451 ; 24/12/2024 (wave lighting points option) 1452 ;mov ah, [wpoints] 1453 ; 30/12/2024 1454 000007CE 31DB xor ebx, ebx 1455 000007D0 8A1D[7F170000] mov bl, [wpoints] 1456 000007D6 3C47 cmp al, 'G' 1457 000007D8 7406 je short c4ue_g 1458 ; 19/11/2024 1459 000007DA 3C0D cmp al, 0Dh ; ENTER/CR key 1460 000007DC 751E jne short c4ue_cpt 1461 ; 23/11/2024 1462 ;xor ebx, ebx 1463 ; 30/12/2024 1464 ;mov bl, ah ; 24/12/2024 1465 000007DE FEC3 inc bl 1466 c4ue_g: ; 30/12/2024 1467 000007E0 80E307 and bl, 07h 1468 000007E3 7501 jnz short c4ue_sc 1469 000007E5 43 inc ebx 1470 c4ue_sc: 1471 000007E6 881D[7F170000] mov [wpoints], bl 1472 ; 30/12/2024 1473 000007EC 8A83[5D120000] mov al, [ebx+colors-1] ; 1 to 7 1474 ; 24/12/2024 1475 000007F2 A2[65120000] mov [ccolor], al 1476 ; 30/12/2024 1477 000007F7 E8DB040000 call clear_window 1478 ;;; 1479 c4ue_cpt: 1480 ; 24/12/2024 1481 ; 18/11/2024 1482 000007FC 59 pop ecx ; * 1483 ;;; 1484 ; 29/12/2024 1485 ; 24/12/2024 (skip wave lighting if data is not loaded yet) 1486 ;cmp byte [SRB], 0 1487 ;ja short c4ue_vb_ok 1488 ;;; 1489 ; 01/12/2024 (TRDOS 386) 1490 sys _time, 4 ; get timer ticks (18.2 ticks/second), 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 000007FD BB04000000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000802 B80D000000 <1> mov eax, %1 103 <1> 104 00000807 CD40 <1> int 40h 1491 ; 24/12/2024 1492 ; 18/11/2024 1493 ;pop ecx ; * 1494 ; 01/12/2024 1495 00000809 3B05[24180000] cmp eax, [timerticks] 1496 ;je short c4ue_ok 1497 ; 18/11/2024 1498 0000080F 7408 je short c4ue_skip_utt 1499 c4ue_utt: 1500 ; 01/12/2024 1501 00000811 A3[24180000] mov [timerticks], eax 1502 00000816 EB05 jmp short c4ue_cpt_@ 1503 1504 ; 30/12/2024 1505 c4ue_vb_ok: 1506 00000818 C3 retn 1507 1508 c4ue_skip_utt: 1509 ; 18/11/2024 1510 00000819 21C9 and ecx, ecx 1511 0000081B 74FB jz short c4ue_vb_ok 1512 c4ue_cpt_@: 1513 ; 18/11/2024 1514 0000081D 803D[7D170000]00 cmp byte [stopped], 0 1515 00000824 77F2 ja short c4ue_vb_ok 1516 1517 00000826 E89F020000 call CalcProgressTime 1518 1519 ;cmp ax, [ProgressTime] 1520 ; 01/12/2024 1521 0000082B 3B05[18180000] cmp eax, [ProgressTime] 1522 ;je short c4ue_vb_ok 1523 ; same second, no need to update 1524 ; 23/11/2024 1525 00000831 7405 je short c4ue_uvb 1526 1527 ;call UpdateProgressTime 1528 ;call UpdateProgressBar@ 1529 00000833 E8B8030000 call UpdateProgressBar 1530 1531 ; 23/11/2024 1532 c4ue_uvb: 1533 00000838 803D[7F170000]00 cmp byte [wpoints], 0 1534 0000083F 76D7 jna short c4ue_vb_ok 1535 1536 ; 30/12/2024 1537 ;call UpdateWavePoints 1538 ;retn 1539 1540 ; 08/01/2025 1541 00000841 FF15[28180000] call dword [UpdateWavePoints] 1542 00000847 C3 retn 1543 1544 ; -------------------------------------------------------- 1545 ; 27/12/2024 - Erdogan Tan 1546 ; -------------------------------------------------------- 1547 1548 ; 08/01/2025 1549 ; 06/01/2025 (cgaplay2.s) -SB16- (32bit regs) 1550 ; 02/01/2025 (cgaplay2.asm) -SB16- 1551 ; 01/01/2025 (cgaplay.asm, 16bit registers) 1552 ; 30/12/2024 (cgaplay.s) -AC97- 1553 ; * 320*200 pixels, 256 colors 1554 ; * 64 volume levels 1555 ; 29/12/2024 1556 ; 27/12/2024 (DMA Buffer Tracking) 1557 ; 26/12/2024 1558 ; 24/12/2024 1559 ;UpdateWavePoints: 1560 ; 06/01/2025 1561 UpdateWavePoints_16s: 1562 ; 08/01/2025 1563 00000848 E833010000 call get_current_sounddata 1564 ; 1565 0000084D BE[78120000] mov esi, prev_points 1566 00000852 833E00 cmp dword [esi], 0 1567 00000855 740B jz short lights_off_ok 1568 ;mov ecx, 640 1569 ; 30/12/2024 1570 00000857 B940010000 mov ecx, 320 1571 light_off: 1572 0000085C AD lodsd 1573 ; eax = wave point (lighting point) address 1574 0000085D C60000 mov byte [eax], 0 ; black point (light off) 1575 00000860 E2FA loop light_off 1576 1577 lights_off_ok: 1578 1579 ; 08/01/2025 1580 %if 0 1581 ; 29/12/2024 1582 cmp byte [tLO],'2' 1583 jne short lights_on_buff_1 1584 lights_on_buff_2: 1585 ; 06/01/2025 1586 mov edx, wav_buffer2 1587 jmp short lights_on 1588 lights_on_buff_1: 1589 ; 06/01/2025 1590 mov edx, wav_buffer1 1591 lights_on: 1592 cmp [pbuf_s], edx 1593 jne short lights_on_2 1594 mov ebx, [wpoints_dif] 1595 mov esi, [pbuf_o] 1596 ;mov ecx, [buffersize] ; bytes 1597 ; 06/01/2025 1598 mov ecx, BUFFERSIZE 1599 sub ecx, ebx ; sub ecx, [wpoints_dif] 1600 add esi, ebx 1601 jc short lights_on_1 1602 cmp esi, ecx 1603 jna short lights_on_3 1604 lights_on_1: 1605 mov esi, ecx 1606 jmp short lights_on_3 1607 1608 lights_on_2: 1609 ; 29/12/2024 1610 mov [pbuf_s], edx 1611 xor esi, esi ; 0 1612 lights_on_3: 1613 mov [pbuf_o], esi 1614 ; 29/12/2024 1615 ;add esi, [pbuf_s] 1616 add esi, edx 1617 %else 1618 ; 08/01/2025 1619 00000862 BE[30180000] mov esi, sounddata 1620 %endif 1621 ;mov ecx, 640 1622 ; 30/12/2024 1623 00000867 B940010000 mov ecx, 320 1624 0000086C 89CD mov ebp, ecx 1625 ; 26/12/2024 1626 0000086E BF[78120000] mov edi, prev_points 1627 ;mov ebx, [graphstart] ; start (top) line 1628 ; 06/01/2025 1629 00000873 BB00730A00 mov ebx, 0A0000h+(11*8*320)+(4*320) 1630 lights_on_4: 1631 00000878 31C0 xor eax, eax ; 0 1632 0000087A 66AD lodsw ; left 1633 0000087C 80C480 add ah, 80h 1634 0000087F 89C2 mov edx, eax 1635 00000881 66AD lodsw ; right 1636 ;add ax, dx 1637 00000883 80C480 add ah, 80h 1638 ;;shr eax, 9 ; 128 volume levels 1639 ; 01/01/2025 1640 00000886 01D0 add eax, edx 1641 ;;shr eax, 10 ; (L+R/2) & 128 volume levels 1642 ;shr eax, 9 ; (L+R/2) & 256 volume levels 1643 ; 30/12/2024 1644 00000888 C1E80B shr eax, 11 ; (L+R/2) & 64 volume levels 1645 ; * 320 row ; 30/12/2024 1646 0000088B F7E5 mul ebp ; * 640 (row) 1647 0000088D 01D8 add eax, ebx ; + column 1648 0000088F 8A15[65120000] mov dl, [ccolor] 1649 00000895 8810 mov [eax], dl ; pixel (light on) color 1650 00000897 AB stosd ; save light on addr in prev_points 1651 00000898 43 inc ebx 1652 00000899 E2DD loop lights_on_4 1653 0000089B C3 retn 1654 1655 ; ------------------------- 1656 1657 ; 08/01/2025 1658 ; 06/01/2025 (cgaplay2.s, SB16, TRDOS386) 1659 ; 02/01/2025 (cgaplay2.asm, SB16, RetroDOS) 1660 ; 01/01/2025 (cgaplay.asm, AC97, RetroDOS) 1661 ; 30/12/2024 (cgaplay.s, AC97, TRDOS386) 1662 ; * 320*200 pixels, 256 colors 1663 ; * 64 volume levels 1664 UpdateWavePoints_16m: 1665 ; 08/01/2025 1666 0000089C E8DF000000 call get_current_sounddata 1667 ; 1668 000008A1 BE[78120000] mov esi, prev_points 1669 000008A6 833E00 cmp dword [esi], 0 1670 000008A9 740B jz short lights_off_16m_ok 1671 ;mov ecx, 640 1672 ; 30/12/2024 1673 000008AB B940010000 mov ecx, 320 1674 light_16m_off: 1675 000008B0 AD lodsd 1676 ; eax = wave point (lighting point) address 1677 000008B1 C60000 mov byte [eax], 0 ; black point (light off) 1678 000008B4 E2FA loop light_16m_off 1679 1680 lights_off_16m_ok: 1681 1682 ; 08/01/2025 1683 %if 0 1684 ; 29/12/2024 1685 cmp byte [tLO],'2' 1686 jne short lights_16m_on_buff_1 1687 lights_16m_on_buff_2: 1688 ; 06/01/2025 1689 mov edx, wav_buffer2 1690 jmp short lights_16m_on 1691 lights_16m_on_buff_1: 1692 ; 06/01/2025 1693 mov edx, wav_buffer1 1694 lights_16m_on: 1695 cmp [pbuf_s], edx 1696 jne short lights_16m_on_2 1697 mov ebx, [wpoints_dif] 1698 mov esi, [pbuf_o] 1699 ; 06/01/2025 1700 mov ecx, BUFFERSIZE 1701 sub ecx, ebx ; sub ecx, [wpoints_dif] 1702 add esi, ebx 1703 jc short lights_16m_on_1 1704 cmp esi, ecx 1705 jna short lights_16m_on_3 1706 lights_16m_on_1: 1707 mov esi, ecx 1708 jmp short lights_16m_on_3 1709 1710 lights_16m_on_2: 1711 ; 06/01/2025 1712 mov [pbuf_s], edx 1713 xor esi, esi ; 0 1714 lights_16m_on_3: 1715 mov [pbuf_o], esi 1716 ; 29/12/2024 1717 ;add esi, [pbuf_s] 1718 add esi, edx 1719 %else 1720 ; 08/01/2025 1721 000008B6 BE[30180000] mov esi, sounddata 1722 %endif 1723 ;mov ecx, 640 1724 ; 30/12/2024 1725 000008BB B940010000 mov ecx, 320 1726 000008C0 89CD mov ebp, ecx 1727 ; 26/12/2024 1728 000008C2 BF[78120000] mov edi, prev_points 1729 ; 06/01/2025 1730 000008C7 BB00730A00 mov ebx, 0A0000h+(11*8*320)+(4*320) 1731 lights_16m_on_4: 1732 ; 06/01/2025 1733 ; 02/01/2025 (16bit mono play modifications) 1734 000008CC 31C0 xor eax, eax ; 0 1735 000008CE 66AD lodsw 1736 000008D0 80C480 add ah, 80h 1737 ; 06/01/2025 1738 000008D3 C1E80A shr eax, 10 ; 64 volume levels 1739 ; * 320 row ; 30/12/2024 1740 000008D6 F7E5 mul ebp ; * 640 (row) 1741 000008D8 01D8 add eax, ebx ; + column 1742 000008DA 8A15[65120000] mov dl, [ccolor] 1743 000008E0 8810 mov [eax], dl ; pixel (light on) color 1744 000008E2 AB stosd ; save light on addr in prev_points 1745 000008E3 43 inc ebx 1746 000008E4 E2E6 loop lights_16m_on_4 1747 000008E6 C3 retn 1748 1749 ; ------------------------- 1750 1751 ; 06/01/2025 1752 ; 02/01/2025 1753 UpdateWavePoints_8s: 1754 ; 08/01/2025 1755 000008E7 E894000000 call get_current_sounddata 1756 ; 1757 000008EC BE[78120000] mov esi, prev_points 1758 000008F1 833E00 cmp dword [esi], 0 1759 000008F4 740B jz short lights_off_8s_ok 1760 ;mov ecx, 640 1761 ; 30/12/2024 1762 000008F6 B940010000 mov ecx, 320 1763 light_8s_off: 1764 000008FB AD lodsd 1765 ; eax = wave point (lighting point) address 1766 000008FC C60000 mov byte [eax], 0 ; black point (light off) 1767 000008FF E2FA loop light_8s_off 1768 1769 lights_off_8s_ok: 1770 1771 ; 08/01/2025 1772 %if 0 1773 ; 29/12/2024 1774 cmp byte [tLO],'2' 1775 jne short lights_8s_on_buff_1 1776 lights_8s_on_buff_2: 1777 ; 06/01/2025 1778 mov edx, wav_buffer2 1779 jmp short lights_8s_on 1780 lights_8s_on_buff_1: 1781 ; 06/01/2025 1782 mov edx, wav_buffer1 1783 lights_8s_on: 1784 cmp [pbuf_s], edx 1785 jne short lights_8s_on_2 1786 mov ebx, [wpoints_dif] 1787 mov esi, [pbuf_o] 1788 ; 06/01/2025 1789 mov ecx, BUFFERSIZE 1790 sub ecx, ebx ; sub ecx, [wpoints_dif] 1791 add esi, ebx 1792 jc short lights_8s_on_1 1793 cmp esi, ecx 1794 jna short lights_8s_on_3 1795 lights_8s_on_1: 1796 mov esi, ecx 1797 jmp short lights_8s_on_3 1798 1799 lights_8s_on_2: 1800 ; 06/01/2025 1801 mov [pbuf_s], edx 1802 xor esi, esi ; 0 1803 lights_8s_on_3: 1804 mov [pbuf_o], esi 1805 ; 29/12/2024 1806 ;add esi, [pbuf_s] 1807 add esi, edx 1808 %else 1809 ; 08/01/2025 1810 00000901 BE[30180000] mov esi, sounddata 1811 %endif 1812 ;mov ecx, 640 1813 ; 30/12/2024 1814 00000906 B940010000 mov ecx, 320 1815 0000090B 89CD mov ebp, ecx 1816 ; 26/12/2024 1817 0000090D BF[78120000] mov edi, prev_points 1818 ; 06/01/2025 1819 00000912 BB00730A00 mov ebx, 0A0000h+(11*8*320)+(4*320) 1820 lights_8s_on_4: 1821 ; 06/01/2025 1822 ; 02/01/2025 (8bit stereo play modifications) 1823 00000917 31C0 xor eax, eax ; 0 1824 00000919 AC lodsb ; left 1825 0000091A 89C2 mov edx, eax 1826 0000091C AC lodsb ; right 1827 0000091D 01D0 add eax, edx 1828 0000091F D1E8 shr eax, 1 ; (L+R/2) 1829 00000921 2CFF sub al, 255 ; max. value will be shown on top 1830 00000923 C1E802 shr eax, 2 ; 64 volume levels 1831 ; * 320 row ; 30/12/2024 1832 00000926 F7E5 mul ebp ; * 640 (row) 1833 00000928 01D8 add eax, ebx ; + column 1834 0000092A 8A15[65120000] mov dl, [ccolor] 1835 00000930 8810 mov [eax], dl ; pixel (light on) color 1836 00000932 AB stosd ; save light on addr in prev_points 1837 00000933 43 inc ebx 1838 00000934 E2E1 loop lights_8s_on_4 1839 00000936 C3 retn 1840 1841 ; ------------------------- 1842 1843 ; 06/01/2025 1844 ; 02/01/2025 1845 UpdateWavePoints_8m: 1846 ; 08/01/2025 1847 00000937 E844000000 call get_current_sounddata 1848 ; 1849 0000093C BE[78120000] mov esi, prev_points 1850 00000941 833E00 cmp dword [esi], 0 1851 00000944 740B jz short lights_off_8m_ok 1852 ;mov ecx, 640 1853 ; 30/12/2024 1854 00000946 B940010000 mov ecx, 320 1855 light_8m_off: 1856 0000094B AD lodsd 1857 ; eax = wave point (lighting point) address 1858 0000094C C60000 mov byte [eax], 0 ; black point (light off) 1859 0000094F E2FA loop light_8m_off 1860 1861 lights_off_8m_ok: 1862 1863 ; 08/01/2025 1864 %if 0 1865 ; 29/12/2024 1866 cmp byte [tLO],'2' 1867 jne short lights_8m_on_buff_1 1868 lights_8m_on_buff_2: 1869 ; 06/01/2025 1870 mov edx, wav_buffer2 1871 jmp short lights_8m_on 1872 lights_8m_on_buff_1: 1873 ; 06/01/2025 1874 mov edx, wav_buffer1 1875 lights_8m_on: 1876 cmp [pbuf_s], edx 1877 jne short lights_8m_on_2 1878 mov ebx, [wpoints_dif] 1879 mov esi, [pbuf_o] 1880 ; 06/01/2025 1881 mov ecx, BUFFERSIZE 1882 sub ecx, ebx ; sub ecx, [wpoints_dif] 1883 add esi, ebx 1884 jc short lights_8m_on_1 1885 cmp esi, ecx 1886 jna short lights_8m_on_3 1887 lights_8m_on_1: 1888 mov esi, ecx 1889 jmp short lights_8m_on_3 1890 1891 lights_8m_on_2: 1892 ; 06/01/2025 1893 mov [pbuf_s], edx 1894 xor esi, esi ; 0 1895 lights_8m_on_3: 1896 mov [pbuf_o], esi 1897 ; 29/12/2024 1898 ;add esi, [pbuf_s] 1899 add esi, edx 1900 %else 1901 ; 08/01/2025 1902 00000951 BE[30180000] mov esi, sounddata 1903 %endif 1904 ;mov ecx, 640 1905 ; 30/12/2024 1906 00000956 B940010000 mov ecx, 320 1907 0000095B 89CD mov ebp, ecx 1908 ; 26/12/2024 1909 0000095D BF[78120000] mov edi, prev_points 1910 ; 06/01/2025 1911 00000962 BB00730A00 mov ebx, 0A0000h+(11*8*320)+(4*320) 1912 lights_8m_on_4: 1913 ; 06/01/2025 1914 ; 02/01/2025 (16bit mono play modifications) 1915 00000967 31C0 xor eax, eax ; 0 1916 00000969 AC lodsb 1917 0000096A 2CFF sub al, 255 ; max. value will be shown on top 1918 0000096C C1E802 shr eax, 2 ; 64 volume levels 1919 ; * 320 row ; 30/12/2024 1920 0000096F F7E5 mul ebp ; * 640 (row) 1921 00000971 01D8 add eax, ebx ; + column 1922 00000973 8A15[65120000] mov dl, [ccolor] 1923 00000979 8810 mov [eax], dl ; pixel (light on) color 1924 0000097B AB stosd ; save light on addr in prev_points 1925 0000097C 43 inc ebx 1926 0000097D E2E8 loop lights_8m_on_4 1927 0000097F C3 retn 1928 1929 ; -------------------------------------------------------- 1930 ; 08/01/2025 - Get Current Sound Data For Graphics 1931 ; -------------------------------------------------------- 1932 1933 ; 08/01/2025 1934 get_current_sounddata: 1935 sys _audio, 0F00h, [sd_count], sounddata 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000980 BB000F0000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000985 8B0D[68120000] <1> mov ecx, %3 97 <1> %if %0 = 4 98 0000098B BA[30180000] <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000990 B820000000 <1> mov eax, %1 103 <1> 104 00000995 CD40 <1> int 40h 1936 00000997 C3 retn 1937 1938 ; -------------------------------------------------------- 1939 ; 19/05/2024 - (playwav4.asm) ich_wav4.asm 1940 ; -------------------------------------------------------- 1941 1942 ; 06/01/2025 1943 ; 29/12/2024 1944 ; 25/12/2024 1945 ; 07/12/2024 1946 ; 01/12/2024 (TRDOS 386) 1947 ; 29/11/2024 1948 check4keyboardstop: 1949 ; 19/05/2024 1950 ; 08/11/2023 1951 ; 04/11/2023 1952 00000998 B401 mov ah, 1 1953 ;int 16h 1954 ; 01/12/2024 (TRDOS 386 keyboard interrupt) 1955 0000099A CD32 int 32h 1956 ;clc 1957 0000099C 7433 jz short _cksr 1958 1959 0000099E 30E4 xor ah, ah 1960 ;int 16h 1961 ; 01/12/2024 (TRDOS 386 keyboard interrupt) 1962 000009A0 CD32 int 32h 1963 1964 ; 25/12/2024 1965 ; 29/11/2024 1966 ;mov [command], al 1967 1968 ;;; 1969 ; 19/05/2024 (change PCM out volume) 1970 000009A2 3C2B cmp al, '+' 1971 000009A4 750D jne short p_1 1972 1973 000009A6 A0[FB090000] mov al, [volume] 1974 000009AB 3C00 cmp al, 0 1975 000009AD 7624 jna short p_3 1976 000009AF FEC8 dec al 1977 000009B1 EB0F jmp short p_2 1978 p_1: 1979 000009B3 3C2D cmp al, '-' 1980 000009B5 751D jne short p_4 1981 1982 000009B7 A0[FB090000] mov al, [volume] 1983 000009BC 3C1F cmp al, 31 1984 000009BE 7313 jnb short p_3 1985 000009C0 FEC0 inc al 1986 p_2: 1987 000009C2 A2[FB090000] mov [volume], al 1988 ; 14/11/2024 1989 ;call SetPCMOutVolume 1990 ; 16/12/2024 (TRDOS 386, SB16) 1991 ; 15/11/2024 (QEMU) 1992 ;call SetMasterVolume 1993 ; 18/12/2024 1994 000009C7 E809FBFFFF call SetMasterVolume@ 1995 ;call UpdateVolume 1996 ;;clc 1997 ;retn 1998 000009CC E99A010000 jmp UpdateVolume 1999 _cksr: ; 19/05/2024 2000 ; 18/12/2024 2001 000009D1 31C0 xor eax, eax 2002 ;clc 2003 p_3: 2004 000009D3 C3 retn 2005 p_4: 2006 ; 17/11/2024 2007 000009D4 80FC01 cmp ah, 01h ; ESC 2008 000009D7 7419 je short p_q 2009 ;cmp ax, 2E03h ; 21/12/2024 2010 000009D9 3C03 cmp al, 03h ; CTRL+C 2011 000009DB 7415 je short p_q 2012 2013 ; 18/11/2024 2014 000009DD 3C20 cmp al, 20h 2015 000009DF 7419 je short p_r 2016 2017 ; 19/11/2024 2018 000009E1 3C0D cmp al, 0Dh ; CR/ENTER 2019 000009E3 7415 je short p_r 2020 2021 000009E5 24DF and al, 0DFh 2022 2023 ; 25/12/2024 2024 ; 29/11/2024 2025 000009E7 A2[80170000] mov [command], al 2026 2027 ;cmp al, 'B' 2028 ;je short p_r 2029 ;cmp al, 'F' 2030 ;je short p_r 2031 2032 ; 29/11/2024 2033 ;cmp al, 'N' 2034 ;je short p_r 2035 ;cmp al, 'P' 2036 ;je short p_r 2037 2038 000009EC 3C51 cmp al, 'Q' 2039 ;je short p_q 2040 000009EE 7409 je short p_quit ; 29/11/2024 2041 2042 000009F0 F8 clc 2043 000009F1 C3 retn 2044 2045 ;;; 2046 ;_cskr: 2047 p_q: 2048 ; 27/12/2024 2049 000009F2 C605[80170000]51 mov byte [command], 'Q' 2050 p_quit: 2051 000009F9 F9 stc 2052 p_r: 2053 000009FA C3 retn 2054 2055 ; 29/05/2024 2056 ; 19/05/2024 2057 volume: 2058 ;db 02h 2059 ; 26/12/2024 2060 000009FB 03 db 03h 2061 2062 ; -------------------------------------------------------- 2063 2064 ; 30/12/2024 2065 ; simulate cursor position in VGA mode 13h 2066 ; ! for 320*200, 256 colors (1 byte/pixel) ! 2067 setCursorPosition: 2068 ; dh = Row 2069 ; dl = Column 2070 2071 000009FC 31C0 xor eax, eax 2072 ; row height is 8 pixels (8*8) 2073 000009FE 88F0 mov al, dh 2074 00000A00 C1E003 shl eax, 3 2075 00000A03 6683C002 add ax, 2 ; top margin 2076 00000A07 C1E010 shl eax, 16 2077 00000A0A 88D0 mov al, dl ; * 8 ; character width = 8 pixels 2078 00000A0C 66C1E003 shl ax, 3 2079 ; hw = row, ax = column 2080 00000A10 A3[6C120000] mov [screenpos], eax 2081 ; 22/12/2024 2082 00000A15 31C0 xor eax, eax 2083 00000A17 C3 retn 2084 2085 ; -------------------------------------------------------- 2086 ; 14/11/2024 2087 ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017) 2088 2089 ;; NAME: SetTotalTime 2090 ;; DESCRIPTION: Calculates the total time in seconds in file 2091 ;; INPUT: DATA_SubchunkSize, WAVE_SampleRate, WAVE_BlockAlign 2092 ;; OUTPUT: CurrentTotalTime=Total time in seconds in file, 2093 ;; Output on the screen of the total time in seconds 2094 2095 ; 01/12/2024 (32 bit registers) 2096 SetTotalTime: 2097 ;; Calculate total seconds in file 2098 ;mov ax, [DATA_SubchunkSize] 2099 ;mov dx, [DATA_SubchunkSize + 2] 2100 ;mov bx, [WAVE_SampleRate] 2101 ;div bx 2102 ;xor dx, dx 2103 ; 01/12/2024 2104 00000A18 A1[AC170000] mov eax, [DATA_SubchunkSize] 2105 00000A1D 0FB71D[9C170000] movzx ebx, word [WAVE_SampleRate] 2106 00000A24 31D2 xor edx, edx 2107 00000A26 F7F3 div ebx 2108 2109 ;mov bx, [WAVE_BlockAlign] 2110 ;div bx 2111 ; 01/12/2024 2112 00000A28 668B1D[A4170000] mov bx, [WAVE_BlockAlign] 2113 00000A2F 31D2 xor edx, edx 2114 00000A31 F7F3 div ebx 2115 2116 ;mov [TotalTime], ax 2117 00000A33 A3[14180000] mov [TotalTime], eax 2118 2119 00000A38 B33C mov bl, 60 2120 00000A3A F6F3 div bl 2121 2122 ;; al = minutes, ah = seconds 2123 00000A3C 50 push eax ; ** 2124 00000A3D 50 push eax ; * 2125 2126 ;mov dh, 24 2127 ; 21/12/2024 (640*480) 2128 ;mov dh, 32 2129 ;mov dl, 42 2130 ; 30/12/2024 (320*200) 2131 00000A3E B617 mov dh, 23 2132 00000A40 B216 mov dl, 22 2133 00000A42 E8B5FFFFFF call setCursorPosition 2134 2135 00000A47 58 pop eax ; * 2136 00000A48 30E4 xor ah, ah 2137 00000A4A BD02000000 mov ebp, 2 2138 00000A4F E812000000 call PrintNumber 2139 2140 ;mov dh, 24 2141 ; 21/12/2024 (640*480) 2142 ;mov dh, 32 2143 ;mov dl, 45 2144 ; 30/12/2024 (320*200) 2145 00000A54 B617 mov dh, 23 2146 00000A56 B219 mov dl, 25 2147 00000A58 E89FFFFFFF call setCursorPosition 2148 2149 00000A5D 58 pop eax ; ** 2150 00000A5E 88E0 mov al, ah 2151 00000A60 30E4 xor ah, ah 2152 ; 21/12/2024 2153 00000A62 66BD0200 mov bp, 2 2154 ;jmp short PrintNumber 2155 2156 ; -------------------------------------------------------- 2157 2158 ; 21/12/2024 (write numbers in VESA VBE graphics mode) 2159 ; 01/12/2024 (32bit registers) 2160 PrintNumber: 2161 ; eax = binary number 2162 ; ebp = digits 2163 00000A66 8B35[6C120000] mov esi, [screenpos] 2164 ; hw = row, si = column 2165 00000A6C BB0A000000 mov ebx, 10 2166 00000A71 31C9 xor ecx, ecx 2167 printNumber_CutNumber: 2168 00000A73 41 inc ecx 2169 00000A74 31D2 xor edx, edx 2170 00000A76 F7F3 div ebx 2171 00000A78 52 push edx 2172 00000A79 39E9 cmp ecx, ebp 2173 00000A7B 7402 je short printNumber_printloop 2174 00000A7D EBF4 jmp printNumber_CutNumber 2175 2176 printNumber_printloop: 2177 00000A7F 58 pop eax 2178 ; 21/12/2024 2179 ; ebp = count of digits 2180 ; eax <= 9 2181 2182 00000A80 0430 add al, '0' 2183 2184 ; esi = pixel position (hw = row, si = column) 2185 ; eax = al = character 2186 ;call write_character 2187 ; 22/12/2024 2188 00000A82 E82A010000 call write_character_white 2189 2190 00000A87 4D dec ebp 2191 00000A88 7405 jz short printNumber_ok 2192 00000A8A 83C608 add esi, 8 ; next column 2193 00000A8D EBF0 jmp short printNumber_printloop 2194 printNumber_ok: 2195 00000A8F C3 retn 2196 2197 ; -------------------------------------------------------- 2198 2199 ; 14/11/2024 - Erdogan Tan 2200 SetProgressTime: 2201 ;; Calculate playing/progress seconds in file 2202 00000A90 E835000000 call CalcProgressTime 2203 2204 ; 01/12/2024 (32bit registers) 2205 UpdateProgressTime: 2206 ; eax = (new) progress time 2207 2208 00000A95 A3[18180000] mov [ProgressTime], eax 2209 2210 00000A9A B33C mov bl, 60 2211 00000A9C F6F3 div bl 2212 2213 ;; al = minutes, ah = seconds 2214 00000A9E 50 push eax ; ** 2215 00000A9F 50 push eax ; * 2216 2217 ;mov dh, 24 2218 ; 21/12/2024 (640*480) 2219 ;mov dh, 32 2220 ;mov dl, 33 2221 ; 30/12/2024 (320*200) 2222 00000AA0 B617 mov dh, 23 2223 00000AA2 B20D mov dl, 13 2224 00000AA4 E853FFFFFF call setCursorPosition 2225 2226 00000AA9 58 pop eax ; * 2227 00000AAA 30E4 xor ah, ah 2228 00000AAC BD02000000 mov ebp, 2 2229 00000AB1 E8B0FFFFFF call PrintNumber 2230 2231 ;mov dh, 24 2232 ; 21/12/2024 (640*480) 2233 ;mov dh, 32 2234 ;mov dl, 36 2235 ; 30/12/2024 (320*200) 2236 00000AB6 B617 mov dh, 23 2237 00000AB8 B210 mov dl, 16 2238 00000ABA E83DFFFFFF call setCursorPosition 2239 2240 00000ABF 58 pop eax ; ** 2241 00000AC0 88E0 mov al, ah 2242 00000AC2 30E4 xor ah, ah 2243 ; 21/12/2024 2244 00000AC4 66BD0200 mov bp, 2 2245 00000AC8 EB9C jmp short PrintNumber 2246 2247 ; -------------------------------------------------------- 2248 2249 ; 01/12/2024 (32bit registers) 2250 ; 17/11/2024 2251 ; 14/11/2024 2252 CalcProgressTime: 2253 ;mov ax, [LoadedDataBytes] 2254 ;mov dx, [LoadedDataBytes+2] 2255 ;mov bx, ax 2256 ;or bx, dx 2257 ;jz short cpt_ok 2258 ; 01/12/2024 2259 00000ACA A1[20180000] mov eax, [LoadedDataBytes] 2260 00000ACF 09C0 or eax, eax 2261 00000AD1 7416 jz short cpt_ok 2262 2263 ;mov bx, [WAVE_SampleRate] 2264 ;div bx 2265 ;xor dx, dx 2266 ;mov bx, [WAVE_BlockAlign] 2267 ;div bx 2268 ; 01/12/2024 2269 00000AD3 0FB71D[9C170000] movzx ebx, word [WAVE_SampleRate] 2270 00000ADA 31D2 xor edx, edx 2271 00000ADC F7F3 div ebx 2272 00000ADE 31D2 xor edx, edx 2273 00000AE0 668B1D[A4170000] mov bx, [WAVE_BlockAlign] 2274 00000AE7 F7F3 div ebx 2275 cpt_ok: 2276 ; eax = (new) progress time 2277 00000AE9 C3 retn 2278 2279 ; -------------------------------------------------------- 2280 ; 14/11/2024 2281 ; (Ref: player.asm, out_cs.asm, Matan Alfasi, 2017) 2282 2283 ;; DESCRIPTION: Update file information on template 2284 ;; PARAMS: WAVE parameters and other variables 2285 ;; REGS: AX(RW) 2286 ;; VARS: CurrentFileName, WAVE_SampleRate, 2287 ;; RETURNS: On-screen file info is updated. 2288 2289 ; 01/12/2024 (32bit registers) 2290 UpdateFileInfo: 2291 ;; Print File Name 2292 ;mov dh, 9 2293 ; 21/12/2024 (640*480 graphics display) 2294 ;mov dh, 8 2295 ;mov dl, 23 2296 ; 30/12/2024 (320*200, video mode 13h) 2297 00000AEA B607 mov dh, 7 2298 00000AEC B208 mov dl, 8 2299 00000AEE E809FFFFFF call setCursorPosition 2300 2301 00000AF3 BE[C0170000] mov esi, wav_file_name 2302 2303 ;;; 2304 ; 14/11/2024 2305 ; skip directory separators 2306 ; (note: asciiz string, max. 79 bytes except zero tail) 2307 00000AF8 89F3 mov ebx, esi 2308 chk4_nxt_sep: 2309 00000AFA AC lodsb 2310 00000AFB 3C2F cmp al, '/' ; 14/12/2024 2311 00000AFD 7406 je short chg_fpos 2312 00000AFF 20C0 and al, al 2313 00000B01 7406 jz short chg_fpos_ok 2314 00000B03 EBF5 jmp short chk4_nxt_sep 2315 chg_fpos: 2316 00000B05 89F3 mov ebx, esi 2317 00000B07 EBF1 jmp short chk4_nxt_sep 2318 chg_fpos_ok: 2319 00000B09 89DE mov esi, ebx ; file name (without its path/directory) 2320 ;;; 2321 _fnl_chk: 2322 ; 30/12/2024 (cgaplay.s) 2323 ; ????????.wav 2324 ; 26/12/2024 (file name length limit -display-) 2325 00000B0B BB0C000000 mov ebx, 12 2326 ;mov ebx, 17 ; ????????.wav????? 2327 00000B10 56 push esi 2328 _fnl_chk_loop: 2329 00000B11 AC lodsb 2330 00000B12 20C0 and al, al 2331 00000B14 7406 jz short _fnl_ok 2332 00000B16 4B dec ebx 2333 00000B17 75F8 jnz short _fnl_chk_loop 2334 00000B19 C60600 mov byte [esi], 0 2335 _fnl_ok: 2336 00000B1C 5E pop esi 2337 ;;; 2338 2339 00000B1D E870000000 call PrintString 2340 2341 ;; Print Frequency 2342 ;mov dh, 10 2343 ; 21/12/2024 (640*480 graphics display) 2344 ;mov dh, 9 2345 ;mov dl, 23 2346 ; 30/12/2024 (320*200, video mode 13h) 2347 00000B22 B608 mov dh, 8 2348 00000B24 B208 mov dl, 8 2349 00000B26 E8D1FEFFFF call setCursorPosition 2350 ;movzx eax, word [WAVE_SampleRate] 2351 ; 22/12/2024 2352 ; eax = 0 2353 00000B2B 66A1[9C170000] mov ax, [WAVE_SampleRate] 2354 00000B31 BD05000000 mov ebp, 5 2355 00000B36 E82BFFFFFF call PrintNumber 2356 2357 ;; Print BitRate 2358 ;mov dh, 9 2359 ; 21/12/2024 (640*480 graphics display) 2360 ;mov dh, 8 2361 ;mov dl, 57 2362 ; 30/12/2024 (320*200, video mode 13h) 2363 00000B3B B607 mov dh, 7 2364 00000B3D B21F mov dl, 31 2365 00000B3F E8B8FEFFFF call setCursorPosition 2366 00000B44 66A1[A6170000] mov ax, [WAVE_BitsPerSample] 2367 00000B4A 66BD0200 mov bp, 2 2368 00000B4E E813FFFFFF call PrintNumber 2369 2370 ;; Print Channel Number 2371 ;mov dh, 10 2372 ; 21/12/2024 (640*480 graphics display) 2373 ;mov dh, 9 2374 ;mov dl, 57 2375 ; 30/12/2024 (320*200, video mode 13h) 2376 00000B53 B608 mov dh, 8 2377 00000B55 B21F mov dl, 31 2378 00000B57 E8A0FEFFFF call setCursorPosition 2379 00000B5C 66A1[9A170000] mov ax, [WAVE_NumChannels] 2380 00000B62 66BD0100 mov bp, 1 2381 00000B66 E8FBFEFFFF call PrintNumber 2382 2383 ;call UpdateVolume 2384 ;retn 2385 2386 ; -------------------------------------------------------- 2387 2388 ; 14/11/2024 2389 UpdateVolume: 2390 ;; Print Volume 2391 ;mov dh, 24 2392 ; 21/12/2024 (640*480) 2393 ;mov dh, 32 2394 ;mov dl, 75 2395 ; 30/12/2024 (320*200, video mode 13h) 2396 00000B6B B617 mov dh, 23 2397 00000B6D B223 mov dl, 35 2398 00000B6F E888FEFFFF call setCursorPosition 2399 ; 22/12/2024 2400 ; eax = 0 2401 2402 00000B74 A0[FB090000] mov al, [volume] 2403 2404 00000B79 B364 mov bl, 100 2405 00000B7B F6E3 mul bl 2406 2407 00000B7D B31F mov bl, 31 2408 00000B7F F6F3 div bl 2409 2410 ;neg ax 2411 ;add ax, 100 2412 ; 01/12/2024 2413 00000B81 B464 mov ah, 100 2414 00000B83 28C4 sub ah, al 2415 00000B85 0FB6C4 movzx eax, ah 2416 ;xor ah, ah 2417 ;mov bp, 3 2418 00000B88 BD03000000 mov ebp, 3 2419 ;call PrintNumber 2420 ;retn 2421 00000B8D E9D4FEFFFF jmp PrintNumber 2422 2423 ; -------------------------------------------------------- 2424 2425 ; 21/12/2024 2426 ; write text in VESA VBE graphics mode 2427 PrintString: 2428 ; esi = string address 2429 printstr_loop: 2430 00000B92 31C0 xor eax, eax 2431 00000B94 AC lodsb 2432 00000B95 08C0 or al, al 2433 00000B97 7417 jz short printstr_ok 2434 2435 00000B99 56 push esi 2436 2437 00000B9A 8B35[6C120000] mov esi, [screenpos] 2438 2439 ; esi = pixel position (hw = row, si = column) 2440 ; eax = al = character 2441 ;call write_character 2442 ; 22/12/2024 2443 00000BA0 E80C000000 call write_character_white 2444 2445 00000BA5 668305[6C120000]08 add word [screenpos], 8 ; update column (only, not row) 2446 2447 00000BAD 5E pop esi 2448 00000BAE EBE2 jmp short printstr_loop 2449 2450 printstr_ok: 2451 00000BB0 C3 retn 2452 2453 ; -------------------------------------------------------- 2454 2455 ; 30/12/2024 2456 ; write character (at cursor position) 2457 ; in video mode 13h (320*200, 256 colors) 2458 ; 21/12/2024 2459 ; write character (at cursor position) 2460 ; in graphics mode (640*480, 256 colors) 2461 ; 22/12/2024 2462 write_character_white: 2463 00000BB1 B90F000000 mov ecx, 0Fh 2464 ; 26/12/2024 2465 ;movzx ecx, byte [tcolor] 2466 write_character: 2467 ; esi = pixel position (hw = row, si = column) 2468 ; eax = al = character 2469 ; cl = color 2470 00000BB6 890D[70120000] mov [wcolor], ecx ; 22/12/2024 2471 2472 ; 30/12/2024 2473 ; 22/12/2024 2474 00000BBC 50 push eax 2475 ; clear previous character pixels 2476 00000BBD BF[54120000] mov edi, fillblock 2477 ;;sys _video, 020Fh, 0, 8001h 2478 ; 30/12/2024 2479 sys _video, 010Fh, 0, 8000h ; 8*8 userfont 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000BC2 BB0F010000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000BC7 B900000000 <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000BCC BA00800000 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000BD1 B81F000000 <1> mov eax, %1 103 <1> 104 00000BD6 CD40 <1> int 40h 2480 00000BD8 58 pop eax 2481 2482 ; 30/12/2024 2483 ;shl eax, 4 ; 8*16 pixel user font 2484 ;mov edi, fontbuff2 ; start of user font data 2485 ;add edi, eax 2486 2487 ; 21/12/2024 2488 ; NOTE: 2489 ; TRDOS 386 does not use 8*14 pixel fonts in sysvideo 2490 ; system calls -in graphics mode- 2491 ; because 8*16 pixel operations are faster 2492 ; than 8*14 pixel operations. 2493 ; ((so, 8*14 fonts can be converted to 8*16 fonts by 2494 ; adding 2 empty lines)) 2495 ; (8*14 characters can be written via pixel operations) 2496 2497 ; 21/12/2024 (TRDOS 386 v2.0.9, trdosk6.s, 27/09/2024) 2498 ;;;;;;;;;;;;;;;;; ; sysvideo system call 2499 ;sysvideo: 2500 ; function in BH 2501 ; 02h: Super VGA, LINEAR FRAME BUFFER data transfers 2502 ; sub function in BL 2503 ; 0Fh: WRITE CHARACTER (FONT) 2504 ; CL = char's color (8 bit, 256 colors) 2505 ; If DH bit 7 = 1 2506 ; USER FONT (from user buffer) 2507 ; DL = 1 -> 8x16 pixel font 2508 ; EDI = user's font buffer address 2509 ; (NOTE: byte order is as row0,row1,row2..) 2510 ; ESI = start position (row, column) 2511 ; (HW = row, SI = column) 2512 ;;;;;;;;;;;;;;;;; 2513 2514 ;sys _video, 020Fh, [wcolor], 8001h 2515 2516 ; 30/12/2024 2517 ; sysvideo system call 2518 ; BH = 01h = VGA graphics (0A0000h) data transfers 2519 ; BL = 0Fh = write character/font 2520 ; DH = 01h = 8*8 system font 2521 ; CL = [wcolor] = color 2522 ; ESI = cursor/writing position (pixels) 2523 ; HW = row, SI = column 2524 ; DL = character (ASCII code) 2525 2526 00000BD9 B401 mov ah, 01h ; 8*8 pixels 2527 2528 sys _video, 010Fh, [wcolor], eax 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000BDB BB0F010000 <1> mov ebx, %2 95 <1> %if %0 >= 3 96 00000BE0 8B0D[70120000] <1> mov ecx, %3 97 <1> %if %0 = 4 98 00000BE6 89C2 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000BE8 B81F000000 <1> mov eax, %1 103 <1> 104 00000BED CD40 <1> int 40h 2529 2530 00000BEF C3 retn 2531 2532 ; -------------------------------------------------------- 2533 2534 ; 30/12/2024 2535 ; write characters in video mode 13h 2536 ; (320*200 pixels, 256 colors) 2537 ; 22/12/2024 2538 ; 21/12/2024 2539 ; (write chars in VESA VBE graphics mode) 2540 ; 14/11/2024 2541 ; (Ref: player.asm, Matan Alfasi, 2017) 2542 ; (Modification: Erdogan Tan, 14/11/2024) 2543 2544 ;PROGRESSBAR_ROW equ 23 2545 ; 21/12/2024 (640*480) 2546 ;PROGRESSBAR_ROW equ 31 2547 ; 30/12/2024 (320*200) 2548 PROGRESSBAR_ROW equ 22 2549 2550 UpdateProgressBar: 2551 00000BF0 E89BFEFFFF call SetProgressTime ; 14/11/2024 2552 2553 ; 01/12/2024 (32bit registers) 2554 00000BF5 A1[18180000] mov eax, [ProgressTime] 2555 UpdateProgressBar@: 2556 ;mov edx, 80 2557 ; 30/12/2024 2558 00000BFA BA28000000 mov edx, 40 ; 320*200 pixels, 40 columns 2559 00000BFF F7E2 mul edx 2560 00000C01 8B1D[14180000] mov ebx, [TotalTime] 2561 00000C07 F7F3 div ebx 2562 2563 ; 22/12/2024 2564 ; check progress bar indicator position if it is same 2565 00000C09 3A05[75120000] cmp al, [pbprev] 2566 00000C0F 7430 je short UpdateProgressBar_ok 2567 00000C11 A2[75120000] mov [pbprev], al 2568 2569 UpdateProgressBar@@: 2570 ;; Push for the 'Clean' part 2571 00000C16 50 push eax ; ** 2572 00000C17 50 push eax ; * 2573 2574 ;; Set cursor position 2575 00000C18 B616 mov dh, PROGRESSBAR_ROW 2576 00000C1A B200 mov dl, 0 2577 00000C1C E8DBFDFFFF call setCursorPosition 2578 2579 00000C21 58 pop eax ; * 2580 00000C22 09C0 or eax, eax 2581 00000C24 742D jz short UpdateProgressBar_Clean 2582 2583 UpdateProgressBar_DrawProgress: 2584 ; 22/12/2024 2585 ; 21/12/2024 2586 ; (write progress bar chars in graphics mode) 2587 ;;;; 2588 00000C26 89C5 mov ebp, eax 2589 00000C28 50 push eax ; *** 2590 00000C29 8B35[6C120000] mov esi, [screenpos] 2591 UpdateProgressBar_DrawProgress_@: 2592 00000C2F B8DF000000 mov eax, 223 2593 2594 ; esi = pixel position (hw = row, si = column) 2595 ; eax = al = character 2596 ;call write_character 2597 ; 22/12/2024 2598 00000C34 E878FFFFFF call write_character_white 2599 2600 00000C39 4D dec ebp 2601 00000C3A 7406 jz short UpdateProgressBar_DrawCursor 2602 2603 00000C3C 83C608 add esi, 8 ; next column 2604 00000C3F EBEE jmp short UpdateProgressBar_DrawProgress_@ 2605 ;;; 2606 2607 UpdateProgressBar_ok: 2608 00000C41 C3 retn 2609 2610 UpdateProgressBar_DrawCursor: 2611 ; 22/12/2024 2612 00000C42 5A pop edx ; *** 2613 00000C43 B616 mov dh, PROGRESSBAR_ROW 2614 00000C45 E8B2FDFFFF call setCursorPosition 2615 2616 ; 21/12/2024 2617 ; (write progress bar character in graphics mode) 2618 ;;;; 2619 ;;;mov eax, 223 2620 ;;;shl eax, 4 ; 8*16 pixel user font 2621 ;;mov eax, 223*16 2622 ;;mov edi, fontbuff2 ; start of user font data 2623 ;;add edi, eax 2624 ;mov edi, fontbuff2+(223*16) 2625 ; 2626 ;sys _video, 020Fh, 0Ch, 8001h 2627 ; 22/12/2024 2628 ;mov eax, 223 2629 ; eax = 0 2630 00000C4A B0DF mov al, 223 2631 00000C4C B10C mov cl, 0Ch ; red 2632 00000C4E E863FFFFFF call write_character 2633 ;;;; 2634 2635 UpdateProgressBar_Clean: 2636 ;pop eax ; ** 2637 ; 22/12/2024 2638 00000C53 5A pop edx ; ** 2639 ; 30/12/2024 2640 ; 21/12/2024 2641 ;mov ebp, 80 2642 ; 30/12/2024 2643 00000C54 BD28000000 mov ebp, 40 ; 40 columns (320*200 pixels) 2644 ;sub bp, ax 2645 00000C59 6629D5 sub bp, dx ; 22/12/2024 2646 00000C5C 74E3 jz short UpdateProgressBar_ok 2647 2648 00000C5E B616 mov dh, PROGRESSBAR_ROW 2649 ;mov dl, al ; 22/12/2024 2650 00000C60 E897FDFFFF call setCursorPosition 2651 2652 ; 21/12/2024 2653 ; (write progress bar chars in graphics mode) 2654 ;;;; 2655 00000C65 8B35[6C120000] mov esi, [screenpos] 2656 UpdateProgressBar_Clean_@: 2657 ;;;mov eax, 223 2658 ;;;shl eax, 4 ; 8*16 pixel user font 2659 ;;mov eax, 223*16 2660 ;mov edi, fontbuff2 ; start of user font data 2661 ;add edi, eax 2662 ;mov edi, fontbuff2+(223*16) 2663 ; 2664 ;sys _video, 020Fh, 08h, 8001h 2665 ; 22/12/2024 2666 ;mov eax, 223 2667 ; eax = 0 2668 00000C6B B0DF mov al, 223 2669 00000C6D B108 mov cl, 08h ; gray (dark) 2670 00000C6F E842FFFFFF call write_character 2671 ;;;; 2672 2673 00000C74 4D dec ebp 2674 00000C75 74CA jz short UpdateProgressBar_ok 2675 2676 00000C77 83C608 add esi, 8 ; next column 2677 00000C7A EBEF jmp short UpdateProgressBar_Clean_@ 2678 ;;;; 2679 2680 ; -------------------------------------------------------- 2681 ; 17/11/2024 2682 2683 Player_ProcessKey_Backwards: 2684 ;; In order to go backwards 5 seconds: 2685 ;; Update file pointer to the beginning, skip headers 2686 00000C7C B142 mov cl, 'B' 2687 00000C7E EB02 jmp short Player_ProcessKey_B_or_F 2688 2689 Player_ProcessKey_Forwards: 2690 ;; In order to fast-forward 5 seconds, set the file pointer 2691 ;; to CUR_SEEK + 5 * Freq 2692 2693 00000C80 B146 mov cl, 'F' 2694 ;jmp short Player_ProcessKey_B_or_F 2695 2696 ; 01/12/2024 (32bit regsisters) 2697 Player_ProcessKey_B_or_F: 2698 ; 17/11/2024 2699 ; 04/11/2024 2700 ; (Ref: player.asm, Matan Alfasi, 2017) 2701 2702 ; 04/11/2024 2703 00000C82 B805000000 mov eax, 5 2704 00000C87 0FB71D[A4170000] movzx ebx, word [WAVE_BlockAlign] 2705 00000C8E F7E3 mul ebx 2706 00000C90 668B1D[9C170000] mov bx, [WAVE_SampleRate] 2707 00000C97 F7E3 mul ebx 2708 ; eax = transfer byte count for 5 seconds 2709 2710 ; 17/11/2024 2711 00000C99 80F942 cmp cl, 'B' 2712 ;mov bx, [LoadedDataBytes] 2713 ;mov cx, [LoadedDataBytes+2] 2714 ; 01/12/2024 2715 00000C9C 8B0D[20180000] mov ecx, [LoadedDataBytes] 2716 00000CA2 7508 jne short move_forward ; cl = 'F' 2717 move_backward: 2718 ;sub bx, ax 2719 ;sbb cx, dx 2720 00000CA4 29C1 sub ecx, eax 2721 00000CA6 7316 jnc short move_file_pointer 2722 move_to_beginning: 2723 ;xor cx, cx ; 0 2724 ;xor bx, bx ; 0 2725 00000CA8 31C9 xor ecx, ecx 2726 00000CAA EB12 jmp short move_file_pointer 2727 move_forward: 2728 ;add bx, ax 2729 ;adc cx, dx 2730 00000CAC 01C1 add ecx, eax 2731 00000CAE 7208 jc short move_to_end 2732 ;cmp cx, [DATA_SubchunkSize+2] 2733 ;ja short move_to_end 2734 ;jb short move_file_pointer 2735 ;cmp bx, [DATA_SubchunkSize] 2736 ;jna short move_file_pointer 2737 00000CB0 3B0D[AC170000] cmp ecx, [DATA_SubchunkSize] 2738 00000CB6 7606 jna short move_file_pointer 2739 move_to_end: 2740 ;mov bx, [DATA_SubchunkSize] 2741 ;mov cx, [DATA_SubchunkSize+2] 2742 00000CB8 8B0D[AC170000] mov ecx, [DATA_SubchunkSize] 2743 move_file_pointer: 2744 ;mov dx, bx 2745 ;mov [LoadedDataBytes], dx 2746 ;mov [LoadedDataBytes+2], cx 2747 00000CBE 890D[20180000] mov [LoadedDataBytes], ecx 2748 ;add dx, 44 ; + header 2749 ;adc cx, 0 2750 00000CC4 83C12C add ecx, 44 2751 2752 ; seek 2753 ;mov bx, [filehandle] 2754 ;mov ax, 4200h 2755 ;int 21h 2756 ; 01/12/2024 2757 00000CC7 31D2 xor edx, edx ; offset from beginning of the file 2758 ; ecx = offset 2759 ; ebx = file handle 2760 ; edx = 0 2761 sys _seek, [filehandle] 89 <1> 90 <1> 91 <1> 92 <1> 93 <1> %if %0 >= 2 94 00000CC9 8B1D[B0170000] <1> mov ebx, %2 95 <1> %if %0 >= 3 96 <1> mov ecx, %3 97 <1> %if %0 = 4 98 <1> mov edx, %4 99 <1> %endif 100 <1> %endif 101 <1> %endif 102 00000CCF B813000000 <1> mov eax, %1 103 <1> 104 00000CD4 CD40 <1> int 40h 2762 00000CD6 C3 retn 2763 2764 ; -------------------------------------------------------- 2765 2766 ; 30/12/2024 (video mode 13h) 2767 ; (320*200, 256 colors) 2768 ; 25/12/2024 2769 ; 22/12/2024 (VESA VBE mode graphics) 2770 ; (640*480, 256 colors) 2771 clear_window: 2772 ;mov edi, [LFB_ADDR] 2773 ; 30/12/2024 2774 ;mov edi, 0A0000h 2775 ;;add edi, (13*80*8*14) 2776 ; 25/12/2024 2777 ;;add edi, 164*640 2778 ;add edi, 12*8*320 2779 ; 30/12/2024 2780 ;mov edi, [graphstart] ; 12*8*320 2781 00000CD7 BF80700A00 mov edi, 0A0000h+(11*8*320)+(2*320) ; * 2782 ; AC97 info start 2783 00000CDC 29C0 sub eax, eax 2784 ;;mov ecx, (16*640*14)/4 ; 16 rows 2785 ;mov ecx, 64*640 ; 256 volume level points 2786 ; 30/12/2024 2787 ;mov ecx, (8*8*320)/4 ; 8 rows 2788 00000CDE B900190000 mov ecx, (10*8*320)/4 ; * 2789 00000CE3 F3AB rep stosd 2790 ; 24/12/2024 2791 00000CE5 A3[78120000] mov [prev_points], eax ; 0 2792 ; 2793 00000CEA C3 retn 2794 2795 ; ------------------------------------------------------------- 2796 ; DATA (INFO) 2797 ; ------------------------------------------------------------- 2798 2799 Credits: 2800 00000CEB 564741205741562050- db 'VGA WAV Player for TRDOS 386 by Erdogan Tan. ' 2800 00000CF4 6C6179657220666F72- 2800 00000CFD 205452444F53203338- 2800 00000D06 36206279204572646F- 2800 00000D0F 67616E2054616E2E20 2801 ;db 'January 2025.',10,13,0 2802 00000D18 466562727561727920- db 'February 2025.', 10,13,0 2802 00000D21 323032352E0A0D00 2803 ;db '08/01/2025', 10,13 2804 00000D29 30352F30322F323032- db '05/02/2025', 10,13,0 2804 00000D32 350A0D00 2805 2806 msgAudioCardInfo: 2807 00000D36 666F7220536F756E64- db 'for Sound Blaster 16 audio device.', 10,13,0 2807 00000D3F 20426C617374657220- 2807 00000D48 313620617564696F20- 2807 00000D51 6465766963652E0A0D- 2807 00000D5A 00 2808 2809 ; 02/01/2025 2810 msg_usage: 2811 00000D5B 75736167653A204347- db 'usage: CGAPLAY2 <...>',10,13,0 2811 00000D64 41504C415932203C46- 2811 00000D6D 696C654E616D65313E- 2811 00000D76 203C46696C654E616D- 2811 00000D7F 65323E203C2E2E2E3E- 2811 00000D88 0A0D00 2812 2813 ; 24/11/2024 2814 noDevMsg: 2815 00000D8B 4572726F723A20556E- db 'Error: Unable to find Sound Blaster 16 audio device!' 2815 00000D94 61626C6520746F2066- 2815 00000D9D 696E6420536F756E64- 2815 00000DA6 20426C617374657220- 2815 00000DAF 313620617564696F20- 2815 00000DB8 64657669636521 2816 00000DBF 0A0D00 db 10,13,0 2817 2818 noFileErrMsg: 2819 00000DC2 4572726F723A206669- db 'Error: file not found.',10,13,0 2819 00000DCB 6C65206E6F7420666F- 2819 00000DD4 756E642E0A0D00 2820 2821 ; 07/12/2024 2822 trdos386_err_msg: 2823 00000DDB 5452444F5320333836- db 'TRDOS 386 System call error !',10,13,0 2823 00000DE4 2053797374656D2063- 2823 00000DED 616C6C206572726F72- 2823 00000DF6 20210A0D00 2824 2825 ; 24/11/2024 2826 msg_init_err: 2827 00000DFB 0D0A db 0Dh, 0Ah 2828 00000DFD 536F756E6420426C61- db "Sound Blaster 16 hardware initialization error !" 2828 00000E06 737465722031362068- 2828 00000E0F 617264776172652069- 2828 00000E18 6E697469616C697A61- 2828 00000E21 74696F6E206572726F- 2828 00000E2A 722021 2829 00000E2D 0D0A00 db 0Dh, 0Ah, 0 2830 2831 ; 19/11/2024 2832 ; 03/06/2017 2833 hex_chars: 2834 00000E30 303132333435363738- db '0123456789ABCDEF', 0 2834 00000E39 3941424344454600 2835 ; 24/11/2024 2836 msgSB16Info: 2837 00000E41 0D0A db 0Dh, 0Ah 2838 00000E43 20417564696F204861- db " Audio Hardware: Sound Blaster 16", 0Dh, 0Ah 2838 00000E4C 7264776172653A2053- 2838 00000E55 6F756E6420426C6173- 2838 00000E5E 7465722031360D0A 2839 00000E66 202020202020426173- db " Base Port: " 2839 00000E6F 6520506F72743A20 2840 msgBasePort: 2841 00000E77 303030680D0A db "000h", 0Dh, 0Ah 2842 00000E7D 202020202020202020- db " IRQ: " 2842 00000E86 2020204952513A20 2843 msgIRQ: 2844 00000E8E 30 db 30h 2845 00000E8F 0D0A00 db 0Dh, 0Ah, 0 2846 2847 00000E92 90 align 4 2848 2849 ; ------------------------------------------------------------- 2850 2851 ; 30/12/2024 2852 PlayingScreen: 2853 00000E94 DBDBDBDBDBDBDBDBDB- db 14 dup(219), " DOS Player ", 14 dup(219) 2853 00000E9D DBDBDBDBDB20444F53- 2853 00000EA6 20506C6179657220DB- 2853 00000EAF DBDBDBDBDBDBDBDBDB- 2853 00000EB8 DBDBDBDB 2854 00000EBC C9CDCDCDCDCDCDCDCD- db 201, 38 dup(205), 187 2854 00000EC5 CDCDCDCDCDCDCDCDCD- 2854 00000ECE CDCDCDCDCDCDCDCDCD- 2854 00000ED7 CDCDCDCDCDCDCDCDCD- 2854 00000EE0 CDCDCDBB 2855 00000EE4 BA203C53706163653E- db 186, " Play/Pause /

Next/Prev ", 186 2855 00000EED 20506C61792F506175- 2855 00000EF6 7365203C4E3E2F3C50- 2855 00000EFF 3E204E6578742F5072- 2855 00000F08 657620BA 2856 00000F0C BA203C533E20202020- db 186, " Stop Color ", 186 2856 00000F15 2053746F7020202020- 2856 00000F1E 2020203C456E746572- 2856 00000F27 3E20436F6C6F722020- 2856 00000F30 202020BA 2857 00000F34 BA203C463E20202020- db 186, " Forwards <+>/<-> Volume ", 186 2857 00000F3D 20466F727761726473- 2857 00000F46 2020203C2B3E2F3C2D- 2857 00000F4F 3E20566F6C756D6520- 2857 00000F58 202020BA 2858 00000F5C BA203C423E20202020- db 186, " Backwards Quit Prg ", 186 2858 00000F65 204261636B77617264- 2858 00000F6E 7320203C513E202020- 2858 00000F77 202051756974205072- 2858 00000F80 672020BA 2859 00000F84 CCCDCDCDCDCDCDCDCD- db 204, 38 dup(205), 185 2859 00000F8D CDCDCDCDCDCDCDCDCD- 2859 00000F96 CDCDCDCDCDCDCDCDCD- 2859 00000F9F CDCDCDCDCDCDCDCDCD- 2859 00000FA8 CDCDCDB9 2860 00000FAC BA2046696C653A2020- db 186, " File: Bits: 0 ", 186 2860 00000FB5 202020202020202020- 2860 00000FBE 202020426974733A20- 2860 00000FC7 202020203020202020- 2860 00000FD0 202020BA 2861 00000FD4 BA20467265713A2030- db 186, " Freq: 0 Hz Channels: 0 ", 186 2861 00000FDD 2020202020487A2020- 2861 00000FE6 2020204368616E6E65- 2861 00000FEF 6C733A203020202020- 2861 00000FF8 202020BA 2862 00000FFC C8CDCDCDCDCDCDCDCD- db 200, 38 dup(205), 188 2862 00001005 CDCDCDCDCDCDCDCDCD- 2862 0000100E CDCDCDCDCDCDCDCDCD- 2862 00001017 CDCDCDCDCDCDCDCDCD- 2862 00001020 CDCDCDBC 2863 00001024 202020202020202020- db 40 dup(32) 2863 0000102D 202020202020202020- 2863 00001036 202020202020202020- 2863 0000103F 202020202020202020- 2863 00001048 20202020 2864 improper_samplerate_txt: 2865 read_error_txt: 2866 0000104C 202020202020202020- db 40 dup(32) 2866 00001055 202020202020202020- 2866 0000105E 202020202020202020- 2866 00001067 202020202020202020- 2866 00001070 20202020 2867 00001074 202020202020202020- db 40 dup(32) 2867 0000107D 202020202020202020- 2867 00001086 202020202020202020- 2867 0000108F 202020202020202020- 2867 00001098 20202020 2868 0000109C 202020202020202020- db 40 dup(32) 2868 000010A5 202020202020202020- 2868 000010AE 202020202020202020- 2868 000010B7 202020202020202020- 2868 000010C0 20202020 2869 000010C4 202020202020202020- db 40 dup(32) 2869 000010CD 202020202020202020- 2869 000010D6 202020202020202020- 2869 000010DF 202020202020202020- 2869 000010E8 20202020 2870 000010EC 202020202020202020- db 40 dup(32) 2870 000010F5 202020202020202020- 2870 000010FE 202020202020202020- 2870 00001107 202020202020202020- 2870 00001110 20202020 2871 00001114 202020202020202020- db 40 dup(32) 2871 0000111D 202020202020202020- 2871 00001126 202020202020202020- 2871 0000112F 202020202020202020- 2871 00001138 20202020 2872 0000113C 202020202020202020- db 40 dup(32) 2872 00001145 202020202020202020- 2872 0000114E 202020202020202020- 2872 00001157 202020202020202020- 2872 00001160 20202020 2873 00001164 202020202020202020- db 40 dup(32) 2873 0000116D 202020202020202020- 2873 00001176 202020202020202020- 2873 0000117F 202020202020202020- 2873 00001188 20202020 2874 0000118C 202020202020202020- db 40 dup(32) 2874 00001195 202020202020202020- 2874 0000119E 202020202020202020- 2874 000011A7 202020202020202020- 2874 000011B0 20202020 2875 000011B4 202020202020202020- db 40 dup(32) 2875 000011BD 202020202020202020- 2875 000011C6 202020202020202020- 2875 000011CF 202020202020202020- 2875 000011D8 20202020 2876 000011DC CDCDCDCDCDCDCDCDCD- db 40 dup(205) 2876 000011E5 CDCDCDCDCDCDCDCDCD- 2876 000011EE CDCDCDCDCDCDCDCDCD- 2876 000011F7 CDCDCDCDCDCDCDCDCD- 2876 00001200 CDCDCDCD 2877 00001204 202020202020202020- db 40 dup(32) 2877 0000120D 202020202020202020- 2877 00001216 202020202020202020- 2877 0000121F 202020202020202020- 2877 00001228 20202020 2878 0000122C 202020202020202020- db 13 dup(32), "00:00 ", 174, 175, " 00:00", 4 dup(32), "VOL 000%" 2878 00001235 2020202030303A3030- 2878 0000123E 20AEAF2030303A3030- 2878 00001247 20202020564F4C2030- 2878 00001250 303025 2879 ;db 40 dup(32) ; not necessary 2880 00001253 00 db 0 2881 2882 ; ------------------------------------------------------------- 2883 2884 ; 30/12/2024 2885 fillblock: 2886 00001254 FF times 8 db 0FFh 2887 0000125C 0000 dw 0 2888 2889 ; ------------------------------------------------------------- 2890 2891 ; 30/12/2024 2892 ; 23/11/2024 2893 colors: 2894 0000125E 0F0B0A0C0E090D db 0Fh, 0Bh, 0Ah, 0Ch, 0Eh, 09h, 0Dh 2895 ; white, cyan, green, red, yellow, blue, magenta 2896 00001265 0B ccolor: db 0Bh ; cyan 2897 2898 ; 06/01/2025 2899 ; 24/11/2024 2900 half_buffer: 2901 00001266 01 db 1 ; dma half buffer 1 or 2 (0 or 1) 2902 ; (initial value = 1 -> after xor in TuneLoop -> 0) 2903 EOF: 2904 2905 ; ------------------------------------------------------------- 2906 2907 bss: 2908 2909 ABSOLUTE bss 2910 2911 00001267 ?? alignb 4 2912 2913 ; 08/01/2025 2914 sd_count: 2915 ;resd 1 ; byte count of sound data (320 points) 2916 2917 ; 24/12/2024 2918 ;wpoints_dif: ; wave lighting points factor (differential) 2919 00001268 ???????? resd 1 ; required bytes for 1/18 second wave lighting 2920 2921 ; 06/01/2025 2922 ;graphstart: 2923 ; resd 1 ; start (top) line/row for wave lighting points 2924 2925 ; 30/12/2024 2926 ;LFB_ADDR: 2927 ; resd 1 2928 2929 ;nextrow: 2930 ;resd 1 2931 screenpos: ; hw = (cursor) row, lw = (cursor) column 2932 0000126C ???????? resd 1 2933 00001270 ???????? wcolor: resd 1 2934 ; 26/12/2024 2935 ;tcolor: resb 1 ; text color 2936 columns: 2937 00001274 ?? resb 1 2938 00001275 ?? pbprev: resb 1 ; previous progress bar indicator position 2939 2940 00001276 ???? alignb 4 2941 2942 bss_start: 2943 2944 ; 30/12/2024 2945 prev_points: 2946 00001278 resd 320 ; previous wave points (which are lighting) 2947 2948 ; 06/01/2025 2949 ; 20/12/2024 (playwavx.s) 2950 audio_io_base: 2951 00001778 ???????? resd 1 2952 audio_intr: 2953 0000177C ?? resb 1 2954 2955 ; 18/11/2024 2956 stopped: 2957 0000177D ?? resb 1 2958 0000177E ?? tLO: resb 1 2959 2960 ; 21/11/2024 2961 ;tLP: resb 1 2962 2963 ; 30/12/2024 2964 wpoints: 2965 0000177F ?? resb 1 2966 2967 ; 08/01/2025 2968 ;pbuf_o: resd 1 2969 ; 29/12/2024 2970 ;pbuf_s: resd 1 2971 2972 ; 25/12/2024 2973 ; 29/11/2024 2974 command: 2975 00001780 ?? resb 1 2976 filecount: 2977 00001781 ?? resb 1 2978 2979 ; 30/11/2024 2980 00001782 ???? alignb 4 2981 2982 ;;;;;;;;;;;;;; 2983 ; 14/11/2024 2984 ; (Ref: player.asm, Matan Alfasi, 2017) 2985 WAVFILEHEADERbuff: 2986 RIFF_ChunkID: 2987 00001784 ???????? resd 1 ; Must be equal to "RIFF" - big-endian 2988 ; 0x52494646 2989 RIFF_ChunkSize: 2990 00001788 ???????? resd 1 ; Represents total file size, not 2991 ; including the first 2 fields 2992 ; (Total_File_Size - 8), little-endian 2993 RIFF_Format: 2994 0000178C ???????? resd 1 ; Must be equal to "WAVE" - big-endian 2995 ; 0x57415645 2996 2997 ;; WAVE header parameters ("Sub-chunk") 2998 WAVE_SubchunkID: 2999 00001790 ???????? resd 1 ; Must be equal to "fmt " - big-endian 3000 ; 0x666d7420 3001 WAVE_SubchunkSize: 3002 00001794 ???????? resd 1 ; Represents total chunk size 3003 WAVE_AudioFormat: 3004 00001798 ???? resw 1 ; PCM (Raw) - is 1, other - is a form 3005 ; of compression, not supported. 3006 WAVE_NumChannels: 3007 0000179A ???? resw 1 ; Number of channels, Mono-1, Stereo-2 3008 WAVE_SampleRate: 3009 0000179C ???????? resd 1 ; Frequency rate, in Hz (8000, 44100 ...) 3010 WAVE_ByteRate: 3011 000017A0 ???????? resd 1 ; SampleRate * NumChannels * BytesPerSample 3012 WAVE_BlockAlign: 3013 000017A4 ???? resw 1 ; NumChannels * BytesPerSample 3014 ; Number of bytes for one sample. 3015 WAVE_BitsPerSample: 3016 000017A6 ???? resw 1 ; 8 = 8 bits, 16 = 16 bits, etc. 3017 3018 ;; DATA header parameters 3019 DATA_SubchunkID: 3020 000017A8 ???????? resd 1 ; Must be equal to "data" - big-endian 3021 ; 0x64617461 3022 DATA_SubchunkSize: 3023 000017AC ???????? resd 1 ; NumSamples * NumChannels * BytesPerSample 3024 ; Number of bytes in the data. 3025 ;;;;;;;;;;;;;; 3026 3027 ; 06/01/2025 3028 3029 filehandle: 3030 000017B0 ???????? resd 1 3031 3032 ; 25/12/2024 3033 ; 30/11/2024 3034 ;argc: resb 1 ; argument count 3035 000017B4 ???????? argv: resd 1 ; current argument (wav file) ptr 3036 000017B8 ???????? argvf: resd 1 ; 1st argument (wav file) ptr 3037 000017BC ???????? argvl: resd 1 ; last argument (wav file) ptr 3038 3039 ; 30/05/2024 3040 wav_file_name: 3041 000017C0 resb 80 ; wave file, path name (<= 80 bytes) 3042 00001810 ???? resw 1 ; 30/11/2024 3043 3044 00001812 ?? flags: resb 1 3045 3046 ; 07/12/2024 3047 00001813 ?? SRB: resb 1 3048 3049 ; 14/11/2024 3050 TotalTime: 3051 00001814 ???????? resd 1 ; Total (WAV File) Playing Time in seconds 3052 ProgressTime: 3053 00001818 ???????? resd 1 3054 0000181C ???????? count: resd 1 ; byte count of one (wav file) read 3055 LoadedDataBytes: 3056 00001820 ???????? resd 1 ; total read/load count 3057 3058 timerticks: 3059 00001824 ???????? resd 1 ; (to eliminate excessive lookup of events in tuneloop) 3060 ; (in order to get the emulator/qemu to run correctly) 3061 3062 ; 06/01/2025 3063 UpdateWavePoints: 3064 00001828 ???????? resd 1 ; wave lighting procedure pointer (8m,16m,8s,16s) 3065 3066 ; 06/01/2025 3067 ; 17/12/2024 3068 allocated: 3069 0000182C ?? resb 1 3070 interrupt: 3071 0000182D ?? resb 1 3072 3073 ; 18/12/2024 3074 ; (the audio buffer must be aligned with the memory page, 3075 ; otherwise the bss area before the buffer will be truncated) 3076 ; ((ref: TRDOS 386 v2.0.9 Kernel, trdosk8.s, 'sysaudio' function 2)) 3077 3078 ; 08/01/2025 3079 0000182E ???? alignb 4 3080 3081 ; 08/01/2025 3082 sounddata: ; (wave lighting points) graphics data 3083 00001830 resb 320*4 3084 3085 00001D30 alignb 4096 ; align to memory page boundary 3086 3087 ; 06/01/2025 (cgaplay2.s) 3088 ; 16/12/2024 (sb16play.s) 3089 audio_buffer: 3090 00002000 resb BUFFERSIZE ; 32768 3091 3092 bss_end: 3093 3094 ; 08/01/2025 3095 ; 16/12/2024 (sb16play.s) 3096 ;alignb 4096 3097 3098 ; 08/01/2025 3099 ; 06/01/2025 3100 ; 24/11/2024 3101 ;dma_buffer: ; 65536 bytes 3102 ;wav_buffer1: 3103 ; resb BUFFERSIZE ; 32768 3104 ;wav_buffer2: 3105 ; resb BUFFERSIZE ; 32768