diff --git a/src/formats.c b/src/formats.c index 6e491837..c34a45be 100644 --- a/src/formats.c +++ b/src/formats.c @@ -238,7 +238,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", @@ -356,6 +356,7 @@ static const char* extension_list[] = { "vpk", "vs", "vsf", + "vsv", // official extension for PSH? TODO: recheck Dawn of Mana "vxn", "waa", @@ -707,7 +708,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/ogg_vorbis.c b/src/meta/ogg_vorbis.c index dac58903..fc030dab 100644 --- a/src/meta/ogg_vorbis.c +++ b/src/meta/ogg_vorbis.c @@ -386,7 +386,8 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb strstr(user_comment,"LOOPSTART=")==user_comment || strstr(user_comment,"um3.stream.looppoint.start=")==user_comment || strstr(user_comment,"LOOP_BEGIN=")==user_comment || /* Hatsune Miku: Project Diva F (PS3) */ - strstr(user_comment,"LoopStart=")==user_comment) { /* Devil May Cry 4 (PC) */ + strstr(user_comment,"LoopStart=")==user_comment || /* Devil May Cry 4 (PC) */ + strstr(user_comment,"XIPH_CUE_LOOPSTART=")==user_comment) { /* Super Mario Run (Android) */ loop_start = atol(strrchr(user_comment,'=')+1); loop_flag = (loop_start >= 0); } @@ -430,6 +431,12 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb loop_flag = 1; loop_end_found = 1; } + else if (strstr(user_comment, "XIPH_CUE_LOOPEND=") == user_comment) { /* XIPH_CUE_LOOPSTART pair */ + if (loop_flag) { + loop_length = atol(strrchr(user_comment, '=') + 1) - loop_start; + loop_length_found = 1; + } + } } } diff --git a/src/meta/ps2_psh.c b/src/meta/ps2_psh.c index e502a1ee..cb9d3a1b 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; @@ -16,8 +15,8 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { int channel_count; /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("psh",filename_extension(filename))) goto fail; + 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; - - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; return vgmstream; /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); + close_vgmstream(vgmstream); return NULL; } diff --git a/src/meta/vsf.c b/src/meta/vsf.c index 36047ece..07751bea 100644 --- a/src/meta/vsf.c +++ b/src/meta/vsf.c @@ -4,25 +4,22 @@ /* 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; - int channel_count; + int loop_flag, channel_count; /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("vsf",filename_extension(filename))) goto fail; + 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) - channel_count = 1; - else - channel_count = 2; + if(read_8bit(0x1C,streamFile)==0x0) + channel_count = 1; + else + channel_count = 2; /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count,loop_flag); @@ -44,25 +41,12 @@ VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) { 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; - - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; return vgmstream; /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); + close_vgmstream(vgmstream); return NULL; } diff --git a/src/vgmstream.h b/src/vgmstream.h index f7342b1e..c31f84a5 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -369,7 +369,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 (PS2) */