diff --git a/src/Makefile b/src/Makefile index 6352cfe7..7a8dc79c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -210,7 +210,8 @@ META_OBJS=meta/adx_header.o \ meta/pc_mxst.o \ meta/pc_sob.o \ meta/exakt_sc.o \ - meta/wii_bns.o + meta/wii_bns.o \ + meta/wii_was.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 5fa9cce1..5e2ec207 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -818,6 +818,10 @@ RelativePath=".\meta\wii_sts.c" > + + @@ -966,6 +970,10 @@ RelativePath=".\coding\psx_decoder.c" > + + @@ -978,10 +986,6 @@ RelativePath=".\coding\xa_decoder.c" > - - open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; - /* The first channel */ - vgmstream->ch[0].channel_start_offset= - vgmstream->ch[0].offset=start_offset; - } - /* The second channel */ - if (channel_count == 2) { - vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!vgmstream->ch[1].streamfile) goto fail; - vgmstream->ch[1].channel_start_offset= - vgmstream->ch[1].offset=second_channel_start; - } + /* open the file for reading */ + { + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + /* The first channel */ + vgmstream->ch[0].channel_start_offset= + vgmstream->ch[0].offset=start_offset; + } + /* The second channel */ + if (channel_count == 2) { + vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!vgmstream->ch[1].streamfile) goto fail; + vgmstream->ch[1].channel_start_offset= + vgmstream->ch[1].offset=second_channel_start; + } } diff --git a/src/meta/wii_was.c b/src/meta/wii_was.c new file mode 100644 index 00000000..33948e20 --- /dev/null +++ b/src/meta/wii_was.c @@ -0,0 +1,72 @@ +#include "meta.h" +#include "../util.h" + +/* WAS (from DiRT 2 (Wii)) */ +VGMSTREAM * init_vgmstream_wii_was(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("was",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != 0x69535753) /* iWAS */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitBE(0x8,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0xE0; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x28,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = read_32bitBE(0x20,streamFile); + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitBE(0x10,streamFile); + vgmstream->layout_type = layout_interleave; + vgmstream->meta_type = meta_WII_WAS; + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x3C+i*2,streamFile); + } + if (vgmstream->channels) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x9C+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; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index 6eea39cc..1c9bfc78 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -227,6 +227,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_sab, init_vgmstream_exakt_sc, init_vgmstream_wii_bns, + init_vgmstream_wii_was, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2311,6 +2312,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_WII_BNS: snprintf(temp,TEMPSIZE,"Nintendo BNS header"); break; + case meta_WII_WAS: + snprintf(temp,TEMPSIZE,"DiRT2 WAS header"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index 97c12919..ec7d5576 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -414,6 +414,7 @@ typedef enum { meta_NGC_SCK_DSP, /* Scorpion King (NGC) */ meta_CAFF, /* iPhone .caf */ meta_EXAKT_SC, /* Activision EXAKT .SC (PS2) */ + meta_WII_WAS, /* DiRT 2 (WII) */ } meta_t; typedef struct { diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 52385205..4d85f20f 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -261,6 +261,7 @@ char * extension_list[] = { "wad\0WAD Audio File (*.WAD)\0", "wam\0WAM Audio File (*.WAM)\0", "wavm\0WAVM Audio File (*.WAVM)\0", + "was\0WAS Audio File (*.WAS)\0", "wii\0WII Audio File (*.WII)\0", "wp2\0WP2 Audio File (*.WP2)\0", "wsd\0WSD Audio File (*.WSD)\0",