From 69a1f2be4ea3f467459eb94e725b2a5171987d16 Mon Sep 17 00:00:00 2001 From: halleyscometsw Date: Sun, 22 Nov 2009 14:06:45 +0000 Subject: [PATCH] Red Dead Revolver .stm (needs renamed to .ps2stm to avoid module collision in Winamp, etc) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@715 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- readme.txt | 1 + src/Makefile | 3 +- src/libvgmstream.vcproj | 4 ++ src/meta/Makefile.unix.am | 1 + src/meta/meta.h | 2 + src/meta/ps2_stm.c | 77 +++++++++++++++++++++++++++++++++++++++ src/vgmstream.c | 4 ++ src/vgmstream.h | 1 + unix/data.c | 1 + winamp/in_vgmstream.c | 1 + 10 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 src/meta/ps2_stm.c diff --git a/readme.txt b/readme.txt index b3b2d967..a561e789 100644 --- a/readme.txt +++ b/readme.txt @@ -229,6 +229,7 @@ etc: - .sc (Activision EXAKT SASSC DPCM) - .sd9 (MS ADPCM) - .spw (FFXI PS-like ADPCM) +- .stm renamed .ps2stm (DVI IMA ADPCM) - .str (SDX2 DPCM) - .stx (GC AFC ADPCM) - .um3 (Ogg Vorbis) diff --git a/src/Makefile b/src/Makefile index 38624614..62bf9735 100644 --- a/src/Makefile +++ b/src/Makefile @@ -215,7 +215,8 @@ META_OBJS=meta/adx_header.o \ meta/pona.o \ meta/fsb_test.o \ meta/xbox_hlwav.o \ - meta/stx.o + meta/stx.o \ + meta/ps2_stm.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index e9913444..d3e54b2f 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -646,6 +646,10 @@ RelativePath=".\meta\ps2_sps.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 014d5868..b82d578a 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -173,5 +173,6 @@ libmeta_la_SOURCES += pona.c libmeta_la_SOURCES += fsb_test.c libmeta_la_SOURCES += xbox_hlwav.c libmeta_la_SOURCES += stx.c +libmeta_la_SOURCES += ps2_stm.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index 3b8fb745..a0721db1 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -427,4 +427,6 @@ VGMSTREAM * init_vgmstream_xbox_hlwav(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_stx(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_ps2_stm(STREAMFILE* streamFile); + #endif diff --git a/src/meta/ps2_stm.c b/src/meta/ps2_stm.c new file mode 100644 index 00000000..64512149 --- /dev/null +++ b/src/meta/ps2_stm.c @@ -0,0 +1,77 @@ +#include "meta.h" +#include "../util.h" + +/* STM: Red Dead Revolver */ +VGMSTREAM * init_vgmstream_ps2_stm(STREAMFILE *streamFile) { + + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("ps2stm",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x53544d41) goto fail; + if (read_32bitBE(0x4,streamFile) != 0x6b690000) goto fail; + + /* check bps */ + if (read_32bitLE(0x10,streamFile) != 4) goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x14,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x800; + vgmstream->sample_rate = (uint16_t)read_32bitLE(0xc,streamFile); + + vgmstream->coding_type = coding_INT_DVI_IMA; + + vgmstream->num_samples = read_32bitLE(0x18,streamFile); + + vgmstream->interleave_block_size = read_32bitLE(0x8,streamFile) / channel_count; + + if(1 < channel_count) + { + /* not sure if this is right ... */ + vgmstream->layout_type = layout_interleave; + } else { + vgmstream->layout_type = layout_none; + } + vgmstream->meta_type = meta_PS2_STM; + + if(loop_flag) { + vgmstream->loop_start_sample=0; + vgmstream->loop_end_sample=vgmstream->num_samples; + } + + /* 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; + + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index a78eca7a..cdf2abbd 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -234,6 +234,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_pona, init_vgmstream_xbox_hlwav, init_vgmstream_stx, + init_vgmstream_ps2_stm, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2348,6 +2349,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_STX: snprintf(temp,TEMPSIZE,"Nintendo .stx header"); break; + case meta_PS2_STM: + snprintf(temp,TEMPSIZE,"Red Dead Revolver .stm (.ps2stm)"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index c7c12fb5..8079f079 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -337,6 +337,7 @@ typedef enum { meta_ADS, /* Gauntlet Dark Legends (GC) */ meta_PS2_SPS, /* Ape Escape 2 */ meta_PS2_XA2_RRP, /* RC Revenge Pro */ + meta_PS2_STM, /* Red Dead Revolver .stm, renamed .ps2stm */ meta_XBOX_WAVM, /* XBOX WAVM File */ meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */ diff --git a/unix/data.c b/unix/data.c index a6f17c91..7541185e 100644 --- a/unix/data.c +++ b/unix/data.c @@ -126,6 +126,7 @@ gchar *vgmstream_exts [] = { "pdt", "pnb", "pos", + "ps2stm", "psh", "psw", diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 661d794b..0b496cfa 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -192,6 +192,7 @@ char * extension_list[] = { "pnb\0PNB Audio File (*.PNB)\0", "pona\0PONA Audio File (*.PONA)\0", "pos\0POS Audio File (*.POS)\0", + "ps2stm\0PS2STM Audio File (*.PS2STM)\0", "psh\0PSH Audio File (*.PSH)\0", "psw\0PSW Audio File (*.PSW)\0",