annotate playercode/mloader.c @ 20:0e9afd6bdaf0

Don't know why this file was here :)
author darius
date Fri, 24 Apr 1998 01:24:55 +0000
parents 5d614bcc4287
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1 /*
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
2
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
3 Name: MLOADER.C
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
4
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
5 Description:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
6 These routines are used to access the available module loaders
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
7
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
8 Portability:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
9 All systems - all compilers
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
10
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
11 */
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
12
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
13 #include <string.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
14 #include "mikmod.h"
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
15
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
16
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
17 FILE *modfp;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
18 UNIMOD of;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
19
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
20 static MLOADER *firstloader = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
21
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
22 UWORD finetune[16] =
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
23 { 8363, 8413, 8463, 8529, 8581, 8651, 8723, 8757,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
24 7895, 7941, 7985, 8046, 8107, 8169, 8232, 8280
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
25 };
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
26
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
27
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
28 void ML_InfoLoader(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
29 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
30 int t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
31 MLOADER *l;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
32
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
33 // list all registered devicedrivers:
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
34
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
35 for(t=1,l=firstloader; l!=NULL; l=l->next, t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
36 printf("%d. %s\n",t,l->version);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
37 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
38
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
39
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
40 void ML_RegisterLoader(MLOADER *ldr)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
41 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
42 MLOADER *cruise = firstloader;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
43
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
44 if(cruise!=NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
45 { while(cruise->next!=NULL) cruise = cruise->next;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
46 cruise->next = ldr;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
47 } else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
48 firstloader = ldr;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
49 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
50
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
51
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
52 BOOL ReadComment(UWORD len)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
53 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
54 //int t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
55
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
56 if(len)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
57 { if(!(of.comment=(CHAR *)_mm_malloc(len+1))) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
58 fread(of.comment,len,1,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
59 of.comment[len] = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
60 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
61 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
62 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
63
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
64
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
65 BOOL AllocPositions(int total)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
66 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
67 if((of.positions = _mm_calloc(total,sizeof(UWORD))) == NULL) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
68 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
69 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
70
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
71
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
72 BOOL AllocPatterns(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
73 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
74 int s,t,tracks = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
75
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
76 // Allocate track sequencing array
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
77
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
78 if(!(of.patterns = (UWORD *)_mm_calloc((ULONG)(of.numpat+1)*of.numchn,sizeof(UWORD)))) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
79 if(!(of.pattrows = (UWORD *)_mm_calloc(of.numpat+1,sizeof(UWORD)))) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
80
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
81 for(t=0; t<of.numpat+1; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
82 { of.pattrows[t] = 64;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
83 for(s=0; s<of.numchn; s++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
84 of.patterns[(t*of.numchn)+s] = tracks++;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
85 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
86
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
87 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
88 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
89
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
90
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
91 BOOL AllocTracks(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
92 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
93 if(!(of.tracks=(UBYTE **)_mm_calloc(of.numtrk,sizeof(UBYTE *)))) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
94 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
95 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
96
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
97
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
98 BOOL AllocInstruments(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
99 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
100 int t,n;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
101
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
102 if((of.instruments=(INSTRUMENT *)_mm_calloc(of.numins,sizeof(INSTRUMENT)))==NULL) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
103
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
104 for(t=0; t<of.numins; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
105 { for(n=0; n<120; n++) // Init note / sample lookup table
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
106 { of.instruments[t].samplenote[n] = n;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
107 of.instruments[t].samplenumber[n] = t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
108 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
109 of.instruments[t].globvol = 64;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
110 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
111 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
112 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
113
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
114
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
115 BOOL AllocSamples(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
116 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
117 UWORD u;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
118
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
119 if((of.samples = (SAMPLE *)_mm_calloc(of.numsmp,sizeof(SAMPLE)))==NULL) return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
120
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
121 for(u=0; u<of.numsmp; u++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
122 { of.samples[u].panning = 128;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
123 of.samples[u].handle = -1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
124 of.samples[u].globvol = 64;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
125 of.samples[u].volume = 64;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
126 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
127 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
128 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
129
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
130
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
131 BOOL ML_LoadSamples(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
132 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
133 SAMPLE *s;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
134 int u;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
135
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
136 for(u=of.numsmp, s=of.samples; u; u--, s++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
137 if(s->length) SL_RegisterSample(s,MD_MUSIC,modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
138
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
139 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
140 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
141
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
142
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
143 CHAR *DupStr(CHAR *s, UWORD len)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
144 // Creates a CSTR out of a character buffer of 'len' bytes, but strips
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
145 // any terminating non-printing characters like 0, spaces etc.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
146 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
147 UWORD t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
148 CHAR *d = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
149
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
150 // Scan for first printing char in buffer [includes high ascii up to 254]
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
151 while(len)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
152 { if(s[len-1] > 0x20) break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
153 len--;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
154 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
155
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
156 // When the buffer wasn't completely empty, allocate
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
157 // a cstring and copy the buffer into that string, except
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
158 // for any control-chars
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
159
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
160 #ifdef __GNUC__
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
161 if(len<16) len = 16;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
162 #endif
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
163
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
164 if((d=(CHAR *)_mm_malloc(len+1)) != NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
165 { for(t=0; t<len; t++) d[t] = (s[t]<32) ? ' ' : s[t];
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
166 d[t] = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
167 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
168
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
169 return d;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
170 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
171
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
172
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
173 static void ML_XFreeSample(SAMPLE *s)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
174 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
175 if(s->handle>=0)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
176 MD_SampleUnLoad(s->handle);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
177 if(s->samplename!=NULL) free(s->samplename);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
178 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
179
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
180
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
181 static void ML_XFreeInstrument(INSTRUMENT *i)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
182 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
183 if(i->insname!=NULL) free(i->insname);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
184 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
185
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
186
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
187 static void ML_FreeEx(UNIMOD *mf)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
188 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
189 UWORD t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
190
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
191 if(mf->songname!=NULL) free(mf->songname);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
192 if(mf->composer!=NULL) free(mf->composer);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
193 if(mf->comment!=NULL) free(mf->comment);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
194
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
195 if(mf->modtype!=NULL) free(mf->modtype);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
196 if(mf->positions!=NULL) free(mf->positions);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
197 if(mf->patterns!=NULL) free(mf->patterns);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
198 if(mf->pattrows!=NULL) free(mf->pattrows);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
199
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
200 if(mf->tracks!=NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
201 { for(t=0; t<mf->numtrk; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
202 if(mf->tracks[t]!=NULL) free(mf->tracks[t]);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
203 free(mf->tracks);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
204 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
205
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
206 if(mf->instruments != NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
207 { for(t=0; t<mf->numins; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
208 ML_XFreeInstrument(&mf->instruments[t]);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
209 free(mf->instruments);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
210 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
211
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
212 if(mf->samples != NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
213 { for(t=0; t<mf->numsmp; t++)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
214 if(mf->samples[t].length) ML_XFreeSample(&mf->samples[t]);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
215 free(mf->samples);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
216 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
217
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
218 memset(mf,0,sizeof(UNIMOD));
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
219 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
220
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
221
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
222 static UNIMOD *ML_AllocUniMod(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
223 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
224 UNIMOD *mf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
225
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
226 if((mf=_mm_calloc(1,sizeof(UNIMOD))) == NULL) return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
227 return mf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
228 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
229
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
230
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
231 /******************************************
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
232
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
233 Next are the user-callable functions
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
234
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
235 ******************************************/
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
236
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
237
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
238 void MikMod_FreeSong(UNIMOD *mf)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
239 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
240 if(mf!=NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
241 { Player_Exit(mf);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
242 ML_FreeEx(mf);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
243 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
244 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
245
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
246
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
247 CHAR *MikMod_LoadSongTitle(CHAR *filename)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
248 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
249 MLOADER *l;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
250 CHAR *retval;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
251 FILE *fp;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
252
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
253 if((fp = _mm_fopen(filename,"rb"))==NULL) return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
254
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
255 _mm_errno = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
256 _mm_critical = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
257 _mm_iobase_setcur(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
258
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
259 // Try to find a loader that recognizes the module
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
260
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
261 for(l=firstloader; l!=NULL; l=l->next)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
262 { _mm_rewind(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
263 if(l->Test()) break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
264 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
265
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
266 if(l==NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
267 { _mm_errno = MMERR_NOT_A_MODULE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
268 _mm_iobase_revert();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
269 if(_mm_errorhandler!=NULL) _mm_errorhandler();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
270 return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
271 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
272
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
273 retval = l->LoadTitle();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
274
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
275 fclose(fp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
276 return(retval);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
277 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
278
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
279
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
280 UNIMOD *MikMod_LoadSongFP(FILE *fp, int maxchan)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
281
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
282 // Loads a module given a file pointer.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
283 // File is loaded from the current file seek position.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
284
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
285 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
286 int t;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
287 MLOADER *l;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
288 BOOL ok;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
289 UNIMOD *mf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
290
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
291 modfp = fp;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
292 _mm_errno = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
293 _mm_critical = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
294
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
295 _mm_iobase_setcur(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
296
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
297 // Try to find a loader that recognizes the module
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
298
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
299 for(l=firstloader; l!=NULL; l=l->next)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
300 { _mm_rewind(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
301 if(l->Test()) break;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
302 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
303
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
304 if(l==NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
305 { _mm_errno = MMERR_NOT_A_MODULE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
306 _mm_iobase_revert();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
307 if(_mm_errorhandler!=NULL) _mm_errorhandler();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
308 return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
309 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
310
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
311 // init unitrk routines
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
312 if(!UniInit())
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
313 { if(_mm_errorhandler!=NULL) _mm_errorhandler();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
314 return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
315 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
316
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
317 // load the song using the song's loader variable
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
318 memset(&of,0,sizeof(UNIMOD));
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
319 of.initvolume = 128;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
320
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
321 // init panning array
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
322 for(t=0; t<64; t++) of.panning[t] = ((t+1)&2) ? 255 : 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
323 for(t=0; t<64; t++) of.chanvol[t] = 64;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
324
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
325 // init module loader and load the header / patterns
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
326 if(l->Init())
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
327 { _mm_rewind(modfp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
328 ok = l->Load();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
329 } else ok = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
330
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
331 // free loader and unitrk allocations
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
332 l->Cleanup();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
333 UniCleanup();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
334
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
335 if(!ok)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
336 { ML_FreeEx(&of);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
337 _mm_iobase_revert();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
338 if(_mm_errorhandler!=NULL) _mm_errorhandler();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
339 return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
340 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
341
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
342 if(!ML_LoadSamples())
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
343 { ML_FreeEx(&of);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
344 _mm_iobase_revert();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
345 if(_mm_errorhandler!=NULL) _mm_errorhandler();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
346 return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
347 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
348
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
349 if((mf=ML_AllocUniMod()) == NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
350 { ML_FreeEx(&of);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
351 _mm_iobase_revert();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
352 if(_mm_errorhandler!=NULL) _mm_errorhandler();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
353 return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
354 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
355
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
356 // Copy the static UNIMOD contents into the dynamic UNIMOD struct.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
357 memcpy(mf,&of,sizeof(UNIMOD));
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
358
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
359 _mm_iobase_revert();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
360
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
361 if(maxchan > 0)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
362 { if(!(mf->flags & UF_NNA) && (mf->numchn < maxchan))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
363 maxchan = mf->numchn;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
364 else if((mf->numvoices!=0) && mf->numvoices < maxchan)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
365 maxchan = mf->numvoices;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
366
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
367 if(maxchan < mf->numchn) mf->flags |= UF_NNA;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
368
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
369 if(MikMod_SetNumVoices(maxchan,-1))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
370 { MikMod_FreeSong(mf);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
371 return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
372 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
373 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
374
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
375 return mf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
376 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
377
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
378
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
379 UNIMOD *MikMod_LoadSong(CHAR *filename, int maxchan)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
380
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
381 // Open a module via it's filename. The loader will initialize the specified
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
382 // song-player 'player'.
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
383
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
384 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
385 FILE *fp;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
386 UNIMOD *mf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
387
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
388 if((fp = _mm_fopen(filename,"rb"))==NULL) return NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
389 if((mf = MikMod_LoadSongFP(fp, maxchan)) != NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
390 { if(SL_LoadSamples() || Player_Init(mf))
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
391 { MikMod_FreeSong(mf);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
392 mf = NULL;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
393 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
394 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
395
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
396 fclose(fp);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
397 return mf;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
398 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
399