Fix some SDF [Mr. Bean's Wacky World (Wii)]

This commit is contained in:
bnnm 2019-01-26 17:04:43 +01:00
parent aecd7da55e
commit 097f7b0285
5 changed files with 71 additions and 73 deletions

View File

@ -1135,10 +1135,9 @@ static const meta_info meta_info_list[] = {
{meta_A2M, "Artificial Mind & Movement A2M header"},
{meta_AHV, "Amuze AHV header"},
{meta_MSV, "Sony MultiStream MSV header"},
{meta_SDF_PS2, "Beyond Reality PS2 SDF header"},
{meta_SDF, "Beyond Reality SDF header"},
{meta_SVG, "High Voltage SVG header"},
{meta_VIS, "Konami VIS header"},
{meta_SDF_3DS, "Beyond Reality 3DS SDF header"},
{meta_VAI, "Asobo Studio .VAI header"},
{meta_AIF_ASOBO, "Asobo Studio .AIF header"},
{meta_AO, "AlphaOgg .AO header"},

View File

@ -768,8 +768,7 @@ VGMSTREAM * init_vgmstream_ahv(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_msv(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sdf_ps2(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sdf_3ds(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sdf(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_svg(STREAMFILE *streamFile);

View File

@ -1,12 +1,12 @@
#include "meta.h"
#include "../coding/coding.h"
/* SDF - from Beyond Reality games [Agent Hugo - Lemoon Twist (PS2)] */
VGMSTREAM * init_vgmstream_sdf_ps2(STREAMFILE *streamFile) {
/* SDF - from Beyond Reality games */
VGMSTREAM * init_vgmstream_sdf(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
size_t data_size;
int loop_flag, channel_count;
int loop_flag, channel_count, sample_rate, interleave, coefs_offset;
/* checks */
@ -17,74 +17,77 @@ VGMSTREAM * init_vgmstream_sdf_ps2(STREAMFILE *streamFile) {
if (read_32bitBE(0x04,streamFile) != 0x03000000) /* version? */
goto fail;
start_offset = 0x18;
data_size = get_streamfile_size(streamFile) - start_offset;
if (read_32bitLE(0x08,streamFile) != data_size)
goto fail;
data_size = read_32bitLE(0x08,streamFile);
start_offset = get_streamfile_size(streamFile) - data_size;
switch(start_offset) {
case 0x18: /* Agent Hugo - Lemoon Twist (PS2)*/
sample_rate = read_32bitLE(0x0c,streamFile);
channel_count = read_32bitLE(0x10,streamFile);
loop_flag = 0; /* all files have loop flags but simply fade out normally and repeat */
interleave = read_32bitLE(0x14,streamFile);
break;
case 0x78: /* Gummy Bears Mini Golf (3DS) */
sample_rate = read_32bitLE(0x10,streamFile);
channel_count = read_32bitLE(0x14,streamFile);
interleave = read_32bitLE(0x18,streamFile);
coefs_offset = 0x1c;
break;
case 0x84: /* Mr. Bean's Wacky World (Wii) */
sample_rate = read_32bitLE(0x10,streamFile);
channel_count = read_32bitLE(0x14,streamFile);
interleave = read_32bitLE(0x18,streamFile);
data_size = read_32bitLE(0x20,streamFile); /* usable size */
coefs_offset = 0x28;
break;
default:
goto fail;
}
loop_flag = 1;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SDF_PS2;
vgmstream->sample_rate = read_32bitLE(0x0c,streamFile);
vgmstream->num_samples = ps_bytes_to_samples(data_size,channel_count);
vgmstream->meta_type = meta_SDF;
vgmstream->sample_rate = sample_rate;
switch(start_offset) {
case 0x18:
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile);
vgmstream->interleave_block_size = interleave;
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}
/* SDF - from Beyond Reality games [Gummy Bears Mini Golf (3DS)] */
VGMSTREAM * init_vgmstream_sdf_3ds(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
size_t data_size;
int loop_flag, channel_count;
/* checks */
if ( !check_extensions(streamFile,"sdf") )
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x53444600) /* "SDF\0" */
goto fail;
if (read_32bitBE(0x04,streamFile) != 0x03000000) /* version? */
goto fail;
start_offset = 0x78; /* assumed */
data_size = get_streamfile_size(streamFile) - start_offset;
if (read_32bitLE(0x08,streamFile) != data_size)
goto fail;
channel_count = read_32bitLE(0x14,streamFile);
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SDF_3DS;
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
vgmstream->num_samples = dsp_bytes_to_samples(data_size,channel_count);
vgmstream->num_samples = ps_bytes_to_samples(data_size,channel_count);
break;
case 0x78:
case 0x84:
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
if (vgmstream->interleave_block_size == 0) /* Gummy Bears Mini Golf */
vgmstream->interleave_block_size = data_size / channel_count;
dsp_read_coefs_le(vgmstream,streamFile,0x1c,0x2e);
//todo: there be hist around 0x3c
vgmstream->num_samples = dsp_bytes_to_samples(data_size,channel_count);
dsp_read_coefs_le(vgmstream, streamFile, coefs_offset+0x00,0x2e);
dsp_read_hist_le (vgmstream, streamFile, coefs_offset+0x24,0x2e);
break;
default:
goto fail;
}
/* most songs simply repeat; don't loop if too short (in seconds) */
if (vgmstream->num_samples > 10*sample_rate) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
}
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;

View File

@ -430,10 +430,9 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_a2m,
init_vgmstream_ahv,
init_vgmstream_msv,
init_vgmstream_sdf_ps2,
init_vgmstream_sdf,
init_vgmstream_svg,
init_vgmstream_vis,
init_vgmstream_sdf_3ds,
init_vgmstream_vai,
init_vgmstream_aif_asobo,
init_vgmstream_ao,
@ -2786,7 +2785,6 @@ int vgmstream_open_stream(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t s
if (!file) goto fail;
}
VGM_LOG("ch%i offset=%lx\n", ch,offset);
vgmstream->ch[ch].streamfile = file;
vgmstream->ch[ch].channel_start_offset =
vgmstream->ch[ch].offset = offset;

View File

@ -687,11 +687,10 @@ typedef enum {
meta_A2M, /* Scooby-Doo! Unmasked (PS2) */
meta_AHV, /* Headhunter (PS2) */
meta_MSV, /* Fight Club (PS2) */
meta_SDF_PS2, /* Agent Hugo - Lemoon Twist (PS2) */
meta_SDF,
meta_SVG, /* Hunter - The Reckoning - Wayward (PS2) */
meta_VIS, /* AirForce Delta Strike (PS2) */
meta_VAI, /* Ratatouille (GC) */
meta_SDF_3DS, /* Gummy Bears Mini Golf (3DS) */
meta_AIF_ASOBO, /* Ratatouille (PC) */
meta_AO, /* Cloudphobia (PC) */
meta_APC, /* MegaRace 3 (PC) */