From 5734a84a23c730d3eaced7c1b974be79a94d2416 Mon Sep 17 00:00:00 2001 From: Simon Aarons Date: Fri, 12 Jul 2019 20:14:39 +1000 Subject: [PATCH] Implement Traveller's Tales' RAD --- src/formats.c | 2 ++ src/libvgmstream.vcxproj | 1 + src/libvgmstream.vcxproj.filters | 3 +++ src/meta/meta.h | 2 ++ src/meta/rad.c | 35 ++++++++++++++++++++++++++++++++ src/vgmstream.c | 1 + src/vgmstream.h | 1 + 7 files changed, 45 insertions(+) create mode 100644 src/meta/rad.c diff --git a/src/formats.c b/src/formats.c index 5d8015d5..2b45dd1a 100644 --- a/src/formats.c +++ b/src/formats.c @@ -333,6 +333,7 @@ static const char* extension_list[] = { "r", "rac", //txth/reserved [Manhunt (Xbox)] + "rad", "rak", "ras", "raw", @@ -1195,6 +1196,7 @@ static const meta_info meta_info_list[] = { {meta_XWMA_KONAMI, "Konami XWMA header"}, {meta_9TAV, "Konami 9TAV header"}, {meta_BWAV, "Nintendo BWAV header"}, + {meta_RAD, "Traveller's Tales RAD header"}, }; diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 2097749c..58b5600d 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -186,6 +186,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index cd99b470..6537c291 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -1591,5 +1591,8 @@ meta\Source Files + + meta\Source Files + \ No newline at end of file diff --git a/src/meta/meta.h b/src/meta/meta.h index 51236281..7789dd09 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -861,4 +861,6 @@ VGMSTREAM * init_vgmstream_opus_prototype(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_awb(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_rad(STREAMFILE * streamFile); + #endif /*_META_H*/ diff --git a/src/meta/rad.c b/src/meta/rad.c new file mode 100644 index 00000000..e6bcb347 --- /dev/null +++ b/src/meta/rad.c @@ -0,0 +1,35 @@ +#include "meta.h" +#include "../coding/coding.h" + +/* RAD - from Traveller's Tales' Bionicle Heroes */ +VGMSTREAM * init_vgmstream_rad(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + off_t start_offset; + int channel_count, loop_flag = 0; + + /* checks */ + if (!check_extensions(streamFile, "rad")) + goto fail; + + start_offset = read_32bitLE(0x00, streamFile); + channel_count = read_8bit(0x0D, streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count, loop_flag); + if (!vgmstream) goto fail; + + vgmstream->sample_rate = read_32bitLE(0x04, streamFile); + vgmstream->num_samples = read_32bitLE(0x08, streamFile); + vgmstream->meta_type = meta_RAD; + vgmstream->layout_type = layout_none; + vgmstream->coding_type = coding_PCM16LE; + + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; + + return vgmstream; + +fail: + close_vgmstream(vgmstream); + return NULL; +} \ No newline at end of file diff --git a/src/vgmstream.c b/src/vgmstream.c index 669864b8..5fbfb041 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -483,6 +483,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_bwav, init_vgmstream_opus_prototype, init_vgmstream_awb, + init_vgmstream_rad, /* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */ init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */ diff --git a/src/vgmstream.h b/src/vgmstream.h index 609dd30e..4469a84e 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -731,6 +731,7 @@ typedef enum { meta_XWMA_KONAMI, meta_9TAV, meta_BWAV, + meta_RAD, } meta_t;