1 /***************************************************************************
2 * S3m/Mod player by Daniel Marks (dmarks@ais.net)
3 * GUS support by David Jeske (jeske@uiuc.edu)
4 *
5 * (C) 1994,1995 By Daniel Marks and David Jeske
6 *
7 * While we retain the copyright to this code, this source code is FREE.
8 * You may use it in any way you wish, in any product you wish. You may
9 * NOT steal the copyright for this code from us.
10 *
11 * We respectfully ask that you email one of us, if possible, if you
12 * produce something significant with this code, or if you have any bug
13 * fixes to contribute. We also request that you give credit where
14 * credit is due if you include part of this code in a program of your own.
15 *
16 * Email: s3mod@uiuc.edu
17 * jeske@uiuc.edu
18 *
19 * See the associated README file for Thanks
20 ***************************************************************************
21 *
22 * main.c - The main part of the s3mod program.
23 *
24 */
25
26 #include "config.h"
27
28 #include <unistd.h>
29 #include <stdio.h>
30 #include <string.h>
31 #include <fcntl.h>
32
33 #include "mod.h"
34 #include "play.h"
35 #include "main.h"
36 #include "cmdline.h"
37 #include "dsp.h"
38 #ifdef GUS
39 #include "gus.h"
40 #endif /* GUS */
41
42 /*
43 * Beginning of real code
44 */
45
46 struct option_struct options;
47 int gus_dev=-1;
48 int use_gus=1;
49 int stereo = 0;
50 int bit16 = 0;
51
help(void)52 void help(void)
53 {
54 printf("\nS3MOD - S3M/MOD tracker (%s) for Linux/Sun/DEC/SGI\n",VERSION);
55 #ifdef LINUX
56 printf(" Linux Support by Daniel Marks \n");
57 printf(" GUS Support by David Jeske (jeske@uiuc.edu)\n");
58 #endif /* LINUX */
59 #ifdef __FreeBSD__
60 printf(" FreeBSD Support by Vanilla I. Shu \n");
61 printf(" GUS Support by David Jeske (jeske@uiuc.edu\n");
62 #endif /* __FreeBSD__ */
63 #if defined(__sgi)
64 printf(" SGI Support by Mike Muuss (Mike@arl.mil)\n\n");
65 #endif /* __sgi */
66 #if defined(SUN) || defined(DEC)
67 printf(" SUN/DEC AF Support by Ricky Beam (cramer@catt.ncsu.edu)\n\n");
68 #endif /* SUN || DEC */
69 printf("(C) Copyright 1994 by Daniel L. Marks and David Jeske\n\n");
70 printf("For information email (s3mod@uiuc.edu).\n");
71 printf("s3mod [-sbfqnl] [sampling frequency] filename\n");
72 printf(" -s stereo\n");
73 #ifdef LINUX
74 printf(" -b 16 bit samples\n");
75 #endif /* ?LINUX */
76 #ifdef __FreeBSD__
77 printf(" -b 16 bit samples\n");
78 #endif /* __FreeBSD__ */
79 printf(" -f set frequency\n");
80 printf(" -q quiet (don't print anything)\n");
81 printf(" -n don't loop\n");
82 printf(" -l loud mode (shift voices louder)\n");
83 #ifdef LINUX
84 printf(" -g do NOT use GUS native mode\n");
85 #endif /* ?LINUX */
86 #ifdef __FreeBSD__
87 printf(" -g do NOT use GUS native mode\n");
88 #endif /* __FreeBSD__ */
89 printf(" -p PAL speed adjustment (145bpm start)\n");
90 printf("s3mod -sbf 44100 foobar.mod\n");
91 printf(" plays in stereo, 16 bits, 44.1 kHz\n\n");
92 printf("This player plays Screamtracker 3 files, and\n");
93 printf("4,6,or 8 track MODs.\n\n");
94 #ifdef DEC
95 printf("NOTE: DEC AF support is in it's ALPHA stages\n\n");
96 #endif /* ?LINUX */
97 exit(1);
98 }
99
100
get_audio_device(void)101 void get_audio_device(void)
102 {
103 int found_gus=0;
104
105 #ifdef GUS
106 if (use_gus)
107 {
108 found_gus = get_gus_device();
109 }
110
111 if (!found_gus)
112 {gus_dev=-1;
113 get_dsp_device();
114 }
115 #else /* GUS */
116 get_dsp_device();
117 #endif /* GUS */
118
119 }
120
121
main(int argc,char ** argv)122 int main(int argc, char **argv)
123 {
124 uint32 j;
125 char *filename;
126 long int frequency;
127 int quiet = 0;
128 int loud = 0;
129 int use_pal = 0;
130
131 mixspeed = DSP_SPEED;
132
133 if (argc < 2)
134 { help();
135 exit(1);
136 }
137
138 parm_setup(argc,argv,"","SsBbQqNnLlGgPp","Ff");
139
140 if (read_parm(NON_FLAGGED, &filename, NULL) != 1)
141 {
142 help();
143 printf("No executable filename found!\n");
144 exit(1);
145 }
146
147 if (read_parm('S',NULL,NULL))
148 stereo=1;
149 else
150 stereo=0;
151 if (read_parm('B',NULL,NULL))
152 bit16=1;
153 else
154 bit16=0;
155 if (read_parm('Q',NULL,NULL))
156 quiet=1;
157 else
158 quiet=0;
159 if (read_parm('N',NULL,NULL))
160 loop_mod = 0;
161 else
162 loop_mod = 1;
163 if (read_parm('L',NULL,NULL))
164 loud = 1;
165 else
166 loud = 0;
167 #ifdef GUS
168 if (read_parm('G',NULL,NULL))
169 use_gus = 0;
170 else
171 use_gus = 1;
172 #endif /* GUS */
173 if (read_parm('P',NULL,NULL))
174 use_pal = 1;
175 else
176 use_pal = 0;
177
178
179 #ifdef SIXTEEN_BIT_PLAY_ONLY
180 bit16 = 1;
181 #endif /* SIXTEEN_BIT_PLAY_ONLY */
182
183 if (read_parm('F',NULL,&frequency))
184 {
185 mixspeed = (frequency);
186 if ((mixspeed < 8000) || (mixspeed > 44100))
187 { help();
188 printf("Invalid Frequency: %ld",frequency);
189 exit(1);
190 }
191 }
192
193 if (use_pal)
194 { options.def_tempo = DEF_TEMPO_PAL;
195 options.def_bpm = DEF_BPM_PAL;
196 }
197 else
198 { options.def_tempo = DEF_TEMPO_NTSC;
199 options.def_bpm = DEF_BPM_NTSC;
200 }
201
202
203 get_audio_device();
204
205 if (load_s3m(filename,&mod,quiet))
206 if (load_mod(filename,&mod,quiet))
207 {
208 printf("File is not a valid mod or s3m!\n");
209 exit(1);
210 }
211
212
213
214 if (!quiet)
215 {
216
217 if (gus_dev==-1)
218 printf("Playing \"%s\"\nAt rate %d, %d bits, %s, blocksize %d\n",
219 filename,
220 mixspeed,
221 bit16 ? 16 : 8,
222 stereo ? "stereo" : "mono",
223 audio_buffer_size);
224
225 else {
226 #ifdef GUS
227 printf("GUS (ALPHA support) Playing \"%s\" \n",filename);
228 printf("Using %d of %d bytes of GUS RAM\n",
229 (gus_total_mem - gus_mem_free(gus_dev)),
230 (gus_total_mem));
231 #else
232 printf("GUS support not compiled in...\n");
233 exit(1);
234 #endif /* GUS */
235 }
236
237
238 }
239
240
241 if (gus_dev!=-1) {
242 #ifdef GUS
243 play_mod_gus(loud);
244 #else
245 printf("GUS support not compiled in...\n");
246 exit(1);
247 #endif
248 } else {
249 play_mod(loud);
250 }
251
252 close_dsp_device();
253 free(audio_start_buffer);
254 return 0;
255 }
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272