vgmstream/src/meta/ps2_rstm.c

45 lines
1.5 KiB
C
Raw Normal View History

#include "meta.h"
2017-12-06 17:35:59 +01:00
#include "../coding/coding.h"
2017-12-06 17:35:59 +01:00
/* RSTM - from Rockstar games [Midnight Club 3, Bully - Canis Canim Edit (PS2)] */
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;
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;
/* 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;
/* 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;
2017-12-06 17:35:59 +01:00
vgmstream->coding_type = coding_PSX;
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;
return vgmstream;
fail:
2017-12-06 17:35:59 +01:00
close_vgmstream(vgmstream);
return NULL;
}