Add .RSM extension (Bully PS2)

This commit is contained in:
bnnm 2017-12-06 17:35:59 +01:00
parent 10aac03cd5
commit 8592aeea3d
3 changed files with 17 additions and 35 deletions

View File

@ -238,6 +238,7 @@ VGMSTREAM_DECLARE_FILE_TYPE("RND", rnd);
VGMSTREAM_DECLARE_FILE_TYPE("RRDS", rrds);
VGMSTREAM_DECLARE_FILE_TYPE("RSD", rsd);
VGMSTREAM_DECLARE_FILE_TYPE("RSF", rsf);
VGMSTREAM_DECLARE_FILE_TYPE("RSM", rsm);
VGMSTREAM_DECLARE_FILE_TYPE("RSTM", rstm);
VGMSTREAM_DECLARE_FILE_TYPE("RVWS", rvws);
VGMSTREAM_DECLARE_FILE_TYPE("RWAR", rwar);

View File

@ -233,7 +233,8 @@ static const char* extension_list[] = {
"rrds",
"rsd",
"rsf",
"rstm",
"rsm",
"rstm", //rsm header id
"rvws",
"rwar",
"rwav",

View File

@ -1,17 +1,15 @@
#include "meta.h"
#include "../util.h"
#include "../coding/coding.h"
/* RSTM (from Midnight Club 3, Bully - Canis Canim Edit) */
/* RSTM - from Rockstar games [Midnight Club 3, Bully - Canis Canim Edit (PS2)] */
VGMSTREAM * init_vgmstream_ps2_rstm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
int loop_flag = 0;
int channel_count;
int loop_flag, channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("rstm",filename_extension(filename))) goto fail;
/* 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" */
@ -19,46 +17,28 @@ VGMSTREAM * init_vgmstream_ps2_rstm(STREAMFILE *streamFile) {
loop_flag = (read_32bitLE(0x24,streamFile)!=0xFFFFFFFF);
channel_count = read_32bitLE(0x0C,streamFile);
start_offset = 0x800;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x800;
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitLE(0x20,streamFile)*28/16/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x24,streamFile)*28/16/channel_count;
vgmstream->loop_end_sample = read_32bitLE(0x20,streamFile)*28/16/channel_count;
}
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;
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 */
{
int i;
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+
vgmstream->interleave_block_size*i;
}
}
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
close_vgmstream(vgmstream);
return NULL;
}