Mercurial > hg > dmlib
annotate tools/xm2jss.c @ 1241:5e2b90e3e4bc
Fix hasData handling and include dmfile.h header.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 07 Mar 2015 14:29:29 +0200 |
parents | 8b6ed580e800 |
children | e44a2b7abe07 |
rev | line source |
---|---|
0 | 1 /* |
2 * xm2jss - Convert XM module to JSSMOD | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2006-2009 Tecnic Software productions (TNSP) | |
5 * | |
6 * Please read file 'COPYING' for information on license and distribution. | |
7 */ | |
8 #include <stdio.h> | |
9 #include <errno.h> | |
10 #include "jss.h" | |
11 #include "jssmod.h" | |
184
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
12 #include "jssplr.h" |
0 | 13 #include "dmlib.h" |
14 #include "dmargs.h" | |
15 #include "dmres.h" | |
1241
5e2b90e3e4bc
Fix hasData handling and include dmfile.h header.
Matti Hamalainen <ccr@tnsp.org>
parents:
1237
diff
changeset
|
16 #include "dmfile.h" |
285
245b15cd1919
Don't link libSDL uselessly to utilities that do not actually use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
17 #include "dmmutex.h" |
245b15cd1919
Don't link libSDL uselessly to utilities that do not actually use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
202
diff
changeset
|
18 |
0 | 19 |
184
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
20 #define jmpNMODEffectTable (36) |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
21 static const char jmpMODEffectTable[jmpNMODEffectTable] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
1099 | 22 #define JM_SAMPLE_MODE_MASK (jsampFlipSign | jsampSwapEndianess | jsampSplit | jsampDelta) |
184
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
23 |
0 | 24 |
300 | 25 char *optInFilename = NULL, *optOutFilename = NULL; |
0 | 26 BOOL optIgnoreErrors = FALSE, |
27 optStripExtInstr = FALSE, | |
28 optStripInstr = FALSE, | |
29 optStripSamples = FALSE, | |
30 optOptimize = FALSE; | |
31 | |
32 int optPatternMode = PATMODE_COMP_HORIZ, | |
33 optSampMode16 = jsampDelta, | |
34 optSampMode8 = jsampFlipSign | jsampDelta; | |
35 | |
36 | |
37 static const char* patModeTable[PATMODE_LAST] = | |
38 { | |
39 "Raw horizontal", | |
40 "Compressed horizontal (similar to XM modules)", | |
41 "Raw vertical", | |
42 "Compressed vertical", | |
43 "Raw vertical for each element", | |
44 }; | |
45 | |
46 | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
856
diff
changeset
|
47 static const DMOptArg optList[] = |
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
856
diff
changeset
|
48 { |
0 | 49 { 0, '?', "help", "Show this help", OPT_NONE }, |
337 | 50 { 1, 'v', "verbose", "Be more verbose", OPT_NONE }, |
51 { 2, 'i', "ignore", "Ignore errors", OPT_NONE }, | |
52 { 3, 'p', "patterns", "Pattern storage mode", OPT_ARGREQ }, | |
53 { 4, 'E', "strip-ext-instr","Strip ext. instruments (implies -I -S)", OPT_NONE }, | |
54 { 5, 'I', "strip-instr", "Strip instruments (implies -S)", OPT_NONE }, | |
55 { 6, 'S', "strip-samples", "Strip instr. sampledata", OPT_NONE }, | |
0 | 56 { 7, '8', "smode8", "8-bit sample conversion flags", OPT_ARGREQ }, |
57 { 8, '1', "smode16", "16-bit sample conversion flags", OPT_ARGREQ }, | |
337 | 58 { 9, 'O', "optimize", "Optimize module", OPT_NONE }, |
0 | 59 }; |
60 | |
61 const int optListN = sizeof(optList) / sizeof(optList[0]); | |
62 | |
63 | |
64 void argShowHelp() | |
65 { | |
66 int i; | |
67 | |
337 | 68 dmPrintBanner(stdout, dmProgName, "[options] <input.xm> <output.jmod>"); |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
856
diff
changeset
|
69 dmArgsPrintHelp(stdout, optList, optListN, 0); |
0 | 70 |
71 printf("\n" | |
72 "Pattern storage modes:\n"); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
73 |
0 | 74 for (i = 1; i < PATMODE_LAST; i++) |
75 printf(" %d = %s\n", i, patModeTable[i-1]); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
76 |
0 | 77 printf( |
78 "\n" | |
79 "Sample data conversion flags (summative):\n" | |
80 " 1 = Delta encoding (DEF 8 & 16)\n" | |
81 " 2 = Flip signedness (DEF 8)\n" | |
82 " 4 = Swap endianess (affects 16-bit only)\n" | |
83 " 8 = Split and de-interleave hi/lo bytes (affects 16-bit only)\n" | |
84 "\n" | |
85 ); | |
86 } | |
87 | |
88 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) | |
89 { | |
90 (void) optArg; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
91 |
0 | 92 switch (optN) |
93 { | |
94 case 0: | |
95 argShowHelp(); | |
96 exit(0); | |
97 break; | |
98 | |
99 case 1: | |
337 | 100 dmVerbosity++; |
101 break; | |
102 | |
103 case 2: | |
0 | 104 optIgnoreErrors = TRUE; |
105 break; | |
106 | |
337 | 107 case 3: |
0 | 108 optPatternMode = atoi(optArg); |
109 if (optPatternMode <= 0 || optPatternMode >= PATMODE_LAST) | |
110 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
111 dmErrorMsg("Unknown pattern conversion mode %d\n", optPatternMode); |
0 | 112 return FALSE; |
113 } | |
114 break; | |
115 | |
337 | 116 case 4: optStripExtInstr = TRUE; break; |
117 case 5: optStripInstr = TRUE; break; | |
118 case 6: optStripSamples = TRUE; break; | |
119 | |
1099 | 120 case 7: optSampMode8 = atoi(optArg) & JM_SAMPLE_MODE_MASK; break; |
121 case 8: optSampMode16 = atoi(optArg) & JM_SAMPLE_MODE_MASK; break; | |
0 | 122 |
337 | 123 case 9: optOptimize = TRUE; break; |
0 | 124 |
125 default: | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
126 dmErrorMsg("Unknown argument '%s'.\n", currArg); |
0 | 127 return FALSE; |
128 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
129 |
0 | 130 return TRUE; |
131 } | |
132 | |
133 | |
134 BOOL argHandleFile(char *currArg) | |
135 { | |
136 // Was not option argument | |
300 | 137 if (!optInFilename) |
138 optInFilename = currArg; | |
337 | 139 else |
300 | 140 if (!optOutFilename) |
141 optOutFilename = currArg; | |
0 | 142 else |
143 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
144 dmErrorMsg("Too many filename arguments specified, '%s'.\n", currArg); |
0 | 145 return FALSE; |
146 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
147 |
0 | 148 return TRUE; |
149 } | |
150 | |
151 | |
152 /* These functions and the macro mess are meant to make the | |
153 * conversion routines themselves clearer and simpler. | |
154 */ | |
155 BOOL jsPutByte(Uint8 *patBuf, size_t patBufSize, size_t *npatBuf, Uint8 val) | |
156 { | |
157 if (*npatBuf >= patBufSize) | |
158 return FALSE; | |
159 else | |
160 { | |
161 patBuf[*npatBuf] = val; | |
162 (*npatBuf)++; | |
163 return TRUE; | |
164 } | |
165 } | |
166 | |
167 #define JSPUTBYTE(x) do { if (!jsPutByte(patBuf, patBufSize, patSize, x)) return DMERR_BOUNDS; } while (0) | |
168 | |
169 #define JSCOMP(x,z) do { if ((x) != jsetNotSet) { qflags |= (z); qcomp++; } } while (0) | |
170 | |
171 #define JSCOMPPUT(xf,xv,qv) do { \ | |
172 if (qflags & (xf)) { \ | |
173 if ((xv) < 0 || (xv) > 255) \ | |
174 JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, \ | |
175 "%s value out of bounds %d.\n", qv, (xv)); \ | |
176 JSPUTBYTE(xv); \ | |
177 } \ | |
178 } while (0) | |
179 | |
180 #define JSCONVPUT(xv,qv) do { \ | |
181 if ((xv) != jsetNotSet) { \ | |
182 if ((xv) < 0 || (xv) > 254) \ | |
183 JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, \ | |
184 "%s value out of bounds %d.\n", qv, (xv)); \ | |
185 JSPUTBYTE((xv) + 1); \ | |
186 } else { \ | |
187 JSPUTBYTE(0); \ | |
188 } \ | |
189 } while (0) | |
190 | |
191 | |
192 /* Convert a note | |
193 */ | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
194 static int jssConvertNote( |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
195 Uint8 *patBuf, const size_t patBufSize, |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
196 size_t *patSize, const JSSNote *pnote) |
0 | 197 { |
198 Uint8 tmp; | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
199 if (pnote->note == jsetNotSet) |
0 | 200 tmp = 0; |
1194 | 201 else |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
202 if (pnote->note == jsetNoteOff) |
0 | 203 tmp = 127; |
204 else | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
205 tmp = pnote->note + 1; |
0 | 206 |
207 if (tmp > 0x7f) | |
208 JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, "Note value out of bounds %d > 0x7f.\n", tmp); | |
209 | |
210 JSPUTBYTE(tmp & 0x7f); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
211 |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
212 JSCONVPUT(pnote->instrument, "Instrument"); |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
213 JSCONVPUT(pnote->volume, "Volume"); |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
214 JSCONVPUT(pnote->effect, "Effect"); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
215 |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
216 tmp = (pnote->param != jsetNotSet) ? pnote->param : 0; |
0 | 217 JSPUTBYTE(tmp); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
218 |
0 | 219 return DMERR_OK; |
220 } | |
221 | |
222 | |
223 /* Compress a note | |
224 */ | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
225 static int jssCompressNote( |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
226 Uint8 *patBuf, const size_t patBufSize, |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
227 size_t *patSize, const JSSNote *pnote) |
0 | 228 { |
229 Uint8 qflags = 0; | |
230 int qcomp = 0; | |
1201 | 231 |
232 // Determine what would get stored, | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
233 // aka actually how much space we use |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
234 JSCOMP(pnote->note, JM_COMP_NOTE); |
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
235 JSCOMP(pnote->instrument, JM_COMP_INSTRUMENT); |
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
236 JSCOMP(pnote->volume, JM_COMP_VOLUME); |
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
237 JSCOMP(pnote->effect, JM_COMP_EFFECT); |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
238 if (pnote->param != jsetNotSet && pnote->param != 0) |
0 | 239 { |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
240 qflags |= JM_COMP_PARAM; |
0 | 241 qcomp++; |
242 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
243 |
0 | 244 if (qcomp < 4) |
245 { | |
1201 | 246 // Okay, it's less than 4 bytes, so use compressed |
0 | 247 JSPUTBYTE(qflags | 0x80); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
248 |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
249 if (pnote->note != jsetNotSet) |
0 | 250 { |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
251 Uint8 tmp = (pnote->note != jsetNoteOff) ? pnote->note : 127; |
0 | 252 if (tmp > 0x7f) |
253 JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, "Note value out of bounds %d > 0x7f.\n", tmp); | |
254 JSPUTBYTE(tmp); | |
255 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
256 |
1210
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
257 JSCOMPPUT(JM_COMP_INSTRUMENT, pnote->instrument, "Instrument"); |
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
258 JSCOMPPUT(JM_COMP_VOLUME, pnote->volume, "Volume"); |
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
259 JSCOMPPUT(JM_COMP_EFFECT, pnote->effect, "Effect"); |
6b48bad13399
Rename pattern note packing flag COMP_* constants to JM_COMP_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1209
diff
changeset
|
260 JSCOMPPUT(JM_COMP_PARAM, pnote->param, "Param"); |
1201 | 261 } |
262 else | |
263 { | |
264 // Was 4 bytes or more, just dump it all in .. | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
265 return jssConvertNote(patBuf, patBufSize, patSize, pnote); |
1201 | 266 } |
267 | |
0 | 268 return DMERR_OK; |
269 } | |
270 | |
271 | |
272 /* Compress pattern | |
273 */ | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
274 static int jssConvertPatternCompHoriz( |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
275 Uint8 *patBuf, const size_t patBufSize, |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
276 size_t *patSize, const JSSPattern *pattern) |
0 | 277 { |
278 int row, channel; | |
279 *patSize = 0; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
280 |
0 | 281 for (row = 0; row < pattern->nrows; row++) |
282 for (channel = 0; channel < pattern->nchannels; channel++) | |
283 { | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
284 const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel]; |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
285 const int res = jssCompressNote(patBuf, patBufSize, patSize, pnote); |
0 | 286 if (res != DMERR_OK) |
287 { | |
288 JSSERROR(res, res, "Note compression failed [patBuf=%p, patBufSize=%d, patSize=%d, row=%d, chn=%d]\n", | |
289 patBuf, patBufSize, *patSize, row, channel); | |
290 return res; | |
291 } | |
292 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
293 |
0 | 294 return DMERR_OK; |
295 } | |
296 | |
297 | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
298 static int jssConvertPatternCompVert( |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
299 Uint8 *patBuf, const size_t patBufSize, |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
300 size_t *patSize, const JSSPattern *pattern) |
0 | 301 { |
302 int row, channel; | |
303 *patSize = 0; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
304 |
0 | 305 for (channel = 0; channel < pattern->nchannels; channel++) |
306 for (row = 0; row < pattern->nrows; row++) | |
307 { | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
308 const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel]; |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
309 const int res = jssCompressNote(patBuf, patBufSize, patSize, pnote); |
0 | 310 if (res != DMERR_OK) |
311 { | |
312 JSSERROR(res, res, "Note compression failed [patBuf=%p, patBufSize=%d, patSize=%d, row=%d, chn=%d]\n", | |
313 patBuf, patBufSize, *patSize, row, channel); | |
314 return res; | |
315 } | |
316 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
317 |
0 | 318 return DMERR_OK; |
319 } | |
320 | |
321 | |
322 /* Convert a pattern | |
323 */ | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
324 static int jssConvertPatternRawHoriz( |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
325 Uint8 *patBuf, const size_t patBufSize, |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
326 size_t *patSize, const JSSPattern *pattern) |
0 | 327 { |
328 int row, channel; | |
329 *patSize = 0; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
330 |
0 | 331 for (row = 0; row < pattern->nrows; row++) |
332 for (channel = 0; channel < pattern->nchannels; channel++) | |
333 { | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
334 const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel]; |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
335 const int res = jssConvertNote(patBuf, patBufSize, patSize, pnote); |
0 | 336 if (res != DMERR_OK) |
337 { | |
338 JSSERROR(res, res, "Note conversion failed [patBuf=%p, patBufSize=%d, patSize=%d, row=%d, chn=%d]\n", | |
339 patBuf, patBufSize, *patSize, row, channel); | |
340 return res; | |
341 } | |
342 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
343 |
0 | 344 return DMERR_OK; |
345 } | |
346 | |
347 | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
348 static int jssConvertPatternRawVert( |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
349 Uint8 *patBuf, const size_t patBufSize, |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
350 size_t *patSize, const JSSPattern *pattern) |
0 | 351 { |
352 int row, channel; | |
353 *patSize = 0; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
354 |
0 | 355 for (channel = 0; channel < pattern->nchannels; channel++) |
356 for (row = 0; row < pattern->nrows; row++) | |
357 { | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
358 const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel]; |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
359 const int res = jssConvertNote(patBuf, patBufSize, patSize, pnote); |
0 | 360 if (res != DMERR_OK) |
361 { | |
362 JSSERROR(res, res, "Note conversion failed [patBuf=%p, patBufSize=%d, patSize=%d, row=%d, chn=%d]\n", | |
363 patBuf, patBufSize, *patSize, row, channel); | |
364 return res; | |
365 } | |
366 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
367 |
0 | 368 return DMERR_OK; |
369 } | |
370 | |
371 | |
372 #define JSFOREACHNOTE1 \ | |
373 for (channel = 0; channel < pattern->nchannels; channel++) \ | |
374 for (row = 0; row < pattern->nrows; row++) { \ | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
375 const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel]; |
0 | 376 |
377 #define JSFOREACHNOTE2 } | |
378 | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
379 static int jssConvertPatternRawElem( |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
380 Uint8 *patBuf, const size_t patBufSize, |
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
381 size_t *patSize, const JSSPattern *pattern) |
0 | 382 { |
383 Uint8 tmp; | |
384 int row, channel; | |
385 *patSize = 0; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
386 |
0 | 387 JSFOREACHNOTE1; |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
388 if (pnote->note == jsetNotSet) |
0 | 389 tmp = 0; |
1194 | 390 else |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
391 if (pnote->note == jsetNoteOff) |
0 | 392 tmp = 127; |
393 else | |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
394 tmp = pnote->note + 1; |
1194 | 395 |
0 | 396 if (tmp > 0x7f) |
397 JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, "Note value out of bounds %d > 0x7f.\n", tmp); | |
1194 | 398 |
0 | 399 JSPUTBYTE(tmp); |
400 JSFOREACHNOTE2; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
401 |
0 | 402 JSFOREACHNOTE1; |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
403 JSCONVPUT(pnote->instrument, "Instrument"); |
0 | 404 JSFOREACHNOTE2; |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
405 |
0 | 406 JSFOREACHNOTE1; |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
407 JSCONVPUT(pnote->volume, "Volume"); |
0 | 408 JSFOREACHNOTE2; |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
409 |
0 | 410 JSFOREACHNOTE1; |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
411 JSCONVPUT(pnote->effect, "Effect"); |
0 | 412 JSFOREACHNOTE2; |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
413 |
0 | 414 JSFOREACHNOTE1; |
1207
59b5821b5cf9
Rename function arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
1201
diff
changeset
|
415 tmp = (pnote->param != jsetNotSet) ? pnote->param : 0; |
338
cd57ba1130eb
Fixes and improvements in the JMOD saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
416 JSPUTBYTE(tmp); |
0 | 417 JSFOREACHNOTE2; |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
418 |
0 | 419 return DMERR_OK; |
420 } | |
421 | |
422 #undef JSFOREACHNOTE1 | |
423 #undef JSFOREACHNOTE2 | |
424 | |
425 | |
426 static void jssCopyEnvelope(JSSMODEnvelope *je, JSSEnvelope *e) | |
427 { | |
428 int i; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
429 |
0 | 430 je->flags = e->flags; |
431 je->npoints = e->npoints; | |
432 je->sustain = e->sustain; | |
433 je->loopS = e->loopS; | |
434 je->loopE = e->loopE; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
435 |
0 | 436 for (i = 0; i < e->npoints; i++) |
437 { | |
438 je->points[i].frame = e->points[i].frame; | |
439 je->points[i].value = e->points[i].value; | |
440 } | |
441 } | |
442 | |
443 | |
444 /* Save a JSSMOD file | |
445 */ | |
446 int jssSaveJSSMOD(FILE *outFile, JSSModule *m, int patMode, int flags8, int flags16) | |
447 { | |
448 JSSMODHeader jssH; | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
449 int i, pattern, order, instr, totalSize; |
0 | 450 const size_t patBufSize = 64*1024; // 64kB pattern buffer |
451 Uint8 *patBuf; | |
452 | |
453 // Check the module | |
454 if (m == NULL) | |
455 JSSERROR(DMERR_NULLPTR, DMERR_NULLPTR, "Module pointer was NULL\n"); | |
456 | |
1233 | 457 if (m->nchannels < 1 || m->npatterns < 1 || m->norders < 1 || |
458 m->nchannels > jsetMaxChannels || | |
459 m->npatterns > jsetMaxPatterns || | |
460 m->norders > jsetMaxOrders) | |
0 | 461 JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
462 "Module had invalid values (nchannels=%d, npatterns=%d, norders=%d)\n", |
0 | 463 m->nchannels, m->npatterns, m->norders); |
464 | |
465 // Create the JSSMOD header | |
466 jssH.idMagic[0] = 'J'; | |
467 jssH.idMagic[1] = 'M'; | |
468 jssH.idVersion = JSSMOD_VERSION; | |
1231 | 469 jssH.defFlags = m->defFlags; |
470 jssH.intVersion = m->intVersion; | |
0 | 471 jssH.norders = m->norders; |
472 jssH.npatterns = m->npatterns; | |
473 jssH.nextInstruments = m->nextInstruments; | |
474 jssH.ninstruments = m->ninstruments; | |
475 jssH.defRestartPos = m->defRestartPos; | |
1231 | 476 |
477 jssH.nchannels = m->nchannels; | |
0 | 478 jssH.defSpeed = m->defSpeed; |
479 jssH.defTempo = m->defTempo; | |
480 jssH.patMode = patMode; | |
1209 | 481 |
0 | 482 // Write header |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
483 totalSize = sizeof(jssH); |
0 | 484 if (fwrite(&jssH, sizeof(jssH), 1, outFile) != 1) |
485 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, "Could not write JSSMOD header!\n"); | |
486 | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
487 dmMsg(1," * JSSMOD-header 0x%04x, %d bytes.\n", JSSMOD_VERSION, totalSize); |
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
488 |
0 | 489 // Write orders list |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
490 for (totalSize = order = 0; order < m->norders; order++) |
0 | 491 { |
1237
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
492 int tmp = m->orderList[order]; |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
493 if (tmp == jsetNotSet || tmp > m->npatterns) |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
494 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
495 "Orderlist entry #%d has invalid value %d.\n", |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
496 order, tmp); |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
497 |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
498 if (!dm_fwrite_le16(outFile, tmp)) |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
499 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
500 "Could not write JSSMOD orders list entry #%d (%d).\n", |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
501 order, tmp); |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
502 |
8b6ed580e800
Add sanity check to order list writing.
Matti Hamalainen <ccr@tnsp.org>
parents:
1235
diff
changeset
|
503 totalSize += sizeof(Uint16); |
0 | 504 } |
505 | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
506 dmMsg(1," * %d item orders list, %d bytes.\n", |
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
507 m->norders, totalSize); |
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
508 |
0 | 509 // Allocate pattern compression buffer |
510 if ((patBuf = dmMalloc(patBufSize)) == NULL) | |
511 JSSERROR(DMERR_MALLOC, DMERR_MALLOC, | |
512 "Error allocating memory for pattern compression buffer.\n"); | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
513 |
1232 | 514 // Convert and write patterns |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
515 for (totalSize = pattern = 0; pattern < m->npatterns; pattern++) |
0 | 516 { |
1232 | 517 JSSPattern *pat = m->patterns[pattern]; |
0 | 518 JSSMODPattern patHead; |
519 size_t finalSize = 0; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
520 |
1232 | 521 if (pat == NULL) |
522 JSSERROR(DMERR_NULLPTR, DMERR_NULLPTR, | |
523 "Pattern #%d was NULL.\n", pattern); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
524 |
1232 | 525 if (pat->nrows > jsetMaxRows) |
526 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
527 "Pattern #%d has %d rows > %d max.\n", | |
528 pattern, pat->nrows, jsetMaxRows); | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
529 |
0 | 530 switch (patMode) |
531 { | |
532 case PATMODE_RAW_HORIZ: | |
1232 | 533 i = jssConvertPatternRawHoriz(patBuf, patBufSize, &finalSize, pat); |
0 | 534 break; |
535 case PATMODE_COMP_HORIZ: | |
1232 | 536 i = jssConvertPatternCompHoriz(patBuf, patBufSize, &finalSize, pat); |
0 | 537 break; |
538 case PATMODE_RAW_VERT: | |
1232 | 539 i = jssConvertPatternRawVert(patBuf, patBufSize, &finalSize, pat); |
0 | 540 break; |
541 case PATMODE_COMP_VERT: | |
1232 | 542 i = jssConvertPatternCompVert(patBuf, patBufSize, &finalSize, pat); |
0 | 543 break; |
544 case PATMODE_RAW_ELEM: | |
1232 | 545 i = jssConvertPatternRawElem(patBuf, patBufSize, &finalSize, pat); |
0 | 546 break; |
547 default: | |
548 dmFree(patBuf); | |
549 JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, | |
550 "Unsupported pattern conversion mode %d.\n", patMode); | |
551 } | |
552 | |
553 if (i != DMERR_OK) | |
554 { | |
555 dmFree(patBuf); | |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
556 JSSERROR(i, i, "Error converting pattern data #%d\n", pattern); |
0 | 557 } |
1211 | 558 |
559 dmMsg(3, " - Pattern %d size %d bytes\n", pattern, finalSize); | |
1232 | 560 patHead.nrows = pat->nrows; |
1211 | 561 patHead.size = finalSize; |
562 totalSize += finalSize + sizeof(patHead); | |
0 | 563 |
1211 | 564 if (fwrite(&patHead, sizeof(patHead), 1, outFile) != 1) |
565 { | |
566 dmFree(patBuf); | |
567 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, | |
568 "Error writing pattern #%d header\n", pattern); | |
569 } | |
0 | 570 |
1211 | 571 if (fwrite(patBuf, sizeof(Uint8), finalSize, outFile) != finalSize) |
572 { | |
573 dmFree(patBuf); | |
574 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, | |
575 "Error writing pattern #%d data\n", pattern); | |
0 | 576 } |
577 } | |
578 dmFree(patBuf); | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
579 dmMsg(1," * %d patterns, %d bytes.\n", m->npatterns, totalSize); |
0 | 580 |
581 // Write extended instruments | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
582 for (totalSize = instr = 0; instr < m->nextInstruments; instr++) |
0 | 583 { |
584 JSSMODExtInstrument jssE; | |
585 JSSExtInstrument *einst = m->extInstruments[instr]; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
586 |
1167 | 587 dmMemset(&jssE, 0, sizeof(jssE)); |
0 | 588 |
589 if (einst) | |
590 { | |
591 // Create header | |
592 jssE.nsamples = einst->nsamples; | |
593 for (i = 0; i < jsetNNotes; i++) | |
594 { | |
595 int snum = einst->sNumForNotes[i]; | |
1118
de25e0f2b856
Fix sNumForNotes conversion/handling in JSSMOD loader and xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1116
diff
changeset
|
596 jssE.sNumForNotes[i] = (snum != jsetNotSet) ? snum + 1: 0; |
0 | 597 } |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
598 |
0 | 599 jssCopyEnvelope(&jssE.volumeEnv, &(einst->volumeEnv)); |
600 jssCopyEnvelope(&jssE.panningEnv, &(einst->panningEnv)); | |
601 jssE.vibratoType = einst->vibratoType; | |
602 jssE.vibratoSweep = einst->vibratoSweep; | |
603 jssE.vibratoDepth = einst->vibratoDepth; | |
604 jssE.fadeOut = einst->fadeOut; | |
605 } else | |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
606 JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR, "Extended instrument #%d NULL!\n", instr); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
607 |
0 | 608 // Write to file |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
609 totalSize += sizeof(jssE); |
0 | 610 if (fwrite(&jssE, sizeof(jssE), 1, outFile) != 1) |
611 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, | |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
612 "Could not write JSSMOD extended instrument #%d to file!\n", instr); |
0 | 613 } |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
614 dmMsg(1," * %d Extended Instruments, %d bytes.\n", m->nextInstruments, totalSize); |
0 | 615 |
616 | |
617 // Write sample instrument headers | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
618 for (totalSize = instr = 0; instr < m->ninstruments; instr++) |
0 | 619 { |
620 JSSMODInstrument jssI; | |
1115 | 621 JSSInstrument *inst = m->instruments[instr]; |
0 | 622 |
1167 | 623 dmMemset(&jssI, 0, sizeof(jssI)); |
0 | 624 |
625 // Create header | |
1115 | 626 if (inst != NULL) |
0 | 627 { |
1115 | 628 jssI.size = inst->size; |
629 jssI.loopS = inst->loopS; | |
630 jssI.loopE = inst->loopE; | |
631 jssI.volume = inst->volume; | |
632 jssI.flags = inst->flags; | |
633 jssI.C4BaseSpeed = inst->C4BaseSpeed; | |
634 jssI.ERelNote = inst->ERelNote; | |
635 jssI.EFineTune = inst->EFineTune; | |
636 jssI.EPanning = inst->EPanning; | |
637 jssI.convFlags = (inst->flags & jsf16bit) ? flags16 : flags8; | |
1241
5e2b90e3e4bc
Fix hasData handling and include dmfile.h header.
Matti Hamalainen <ccr@tnsp.org>
parents:
1237
diff
changeset
|
638 if (inst->data != NULL) |
5e2b90e3e4bc
Fix hasData handling and include dmfile.h header.
Matti Hamalainen <ccr@tnsp.org>
parents:
1237
diff
changeset
|
639 jssI.convFlags |= jsampHasData; |
0 | 640 } |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
641 else |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
642 JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR, "Instrument #%d NULL!\n", instr); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
643 |
0 | 644 // Write to file |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
645 totalSize += sizeof(jssI); |
0 | 646 if (fwrite(&jssI, sizeof(jssI), 1, outFile) != 1) |
647 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, | |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
648 "Could not write JSSMOD instrument #%d to file!\n", instr); |
0 | 649 } |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
650 dmMsg(1," * %d Instrument headers, %d bytes.\n", m->ninstruments, totalSize); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
651 |
0 | 652 // Write sample data |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
653 for (totalSize = instr = 0; instr < m->ninstruments; instr++) |
0 | 654 if (m->instruments[instr]) |
655 { | |
656 JSSInstrument *inst = m->instruments[instr]; | |
657 if (inst->data != NULL) | |
658 { | |
659 size_t res; | |
660 if (inst->flags & jsf16bit) | |
661 { | |
662 jssEncodeSample16(inst->data, inst->size, flags16); | |
663 res = fwrite(inst->data, sizeof(Uint16), inst->size, outFile); | |
664 } | |
665 else | |
666 { | |
667 jssEncodeSample8(inst->data, inst->size, flags8); | |
668 res = fwrite(inst->data, sizeof(Uint8), inst->size, outFile); | |
669 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
670 |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
671 totalSize += inst->size; |
86 | 672 if (res != (size_t) inst->size) |
0 | 673 JSSERROR(DMERR_FWRITE, DMERR_FWRITE, |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
674 "Could not write JSSMOD sample #%d to file!\n", instr); |
0 | 675 } |
676 } | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
677 dmMsg(1," * %d samples, %d bytes.\n", m->ninstruments, totalSize); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
678 |
0 | 679 return DMERR_OK; |
680 } | |
681 | |
682 | |
683 /* Optimize a given module | |
684 */ | |
685 JSSModule *optimizeModule(JSSModule *m) | |
686 { | |
687 BOOL usedPatterns[jsetMaxPatterns + 1], | |
688 usedInstruments[jsetMaxInstruments + 1], | |
689 usedExtInstruments[jsetMaxInstruments + 1]; | |
690 int mapExtInstruments[jsetMaxInstruments + 1], | |
691 mapInstruments[jsetMaxInstruments + 1], | |
692 mapPatterns[jsetMaxPatterns + 1]; | |
693 JSSModule *r = NULL; | |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
694 int i, n8, n16, unused; |
0 | 695 |
696 // Allocate a new module | |
697 if ((r = jssAllocateModule()) == NULL) | |
698 return NULL; | |
699 | |
700 // Copy things | |
701 r->moduleType = m->moduleType; | |
702 r->moduleName = dm_strdup(m->moduleName); | |
703 r->trackerName = dm_strdup(m->trackerName); | |
704 r->defSpeed = m->defSpeed; | |
705 r->defTempo = m->defTempo; | |
706 r->defFlags = m->defFlags; | |
707 r->defRestartPos = m->defRestartPos; | |
708 r->intVersion = m->intVersion; | |
709 r->nchannels = m->nchannels; | |
710 r->norders = m->norders; | |
711 for (i = 0; i < jsetNChannels; i++) | |
712 r->defPanning[i] = m->defPanning[i]; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
713 |
0 | 714 // Initialize values |
715 for (i = 0; i <= jsetMaxInstruments; i++) | |
716 { | |
717 usedExtInstruments[i] = FALSE; | |
798 | 718 usedInstruments[i] = FALSE; |
719 mapExtInstruments[i] = jsetNotSet; | |
720 mapInstruments[i] = jsetNotSet; | |
0 | 721 } |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
722 |
0 | 723 for (i = 0; i <= jsetMaxPatterns; i++) |
724 { | |
725 usedPatterns[i] = FALSE; | |
798 | 726 mapPatterns[i] = jsetNotSet; |
0 | 727 } |
728 | |
1094 | 729 // |
798 | 730 // Find out all actually used patterns and ext.instruments |
1100 | 731 // by going through all patterns specified in the order list |
1094 | 732 // |
0 | 733 for (i = 0; i < m->norders; i++) |
734 { | |
735 int pattern = m->orderList[i]; | |
736 if (pattern >= 0 && pattern < m->npatterns) | |
737 { | |
738 JSSPattern *p = m->patterns[pattern]; | |
739 if (p != NULL) | |
740 { | |
741 int row, channel; | |
742 JSSNote *n = p->data; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
743 |
1100 | 744 // Mark this pattern as used |
0 | 745 usedPatterns[pattern] = TRUE; |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
746 |
1100 | 747 // Check all notes in this pattern to see what instruments are used |
0 | 748 for (row = 0; row < p->nrows; row++) |
749 for (channel = 0; channel < p->nchannels; channel++, n++) | |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
750 if (n->instrument != jsetNotSet) |
0 | 751 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
752 if (n->instrument >= 0 && n->instrument < m->nextInstruments) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
753 usedExtInstruments[n->instrument] = TRUE; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
754 else |
0 | 755 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
756 dmMsg(2, "Pattern 0x%x, row=0x%x, chn=%d has invalid instrument 0x%x\n", |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
757 pattern, row, channel, n->instrument + 1); |
0 | 758 } |
759 } | |
760 } | |
761 else | |
762 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
763 dmErrorMsg("Pattern 0x%x is used on order 0x%x, but has no data!\n", |
1094 | 764 pattern, i); |
807
d83dc7e47076
Fix some order list and pattern handling things.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
765 |
d83dc7e47076
Fix some order list and pattern handling things.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
766 // Fix it. |
d83dc7e47076
Fix some order list and pattern handling things.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
767 m->orderList[i] = jsetMaxPatterns; |
0 | 768 } |
769 } | |
770 else | |
771 if (pattern != jsetMaxPatterns) | |
772 { | |
1101 | 773 dmErrorMsg("Order 0x%x has invalid pattern number 0x%x, changing to empty!\n", |
1094 | 774 i, pattern); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
775 |
807
d83dc7e47076
Fix some order list and pattern handling things.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
776 // Fix it. |
d83dc7e47076
Fix some order list and pattern handling things.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
777 m->orderList[i] = jsetMaxPatterns; |
0 | 778 } |
779 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
780 |
1094 | 781 // |
1100 | 782 // Find used sample instruments |
1094 | 783 // |
1101 | 784 dmMsg(1, "Checking ext.instruments for used sample instruments...\n"); |
856
415cc781e127
Fix some brain farts in instrument remapping.
Matti Hamalainen <ccr@tnsp.org>
parents:
807
diff
changeset
|
785 for (i = 0; i < jsetMaxInstruments; i++) |
0 | 786 if (usedExtInstruments[i] && m->extInstruments[i] != NULL) |
787 { | |
788 int note; | |
789 JSSExtInstrument *e = m->extInstruments[i]; | |
1094 | 790 |
0 | 791 for (note = 0; note < jsetNNotes; note++) |
792 if (e->sNumForNotes[note] != jsetNotSet) | |
793 { | |
794 int q = e->sNumForNotes[note]; | |
795 if (q >= 0 && q < m->ninstruments) | |
796 { | |
797 usedInstruments[q] = TRUE; | |
798 } | |
799 else | |
800 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
801 dmErrorMsg("Ext.instrument #%d sNumForNotes[%d] value out range (%d < %d).\n", |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
802 i + 1, m->ninstruments, q + 1); |
0 | 803 } |
804 } | |
805 } | |
1094 | 806 |
807 // | |
0 | 808 // Create pattern mappings |
1094 | 809 // |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
810 dmMsg(1, "Creating pattern remaps...\n"); |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
811 for (unused = i = 0; i <= jsetMaxPatterns; i++) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
812 if (usedPatterns[i]) |
0 | 813 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
814 JSSPattern *pat; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
815 |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
816 if (i >= m->npatterns) |
0 | 817 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
818 dmErrorMsg("Pattern 0x%x >= 0x%x, but used!\n", i, m->npatterns); |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
819 continue; |
0 | 820 } |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
821 |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
822 if ((pat = m->patterns[i]) == NULL) |
0 | 823 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
824 dmErrorMsg("Pattern 0x%x used but is NULL.\n", i); |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
825 continue; |
0 | 826 } |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
827 |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
828 mapPatterns[i] = r->npatterns; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
829 r->patterns[r->npatterns] = m->patterns[i]; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
830 (r->npatterns)++; |
0 | 831 } |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
832 else |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
833 if (m->patterns[i] != NULL) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
834 unused++; |
1094 | 835 |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
836 dmMsg(1, "%d used patterns (%d unused).\n", |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
837 r->npatterns, unused); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
838 |
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
839 |
1094 | 840 // |
0 | 841 // Re-map instruments |
1094 | 842 // |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
843 dmMsg(1, "Creating sample instrument remaps...\n"); |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
844 for (unused = n8 = n16 = i = 0; i < jsetMaxInstruments; i++) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
845 if (usedInstruments[i]) |
0 | 846 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
847 JSSInstrument *ip; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
848 if (optStripInstr) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
849 continue; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
850 |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
851 if (i >= m->ninstruments) |
0 | 852 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
853 dmErrorMsg("Instrument 0x%x >= 0x%x, but used!\n", |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
854 i + 1, m->ninstruments); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
855 continue; |
0 | 856 } |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
857 |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
858 if ((ip = m->instruments[i]) == NULL) |
0 | 859 { |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
860 dmErrorMsg("Instrument 0x%x used but is NULL.\n", i + 1); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
861 continue; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
862 } |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
863 |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
864 dmPrint(2, "%02x -> %02x : ", i + 1, r->ninstruments + 1); |
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
865 |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
866 mapInstruments[i] = r->ninstruments; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
867 r->instruments[r->ninstruments] = ip; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
868 (r->ninstruments)++; |
0 | 869 |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
870 if (ip->flags & jsf16bit) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
871 n16++; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
872 else |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
873 n8++; |
0 | 874 } |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
875 else |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
876 if (m->instruments[i] != NULL) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
877 unused++; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
878 |
0 | 879 dmPrint(2, "\n"); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
880 dmMsg(1, "Total of %d [16-bit] + %d [8-bit] samples = %d instruments (%d unused).\n", |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
881 n16, n8, r->ninstruments, unused); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
882 |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
883 // |
0 | 884 // Re-map ext.instruments |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
885 // |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
886 dmMsg(1, "Creating ext.instrument remaps...\n"); |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
887 for (unused = i = 0; i < jsetMaxInstruments; i++) |
0 | 888 if (usedExtInstruments[i]) |
889 { | |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
890 JSSExtInstrument *eip; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
891 int note; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
892 if (optStripExtInstr) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
893 continue; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
894 |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
895 if (i >= m->nextInstruments) |
0 | 896 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
897 dmErrorMsg("Ext.instrument 0x%x >= 0x%x, but used!\n", |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
898 i + 1, m->nextInstruments); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
899 continue; |
0 | 900 } |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
901 |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
902 if ((eip = m->extInstruments[i]) == NULL) |
0 | 903 { |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
904 dmErrorMsg("Extended instrument 0x%x used but is NULL.\n", i + 1); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
905 continue; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
906 } |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
907 |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
908 dmPrint(2, "%02x -> %02x : ", i + 1, r->nextInstruments + 1); |
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
909 |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
910 mapExtInstruments[i] = r->nextInstruments; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
911 r->extInstruments[r->nextInstruments] = eip; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
912 (r->nextInstruments)++; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
913 |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
914 // Re-map sNumForNotes table for this ext.instrument |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
915 for (note = 0; note < jsetNNotes; note++) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
916 { |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
917 int q = eip->sNumForNotes[note]; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
918 if (q != jsetNotSet) |
0 | 919 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
920 int map; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
921 if (q >= 0 && q < jsetMaxInstruments) |
0 | 922 { |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
923 map = mapInstruments[q]; |
0 | 924 } |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
925 else |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
926 { |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
927 map = jsetNotSet; |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
928 dmErrorMsg("Einst=%d, note=%d, sNumForNote=%d (%d max)\n", |
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
929 i + 1, note, q + 1, r->ninstruments); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
930 } |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
931 |
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
932 dmPrint(3, "%02x.%02x ", q + 1, map + 1); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
933 eip->sNumForNotes[note] = map; |
0 | 934 } |
935 } | |
936 } | |
937 else | |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
938 if (m->extInstruments[i] != NULL) |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
939 unused++; |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
940 |
0 | 941 dmPrint(2, "\n"); |
1097
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
942 dmMsg(1, "%d extended instruments (%d unused).\n", |
0e3cb9e61170
Code cleanup, in preparation for bug hunting.
Matti Hamalainen <ccr@tnsp.org>
parents:
1094
diff
changeset
|
943 r->nextInstruments, unused); |
1094 | 944 |
945 // | |
946 // Remap pattern data with remapped instrument data | |
947 // | |
0 | 948 for (i = 0; i < r->npatterns; i++) |
949 { | |
950 int row, channel; | |
951 JSSPattern *p = r->patterns[i]; | |
952 JSSNote *n = p->data; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
953 |
0 | 954 for (row = 0; row < p->nrows; row++) |
955 for (channel = 0; channel < p->nchannels; channel++, n++) | |
956 { | |
184
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
957 char effect; |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
958 |
1109 | 959 // If not stripping extended instruments, check for |
960 // the validity of the used instrument and remap | |
338
cd57ba1130eb
Fixes and improvements in the JMOD saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
961 if (!optStripExtInstr) |
cd57ba1130eb
Fixes and improvements in the JMOD saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
962 { |
856
415cc781e127
Fix some brain farts in instrument remapping.
Matti Hamalainen <ccr@tnsp.org>
parents:
807
diff
changeset
|
963 if (n->instrument >= 0 && n->instrument < jsetMaxInstruments) |
338
cd57ba1130eb
Fixes and improvements in the JMOD saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
964 n->instrument = mapExtInstruments[n->instrument]; |
202
85614db5f577
Warn about invalid instruments.
Matti Hamalainen <ccr@tnsp.org>
parents:
184
diff
changeset
|
965 |
1116 | 966 if (n->instrument != jsetNotSet && |
967 r->extInstruments[n->instrument] == NULL) | |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
968 { |
1116 | 969 dmErrorMsg("Non-existing instrument used #%d, INTERNAL ERROR.\n", |
1111
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
970 n->instrument + 1); |
f9a96fc2a932
Adjust messages to show user-visible (1 based) instrument numbers.
Matti Hamalainen <ccr@tnsp.org>
parents:
1109
diff
changeset
|
971 } |
338
cd57ba1130eb
Fixes and improvements in the JMOD saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
972 } |
cd57ba1130eb
Fixes and improvements in the JMOD saving and loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
973 |
184
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
974 JMPGETEFFECT(effect, n->effect); |
1094 | 975 |
184
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
976 switch (effect) |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
977 { |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
978 case 'C': // Cxx = Set volume |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
979 if (n->volume == jsetNotSet) |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
980 { |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
981 n->volume = n->param; |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
982 n->effect = jsetNotSet; |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
983 n->param = jsetNotSet; |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
984 } |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
985 break; |
50f55def91e5
Add a minor optimization in the conversion.
Matti Hamalainen <ccr@tnsp.org>
parents:
86
diff
changeset
|
986 } |
0 | 987 } |
988 } | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
989 |
1113
28dcf10fb8a9
Comments, cosmetics, combine one error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
1111
diff
changeset
|
990 // |
0 | 991 // Remap orders list |
1113
28dcf10fb8a9
Comments, cosmetics, combine one error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
1111
diff
changeset
|
992 // |
0 | 993 for (i = 0; i < m->norders; i++) |
994 { | |
995 r->orderList[i] = mapPatterns[m->orderList[i]]; | |
996 } | |
997 | |
998 return r; | |
999 } | |
1000 | |
1001 | |
1002 int main(int argc, char *argv[]) | |
1003 { | |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1004 DMResource *inFile = NULL; |
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1005 FILE *outFile = NULL; |
0 | 1006 JSSModule *sm, *dm; |
1007 int result; | |
1008 | |
1009 dmInitProg("xm2jss", "XM to JSSMOD converter", "0.6", NULL, NULL); | |
1010 dmVerbosity = 0; | |
1011 | |
1012 // Parse arguments | |
1013 if (!dmArgsProcess(argc, argv, optList, optListN, | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
856
diff
changeset
|
1014 argHandleOpt, argHandleFile, OPTH_BAILOUT)) |
0 | 1015 exit(1); |
1016 | |
300 | 1017 // Check arguments |
1018 if (optInFilename == NULL || optOutFilename == NULL) | |
1019 { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
1020 dmErrorMsg("Input or output file not specified. Try --help.\n"); |
300 | 1021 return 1; |
1022 } | |
0 | 1023 |
1024 // Read the source file | |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1025 if ((result = dmf_create_stdio(optInFilename, "rb", &inFile)) != DMERR_OK) |
0 | 1026 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
1027 dmErrorMsg("Error opening input file '%s', %d: %s\n", |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1028 optInFilename, result, dmErrorStr(result)); |
0 | 1029 return 1; |
1030 } | |
1031 | |
1032 // Initialize miniJSS | |
1033 jssInit(); | |
1034 | |
1035 // Read file | |
1036 dmMsg(1, "Reading XM-format file ...\n"); | |
797
f066e9dccf29
Oops, fix some inverted booleans.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
1037 result = jssLoadXM(inFile, &sm, FALSE); |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1038 dmf_close(inFile); |
0 | 1039 if (result != 0) |
1040 { | |
1195
4d27c4ec8d4d
Use %d instead of %i in formats.
Matti Hamalainen <ccr@tnsp.org>
parents:
1194
diff
changeset
|
1041 dmErrorMsg("Error while loading XM file (%d), ", result); |
0 | 1042 if (optIgnoreErrors) |
1043 fprintf(stderr, "ignoring. This may cause problems.\n"); | |
1044 else | |
1045 { | |
1046 fprintf(stderr, "giving up. Use --ignore if you want to try to convert anyway.\n"); | |
1047 return 2; | |
1048 } | |
1049 } | |
1050 | |
1051 // Check stripping settings | |
1052 if (optStripExtInstr) optStripInstr = TRUE; | |
1053 if (optStripInstr) optStripSamples = TRUE; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
1054 |
0 | 1055 // Remove samples |
1056 if (optStripSamples) | |
1057 { | |
1058 int i; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
1059 |
0 | 1060 dmMsg(1, "Stripping samples...\n"); |
1061 for (i = 0; i < sm->ninstruments; i++) | |
1062 { | |
1063 dmFree(sm->instruments[i]->data); | |
1064 sm->instruments[i]->data = NULL; | |
1065 } | |
1066 } | |
1067 | |
1068 // Remove instruments | |
1069 if (optStripInstr) | |
1070 { | |
1071 int i; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
1072 |
0 | 1073 dmMsg(1, "Stripping instruments...\n"); |
1074 for (i = 0; i < sm->ninstruments; i++) | |
1075 { | |
1076 dmFree(sm->instruments[i]); | |
1077 sm->instruments[i] = NULL; | |
1078 } | |
1079 sm->ninstruments = 0; | |
1080 } | |
1081 | |
1082 // Remove ext.instruments | |
1083 if (optStripExtInstr) | |
1084 { | |
1085 int i; | |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
1086 |
0 | 1087 dmMsg(1, "Stripping ext.instruments...\n"); |
1088 for (i = 0; i < sm->nextInstruments; i++) | |
1089 { | |
1090 dmFree(sm->extInstruments[i]); | |
1091 sm->extInstruments[i] = NULL; | |
1092 } | |
1093 sm->nextInstruments = 0; | |
1094 } | |
1109 | 1095 |
0 | 1096 // Run the optimization procedure |
1097 if (optOptimize) | |
1098 { | |
1099 dmMsg(1, "Optimizing module data...\n"); | |
1100 dm = optimizeModule(sm); | |
1101 } else | |
1102 dm = sm; | |
1103 | |
1104 // Write output file | |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1105 if ((outFile = fopen(optOutFilename, "wb")) == NULL) |
0 | 1106 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
1107 dmErrorMsg("Error creating output file '%s', %d: %s\n", |
300 | 1108 optOutFilename, errno, strerror(errno)); |
0 | 1109 return 1; |
1110 } | |
1111 | |
9
c42ee907de9c
Various improvements in xm2jss output.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1112 dmMsg(1, "Writing JSSMOD-format file [patMode=0x%04x, samp8=0x%02x, samp16=0x%02x]\n", |
0 | 1113 optPatternMode, optSampMode8, optSampMode16); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
1114 |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1115 result = jssSaveJSSMOD(outFile, dm, optPatternMode, optSampMode8, optSampMode16); |
1113
28dcf10fb8a9
Comments, cosmetics, combine one error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
1111
diff
changeset
|
1116 |
1114
7aaab1533c90
Free the source module data at end.
Matti Hamalainen <ccr@tnsp.org>
parents:
1113
diff
changeset
|
1117 dmFree(sm); |
7aaab1533c90
Free the source module data at end.
Matti Hamalainen <ccr@tnsp.org>
parents:
1113
diff
changeset
|
1118 |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
1119 fclose(outFile); |
1235
5b8245e5f785
Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1233
diff
changeset
|
1120 |
0 | 1121 if (result != 0) |
1122 { | |
1113
28dcf10fb8a9
Comments, cosmetics, combine one error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
1111
diff
changeset
|
1123 dmErrorMsg( |
28dcf10fb8a9
Comments, cosmetics, combine one error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
1111
diff
changeset
|
1124 "Error while saving JSSMOD file, %d: %s\n" |
28dcf10fb8a9
Comments, cosmetics, combine one error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
1111
diff
changeset
|
1125 "WARNING: The resulting file may be broken!\n", |
300 | 1126 result, dmErrorStr(result)); |
0 | 1127 } |
300 | 1128 else |
1129 { | |
1130 dmMsg(1, "Conversion complete.\n"); | |
1131 } | |
0 | 1132 return 0; |
1133 } |