2008-12-07 11:27:04 +01:00
|
|
|
#include "meta.h"
|
2019-03-04 20:08:33 +01:00
|
|
|
#include "../coding/coding.h"
|
2008-12-07 11:27:04 +01:00
|
|
|
|
2010-02-15 10:02:31 +01:00
|
|
|
|
2019-03-04 20:08:33 +01:00
|
|
|
/* DCS+WAV - from In Utero games [Evil Twin: Cyprien's Chronicles (DC)] */
|
|
|
|
VGMSTREAM * init_vgmstream_dcs_wav(STREAMFILE *streamFile) {
|
2009-01-05 12:58:27 +01:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2019-03-04 20:08:33 +01:00
|
|
|
STREAMFILE * streamHeader = NULL;
|
|
|
|
int loop_flag, channel_count, sample_rate;
|
|
|
|
off_t start_offset, fmt_offset;
|
2008-12-07 11:27:04 +01:00
|
|
|
|
|
|
|
|
2019-03-04 20:08:33 +01:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile,"dcs"))
|
|
|
|
goto fail;
|
2008-12-07 11:27:04 +01:00
|
|
|
|
2019-03-04 20:08:33 +01:00
|
|
|
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" */
|
2009-01-05 12:58:27 +01:00
|
|
|
goto fail;
|
2019-03-04 20:08:33 +01:00
|
|
|
|
|
|
|
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);
|
2009-01-05 12:58:27 +01:00
|
|
|
loop_flag = 0;
|
2019-03-04 20:08:33 +01:00
|
|
|
start_offset = 0x00;
|
2008-12-07 11:27:04 +01:00
|
|
|
|
2019-03-04 20:08:33 +01:00
|
|
|
/* build the VGMSTREAM */
|
2008-12-07 11:27:04 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2019-03-04 20:08:33 +01:00
|
|
|
vgmstream->meta_type = meta_DCS_WAV;
|
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = yamaha_bytes_to_samples(get_streamfile_size(streamFile), channel_count);
|
2019-09-21 19:15:01 +02:00
|
|
|
vgmstream->coding_type = coding_AICA_int;
|
2019-03-04 20:08:33 +01:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x4000;
|
2009-01-05 12:58:27 +01:00
|
|
|
|
2019-03-04 20:08:33 +01:00
|
|
|
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
|
|
|
goto fail;
|
|
|
|
close_streamfile(streamHeader);
|
2008-12-07 11:27:04 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2019-03-04 20:08:33 +01:00
|
|
|
close_streamfile(streamHeader);
|
|
|
|
close_vgmstream(vgmstream);
|
2008-12-07 11:27:04 +01:00
|
|
|
return NULL;
|
|
|
|
}
|