From 8ddf6990c915b45b124a49e19606ba1033194e94 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Sun, 24 Jan 2010 21:27:22 +0000 Subject: [PATCH] .isws added (Sega Superstars Tennis Wii) Multi-Channel support for IDSP git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@728 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 6 ++- src/meta/Makefile.unix.am | 1 + src/meta/idsp.c | 51 +++++++++++++----------- src/meta/isws.c | 81 +++++++++++++++++++++++++++++++++++++++ src/meta/meta.h | 2 + src/vgmstream.c | 4 ++ src/vgmstream.h | 1 + winamp/in_vgmstream.c | 1 + 9 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 src/meta/isws.c diff --git a/src/Makefile b/src/Makefile index b1105258..ed3db5bd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -218,7 +218,8 @@ META_OBJS=meta/adx_header.o \ meta/stx.o \ meta/ps2_stm.o \ meta/myspd.o \ - meta/his.o + meta/his.o \ + meta/isws.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 38c38be8..33d8cf03 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1,7 +1,7 @@  + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 11f97027..8a8506ac 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -176,5 +176,6 @@ libmeta_la_SOURCES += stx.c libmeta_la_SOURCES += ps2_stm.c libmeta_la_SOURCES += myspd.c libmeta_la_SOURCES += his.c +libmeta_la_SOURCES += isws.c EXTRA_DIST = meta.h diff --git a/src/meta/idsp.c b/src/meta/idsp.c index 1fddb6e4..2b4495be 100644 --- a/src/meta/idsp.c +++ b/src/meta/idsp.c @@ -90,7 +90,7 @@ VGMSTREAM * init_vgmstream_idsp2(STREAMFILE *streamFile) { off_t start_offset; int loop_flag; int channel_count; - int i; + int i, j; /* check extension, case insensitive */ streamFile->get_name(streamFile,filename,sizeof(filename)); @@ -122,38 +122,43 @@ VGMSTREAM * init_vgmstream_idsp2(STREAMFILE *streamFile) { if (channel_count == 1) { vgmstream->layout_type = layout_none; } else if (channel_count > 1) { + if (read_32bitBE(0xD8,streamFile) == 0) { + vgmstream->layout_type = layout_none; + vgmstream->interleave_block_size = (get_streamfile_size(streamFile)-start_offset)/2; + } else if (read_32bitBE(0xD8,streamFile) > 0) { vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = read_32bitBE(0xD8,streamFile); + vgmstream->interleave_block_size = read_32bitBE(0xD8,streamFile); + } } vgmstream->meta_type = meta_IDSP2; { if (vgmstream->coding_type == coding_NGC_DSP) { - for (i=0;i<16;i++) - vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x118+i*2,streamFile); - } - if (channel_count == 2) { - for (i=0;i<16;i++) - vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x178+i*2,streamFile); + off_t coef_table[8] = {0x118,0x178,0x1D8,0x238,0x298,0x2F8,0x358,0x3B8}; + for (j=0;jchannels;j++) { + for (i=0;i<16;i++) { + vgmstream->ch[j].adpcm_coef[i] = read_16bitBE(coef_table[j]+i*2,streamFile); + } } } + } - /* 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; - - } - } + /* 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; diff --git a/src/meta/isws.c b/src/meta/isws.c new file mode 100644 index 00000000..0c0378eb --- /dev/null +++ b/src/meta/isws.c @@ -0,0 +1,81 @@ +#include "meta.h" +#include "../util.h" + +VGMSTREAM * init_vgmstream_isws(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + int loop_flag; + int channel_count; + int i, j; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("isws",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x69535753) /* iSWS */ + goto fail; + + loop_flag = 0; // read_32bitBE(0x20,streamFile); + channel_count = read_32bitBE(0x08,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = (channel_count * 0x60) + 0x20; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x28,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = (read_32bitBE(0x20,streamFile)); + if (loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = (read_32bitBE(0x20,streamFile)); + } + + if (channel_count == 1) { + vgmstream->layout_type = layout_none; + } else if (channel_count > 1) { + // vgmstream->layout_type = layout_interleave; + vgmstream->layout_type = layout_interleave_shortblock; + vgmstream->interleave_block_size = read_32bitBE(0x10,streamFile); + vgmstream->interleave_smallblock_size = (((read_32bitBE(0x24,streamFile))-start_offset)%(vgmstream->channels*vgmstream->interleave_block_size))/vgmstream->channels; + } + vgmstream->meta_type = meta_ISWS; + + { + if (vgmstream->coding_type == coding_NGC_DSP) { + off_t coef_table[8] = {0x3C,0x9C,0xFC,0x15C,0x1BC,0x21C,0x27C,0x2DC}; + for (j=0;jchannels;j++) { + for (i=0;i<16;i++) { + vgmstream->ch[j].adpcm_coef[i] = read_16bitBE(coef_table[j]+i*2,streamFile); + } + } + } + } + + /* 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/meta/meta.h b/src/meta/meta.h index 1ff89d0f..173d8003 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -433,4 +433,6 @@ VGMSTREAM * init_vgmstream_myspd(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_his(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_isws(STREAMFILE* streamFile); + #endif diff --git a/src/vgmstream.c b/src/vgmstream.c index e54f0ec9..3567ebf7 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -237,6 +237,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_stm, init_vgmstream_myspd, init_vgmstream_his, + init_vgmstream_isws, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2372,6 +2373,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_HIS: snprintf(temp,TEMPSIZE,"Her Interactive Sound header"); break; + case meta_ISWS: + snprintf(temp,TEMPSIZE,"SEGA Superstars Tennis iSWS header"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index b7eb9207..bcfca7e6 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -425,6 +425,7 @@ typedef enum { meta_WII_WAS, /* DiRT 2 (WII) */ meta_PONA, /* Policenauts (3DO + PSX) */ meta_XBOX_HLWAV, /* Half Life 2 (XBOX) */ + meta_ISWS, /* SEGA Superstars Tennis (Wii) */ } meta_t; typedef struct { diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 70b9900c..6596f2f6 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -152,6 +152,7 @@ char * extension_list[] = { "ild\0ILD Audio File (*.ILD)\0", "int\0PS2 RAW Interleaved PCM (*.INT)\0", "isd\0ISD Audio File (*.ISD)\0", + "isws\0ISWS Audio File (*.ISWS)\0", "ivaud\0IVAUD Audio File (*.IVAUD)\0", "ivb\0IVB Audio File (*.IVB)\0",