-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBLASTER.C
208 lines (183 loc) · 8.19 KB
/
BLASTER.C
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
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//ÛÛ ÛÛ
//ÛÛ BLASTER.C ÛÛ
//ÛÛ ÛÛ
//ÛÛ Demonstrates a technique for determining the address and type ÛÛ
//ÛÛ parameters of a Sound Blaster Pro adapter. Relies on the BLASTER ÛÛ
//ÛÛ environment variable, which is normally inserted into the end ÛÛ
//ÛÛ user's AUTOEXEC.BAT file by the Sound Blaster installation program. ÛÛ
//ÛÛ ÛÛ
//ÛÛ-----------------------------------------------------------------------ÛÛ
//ÛÛ Example usage: ÛÛ
//ÛÛ ÛÛ
//ÛÛ C:\>SET BLASTER=A220 I7 D1 T4 ÛÛ
//ÛÛ ÛÛ
//ÛÛ C:\>blaster ÛÛ
//ÛÛ Sound Blaster type: Sound Blaster Pro (Yamaha YMF262/OPL3 version) ÛÛ
//ÛÛ I/O address: 220H ÛÛ
//ÛÛ IRQ: 7 ÛÛ
//ÛÛ DMA: 1 ÛÛ
//ÛÛ Digital sound driver: SBPDIG.ADV ÛÛ
//ÛÛ FM sound driver: SBP2FM.ADV ÛÛ
//ÛÛ ÛÛ
//ÛÛ C:\> ÛÛ
//ÛÛ-----------------------------------------------------------------------ÛÛ
//ÛÛ ÛÛ
//ÛÛ V1.00 of 20-Apr-92 ÛÛ
//ÛÛ ÛÛ
//ÛÛ Project: IBM Audio Interface Library ÛÛ
//ÛÛ Author: John Miles ÛÛ
//ÛÛ ÛÛ
//ÛÛ C source compatible with Turbo C++ v1.0 or later ÛÛ
//ÛÛ ÛÛ
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//ÛÛ ÛÛ
//ÛÛ blaster.obj: blaster.c ail.h ÛÛ
//ÛÛ bcc -ml -c -v blaster.c ÛÛ
//ÛÛ ÛÛ
//ÛÛ blaster.exe: blaster.obj ail.obj ÛÛ
//ÛÛ tlink @blaster.lls ÛÛ
//ÛÛ ÛÛ
//ÛÛ Contents of BLASTER.LLS: ÛÛ
//ÛÛ /c /v /x + ÛÛ
//ÛÛ \bc\lib\c0l.obj + ÛÛ
//ÛÛ blaster ail, + ÛÛ
//ÛÛ blaster.exe, + ÛÛ
//ÛÛ blaster.map, + ÛÛ
//ÛÛ \bc\lib\cl.lib ÛÛ
//ÛÛ ÛÛ
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//ÛÛ ÛÛ
//ÛÛ Copyright (C) 1992 Miles Design, Inc. ÛÛ
//ÛÛ ÛÛ
//ÛÛ Miles Design, Inc. ÛÛ
//ÛÛ 10926 Jollyville #308 ÛÛ
//ÛÛ Austin, TX 78759 ÛÛ
//ÛÛ (512) 345-2642 / FAX (512) 338-9630 / BBS (512) 454-9990 ÛÛ
//ÛÛ ÛÛ
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include "ail.h" // Audio Interface Library API function header
/*************************************************************/
//
// board_ID(): Reads the BLASTER environment variable to determine the type
// and I/O port settings of the user's Sound Blaster adapter.
//
// Returns the names of the FM and digital sound drivers which should be
// used to communicate with the board, as well as an AIL drvr_desc structure
// which contains the correct I/O parameters for the board.
//
// If board_ID() returns 0, no BLASTER environment variable was found.
// Either the user has not installed the Sound Blaster in accordance with
// Creative Labs' instructions, or no Sound Blaster is installed.
//
// You can call board_ID() twice: once to get the name of the driver to
// load, and a second time to insert the correct I/O parameters into the
// drvr_desc structure returned by the driver's AIL_describe_driver()
// function.
//
/*************************************************************/
int board_ID(drvr_desc *desc, char *FM_driver_name,
char *DSP_driver_name, char *board_name)
{
int i,j,k,m,d,num,p;
char *env;
char string[128];
static drvr_desc t;
static int type;
static char tokens[] =
{
"AIDT"
};
static int base[] =
{
16,10,10,10
};
static int *targets[] =
{
&t.default_IO,&t.default_IRQ,&t.default_DMA,&type
};
static char *FM_driver_names[] =
{
"SBFM.ADV",
"SBP1FM.ADV",
"SBFM.ADV",
"SBP2FM.ADV",
};
static char *DSP_driver_names[] =
{
"SBDIG.ADV",
"SBPDIG.ADV",
"SBDIG.ADV",
"SBPDIG.ADV",
};
static char *board_names[] =
{
"Sound Blaster V1.5 or earlier",
"Sound Blaster Pro (Yamaha YM3812 version)",
"Sound Blaster V2.0",
"Sound Blaster Pro (Yamaha YMF262/OPL3 version)",
};
env = getenv("BLASTER");
if (env==NULL) return 0;
strncpy(string,env,127);
if (!strlen(string)) return 0;
strupr(string);
t = *desc;
for (m=0;m<strlen(string);m++)
{
if ((m != 0) && (string[m] != ' ')) continue;
m += (string[m] == ' '); k = string[m];
for (i=0;i<4;i++)
if (k==tokens[i])
{
p = m + 1;
num = 0;
do
{
d = string[p++];
for (j=0;j<base[i];j++)
if (toupper(d) == "0123456789ABCDEF"[j])
num = (num * base[i]) + j;
}
while (isalnum(d));
*targets[i] = num;
break;
}
}
*desc = t;
if (!type) return 0;
if (type > 4) type=4;
if (FM_driver_name != NULL)
strcpy(FM_driver_name,FM_driver_names[type-1]);
if (DSP_driver_name != NULL)
strcpy(DSP_driver_name,DSP_driver_names[type-1]);
if (board_name != NULL)
strcpy(board_name,board_names[type-1]);
return type;
}
/*************************************************************/
void main(void)
{
static drvr_desc blank = {0,0,{0,0,0,0},NULL,0,0,0,0,0,0};
char DSP_drvr[16];
char FM_drvr[16];
char board[64];
if (!board_ID(&blank,FM_drvr,DSP_drvr,board))
{
printf("Sound Blaster not installed, or BLASTER environment\n");
printf("variable not set.\n");
exit(1);
}
printf(" Sound Blaster type: %s\n",board);
printf(" I/O address: %XH\n",blank.default_IO);
printf(" IRQ: %u\n",blank.default_IRQ);
printf(" DMA: %u\n",blank.default_DMA);
printf("Digital sound driver: %s\n",DSP_drvr);
printf(" FM sound driver: %s\n",FM_drvr);
}