-
Notifications
You must be signed in to change notification settings - Fork 8
/
SHELL.ASM
10882 lines (9598 loc) · 240 KB
/
SHELL.ASM
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
P386 ; Enable 32 bit registers.
DEBUGGING equ 0
ACTIVISION equ 0 ; True if building Bill Volk's version.
DMA_FF_REG equ 0CH
VERSION_NUMBER equ 340
;;
;; The MIT license:
;;
;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the "Software"), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the Software is furnished
;; to do so, subject to the following conditions:
;;
;; The above copyright notice and this permission notice shall be included in all
;; copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;;
;; 3.0 -> stereo rev.
;; 3.1 -> version number rev, semaphore reporting.
;; 3.11 -> fixed bug halting looped sample, when looped sample wasn't playing.
;; 3.12 -> got rid of the int 3 instructions accidently left in sblaster.
;; 3.2 -> auto-init dma mode functions.
;; 3.3 -> auto-init dma on SBLASTER cards, as well as SBP16 support.
;; 3.4 -> support for 386 flat-model register passing convention.
LOCALS ;; Enable local labels
IDEAL ;; Use Turbo Assembler's IDEAL mode
JUMPS
INCLUDE "PROLOGUE.MAC" ;; common prologue
INCLUDE "SOUNDRV.INC"
;; Set's the DIGPAK semaphore
Macro SetSemaphore
mov [cs:INDIGPAK],1
endm
;; This macro checks the DPMI compliant FLAG
;; If DPMI is on, then the address of the SoundStructure passed is
;; in ESI instead of DS:SI. First make certain it is in the low 1mb
;; of address space. If not, clearsemaphoreiret. Otherwise set DS:SI
;; equal to that address.
Macro ConvertDPMI seg,indx
LOCAL @@HOP
cmp [cs:DPMI],0 ; In 32 bit DPMI mode?
je @@HOP
push eax ; Save EAX
mov eax,indx ; Get the entire 32 bit flat-model address.
shr eax,4 ; leave just the segment portion.
mov seg,ax ; place the segment into DS
and indx,0Fh ; leave just the offset portion.
pop eax
@@HOP:
endm
;; Clear's the semaphore, and does an IRET
Macro ClearSemaphoreIRET
mov [cs:INDIGPAK],0
iret
endm
Macro ClearSemaphore
mov [cs:INDIGPAK],0
endm
IFNDEF NOSOUND
NOSOUND equ 0
ENDIF
IFNDEF FOREGROUND
FOREGROUND equ 0
ENDIF
IFNDEF LIFESIZE
LIFESIZE equ 0
ENDIF
IFNDEF SBPRO
SBPRO equ 0
ENDIF
IFNDEF PAS16
PAS16 equ 0
ENDIF
IFNDEF SENSATION
SENSATION equ 0
ENDIF
IFNDEF STFX
STFX equ 0
ENDIF
IFNDEF SBCLONE
SBCLONE equ 0
ENDIF
;; Make correct equate versus build equate.
IF BUILD EQ 1
DIG_ADLIB equ 1
ENDIF
IF BUILD EQ 2
DIG_CVXSND equ 1
IF NOSOUND
BACKFLLL equ 0
ELSE
BACKFILL equ 1
ENDIF
ENDIF
IF BUILD EQ 3
DIG_VMSND equ 1
BACKFILL equ 1
ENDIF
IF BUILD EQ 4
DIG_SMSND equ 1
BACKFILL equ 1
ENDIF
IF BUILD EQ 5
DIG_IBMSND equ 1
ENDIF
IF BUILD EQ 6
DIG_DIGISP equ 1
ENDIF
IF BUILD EQ 7
DIG_TANEXTX equ 1
ENDIF
IF BUILD EQ 8
DIG_TANSLTL equ 1
ENDIF
IF BUILD EQ 9
DIG_SBLASTER equ 1
BACKFILL equ 1
ENDIF
IF BUILD EQ 10
DIG_SOURCE equ 1
ENDIF
IF BUILD EQ 11
DIG_ECHOII equ 1
ENDIF
IF BUILD EQ 12
DIG_LANTSND equ 1
ENDIF
IF BUILD EQ 13
DIG_IBMBAK equ 1
ENDIF
IF BUILD EQ 14
DIG_IBM1BIT equ 1
ENDIF
IF BUILD EQ 15
DIG_PAUDIO equ 1
BACKFILL equ 1
ENDIF
IF BUILD EQ 16
DIG_BIGMOUTH equ 1
BACKFILL equ 1
ENDIF
IF BUILD EQ 17
DIG_MASTER equ 1
ENDIF
IF BUILD EQ 18
DIG_ADLIBG equ 1
BACKFILL equ 1
ENDIF
IF BUILD EQ 19
DIG_T2500 equ 1
ENDIF
IF BUILD EQ 20
DIG_ARIA EQU 1
BACKFILL equ 0
IFNDEF ARIA_STEREO
ARIA_STEREO equ 1
ENDIF
ENDIF
IF BUILD EQ 21
DIG_VBEAI equ 1
DIG_PAUDIO equ 1
BACKFILL equ 1
ENDIF
IFNDEF DIG_VBEAI
DIG_VBEAI equ 0
ENDIF
IF DIG_LANTSND
;; include "vpi.mac"
; Defined encoding methods:
;
VWFM_mu_law equ 0 ; mu-law companding
VWFM_nyb62 equ 1 ; nybble 62 sample compression of #0
;
;-------------------------------------------------------------------------
;
; Voice Control Block (VCB) structure
;
VCB_RESERVED_SIZE EQU 16
Struc VCB
VCB_command DB ? ; Command code
VCB_buffer@ FARPTR <> ; Buffer address
VCB_length DW 0 ; Length of buffer
VCB_rlength DW 0 ; Actual # bytes transferred
VCB_post@ FARPTR <> ; Completion post routine address
VCB_vca_num DB 0 ; Voice adapter number
VCB_cmd_cplt DB 0 ; ff = Pending, other = Complete
VCB_word_format DW ? ; Voice word format (see above)
VCB_rpt_count DW 0 ; # of times to execute cmd - 1
VCB_reserved DB VCB_RESERVED_SIZE DUP(0)
; Reserved for future use
; (Should be set to 0)
ENDS
VCB_UNRESERVED_SIZE EQU VCB_reserved - VCB_command
VCB_SIZE EQU VCB_UNRESERVED_SIZE+VCB_RESERVED_SIZE
;
;-------------------------------------------------------------------------
;
; Adapter channel capabilities bitmask record:
;
; VSCH_unused - Reserved for future assignment
; VSCH_fdx - 1: adapter can simultaneously process Record and Play
; requests (Full-duplex).
; VSCH_record - 1: adapter can process Record requests.
; VSCH_play - 1: adapter can process Play requests.
;
;;VSCH RECORD VSCH_unused:5,VSCH_fdx:1,VSCH_record:1,VSCH_play:1
;;VSCH_mask_play EQU MASK VSCH_play ; Bit set for play capability
;;VSCH_mask_record EQU MASK VSCH_record
; Bit set for record capability
;;VSCH_mask_fdx EQU MASK VSCH_fdx ; Bit set for simultaneous
; record/play capability.
; Some adapter IDs possible in vst_adapt_id:
;
VCA_ID_LV_PC EQU 0 ; LANtastic (tm) Voice PC-BUS
VCA_ID_LV_MCA EQU 1 ; LANtastic Voice (tm) u-Channel
;
;-------------------------------------------------------------------------
;
; Adapter status buffer (Returned by STATUS VCB request):
;
Struc VCB_statbuff
vst_drvr_name DB 64 DUP (?) ; ASCIZ Voice driver name
vst_adapt_id DW 0 ; Voice adapter ID number (see above)
vst_word_format DW ? ; Hardware word format code
vst_channel_mask DB ? ; Channel capabilities (see above)
ENDS
VCB_STATBUFF_SIZE EQU 69
;
;-------------------------------------------------------------------------
;
; Valid VCB command codes:
;
VCB_no_wait EQU 80h ; Bit set for No-wait mode
VCB_CMD_STATUS EQU 00h ; Get adapter status
VCB_CMD_RESET EQU 01h ; Reset adapter/driver
VCB_CMD_DEINSTALL EQU 02h ; Deinstall adapter
VCB_CMD_CANCEL EQU 03h ; Cancel pending VCB
VCB_CMD_SEND EQU 04h ; Send to PLAY channel
VCB_CMD_SILENCE EQU 05h ; Send silence to PLAY channel
VCB_CMD_RECEIVE EQU 06h ; Receive from RECORD channel
VCB_CMD_THRESHOLD EQU 07h ; Wait for threshold
; Eligible no-wait commamds:
;
VCB_CMD_SENDNW EQU VCB_CMD_SEND+VCB_no_wait
; Send to PLAY, no waiting
VCB_CMD_SILENCENW EQU VCB_CMD_SILENCE+VCB_no_wait
; Send silence to PLAY, no waiting
VCB_CMD_RECEIVENW EQU VCB_CMD_RECEIVE+VCB_no_wait
; Receive from RECORD, no waiting
VCB_CMD_THRESHOLDNW EQU VCB_CMD_THRESHOLD+VCB_no_wait
; Wait for threshold in background
;
;-------------------------------------------------------------------------
;
; VCB Status codes:
VS_OK EQU 00h ; Command completed successfully
VS_INVALID_COMMAND EQU 01h ; Unknown VCB command
VS_NOT_PENDING EQU 02h ; Address is not a pending VCB
VS_CANCELLED EQU 03h ; Command was cancelled
VS_INVALID_VCA EQU 04h ; Invalid adapter number
VS_INVALID_WFMT EQU 05h ; Unsupported word format
VS_NO_PLAY EQU 06h ; Attempt to do output to input-
; only device
VS_NO_RECORD EQU 07h ; Attempt to read from output-only
; device
VS_CANT_DEINSTALL EQU 08h ; The driver TSR cannot be removed
; due to an interrupt hook
; conflict
VS_INVALID_LENGTH EQU 09h ; The Length field was not acceptable
; for the command and word format.
VS_PENDING EQU 0ffh ; VCB is running (not an error)
MPX_installed_status EQU 0 ; get installed status in AL
MPX_interrupt EQU 2fh ; Multiplex interrupt number
ENDIF
IF DIG_SOURCE
Macro SourceOn
push dx
push ax
MOV DX,[cs:PORTMOD+1] ;Address of LPT1 control port
add dx,2
IN AL,DX
AND AL,11110111b ;Clear bit 3
jmp $+2
OUT DX,AL ;Turn on SS
pop ax
pop dx
endm
Macro SourceOff
push dx
push ax
MOV DX,[cs:PORTMOD+1]
add dx,2
IN AL,DX
OR AL,00001000b ;Set bit 3
jmp $+2
OUT DX,AL
pop ax
pop dx
endm
ENDIF
KINT equ 66h
SEGMENT _TEXT PARA PUBLIC 'CODE'
ENDS
ASSUME CS: _TEXT, DS: _TEXT, SS: NOTHING, ES: NOTHING
SEGMENT _TEXT
IF ISCOM
org 100h
ENDIF
START:
jmp LoadSound ; Load the digitized sound driver
db "DIGPAK",0,13,10 ; Digitized Sound Package Identity String
IDENTIFIER:
;; =============[*][ 1 2 3 ]
;; =============[*][1234567890123456789012345678901234567890]
IF DIG_MASTER
db "MediaMaster or compatible",0,13,10
ENDIF
IF DIG_ADLIB
db "Adlib or compatible",0,13,10
ENDIF
IF DIG_CVXSND
IF LIFESIZE
db "Life Size Enhancer",0,13,10
ELSE
IF NOSOUND
db "No digital sound card",0,13,10
ELSE
db "Covox Speech Thing",0,13,10
ENDIF
ENDIF
ENDIF
IF DIG_VMSND
db "Covox Voice Master & Sound Master II",0,13,10
ENDIF
IF DIG_SMSND
db "Covox Sound Master I",0,13,10
ENDIF
IF DIG_IBMSND
db "IBM Internal Speaker, Foreground",0,13,10
ENDIF
IF DIG_DIGISP
db "Digispeech DS201 Speech Adaptor",0,13,10
ENDIF
IF DIG_TANEXTX
db "Tandy TX/EX/HX/SX & PCjr",0,13,10
ENDIF
IF DIG_TANSLTL
db "Tandy SL/TL & Sensation",0,13,10
ENDIF
IF DIG_SBLASTER
IF SBPRO
db "Sound Blaster Pro",0,13,10
ELSE
IF STFX
db "ATI Stereo FX",0,13,10
ELSE
IF SBCLONE
db "SoundBlaster CLONE",0,13,10
ELSE
db "SoundBlaster, Creative Labs",0,13,10
ENDIF
ENDIF
ENDIF
ENDIF
IF DIG_SOURCE
db "Sound Source, Walt Disney",0,13,10
ENDIF
IF DIG_ECHOII
db "Echo II, Street Electronics",0,13,10
ENDIF
IF DIG_LANTSND
db "Lantastic Voice Adaptor",0,13,10
ENDIF
IF DIG_IBMBAK
db "IBM Internal Speaker background",0,13,10
ENDIF
IF DIG_IBM1BIT
db "IBM Internal Speaker, 1 bit",0,13,10
ENDIF
IF DIG_PAUDIO
IF PAS16
db "ProAudio Spectrum 16",0,13,10
ELSE
IF DIG_VBEAI
db "VESA Wave Driver",0,13,10
ELSE
db "ProAudio Spectrum 8",0,13,10
ENDIF
ENDIF
ENDIF
IF DIG_BIGMOUTH
db "BigMouth, Talking Technolgoies",0,13,10
ENDIF
IF DIG_ADLIBG
IF SENSATION
db "Tandy Sensation",0,13,10
ELSE
db "Adlib Gold",0,13,10
ENDIF
ENDIF
IF DIG_T2500
db "Tandy 2500 XL",0,13,10
ENDIF
IF DIG_ARIA
db "Aria, Sierra Semiconductor",0,13,10
ENDIF
db "The Audio Solution, Copyright (c) 1993",0,13,10
db "Written by John W. Ratcliff",0,13,10
IF ISCOM
org 200h ; Beginning address of jumps.
jmp InstallInterupt ; Install the interupt vector.
jmp DeInstallInterupt ; De-install the interupt.
ENDIF
;; Unique data areas to individual hardware implementations.
IF DIG_ADLIB
AdlibIO dw 388h ; Base address of adilb.
DUMMYIRQ dw -1 ; No IRQ used.
DUMMYEXTRA dw -1 ; Nothing extra.
ENDIF
IF DIG_CVXSND
IF NOSOUND
dw -1
ELSE
BASELPT dw 408h ; Base address of LPT1
ENDIF
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_VMSND
PortAddress dw 22Fh
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_SMSND
PortAddress dw 222h
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_IBMSND
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_DIGISP
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_TANEXTX
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_TANSLTL
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_SBLASTER
_io_addx DW 220h ; Default I/O address.
_intr_num DW 7 ; Default is interupt #7
DSP_DMA dw 1 ; default DMA is ONE!
ENDIF
IF DIG_SOURCE
BASELPT dw 408h ; Base address of LPT1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_ECHOII
PORTADDRESS dw 208h ; Base address of Echo II
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_LANTSND
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_IBMBAK
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_IBM1BIT
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_PAUDIO
DUMMYBASE dw -1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_BIGMOUTH
PortAddress dw 222h
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_MASTER
card_address dw 338h
cur_int dw 7
cur_dma_channel dw 1
ENDIF
IF DIG_ADLIBG
IO_ADDR dw 388h ; Default Adlib Gold I/O address.
DUMMYIRQ dw -1 ; Read from control register.
DUMMYDMA dw -1 ; Read from contorl registers.
ENDIF
IF DIG_T2500
IO_ADDR dw 1E4h ; Base address of LPT1
DUMMYIRQ dw -1
DUMMYEXTRA dw -1
ENDIF
IF DIG_ARIA
ARIA_ADDR dw 290h
ARIA_IRQ dw 10
DUMMYEXTRA dw -1
ENDIF
;------------------------------------------------------------------
;
;Report DMAC position
;
Macro REPORTDMA DMA
LOCAL __exit
IF DIG_PAUDIO
push bx
push cx
push dx
push si
mov si,[cs:DMAPointer] ; point to the DMA controller table
xor dx,dx
mov dl,[cs:si+_dmaclear]; flipflop register
out dx,al ;clear byte FF
; clear the flip flop
mov dx,[cs:OurDMAddress]
inc dx ; adjust to count addr
mov cx,offset DMA1AddrTable
sub si,cx ; increment dx if the second
neg si ; DMA controller is used
sbb si,si ; keep the flag for later
adc dx,0 ; add one if second device
in al,dx ;DMAnCNT: Channel n Word Count
mov cl,al
in al,dx
mov ch,al ;CX = 1st value read
in al,dx ;DMAnCNT: Channel n Word Count
mov bl,al
in al,dx
mov bh,al ;BX = 2nd value read
mov ax,cx ;assume 1st value larger -- if not,
cmp ax,bx ;it must be a glitch, so we'll use
jae __exit ;the 2nd value
mov ax,bx
__exit:
mov cx,si
neg cx ; from FFFF to 1 or 0 to 0
shl ax,cl
pop si
pop dx
pop cx
pop bx
ret
ELSE ; !DIG_PAUDIO
push bx
push cx
push dx
xor dx,dx
mov dl,[BYTE cs:&DMA]
shl dx,1
add dx,1
mov al,0
out 0ch,al ;clear byte FF
in al,dx ;DMAnCNT: Channel n Word Count
mov cl,al
in al,dx
mov ch,al ;CX = 1st value read
in al,dx ;DMAnCNT: Channel n Word Count
mov bl,al
in al,dx
mov bh,al ;BX = 2nd value read
mov ax,cx ;assume 1st value larger -- if not,
cmp ax,bx ;it must be a glitch, so we'll use
jae __exit ;the 2nd value
mov ax,bx
__exit:
pop dx
pop cx
pop bx
ret
ENDIF
ENDM
JumpTable dw offset FUNCT1
dw offset FUNCT2
dw offset FUNCT3
dw offset FUNCT4
dw offset FUNCT5
dw offset FUNCT6
dw offset FUNCT7
dw offset FUNCT8
dw offset FUNCT9
dw offset FUNCTA
dw offset FUNCTB
dw offset FUNCTC
dw offset FUNCTD
dw offset FUNCTE
dw offset FUNCTF
dw offset FUNCT10
dw offset FUNCT11
dw offset FUNCT12
dw offset FUNCT13
dw offset FUNCT14
dw offset FUNCT15 ; Set DMA backfill mode.
dw offset FUNCT16 ; Report DMAC count.
dw offset FUNCT17 ; Verify DMA block.
dw offset FUNCT18 ; Set PCM volume.
dw offset FUNCT19 ; set 32 bit addressing mode on/off
DPMI dw 0 ; Default 32 bit addressing mode is off.
IF BACKFILL
BACKF dw 0 ; Backfill defaults to off
ENDIF
JumpPtr dw ?
IF DIG_PAUDIO OR DIG_SBLASTER
IF DIG_SBLASTER
_voice_status dw 0
ENDIF
ELSE
PlayingSound dw 0 ; Flag true when sound sample is playing.
ENDIF
CallBacks dw 0 ; Callback to application flag.
LABEL CALLBACK DWORD ; Callback address label.
CallLow dw 0 ; Low word of callback address.
CallHigh dw 0 ; High word of callback address.
CallDS dw 0 ; Value of DS register at callback time.
IF FOREGROUND
LoopConstant dw 0
ENDIF
DivisorRate dw 0 ; Default divisor rate.
RecordMode dw 0 ; set audio recording flag.
PlayMode dw PCM_8_MONO ; Default play mode is 8 bit PCM.
;; Data used by Kernel interupt
KJUMP FARPTR <> ; Address
OLDIN FARPTR <> ; Original interupt vector.
ID db 'KERN' ; 4B45524Eh Interupt identifier string.
IND db 'KR' ; 4B52h indicates a kernel installed interupt.
Proc SoundInterupt far
;;; Usage: DS:SI -> point to sound structure to play.
;; FUNCT1 AX = 0688h DigPlay
;; FUNCT2 AX = 0689h Sound Status
;; FUNCT3 AX = 068Ah Massage Audio
;; FUNCT4 AX = 068Bh DigPlay2, pre-massaged audio.
;; FUNCT5 AX = 068Ch Report audio capabilities.
;; FUNCT6 AX = 068Dh Report playback address.
;; FUNCT7 AX = 068Eh Set Callback address.
;; FUNCT8 AX = 068Fh Stop Sound.
;; FUNCT9 AX = 0690h Set Hardware addresses.
;; FUNCTA AX = 0691h Report Current callback address.
;; FUNCTB AX = 0692h Restore hardware vectors.
;; FUNCTC AX = 0693h Set Timer Divisor Sharing Rate
;; FUNCTD AX = 0694h Play preformatted loop
;; FUNCTE AX = 0695h Post Pending Audio
;; FUNCTF AX = 0696h Report Pending Status
;; FUNCT10 AX = 0697h Set Stereo Panning value.
;; FUNCT11 AX = 698h Set DigPak Play mode.
;; FUNCT12 AX = 699h Report Address of pending status flag.
;; FUNCT13 AX = 69Ah Set Recording mode 0 off 1 on.
;; FUNCT14 AX = 69Bh StopNextLoop
;; FUNCT15 AX = 69Ch Set DMA backfill mode.
;; FUNCT16 AX = 69Dh Report current DMAC count.
;; FUNCT17 AX = 69Eh Verify DMA block.
;; FUNCT18 AX = 69Fh Set PCM volume.
;; FUNCT19 AX = 6A0h Set 32 bit addressing interface on/off
IF DEBUGGING
call DebugLine
ENDIF
cmp ax,0688h
jb @@CHAIN
cmp ax,06A0h
ja @@CHAIN
SetSemaphore ; Set the inside DigPak semaphore
sti
sub ax,0688h
shl ax,1
add ax,offset JumpTable
xchg ax,bx
mov bx,[cs:bx]
xchg ax,bx
mov [cs:JumpPtr],ax
jmp [cs:JumpPtr] ;; Near jump will be modified!!
@@CHAIN:
cmp [cs:OLDIN.XPTR.POFF],0
jne @@CHAIN2
cmp [cs:OLDIN.XPTR.PSEG],0
je @@IRET
@@CHAIN2:
jmp [cs:OLDIN.DPTR] ; Chain to original interrupt vector.
@@IRET:
ClearSemaphoreIRET
endp
FUNCT1:
;;**************************************************************************
;:Function #1: DigPlay, Play an 8 bit digitized sound.
;:
;: INPUT: AX = 688h Command number.
;: DS:SI Point to a sound structure that
;: describes the sound effect to be played.
;;**************************************************************************
PushCREGS
ConvertDPMI ds,esi
call CompleteSound
call SetAudio
IF DIG_ADLIB OR DIG_IBMSND OR DIG_DIGISP OR DIG_TANEXTX OR DIG_ECHOII OR DIG_LANTSND OR DIG_IBMBAK OR DIG_IBM1BIT OR DIG_ADLIBG
IF DIG_ADLIB OR DIG_IBMSND OR DIG_TANEXTX OR DIG_ECHOII OR DIG_IBMBAK
call DownSample9000
ENDIF
call TranslateSound
ENDIF
IF DIG_T2500 OR DIG_SOURCE
call DownSample7000
ENDIF
IF DIG_PAUDIO OR DIG_SBLASTER
ELSE
mov [PlayingSound],1
ENDIF
IF DIG_ADLIB OR DIG_IBMSND OR DIG_TANEXTX OR DIG_ECHOII OR DIG_IBMBAK
call Compute9000
ENDIF
IF DIG_T2500 OR DIG_SOURCE
call Compute7000
ENDIF
IF NOSOUND
call Compute256
ENDIF
call PlaySound
PopCREGS
ClearSemaphoreIRET
FUNCT2:
;;**************************************************************************
;:Function #2: SoundStatus, Check current status of sound driver.
;:
;: INPUT: AX = 689h
;: OUTPUT: AX = 0 No sound is playing.
;: = 1 Sound effect currently playing.
;; DX = 1 Looping a sound effect
;; BX = Version numer, in decimal, times 100, so that 3.00
;; would be 300. Version number begins with version 3.10
;; which includes the DigPak semaphore.
;;**************************************************************************
mov bx,VERSION_NUMBER ; Return VERSION NUMBER in BX! 3.40
cmp [cs:LOOPING],1 ; Looping a sample?
jne @@REP
xor ax,ax
mov dx,1 ; Return high word looping flag.
ClearSemaphoreIRET
@@REP:
IF DIG_PAUDIO OR DIG_SBLASTER
mov ax,[cs:_voice_status]
ELSE
mov ax,[cs:PlayingSound]
ENDIF
xor dx,dx ; Not looping
ClearSemaphoreIRET
FUNCT3:
;;**************************************************************************
;:Function #3: MassageAudio, Preformat audio data into ouptut hardware format.
;:
;: INPUT: AX = 68Ah
;: DS:SI Point to address of sound structure.
;;**************************************************************************
PushCREGS
ConvertDPMI ds,esi
cmp [cs:PlayMode],PCM_16_MONO ; Don't massage audio in 16 bit mode!
je @@JUSTRET
call SetAudio
IF DIG_ADLIB OR DIG_IBMSND OR DIG_DIGISP OR DIG_TANEXTX OR DIG_ECHOII OR DIG_LANTSND OR DIG_IBMBAK OR DIG_IBM1BIT OR DIG_ADLIBG
IF DIG_ADLIB OR DIG_IBMSND OR DIG_TANEXTX OR DIG_ECHOII OR DIG_IBMBAK
call DownSample9000
ENDIF
call TranslateSound
ENDIF
IF DIG_T2500 OR DIG_SOURCE
call DownSample7000
ENDIF
@@JUSTRET:
PopCREGS
ClearSemaphoreIRET
FUNCT4:
;;**************************************************************************
;:Function #4: DigPlay2, Play preformatted audio data.
;:
;: INPUT: AX = 68Bh
;: DS:SI Point to address of sound structure.
;;**************************************************************************
PushCREGS
ConvertDPMI ds,esi
call CompleteSound
call DoSoundPlay
mov [cs:FROMLOOP],0 ; Turn from loop semephore off.
PopCREGS
ClearSemaphoreIRET
FUNCT5:
;;**************************************************************************
;:Function #5: AudioCapabilities, Report capabilities of hardware device.
;:
;: INPUT: AX = 68Ch
;: OUTPUT: AX = Bit 0 -> On, supports background playback.
;: Off, driver only plays as a foreground process.
;: Bit 1 -> On, source data is reformatted for output device.
;: Off, device handles raw 8 bit unsigned audio.
;: Bit 2 -> On, Device plays back at a fixed frequency, but
;: the audio driver will downsample input data
;: to fit.
;: Off, device plays back at user specified frequency.
;: (NOTE: You can still playback an audio sample at
;: whatever frequency you wish. The driver
;: will simply downsample the data to fit
;: the output hardware. Currently it does
;: not support upsampling though.)
;: Bit 3 -> On, this device uses the timer interrupt vector
;: during sound playback.
;: DX = If this device plays back at a fixed frequency the DX
;: register will contain that fixed frequency playback rate.
;;**************************************************************************
IF DIG_ADLIBG
mov ax,(PLAYBACK OR MASSAGE OR STEREOPLAY OR DMABACKFILL)
ENDIF
IF DIG_ADLIB
mov ax,(PLAYBACK OR MASSAGE OR USESTIMER OR FIXEDFREQ OR SHARESTIMER)
mov dx,9000
ENDIF
IF DIG_T2500
mov ax,(PLAYBACK OR MASSAGE OR USESTIMER OR FIXEDFREQ OR SHARESTIMER)
mov dx,7000
ENDIF
IF DIG_CVXSND OR DIG_VMSND OR DIG_SMSND OR DIG_BIGMOUTH
IF NOSOUND
mov ax,(PLAYBACK OR USESTIMER OR SHARESTIMER)
ELSE
mov ax,(PLAYBACK OR USESTIMER OR SHARESTIMER OR DMABACKFILL)
ENDIF
ENDIF
IF NOSOUND
or ax,FIXEDFREQ
mov dx,256
ENDIF
IF DIG_IBMSND
mov ax,(MASSAGE OR USESTIMER OR FIXEDFREQ OR SHARESTIMER)
mov dx,9000
ENDIF
IF DIG_DIGISP
mov ax,(MASSAGE OR FIXEDFREQ)
mov dx,8000
ENDIF
IF DIG_TANEXTX
mov ax,(PLAYBACK OR MASSAGE OR USESTIMER OR FIXEDFREQ OR SHARESTIMER)
mov dx,9000
ENDIF
IF DIG_TANSLTL
mov ax,(PLAYBACK)
ENDIF
IF DIG_SBLASTER
mov ax,(PLAYBACK OR AUDIORECORD)
cmp [cs:AUTOALLOWED],1 ; allowed to do auto-init DMA?
jne @@NOA
or ax,DMABACKFILL ;**!!Can't get it to work!
@@NOA:
ENDIF
IF DIG_SOURCE
mov ax,(PLAYBACK OR USESTIMER OR FIXEDFREQ OR SHARESTIMER)
mov dx,7000
ENDIF
IF DIG_ECHOII
mov ax,(PLAYBACK OR MASSAGE OR USESTIMER OR FIXEDFREQ OR SHARESTIMER)
mov dx,9000
ENDIF
IF DIG_LANTSND
mov ax,(PLAYBACK OR MASSAGE OR FIXEDFREQ)
mov dx,8000
ENDIF
IF DIG_IBMBAK
mov ax,(PLAYBACK OR MASSAGE OR USESTIMER OR FIXEDFREQ OR SHARESTIMER)
mov dx,9000
ENDIF
IF DIG_IBM1BIT
mov ax,(PLAYBACK OR MASSAGE OR USESTIMER OR SHARESTIMER)
ENDIF
IF DIG_PAUDIO
mov ax,(PLAYBACK OR DMABACKFILL) ;;** OR AUDIORECORD)
ENDIF
IF DIG_ARIA
mov ax,(PLAYBACK OR STEREOPAN)
IF ARIA_STEREO
or ax,STEREOPLAY
ENDIF
ENDIF
IF FOREGROUND
and ax,0FFFEh ; Strip background bit OFF
ENDIF