Fix some .vgs [Ishikura Noboru no Igo Kouza: Chuukyuuhen (PS2)]

This commit is contained in:
bnnm 2021-06-24 22:34:41 +02:00
parent 8c92b600fd
commit c4d8853ff6
5 changed files with 67 additions and 55 deletions

View File

@ -1153,7 +1153,7 @@ static const meta_info meta_info_list[] = {
{meta_WII_RAS, "RAS header"},
{meta_SPM, "Square SPM header"},
{meta_X360_TRA, "Terminal Reality .TRA raw header"},
{meta_PS2_VGS, "Princess Soft VGS header"},
{meta_VGS_PS, "Princess Soft VGS header"},
{meta_PS2_IAB, "Runtime .IAB header"},
{meta_VS_STR, "Square .VS STR* header"},
{meta_LSF_N1NJ4N, ".lsf !n1nj4n header"},

View File

@ -390,7 +390,7 @@ VGMSTREAM * init_vgmstream_ps2_mcg(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_zsd(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_vgs_ps(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_redspark(STREAMFILE *streamFile);

View File

@ -1,51 +1,63 @@
#include "meta.h"
#include "../coding/coding.h"
/* VGS - from Princess Soft games [Gin no Eclipse (PS2), Metal Wolf REV (PS2)] */
VGMSTREAM * init_vgmstream_ps2_vgs(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
size_t data_size, channel_size, interleave;
int loop_flag, channel_count;
int32_t loop_start = 0, loop_end = 0;
/* check */
if ( !check_extensions(streamFile,"vgs") )
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x56475300) /* "VGS\0" ('VAG stereo', presumably) */
goto fail;
start_offset = 0x30;
data_size = get_streamfile_size(streamFile) - start_offset;
interleave = 0x20000;
channel_count = 2;
channel_size = read_32bitBE(0x0c,streamFile);
loop_flag = 0; /* all files have loop flags but simply fade out normally and repeat */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_PS2_VGS;
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
vgmstream->num_samples = ps_bytes_to_samples(channel_size,1);
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = loop_end;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
if (vgmstream->interleave_block_size)
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size*vgmstream->channels)) / vgmstream->channels;
read_string(vgmstream->stream_name,0x10+1, 0x20,streamFile); /* always, can be null */
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}
#include "meta.h"
#include "../coding/coding.h"
/* VGS - from Princess Soft games [Gin no Eclipse (PS2), Metal Wolf REV (PS2)] */
VGMSTREAM* init_vgmstream_vgs_ps(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
size_t data_size, channel_size, interleave, sample_rate;
int loop_flag, channels;
int32_t loop_start = 0, loop_end = 0;
/* check */
if (!check_extensions(sf,"vgs"))
goto fail;
if (!is_id32be(0x00,sf, "VGS\0")) /* 'VAG stereo', presumably (simple VAG clone) */
goto fail;
start_offset = 0x30;
data_size = get_streamfile_size(sf) - start_offset;
/* test PS-ADPCM null frame for 2nd channel to detect interleave */
if (read_u32be(0x20000 + start_offset,sf) == 0) {
interleave = 0x20000; /* common */
}
else if (read_u32be(0x8000 + start_offset,sf) == 0) {
interleave = 0x8000; /* Ishikura Noboru no Igo Kouza: Chuukyuuhen (PS2) */
}
else {
goto fail;
}
channels = 2;
channel_size = read_u32be(0x0c,sf);
sample_rate = read_s32be(0x10,sf);
loop_flag = 0; /* all files have loop flags but simply fade out normally and repeat */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_VGS_PS;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(channel_size, 1);
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = loop_end;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
if (vgmstream->interleave_block_size)
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size * channels)) / channels;
read_string(vgmstream->stream_name,0x10+1, 0x20,sf); /* always, can be null */
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -196,7 +196,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
init_vgmstream_ads_midway,
init_vgmstream_ps2_mcg,
init_vgmstream_zsd,
init_vgmstream_ps2_vgs,
init_vgmstream_vgs_ps,
init_vgmstream_redspark,
init_vgmstream_ivaud,
init_vgmstream_wii_wsd,

View File

@ -566,7 +566,7 @@ typedef enum {
meta_WII_RAS, /* Donkey Kong Country Returns (Wii) */
meta_SPM,
meta_X360_TRA, /* Def Jam Rapstar */
meta_PS2_VGS, /* Princess Soft PS2 games */
meta_VGS_PS,
meta_PS2_IAB, /* Ueki no Housoku - Taosu ze Robert Juudan!! (PS2) */
meta_VS_STR, /* The Bouncer */
meta_LSF_N1NJ4N, /* .lsf n1nj4n Fastlane Street Racing (iPhone) */