Mercurial > hg > dmlib
annotate tools/dumpmod.c @ 1092:03322ee5bb32
Change dumpmod short format sample instrument output.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 03 Mar 2015 01:40:52 +0200 |
parents | 985225a93aeb |
children | ea2cc4932714 |
rev | line source |
---|---|
0 | 1 /* |
942
38cad00b41dd
Rename viewmod utility to dumpmod.
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
2 * dumpmod - View information about given module file |
0 | 3 * Programmed and designed by Matti 'ccr' Hamalainen |
942
38cad00b41dd
Rename viewmod utility to dumpmod.
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
4 * (C) Copyright 2006-2015 Tecnic Software productions (TNSP) |
0 | 5 * |
6 * Please read file 'COPYING' for information on license and distribution. | |
7 */ | |
8 #include "jss.h" | |
9 #include "jssmod.h" | |
10 #include <errno.h> | |
11 #include <string.h> | |
12 #include "dmargs.h" | |
285
245b15cd1919
Don't link libSDL uselessly to utilities that do not actually use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
152
diff
changeset
|
13 #include "dmmutex.h" |
0 | 14 |
15 | |
16 char *optFilename = NULL; | |
17 BOOL optViewPatterns = FALSE, | |
18 optViewInstruments = FALSE, | |
19 optViewExtInstruments = FALSE, | |
795 | 20 optViewGeneralInfo = FALSE, |
21 optDump = FALSE; | |
0 | 22 |
23 | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
24 static const DMOptArg optList[] = |
0 | 25 { |
26 { 0, '?', "help", "Show this help and exit", OPT_NONE }, | |
27 { 1, 'p', "patterns", "View patterns", OPT_NONE }, | |
28 { 2, 'i', "instruments", "View instruments", OPT_NONE }, | |
29 { 5, 'e', "extinstruments", "View extended instruments", OPT_NONE }, | |
30 { 3, 'g', "general", "General information", OPT_NONE }, | |
31 { 4, 'v', "verbose", "Be more verbose", OPT_NONE }, | |
795 | 32 { 6, 'd', "dump", "Dump mode", OPT_NONE }, |
0 | 33 }; |
34 | |
35 const int optListN = sizeof(optList) / sizeof(optList[0]); | |
36 | |
37 | |
38 void argShowHelp() | |
39 { | |
40 dmPrintBanner(stdout, dmProgName, "[options] [modfile]"); | |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
41 dmArgsPrintHelp(stdout, optList, optListN, 0); |
0 | 42 } |
43 | |
44 | |
45 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) | |
46 { | |
47 (void) optArg; | |
48 | |
49 switch (optN) | |
50 { | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
51 case 0: |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
52 argShowHelp(); |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
53 exit(0); |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
54 break; |
0 | 55 |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
56 case 1: |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
57 optViewPatterns = TRUE; |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
58 break; |
0 | 59 |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
60 case 2: |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
61 optViewInstruments = TRUE; |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
62 break; |
0 | 63 |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
64 case 3: |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
65 optViewGeneralInfo = TRUE; |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
66 break; |
0 | 67 |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
68 case 4: |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
69 dmVerbosity++; |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
70 break; |
0 | 71 |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
72 case 5: |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
73 optViewExtInstruments = TRUE; |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
74 break; |
0 | 75 |
795 | 76 case 6: |
77 optDump = TRUE; | |
78 break; | |
79 | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
80 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
942
diff
changeset
|
81 dmErrorMsg("Unknown argument '%s'.\n", currArg); |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
82 return FALSE; |
0 | 83 } |
84 | |
85 return TRUE; | |
86 } | |
87 | |
88 | |
89 BOOL argHandleFile(char *currArg) | |
90 { | |
91 // Was not option argument | |
92 if (!optFilename) | |
93 optFilename = currArg; | |
94 else { | |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
942
diff
changeset
|
95 dmErrorMsg("Gay error '%s'!\n", currArg); |
0 | 96 return FALSE; |
97 } | |
98 | |
99 return TRUE; | |
100 } | |
101 | |
102 | |
103 const char patNoteTable[12][3] = | |
104 { | |
105 "C-", "C#", "D-", | |
106 "D#", "E-", "F-", | |
107 "F#", "G-", "G#", | |
108 "A-", "A#", "B-" | |
109 }; | |
110 | |
111 #define jmpNMODEffectTable (36) | |
112 static const char jmpMODEffectTable[jmpNMODEffectTable] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
113 | |
114 | |
115 /* Print a given pattern | |
116 */ | |
117 void printPattern(FILE *f, JSSPattern *p) | |
118 { | |
119 int i, j; | |
120 char c; | |
121 JSSNote *n; | |
122 | |
123 if (!p) | |
124 return; | |
125 | |
126 n = p->data; | |
127 | |
128 for (i = 0; i < p->nrows; i++) | |
129 { | |
130 fprintf(f, "%.2x: ", i); | |
131 | |
132 for (j = 0; j < p->nchannels; j++) | |
133 { | |
134 switch (n->note) | |
135 { | |
136 case jsetNotSet: | |
137 fprintf(f, "... "); | |
138 break; | |
139 case jsetNoteOff: | |
140 fprintf(f, "=== "); | |
141 break; | |
142 default: | |
143 fprintf(f, "%s%i ", patNoteTable[n->note % 12], n->note / 12); | |
144 break; | |
145 } | |
146 | |
147 if (n->instrument != jsetNotSet) | |
148 fprintf(f, "%.2x ", n->instrument + 1); // Because FT2 is 1-based and we use 0 internally | |
149 else | |
150 fprintf(f, ".. "); | |
151 | |
152 if (n->volume == jsetNotSet) | |
153 fprintf(f, ".. "); | |
154 else if (n->volume >= 0x00 && n->volume <= 0x40) | |
155 fprintf(f, "%.2x ", n->volume); | |
156 else | |
157 { | |
158 switch (n->volume & 0xf0) | |
159 { | |
160 case 0x50: c = '-'; break; | |
161 case 0x60: c = '+'; break; | |
162 case 0x70: c = '/'; break; | |
163 case 0x80: c = '\\'; break; | |
164 case 0x90: c = 'S'; break; | |
165 case 0xa0: c = 'V'; break; | |
166 case 0xb0: c = 'P'; break; | |
167 case 0xc0: c = '<'; break; | |
168 case 0xd0: c = '>'; break; | |
169 case 0xe0: c = 'M'; break; | |
170 default: c = '?'; break; | |
171 } | |
172 fprintf(f, "%c%x ", c, (n->volume & 0x0f)); | |
173 } | |
174 | |
175 if (n->effect >= 0 && n->effect < jmpNMODEffectTable) | |
176 fprintf(f, "%c", jmpMODEffectTable[n->effect]); | |
177 else if (n->effect == jsetNotSet) | |
178 fprintf(f, "."); | |
179 else | |
180 fprintf(f, "?"); | |
181 | |
182 if (n->param != jsetNotSet) | |
183 fprintf(f, "%.2x|", n->param); | |
184 else | |
185 fprintf(f, "..|"); | |
186 | |
187 n++; | |
188 } | |
189 | |
190 fprintf(f, "\n"); | |
191 } | |
192 } | |
193 | |
194 | |
195 /* | |
196 * Print given extended instrument | |
197 */ | |
198 void printEnvelope(FILE *f, JSSEnvelope *e, char *s) | |
199 { | |
200 int i; | |
201 | |
202 fprintf(f, | |
203 "\t%s-envelope:\n" | |
204 "\t - flags.....: %.4x", s, e->flags); | |
205 | |
206 if (e->flags & jenvfUsed) | |
207 fprintf(f, " [used]"); | |
208 if (e->flags & jenvfSustain) | |
209 fprintf(f, " [sust]"); | |
210 if (e->flags & jenvfLooped) | |
211 fprintf(f, " [loop]"); | |
212 | |
213 fprintf(f, "\n" | |
214 "\t - npoints...: %i\n" | |
215 "\t - sustain...: %i\n" | |
216 "\t - loopS.....: %i\n" | |
217 "\t - loopE.....: %i\n", | |
218 e->npoints, e->sustain, e->loopS, e->loopE); | |
219 | |
220 if (dmVerbosity >= 2) | |
221 { | |
222 fprintf(f, "\t - Points....:"); | |
223 for (i = 0; i < e->npoints; i++) | |
224 { | |
225 fprintf(f, " [%i:%i]", | |
226 e->points[i].frame, e->points[i].value); | |
227 } | |
228 | |
229 fprintf(f, "\n"); | |
230 } | |
231 } | |
232 | |
233 | |
234 void printExtInstrument(FILE *f, JSSExtInstrument *i) | |
235 { | |
236 if (!i) | |
237 { | |
238 fprintf(f, "\n"); | |
239 return; | |
240 } | |
241 | |
242 #ifndef JSS_LIGHT | |
795 | 243 if (i->desc && !optDump) |
0 | 244 fprintf(f, |
245 "Description: '%s'\n", i->desc); | |
246 #endif | |
247 fprintf(f, | |
248 "nsamples.......: %i\n" | |
249 "vibratoType....: %i\n" | |
250 "vibratoSweep...: %i\n" | |
251 "vibratoDepth...: %i\n" | |
252 "vibratoRate....: %i\n" | |
253 "fadeOut........: %i\n", | |
254 i->nsamples, i->vibratoType, i->vibratoSweep, | |
255 i->vibratoDepth, i->vibratoRate, i->fadeOut); | |
256 | |
257 if (dmVerbosity >= 1) | |
258 { | |
259 printEnvelope(f, &i->volumeEnv, "Volume"); | |
260 printEnvelope(f, &i->panningEnv, "Panning"); | |
261 } | |
262 fprintf(f, "\n"); | |
263 } | |
264 | |
265 | |
266 void printInstrument(FILE *f, JSSInstrument *i) | |
267 { | |
268 if (!i) | |
269 { | |
270 fprintf(f, "\n"); | |
271 return; | |
272 } | |
273 | |
274 if (dmVerbosity >= 1) | |
275 { | |
276 #ifndef JSS_LIGHT | |
795 | 277 if (i->desc && !optDump) |
0 | 278 fprintf(f, "Description: '%s'\n", i->desc); |
279 #endif | |
280 fprintf(f, | |
281 "size...........: %ld (0x%lx)\n" | |
282 "loopStart......: %ld (0x%lx)\n" | |
283 "loopEnd........: %ld (0x%lx)\n" | |
284 "volume.........: %d (0x%x)\n" | |
285 "flags..........: 0x%x ", | |
286 (unsigned long) i->size, (unsigned long) i->size, | |
287 (unsigned long) i->loopS, (unsigned long) i->loopE, | |
288 (unsigned long) i->loopS, (unsigned long) i->loopE, | |
289 i->volume, i->volume, | |
290 i->flags); | |
291 | |
292 if (i->flags & jsfLooped) fprintf(f, "[loop] "); | |
293 if (i->flags & jsfBiDi) fprintf(f, "[bi-di] "); | |
294 if (i->flags & jsf16bit) fprintf(f, "[16bit] "); | |
295 | |
296 fprintf(f, | |
297 "\nC4BaseSpeed....: %d (0x%x)\n" | |
298 "ERelNote.......: %d (%s%d)\n" | |
299 "EFineTune......: %d\n" | |
300 "EPanning,,,....: %d (0x%x)\n\n", | |
301 i->C4BaseSpeed, i->C4BaseSpeed, | |
302 i->ERelNote, patNoteTable[(48 + i->ERelNote) % 12], (48 + i->ERelNote) / 12, | |
303 i->EFineTune, i->EPanning, i->EPanning); | |
304 } | |
305 else | |
306 { | |
307 #ifndef JSS_LIGHT | |
795 | 308 if (i->desc && !optDump) |
1092
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
309 fprintf(f, "%s|", i->desc); |
0 | 310 #endif |
311 fprintf(f, | |
1092
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
312 "%8ld|%8ld..%-8ld|%03d|%-2s %-2s %-2s|" |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
313 "%4d|%s%d|%d|%d\n", |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
314 (unsigned long) i->size, |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
315 (unsigned long) i->loopS, |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
316 (unsigned long) i->loopE, |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
317 i->volume, |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
318 |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
319 (i->flags & jsfLooped) ? "lp" : "", |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
320 (i->flags & jsfBiDi) ? "bi" : "", |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
321 (i->flags & jsf16bit) ? "16" : "8", |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
322 |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
323 i->C4BaseSpeed, |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
324 patNoteTable[(48 + i->ERelNote) % 12], |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
325 (48 + i->ERelNote) / 12, i->EFineTune, |
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
326 i->EPanning); |
0 | 327 } |
328 } | |
329 | |
330 | |
331 void printGeneralInfo(FILE *f, JSSModule *m) | |
332 { | |
333 int i; | |
334 | |
335 if (!m) | |
336 return; | |
337 | |
795 | 338 if (!optDump) |
339 { | |
0 | 340 fprintf(f, "Module type.....: %i\n", m->moduleType); |
341 #ifndef JSS_LIGHT | |
342 if (m->moduleName) | |
343 fprintf(f, "Module name.....: '%s'\n", m->moduleName); | |
344 if (m->trackerName) | |
345 fprintf(f, "Tracker name....: '%s'\n", m->trackerName); | |
346 #endif | |
795 | 347 } |
0 | 348 fprintf(f, |
349 "Speed...........: %d ticks\n" | |
350 "Tempo...........: %d bpm\n" | |
351 "Flags...........: %x ", | |
352 m->defSpeed, m->defTempo, m->defFlags); | |
353 | |
354 if (m->defFlags & jmdfAmigaPeriods) fprintf(f, "[Amiga periods] "); | |
355 if (m->defFlags & jmdfAmigaLimits) fprintf(f, "[Amiga limits] "); | |
356 if (m->defFlags & jmdfStereo) fprintf(f, "[stereo] "); | |
357 if (m->defFlags & jmdfFT2Replay) fprintf(f, "[FT2 replay] "); | |
358 if (m->defFlags & jmdfST300Slides) fprintf(f, "[ST300 slides] "); | |
359 if (m->defFlags & jmdfByteLStart) fprintf(f, "[ByteStart] "); | |
360 | |
361 fprintf(f, "\n" | |
362 "Restart pos.....: %d (order)\n" | |
363 "IntVersion......: %x\n" | |
364 "Channels........: %d\n" | |
365 "Instruments.....: %d\n" | |
366 "Ext.instruments.: %d\n" | |
367 "Patterns........: %d\n" | |
368 "Orders..........: %d\n", | |
369 m->defRestartPos, m->intVersion, m->nchannels, | |
370 m->ninstruments, m->nextInstruments, m->npatterns, | |
371 m->norders); | |
372 | |
373 if (dmVerbosity >= 1) | |
374 { | |
375 fprintf(f, "Orderlist: "); | |
376 for (i = 0; i < m->norders - 1; i++) | |
377 fprintf(f, "%d, ", m->orderList[i]); | |
378 if (i < m->norders) | |
379 fprintf(f, "%d", m->orderList[i]); | |
380 fprintf(f, "\n"); | |
381 } | |
382 } | |
383 | |
384 | |
385 | |
386 int main(int argc, char *argv[]) | |
387 { | |
388 int result = -1, i; | |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
730
diff
changeset
|
389 DMResource *file = NULL; |
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
730
diff
changeset
|
390 JSSModule *mod = NULL; |
0 | 391 |
942
38cad00b41dd
Rename viewmod utility to dumpmod.
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
392 dmInitProg("dumpmod", "miniJSS Module Viewer", "0.4", NULL, NULL); |
0 | 393 dmVerbosity = 0; |
394 | |
395 // Parse arguments | |
396 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:
797
diff
changeset
|
397 argHandleOpt, argHandleFile, OPTH_BAILOUT)) |
0 | 398 exit(1); |
399 | |
400 // Initialize miniJSS | |
401 jssInit(); | |
402 | |
403 // Open the file | |
404 dmMsg(1, "Reading module file '%s'\n", optFilename); | |
405 if (optFilename == NULL) | |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
406 result = dmf_create_stdio_stream(stdin, &file); |
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
407 else |
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
408 result = dmf_create_stdio(optFilename, "rb", &file); |
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
409 |
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
410 if (result != DMERR_OK) |
0 | 411 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
942
diff
changeset
|
412 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
|
413 optFilename, result, dmErrorStr(result)); |
0 | 414 return 1; |
415 } | |
416 | |
417 // Read module file | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
418 dmMsg(1, "Reading file: %s\n", optFilename); |
0 | 419 #ifdef JSS_SUP_XM |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
420 dmMsg(1, "* Trying XM...\n"); |
797
f066e9dccf29
Oops, fix some inverted booleans.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
421 result = jssLoadXM(file, &mod, TRUE); |
0 | 422 #endif |
423 #ifdef JSS_SUP_JSSMOD | |
424 if (result != 0) | |
425 { | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
426 dmfseek(file, 0L, SEEK_SET); |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
730
diff
changeset
|
427 dmMsg(1, "* Trying JSSMOD ...\n"); |
796 | 428 result = jssLoadJSSMOD(file, &mod, TRUE); |
0 | 429 } |
430 #endif | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
431 dmf_close(file); |
8
fc097f7717df
Fix JSSMod loading in viewmod and testpl.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
432 if (result != DMERR_OK) |
0 | 433 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
942
diff
changeset
|
434 dmErrorMsg("Error loading module file, %d: %s\n", |
8
fc097f7717df
Fix JSSMod loading in viewmod and testpl.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
435 result, dmErrorStr(result)); |
0 | 436 return 3; |
437 } | |
438 | |
439 // Print out information | |
440 if (optViewGeneralInfo) | |
79
d6c2efa25aa4
Oops, missed one s/m/mod/ .. fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
77
diff
changeset
|
441 printGeneralInfo(stdout, mod); |
0 | 442 |
443 if (optViewPatterns) | |
444 { | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
445 for (i = 0; i < mod->npatterns; i++) |
0 | 446 { |
447 printf("\nPattern #%03i:\n", i); | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
448 printPattern(stdout, mod->patterns[i]); |
0 | 449 } |
450 } | |
451 | |
452 if (optViewExtInstruments) | |
453 { | |
454 printf("\n" | |
455 "ExtInstruments:\n" | |
456 "---------------\n" | |
457 ); | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
458 for (i = 0; i < mod->nextInstruments; i++) |
0 | 459 { |
1092
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
460 printf("#%03d: ", i + 1); |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
461 printExtInstrument(stdout, mod->extInstruments[i]); |
0 | 462 } |
463 } | |
464 | |
465 if (optViewInstruments) | |
466 { | |
467 printf("\n" | |
468 "Instruments:\n" | |
469 "------------\n" | |
470 ); | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
471 for (i = 0; i < mod->ninstruments; i++) |
0 | 472 { |
1092
03322ee5bb32
Change dumpmod short format sample instrument output.
Matti Hamalainen <ccr@tnsp.org>
parents:
958
diff
changeset
|
473 printf("#%03d: ", i + 1); |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
474 printInstrument(stdout, mod->instruments[i]); |
0 | 475 } |
476 } | |
477 | |
478 // Free module data | |
77
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
479 jssFreeModule(mod); |
c6cdaa675801
Add the file mode parameter to dmf_create_stdio() calls, and throw in some
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
480 jssClose(); |
0 | 481 |
482 exit(0); | |
483 return 0; | |
484 } |