diff --git a/fb2k/foo_filetypes.h b/fb2k/foo_filetypes.h index 540009ff..0dd8751f 100644 --- a/fb2k/foo_filetypes.h +++ b/fb2k/foo_filetypes.h @@ -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); diff --git a/src/formats.c b/src/formats.c index 7384de24..863cb11a 100644 --- a/src/formats.c +++ b/src/formats.c @@ -233,7 +233,8 @@ static const char* extension_list[] = { "rrds", "rsd", "rsf", - "rstm", + "rsm", + "rstm", //rsm header id "rvws", "rwar", "rwav", diff --git a/src/meta/ps2_rstm.c b/src/meta/ps2_rstm.c index 3e501c69..664a2439 100644 --- a/src/meta/ps2_rstm.c +++ b/src/meta/ps2_rstm.c @@ -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;ich[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; }