2008-05-06 05:35:37 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../coding/coding.h"
|
2008-03-25 08:30:04 +01:00
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
/* RS03 - from Metroid Prime 2 (GC) */
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_rs03(STREAMFILE *streamFile) {
|
2008-03-25 08:30:04 +01:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2018-03-24 19:27:24 +01:00
|
|
|
size_t data_size;
|
|
|
|
int channel_count, loop_flag;
|
2008-03-25 08:30:04 +01:00
|
|
|
|
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "dsp"))
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x52530003) /* "RS03" */
|
2008-03-25 08:30:04 +01:00
|
|
|
goto fail;
|
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
channel_count = read_32bitBE(0x04,streamFile);
|
2008-03-31 22:17:07 +02:00
|
|
|
if (channel_count != 1 && channel_count != 2) goto fail;
|
2018-03-24 19:27:24 +01:00
|
|
|
loop_flag = read_16bitBE(0x14,streamFile);
|
2008-03-25 08:30:04 +01:00
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
start_offset = 0x60;
|
|
|
|
data_size = (get_streamfile_size(streamFile) - start_offset);
|
2008-03-25 08:30:04 +01:00
|
|
|
|
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
/* build the VGMSTREAM */
|
2008-03-25 08:30:04 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2018-08-26 19:16:24 +02:00
|
|
|
vgmstream->sample_rate = read_32bitBE(0x0c,streamFile);
|
|
|
|
vgmstream->num_samples = read_32bitBE(0x08,streamFile);
|
2008-07-14 14:05:49 +02:00
|
|
|
if (loop_flag) {
|
2018-08-26 19:16:24 +02:00
|
|
|
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);
|
2008-07-14 14:05:49 +02:00
|
|
|
}
|
2008-03-25 08:30:04 +01:00
|
|
|
|
|
|
|
vgmstream->meta_type = meta_DSP_RS03;
|
2018-03-24 19:27:24 +01:00
|
|
|
vgmstream->coding_type = coding_NGC_DSP;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x8f00;
|
|
|
|
if (vgmstream->interleave_block_size)
|
|
|
|
vgmstream->interleave_last_block_size = ((data_size % (vgmstream->interleave_block_size*vgmstream->channels))/2+7)/8*8;
|
2008-03-25 08:30:04 +01:00
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
dsp_read_coefs_be(vgmstream,streamFile,0x20,0x20);
|
2008-03-25 08:30:04 +01:00
|
|
|
|
|
|
|
|
2018-03-24 19:27:24 +01:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2008-03-25 08:30:04 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-03-24 19:27:24 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-03-25 08:30:04 +01:00
|
|
|
return NULL;
|
|
|
|
}
|