Mercurial > hg > dmlib
comparison tools/mod2wav.c @ 2586:9807ae37ad69
Require stdbool.h, we require C11 now.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 08 Dec 2022 15:59:22 +0200 |
parents | b205c60aa657 |
children |
comparison
equal
deleted
inserted
replaced
2585:ef6c826c5b7a | 2586:9807ae37ad69 |
---|---|
56 int optOutFormat = JSS_AUDIO_S16, | 56 int optOutFormat = JSS_AUDIO_S16, |
57 optOutChannels = 2, | 57 optOutChannels = 2, |
58 optOutFreq = 44100, | 58 optOutFreq = 44100, |
59 optMuteOChannels = -1, | 59 optMuteOChannels = -1, |
60 optStartOrder = -1; | 60 optStartOrder = -1; |
61 BOOL optUsePlayTime = FALSE; | 61 bool optUsePlayTime = false; |
62 size_t optPlayTime; | 62 size_t optPlayTime; |
63 | 63 |
64 | 64 |
65 static const DMOptArg optList[] = | 65 static const DMOptArg optList[] = |
66 { | 66 { |
87 dmPrintBanner(stdout, dmProgName, "[options] [sourcefile] [destfile.wav]"); | 87 dmPrintBanner(stdout, dmProgName, "[options] [sourcefile] [destfile.wav]"); |
88 dmArgsPrintHelp(stdout, optList, optListN, 0, 80 - 2); | 88 dmArgsPrintHelp(stdout, optList, optListN, 0, 80 - 2); |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) | 92 bool argHandleOpt(const int optN, char *optArg, char *currArg) |
93 { | 93 { |
94 (void) optArg; | 94 (void) optArg; |
95 | 95 |
96 switch (optN) | 96 switch (optN) |
97 { | 97 { |
137 optStartOrder = atoi(optArg); | 137 optStartOrder = atoi(optArg); |
138 break; | 138 break; |
139 | 139 |
140 case 24: | 140 case 24: |
141 optPlayTime = atoi(optArg); | 141 optPlayTime = atoi(optArg); |
142 optUsePlayTime = TRUE; | 142 optUsePlayTime = true; |
143 break; | 143 break; |
144 | 144 |
145 default: | 145 default: |
146 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg); | 146 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg); |
147 return FALSE; | 147 return false; |
148 } | 148 } |
149 | 149 |
150 return TRUE; | 150 return true; |
151 } | 151 } |
152 | 152 |
153 | 153 |
154 BOOL argHandleFile(char *currArg) | 154 bool argHandleFile(char *currArg) |
155 { | 155 { |
156 if (optInFilename == NULL) | 156 if (optInFilename == NULL) |
157 optInFilename = currArg; | 157 optInFilename = currArg; |
158 else | 158 else |
159 if (optOutFilename == NULL) | 159 if (optOutFilename == NULL) |
160 optOutFilename = currArg; | 160 optOutFilename = currArg; |
161 else | 161 else |
162 { | 162 { |
163 dmErrorMsg("Too many filename arguments (only source and dest needed) '%s'\n", currArg); | 163 dmErrorMsg("Too many filename arguments (only source and dest needed) '%s'\n", currArg); |
164 return FALSE; | 164 return false; |
165 } | 165 } |
166 | 166 |
167 return TRUE; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 BOOL dmWriteWAVChunk(FILE * f, DMWaveChunk *ch) | 171 bool dmWriteWAVChunk(FILE * f, DMWaveChunk *ch) |
172 { | 172 { |
173 return dm_fwrite_str(f, ch->chunkID, 4) && dm_fwrite_le32(f, ch->chunkSize); | 173 return dm_fwrite_str(f, ch->chunkID, 4) && dm_fwrite_le32(f, ch->chunkSize); |
174 } | 174 } |
175 | 175 |
176 | 176 |
265 #ifdef JSS_SUP_XM | 265 #ifdef JSS_SUP_XM |
266 if (mod == NULL) | 266 if (mod == NULL) |
267 { | 267 { |
268 dmMsg(2, "* Trying XM...\n"); | 268 dmMsg(2, "* Trying XM...\n"); |
269 dmfreset(inFile); | 269 dmfreset(inFile); |
270 if ((res = jssLoadXM(inFile, &mod, TRUE)) == DMERR_OK) | 270 if ((res = jssLoadXM(inFile, &mod, true)) == DMERR_OK) |
271 { | 271 { |
272 dmfreset(inFile); | 272 dmfreset(inFile); |
273 res = jssLoadXM(inFile, &mod, FALSE); | 273 res = jssLoadXM(inFile, &mod, false); |
274 } | 274 } |
275 } | 275 } |
276 #endif | 276 #endif |
277 #ifdef JSS_SUP_JSSMOD | 277 #ifdef JSS_SUP_JSSMOD |
278 if (mod == NULL) | 278 if (mod == NULL) |
279 { | 279 { |
280 dmMsg(1, "* Trying JSSMOD ...\n"); | 280 dmMsg(1, "* Trying JSSMOD ...\n"); |
281 dmfreset(inFile); | 281 dmfreset(inFile); |
282 if ((res = jssLoadJSSMOD(inFile, &mod, TRUE)) == DMERR_OK) | 282 if ((res = jssLoadJSSMOD(inFile, &mod, true)) == DMERR_OK) |
283 { | 283 { |
284 dmfreset(inFile); | 284 dmfreset(inFile); |
285 res = jssLoadJSSMOD(inFile, &mod, FALSE); | 285 res = jssLoadJSSMOD(inFile, &mod, false); |
286 } | 286 } |
287 } | 287 } |
288 #endif | 288 #endif |
289 dmf_close(inFile); | 289 dmf_close(inFile); |
290 | 290 |
359 jvmSetGlobalVol(dev, 150); | 359 jvmSetGlobalVol(dev, 150); |
360 | 360 |
361 if (optMuteOChannels > 0 && optMuteOChannels <= mod->nchannels) | 361 if (optMuteOChannels > 0 && optMuteOChannels <= mod->nchannels) |
362 { | 362 { |
363 for (int i = 0; i < mod->nchannels; i++) | 363 for (int i = 0; i < mod->nchannels; i++) |
364 jvmMute(dev, i, TRUE); | 364 jvmMute(dev, i, true); |
365 | 365 |
366 jvmMute(dev, optMuteOChannels - 1, FALSE); | 366 jvmMute(dev, optMuteOChannels - 1, false); |
367 } | 367 } |
368 | 368 |
369 // Open output file | 369 // Open output file |
370 if ((outFile = fopen(optOutFilename, "wb")) == NULL) | 370 if ((outFile = fopen(optOutFilename, "wb")) == NULL) |
371 { | 371 { |