2010-04-20 22:26:10 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
2017-03-09 20:37:48 +01:00
|
|
|
#include "../coding/coding.h"
|
2010-04-20 22:26:10 +02:00
|
|
|
|
2017-03-09 20:37:48 +01:00
|
|
|
/* MPDS - found in Paradigm Entertainment GC games */
|
2010-04-20 22:26:10 +02:00
|
|
|
VGMSTREAM * init_vgmstream_ngc_dsp_mpds(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2017-03-09 20:37:48 +01:00
|
|
|
off_t start_offset;
|
|
|
|
int loop_flag = 0, channel_count, short_mpds;
|
|
|
|
|
2010-04-20 22:26:10 +02:00
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
2017-03-09 20:37:48 +01:00
|
|
|
/* .adp: Big Air Freestyle */
|
|
|
|
/* .mds: Terminator 3 The Redemption, Mission Impossible: Operation Surma */
|
|
|
|
if (!check_extensions(streamFile, "dsp,mds")) goto fail;
|
2010-04-20 22:26:10 +02:00
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x4D504453) /* "MPDS" */
|
|
|
|
goto fail;
|
|
|
|
|
2017-03-09 20:37:48 +01:00
|
|
|
short_mpds = read_32bitBE(0x04,streamFile) != 0x00010000 && read_32bitBE(0x0c,streamFile) == 0x00000002; /* version byte? */
|
2010-04-20 22:26:10 +02:00
|
|
|
|
2017-03-09 20:37:48 +01:00
|
|
|
channel_count = short_mpds ?
|
|
|
|
read_16bitBE(0x0a, streamFile) :
|
|
|
|
read_32bitBE(0x14, streamFile);
|
|
|
|
if (channel_count > 2) goto fail;
|
2010-04-20 22:26:10 +02:00
|
|
|
|
2017-03-09 20:37:48 +01:00
|
|
|
/* build the VGMSTREAM */
|
2010-04-20 22:26:10 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2017-03-09 20:37:48 +01:00
|
|
|
/* fill in the vital statistics */
|
2010-04-20 22:26:10 +02:00
|
|
|
vgmstream->coding_type = coding_NGC_DSP;
|
|
|
|
vgmstream->meta_type = meta_NGC_DSP_MPDS;
|
2017-03-09 20:37:48 +01:00
|
|
|
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
|
|
|
|
|
|
|
|
if (!short_mpds) { /* Big Air Freestyle */
|
|
|
|
start_offset = 0x80;
|
|
|
|
vgmstream->num_samples = read_32bitBE(0x08,streamFile);
|
|
|
|
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
|
|
|
vgmstream->interleave_block_size = channel_count==1 ? 0 : read_32bitBE(0x18,streamFile);
|
|
|
|
|
|
|
|
/* compare sample count with body size */
|
|
|
|
if ((vgmstream->num_samples / 7 * 8) != (read_32bitBE(0x0C,streamFile))) goto fail;
|
|
|
|
|
|
|
|
dsp_read_coefs_be(vgmstream,streamFile,0x24, 0x28);
|
2010-04-20 22:26:10 +02:00
|
|
|
}
|
2017-03-09 20:37:48 +01:00
|
|
|
else { /* Terminator 3 The Redemption, Mission Impossible: Operation Surma */
|
|
|
|
start_offset = 0x20;
|
|
|
|
vgmstream->num_samples = read_32bitBE(0x04,streamFile);
|
|
|
|
vgmstream->sample_rate = (uint16_t)read_16bitBE(0x08,streamFile);
|
|
|
|
vgmstream->interleave_block_size = channel_count==1 ? 0 : 0x200;
|
2010-04-20 22:26:10 +02:00
|
|
|
|
2017-03-09 20:37:48 +01:00
|
|
|
#if 0 //todo unknown coeffs, maybe depends on stuff @ 0x10? (but looks like some kind of size)
|
|
|
|
{
|
|
|
|
int i,ch;
|
|
|
|
for (ch=0; ch < vgmstream->channels; ch++) {
|
|
|
|
for (i=0; i < 16; i++)
|
|
|
|
vgmstream->ch[ch].adpcm_coef[i] = mpds_coefs[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2010-04-20 22:26:10 +02:00
|
|
|
}
|
|
|
|
|
2017-03-09 20:37:48 +01:00
|
|
|
|
|
|
|
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
|
|
|
|
2010-04-20 22:26:10 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-03-09 20:37:48 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2010-04-20 22:26:10 +02:00
|
|
|
return NULL;
|
2010-04-20 23:07:45 +02:00
|
|
|
}
|