Merge pull request #1524 from EdnessP/master

EA SBK: sbnk+sdat/BNKx
This commit is contained in:
bnnm 2024-05-11 12:07:19 +02:00 committed by GitHub
commit f7c272d892
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 109 additions and 0 deletions

0
3
View File

View File

@ -1433,6 +1433,7 @@ static const meta_info meta_info_list[] = {
{meta_GWB_GWD, "Ubisoft GWB+GWD header"},
{meta_CBX, "Traveller's Tales CBX header"},
{meta_VAS_ROCKSTAR, "Rockstar .VAS header"},
{meta_EA_SBK, "Electronic Arts SBK header"},
};
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {

View File

@ -430,6 +430,7 @@
<ClCompile Include="meta\ea_eaac_sbr_harmony.c" />
<ClCompile Include="meta\ea_eaac_standard.c" />
<ClCompile Include="meta\ea_eaac_tmx.c" />
<ClCompile Include="meta\ea_sbk.c" />
<ClCompile Include="meta\ea_schl.c" />
<ClCompile Include="meta\ea_schl_fixed.c" />
<ClCompile Include="meta\ea_swvr.c" />

View File

@ -1111,6 +1111,9 @@
<ClCompile Include="meta\ea_eaac_tmx.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ea_sbk.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ea_schl.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

95
src/meta/ea_sbk.c Normal file
View File

@ -0,0 +1,95 @@
#include "meta.h"
#include "../util/endianness.h"
/* .SBK - EA Redwood Shores soundbank (Simpsons Game, Godfather) */
VGMSTREAM* init_vgmstream_ea_sbk(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int target_stream = sf->stream_index;
off_t sdat_offset;
size_t sdat_size;
read_u32_t read_u32;
/* checks */
if (!is_id32be(0x00, sf, "sbnk") && /* sbnk */
!is_id32le(0x00, sf, "sbnk")) /* knbs */
return NULL;
if (!check_extensions(sf, "sbk"))
return NULL;
read_u32 = is_id32be(0x00, sf, "sbnk") ? read_u32le : read_u32be;
/* sdat_size is stored at 0x0C too? */
sdat_offset = read_u32(0x10, sf);
sdat_size = read_u32(0x14, sf);
/* lots of other unk data between here and the sdat chunk */
if (read_u32(0x0C, sf) != sdat_size)
goto fail;
if (sdat_offset + sdat_size != get_streamfile_size(sf))
goto fail;
if (target_stream < 0) goto fail;
if (target_stream == 0) target_stream = 1;
target_stream -= 1;
if (is_id32be(sdat_offset, sf, "BNKl") ||
is_id32be(sdat_offset, sf, "BNKb")) {
/* The Godfather */
vgmstream = load_vgmstream_ea_bnk(sf, sdat_offset, target_stream, 0);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_EA_SBK;
}
else if (is_id32be(sdat_offset, sf, "sdat") || /* sdat */
is_id32le(sdat_offset, sf, "sdat")) { /* tads */
/* The Simpsons Game, The Godfather II */
int total_streams;
off_t entry_offset, stream_offset;
eaac_meta_t info = {0};
total_streams = read_u32(sdat_offset + 0x04, sf);
if (total_streams < 1 || target_stream + 1 > total_streams)
goto fail;
/* For each entry:
* 0x00: stream index
* 0x04: 0x0313BABE (?)
* 0x08: stream offset
* 0x0C: 0xFEEDFEED (?)
*/
entry_offset = sdat_offset + 0x08 + target_stream * 0x10;
if (read_u32(entry_offset + 0x00, sf) != target_stream) goto fail;
stream_offset = sdat_offset + read_u32(entry_offset + 0x08, sf);
info.sf_head = sf;
info.sf_body = sf;
info.head_offset = stream_offset;
//info.body_offset
info.type = meta_EA_SBK;
vgmstream = load_vgmstream_ea_eaac(&info);
if (!vgmstream) goto fail;
vgmstream->num_streams = total_streams;
}
else {
VGM_LOG("EA SBK: unsupported sound data chunk\n");
goto fail;
}
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -142,6 +142,10 @@ static off_t get_ea_stream_mpeg_start_offset(STREAMFILE* sf, off_t start_offset,
static VGMSTREAM* init_vgmstream_ea_variable_header(STREAMFILE* sf, ea_header* ea, off_t start_offset, int is_bnk);
static void update_ea_stream_size(STREAMFILE* sf, off_t start_offset, VGMSTREAM* vgmstream);
VGMSTREAM* load_vgmstream_ea_bnk(STREAMFILE* sf, off_t offset, int target_stream, int is_embedded) {
return parse_bnk_header(sf, offset, target_stream, is_embedded);
}
/* EA SCHl with variable header - from EA games (roughly 1997~2010); generated by EA Canada's sx.exe/Sound eXchange */
VGMSTREAM* init_vgmstream_ea_schl(STREAMFILE* sf) {

View File

@ -1004,4 +1004,7 @@ VGMSTREAM* init_vgmstream_cbx(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_vas_rockstar(STREAMFILE* sf);
VGMSTREAM* load_vgmstream_ea_bnk(STREAMFILE* sf, off_t offset, int target_stream, int is_embedded);
VGMSTREAM* init_vgmstream_ea_sbk(STREAMFILE* sf);
#endif /*_META_H*/

View File

@ -523,6 +523,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_s_pack,
init_vgmstream_cbx,
init_vgmstream_vas_rockstar,
init_vgmstream_ea_sbk,
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
init_vgmstream_agsc,

View File

@ -707,6 +707,7 @@ typedef enum {
meta_GWB_GWD,
meta_CBX,
meta_VAS_ROCKSTAR,
meta_EA_SBK,
} meta_t;