mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-29 19:37:30 +01:00
Clean .dcs+wav [Evil Twin (DC)]
This commit is contained in:
parent
879f65a864
commit
f0d3cadf3d
@ -922,7 +922,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_NGC_SSM, "SSM DSP Header"},
|
||||
{meta_PS2_JOE, "Asobo Studio .JOE header"},
|
||||
{meta_VGS, "Guitar Hero VGS Header"},
|
||||
{meta_DC_DCSW_DCS, "Evil Twin DCS file with helper"},
|
||||
{meta_DCS_WAV, "In Utero DCS+WAV header"},
|
||||
{meta_SMP, "Infernal Engine .smp header"},
|
||||
{meta_MUL, "Crystal Dynamics .MUL header"},
|
||||
{meta_THP, "THP Movie File Format Header"},
|
||||
|
@ -1,119 +1,58 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* WAV+DCS (DCSW+DCS)
|
||||
2008-12-06 - manakoAT : Evil Twin - Cypriens Chronicles...
|
||||
2008-12-07 - manakoAT : Added a function to read the Header file and for
|
||||
retrieving the channels/frequency, Frequency starts
|
||||
always at a "data" chunk - 0x0C bytes, Channels
|
||||
always - 0x0E bytes...
|
||||
2010-01-13 - manakoAT : Changed the 'Helper' extension from .wav to .dcws, to prevent conflicts */
|
||||
|
||||
VGMSTREAM * init_vgmstream_dc_dcsw_dcs(STREAMFILE *streamFile) {
|
||||
/* DCS+WAV - from In Utero games [Evil Twin: Cyprien's Chronicles (DC)] */
|
||||
VGMSTREAM * init_vgmstream_dcs_wav(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
STREAMFILE * streamFileDCSW = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
char filenameDCSW[PATH_LIMIT];
|
||||
int i;
|
||||
int channel_count;
|
||||
int loop_flag;
|
||||
int frequency;
|
||||
int dataBuffer = 0;
|
||||
int Founddata = 0;
|
||||
size_t file_size;
|
||||
off_t current_chunk;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("dcs",filename_extension(filename))) goto fail;
|
||||
STREAMFILE * streamHeader = NULL;
|
||||
int loop_flag, channel_count, sample_rate;
|
||||
off_t start_offset, fmt_offset;
|
||||
|
||||
/* Getting the Header file name... */
|
||||
strcpy(filenameDCSW,filename);
|
||||
strcpy(filenameDCSW+strlen(filenameDCSW)-3,"dcsw");
|
||||
|
||||
/* Look if the Header file is present, else cancel vgmstream */
|
||||
streamFileDCSW = streamFile->open(streamFile,filenameDCSW,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!streamFileDCSW) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFileDCSW) != 0x52494646 || /* "RIFF" */
|
||||
read_32bitBE(0x08,streamFileDCSW) != 0x57415645 || /* "WAVE" */
|
||||
read_32bitBE(0x0C,streamFileDCSW) != 0x34582E76 || /* 0x34582E76 */
|
||||
read_32bitBE(0x3C,streamFileDCSW) != 0x406E616D) /* "@nam" */
|
||||
goto fail;
|
||||
|
||||
/* scan file until we find a "data" string */
|
||||
file_size = get_streamfile_size(streamFileDCSW);
|
||||
{
|
||||
current_chunk = 0;
|
||||
/* Start at 0 and loop until we reached the
|
||||
file size, or until we found a "data string */
|
||||
while (!Founddata && current_chunk < file_size) {
|
||||
dataBuffer = (read_32bitBE(current_chunk,streamFileDCSW));
|
||||
if (dataBuffer == 0x64617461) { /* "data" */
|
||||
/* if "data" string found, retrieve the needed infos */
|
||||
Founddata = 1;
|
||||
/* We will cancel the search here if we have a match */
|
||||
break;
|
||||
}
|
||||
/* else we will increase the search offset by 1 */
|
||||
current_chunk = current_chunk + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Founddata == 0) {
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile,"dcs"))
|
||||
goto fail;
|
||||
} else if (Founddata == 1) {
|
||||
channel_count = (uint16_t)read_16bitLE(current_chunk-0x0E,streamFileDCSW);
|
||||
frequency = read_32bitLE(current_chunk-0x0C,streamFileDCSW);
|
||||
}
|
||||
|
||||
loop_flag = 0;
|
||||
|
||||
/* Seems we're dealing with a vaild file+header,
|
||||
now we can finally build the VGMSTREAM */
|
||||
streamHeader = open_streamfile_by_ext(streamFile, "wav");
|
||||
if (!streamHeader) goto fail;
|
||||
|
||||
/* a slightly funny RIFF */
|
||||
if (read_u32be(0x00,streamHeader) != 0x52494646 || /* "RIFF" */
|
||||
read_u32be(0x08,streamHeader) != 0x57415645 || /* "WAVE" */
|
||||
read_u32be(0x0C,streamHeader) != 0x34582E76 || /* "4X.v" */
|
||||
read_u32be(0x3C,streamHeader) != 0x406E616D) /* "@nam" */
|
||||
goto fail;
|
||||
|
||||
fmt_offset = 0x44 + read_32bitLE(0x40,streamHeader); /* skip @nam */
|
||||
if (fmt_offset % 2) fmt_offset += 1;
|
||||
if (read_u32be(fmt_offset,streamHeader) != 0x666D7420) goto fail; /* "fmt " */
|
||||
fmt_offset += 0x04+0x04;
|
||||
|
||||
if (read_u16le(fmt_offset+0x00,streamHeader) != 0x0005) goto fail; /* unofficial format */
|
||||
channel_count = read_u16le(fmt_offset+0x02,streamHeader);
|
||||
sample_rate = read_u32le(fmt_offset+0x04,streamHeader);
|
||||
loop_flag = 0;
|
||||
start_offset = 0x00;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = frequency;
|
||||
vgmstream->num_samples=(get_streamfile_size(streamFile))*2/channel_count;
|
||||
|
||||
if(loop_flag) {
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = (get_streamfile_size(streamFile))*2/channel_count;
|
||||
}
|
||||
|
||||
if (channel_count == 1) {
|
||||
vgmstream->layout_type = layout_none;
|
||||
} else if (channel_count > 1) {
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x4000;
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_DCS_WAV;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = yamaha_bytes_to_samples(get_streamfile_size(streamFile), channel_count);
|
||||
vgmstream->coding_type = coding_YAMAHA_int;
|
||||
vgmstream->meta_type = meta_DC_DCSW_DCS;
|
||||
|
||||
/* open the file for reading by each channel */
|
||||
{
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=i*vgmstream->interleave_block_size;
|
||||
vgmstream->ch[i].adpcm_step_index = 0x7f;
|
||||
}
|
||||
}
|
||||
|
||||
close_streamfile(streamFileDCSW); streamFileDCSW=NULL;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x4000;
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
goto fail;
|
||||
close_streamfile(streamHeader);
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (streamFileDCSW) close_streamfile(streamFileDCSW);
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_streamfile(streamHeader);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ VGMSTREAM * init_vgmstream_ps2_joe(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_vgs(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_dc_dcsw_dcs(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_dcs_wav(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_mul(STREAMFILE * streamFile);
|
||||
|
||||
|
@ -191,7 +191,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_ngc_ssm,
|
||||
init_vgmstream_ps2_joe,
|
||||
init_vgmstream_vgs,
|
||||
init_vgmstream_dc_dcsw_dcs,
|
||||
init_vgmstream_dcs_wav,
|
||||
init_vgmstream_mul,
|
||||
init_vgmstream_thp,
|
||||
init_vgmstream_wii_sts,
|
||||
|
@ -453,7 +453,7 @@ typedef enum {
|
||||
meta_STR_ASR, /* Donkey Kong Jet Race */
|
||||
meta_ZWDSP, /* Zack and Wiki */
|
||||
meta_VGS, /* Guitar Hero Encore - Rocks the 80s */
|
||||
meta_DC_DCSW_DCS, /* Evil Twin - Cypriens Chronicles (DC) */
|
||||
meta_DCS_WAV,
|
||||
meta_SMP,
|
||||
meta_WII_SNG, /* Excite Trucks */
|
||||
meta_MUL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user