From ceaa776f835dada4fdbec2838cb61aa06718240a Mon Sep 17 00:00:00 2001 From: bxaimc Date: Mon, 19 Mar 2018 15:19:30 -0400 Subject: [PATCH] Add -official- VSV extension to PSH meta. Modified channe_count flag in VSF for test files found in FFXII:TZA (PS4). --- src/formats.c | 5 +++-- src/meta/ps2_psh.c | 34 ++++++++++------------------------ src/meta/vsf.c | 40 ++++++++++++---------------------------- src/vgmstream.h | 2 +- 4 files changed, 26 insertions(+), 55 deletions(-) diff --git a/src/formats.c b/src/formats.c index 20ebe87e..c48d07f7 100644 --- a/src/formats.c +++ b/src/formats.c @@ -236,7 +236,7 @@ static const char* extension_list[] = { "pona", "pos", "ps2stm", //fake extension for .stm (to be removed) - "psh", + "psh", // fake extension for VSV(?) Dawn of Mana needs to be checked again "psnd", "psw", @@ -351,6 +351,7 @@ static const char* extension_list[] = { "vpk", "vs", "vsf", + "vsv", // official extension for PSH? TODO: recheck Dawn of Mana "vxn", "waa", @@ -698,7 +699,7 @@ static const meta_info meta_info_list[] = { {meta_MUS_ACM, "InterPlay MUS ACM header"}, {meta_PS2_KCES, "Konami KCES Header"}, {meta_PS2_DXH, "Tokobot Plus DXH Header"}, - {meta_PS2_PSH, "Dawn of Mana - Seiken Densetsu 4 PSH Header"}, + {meta_PS2_PSH, "Square Enix PSH/VSV Header"}, {meta_RIFF_WAVE_labl, "RIFF WAVE header with loop markers"}, {meta_RIFF_WAVE_smpl, "RIFF WAVE header with sample looping info"}, {meta_RIFF_WAVE_wsmp, "RIFF WAVE header with wsmp looping info"}, diff --git a/src/meta/ps2_psh.c b/src/meta/ps2_psh.c index e502a1ee..5d451188 100644 --- a/src/meta/ps2_psh.c +++ b/src/meta/ps2_psh.c @@ -1,11 +1,10 @@ #include "meta.h" #include "../util.h" -/* PSH (from Dawn of Mana - Seiken Densetsu 4) */ +/* PSH (from Dawn of Mana - Seiken Densetsu 4, Kingdom Hearts Re:Chain of Memories) */ /* probably Square Vag Stream */ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; - char filename[PATH_LIMIT]; off_t start_offset; uint8_t testBuffer[0x10]; off_t loopEnd = 0; @@ -15,9 +14,9 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { int loop_flag; int channel_count; - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("psh",filename_extension(filename))) goto fail; + /* check extension, case insensitive */ + if (!check_extensions(streamFile, "psh,vsv")) // vsv seems to be official extension + goto fail; /* check header */ if (read_16bitBE(0x02,streamFile) != 0x6400) @@ -65,25 +64,12 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { vgmstream->meta_type = meta_PS2_PSH; /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; + return vgmstream; - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - - /* clean up anything we may have opened */ + /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); - return NULL; + close_vgmstream(vgmstream); + return NULL; } diff --git a/src/meta/vsf.c b/src/meta/vsf.c index 36047ece..dc20476e 100644 --- a/src/meta/vsf.c +++ b/src/meta/vsf.c @@ -4,22 +4,19 @@ /* VSF (from Musashi: Samurai Legend) */ VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; - char filename[PATH_LIMIT]; off_t start_offset; + int loop_flag, channel_count; - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("vsf",filename_extension(filename))) goto fail; + /* check extension, case insensitive */ + if (!check_extensions(streamFile, "vsf")) + goto fail; /* check header */ if (read_32bitBE(0x00,streamFile) != 0x56534600) /* "VSF" */ goto fail; loop_flag = (read_32bitLE(0x1c,streamFile)==0x13); - if(read_32bitLE(0x8,streamFile)==0x0) + if(read_8bit(0x1C,streamFile)==0x0) channel_count = 1; else channel_count = 2; @@ -43,26 +40,13 @@ VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) { vgmstream->interleave_block_size = 0x400; vgmstream->meta_type = meta_PS2_VSF; - /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; + /* open the file for reading */ + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; + return vgmstream; - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - - /* clean up anything we may have opened */ + /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); - return NULL; + close_vgmstream(vgmstream); + return NULL; } diff --git a/src/vgmstream.h b/src/vgmstream.h index 5cc7b03a..9f28e649 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -368,7 +368,7 @@ typedef enum { meta_PS2_RSTM, /* Midnight Club 3 */ meta_PS2_KCES, /* Dance Dance Revolution */ meta_PS2_DXH, /* Tokobot Plus - Myteries of the Karakuri */ - meta_PS2_PSH, /* Dawn of Mana - Seiken Densetsu 4 */ + meta_PS2_PSH, /* Square Enix PSH/VSV (Dawn of Mana/KH Re:CoM) */ meta_SCD_PCM, /* Lunar - Eternal Blue */ meta_PS2_PCM, /* Konami KCEJ East: Ephemeral Fantasia, Yu-Gi-Oh! The Duelists of the Roses, 7 Blades */ meta_PS2_RKV, /* Legacy of Kain - Blood Omen 2 */