]> icculus.org git repositories - btb/d2x.git/blob - main/old/cdmix32.c
use the orientation parameter of g3_draw_bitmap
[btb/d2x.git] / main / old / cdmix32.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #include <stdio.h>
15 #include <string.h>
16 #include <stdlib.h>
17 #include <conio.h>
18 #include <ctype.h>
19
20 #include "inferno.h"
21 #include "sos.h"
22 #include "mono.h"
23 #include "dxxerror.h"
24
25 typedef struct 
26  {
27   int id;
28   char *name;
29  } DigiDevices;
30
31 #define _AWE32_8_ST                             0xe208
32
33 #define NUM_OF_CARDS 4
34
35 #ifndef WINDOWS
36 DigiDevices SBCards[NUM_OF_CARDS]={
37   {_SOUND_BLASTER_8_MONO      , "Sound Blaster" },
38   {_SOUND_BLASTER_8_ST        , "Sound Blaster Pro" },
39   {_SB16_8_ST                 , "Sound Blaster 16/AWE32" },
40   {_AWE32_8_ST                                          ,  "Sound Blaster AWE32"} 
41  };
42 #endif
43
44 int CD_blast_mixer ()
45  {
46   FILE *InFile;
47   char line[100],nosbcard=1;
48   char *ptr,*token,*value;
49   int i;
50   int digiport=0,digiboard=0;
51   short int DataPort=0,AddressPort=0;
52   char redvol=0;
53
54
55 #ifndef WINDOWS
56   InFile = fopen("descent.cfg", "rt");
57   if (InFile == NULL) 
58          return (NULL);
59
60   while (!feof(InFile)) {
61                 memset(line, 0, 80);
62                 fgets(line, 80, InFile);
63                 ptr = &(line[0]);
64                 while (isspace(*ptr))
65                         ptr++;
66                 if (*ptr != '\0') {
67                         token = strtok(ptr, "=");
68                         value = strtok(NULL, "=");
69                         if (value[strlen(value)-1] == '\n')
70                         value[strlen(value)-1] = 0;
71                         if (!strcmp(token, "DigiDeviceID8"))
72                                 digiboard = strtol(value, NULL, 16);
73                         else if (!strncmp(token, "DigiPort",8))
74                          {
75                                 digiport = strtol(value, NULL, 16);
76                          }
77                         else if (!strcmp(token, "RedbookVolume"))
78                                 redvol = strtol(value, NULL, 10);
79                 }
80         }
81
82   mprintf ((0,"Digiport=0x%x\n",digiport));
83   mprintf ((0,"Digiboard=0x%x\n",digiboard));
84   mprintf ((0,"Redbook volume=%d\n",redvol));
85   for (nosbcard=1,i=0;i<NUM_OF_CARDS;i++)
86    {
87     if (SBCards[i].id==digiboard)
88                 {
89        mprintf ((0,"Sound board=%s\n",SBCards[i].name));        
90                  digiboard=i;
91                  nosbcard=0;
92                  break;
93                 }
94         }
95           
96   fclose (InFile);
97  
98   if (nosbcard)
99         {
100          mprintf ((0,"No Soundblaster type card was found!"));
101     return (0);
102         }
103
104   AddressPort=digiport+4;
105   DataPort=digiport+5;
106
107   if (digiboard==0)     // Plain SB
108         SetRedSB(AddressPort,DataPort,redvol);
109   else if (digiboard==1)        // SB Pro
110         SetRedSBPro(AddressPort,DataPort,redvol);
111   else if (digiboard==2 || digiboard==3) // Sound blaster 16/AWE 32
112    SetRedSB16 (AddressPort,DataPort,redvol);
113   else
114         Int3(); // What? Get Jason, this shouldn't have happened
115
116 #endif
117
118   return (1);
119  }
120
121 void SetRedSB16 (short aport,short dport,char vol)
122  {
123   char val;
124   
125   if (vol>15)
126    vol=15;
127     
128   outp (aport,0x36);
129   val=inp (dport);
130
131   if ((val>>3)==0)
132    {
133           val|=(25<<3);
134           outp (dport,val);
135         }
136
137   outp (aport,0x37);
138   val=inp (dport);
139   if ((val>>3)==0)
140    {
141           val|=(25<<3);
142           outp (dport,val);
143         }
144  }
145 void SetRedSB (short aport,short dport,char vol)
146  {
147   char val;
148   
149   if (vol>15)
150    vol=15;
151
152   vol=11;
153  
154   outp (aport,0x08);
155   val=inp (dport);
156   if ((val & 7)==0)
157         {
158          val|=0x05;
159          outp (dport,val);
160         }
161  }
162 void SetRedSBPro (short aport,short dport,char vol)
163  {
164   char val;
165   
166   if (vol>15)
167    vol=15;
168
169   vol=11;
170  
171   outp (aport,0x28);
172   val=inp (dport);
173   if ((val & 7)==0)
174         {
175           val|=0x55;
176           outp (dport,val);
177         }
178  }
179
180
181
182
183
184   
185
186   
187   
188