diff --git a/src/formats.c b/src/formats.c index eb4d2c2a..3d27fd46 100644 --- a/src/formats.c +++ b/src/formats.c @@ -221,6 +221,7 @@ static const char* extension_list[] = { "idwav", "idx", "idxma", + "ifs", "ikm", "ild", "ilv", //txth/reserved [Star Wars Episode III (PS2)] diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 571ca423..d8410760 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1282,10 +1282,14 @@ RelativePath=".\meta\ps2_iab.c" > - - + + + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 372ed62c..e7e5698f 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -441,6 +441,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index 28e5febe..65c92f9a 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -826,6 +826,9 @@ meta\Source Files + + meta\Source Files + meta\Source Files diff --git a/src/meta/ifs.c b/src/meta/ifs.c new file mode 100644 index 00000000..b81bf15a --- /dev/null +++ b/src/meta/ifs.c @@ -0,0 +1,67 @@ +#include "meta.h" +#include "../coding/coding.h" + + +/* .ifs - Konami arcade games container [drummania (AC), GITADORA (AC)] */ +VGMSTREAM* init_vgmstream_ifs(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + STREAMFILE* temp_sf = NULL; + off_t subfile_offset, subfile_size; + int total_subsongs, target_subsong = sf->stream_index; + + + /* checks */ + if (!check_extensions(sf, "ifs")) + goto fail; + + if (read_u32be(0x00,sf) != 0x6CAD8F89) + goto fail; + if (read_u16be(0x04,sf) != 0x0003) + goto fail; + + /* .ifs format is a binary XML thing with types/fields/nodes/etc, that sometimes + * contains Konami's BMP as subsongs (may differ in num_samples). This is an + * abridged version of the whole thing, see: + * - https://github.com/mon/ifstools + * - https://github.com/mon/kbinxml + * - https://bitbucket.org/ahigerd/gitadora2wav/ + */ + + { + off_t offset, size, subfile_start; + + subfile_start = read_u32be(0x10,sf); + + /* skip root section and point to childs */ + offset = 0x28 + 0x04 + read_u32be(0x28,sf); + size = read_u32be(offset + 0x00,sf); + offset += 0x04; + + /* point to subfile offsets */ + size = size - 0x04 - read_u32be(offset + 0x00,sf) - 0x04; + offset = offset + 0x04 + read_u32be(offset + 0x00,sf) + 0x04; + + total_subsongs = size / 0x0c; + if (target_subsong == 0) target_subsong = 1; + if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail; + + subfile_offset = read_u32be(offset + (target_subsong-1)*0x0c + 0x00,sf) + subfile_start; + subfile_size = read_u32be(offset + (target_subsong-1)*0x0c + 0x04,sf); + } + + temp_sf = setup_subfile_streamfile(sf, subfile_offset, subfile_size, "bin"); + if (!temp_sf) goto fail; + + vgmstream = init_vgmstream_bmp_konami(temp_sf); + if (!vgmstream) goto fail; + + vgmstream->num_streams = total_subsongs; + /* subsongs have names but are packed in six-bit strings */ + + close_streamfile(temp_sf); + return vgmstream; +fail: + close_streamfile(temp_sf); + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/meta.h b/src/meta/meta.h index 0aa2b17a..95b37232 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -932,4 +932,6 @@ VGMSTREAM* init_vgmstream_cpk_memory(STREAMFILE* sf, STREAMFILE* sf_acb); VGMSTREAM *init_vgmstream_sbk(STREAMFILE *sf); +VGMSTREAM* init_vgmstream_ifs(STREAMFILE* sf); + #endif /*_META_H*/ diff --git a/src/vgmstream.c b/src/vgmstream.c index 99ba51bc..dac2703c 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -515,6 +515,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = { init_vgmstream_sbk, init_vgmstream_dsp_wiiadpcm, init_vgmstream_dsp_cwac, + init_vgmstream_ifs, /* 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 */