From 0742206f53426c7a2b7c61fd77b2b6313e2c9684 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 15 Jul 2018 18:40:01 -0700 Subject: [PATCH] Updated VGMStream to r1050-1395-g454488b5. --- Frameworks/vgmstream/vgmstream/src/formats.c | 1 + .../vgmstream/vgmstream/src/meta/meta.h | 2 + .../vgmstream/vgmstream/src/meta/opus.c | 60 +++++++++++++++++++ .../vgmstream/vgmstream/src/vgmstream.c | 2 + 4 files changed, 65 insertions(+) diff --git a/Frameworks/vgmstream/vgmstream/src/formats.c b/Frameworks/vgmstream/vgmstream/src/formats.c index c503a4318..2f58b387b 100644 --- a/Frameworks/vgmstream/vgmstream/src/formats.c +++ b/Frameworks/vgmstream/vgmstream/src/formats.c @@ -233,6 +233,7 @@ static const char* extension_list[] = { "naac", "ndp", "ngca", + "nlsd", "nop", "nps", "npsf", //fake extension/header id for .nps (to be removed) diff --git a/Frameworks/vgmstream/vgmstream/src/meta/meta.h b/Frameworks/vgmstream/vgmstream/src/meta/meta.h index cb6317490..c4545d642 100644 --- a/Frameworks/vgmstream/vgmstream/src/meta/meta.h +++ b/Frameworks/vgmstream/vgmstream/src/meta/meta.h @@ -674,6 +674,8 @@ VGMSTREAM * init_vgmstream_opus_n1(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_opus_capcom(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_opus_nop(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_opus_shinen(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_opus_nus3(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_opus_nlsd(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_pc_al2(STREAMFILE * streamFile); diff --git a/Frameworks/vgmstream/vgmstream/src/meta/opus.c b/Frameworks/vgmstream/vgmstream/src/meta/opus.c index 6bcc119d1..06e07f6d7 100644 --- a/Frameworks/vgmstream/vgmstream/src/meta/opus.c +++ b/Frameworks/vgmstream/vgmstream/src/meta/opus.c @@ -272,3 +272,63 @@ fail: return NULL; } +/* Bandai Namco Opus (found in NUS3Banks) [Taiko no Tatsujin: Nintendo Switch Version!] */ +VGMSTREAM * init_vgmstream_opus_nus3(STREAMFILE *streamFile) { + off_t offset = 0; + int num_samples = 0, loop_start = 0, loop_end = 0, loop_flag; + + /* checks */ + if (!check_extensions(streamFile, "lopus")) + goto fail; + if (read_32bitBE(0x00, streamFile) != 0x4F505553) /* "OPUS" */ + goto fail; + + /* Here's an interesting quirk, OPUS header contains big endian values + while the Nintendo Opus header and data that follows remain little endian as usual */ + offset = read_32bitBE(0x20, streamFile); + num_samples = read_32bitBE(0x08, streamFile); + + /* Check if there's a loop end value to determine loop_flag*/ + loop_flag = read_32bitBE(0x18, streamFile); + if (loop_flag) { + loop_start = read_32bitBE(0x14, streamFile); + loop_end = read_32bitBE(0x18, streamFile); + } + + return init_vgmstream_opus(streamFile, meta_OPUS, offset, num_samples, loop_start, loop_end); +fail: + return NULL; +} + +/* Nihon Falcom NLSD Opus [Ys VIII: Lacrimosa of Dana (Switch)] + Similar to Nippon Ichi Software "AT9" Opus (Penny Punching Princess (Switch) + Unlike Penny Punching Princess, this is not segmented */ +VGMSTREAM * init_vgmstream_opus_nlsd(STREAMFILE *streamFile) { + off_t offset = 0; + int num_samples = 0, loop_start = 0, loop_end = 0, loop_flag; + + /* checks */ + if (!check_extensions(streamFile, "nlsd")) + goto fail; + /* File type check - DSP is 0x8, Opus is 0x9 */ + if (read_32bitBE(0x00, streamFile) != 0x09000000) + goto fail; + + offset = 0x1C; + num_samples = read_32bitLE(0x0C, streamFile); + + /* Check if there's a loop_end "adjuster" value to determine loop_flag + Setting loop_flag to loop_start would work too but it may cause conflicts + With files that may have a 0 sample loop_start. */ + // Not sure why this is a thing but let's roll with it. + loop_flag = read_32bitLE(0x18, streamFile); + if (loop_flag) { + loop_start = read_32bitLE(0x10, streamFile); + /* They were being really creative here */ + loop_end = (num_samples - read_32bitLE(0x18, streamFile)); + } + + return init_vgmstream_opus(streamFile, meta_OPUS, offset, num_samples, loop_start, loop_end); +fail: + return NULL; +} diff --git a/Frameworks/vgmstream/vgmstream/src/vgmstream.c b/Frameworks/vgmstream/vgmstream/src/vgmstream.c index 1c9a6fbf2..91c0594d3 100644 --- a/Frameworks/vgmstream/vgmstream/src/vgmstream.c +++ b/Frameworks/vgmstream/vgmstream/src/vgmstream.c @@ -368,6 +368,8 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_opus_capcom, init_vgmstream_opus_nop, init_vgmstream_opus_shinen, + init_vgmstream_opus_nus3, + init_vgmstream_opus_nlsd, init_vgmstream_pc_al2, init_vgmstream_pc_ast, init_vgmstream_naac,