Mercurial > hg > dmlib
annotate minijss/jloadxm.c @ 1158:31bc984b7cd4
Rename a function.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Mar 2015 07:00:02 +0200 |
parents | e13269e17422 |
children | 29dc9337fa11 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Fast Tracker ][ (XM) module loader | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
1125 | 4 * (C) Copyright 2006-2015 Tecnic Software productions (TNSP) |
0 | 5 * |
6 * TO DO: | |
7 * - Add support for 1.02/1.03 XM-format versions. | |
8 * (Not very useful, but if it's not too hard, then do it) | |
9 */ | |
10 #include "jssmod.h" | |
11 #include <string.h> | |
12 | |
13 | |
14 /* XM value limit definitions | |
15 */ | |
16 #define XM_MaxChannels (32) | |
17 #define XM_MaxPatterns (256) | |
18 #define XM_MaxOrders (255) | |
19 #define XM_MaxInstruments (128) | |
20 #define XM_MaxInstSamples (16) | |
21 #define XM_MaxEnvPoints (12) | |
22 #define XM_MaxNotes (96) | |
23 #define XM_MaxSampleVolume (64) | |
24 | |
25 | |
26 /* XM format structures | |
27 */ | |
28 typedef struct | |
29 { | |
30 char idMagic[17]; // XM header ID "Extended Module: " | |
31 char songName[20]; // Module song name | |
32 Uint8 unUsed1A; // ALWAYS 0x1a | |
33 char trackerName[20]; // ID-string of tracker software | |
34 Uint16 version; // XM-version 0x0104 | |
35 Uint32 headSize; // Module header size, FROM THIS POINT! | |
36 Uint16 norders, // Number of orders | |
37 defRestartPos, // Default song restart position | |
38 nchannels, // Number of channels | |
39 npatterns, // Number of patterns | |
40 ninstruments, // Number of instruments | |
552
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
41 flags, // Module flags: |
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
42 // bit0: 0 = Amiga frequency table |
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
43 // 1 = Linear frequency table |
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
44 // |
0 | 45 defSpeed, // Default speed |
46 defTempo; // Default tempo | |
47 Uint8 orderList[256]; // Order list | |
48 } XMHeader; | |
49 | |
50 | |
51 typedef struct | |
52 { | |
53 Uint32 headSize; // Instrument header size (see docs!) | |
54 char instName[22]; // Name/description | |
55 Uint8 instType; // Type | |
56 Uint16 nsamples; // Number of samples | |
57 } XMInstrument1; | |
58 | |
59 | |
60 typedef struct | |
61 { | |
62 Uint16 frame, value; | |
552
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
63 } XMEnvPoint; |
0 | 64 |
65 | |
66 typedef struct | |
67 { | |
68 Uint8 flags, npoints, sustain, loopS, loopE; | |
552
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
69 XMEnvPoint points[XM_MaxEnvPoints]; |
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
70 } XMEnvelope; |
0 | 71 |
72 | |
73 typedef struct | |
74 { | |
75 Uint32 headSize; // Header size | |
76 Uint8 sNumForNotes[XM_MaxNotes]; // Sample numbers for notes | |
552
d4cee32e7050
Rename internal structures, cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents:
313
diff
changeset
|
77 XMEnvelope volumeEnv, panningEnv; |
0 | 78 Uint8 vibratoType, vibratoSweep, vibratoDepth, vibratoRate; |
79 | |
80 Uint16 fadeOut, ARESERVED; | |
81 } XMInstrument2; | |
82 | |
83 | |
84 typedef struct | |
85 { | |
86 Uint32 size, loopS, loopL; | |
87 Uint8 volume; | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
88 Sint8 fineTune; |
0 | 89 Uint8 type, panning; |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
90 Sint8 relNote; |
0 | 91 Uint8 ARESERVED; |
92 char sampleName[22]; | |
93 } XMSample; | |
94 | |
95 | |
96 typedef struct | |
97 { | |
98 Uint32 headSize; | |
99 Uint8 packing; | |
100 Uint16 nrows, size; | |
101 } XMPattern; | |
102 | |
103 | |
104 | |
105 /* Unpack XM-format pattern from file-stream into JSS-pattern structure | |
106 */ | |
1148 | 107 #define JSGETBYTE(XV) \ |
108 do { \ | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
109 size--; \ |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
110 if (size < 0) \ |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
111 JSSERROR(DMERR_OUT_OF_DATA, DMERR_OUT_OF_DATA, \ |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
112 "Unexpected end of packed pattern data.\n"); \ |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
113 XV = dmfgetc(inFile); \ |
0 | 114 } while (0) |
115 | |
116 | |
1148 | 117 /* Convert XM note value to internal JSS note |
118 */ | |
313
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
119 static int jssXMConvertNote(int val) |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
120 { |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
121 if (val < 1 || val > 97) |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
122 return jsetNotSet; |
1148 | 123 else |
124 if (val == 97) | |
313
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
125 return jsetNoteOff; |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
126 else |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
127 return val - 1; |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
128 } |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
129 |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
130 |
1148 | 131 /* Unpack a XM pattern structure from resource to given JSS pattern |
132 */ | |
0 | 133 static int jssXMUnpackPattern(DMResource *inFile, int size, JSSPattern *pattern) |
134 { | |
135 int packb, row, channel, tmp; | |
136 JSSNote *pnote; | |
137 assert(pattern != NULL); | |
138 | |
139 pnote = pattern->data; | |
140 | |
313
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
141 for (row = 0; row < pattern->nrows && size > 0; row++) |
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
142 for (channel = 0; channel < pattern->nchannels && size > 0; channel++) |
0 | 143 { |
144 JSGETBYTE(packb); | |
145 if (packb & 0x80) | |
146 { | |
147 if (packb & 0x01) | |
148 { | |
149 // PACK 0x01: Read note | |
150 JSGETBYTE(tmp); | |
313
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
151 pnote->note = jssXMConvertNote(tmp); |
0 | 152 } |
153 | |
154 if (packb & 0x02) | |
155 { | |
156 // PACK 0x02: Read instrument | |
157 JSGETBYTE(tmp); | |
158 pnote->instrument = (tmp > 0) ? tmp - 1 : jsetNotSet; | |
159 } | |
160 | |
161 if (packb & 0x04) | |
162 { | |
163 // PACK 0x04: Read volume | |
164 JSGETBYTE(tmp); | |
165 pnote->volume = (tmp >= 0x10) ? tmp - 0x10 : jsetNotSet; | |
166 } | |
167 | |
168 if (packb & 0x08) | |
169 { | |
170 // PACK 0x08: Read effect | |
171 JSGETBYTE(pnote->effect); | |
172 pnote->param = 0; | |
173 } | |
174 | |
175 if (packb & 0x10) | |
176 { | |
177 // PACK 0x10: Read effect parameter | |
178 JSGETBYTE(pnote->param); | |
179 if (pnote->effect == jsetNotSet && pnote->param != 0) | |
180 pnote->effect = 0; | |
181 } | |
182 } | |
183 else | |
184 { | |
185 // All data available | |
313
a89500f26dde
Cleanup the pattern decoder a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
186 pnote->note = jssXMConvertNote(packb & 0x7f); |
0 | 187 |
188 // Get instrument | |
189 JSGETBYTE(tmp); | |
190 pnote->instrument = (tmp > 0) ? tmp - 1 : jsetNotSet; | |
191 | |
192 // Get volume | |
193 JSGETBYTE(tmp); | |
194 pnote->volume = (tmp >= 0x10) ? tmp - 0x10 : jsetNotSet; | |
195 | |
196 // Get effect | |
197 JSGETBYTE(pnote->effect); | |
198 | |
199 // Get parameter | |
200 JSGETBYTE(pnote->param); | |
201 if (pnote->effect == 0 && pnote->param == 0) | |
202 pnote->effect = pnote->param = jsetNotSet; | |
203 } | |
204 pnote++; | |
205 } | |
206 | |
207 // Check the state | |
208 if (size > 0) | |
209 { | |
210 // Some data left unparsed | |
211 JSSWARNING(DMERR_EXTRA_DATA, DMERR_EXTRA_DATA, | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
212 "Unparsed data after pattern (%d bytes), possibly broken file.\n", size); |
0 | 213 } |
214 | |
215 return DMERR_OK; | |
216 } | |
217 | |
218 | |
219 /* Convert XM envelope structure to JSS envelope structure | |
220 */ | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
221 static int jssXMConvertEnvelope(JSSEnvelope * dst, XMEnvelope * src, const char * name, const int ninstr) |
0 | 222 { |
223 int i; | |
1148 | 224 (void) name; |
225 (void) ninstr; | |
0 | 226 |
227 // Convert envelope points | |
228 for (i = 0; i < XM_MaxEnvPoints; i++) | |
229 { | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
230 dst->points[i].frame = src->points[i].frame; |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
231 dst->points[i].value = src->points[i].value; |
0 | 232 } |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1126
diff
changeset
|
233 |
0 | 234 // Convert other values |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
235 dst->npoints = src->npoints; |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
236 dst->sustain = src->sustain; |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
237 dst->loopS = src->loopS; |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
238 dst->loopE = src->loopE; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1126
diff
changeset
|
239 |
0 | 240 // Check if the envelope is used |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
241 if (src->flags & 0x01) |
0 | 242 { |
243 // Convert envelope flags | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
244 dst->flags = jenvfUsed; |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
245 if (src->flags & 0x02) |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
246 dst->flags |= jenvfSustain; |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
247 |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
248 if (src->flags & 0x04) |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
249 dst->flags |= jenvfLooped; |
0 | 250 |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
251 if (src->flags & 0xf0) |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
252 { |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
253 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
254 "Inst#%d/%s-env: Uses unsupported flags values, 0x%02x.\n", |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
255 ninstr, name, src->flags); |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
256 } |
0 | 257 |
258 // Check other values | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
259 if (src->npoints > XM_MaxEnvPoints) |
0 | 260 { |
261 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
262 "Inst#%d/%s-env: nPoints > MAX, possibly broken file.\n", |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
263 ninstr, name); |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
264 dst->npoints = XM_MaxEnvPoints; |
0 | 265 } |
266 | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
267 if ((dst->flags & jenvfSustain) && src->sustain > src->npoints) |
0 | 268 { |
269 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
270 "Inst#%d/%s-env: iSustain > nPoints (%d > %d), possibly broken file.\n", |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
271 ninstr, name, src->sustain, src->npoints); |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
272 dst->sustain = src->npoints; |
0 | 273 } |
274 | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
275 if ((dst->flags & jenvfLooped) && src->loopE > src->npoints) |
0 | 276 { |
277 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
278 "Inst#%d/%s-env: loopE > nPoints (%d > %d), possibly broken file.\n", |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
279 ninstr, name, src->loopE, src->npoints); |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
280 dst->loopE = src->npoints; |
0 | 281 } |
282 | |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
283 if ((dst->flags & jenvfLooped) && src->loopS > src->loopE) |
0 | 284 { |
285 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
286 "Inst#%d/%s-env: loopS > loopE (%d > %d), possibly broken file.\n", |
1149
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
287 ninstr, name, src->loopS, src->loopE); |
f5edb39a8db1
Rename some function arguments for clarity. One letter variable names are
Matti Hamalainen <ccr@tnsp.org>
parents:
1148
diff
changeset
|
288 dst->loopS = src->loopE; |
0 | 289 } |
290 } | |
291 | |
292 return DMERR_OK; | |
293 } | |
294 | |
295 | |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
296 static int jssXMLoadInstrument(DMResource *inFile, JSSModule *module, int ninst, int nsample, int *xmConvTable) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
297 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
298 XMSample xmS; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
299 JSSInstrument *inst; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
300 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
301 // Read header data |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
302 if (!dmf_read_le32(inFile, &xmS.size) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
303 !dmf_read_le32(inFile, &xmS.loopS) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
304 !dmf_read_le32(inFile, &xmS.loopL) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
305 !dmf_read_byte(inFile, &xmS.volume) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
306 !dmf_read_byte(inFile, (Uint8 *) &xmS.fineTune) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
307 !dmf_read_byte(inFile, &xmS.type) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
308 !dmf_read_byte(inFile, &xmS.panning) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
309 !dmf_read_byte(inFile, (Uint8 *) &xmS.relNote) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
310 !dmf_read_byte(inFile, &xmS.ARESERVED) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
311 !dmf_read_str(inFile, &xmS.sampleName, sizeof(xmS.sampleName))) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
312 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
313 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
314 "Error reading instrument sample header #%d/%d [%d]", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
315 ninst, nsample, module->ninstruments); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
316 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
317 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
318 if (xmS.size <= 0) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
319 return DMERR_OK; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
320 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
321 // Allocate sample instrument |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
322 JSSDEBUG("Allocating sample #%d/%d [%d]\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
323 ninst, nsample, module->ninstruments); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
324 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
325 xmConvTable[nsample] = module->ninstruments; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
326 inst = module->instruments[module->ninstruments] = jssAllocateInstrument(); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
327 if (inst == NULL) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
328 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
329 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
330 "Could not allocate sample #%d/%d [%d]\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
331 ninst, nsample, module->ninstruments); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
332 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
333 module->ninstruments++; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
334 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
335 // Copy values |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
336 if (xmS.volume > XM_MaxSampleVolume) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
337 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
338 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
339 "Samp #%d/%d: volume > MAX\n", ninst, nsample); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
340 xmS.volume = XM_MaxSampleVolume; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
341 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
342 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
343 inst->volume = xmS.volume; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
344 inst->ERelNote = xmS.relNote; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
345 inst->EFineTune = xmS.fineTune; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
346 inst->EPanning = xmS.panning; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
347 #ifndef JSS_LIGHT |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
348 inst->desc = jssASCIItoStr(xmS.sampleName, 0, sizeof(xmS.sampleName)); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
349 #endif |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
350 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
351 // Convert flags |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
352 switch (xmS.type & 0x03) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
353 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
354 case 0: inst->flags = 0; break; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
355 case 1: inst->flags = jsfLooped; break; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
356 case 2: inst->flags = jsfLooped | jsfBiDi; break; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
357 default: |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
358 inst->flags = 0; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
359 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
360 "Samp #%d/%d: Invalid sample type 0x%x\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
361 ninst, nsample, xmS.type); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
362 break; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
363 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
364 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
365 if (xmS.type & 0x10) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
366 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
367 // 16-bit sample |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
368 JSFSET(inst->flags, jsf16bit); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
369 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
370 inst->size = xmS.size / sizeof(Uint16); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
371 inst->loopS = xmS.loopS / sizeof(Uint16); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
372 inst->loopE = ((xmS.loopS + xmS.loopL) / sizeof(Uint16)); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
373 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
374 else |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
375 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
376 // 8-bit sample |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
377 inst->size = xmS.size; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
378 inst->loopS = xmS.loopS; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
379 inst->loopE = (xmS.loopS + xmS.loopL); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
380 } |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1126
diff
changeset
|
381 |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
382 if (xmS.loopL == 0) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
383 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
384 // Always unset loop, if loop length is zero |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
385 JSFUNSET(inst->flags, jsfLooped); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
386 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
387 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
388 if (inst->flags & jsfLooped) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
389 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
390 if (inst->loopS >= inst->size) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
391 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
392 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
393 "Samp #%d/%d: loopS >= size (%d >= %d)\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
394 ninst, nsample, inst->loopS, inst->size); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
395 JSFUNSET(inst->flags, jsfLooped); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
396 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
397 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
398 if (inst->loopE > inst->size) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
399 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
400 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
401 "Samp #%d/%d: loopE > size (%d > %d)\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
402 ninst, nsample, inst->loopE, inst->size); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
403 JSFUNSET(inst->flags, jsfLooped); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
404 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
405 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
406 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
407 return DMERR_OK; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
408 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
409 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
410 |
1158 | 411 static int jssXMLoadSampleData(DMResource *inFile, JSSInstrument *inst, int ninst, int nsample) |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
412 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
413 int ret; |
1157
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
414 size_t bsize; |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
415 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
416 JSSDEBUG("desc....: '%s'\n" |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
417 "size....: %d\n" |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
418 "loopS...: %d\n" |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
419 "loopE...: %d\n" |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
420 "volume..: %d\n" |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
421 "flags...: %x\n", |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
422 inst->desc, |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
423 inst->size, inst->loopS, inst->loopE, |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
424 inst->volume, inst->flags); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
425 |
1157
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
426 // Allocate memory for sample data |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
427 bsize = (inst->flags & jsf16bit) ? sizeof(Uint16) : sizeof(Uint8); |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
428 bsize *= inst->size; |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
429 |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
430 if ((inst->data = dmMalloc(bsize)) == NULL) |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
431 { |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
432 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
433 "Could not allocate %d bytes of sample data for instrument/sample #%d/%d.\n", |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
434 bsize, ninst, nsample); |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
435 } |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
436 |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
437 // Read sampledata |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
438 if (dmfread(inst->data, sizeof(Uint8), bsize, inFile) != bsize) |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
439 { |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
440 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
441 "Error reading sample data for instrument #%d/%d, %d bytes.\n", |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
442 ninst, nsample, bsize); |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
443 } |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
444 |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
445 // Convert the sample data |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
446 if (inst->flags & jsf16bit) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
447 { |
1157
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
448 ret = jssDecodeSample16( |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
449 (Uint16 *) inst->data, inst->size, |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
450 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
451 (jsampDelta | jsampSwapEndianess) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
452 #else |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
453 (jsampDelta) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
454 #endif |
1157
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
455 ); |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
456 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
457 else |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
458 { |
1157
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
459 ret = jssDecodeSample8( |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
460 (Uint8 *) inst->data, inst->size, |
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
461 (jsampDelta | jsampFlipSign)); |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
462 } |
1157
e13269e17422
Clean up the sample data loading a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1149
diff
changeset
|
463 return ret; |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
464 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
465 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
466 |
1132 | 467 static BOOL jssXMLoadEnvelopePoints(DMResource *inFile, XMEnvelope *env) |
1131
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
468 { |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
469 int i; |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
470 for (i = 0; i < XM_MaxEnvPoints; i++) |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
471 { |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
472 if (!dmf_read_le16(inFile, &(env->points[i].frame)) || |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
473 !dmf_read_le16(inFile, &(env->points[i].value))) |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
474 return FALSE; |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
475 } |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
476 return TRUE; |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
477 } |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
478 |
b349646f19a0
Split envelope reading to tiny helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1130
diff
changeset
|
479 |
1132 | 480 static BOOL jssXMLoadEnvelopeData(DMResource *inFile, XMEnvelope *env) |
481 { | |
482 return | |
483 dmf_read_byte(inFile, &(env->sustain)) && | |
484 dmf_read_byte(inFile, &(env->loopS)) && | |
485 dmf_read_byte(inFile, &(env->loopE)); | |
486 } | |
487 | |
488 | |
0 | 489 /* Load XM-format extended instrument from file-stream into JSS module's given inst |
490 */ | |
491 static int jssXMLoadExtInstrument(DMResource *inFile, int ninst, JSSModule *module) | |
492 { | |
493 XMInstrument1 xmI1; | |
1126 | 494 off_t remainder, pos = dmftell(inFile); |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
495 int xmConvTable[XM_MaxInstruments + 1]; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
496 JSSExtInstrument *pEInst; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
497 XMInstrument2 xmI2; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
498 int i, nsample, ret; |
0 | 499 |
500 // Get instrument header #1 | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
501 if (!dmf_read_le32(inFile, &xmI1.headSize) || |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
502 !dmf_read_str(inFile, &xmI1.instName, sizeof(xmI1.instName)) || |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
503 !dmf_read_byte(inFile, &xmI1.instType) || |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
504 !dmf_read_le16(inFile, &xmI1.nsamples)) |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
505 return DMERR_FREAD; |
0 | 506 |
507 // If there are samples, there is header #2 | |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
508 if (xmI1.nsamples == 0) |
0 | 509 { |
510 // We may STILL need to skip extra data after 1st instr. header | |
511 remainder = xmI1.headSize - (dmftell(inFile) - pos); | |
512 if (remainder > 0) | |
513 { | |
98 | 514 JSSDEBUG("xmI1#2 Skipping: %li\n", remainder); |
0 | 515 dmfseek(inFile, remainder, SEEK_CUR); |
516 } | |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
517 return DMERR_OK; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
518 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
519 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
520 // Allocate instrument |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
521 if ((pEInst = jssAllocateExtInstrument()) == NULL) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
522 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
523 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
524 "Could not allocate extended instrument structure #%d\n", ninst); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
525 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
526 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
527 module->extInstruments[ninst] = pEInst; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
528 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
529 // Get instrument header #2 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
530 if (!dmf_read_le32(inFile, &xmI2.headSize) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
531 !dmf_read_str(inFile, &xmI2.sNumForNotes, sizeof(xmI2.sNumForNotes))) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
532 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
533 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
1132 | 534 "Could not read secondary instrument header part #1 for #%d.\n", ninst); |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
535 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
536 |
1132 | 537 if (!jssXMLoadEnvelopePoints(inFile, &xmI2.volumeEnv) || |
538 !jssXMLoadEnvelopePoints(inFile, &xmI2.panningEnv)) | |
539 { | |
540 JSSERROR(DMERR_FREAD, DMERR_FREAD, | |
541 "Could not read envelope point data for instrument #%d.\n", ninst); | |
542 } | |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
543 |
1132 | 544 if (!dmf_read_byte(inFile, &xmI2.volumeEnv.npoints) || |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
545 !dmf_read_byte(inFile, &xmI2.panningEnv.npoints) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
546 |
1132 | 547 !jssXMLoadEnvelopeData(inFile, &xmI2.volumeEnv) || |
548 !jssXMLoadEnvelopeData(inFile, &xmI2.panningEnv) || | |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
549 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
550 !dmf_read_byte(inFile, &xmI2.volumeEnv.flags) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
551 !dmf_read_byte(inFile, &xmI2.panningEnv.flags) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
552 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
553 !dmf_read_byte(inFile, &xmI2.vibratoType) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
554 !dmf_read_byte(inFile, &xmI2.vibratoSweep) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
555 !dmf_read_byte(inFile, &xmI2.vibratoDepth) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
556 !dmf_read_byte(inFile, &xmI2.vibratoRate) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
557 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
558 !dmf_read_le16(inFile, &xmI2.fadeOut) || |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
559 !dmf_read_le16(inFile, &xmI2.ARESERVED)) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
560 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
561 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
1132 | 562 "Could not read secondary instrument header part #2 for #%d.\n", ninst); |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
563 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
564 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
565 // Skip the extra data after header #2 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
566 remainder = xmI1.headSize - (dmftell(inFile) - pos); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
567 if (remainder > 0) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
568 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
569 JSSDEBUG("xmI1#1 Skipping: %li\n", remainder); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
570 dmfseek(inFile, remainder, SEEK_CUR); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
571 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
572 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
573 // Check and convert all ext instrument information |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
574 #ifndef JSS_LIGHT |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
575 pEInst->desc = jssASCIItoStr(xmI1.instName, 0, sizeof(xmI1.instName)); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
576 #endif |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
577 jssXMConvertEnvelope(&pEInst->volumeEnv, &xmI2.volumeEnv, "vol", ninst); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
578 jssXMConvertEnvelope(&pEInst->panningEnv, &xmI2.panningEnv, "pan", ninst); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
579 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
580 switch (xmI2.vibratoType) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
581 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
582 case 0: pEInst->vibratoType = jvibSine; break; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
583 case 1: pEInst->vibratoType = jvibRamp; break; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
584 case 2: pEInst->vibratoType = jvibSquare; break; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
585 case 3: pEInst->vibratoType = jvibRandom; break; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
586 default: |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
587 pEInst->vibratoType = jvibSine; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
588 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
589 "Invalid extinstrument vibrato type %d for inst #%d\n", ninst); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
590 break; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
591 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
592 pEInst->vibratoSweep = xmI2.vibratoSweep; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
593 pEInst->vibratoDepth = xmI2.vibratoDepth; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
594 pEInst->vibratoRate = xmI2.vibratoRate; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
595 pEInst->fadeOut = xmI2.fadeOut; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
596 pEInst->nsamples = xmI1.nsamples; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
597 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
598 // Initialize the SNumForNotes conversion table |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
599 for (i = 0; i < XM_MaxInstruments; i++) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
600 xmConvTable[i] = jsetNotSet; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
601 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
602 // Read sample headers |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
603 for (nsample = 0; nsample < xmI1.nsamples; nsample++) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
604 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
605 if ((ret = jssXMLoadInstrument(inFile, module, ninst, nsample, xmConvTable)) != DMERR_OK) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
606 return ret; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
607 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
608 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
609 // Read sample data |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
610 for (nsample = 0; nsample < xmI1.nsamples; nsample++) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
611 if (xmConvTable[nsample] != jsetNotSet) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
612 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
613 JSSInstrument *inst = module->instruments[xmConvTable[nsample]]; |
1158 | 614 if ((ret = jssXMLoadSampleData(inFile, inst, ninst, nsample)) != DMERR_OK) |
1130
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
615 return ret; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
616 } |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
617 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
618 |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
619 // Apply new values to sNumForNotes values |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
620 for (i = 0; i < XM_MaxNotes; i++) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
621 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
622 int tmp = xmI2.sNumForNotes[i]; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
623 if (tmp >= 0 && tmp < xmI1.nsamples) |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
624 pEInst->sNumForNotes[i] = xmConvTable[tmp]; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
625 else |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
626 { |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
627 pEInst->sNumForNotes[i] = jsetNotSet; |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
628 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
629 "Ext.instrument #%d sNumForNotes[%d] out of range (%d).\n", |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
630 ninst, i, tmp); |
725e7caa43a0
Split instrument sample data loading to another function in XM loader.
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
631 } |
0 | 632 } |
633 | |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
634 return DMERR_OK; |
0 | 635 } |
636 | |
637 | |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
638 static int jssXMLoadPatterns(DMResource *inFile, JSSModule *module, XMHeader *xmH) |
0 | 639 { |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
640 int index, result; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
641 XMPattern xmP; |
0 | 642 |
643 for (index = 0; index < module->npatterns; index++) | |
644 { | |
645 // Get the pattern header | |
1126 | 646 off_t remainder, pos = dmftell(inFile); |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1126
diff
changeset
|
647 |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
648 if (!dmf_read_le32(inFile, &xmP.headSize) || |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
649 !dmf_read_byte(inFile, &xmP.packing) || |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
650 !dmf_read_le16(inFile, &xmP.nrows) || |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
651 !dmf_read_le16(inFile, &xmP.size)) |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
652 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
653 "Could not read pattern header data #%d.\n", |
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
654 index); |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1126
diff
changeset
|
655 |
0 | 656 |
657 // Check the header | |
658 if (xmP.packing != 0) | |
659 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
660 "Pattern #%d packing type unsupported (%d)\n", |
0 | 661 index, xmP.packing); |
662 | |
663 if (xmP.nrows == 0) | |
664 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
665 "Pattern #%d has %d rows, invalid data.\n", |
0 | 666 index, xmP.nrows); |
667 | |
668 if (xmP.size > 0) | |
669 { | |
670 // Allocate and unpack pattern | |
671 module->patterns[index] = jssAllocatePattern(xmP.nrows, module->nchannels); | |
672 if (module->patterns[index] == NULL) | |
673 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
674 "Could not allocate memory for pattern #%d\n", index); |
0 | 675 |
676 result = jssXMUnpackPattern(inFile, xmP.size, module->patterns[index]); | |
677 if (result != 0) | |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
678 JSSERROR(result, result, "Error in unpacking pattern #%d data\n", index); |
0 | 679 } |
680 | |
681 // Skip extra data (if the file is damaged) | |
88 | 682 remainder = xmP.headSize - (dmftell(inFile) - pos); |
683 if (remainder > 0) | |
0 | 684 { |
98 | 685 JSSDEBUG("xmP Skipping: %li\n", remainder); |
88 | 686 dmfseek(inFile, remainder, SEEK_CUR); |
0 | 687 } |
688 } | |
689 | |
690 // Allocate the empty pattern | |
691 module->patterns[jsetMaxPatterns] = jssAllocatePattern(64, module->nchannels); | |
692 | |
693 /* Convert song orders list by replacing nonexisting patterns | |
694 * with pattern number jsetMaxPatterns. | |
695 */ | |
696 for (index = 0; index < module->norders; index++) | |
697 { | |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
698 int tmp = xmH->orderList[index]; |
1126 | 699 if (tmp >= module->npatterns || |
700 module->patterns[tmp] == NULL) | |
0 | 701 tmp = jsetMaxPatterns; |
702 | |
703 module->orderList[index] = tmp; | |
704 } | |
705 | |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
706 return DMERR_OK; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
707 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
708 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
709 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
710 static int jssXMLoadInstruments(DMResource *inFile, JSSModule *module) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
711 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
712 int index; |
0 | 713 for (index = 0; index < module->nextInstruments; index++) |
714 { | |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
715 int result = jssXMLoadExtInstrument(inFile, index, module); |
0 | 716 if (result != 0) |
778
a4cf7716ba58
Clean up the XM module loader a bit, add more error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
658
diff
changeset
|
717 JSSERROR(result, result, "Errors while reading instrument #%d\n", index); |
0 | 718 } |
1124
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
719 return DMERR_OK; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
720 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
721 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
722 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
723 /* Load XM-format module from given file-stream |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
724 */ |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
725 int jssLoadXM(DMResource *inFile, JSSModule **ppModule, BOOL probe) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
726 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
727 JSSModule *module; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
728 XMHeader xmH; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
729 int index, result; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
730 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
731 assert(ppModule != NULL); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
732 assert(inFile != NULL); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
733 *ppModule = NULL; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
734 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
735 // Try to get the XM-header |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
736 if (!dmf_read_str(inFile, &xmH.idMagic, sizeof(xmH.idMagic)) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
737 !dmf_read_str(inFile, &xmH.songName, sizeof(xmH.songName)) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
738 !dmf_read_byte(inFile, &xmH.unUsed1A) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
739 !dmf_read_str(inFile, &xmH.trackerName, sizeof(xmH.trackerName)) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
740 !dmf_read_le16(inFile, &xmH.version) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
741 !dmf_read_le32(inFile, &xmH.headSize) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
742 !dmf_read_le16(inFile, &xmH.norders) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
743 !dmf_read_le16(inFile, &xmH.defRestartPos) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
744 !dmf_read_le16(inFile, &xmH.nchannels) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
745 !dmf_read_le16(inFile, &xmH.npatterns) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
746 !dmf_read_le16(inFile, &xmH.ninstruments) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
747 !dmf_read_le16(inFile, &xmH.flags) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
748 !dmf_read_le16(inFile, &xmH.defSpeed) || |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
749 !dmf_read_le16(inFile, &xmH.defTempo)) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
750 return DMERR_FREAD; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
751 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
752 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
753 // Check the fields, none of these are considered fatal |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
754 if (strncmp(xmH.idMagic, "Extended Module: ", 17) != 0) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
755 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
756 if (probe) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
757 return DMERR_NOT_SUPPORTED; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
758 else |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
759 JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
760 "Not a FT2 Extended Module (XM), header signature mismatch!\n"); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
761 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
762 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
763 if (xmH.unUsed1A != 0x1a) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
764 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
765 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
766 "Possibly modified or corrupted XM [%x]\n", xmH.unUsed1A); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
767 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
768 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
769 if (xmH.norders > XM_MaxOrders) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
770 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
771 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
772 "Number of orders %d > %d, possibly broken module.\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
773 xmH.norders, XM_MaxOrders); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
774 xmH.norders = XM_MaxOrders; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
775 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
776 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
777 if (xmH.norders == 0) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
778 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
779 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
780 "Number of orders was zero.\n"); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
781 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
782 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
783 if (xmH.npatterns > XM_MaxPatterns) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
784 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
785 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
786 "Number of patterns %d > %d, possibly broken module.\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
787 xmH.npatterns, XM_MaxPatterns); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
788 xmH.npatterns = XM_MaxPatterns; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
789 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
790 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
791 if (xmH.npatterns == 0) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
792 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
793 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
794 "Number of patterns was zero.\n"); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
795 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
796 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
797 if (xmH.nchannels <= 0 || xmH.nchannels > XM_MaxChannels) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
798 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
799 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
800 "Number of channels was invalid, %d (should be 1 - %d).\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
801 xmH.nchannels, XM_MaxChannels); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
802 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
803 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
804 if (xmH.ninstruments <= 0 || xmH.ninstruments > XM_MaxInstruments) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
805 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
806 JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
807 "Number of instruments was invalid, %d (should be 1 - %d).\n", |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
808 xmH.ninstruments, XM_MaxInstruments); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
809 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
810 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
811 if (!dmf_read_str(inFile, &xmH.orderList, sizeof(xmH.orderList))) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
812 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
813 JSSERROR(DMERR_FREAD, DMERR_FREAD, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
814 "Error reading pattern order list.\n"); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
815 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
816 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
817 /* Okay, allocate a module structure |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
818 */ |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
819 module = jssAllocateModule(); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
820 if (module == NULL) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
821 { |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
822 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
823 "Could not allocate memory for module structure.\n"); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
824 } |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
825 *ppModule = module; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
826 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
827 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
828 // Convert and check the header data |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
829 module->moduleType = jmdtXM; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
830 module->intVersion = xmH.version; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
831 #ifndef JSS_LIGHT |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
832 module->moduleName = jssASCIItoStr(xmH.songName, 0, sizeof(xmH.songName)); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
833 module->trackerName = jssASCIItoStr(xmH.trackerName, 0, sizeof(xmH.trackerName)); |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
834 #endif |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
835 module->defSpeed = xmH.defSpeed; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
836 module->defTempo = xmH.defTempo; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
837 module->nextInstruments = xmH.ninstruments; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
838 module->ninstruments = 0; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
839 module->npatterns = xmH.npatterns; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
840 module->norders = xmH.norders; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
841 module->nchannels = xmH.nchannels; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
842 module->defFlags = jmdfStereo | jmdfFT2Replay; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
843 module->defRestartPos = xmH.defRestartPos; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
844 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
845 if ((xmH.flags & 1) == 0) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
846 module->defFlags |= jmdfAmigaPeriods; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
847 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
848 // Setup the default pannings |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
849 for (index = 0; index < jsetNChannels; index++) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
850 module->defPanning[index] = jchPanMiddle; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
851 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
852 // Load rest of the module |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
853 if ((result = jssXMLoadPatterns(inFile, module, &xmH)) != DMERR_OK) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
854 return result; |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
855 |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
856 if ((result = jssXMLoadInstruments(inFile, module)) != DMERR_OK) |
b8bfd9fbe1d9
Modularize the XM loader somewhat by splitting to more functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
857 return result; |
0 | 858 |
859 return DMERR_OK; | |
860 } |