annotate tools/mod2wav.c @ 2565:d56a0e86067a

Improve error handling.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 28 Feb 2022 11:49:58 +0200
parents aacf3bd1cceb
children b205c60aa657
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * mod2wav - Render XM/JSSMOD module to WAV waveform file
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * (C) Copyright 2007 Tecnic Software productions (TNSP)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
1432
a9516570cc26 Improve build, so that we can build the tools and tests with minimal
Matti Hamalainen <ccr@tnsp.org>
parents: 1235
diff changeset
8 #include "dmtool.h"
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #include <stdio.h>
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #include <stdlib.h>
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #include "jss.h"
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 #include "jssmod.h"
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #include "jssmix.h"
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 #include "jssplr.h"
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #include "dmlib.h"
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 #include "dmargs.h"
1953
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
17 #include "dmfile.h"
285
245b15cd1919 Don't link libSDL uselessly to utilities that do not actually use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
18 #include "dmmutex.h"
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
1953
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
21 #define DM_WAVE_FORMAT_PCM (1)
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
22 #define DM_WAVE_RIFF_ID "RIFF"
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
23 #define DM_WAVE_WAVE_ID "WAVE"
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
24 #define DM_WAVE_FMT_ID "fmt "
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
25 #define DM_WAVE_DATA_ID "data"
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
26
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
27
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
28 typedef struct
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
29 {
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
30 Uint8 chunkID[4];
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
31 Uint32 chunkSize;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
32 } DMWaveChunk;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
33
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
34
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
35 typedef struct
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
36 {
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
37 Uint8 riffID[4];
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
38 Uint32 fileSize;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
39 Uint8 riffType[4];
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
40
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
41 DMWaveChunk chFormat;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
42
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
43 Uint16 wFormatTag;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
44 Uint16 nChannels;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
45 Uint32 nSamplesPerSec;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
46 Uint32 nAvgBytesPerSec;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
47 Uint16 nBlockAlign;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
48 Uint16 wBitsPerSample;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
49
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
50 DMWaveChunk chData;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
51 // Data follows here
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
52 } DMWaveFile;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
53
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
54
300
4972ca91d062 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
55 char *optInFilename = NULL, *optOutFilename = NULL;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 int optOutFormat = JSS_AUDIO_S16,
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 optOutChannels = 2,
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 optOutFreq = 44100,
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 optMuteOChannels = -1,
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 optStartOrder = -1;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 BOOL optUsePlayTime = FALSE;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 size_t optPlayTime;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 797
diff changeset
65 static const DMOptArg optList[] =
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
66 {
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
67 { 0, '?', "help" , "Show this help", OPT_NONE },
2410
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
68 { 1, 0, "license" , "Print out this program's license agreement", OPT_NONE },
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
69 { 2, 'v', "verbose" , "Be more verbose", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
70
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
71 { 10, '1', "16bit" , "16-bit output", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
72 { 12, '8', "8bit" , "8-bit output", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
73 { 14, 'm', "mono" , "Mono output", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
74 { 16, 's', "stereo" , "Stereo output", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
75 { 18, 'f', "freq" , "Output frequency", OPT_ARGREQ },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
76 { 20, 'M', "mute" , "Mute other channels than #", OPT_ARGREQ },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
77 { 22, 'o', "order" , "Start from order #", OPT_ARGREQ },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
78 { 24, 't', "time" , "Play for # seconds", OPT_ARGREQ },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
79 // { 26, 'l', "loop" , "Loop for # times", OPT_ARGREQ },
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 };
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 const int optListN = sizeof(optList) / sizeof(optList[0]);
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
85 void argShowHelp()
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
86 {
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
87 dmPrintBanner(stdout, dmProgName, "[options] [sourcefile] [destfile.wav]");
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
88 dmArgsPrintHelp(stdout, optList, optListN, 0, 80 - 2);
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
89 }
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
90
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
91
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 {
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 (void) optArg;
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
95
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
96 switch (optN)
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
97 {
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
98 case 0:
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
99 argShowHelp();
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
100 exit(0);
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
101 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
2410
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
103 case 1:
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
104 dmPrintLicense(stdout);
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
105 exit(0);
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
106 break;
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
107
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
108 case 2:
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
109 dmVerbosity++;
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
110 break;
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
111
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
112 case 10:
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
113 optOutFormat = JSS_AUDIO_S16;
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
114 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
116 case 12:
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
117 optOutFormat = JSS_AUDIO_U8;
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
118 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
120 case 14:
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
121 optOutChannels = JSS_AUDIO_MONO;
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
122 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
124 case 16:
38
8b04b0b51edc Oops, fix a stupid bug in -s option .. it was setting the wrong variable. :|
Matti Hamalainen <ccr@tnsp.org>
parents: 37
diff changeset
125 optOutChannels = JSS_AUDIO_STEREO;
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
126 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
128 case 18:
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
129 optOutFreq = atoi(optArg);
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
130 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
132 case 20:
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
133 optMuteOChannels = atoi(optArg);
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
134 break;
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
135
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
136 case 22:
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
137 optStartOrder = atoi(optArg);
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
138 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2402
diff changeset
140 case 24:
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
141 optPlayTime = atoi(optArg);
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
142 optUsePlayTime = TRUE;
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
143 break;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
145 default:
2183
e3f0eaf23f4f Change the error message for unimplemented option argument.
Matti Hamalainen <ccr@tnsp.org>
parents: 1953
diff changeset
146 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg);
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
147 return FALSE;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
149
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 return TRUE;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 BOOL argHandleFile(char *currArg)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 {
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
156 if (optInFilename == NULL)
300
4972ca91d062 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
157 optInFilename = currArg;
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
158 else
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
159 if (optOutFilename == NULL)
300
4972ca91d062 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
160 optOutFilename = currArg;
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
161 else
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
162 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
163 dmErrorMsg("Too many filename arguments (only source and dest needed) '%s'\n", currArg);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 return FALSE;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
166
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 return TRUE;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170
1953
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
171 BOOL dmWriteWAVChunk(FILE * f, DMWaveChunk *ch)
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
172 {
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
173 return dm_fwrite_str(f, ch->chunkID, 4) && dm_fwrite_le32(f, ch->chunkSize);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
174 }
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
175
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
176
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
177 void dmMakeWAVChunk(DMWaveChunk *ch, const char *chunkID, const Uint32 chunkSize)
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
178 {
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
179 memcpy(&(ch->chunkID), (const void *) chunkID, 4);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
180 ch->chunkSize = chunkSize;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
181 }
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
182
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
183
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
184 void dmWriteWAVHeader(FILE *outFile, int sampBits, int sampFreq, int sampChn, size_t sampLen)
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
185 {
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
186 DMWaveFile wav;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
187
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
188 // PCM WAVE chunk
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
189 dmMakeWAVChunk(&wav.chFormat, DM_WAVE_FMT_ID, (2 + 2 + 4 + 4 + 2 + 2));
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
190
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
191 wav.wFormatTag = DM_WAVE_FORMAT_PCM;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
192 wav.nChannels = sampChn;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
193 wav.nSamplesPerSec = sampFreq;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
194 wav.nAvgBytesPerSec = (sampBits * sampChn * sampFreq) / 8;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
195 wav.nBlockAlign = (sampBits * sampChn) / 8;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
196 wav.wBitsPerSample = sampBits;
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
197
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
198 // Data chunk
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
199 dmMakeWAVChunk(&wav.chData, DM_WAVE_DATA_ID, (sampLen * wav.nBlockAlign));
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
200
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
201 // RIFF header
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
202 memcpy(&wav.riffID, (const void *) DM_WAVE_RIFF_ID, 4);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
203 memcpy(&wav.riffType, (const void *) DM_WAVE_WAVE_ID, 4);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
204 wav.fileSize = ((4 + 4 + 4) + wav.chFormat.chunkSize + wav.chData.chunkSize);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
205
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
206 // Write header
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
207 dm_fwrite_str(outFile, wav.riffID, sizeof(wav.riffID));
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
208 dm_fwrite_le32(outFile, wav.fileSize);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
209
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
210 dm_fwrite_str(outFile, wav.riffType, sizeof(wav.riffType));
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
211 dmWriteWAVChunk(outFile, &wav.chFormat);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
212
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
213 dm_fwrite_le16(outFile, wav.wFormatTag);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
214 dm_fwrite_le16(outFile, wav.nChannels);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
215 dm_fwrite_le32(outFile, wav.nSamplesPerSec);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
216 dm_fwrite_le32(outFile, wav.nAvgBytesPerSec);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
217 dm_fwrite_le16(outFile, wav.nBlockAlign);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
218 dm_fwrite_le16(outFile, wav.wBitsPerSample);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
219
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
220 dmWriteWAVChunk(outFile, &wav.chData);
c3e88d9343ca Move WAV stuff back into mod2wav.c, made no sense to have it elsewhere.
Matti Hamalainen <ccr@tnsp.org>
parents: 1606
diff changeset
221 }
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
222
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
223
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 int main(int argc, char *argv[])
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 {
15
feec43a3497c Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
226 DMResource *inFile = NULL;
feec43a3497c Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
227 FILE *outFile = NULL;
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
228 JSSModule *mod = NULL;
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
229 JSSMixer *dev = NULL;
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
230 JSSPlayer *plr = NULL;
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
231 size_t bufLen = 1024*4, dataTotal, dataWritten, sampSize;
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
232 Uint8 *dataBuf = NULL;
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
233 int res = DMERR_OK;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 dmInitProg("mod2wav", "XM/JSSMOD to WAV renderer", "0.2", NULL, NULL);
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 dmVerbosity = 1;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 // Parse arguments
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 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
240 argHandleOpt, argHandleFile, OPTH_BAILOUT))
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
241 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 // Check arguments
300
4972ca91d062 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
244 if (optInFilename == NULL || optOutFilename == NULL)
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
245 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
246 res = dmError(DMERR_INVALID_ARGS,
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
247 "Input or output file not specified.\n");
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
248 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
250
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 // Initialize miniJSS
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 jssInit();
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
253
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 // Open the source file
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
255 if ((res = dmf_open_stdio(optInFilename, "rb", &inFile)) != DMERR_OK)
15
feec43a3497c Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
256 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
257 dmErrorMsg("Error opening input file '%s': %s\n",
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
258 optInFilename, dmErrorStr(res));
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
259 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 // Read module file
1199
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
263 dmMsg(1, "Reading file: %s\n", optInFilename);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 #ifdef JSS_SUP_XM
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
265 if (mod == NULL)
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
266 {
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
267 dmMsg(2, "* Trying XM...\n");
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
268 dmfreset(inFile);
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
269 if ((res = jssLoadXM(inFile, &mod, TRUE)) == DMERR_OK)
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
270 {
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
271 dmfreset(inFile);
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
272 res = jssLoadXM(inFile, &mod, FALSE);
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
273 }
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
274 }
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 #endif
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 #ifdef JSS_SUP_JSSMOD
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
277 if (mod == NULL)
15
feec43a3497c Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
278 {
777
ed60a7ee3ebb Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents: 730
diff changeset
279 dmMsg(1, "* Trying JSSMOD ...\n");
1199
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
280 dmfreset(inFile);
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
281 if ((res = jssLoadJSSMOD(inFile, &mod, TRUE)) == DMERR_OK)
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
282 {
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
283 dmfreset(inFile);
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
284 res = jssLoadJSSMOD(inFile, &mod, FALSE);
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
285 }
15
feec43a3497c Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
286 }
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 #endif
15
feec43a3497c Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
288 dmf_close(inFile);
1199
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
289
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
290 // Check for errors, we still might have some data tho
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
291 if (res != DMERR_OK)
15
feec43a3497c Fix input file reading of mod2wav utility.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
292 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
293 dmErrorMsg("Error loading module file: %s\n",
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
294 dmErrorStr(res));
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
295 goto out;
1199
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
296 }
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
297
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
298 // Check if we have anything
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
299 if (mod == NULL)
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
300 {
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
301 res = dmError(DMERR_INIT_FAIL,
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
302 "Could not load module file.\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
303 goto out;
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
304 }
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
306 // Try to convert it
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
307 if ((res = jssConvertModuleForPlaying(mod)) != DMERR_OK)
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
308 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
309 dmErrorMsg("Could not convert module for playing: %s\n",
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
310 dmErrorStr(res));
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
311 goto out;
49
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
312 }
033c660c25f5 Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
313
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 // Open mixer
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
315 dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO);
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
316 if (dev == NULL)
39
281b080e8c44 More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
317 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
318 res = dmError(DMERR_INIT_FAIL,
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
319 "jvmInit() returned NULL\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
320 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
323 sampSize = jvmGetSampleSize(dev);
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
324 if ((dataBuf = dmMalloc(bufLen * sampSize)) == NULL)
39
281b080e8c44 More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 38
diff changeset
325 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
326 res = dmError(DMERR_MALLOC,
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
327 "Could not allocate mixing buffer.\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
328 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
330
2389
647671a9a0b8 More printf() format specifier size_t -related fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2258
diff changeset
331 dmMsg(1, "Using fmt=%d, bits=%d, channels=%d, freq=%d [%" DM_PRIu_SIZE_T " / sample]\n",
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
332 optOutFormat, jvmGetSampleRes(dev), optOutChannels, optOutFreq,
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 sampSize);
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
334
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 // Initialize player
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
336 if ((plr = jmpInit(dev)) == NULL)
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
337 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
338 dmErrorMsg("jmpInit() returned NULL.\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
339 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
341
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 // Set callback
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
343 jvmSetCallback(dev, jmpExec, plr);
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
344
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 // Initialize playing
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
346 jmpSetModule(plr, mod);
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
347 if (optStartOrder >= 0)
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
348 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
349 dmMsg(1, "Starting from song order #%d\n",
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
350 optStartOrder);
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
351 }
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
352 else
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
353 {
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 optStartOrder = 0;
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
355 }
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
356
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
357 jmpPlayOrder(plr, optStartOrder);
185
1f8f4d7cb33b Increase default global volume.
Matti Hamalainen <ccr@tnsp.org>
parents: 83
diff changeset
358 jvmSetGlobalVol(dev, 150);
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
359
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
360 if (optMuteOChannels > 0 && optMuteOChannels <= mod->nchannels)
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
361 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
362 for (int i = 0; i < mod->nchannels; i++)
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
363 jvmMute(dev, i, TRUE);
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
364
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
365 jvmMute(dev, optMuteOChannels - 1, FALSE);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
367
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 // Open output file
300
4972ca91d062 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 285
diff changeset
369 if ((outFile = fopen(optOutFilename, "wb")) == NULL)
37
cec910d02b26 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
370 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
371 res = dmGetErrno();
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
372 dmErrorMsg("Error opening output file '%s': %s.\n",
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
373 optInFilename, dmErrorStr(res));
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
374 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 // Write initial header
206
9b6c0ed66960 Use the routines factored into dmwav module.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
378 dmWriteWAVHeader(outFile, jvmGetSampleRes(dev), optOutFreq, optOutChannels, 1024);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 // Render audio data and output to file
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 if (optUsePlayTime)
2389
647671a9a0b8 More printf() format specifier size_t -related fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 2258
diff changeset
382 dmMsg(1, "Rendering module (%" DM_PRIu_SIZE_T " seconds) ...\n", optPlayTime);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 else
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 dmMsg(1, "Rendering module ...\n");
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
385
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 optPlayTime *= optOutFreq;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 dataTotal = 0;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 dataWritten = 1;
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
389 while (plr->isPlaying && dataWritten > 0)
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 {
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 size_t writeLen = bufLen;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 if (optUsePlayTime && (writeLen + dataTotal) > optPlayTime)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 writeLen = optPlayTime - dataTotal;
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
394
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 if (writeLen > 0)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396 {
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
397 jvmRenderAudio(dev, dataBuf, writeLen);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
399 jssEncodeSample16((Uint16 *) dataBuf, writeLen * optOutChannels, jsampSwapEndianess);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 #endif
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
401 dataWritten = fwrite(dataBuf, sampSize, writeLen, outFile);
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 if (dataWritten < writeLen)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
404 res = dmError(DMERR_FWRITE,
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
405 "Error writing audio data!\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
406 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 }
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408 dataTotal += dataWritten;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
410
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 if (optUsePlayTime && dataTotal >= optPlayTime)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 break;
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
414
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415 // Write the correct header
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 if (fseek(outFile, 0L, SEEK_SET) != 0)
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 {
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
418 res = dmError(DMERR_FSEEK,
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
419 "Error rewinding to header position!\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
420 goto out;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 }
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
422
206
9b6c0ed66960 Use the routines factored into dmwav module.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
423 dmWriteWAVHeader(outFile, jvmGetSampleRes(dev), optOutFreq, optOutChannels, dataTotal);
1235
5b8245e5f785 Remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
424
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425 // Done!
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
426 dmMsg(1, "OK.\n");
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
427
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2530
diff changeset
428 out:
2258
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
429 if (outFile != NULL)
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
430 fclose(outFile);
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
431
c146033f1f6a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2183
diff changeset
432 dmFree(dataBuf);
68
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
433 jmpClose(plr);
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
434 jvmClose(dev);
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
435 jssFreeModule(mod);
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
436 jssClose();
182e5fac93f5 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
437
2530
aacf3bd1cceb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 2410
diff changeset
438 return res;
0
32250b436bca Initial re-import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 }