From 272a23490d2f14a80371a759b3ada02ca20e3fd0 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 26 May 2019 22:55:37 +0200 Subject: [PATCH] Add FSB5 .bank [Shantae: Half-Genie Hero (Switch)] --- src/formats.c | 1 + src/libvgmstream.vcproj | 12 ++++--- src/libvgmstream.vcxproj | 1 + src/libvgmstream.vcxproj.filters | 3 ++ src/meta/fsb5_fev.c | 54 ++++++++++++++++++++++++++++++++ src/meta/meta.h | 2 ++ src/vgmstream.c | 1 + 7 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 src/meta/fsb5_fev.c diff --git a/src/formats.c b/src/formats.c index 720b22ea..be29f374 100644 --- a/src/formats.c +++ b/src/formats.c @@ -73,6 +73,7 @@ static const char* extension_list[] = { "b1s", "baf", "baka", + "bank", "bar", "bcstm", "bcwav", diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 99b9fafd..577084f7 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -608,10 +608,14 @@ RelativePath=".\meta\fsb.c" > - - + + + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 25ceb131..ff20d5ef 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -275,6 +275,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index ef23711f..ce1ec309 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -391,6 +391,9 @@ meta\Source Files + + meta\Source Files + meta\Source Files diff --git a/src/meta/fsb5_fev.c b/src/meta/fsb5_fev.c new file mode 100644 index 00000000..74b1dba4 --- /dev/null +++ b/src/meta/fsb5_fev.c @@ -0,0 +1,54 @@ +#include "meta.h" +#include "../coding/coding.h" + +/* FEV+FSB5 container [Shantae: Half-Genie Hero (Switch)] */ +VGMSTREAM * init_vgmstream_fsb5_fev_bank(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + STREAMFILE *temp_streamFile = NULL; + off_t subfile_offset, chunk_offset, first_offset = 0x0c; + size_t subfile_size, chunk_size; + + + /* checks */ + if (!check_extensions(streamFile, "bank")) + goto fail; + + if (read_32bitBE(0x00,streamFile) != 0x52494646) /* "RIFF" */ + goto fail; + if (read_32bitBE(0x08,streamFile) != 0x46455620) /* "FEV " */ + goto fail; + + /* .fev is an event format referencing various external .fsb, but FMOD can bake .fev and .fsb to + * form a .bank, which is the format we support here (regular .fev is complex and not very interesting). + * Format is RIFF with FMT (main), LIST (config) and SND (FSB5 data), we want the FSB5 offset inside LIST */ + if (!find_chunk_le(streamFile, 0x4C495354,first_offset,0, &chunk_offset,NULL)) /* "LIST" */ + goto fail; + + if (read_32bitBE(chunk_offset+0x00,streamFile) != 0x50524F4A || /* "PROJ" */ + read_32bitBE(chunk_offset+0x04,streamFile) != 0x424E4B49) /* "BNKI" */ + goto fail; /* event .fev has "OBCT" instead of "BNKI" */ + + /* inside BNKI is a bunch of LIST each with event subchunks and finally the fsb offset */ + first_offset = chunk_offset + 0x04; + if (!find_chunk_le(streamFile, 0x534E4448,first_offset,0, &chunk_offset,&chunk_size)) /* "SNDH" */ + goto fail; + + if (chunk_size != 0x0c) + goto fail; /* assuming only one FSB5 is possible */ + subfile_offset = read_32bitLE(chunk_offset+0x04,streamFile); + subfile_size = read_32bitLE(chunk_offset+0x08,streamFile); + + + temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, "fsb"); + if (!temp_streamFile) goto fail; + + vgmstream = init_vgmstream_fsb5(temp_streamFile); + close_streamfile(temp_streamFile); + + return vgmstream; + +fail: + close_streamfile(temp_streamFile); + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/meta.h b/src/meta/meta.h index 631eac00..a1111095 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -852,4 +852,6 @@ VGMSTREAM * init_vgmstream_xwma_konami(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_9tav(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_fsb5_fev_bank(STREAMFILE * streamFile); + #endif /*_META_H*/ diff --git a/src/vgmstream.c b/src/vgmstream.c index 4e6c327d..1cd0be53 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -479,6 +479,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_msf_konami, init_vgmstream_xwma_konami, init_vgmstream_9tav, + init_vgmstream_fsb5_fev_bank, /* 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 */