-
Notifications
You must be signed in to change notification settings - Fork 4
/
MIXER.PAS
1360 lines (1136 loc) · 33.5 KB
/
MIXER.PAS
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
{*****************************************************************************
Mixer for my Low Level Driver for OPTi 82C929 Soundcards
*****************************************************************************
Version: 1.12
Date : 24.02.2019
Author : Jan Knipperts
*****************************************************************************}
Program OPTi929_Mixer;
uses opti929,mpu,oplfm,opl4,
sbpro,ad1848,bmf,dos,
textmode,misc;
{$L SONG.OBJ}
Procedure INTRO8; external; {include the FM song}
{$L TEST8.OBJ}
Procedure SOUND8BIT; external; {include the sample}
type
slider = record
x : byte;
end;
SBcfg = record
Base : word;
irq, dma : byte;
end;
codecvolumes = record
DACL,
DACR,
AUX1L,
AUX1R,
AUX2L,
AUX2R,
inp,
micgain,
gain : byte;
dmix : boolean;
end;
Freqconfig = record
freq,
bits,
chan : byte;
end;
const
title : string = 'MAD16 Pro Mixer v.1.12 (c) 2019 Jan Knipperts';
footer : string = 'F1 = Load last settings, ESC = Save and quit';
kfooter : string = 'Up/Down = Select; +/- = Set Volume; Space/Enter = Toggle; F,S,W = Soundcheck';
cfgfile : string = 'sound.cfg';
samplesize = 22050;
F1 = #59;
F2 = #60;
textcol = 15;
headings = 14;
background = 1;
DmaChannel : Array [0..3,1..3] of Byte =
(($87,$0,$1),($83,$2,$3),($81,$2,$3),($82,$6,$7));
var
dacl,dacr,aux1l,aux1r,aux2l,aux2r : slider;
xp,yp : byte;
cfg : OPTi929config;
SBFreq,
WSSFreq : Freqconfig;
fmplaying, dacplaying : boolean;
fmbuffer,fmsongptr : pointer;
irqcalled : boolean;
sb : sbcfg;
index : word;
timeout,SBm,
dmix,keyboardmode,
volumecmd,nodetect : boolean;
volumes : codecvolumes;
f : file;
key : char;
dma, Offset, Page : Word;
dl,dh,filter : Byte;
s : string;
vl,vr,input,mgain,select : byte;
c1,c2 : integer;
Procedure Prepare_AD1848_for_SB;
{Configure the codec to a propper format and frequency for Sound Blaster compatibility}
var dummy : byte;
begin
asm
cli
end;
WaitForCodec; {Just to be sure the codec is ready}
{SetDMAMode(true); {Set codec to single DMA mode for SB}
case sbfreq.bits of
0: dummy := PCM_U_8BIT;
1: dummy := PCM_COMPL_16BIT;
end;
{Set data format, frequency and mono/stereo}
AD1848_SetOutputFormat(codec_rates[SBFreq.freq+1].freq,dummy,boolean(sbfreq.chan));
Calibrate_AD1848; {Recalibrate codec o new samplerate}
WaitForCodec; {Wait for the codec to be ready again}
asm
sti
end;
end;
function LoadSettings : Boolean;
begin
if not fileexist(cfgfile) then
begin
Loadsettings := false;
end
else
begin
assign(f,cfgfile);
reset(f,1);
{$I-}
blockread(f,cfg,sizeof(cfg));
blockread(f,sbfreq,sizeof(freqconfig));
blockread(f,wssfreq,sizeof(freqconfig));
blockread(f,filter,sizeof(filter));
blockread(f,volumes,sizeof(codecvolumes));
close(f);
{$I+}
if IOResult <> 0 then
begin
Loadsettings := false;
end
else
begin
Loadsettings := true;
input := volumes.inp;
mgain := volumes.micgain;
dmix := volumes.dmix;
end;
end;
end;
function SaveSettings : Boolean;
begin
assign(f,cfgfile);
{$I-}
rewrite(f,1);
{$I+}
if IOResult <> 0 then
begin
Savesettings := false;
end
else
begin
volumes.inp := input;
volumes.micgain := mgain;
volumes.dmix := dmix;
{$I-}
blockwrite(f,cfg,sizeof(cfg));
blockwrite(f,sbfreq,sizeof(freqconfig));
blockwrite(f,wssfreq,sizeof(freqconfig));
blockwrite(f,filter,sizeof(filter));
blockwrite(f,volumes,sizeof(codecvolumes));
close(f);
{$I+}
if IOResult <> 0 then
begin
Savesettings := false;
end
else
begin
Savesettings := true;
end;
end;
end;
Procedure Refresh_volumes;
begin
fastwrite(51,7,headings,background,addspace(round((volumes.dacl / 30)*100)));
fastwrite(54,7,headings,background,'%');
fastwrite(51,8,headings,background,addspace(round((volumes.dacr / 30)*100)));
fastwrite(54,8,headings,background,'%');
fastwrite(51,13,headings,background,addspace(round((volumes.aux1l / 30)*100)));
fastwrite(54,13,headings,background,'%');
fastwrite(51,14,headings,background,addspace(round((volumes.aux1r / 30)*100)));
fastwrite(54,14,headings,background,'%');
fastwrite(51,19,headings,background,addspace(round((volumes.aux2l / 30)*100)));
fastwrite(54,19,headings,background,'%');
fastwrite(51,20,headings,background,addspace(round((volumes.aux2r / 30)*100)));
fastwrite(54,20,headings,background,'%');
end;
Procedure Reset_Sliders;
begin
putchar(dacl.x,7,#196,textcol,background);
putchar(dacr.x,8,#196,textcol,background);
putchar(aux1l.x,13,#196,textcol,background);
putchar(aux1r.x,14,#196,textcol,background);
putchar(aux2l.x,19,#196,textcol,background);
putchar(aux2r.x,20,#196,textcol,background);
dacl.x := volumes.dacl+18;
dacr.x := volumes.dacr+18;
aux1l.x := volumes.aux1l+18;
aux1r.x := volumes.aux1r+18;
aux2l.x := volumes.aux2l+18;
aux2r.x := volumes.aux2r+18;
putchar(dacl.x,7,#219,textcol,background);
putchar(dacr.x,8,#219,textcol,background);
putchar(aux1l.x,13,#219,textcol,background);
putchar(aux1r.x,14,#219,textcol,background);
putchar(aux2l.x,19,#219,textcol,background);
putchar(aux2r.x,20,#219,textcol,background);
fastwrite(69,22,15,0,addspace(round((volumes.gain / 15)*100))+'%');
Refresh_Volumes;
end;
Procedure Mark(x,y,l : byte);
var c : byte;
begin
if keyboardmode then
begin
for c := x to x+(l-1) do
begin
changeattr(c,y,14,4);
end;
end;
end;
Procedure UnMark(x,y,l : byte);
var c : byte;
begin
if keyboardmode then
begin
for c := x to x+(l-1) do
begin
if select < 13 then changeattr(c,y,15,1)
else changeattr(c,y,15,0);
end;
end;
end;
Procedure UnSelectItem(sel : byte);
var x,y,l : byte;
begin
if keyboardmode then
begin
case sel of
1: begin y := 7; x := 10; l := 6; end;
2: begin y := 8; x := 10; l := 6; end;
3: begin y := 13; x := 10; l := 6; end;
4: begin y := 14; x := 10; l := 6; end;
5: begin y := 19; x := 10; l := 6; end;
6: begin y := 20; x := 10; l := 6; end;
7: begin y := 15; x := 63; l := 1; end;
8: begin y := 16; x := 63; l := 1; end;
9: begin y := 17; x := 66; l := 1; end;
10: begin y := 18; x := 63; l := 1; end;
11: begin y := 19; x := 63; l := 1; end;
12: begin y := 21; x := 63; l := 1; end;
13: begin y := 22; x := 69; l := 4; end;
end;
Unmark(x,y,l);
end;
end;
Procedure SelectItem(sel : byte);
var x,y,l : byte;
begin
if keyboardmode then
begin
case sel of
1: begin y := 7; x := 10; l := 6; end;
2: begin y := 8; x := 10; l := 6; end;
3: begin y := 13; x := 10; l := 6; end;
4: begin y := 14; x := 10; l := 6; end;
5: begin y := 19; x := 10; l := 6; end;
6: begin y := 20; x := 10; l := 6; end;
7: begin y := 15; x := 63; l := 1; end;
8: begin y := 16; x := 63; l := 1; end;
9: begin y := 17; x := 66; l := 1; end;
10: begin y := 18; x := 63; l := 1; end;
11: begin y := 19; x := 63; l := 1; end;
12: begin y := 21; x := 63; l := 1; end;
13: begin y := 22; x := 69; l := 4; end;
end;
mark(x,y,l);
end;
end;
Procedure WSS_PlaySample(Sample : Pointer; Size : Word; DMACh : Byte);
{Play data from pointer sample through WSS:
Size Size of data block (Max. 64 Kb in one time!)
DMACh Number of DMA-channel (0-3)}
Begin
Dec(Size);
Offset := Seg(Sample^) Shl 4 + Ofs(Sample^);
Page := (Seg(Sample^) + Ofs(Sample^) Shr 4) Shr 12;
Port[$0A] := $4 + DMACh;
Port[$0C] := 0; {Clear the internal DMA flip-flop}
Port[$0B] := $48 + DMACh;
Port[DMAChannel[1,2]] := Lo(Offset);
Port[DMAChannel[1,2]] := Hi(Offset);
Port[DMAChannel[1,1]] := Page;
Port[DMAChannel[1,3]] := Lo(Size);
Port[DMAChannel[1,3]] := Hi(Size);
Port[$0A] := DMACh;
WriteCODECReg($0E,lo(size - 1));
WriteCODECReg($0F,hi(size - 1));
writeCODECreg($0A,$02); {enable interrupt and pin control}
MuteDAC(LEFTANDRIGHT,false);
Playback(true);
End;
Procedure EnterWSSMode;
var dummy : byte;
begin
SetWSSMode(cfg); {Set OPTi 929 to WSS Mode}
WaitForCodec; {Wait for the codec to be ready}
AD1848_SetOutputFormat(11025,PCM_U_8BIT,STEREO); {Set audio format}
Calibrate_AD1848; {Recalibrate codec to new samplerate}
WaitForCodec; {Wait for the codec to be ready again}
Playback(false);
end;
Procedure EnterSBMode;
begin
Prepare_AD1848_for_SB;
WaitForCodec; {Wait for the codec to be ready}
SetSBMode(cfg); {Set OPTi Controller to SB Mode}
DSP_Reset(sb.base); {Reset sound blaster dsp}
SB_ResetMixer;
case sbfreq.chan of
0: SB_SetOutput(false,boolean(filter)); {Set Mono output}
1: SB_SetOutput(true,boolean(filter)); {Set Stereo output}
end;
If cfg.sbmix = 0 then SBMixer(false);
end;
Procedure Wait_for_Mousebutton;
begin
if not keyboardmode then
begin
repeat
Mouse_Read;
until mouse.b = 0;
end
else
begin
while iskeypressed do getkey;
key := #0;
end;
end;
Procedure PlayFM;
begin
if fmplaying then
begin
fastwrite(66,5,0,7,'FM Music');
if keyboardmode then putchar(66,5,'F',4,7);
fastwrite(67,6,0,background,#223+#223+#223+#223+#223+#223+#223+#223);
fastwrite(74,5,0,background,#220);
if not keyboardmode then mouse_show;
ClearOPL;
StopBMFPlayer;
fmplaying := false;
Wait_for_Mousebutton;
end
else
begin
fastwrite(66,5,0,7,'FM Music');
fastwrite(67,6,background,background,#223+#223+#223+#223+#223+#223+#223+#223);
fastwrite(74,5,background,background,#220);
mouse_show;
PlayBMFdata(@intro8,3797);
fmplaying := true;
Wait_for_Mousebutton;
end;
end;
Procedure PlayDAC;
begin
if dacplaying then
begin
fastwrite(66,7,0,7,'Sample');
if keyboardmode then putchar(66,7,'S',4,7);
fastwrite(67,8,0,background,#223+#223+#223+#223+#223+#223);
fastwrite(72,7,0,background,#220);
mouse_show;
Playback(false);
Port[$0A] := $4 + cfg.wssdma;
Port[$0C] := 0; {Clear the internal DMA flip-flop}
WriteCODECReg($0E,0);
WriteCODECReg($0F,0);
writeCODECreg($0A,$00); {disable interrupt and pin control}
port[$20] := $20;
mutedac(leftandright,true);
dacplaying := false;
Wait_for_Mousebutton;
end
else
begin
fastwrite(66,7,0,7,'Sample');
fastwrite(67,8,background,background,#223+#223+#223+#223+#223+#223);
fastwrite(72,7,background,background,#220);
mouse_show;
mutedac(leftandright,true);
WSS_PlaySample(addr(SOUND8BIT),samplesize,cfg.wssdma);
dacplaying := true;
Wait_for_Mousebutton;
end;
end;
Procedure PlayMidi;
begin
fastwrite(66,9,0,7,'Wavetable');
fastwrite(67,10,background,background,#223+#223+#223+#223+#223+#223+#223+#223+#223);
fastwrite(75,9,background,background,#220);
mouse_show;
NoteOff(1,48,127);
SetPatch(1,1);
NoteOn(1,48,127);
Wait_for_Mousebutton;
mouse_hide;
fastwrite(66,9,0,7,'Wavetable');
if keyboardmode then putchar(66,9,'W',4,7);
fastwrite(67,10,0,background,#223+#223+#223+#223+#223+#223+#223+#223+#223);
fastwrite(75,9,0,background,#220);
mouse_show;
end;
Procedure SetMic;
begin
input := Mic;
putchar(63,15,' ',textcol,background);
putchar(63,16,'x',textcol,background);
fastwrite(65,17,textcol,background,'( ) +20db');
putchar(63,18,' ',textcol,background);
putchar(63,19,' ',textcol,background);
if mgain = 1 then
begin
putchar(66,17,'x',textcol,background);
mouse_show;
SetInput(MIC,LEFTANDRIGHT,volumes.gain,true);
end
else
begin
putchar(66,17,' ',textcol,background);
mouse_show;
SetInput(MIC,LEFTANDRIGHT,volumes.gain,false);
end;
end;
Procedure SetLine;
begin
input := Line;
putchar(63,15,'x',textcol,background);
putchar(63,16,' ',textcol,background);
fastwrite(65,17,8,background,'( ) +20db');
putchar(63,18,' ',textcol,background);
putchar(63,19,' ',textcol,background);
mgain := 0;
mouse_show;
SetInput(LINE,LEFTANDRIGHT,volumes.gain,false);
end;
Procedure SetMicGain;
begin
if mgain = 1 then
begin
putchar(66,17,' ',textcol,background);
mouse_show;
mgain := 0;
SetInput(MIC,LEFTANDRIGHT,volumes.gain,false);
end
else
begin
putchar(66,17,'x',textcol,background);
mouse_show;
SetInput(MIC,LEFTANDRIGHT,volumes.gain,true);
mgain := 1;
end;
end;
Procedure SetAUx;
begin
input := AUX1i;
putchar(63,15,' ',textcol,background);
putchar(63,16,' ',textcol,background);
fastwrite(65,17,8,background,'( ) +20db');
putchar(63,18,'x',textcol,background);
putchar(63,19,' ',textcol,background);
mgain := 0;
mouse_show;
SetInput(AUX1i,LEFTANDRIGHT,volumes.gain,false);
end;
Procedure SetPostMix;
begin
input := PostMx;
putchar(63,15,' ',textcol,background);
putchar(63,16,' ',textcol,background);
fastwrite(65,17,8,background,'( ) +20db');
putchar(63,18,' ',textcol,background);
putchar(63,19,'x',textcol,background);
mouse_show;
SetInput(POSTMX,LEFTANDRIGHT,volumes.gain,false);
end;
Procedure SetDmix;
begin
if dmix = false then
begin
putchar(63,21,'x',textcol,background);
mouse_show;
SetDigitalMix(true,volumes.gain);
dmix := true;
end
else
begin
putchar(63,21,' ',textcol,background);
mouse_show;
SetDigitalMix(false,volumes.gain);
dmix := false;
end;
end;
Procedure SetGain;
begin
fastwrite(69,22,15,0,addspace(round((volumes.gain / 15)*100))+'%');
mouse_show;
if input = mic then
begin
if mgain = 1 then
begin
SetInput(MIC,LEFTANDRIGHT,volumes.gain,true);
end
else
begin
SetInput(MIC,LEFTANDRIGHT,volumes.gain,false);
end;
end;
if input = line then
begin
SetInput(LINE,LEFTANDRIGHT,volumes.gain,false);
end;
if input = PostMx then
begin
SetInput(POSTMX,LEFTANDRIGHT,volumes.gain,false);
end;
if input = AUX1i then
begin
SetInput(AUX1i,LEFTANDRIGHT,volumes.gain,false);
end;
end;
{================= Handle command line options ========================}
Function FindOption(lookup : string) : boolean;
var cnt : byte;
s : string;
begin
FindOption := false;
for cnt := 1 to paramcount do
begin
if length(paramstr(cnt)) > length(lookup) then
s := copy(uppercase(paramstr(cnt)),1,length(lookup))
else
s := uppercase(paramstr(cnt));
if s = uppercase(lookup) then
begin
FindOption := true;
break;
end;
end;
end;
begin
if FindOption('AUX1') or FindOption('AUX2') or FindOption('DAC') then
VOLUMECMD := true;
keyboardmode := FindOption('/K');
nodetect := FindOption('/NODETECT');
if (paramcount > 0) and
(volumecmd = false) and
(keyboardmode = false) and
(nodetect = false) then
begin
writeln('');
writeln(' '+title);
writeln(' Possible commandline parameters for the Mixer: ');
writeln('');
writeln(' /K - Force keyboard control ');
writeln(' /NODETECT - Skips hardware detection');
writeln('');
writeln(' The desired volume can also be set from the command line:');
writeln('');
writeln(' Mixer.exe <Device> <Left volume (%)> <Right volume (%)>');
writeln(' Supported values for <Device> are AUX1, AUX2 and DAC');
writeln('');
halt(0);
end;
if volumecmd = false then
begin
writeln('');
write(' Reading configuration... ');
end;
if not loadsettings then
begin
writeln('');
writeln('Config file not found! Please run SETUP first.');
writeln('');
halt(1);
end;
{Init some variables for codec access}
CODEC.WSSPort := cfg.WSSBase;
CODEC.ADDR := cfg.WSSBase+4;
CODEC.DATA := cfg.WSSBase+5;
CODEC.STATUS := cfg.WSSBase+6;
CODEC.PIO := cfg.WSSBase+7;
{..and for MPU access}
COMDPORT := cfg.mpubase+1;
STATPORT := cfg.mpubase+1;
DATAPORT := cfg.mpubase;
if volumecmd = false then writeln('OK');
if nodetect = false then
begin
if (volumecmd = false) then write(' Checking hardware....');
if not Detect929 then
begin
writeln('');
writeln(' No OPTi 82C929 Soundcontroller found! ');
writeln('');
halt(1);
end;
if not DetectAD1848 then
begin
writeln('');
writeln(' No supported Codec found! ');
writeln(' Run SETUP to check the configuration. ');
writeln('');
halt(1);
end;
if SBMode then {Opti929 is in SB mode}
begin
if not DSP_Reset(cfg.SBBase) then {Try to reset the DSP}
begin
writeln('');
writeln(' Sound Blaster initialization failed!');
writeln(' Run SETUP to check the configuration. ');
writeln('');
halt(1);
end;
SB_resetMixer; {Reset mixer}
SBM := true; {Save that we started in SB mode to restore it later}
end;
if (detectOPL2 = false) and (detectOPL3 = false) and (OPL4_detect = false) then
begin
writeln('');
writeln(' No compatible Yamaha FM synthesis chip found!');
writeln('');
halt(1);
end;
InitOPL;
ClearOPL;
if not volumecmd then
begin
if cfg.mpu401 = 1 then
begin
ResetMPU(0); {First try to reset MPU to default (intelligent) mode}
if not ResetMPU(1) then {Then try to set it to UART}
begin
writeln('');
writeln(' Initalisation of MPU-401 interface failed!');
writeln(' Run SETUP to check the configuration. ');
writeln('');
halt(1);
end;
end;
if (mouse_there = false) or (mouse_init = false) or (uppercase(paramstr(1)) = '/K') then
begin
keyboardmode := true;
mouse_there := false;
end
else
begin
keyboardmode := false;
end;
writeln('OK');
end;
end;
if volumecmd = true then
begin
s := uppercase(paramstr(1));
if (s = 'DAC') or (s = 'AUX1') or (s = 'AUX2') then
begin
val(paramstr(2),vl,c1);
val(paramstr(3),vr,c2);
if (c1 <> 0) or (c2 <> 0) or (vl > 100) or (vr > 100) then
begin
writeln('Invalid value for volume! ');
writeln('');
halt(1);
end;
vl := round(vl*0.3);
vr := round(vr*0.3);
protect_shadowregs(false);
EnterWSSMode; {switch controller to WSS mode for full codec access}
if s = 'DAC' then
begin
AD1848_SetVolume(DAC,Left,vl);
AD1848_SetVolume(DAC,Right,vr);
end;
if s = 'AUX1' then
begin
AD1848_SetVolume(AUX1,Left,vl);
AD1848_SetVolume(AUX1,Right,vr);
end;
if s = 'AUX2' then
begin
AD1848_SetVolume(AUX2,Left,vl);
AD1848_SetVolume(AUX2,Right,vr);
end;
if sbm then
begin
Prepare_AD1848_for_SB;
WaitForCodec; {Wait for the codec to be ready}
SetSBMode(cfg); {Set OPTi Controller to SB Mode}
DSP_Reset(sb.base); {Reset sound blaster dsp}
SB_ResetMixer;
case sbfreq.chan of
0: SB_SetOutput(false,boolean(filter)); {Set Mono output}
1: SB_SetOutput(true,boolean(filter)); {Set Stereo output}
end;
If cfg.sbmix = 0 then SBMixer(false); end;
protect_shadowregs(boolean(cfg.shprotect));
writeln(' '+s+' volume set to '+addzero(round((vl/30)*100))+'% for the left channel and '+
addzero(round((vr/30)*100))+'% for the right channel.');
halt(0);
end
else
begin
writeln(' Invalid parameter!');
writeln(' Mixer.exe <Device> <Left volume (%)> <Right volume (%)>');
writeln(' Supported values for <Device> are AUX1, AUX2 and DAC');
writeln('');
halt(1);
end;
end;
asm
mov ax,3h
int 10h
end;
cursor(false);
randomize;
EnterWSSMode;
protect_shadowregs(false);
InitMenuScreen(title);
if not keyboardmode then
begin
Centeredline(25,14,1,footer);
end
else
begin
Centeredline(24,14,1,kfooter);
Centeredline(25,14,1,footer);
end;
window(4,3,57,23,textcol,background,true);
fastwrite(23,3,headings,background,'Actual volumes:');
fastwrite(8, 5,headings,background,'DAC Output');
fastwrite(10, 7,textcol,background,'Left:');
for z := 0 to 30 do fastwrite(18+z, 7,textcol,background,#196);
fastwrite(10, 8,textcol,background,'Right:');
for z := 0 to 30 do fastwrite(18+z, 8,textcol,background,#196);
fastwrite(8,11,headings,background,'Auxiliary 1 (CD and ext. Midi) ');
fastwrite(10,13,textcol,background,'Left:');
for z := 0 to 30 do fastwrite(18+z, 13,textcol,background,#196);
fastwrite(10,14,textcol,background,'Right:');
for z := 0 to 30 do fastwrite(18+z, 14,textcol,background,#196);
fastwrite(8,17,headings,background,'Auxiliary 2 (FM and Wavetableheader) ');
fastwrite(10,19,textcol,background,'Left:');
for z := 0 to 30 do fastwrite(18+z, 19,textcol,background,#196);
fastwrite(10,20,textcol,background,'Right:');
for z := 0 to 30 do fastwrite(18+z, 20,textcol,background,#196);
volumes.dacl := AD1848_GetVolume(DAC,Left);
volumes.dacr := AD1848_GetVolume(DAC,Right);
volumes.aux1l := AD1848_GetVolume(AUX1,Left);
volumes.aux1r := AD1848_GetVolume(AUX1,Right);
volumes.aux2l := AD1848_GetVolume(AUX2,Left);
volumes.aux2r := AD1848_GetVolume(AUX2,Right);
volumes.gain := AD1848_GetGain(LeftANDRight);
dacl.x := volumes.dacl+18;
dacr.x := volumes.dacr+18;
aux1l.x := volumes.aux1l+18;
aux1r.x := volumes.aux1r+18;
aux2l.x := volumes.aux2l+18;
aux2r.x := volumes.aux2r+18;
putchar(dacl.x,7,#219,textcol,background);
putchar(dacr.x,8,#219,textcol,background);
putchar(aux1l.x,13,#219,textcol,background);
putchar(aux1r.x,14,#219,textcol,background);
putchar(aux2l.x,19,#219,textcol,background);
putchar(aux2r.x,20,#219,textcol,background);
window(60,13,79,23,textcol,background,true);
fastwrite(63,13,headings,background,'Input Control:');
fastwrite(62,15,textcol,background,'( ) Line in');
fastwrite(62,16,textcol,background,'( ) Microphone');
fastwrite(65,17,8,background,'( ) +20db');
if mgain = 1 then putchar(66,17,'x',8,15);
fastwrite(62,18,textcol,background,'( ) AUX1');
fastwrite(62,19,textcol,background,'( ) Post-Mixed');
fastwrite(62,21,textcol,background,'( ) Mix ADC/DAC');
fastwrite(62,22,textcol,background,'Gain:');
if not keyboardmode then
begin
putchar(68,22,#24,0,7);
putchar(73,22,#25,0,7);
end;
fastwrite(69,22,15,0,addspace(round((volumes.gain / 15)*100))+'%');
if input = line then putchar(63,15,'x',textcol,background);
if input = mic then
begin
putchar(63,16,'x',textcol,background);
fastwrite(65,17,textcol,background,'( ) +20db');
if mgain = 1 then putchar(66,17,'x',textcol,background);
end;
if input = aux1i then putchar(63,18,'x',textcol,background);
if input = postmx then putchar(63,19,'x',textcol,background);
if dmix then putchar(63,21,'x',textcol,background);
window(64,3,78,11,textcol,background,true);
fastwrite(66,3,headings,background,'Soundcheck:');
fastwrite(66,5,0,7,'FM Musik');
if keyboardmode then putchar(66,5,'F',4,7);
fastwrite(67,6,0,background,#223+#223+#223+#223+#223+#223+#223+#223);
fastwrite(74,5,0,background,#220);
fastwrite(66,7,0,7,'Sample');
if keyboardmode then putchar(66,7,'S',4,7);
fastwrite(67,8,0,background,#223+#223+#223+#223+#223+#223);
fastwrite(72,7,0,background,#220);
if cfg.mpu401 = 0 then
begin
fastwrite(66,9,0,7,'Wavetable');
end
else
begin
fastwrite(66,9,0,7,'Wavetable');
if keyboardmode then putchar(66,9,'W',4,7);
fastwrite(67,10,0,background,#223+#223+#223+#223+#223+#223+#223+#223+#223);
fastwrite(75,9,0,background,#220);
end;
fmplaying := false;
dacplaying := false;
Refresh_volumes;
if not keyboardmode then
begin
mouse_show;
end
else
begin
select := 1;
selectitem(select);
end;
while iskeypressed do getkey;
repeat;
if not keyboardmode then Mouse_Read;
if (getbit(ReadCODECReg($B),6) = 1) and (dacplaying = true) then
begin
Playback(false);
mutedac(leftandright,true);
WriteCODECReg($0E,0); {Reset counter}
WriteCODECReg($0F,0);
writeCODECreg($0A,$00); {disable interrupt and pin control}
Port[$20] := $20;
mouse_hide;
fastwrite(66,7,0,7,'Sample');