Add RFRM .csmp and cleanup [Donkey Kong Country Tropical Freeze (Wii U)]

This commit is contained in:
bnnm 2018-08-26 19:16:24 +02:00
parent ce6722181a
commit cc537270c1
11 changed files with 88 additions and 17 deletions

View File

@ -672,8 +672,9 @@ static const meta_info meta_info_list[] = {
{meta_AIX, "CRI AIX header"},
{meta_AAX, "CRI AAX header"},
{meta_UTF_DSP, "CRI ADPCM_WII header"},
{meta_DSP_AGSC, "Retro Studios AGSC header"},
{meta_DSP_CSMP, "Retro Studios CSMP header"},
{meta_AGSC, "Retro Studios AGSC header"},
{meta_CSMP, "Retro Studios CSMP header"},
{meta_RFRM, "Retro Studios RFRM header"},
{meta_NGC_ADPDTK, "Nintendo ADP raw header"},
{meta_RSF, "Retro Studios RSF raw header"},
{meta_AFC, "Nintendo AFC header"},

View File

@ -1198,10 +1198,14 @@
RelativePath=".\meta\raw.c"
>
</File>
<File
RelativePath=".\meta\redspark.c"
>
</File>
<File
RelativePath=".\meta\redspark.c"
>
</File>
<File
RelativePath=".\meta\rfrm.c"
>
</File>
<File
RelativePath=".\meta\riff.c"
>

View File

@ -386,6 +386,7 @@
<ClCompile Include="meta\ea_swvr.c" />
<ClCompile Include="meta\raw.c" />
<ClCompile Include="meta\redspark.c" />
<ClCompile Include="meta\rfrm.c" />
<ClCompile Include="meta\riff.c" />
<ClCompile Include="meta\rkv.c" />
<ClCompile Include="meta\rs03.c" />

View File

@ -730,6 +730,9 @@
<ClCompile Include="meta\redspark.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\rfrm.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\riff.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

View File

@ -42,7 +42,7 @@ VGMSTREAM * init_vgmstream_agsc(STREAMFILE *streamFile) {
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_none;
vgmstream->meta_type = meta_DSP_AGSC;
vgmstream->meta_type = meta_AGSC;
vgmstream->allow_dual_stereo = 1;
for (i=0;i<16;i++) {

View File

@ -32,7 +32,7 @@ VGMSTREAM * init_vgmstream_csmp(STREAMFILE *streamFile) {
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_DSP_CSMP;
vgmstream->meta_type = meta_CSMP;
vgmstream->sample_rate = read_32bitBE(chunk_offset+0x08,streamFile);
vgmstream->num_samples = read_32bitBE(chunk_offset+0x00,streamFile);
vgmstream->loop_start_sample = dsp_nibbles_to_samples(read_32bitBE(chunk_offset+0x10,streamFile));
@ -53,4 +53,3 @@ fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -37,6 +37,8 @@ VGMSTREAM * init_vgmstream_ngc_dsp_std_int(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_csmp(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_rfrm(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_ads(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_ads_container(STREAMFILE *streamFile);

60
src/meta/rfrm.c Normal file
View File

@ -0,0 +1,60 @@
#include "meta.h"
#include "../coding/coding.h"
/* RFTM - Retro Studios format [Donkey Kong Country Tropical Freeze (WiiU)] */
VGMSTREAM * init_vgmstream_rfrm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset, header_offset;
size_t interleave;
int loop_flag, channel_count;
/* checks */
if (!check_extensions(streamFile, "csmp"))
goto fail;
/* format uses weird-sized chunks, quick hack until I get enough files */
if (read_32bitBE(0x00, streamFile) != 0x5246524D) /* "RFRM" */
goto fail;
if (read_32bitBE(0x14, streamFile) != 0x43534D50) /* "CSMP" */
goto fail;
if (read_32bitBE(0x3d, streamFile) != 0x44415441) /* "DATA" */
goto fail;
channel_count = read_32bitBE(0x35, streamFile);
header_offset = 0x58;
loop_flag = read_16bitBE(header_offset+0x0c,streamFile);
start_offset = header_offset + 0x60;
interleave = (get_streamfile_size(streamFile) - header_offset) / channel_count;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_RFRM;
vgmstream->sample_rate = read_32bitBE(header_offset+0x08,streamFile);
vgmstream->num_samples = read_32bitBE(header_offset+0x00,streamFile);
vgmstream->loop_start_sample = dsp_nibbles_to_samples(read_32bitBE(header_offset+0x10,streamFile));
vgmstream->loop_end_sample = dsp_nibbles_to_samples(read_32bitBE(header_offset+0x14,streamFile))+1;
if (vgmstream->loop_end_sample > vgmstream->num_samples) /* ? */
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
dsp_read_coefs_be(vgmstream, streamFile, header_offset+0x1c, interleave);
dsp_read_hist_be(vgmstream, streamFile, header_offset+0x40, interleave);
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -27,11 +27,11 @@ VGMSTREAM * init_vgmstream_rs03(STREAMFILE *streamFile) {
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = read_32bitBE(0xc,streamFile);
vgmstream->num_samples = read_32bitBE(8,streamFile);
vgmstream->sample_rate = read_32bitBE(0x0c,streamFile);
vgmstream->num_samples = read_32bitBE(0x08,streamFile);
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitBE(0x18,streamFile)/8*14;
vgmstream->loop_end_sample = read_32bitBE(0x1c,streamFile)/8*14;
vgmstream->loop_start_sample = dsp_bytes_to_samples(read_32bitBE(0x18,streamFile), 1);
vgmstream->loop_end_sample = dsp_bytes_to_samples(read_32bitBE(0x1c,streamFile), 1);
}
vgmstream->meta_type = meta_DSP_RS03;

View File

@ -33,6 +33,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_ngc_dsp_std_le,
init_vgmstream_ngc_mdsp_std,
init_vgmstream_csmp,
init_vgmstream_rfrm,
init_vgmstream_cstr,
init_vgmstream_gcsw,
init_vgmstream_ps2_ads,

View File

@ -268,13 +268,14 @@ typedef enum {
/* The meta type specifies how we know what we know about the file.
* We may know because of a header we read, some of it may have been guessed from filenames, etc. */
typedef enum {
/* DSP-specific */
meta_DSP_STD, /* Nintendo standard GC ADPCM (DSP) header */
meta_DSP_CSMP, /* Retro: Metroid Prime 3, Donkey Kong Country Returns */
meta_DSP_CSTR, /* Star Fox Assault "Cstr" */
meta_DSP_RS03, /* Retro: Metroid Prime 2 "RS03" */
meta_DSP_STM, /* Paper Mario 2 STM */
meta_DSP_AGSC, /* Retro: Metroid Prime 2 title */
meta_AGSC, /* Retro: Metroid Prime 2 title */
meta_CSMP, /* Retro: Metroid Prime 3 (Wii), Donkey Kong Country Returns (Wii) */
meta_RFRM, /* Retro: Donkey Kong Country Tropical Freeze (Wii U) */
meta_DSP_MPDSP, /* Monopoly Party single header stereo */
meta_DSP_JETTERS, /* Bomberman Jetters .dsp */
meta_DSP_MSS, /* Free Radical GC games */
@ -289,7 +290,6 @@ typedef enum {
meta_DSP_YGO, /* Konami: Yu-Gi-Oh! The Falsebound Kingdom (NGC), Hikaru no Go 3 (NGC) */
meta_DSP_SADF, /* Procyon Studio SADF - Xenoblade Chronicles 2 (Switch) */
/* Nintendo */
meta_STRM, /* Nintendo STRM */
meta_RSTM, /* Nintendo RSTM (Revolution Stream, similar to STRM) */
meta_AFC, /* AFC */