-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathac97play.s
7804 lines (6901 loc) · 161 KB
/
ac97play.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ****************************************************************************
; ac97play.s (for TRDOS 386)
; ----------------------------------------------------------------------------
; AC97PLAY.PRG ! AC'97 (ICH) .WAV PLAYER program by Erdogan TAN
;
; 30/11/2024
;
; [ Last Modification: 05/02/2025 ]
;
; Modified from AC97PLAY.COM .wav player program by Erdogan Tan, 29/11/2024
;
; Assembler: FASM 1.73
; fasm ac97play.s AC97PLAY.PRG
; ----------------------------------------------------------------------------
; In the visualization part of the code, the source code of Matan Alfasi's
; (Ami-Asaf) player.exe program was partially used.
; ----------------------------------------------------------------------------
; Previous versions of this Wav Player were based in part on .wav file player
; (for DOS) source code written by Jeff Leyla in 2002.
; ac97play.asm (DOS, 29/11/2024) -- ref: TRDOS 386, playwav7.s, 01/06/2024 --
; ------------------------------------------------------------------
; playwav7.s (TRDOS 386) - tuneloop (user mode) version (29/05/2024)
; ------------------------------------------------------------------
; playwav8.asm (DOS, 25/11/2024)
; playwav7.asm (DOS, 13/11/2024)
; playwav6.asm (DOS, 30/05/2024)
; ------------------------------
; TUNELOOP version (playing without AC97 interrupt) - 06/11/2023 - Erdogan Tan
; sample rate conversion version - 18/11/2023 - Erdogan Tan
; CODE
; 30/11/2024
; 20/08/2024 ; TRDOS 386 v2.0.9
; 29/04/2016
_ver equ 0
_exit equ 1
_fork equ 2
_read equ 3
_write equ 4
_open equ 5
_close equ 6
_wait equ 7
_creat equ 8
_link equ 9
_unlink equ 10
_exec equ 11
_chdir equ 12
_time equ 13
_mkdir equ 14
_chmod equ 15
_chown equ 16
_break equ 17
_stat equ 18
_seek equ 19
_tell equ 20
_mount equ 21
_umount equ 22
_setuid equ 23
_getuid equ 24
_stime equ 25
_quit equ 26
_intr equ 27
_fstat equ 28
_emt equ 29
_mdate equ 30
_video equ 31
_audio equ 32
_timer equ 33
_sleep equ 34
_msg equ 35
_geterr equ 36
_fpsave equ 37
_pri equ 38
_rele equ 39
_fff equ 40
_fnf equ 41
_alloc equ 42
_dalloc equ 43
_calbac equ 44
_dma equ 45
_stdio equ 46
; 30/11/2024
; 12/09/2024 ('sys' macro in FASM format)
macro sys op1,op2,op3,op4
{
if op4 eq
else
mov edx, op4
end if
if op3 eq
else
mov ecx, op3
end if
if op2 eq
else
mov ebx, op2
end if
mov eax, op1
int 40h
}
; player internal variables and other equates.
; 17/11/2024 (16bit DOS, segment-offset 64KB-16bit limit)
;BUFFERSIZE equ 65520
; 30/11/2024 (TRDOS 386, 32bit DOS, there is not a 64KB limit)
BUFFERSIZE equ 65536
ENDOFFILE equ 1 ; flag for knowing end of file
; 30/11/2024
use32
org 0
include 'ac97.inc' ; 17/02/2017
_STARTUP:
; 30/11/2024
; 30/05/2024
; Prints the Credits Text.
sys _msg, Credits, 255, 0Bh
; 30/11/2024
; clear bss
mov ecx, bss_end
mov edi, bss_start
sub ecx, edi
shr ecx, 1
xor eax, eax
rep stosw
; Detect (& Enable) AC'97 Audio Device
call DetectAC97
;jnc short GetFileName
; 30/11/2024
jnc short Player_InitalizePSP
; 30/11/2024
; 30/05/2024
_dev_not_ready:
; couldn't find the audio device!
sys _msg, noDevMsg, 255, 0Fh
jmp Exit
; 28/11/2024
Player_InitalizePSP:
; 30/11/2024
; (TRDOS 386 -Retro UNIX 386- argument transfer method)
; (stack: argc,argv0addr,argv1addr,argv2addr ..
; .. argv0text, argv1text ..)
; ---- argc, argv[] ----
mov esi, esp
lodsd
cmp eax, 2 ; two arguments
; (program file name & mod file name)
jb pmsg_usage ; nothing to do
;mov [argc], al
shl eax, 2 ; *4
add eax, esp
; eax = last argument's address pointer
mov [argvl], eax ; last wav file (argument)
mov [argv], esi ; current argument (PRG file name)
lodsd ; skip program (PRG) file name
mov [argvf], esi ; 1st wav file (argument)
Player_ParseParameters:
; 30/11/2024
; 29/11/2024
; 18/12/2024
;mov edx, wav_file_name
cmp byte [IsInSplash], 0
jna short check_p_command
call write_audio_dev_info
;;;
; 18/12/2024
vbuffer_map:
; 01/12/2024
; Map video buffer (0B8000h) to user memory (same addr)
sys _video, 0400h
cmp eax, 0B8000h
jne short jmp_Player_Quit ; terminate without error msg
;;;
mov edx, SplashFileName
jmp short _1
check_p_command:
; 07/12/2024
mov esi, [argv]
;
cmp byte [command], 'P'
je short Player_ParsePreviousParameter
; 07/12/2024
; 30/11/2024
;mov esi, [argv] ; current argument (wav file) ptr
add esi, 4
cmp esi, [argvl] ; last argument (wav file) ptr
jna short Player_ParseNextParameter
jmp_Player_Quit:
jmp Player_Quit
Player_ParsePreviousParameter:
; 29/11/2024
;mov byte [command], 0
; 30/11/2024
;mov esi, [argv] ; 07/12/2024
cmp esi, [argvf] ; first argument (wav file) ptr
jna short Player_ParseNextParameter
sub esi, 4
Player_ParseNextParameter:
; 30/11/2024
mov [argv], esi ; set as current argument
; 01/12/2024
mov esi, [esi]
; 07/12/2024
;mov ecx, esi
;mov esi, [ecx]
; 29/11/2024
call GetFileName
;jcxz jmp_Player_Quit
jecxz jmp_Player_Quit ; 30/11/2024
; 30/11/2024
; 28/11/2024
mov edx, wav_file_name
;;;
_1:
; open the file
; open existing file
; 28/11/2024
;mov edx, wav_file_name
call openFile ; no error? ok.
jnc getwavparms ; 14/11/2024
; 28/11/2024
cmp byte [IsInSplash], 0
ja Player_SplashScreen
; 29/11/2024
cmp byte [filecount], 0
ja short check_p_command
call ClearScreen
; 30/11/2024
sys _msg, Credits, 255, 0Bh
call write_audio_dev_info
wav_file_open_error:
; file not found!
; 30/11/2024
sys _msg, noFileErrMsg, 255, 0Ch
_exit_:
jmp Exit
; 30/11/2024 (32bit)
; 29/11/2024
; 30/05/2024
GetFileName:
mov edi, wav_file_name
; 30/11/2024
;mov esi, [argv]
xor ecx, ecx ; 0
ScanName:
lodsb
;test al, al
;jz short a_4
; 29/11/2024
cmp al, 0Dh
jna short a_4
cmp al, 20h
je short ScanName ; scan start of name.
stosb
mov ah, 0FFh
;;;
; 14/11/2024
; (max. path length = 64 bytes for MSDOS ?) (*)
;xor ecx, ecx ; 0
;;;
a_0:
inc ah
a_1:
;;;
; 14/11/2024
inc ecx
;;;
lodsb
stosb
cmp al, '.'
je short a_0
; 29/11/2024
cmp al, 20h
;and al, al
;jnz short a_1
;;;
; 14/11/2024
jna short a_3
and ah, ah
jz short a_2
cmp al, '/' ; 14/12/2024
jne short a_2
mov ah, 0
a_2:
cmp cl, 75 ; 64+8+'.'+3 -> offset 75 is the last chr
jb short a_1
; 29/11/2024
sub ecx, ecx
jmp short a_4
a_3:
; 29/11/2024
dec edi
;;;
or ah, ah ; if period NOT found,
jnz short a_4 ; then add a .WAV extension.
SetExt:
; 29/11/2024
;dec edi
mov dword [edi], '.WAV'
; ! 64+12 is DOS limit
; but writing +4 must not
; destroy the following data
;mov byte [edi+4], 0 ; so, 80 bytes path + 0 is possible here
; 29/11/2024
add ecx, 4
add edi, 4
a_4:
mov byte [edi], 0
; 30/11/2024
retn
getwavparms:
; 14/11/2024
call getWAVParameters
jc short _exit_ ; nothing to do
; 17/11/2024
mov bl, 4
sub bl, byte [WAVE_BlockAlign]
; = 0 for 16 bit stereo
; = 2 for 8 bit stereo or 16 bit mono
; = 3 for 8 bit mono
shr bl, 1 ; 0 --> 0, 2 --> 1, 3 --> 1
; 15/11/2024
adc bl, 0 ; 3 --> 1 --> 2
mov byte [fbs_shift], bl ; = 2 mono and 8 bit
; = 0 stereo and 16 bit
; = 1 mono or 8 bit
; 30/05/2024
call codecConfig ; unmute codec, set rates.
jc init_err
; 28/11/2024
cmp byte [IsInSplash], 0
jna Player_Template
; 30/11/2024 (TRDOS 386 version, Int 31h)
; 28/11/2024
Player_SplashScreen:
; 15/11/2024
;; Set video mode to 03h (not necessary)
mov eax, 03h
;int 10h
int 31h
; 15/11/2024
;; Get the cursor type
mov ah, 03h
;int 10h
int 31h
mov [cursortype], cx ; save
; 15/11/2024
;; Set the cursor to invisible
mov ah, 01h
mov ecx, 2607h
;int 10h
int 31h
; 15/11/2024
;xor edx, edx
;call setCursorPosition
;; Print the splash screen in white
mov eax, 1300h
mov ebx, 000Fh
mov ecx, 1999
mov edx, 0
mov ebp, SplashScreen
;int 10h
int 31h
;;;
; 01/12/2024
; 30/11/2024 (32bit)
;;;
; 22/11/2024
; set wave volume led addresses
;mov ebx, 13*80*2
; 01/12/2024
mov ebx, 0B8000h + 13*80*2
mov ebp, 80
mov edi, wleds_addr
wleds_sa_1:
mov ecx, 7
wleds_sa_2:
mov eax, 80*2
mul ecx
add eax, ebx
;stosw
stosd ; 01/12/2024
loop wleds_sa_2
mov eax, ebx
;stosw
stosd ; 01/12/2024
inc ebx
inc ebx
dec ebp
jnz short wleds_sa_1
;;;
; 28/11/2024
cmp dword [filehandle], -1
jne StartPlay
; 30/11/2024
;;; wait for 3 seconds
sys _time, 0 ; get time in unix epoch format
mov ecx, eax
add ecx, 2 ; wait for 2 seconds ; 18/12/2024
_wait_3s:
nop
sys _time, 0
cmp eax, ecx
jb short _wait_3s
;;;
; 28/11/2024
mov byte [IsInSplash], 0
;mov edx, wav_file_name
; 30/11/2024
mov esi, [argvf]
; 29/11/2024
jmp Player_ParseNextParameter
; 30/11/2024 (32bit)
; 28/11/2024
Player_Template:
;;;
; 09/12/2024
xor edx, edx
; 29/11/2024
inc byte [filecount]
;mov byte [command], 0
; 09/12/2024
;mov dword [pbuf_s], 0
mov byte [command], dl ; 0
mov dword [pbuf_s], edx ; 0
;;;
;xor edx, edx
call setCursorPosition
;; Print the splash screen in white
mov eax, 1300h
mov ebx, 000Fh
mov ecx, 1999
; 09/12/2024
; edx = 0
;mov edx, 0
mov ebp, Template
;int 10h
; 30/11/2024
int 31h
;;;
; 14/11/2024
call SetTotalTime
call UpdateFileInfo
; 30/11/2024
; 28/11/2024
StartPlay:
; 25/11/2023
; ------------------------------------------
; 18/11/2023 (ich_wav4.asm)
; 13/11/2023 (ich_wav3.asm)
cmp byte [VRA], 1
jb short chk_sample_rate
playwav_48_khz:
mov dword [loadfromwavfile], loadFromFile
;mov dword [loadsize], 0 ; 65536
;;;
; 17/11/2024
;mov word [buffersize], 32768
;mov ax, BUFFERSIZE/2 ; 32760
; 30/11/2024
mov eax, BUFFERSIZE/2 ; 32768
mov [buffersize], eax ; 16 bit samples
shl eax, 1 ; bytes
mov cl, [fbs_shift]
shr eax, cl
;mov [loadsize], ax ; 16380 or 32760 or 65520
mov [loadsize], eax ; 16384 or 32768 or 65536
;;;
jmp PlayNow ; 30/05/2024
; 02/02/2025
chk_sample_rate:
; set conversion parameters
; (for 8, 11.025, 16, 22.050, 24, 32 kHZ)
mov ax, [WAVE_SampleRate]
cmp ax, 48000
je short playwav_48_khz
chk_22khz:
cmp ax, 22050
jne short chk_11khz
cmp byte [WAVE_BitsPerSample], 8
jna short chk_22khz_1
mov ebx, load_22khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_22khz_2
mov ebx, load_22khz_mono_16_bit
jmp short chk_22khz_2
chk_22khz_1:
mov ebx, load_22khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_22khz_2
mov ebx, load_22khz_mono_8_bit
chk_22khz_2:
mov eax, 7514 ; (442*17)
mov edx, 37
mov ecx, 17
jmp set_sizes
chk_11khz:
cmp ax, 11025
jne short chk_44khz
cmp byte [WAVE_BitsPerSample], 8
jna short chk_11khz_1
mov ebx, load_11khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_11khz_2
mov ebx, load_11khz_mono_16_bit
jmp short chk_11khz_2
chk_11khz_1:
mov ebx, load_11khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_11khz_2
mov ebx, load_11khz_mono_8_bit
chk_11khz_2:
mov eax, 3757 ; (221*17)
mov edx, 74
mov ecx, 17
jmp set_sizes
chk_44khz:
cmp ax, 44100
jne short chk_16khz
cmp byte [WAVE_BitsPerSample], 8
jna short chk_44khz_1
mov ebx, load_44khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_44khz_2
mov ebx, load_44khz_mono_16_bit
jmp short chk_44khz_2
chk_44khz_1:
mov ebx, load_44khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_44khz_2
mov ebx, load_44khz_mono_8_bit
chk_44khz_2:
mov eax, 15065 ; (655*23)
mov edx, 25
mov ecx, 23
jmp set_sizes
chk_16khz:
cmp ax, 16000
jne short chk_8khz
cmp byte [WAVE_BitsPerSample], 8
jna short chk_16khz_1
mov ebx, load_16khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_16khz_2
mov ebx, load_16khz_mono_16_bit
jmp short chk_16khz_2
chk_16khz_1:
mov ebx, load_16khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_16khz_2
mov ebx, load_16khz_mono_8_bit
chk_16khz_2:
mov eax, 5461
mov edx, 3
mov ecx, 1
jmp set_sizes
chk_8khz:
cmp ax, 8000
jne short chk_24khz
cmp byte [WAVE_BitsPerSample], 8
jna short chk_8khz_1
mov ebx, load_8khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_8khz_2
mov ebx, load_8khz_mono_16_bit
jmp short chk_8khz_2
chk_8khz_1:
mov ebx, load_8khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_8khz_2
mov ebx, load_8khz_mono_8_bit
chk_8khz_2:
mov eax, 2730
mov edx, 6
mov ecx, 1
jmp set_sizes
chk_24khz:
cmp ax, 24000
jne short chk_32khz
cmp byte [WAVE_BitsPerSample], 8
jna short chk_24khz_1
mov ebx, load_24khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_24khz_2
mov ebx, load_24khz_mono_16_bit
jmp short chk_24khz_2
chk_24khz_1:
mov ebx, load_24khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_24khz_2
mov ebx, load_24khz_mono_8_bit
chk_24khz_2:
mov eax, 8192
mov edx, 2
mov ecx, 1
jmp short set_sizes
chk_32khz:
cmp ax, 32000
;jne short vra_needed
; 02/02/2025
jne short chk_12khz
cmp byte [WAVE_BitsPerSample], 8
jna short chk_32khz_1
mov ebx, load_32khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_32khz_2
mov ebx, load_32khz_mono_16_bit
jmp short chk_32khz_2
chk_32khz_1:
mov ebx, load_32khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_32khz_2
mov ebx, load_32khz_mono_8_bit
chk_32khz_2:
mov eax, 10922
mov edx, 3
mov ecx, 2
;jmp short set_sizes
set_sizes:
cmp byte [WAVE_NumChannels], 1
je short ss_1
shl eax, 1
ss_1:
cmp byte [WAVE_BitsPerSample], 8
jna short ss_2
; 16 bit samples
shl eax, 1
ss_2:
mov [loadsize], eax
mul edx
;cmp ecx, 1
;je short ss_3
div ecx
;ss_3:
mov cl, [fbs_shift]
shl eax, cl
; 02/02/2025
; eax = 16 bit stereo byte count (target buffer size)
shr eax, 1 ; buffer size is 16 bit sample count
mov [buffersize], eax
mov [loadfromwavfile], ebx
jmp short PlayNow
;;;;
; 02/02/2025
chk_12khz:
cmp ax, 12000
jne short vra_needed
cmp byte [WAVE_BitsPerSample], 8
jna short chk_12khz_1
mov ebx, load_12khz_stereo_16_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_12khz_2
mov ebx, load_12khz_mono_16_bit
jmp short chk_12khz_2
chk_12khz_1:
mov ebx, load_12khz_stereo_8_bit
cmp byte [WAVE_NumChannels], 1
jne short chk_12khz_2
mov ebx, load_12khz_mono_8_bit
chk_12khz_2:
mov eax, 4096
mov edx, 4
mov ecx, 1
jmp set_sizes
;;;;
vra_needed:
; 30/11/2024 (TRDOS 386, ax -> eax)
; 13/11/2023
pop eax ; discard return address to the caller
; 30/05/2024
vra_err:
; 30/11/2024
sys _msg, msg_no_vra, 255, 0Fh
jmp Exit
; 01/12/2024 (32bit)
PlayNow:
;;;
; 14/11/2024
;mov al, 3 ; 0 = max, 31 = min
; 14/12/2024
mov al, [volume]
call SetPCMOutVolume@
; 15/11/2024
;;call SetMasterVolume
;call SetPCMOutVolume
;;;
; 18/12/2024
cmp dword [_bdl_buffer], 0
ja short PlayNow@
;
;; 29/11/2024
;cmp byte [IsInSplash], 0
;;ja short PlayNow@
;; 02/12/2024
;jna short PlayNow@
;;;
;PlayNow@:
; 28/11/2024
;cmp byte [IsInSplash], 0
;ja short _3
;
;call UpdateVolume
;
; 02/12/2024
call PlayWav@
jmp short _3
; 02/12/2024
PlayNow@:
; reset file loading and EOF parameters
; 18/12/2024
mov dword [count], 0
mov dword [LoadedDataBytes], 0
mov byte [flags], 0
mov byte [stopped], 0
;jmp short PlayNow@@
;;;
PlayNow@@:
;;;
;
; 14/11/2024
call UpdateProgressBar
;;;
; 30/05/2024
; playwav4.asm
_2:
call check4keyboardstop ; flush keyboard buffer
jc short _2 ; 07/11/2023
; play the .wav file. Most of the good stuff is in here.
; 05/12/2024
; 02/12/2024
;mov eax, [_bdl_buffer] ; BDL_BUFFER physical address
;_3:
call PlayWav
_3: ; 02/12/2024
; 29/11/2024
; 28/11/2024
call closeFile
;mov edx, wav_file_name
cmp byte [IsInSplash], 0
;jna short Exit
jna short _4 ; 29/11/2024
mov byte [IsInSplash], 0
;jmp _1
; 01/12/2024
mov esi, [argvf]
; 29/11/2024
jmp Player_ParseNextParameter
; 29/11/2024
_4:
cmp byte [command], 'Q'
je short Exit
jmp check_p_command
; close the .wav file and exit.
Exit:
; 15/11/2024
;; Restore Cursor Type
mov cx, [cursortype]
cmp cx, 0
jz short Exit@
mov ah, 01h
;int 10h
; 01/12/2024
int 31h
Exit@:
; 29/11/2024
;call closeFile
Exit@@:
;mov ax, 4C00h ; bye !
;int 21h
; 01/12/2024
sys _exit, 0
here:
jmp short here ; do not come here !
; 30/05/2024
pmsg_usage:
;sys_msg msg_usage, 0Fh ; 14/11/2024
; 01/12/2024
sys _msg, msg_usage, 255, 0Fh
jmp short Exit
; 30/05/2024
init_err:
;sys_msg msg_init_err, 0Fh
; 01/12/2024
sys _msg, msg_init_err, 255, 0Fh
jmp short Exit
; 02/12/2024
Player_Quit@:
pop eax ; return addr (call PlayWav@)
; 29/11/2024
Player_Quit:
call ClearScreen
jmp short Exit@@
ClearScreen:
mov ax, 03h
;int 10h
; 01/12/2024
int 31h
retn
; --------------------------------------------
; 02/12/2024
PlayWav@:
; 29/05/2024
; Allocate memory block (33 pages)
sys _alloc, BDL_BUFFER, 33*4096, 0 ; no upper limit
;jc short Player_Quit ; 01/12/2024
jc short Player_Quit@ ; 02/12/2024
mov [_bdl_buffer], eax ; BDL_BUFFER physical address
; 02/12/2024
jmp short PlayWav@@
; 01/12/2024
; 29/05/2024 (TRDOS 386, playwav7.s)
; ((Modified from playwav4.asm, ich_wav4.asm))
; ------------------
;playwav_vra:
PlayWav:
; create Buffer Descriptor List
; Generic Form of Buffer Descriptor
; ---------------------------------
; 63 62 61-48 47-32 31-0
; --- --- -------- ------- -----
; IOC BUP -reserved- Buffer Buffer
; Length Pointer
; [15:0] [31:0]
;mov esi, eax
mov eax, [_bdl_buffer] ; BDL_BUFFER physical address
PlayWav@@: ; 02/12/2024
add eax, 4096 ; WAVBUFFER_1 physical address
mov ebx, eax
;mov [wav_buffer1], eax
;add eax, 65536 ; WAVBUFFER_2 physical address
;mov [wav_buffer2], eax
mov edi, BDL_BUFFER
mov ecx, 16
_0:
;mov eax, WAVBUFFER_1
mov eax, ebx ; WAVBUFFER_1 physical address
stosd
mov eax, [buffersize]
; 02/12/2024
;shr eax, 1 ; buffer size in word
or eax, BUP ; tuneloop (without interrupt)
stosd
;mov eax, WAVBUFFER_2
mov eax, ebx
add eax, 65536 ; WAVBUFFER_2 physical address
stosd
mov eax, [buffersize]
; 02/12/2024
;shr eax, 1 ; buffer size in word
or eax, BUP ; tuneloop (without interrupt)
stosd
loop _0
; 14/11/2024
;mov dword [count], ecx ; 0
;mov dword [LoadedDataBytes], 0
; 19/11/2024
RePlayWav:
; 01/12/2024
; load 64k into buffer 1
mov edi, WAVBUFFER_1
; 02/02/2025
mov [audio_buffer], edi
call dword [loadfromwavfile]
; 01/12/2024
; 14/11/2024
mov eax, [count]
add [LoadedDataBytes], eax
; 18/12/2024
mov dword [count], 0
; and 64k into buffer 2
mov edi, WAVBUFFER_2
; 02/02/2025
mov [audio_buffer], edi
call dword [loadfromwavfile]
; 01/12/2024
; 14/11/2024
mov eax, [count]
add [LoadedDataBytes], eax
; write NABMBAR+10h with offset of buffer descriptor list
;;mov eax, BDL_BUFFER
;mov eax, esi ; BDL_BUFFER physical address
;mov eax, [_bdl_buffer] ; BDL_BUFFER physical address
; 02/12/2024
mov ebx, [_bdl_buffer]
mov dx, [NABMBAR]
add dx, PO_BDBAR_REG ; set pointer to BDL
;out dx, eax ; write to AC97 controller
; 29/05/2024
;mov ebx, eax ; data, dword
; 02/12/2024
; ebx = [_bdl_buffer] ; data, dword
mov ah, 5 ; write port dword
int 34h
; 31/05/2024
; 19/05/2024
;call delay1_4ms
mov al, 31
call setLastValidIndex
; 31/05/2024
; 19/05/2024
;call delay1_4ms