mirror of
https://github.com/ScrelliCopter/VGM-Tools
synced 2025-02-21 04:09:25 +11:00
neotools: code fixup & vgz support
This commit is contained in:
@@ -5,51 +5,46 @@
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
return 1;
|
||||
if (argc != 2) return 1;
|
||||
|
||||
// Open file.
|
||||
FILE* file = fopen(argv[1], "rb");
|
||||
if (!file)
|
||||
return 1;
|
||||
nfile* file = nopen(argv[1], "rb"); // Open file
|
||||
if (!file) return 1;
|
||||
|
||||
// Error on VGZ's for now.
|
||||
if (fgetc(file) == 0x1F && fgetc(file) == 0x8B)
|
||||
#if !USE_ZLIB
|
||||
if (ngetc(file) == 0x1F && ngetc(file) == 0x8B)
|
||||
{
|
||||
printf("I'm a little gzip short and stout\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_SET);
|
||||
nseek(file, 0, SEEK_SET);
|
||||
#endif
|
||||
|
||||
Buffer smpbuf = {NULL, 0, 0};
|
||||
char name[32];
|
||||
int smpaCount = 0, smpbCount = 0;
|
||||
|
||||
// Find ADCPM samples.
|
||||
// Find ADCPM samples
|
||||
int scanType;
|
||||
while ((scanType = vgmScanSample(file)))
|
||||
{
|
||||
if (scanType != 'A' && scanType != 'B')
|
||||
continue;
|
||||
fprintf(stderr, "ADPCM-%c data found at 0x%08lX\n", scanType, ftell(file));
|
||||
fprintf(stderr, "ADPCM-%c data found at 0x%08lX\n", scanType, ntell(file));
|
||||
|
||||
if (vgmReadSample(file, &smpbuf) || smpbuf.size == 0)
|
||||
continue;
|
||||
if (scanType == 'A')
|
||||
{
|
||||
// decode
|
||||
snprintf(name, sizeof(name), "smpa_%02x.pcm", smpaCount++);
|
||||
printf("./adpcm \"%s\" \"$WAVDIR/%s.wav\"\n", name, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// decode
|
||||
snprintf(name, sizeof(name), "smpb_%02x.pcm", smpbCount++);
|
||||
printf("./adpcmb -d \"%s\" \"$WAVDIR/%s.wav\"\n", name, name);
|
||||
}
|
||||
|
||||
// Write adpcm sample.
|
||||
// Write ADPCM sample
|
||||
FILE* fout = fopen(name, "wb");
|
||||
if (!fout)
|
||||
continue;
|
||||
@@ -58,6 +53,6 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
free(smpbuf.data);
|
||||
fclose(file);
|
||||
nclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user