From 89548b417af2e7413cdf0b532064503659185dfb Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 27 Mar 2021 17:42:03 +0100 Subject: [PATCH] Fix .nus3audio with dummy entries [Gundam Extreme Vs M.B. ON (PS4)] --- src/meta/nus3audio.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/meta/nus3audio.c b/src/meta/nus3audio.c index 043a832e..ff74c4ca 100644 --- a/src/meta/nus3audio.c +++ b/src/meta/nus3audio.c @@ -3,7 +3,7 @@ typedef enum { IDSP, OPUS, RIFF, } nus3audio_codec; -/* .nus3audio - Namco's newest newest audio container [Super Smash Bros. Ultimate (Switch)] */ +/* .nus3audio - Namco's newest newest audio container [Super Smash Bros. Ultimate (Switch), Mobile Suit Gundam: Extreme Vs. Maxi Boost ON (PS4)] */ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) { VGMSTREAM* vgmstream = NULL; STREAMFILE* temp_sf = NULL; @@ -11,7 +11,7 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) { size_t subfile_size = 0; nus3audio_codec codec; const char* fake_ext = NULL; - int total_subsongs, target_subsong = sf->stream_index; + int total_subsongs, target_subsong = sf->stream_index, found = 0; /* checks */ @@ -51,6 +51,7 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) { case 0x41444F46: /* "ADOF": audio offsets (absolute, inside PACK) */ subfile_offset = read_u32le(offset+0x08 + 0x08*(target_subsong-1) + 0x00,sf); subfile_size = read_u32le(offset+0x08 + 0x08*(target_subsong-1) + 0x04,sf); + found = 1; break; case 0x544E4944: /* "TNID": tone ids? */ @@ -64,11 +65,23 @@ VGMSTREAM* init_vgmstream_nus3audio(STREAMFILE* sf) { offset += 0x08 + chunk_size; } - if (total_subsongs == 0 || subfile_offset == 0 || subfile_size == 0) { + if (total_subsongs == 0 || !found) { VGM_LOG("NUS3AUDIO: subfile not found\n"); goto fail; } + /* handle dummy entries, ex. Gundam EvM (PS4) */ + if (subfile_offset == 0 && subfile_size == 0) { + vgmstream = init_vgmstream_silence(0, 0, 0); + if (!vgmstream) goto fail; + + vgmstream->num_streams = total_subsongs; + snprintf(vgmstream->stream_name, STREAM_NAME_SIZE, "%s", "dummy"); + + return vgmstream; + } + + codec_id = read_u32be(subfile_offset, sf); switch(codec_id) { case 0x49445350: /* "IDSP" */