-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcgaplay2.s
3093 lines (2695 loc) · 61.7 KB
/
cgaplay2.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
; ****************************************************************************
; cgaplay2.s - TRDOS 386 (TRDOS v2.0.9) WAV PLAYER - Video Mode 13h
; ----------------------------------------------------------------------------
; CGAPLAY2.PRG ! Sound Blaster 16 .WAV PLAYER program by Erdogan TAN
;
; 06/01/2025 - play music from multiple wav files -
;
; [ Last Modification: 08/01/2025 ]
;
; Modified from CGAPLAY.PRG .wav player program by Erdogan Tan, 01/01/2025
; SB16PLAY.PRG, 20/12/2024
;
; ****************************************************************************
; nasm cgaplay2.s -l cgaplay2.txt -o CGAPLAY2.PRG -Z error.txt
; 02/01/2025
; cgaplay2.asm - CGAPLAY2.COM - Sound Blaster 16
; 01/01/2025
; cgaplay.s - CGAPLAY.PRG - AC97 - Video Mode 13h (320*200, 256 colors)
; 26/12/2024
; vgaplay.s - VGAPLAY.PRG - AC97 - VESA Mode 101h (640*480, 256 colors)
; 20/12/2024
; sb16play.s : Video Mode 03h (Text Mode)
; 07/12/2024 - playwav9.s - interrupt (srb) + tuneloop version
; ------------------------------------------------------------
; INTERRUPT (SRB) + TUNELOOP version ; 24/11/2024 (PLAYWAV9.ASM)
; (running in DOSBOX, VIRTUALBOX, QEMU is ok)
; Signal Response Byte = message/signal to user about an event/interrupt
; as requested (TuneLoop procedure continuously checks this SRB)
; (TRDOS 386 v2 feature is used here as very simple interrupt handler output)
; ------------------------------------------------------------
; 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
; ------------------------------------------------------------
%macro sys 1-4
; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
; 03/09/2015
; 13/04/2015
; Retro UNIX 386 v1 system call.
%if %0 >= 2
mov ebx, %2
%if %0 >= 3
mov ecx, %3
%if %0 = 4
mov edx, %4
%endif
%endif
%endif
mov eax, %1
;int 30h
int 40h ; TRDOS 386 (TRDOS v2.0)
%endmacro
; Retro UNIX 386 v1 system call format:
; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
; ------------------------------------------------------------
; player internal variables and other equates.
BUFFERSIZE equ 32768 ; audio (half) buffer size
ENDOFFILE equ 1 ; flag for knowing end of file
; 06/01/2025
DMABUFFERSIZE equ BUFFERSIZE*2
; ------------------------------------------------------------
[BITS 32] ; 32-bit intructions
[ORG 0]
START_CODE:
; Prints the Credits Text.
sys _msg, Credits, 255, 0Bh
; clear bss
mov edi, bss_start
mov ecx, (bss_end - bss_start)/4
xor eax, eax
rep stosd
; -------------------------------------------------------------
; 02/01/2025
; 24/11/2024
; Detect (& Reset) Sound Blaster 16 Audio Device
call DetectSB16
;jnc short GetFileName
; 06/01/2025
jnc short get_audio_info
; 30/11/2024
; 30/05/2024
_dev_not_ready:
; couldn't find the audio device!
sys _msg, noDevMsg, 255, 0Fh
jmp Exit
; -------------------------------------------------------------
; 06/01/2025 (cgaplay2.s)
get_audio_info:
; 20/12/2024 (playwavx.s, sb16play.s)
; 07/12/2024 (playwav9.s)
; 06/06/2017
sys _audio, 0E00h ; get audio controller info
jc error_exit ; 25/11/2023
; 20/12/2024
mov [audio_io_base], edx
mov [audio_intr], al
; -------------------------------------------------------------
; 06/01/2025
; 30/12/2024
;;;
; DIRECT VGA MEMORY ACCESS
; bl = 0, bh = 5
; Direct access/map to VGA memory (0A0000h)
sys _video, 0500h
cmp eax, 0A0000h
je short set_video_mode_13h
; 30/12/2024
jmp trdos386_error
set_video_mode_13h:
;; Set Video Mode to 13h
;sys _video, 0813h
;cmp eax, 14h
;je short mode_13h_set_ok
; set VGA mode by using int 31h
mov ax, 13h ; mode 13h ;
int 31h ; real mode: int 10h
; -------------------------------------------------------------
mode_13h_set_ok:
; 30/12/2024
; 24/12/2024 (setting for wave lighting points)
;mov eax, 0A0000h
;;add eax, 12*8*320
;add eax, (13*8*320)+(2*320)
; wave graphics start (top) line/row
; 64 volume levels
;mov [graphstart], eax
;; 30/12/2024
;;mov dword [graphstart], 0A0000h+(13*8*320)+(4*320)
; 06/01/2025
; 01/01/2025
;mov dword [graphstart], 0A0000h+(11*8*320)+(4*320)
; -------------------------------------------------------------
; 25/12/2024
; 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)
; 30/12/2024
Player_ParseParameters:
jmp short Player_ParseNextParameter
; 25/12/2024
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]
; 30/12/2024
; 29/11/2024
call GetFileName
;jcxz jmp_Player_Quit
jecxz jmp_Player_Quit ; 30/11/2024
; 30/12/2024
; open existing file
; 28/11/2024
mov edx, wav_file_name
call openFile ; no error? ok.
jnc getwavparms ; 14/11/2024
; 29/11/2024
cmp byte [filecount], 0
ja short check_p_command
; 25/12/2024
; 21/12/2024
call set_text_mode
; file not found!
; 30/11/2024
sys _msg, noFileErrMsg, 255, 0Ch
jmp Exit
_exit_:
jmp terminate
; -------------------------------------------------------------
; 26/12/2024
; 25/12/2024
; 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
; 07/01/2025
cmp byte [allocated], 0
ja short StartPlay
; -------------------------------------------------------------
; 06/01/2025 (cgaplay2.s)
; 16/12/2024 (sb16play.s)
; 07/12/2024 (playwav9.s) -ac97-
; Allocate Audio Buffer (for user)
sys _audio, 0200h, BUFFERSIZE, audio_buffer
jc error_exit
; 17/12/2024
inc byte [allocated]
; 17/12/2024
; Initialize Audio Device (bh = 3)
sys _audio, 301h, 0, audio_int_handler
jc error_exit
; 17/12/2024
inc byte [interrupt]
; 08/01/2025
;; 17/12/2024
;; 16/12/2024
;; Map DMA Buffer to User (for wave graphics)
;sys _audio, 0D00h, BUFFERSIZE*2, dma_buffer
;jc error_exit
; -------------------------------------------------------------
StartPlay:
; 30/12/2024
mov byte [wpoints], 1
; 08/01/2025
%if 0
;;;
; 06/01/2025
movzx eax, word [WAVE_SampleRate]
;mov ax, [WAVE_SampleRate]
mov ecx, 10
mul ecx
mov cl, 182
div ecx
; ax = samples per 1/18.2 second
mov cl, byte [WAVE_BlockAlign]
mul ecx
mov [wpoints_dif], eax ; buffer read differential (distance)
; for wave volume leds update
; (byte stream per 1/18.2 second)
%else
; 08/01/2025
xor ecx, ecx
mov cl, byte [WAVE_BlockAlign]
%endif
; 08/01/2025
mov eax, 320
mul ecx
mov [sd_count], eax
;;;
; -------------------------------------------------------------
; 06/01/2025 (cgaplay2.s)
; 02/01/2025 (cgaplay2.asm)
;;;
; 23/11/2024 (sb16play.asm, [turn_on_leds])
cmp byte [WAVE_NumChannels], 1
ja short stolp_s
stolp_m:
cmp byte [WAVE_BitsPerSample], 8
ja short stolp_m16
stolp_m8:
mov word [UpdateWavePoints], UpdateWavePoints_8m
jmp short stolp_ok
stolp_m16:
mov word [UpdateWavePoints], UpdateWavePoints_16m
jmp short stolp_ok
stolp_s:
cmp byte [WAVE_BitsPerSample], 8
ja short stolp_s16
stolp_s8:
mov word [UpdateWavePoints], UpdateWavePoints_8s
jmp short stolp_ok
stolp_s16:
mov word [UpdateWavePoints], UpdateWavePoints_16s
jmp short stolp_ok
stolp_ok:
;;;
; -------------------------------------------------------------
; 25/12/2024
inc byte [filecount]
mov byte [command], 0
; 30/12/2024
mov byte [pbprev], -1
; 06/01/2025
; -------------------------------------------------------------
; 30/12/2024
Player_Template:
; 21/12/2024
call clearscreen
call drawplayingscreen
; 14/11/2024
call SetTotalTime
call UpdateFileInfo
; -------------------------------------------------------------
; 06/01/2025 (cgaplay2.s) -SB16-
; 02/01/2025 (cgaplay2.asm) -SB16-
; 01/01/2025 (cgaplay.asm) -AC97-
; 30/12/2024 (cgaplay.s) -AC97-
; 29/12/2024 (vgaplay3.s) -AC97-
; 20/12/2024 (sb16play.asm)
; 18/12/2024 (ac97play.s)
PlayNow:
; 01/12/2024 (32bit)
; 14/11/2024
;;mov al, 3 ; 0 = max, 31 = min
; 24/11/2024
;mov al, 5 ; 15 = max, 0 = min
; 27/11/2024
;mov [volume], al
; 14/12/2024
mov al, [volume]
;call SetPCMOutVolume@
; 02/01/2025
call SetMasterVolume@
; 15/11/2024
;call SetMasterVolume
;;call SetPCMOutVolume
;;;
; 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.
call PlayWav
; 30/12/2024
; 29/12/2024 (vgaplay3.s)
; 27/12/2024 (vgaplay.s)
_3:
; close the .wav file and exit.
; 25/12/2024
call closeFile
; 25/12/2024
;;;
; 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
; 08/01/2025
; 29/12/2024
;mov dword [pbuf_s], 0
;;;
cmp byte [command], 'Q'
je short terminate
jmp check_p_command
terminate:
call set_text_mode
; 06/01/2025
Exit@:
; 17/12/2024
cmp byte [interrupt], 0
jna short skip_cb_cancel
; Cancel callback service (for user)
sys _audio, 0900h
skip_cb_cancel:
; 17/12/2024
cmp byte [allocated], 0
jna short skip_ab_dalloc
; Deallocate Audio Buffer (for user)
sys _audio, 0A00h
skip_ab_dalloc:
; Disable Audio Device
sys _audio, 0C00h
;;;
Exit:
;mov ax, 4C00h ; bye !
;int 21h
; 01/12/2024
sys _exit, 0
halt:
jmp short halt
; -------------------------------------------------------------
; 30/05/2024
pmsg_usage:
; 21/12/2024
call set_text_mode
; 01/12/2024
sys _msg, msg_usage, 255, 0Fh
jmp short Exit
; -------------------------------------------------------------
; 30/05/2024
init_err:
; 21/12/2024
call set_text_mode
; 01/12/2024
sys _msg, msg_init_err, 255, 0Fh
jmp short Exit
; -------------------------------------------------------------
; 07/12/2024
error_exit:
; 21/12/2024
call set_text_mode
trdos386_error:
sys _msg, trdos386_err_msg, 255, 0Eh
jmp short Exit
; -------------------------------------------------------------
; 21/12/2024
print_msg:
mov ah, 0Eh
mov ebx, 7
;mov bl, 7 ; char attribute & color
p_next_chr:
lodsb
or al, al
jz short p_retn ; retn
int 31h
jmp short p_next_chr
p_retn:
retn
; -------------------------------------------------------------
; 30/12/2024
clearscreen:
; fast clear
; 320*200, 256 colors
mov edi, 0A0000h
mov ecx, (320*200*1)/4
xor eax, eax
rep stosd
retn
; -------------------------------------------------------------
; 30/12/2024 (VGA Mode 13h, 320*200 pixels, 256 colors)
; 26/12/2024
; 21/12/2024
drawplayingscreen:
mov ebp, PlayingScreen
;mov esi, 0 ; row 0, column 0
mov esi, 00020000h ; row 2, column 0 ; top margin = 2
p_d_x:
mov byte [columns], 40
mov dh, 01h ; 8x8 system font
p_d_x_n:
mov dl, [ebp]
and dl, dl
jz short p_d_x_ok
; sysvideo system call
; BH = 01h = VGA graphics (0A0000h) data transfers
; BL = 0Fh = write character/font
; DH = 01h = 8*8 system font
; CL = 0Fh = color (white)
; ESI = cursor/writing position (pixels)
; HW = row, SI = column
sys _video, 010Fh, 0Fh
inc ebp
add si, 8 ; next char pos
dec byte [columns]
jnz short p_d_x_n ; next column
xor si, si
add esi, 00080000h ; next row ; 8*8
jmp short p_d_x
p_d_x_ok:
retn
; -------------------------------------------------------------
; 21/12/2024
set_text_mode:
xor ah, ah
mov al, 3
;int 10h ; al = 03h text mode, int 10 video
int 31h ; TRDOS 386 - Video interrupt
retn
; -------------------------------------------------------------
; 02/12/2024
Player_Quit@:
pop eax ; return addr (call PlayWav@)
; 29/11/2024
Player_Quit:
jmp terminate
; -------------------------------------------------------------
; 06/01/2025 (cgaplay2.s)
; 02/01/2025 (cgaplay2.asm)
; 20/12/2024
; 15/12/2024 (sb16play.s)
; ref: playwav4.s, 18/08/2020
; 24/11/2024 (sb16play.asm)
PlayWav:
; load 32768 bytes into audio buffer
;mov edi, audio_buffer ; 16/12/2024
call loadFromFile
; 18/12/2024
;jc error_exit
;mov byte [half_buff], 1 ; (DMA) Buffer 1
mov eax, [count]
add [LoadedDataBytes], eax
test byte [flags], ENDOFFILE ; end of file ?
jnz short _pw1 ; yes
; bypass filling dma half buffer 2
; bh = 16 : update (current, first) dma half buffer
; bl = 0 : then switch to the next (second) half buffer
sys _audio, 1000h
; [audio_flag] = 1 (in TRDOS 386 kernel)
; audio_buffer must be filled again after above system call
; (Because audio interrupt will be generated by sound hardware
; at the end of the first half of dma buffer.. so,
; the second half must be ready. 'sound_play' will use it.)
;mov edi, audio_buffer ; 16/12/2024
call loadFromFile
;jc short p_return
mov eax, [count]
add [LoadedDataBytes], eax
; 06/01/2025
_pw1:
; 07/01/2025
; 20/12/2024
; 25/11/2024
call SB16Init_play ; initialize SB16 card
; set sample rate, start to play
jc init_err
; 08/01/2025
; 20/12/2024
test byte [flags], ENDOFFILE ; end of file
jnz short _pw2 ; yes
; 20/12/2024
;mov edi, audio_buffer
call loadFromFile
;jc short p_return
;xor byte [half_buffer], 1
mov eax, [count]
add [LoadedDataBytes], eax
_pw2:
mov byte [SRB], 0
; -------------------------------------------
; 07/01/2025
; 06/01/2025 (cgaplay2.s)
; 30/12/2024 (cgaplay.s)
; 29/12/2024 (vgaplay3.s)
; 18/12/2024 (ac97play.s)
; 01/12/2024 (32bit)
; 29/11/2024
; 16/12/2024 (TRDOS 386)
; 29/11/2024
; 27/11/2024
; 24/11/2024
TuneLoop:
; 30/05/2024
; 18/11/2023 (ich_wav4.asm)
; 08/11/2023
; 06/11/2023
; 20/12/2024
call UpdateProgressBar
tLWait:
; 07/12/2024 (playwav9.s)
; 18/11/2024
cmp byte [stopped], 0
; 24/11/2024
jna short tL1
;;;
; 09/12/2024 (ac97play.s)
cmp byte [stopped], 3
jnb _exitt_
;;;
call checkUpdateEvents
jc _exitt_
;;;
; 29/11/2024
cmp byte [command], 'N'
je _exitt_
cmp byte [command], 'P'
je _exitt_
;;;
cmp byte [tLO], '0'
je short tLWait
call tLZ
mov byte [tLO], '0'
jmp short tLWait
tL1:
; 16/12/2024
; 07/12/2024 (playwav9.s)
; 27/11/2024
; Check audio interrupt status
cmp byte [SRB], 0
ja short tL3
tL2:
call checkUpdateEvents
jc _exitt_
jmp short tLWait
tL3:
; 07/01/2025
xor byte [half_buffer], 1
; 07/12/2024
mov byte [SRB], 0
; 16/12/2024
;mov edi, audio_buffer
call loadFromFile
jc short _exitt_ ; end of file
; 26/11/2024
mov al, [half_buffer]
add al, '1'
; 19/11/2024
mov [tLO], al
call tL0
; 16/12/2024 (TRDOS 386)
; 24/11/2024
; 14/11/2024
mov eax, [count]
add [LoadedDataBytes], eax
; 27/11/2024
jmp short tL2
_exitt_:
; 24/11/2024
call sb16_stop
;;;
; 14/11/2024
call UpdateProgressBar
;;;
; 18/11/2024
tLZ:
; 30/05/2024
mov al, '0'
;add al, '0'
;call tL0
;
;retn
; 06/11/2023
;jmp short tL0
;retn
tL0:
; 30/12/2024 (cgaplay.s)
; 29/05/2024 (TRDOS 386)
; 08/11/2023
; 05/11/2023
; 17/02/2017 - Buffer switch test (temporary)
; 06/11/2023
; al = buffer indicator ('1', '2' or '0' -stop- )
; 30/12/2024 (video mode 13h modification)
; (320*200, 256 colors)
;;;
mov dl, al ; character
mov edi, 0A0000h
mov ebx, 8 ; 8 pixels (8*8 pixels font)
mov al, 0Ch ; red
tL0_1:
;mov ecx, 8 ; 8 pixels (8*8 pixels font)
mov ecx, 7
tL0_2:
stosb
dec ecx
jnz short tL0_2
dec ebx
jz short tL0_3
;add edi, 320-8 ; next line
add edi, 320-7
jmp short tL0_1
tL0_3:
; write system font
mov dh, 01h
;mov dl, al ; character
xor esi, esi ; = row 0, column 0
sys _video, 010Fh, 0Eh ; yellow
;;;
retn
; -------------------------------------------
; 06/01/2025 (cgaplay2.s) -TRDOS386-
; 02/01/2025 (cgaplay2.asm) -DOS-
; 18/12/2024
; 16/12/2024 (sb16play.s)
; 07/12/2024 (playwav9.s)
SetMasterVolume:
;cmp al, 31
;ja short setvolume_ok
mov [volume], al ; max = 0, min = 31
SetMasterVolume@:
; al = [volume]
mov ah, 31
sub ah, al
mov al, ah
; Set Master Volume Level (BL=0 or 80h)
; for next playing (BL>=80h)
;sys _audio, 0B80h, eax
sys _audio, 0B00h, eax
setvolume_ok:
retn
; -------------------------------------------
; 16/12/2024 (sb16play.s)
; Ref: playwav4.s (18/08/2020)
; Detect (BH=1) SB16 (BL=1) Audio Card (or Emulator)
DetectSB16:
sys _audio, 101h
retn
; --------------------------------------------
; 16/12/2024 (sb16play.s)
; 07/12/2024 (playwav9.s)
; Ref: TRDOS 386 v2.0.9, trdosk8.s (18/09/2024)
; 'sysaudio' system call (23/08/2024)
; 18/11/2024
; Ref: TRDOS 386 v2.0.9, audio.s, Erdogan Tan, 06/06/2024
sb16_stop:
; 18/11/2024
mov byte [stopped], 2
; 07/12/2024
sys _audio, 0700h
retn
sb16_pause:
; 18/11/2024
mov byte [stopped], 1 ; paused
; 07/12/2024
sys _audio, 0500h
retn
sb16_play:
sb16_continue:
; continue to play (after pause)
; 18/11/2024
mov byte [stopped], 0
; 07/12/2024
sys _audio, 0600h
retn
; ----------------------------------
; 26/12/2024
; 07/12/2024
; 01/12/2024
; 14/11/2024
; INPUT: ds:dx = file name address
; OUTPUT: [filehandle] = ; -1 = not open
openFile: