From caf3bb871c1a55480eef82201f458c3ac611dc65 Mon Sep 17 00:00:00 2001 From: bxaimc Date: Wed, 16 May 2018 17:58:09 -0400 Subject: [PATCH] Add PSI file reading in Opus for loops in BlazBlue: Cross Tag Battle (Switch) --- src/formats.c | 1 + src/meta/opus.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/formats.c b/src/formats.c index aa893007..c0fd8336 100644 --- a/src/formats.c +++ b/src/formats.c @@ -250,6 +250,7 @@ static const char* extension_list[] = { "pos", "ps2stm", //fake extension for .stm (to be removed) "psh", // fake extension for VSV(?) Dawn of Mana needs to be checked again + "psi", // PSI Metadata for Opus - BlazBlue: Cross Tag Battle (Switch), Maybe others? "psnd", "psw", //fake extension for .wam diff --git a/src/meta/opus.c b/src/meta/opus.c index a120147a..60aef357 100644 --- a/src/meta/opus.c +++ b/src/meta/opus.c @@ -88,6 +88,7 @@ fail: /* standard Switch Opus, Nintendo header + raw data (generated by opus_test.c?) [Lego City Undercover (Switch)] */ VGMSTREAM * init_vgmstream_opus_std(STREAMFILE *streamFile) { + STREAMFILE * PSIFile = NULL; off_t offset = 0; int num_samples = 0, loop_start = 0, loop_end = 0; @@ -95,10 +96,23 @@ VGMSTREAM * init_vgmstream_opus_std(STREAMFILE *streamFile) { if (!check_extensions(streamFile,"opus,lopus")) goto fail; - offset = 0x00; - num_samples = 0; - loop_start = 0; - loop_end = 0; + /* BlazBlue: Cross Tag Battle (Switch) PSI Metadata for corresponding Opus */ + /* Maybe future Arc System Works games will use this too? */ + PSIFile = open_streamfile_by_ext(streamFile, "psi"); + + offset = 0x00; + + if (PSIFile){ + num_samples = read_32bitLE(0x8C, PSIFile); + loop_start = read_32bitLE(0x84, PSIFile); + loop_end = read_32bitLE(0x88, PSIFile); + close_streamfile(PSIFile); + } + else { + num_samples = 0; + loop_start = 0; + loop_end = 0; + } return init_vgmstream_opus(streamFile, meta_OPUS, offset, num_samples,loop_start,loop_end); fail: