mirror of
https://github.com/ScrelliCopter/VGM-Tools
synced 2025-02-21 04:09:25 +11:00
move main to a new source file, update makefile to support multiple sources
This commit is contained in:
18
neotools/autoextract.c
Normal file
18
neotools/autoextract.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "neoadpcmextract.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
if (argc != 2)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
// Open file.
|
||||||
|
FILE* file = fopen(argv[1], "rb");
|
||||||
|
if (!file)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
int err = vgmExtractSamples(file);
|
||||||
|
fclose(file);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
@@ -1,12 +1,23 @@
|
|||||||
TARGET := neoadpcmextract
|
TARGET := neoadpcmextract
|
||||||
SOURCE := neoadpcmextract.c
|
SOURCE := autoextract.c neoadpcmextract.c
|
||||||
CFLAGS := -std=c99 -O2 -pipe -Wall -Wextra -pedantic
|
CFLAGS := -std=c99 -O2 -pipe -Wall -Wextra -pedantic
|
||||||
|
LDFLAGS := $(CFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
OBJECT := $(SOURCE:%.c=%.o)
|
||||||
|
DEPEND := $(OBJECT:%.o=%.d)
|
||||||
|
|
||||||
|
.PHONY: default all clean
|
||||||
|
default: $(TARGET)
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(SOURCE)
|
$(TARGET): $(OBJECT)
|
||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(LDFLAGS) $^ -o $@
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(CFLAGS) -MMD -c $< -o $@
|
||||||
|
|
||||||
|
-include: $(DEPEND)
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGET)
|
rm -f $(TARGET) $(OBJECT) $(DEPEND)
|
||||||
|
|||||||
@@ -61,22 +61,18 @@ int DecodeSample(FILE* fin, const char* name, Buffer* buf)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int vgmExtractSamples(FILE* file)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Open file.
|
|
||||||
FILE* file = fopen(argv[1], "rb");
|
|
||||||
if (!file)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Search for pcm headers.
|
|
||||||
Buffer smpBytes = {NULL, 0};
|
Buffer smpBytes = {NULL, 0};
|
||||||
char namebuf[32];
|
char namebuf[32];
|
||||||
int smpaCount = 0, smpbCount = 0;
|
int smpaCount = 0, smpbCount = 0;
|
||||||
|
|
||||||
|
// Scan for pcm headers.
|
||||||
while (!feof(file) && !ferror(file))
|
while (!feof(file) && !ferror(file))
|
||||||
{
|
{
|
||||||
|
// Patterns to match (in hex):
|
||||||
|
// 67 66 82 - ADPCM-A
|
||||||
|
// 67 66 83 - ADPCM-B
|
||||||
if (fgetc(file) != 0x67 || fgetc(file) != 0x66)
|
if (fgetc(file) != 0x67 || fgetc(file) != 0x66)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -98,6 +94,5 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(smpBytes.data);
|
free(smpBytes.data);
|
||||||
fclose(file);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user