2008-07-19 10:48:49 +02:00
|
|
|
#include "meta.h"
|
2017-12-06 17:35:59 +01:00
|
|
|
#include "../coding/coding.h"
|
2008-07-19 10:48:49 +02:00
|
|
|
|
2017-12-06 17:35:59 +01:00
|
|
|
/* RSTM - from Rockstar games [Midnight Club 3, Bully - Canis Canim Edit (PS2)] */
|
2008-07-19 10:48:49 +02:00
|
|
|
VGMSTREAM * init_vgmstream_ps2_rstm(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2017-12-06 17:35:59 +01:00
|
|
|
int loop_flag, channel_count;
|
2008-07-19 10:48:49 +02:00
|
|
|
|
2017-12-06 17:35:59 +01:00
|
|
|
/* check extension (.rsm: in filelist, .rstm: renamed to header id) */
|
|
|
|
if ( !check_extensions(streamFile,"rsm,rstm") )
|
|
|
|
goto fail;
|
2008-07-19 10:48:49 +02:00
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x5253544D) /* "RSTM" */
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
loop_flag = (read_32bitLE(0x24,streamFile)!=0xFFFFFFFF);
|
|
|
|
channel_count = read_32bitLE(0x0C,streamFile);
|
2017-12-06 17:35:59 +01:00
|
|
|
start_offset = 0x800;
|
2008-07-19 10:48:49 +02:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);
|
2017-12-06 17:35:59 +01:00
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(read_32bitLE(0x20,streamFile),channel_count);
|
|
|
|
vgmstream->loop_start_sample = ps_bytes_to_samples(read_32bitLE(0x24,streamFile),channel_count);
|
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
2008-07-19 10:48:49 +02:00
|
|
|
|
2017-12-06 17:35:59 +01:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
2008-07-19 10:48:49 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x10;
|
|
|
|
vgmstream->meta_type = meta_PS2_RSTM;
|
|
|
|
|
|
|
|
/* open the file for reading */
|
2017-12-06 17:35:59 +01:00
|
|
|
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
|
|
|
goto fail;
|
2008-07-19 10:48:49 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-12-06 17:35:59 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-07-19 10:48:49 +02:00
|
|
|
return NULL;
|
|
|
|
}
|