Add .ifs with bgm subsongs [drummania (AC), GITADORA (AC)]

This commit is contained in:
bnnm 2020-12-20 15:07:23 +01:00
parent 0958519274
commit 3a2cc91891
7 changed files with 83 additions and 4 deletions

View File

@ -221,6 +221,7 @@ static const char* extension_list[] = {
"idwav",
"idx",
"idxma",
"ifs",
"ikm",
"ild",
"ilv", //txth/reserved [Star Wars Episode III (PS2)]

View File

@ -1282,10 +1282,14 @@
RelativePath=".\meta\ps2_iab.c"
>
</File>
<File
RelativePath=".\meta\ikm.c"
>
</File>
<File
RelativePath=".\meta\ifs.c"
>
</File>
<File
RelativePath=".\meta\ikm.c"
>
</File>
<File
RelativePath=".\meta\ps2_ild.c"
>

View File

@ -441,6 +441,7 @@
<ClCompile Include="meta\ps2_gbts.c" />
<ClCompile Include="meta\ps2_gcm.c" />
<ClCompile Include="meta\ps2_hgc1.c" />
<ClCompile Include="meta\ifs.c" />
<ClCompile Include="meta\ikm.c" />
<ClCompile Include="meta\ps2_ild.c" />
<ClCompile Include="meta\raw_int.c" />

View File

@ -826,6 +826,9 @@
<ClCompile Include="meta\ps2_hgc1.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ifs.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ikm.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

67
src/meta/ifs.c Normal file
View File

@ -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;
}

View File

@ -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*/

View File

@ -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 */