From 019497f8290a910c29f8ca03dcf3e2dc994279b6 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Fri, 6 Feb 2009 19:16:37 +0000 Subject: [PATCH] nds swav added git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@575 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 4 ++ src/meta/Makefile.unix.am | 1 + src/meta/gsp_gsb.c | 18 ++++---- src/meta/meta.h | 2 + src/meta/nds_swav.c | 89 +++++++++++++++++++++++++++++++++++++++ src/vgmstream.c | 4 ++ src/vgmstream.h | 1 + winamp/in_vgmstream.c | 1 + 9 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 src/meta/nds_swav.c diff --git a/src/Makefile b/src/Makefile index 1d8a360a..dac92e08 100644 --- a/src/Makefile +++ b/src/Makefile @@ -178,7 +178,8 @@ META_OBJS=meta/adx_header.o \ meta/ps2_p2bt.o \ meta/ps2_gbts.o \ meta/ngc_ffcc_str.o \ - meta/sat_baka.o + meta/sat_baka.o \ + meta/nds_swav.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 75b982b9..e66eed59 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -370,6 +370,10 @@ RelativePath=".\meta\nds_strm.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index f3f49399..270ea0f9 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -139,5 +139,6 @@ libmeta_la_SOURCES += ps2_p2bt.c libmeta_la_SOURCES += ps2_gbts.c libmeta_la_SOURCES += ngc_ffcc_str.c libmeta_la_SOURCES += sat_baka.c +libmeta_la_SOURCES += nds_swav.c EXTRA_DIST = meta.h diff --git a/src/meta/gsp_gsb.c b/src/meta/gsp_gsb.c index 8f6716ea..de9e77ad 100644 --- a/src/meta/gsp_gsb.c +++ b/src/meta/gsp_gsb.c @@ -63,15 +63,15 @@ VGMSTREAM * init_vgmstream_gsp_gsb(STREAMFILE *streamFile) { vgmstream->meta_type = meta_GSP_GSB; - /* open the file for reading by each channel */ - { - for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size); - - if (!vgmstream->ch[i].streamfile) goto fail; - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=i*vgmstream->interleave_block_size; - } + /* open the file for reading by each channel */ + { + for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size); + + if (!vgmstream->ch[i].streamfile) goto fail; + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=i*vgmstream->interleave_block_size; + } } if (vgmstream->coding_type == coding_NGC_DSP) { diff --git a/src/meta/meta.h b/src/meta/meta.h index 6f865574..8561decf 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -334,4 +334,6 @@ VGMSTREAM * init_vgmstream_ngc_ffcc_str(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_sat_baka(STREAMFILE *streamFile); +VGMSTREAM * init_vgmstream_nds_swav(STREAMFILE *streamFile); + #endif diff --git a/src/meta/nds_swav.c b/src/meta/nds_swav.c new file mode 100644 index 00000000..7fdec2a0 --- /dev/null +++ b/src/meta/nds_swav.c @@ -0,0 +1,89 @@ +#include "meta.h" +#include "../util.h" + +/* 28.01.2009 - bxaimc : + SWAV - found in Asphalt Urban GT & Asphalt Urban GT 2 */ +VGMSTREAM * init_vgmstream_nds_swav(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + int codec_number; + int channel_count; + int loop_flag; + coding_t coding_type; + off_t start_offset; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("swav",filename_extension(filename))) goto fail; + + /* check header */ + if ((uint32_t)read_32bitBE(0x00,streamFile)!=0x53574156) /* SWAV */ + goto fail; + + /* check for DATA section */ + if ((uint32_t)read_32bitBE(0x10,streamFile)!=0x44415441) /* "DATA" */ + goto fail; + + /* check type details */ + codec_number = read_8bit(0x18,streamFile); + loop_flag = read_32bitLE(0x20,streamFile); + channel_count = (uint16_t)read_16bitLE(0xE,streamFile); + + switch (codec_number) { + case 0: + coding_type = coding_PCM8; + break; + case 1: + coding_type = coding_PCM16LE; + break; + case 2: + coding_type = coding_NDS_IMA; + break; + default: + goto fail; + } + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x24; + vgmstream->num_samples = (read_32bitLE(0x20,streamFile)*8)/channel_count; + vgmstream->sample_rate = (uint16_t)read_16bitLE(0x1A,streamFile); + + if (loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = (read_32bitLE(0x20,streamFile)*8)/channel_count; + } + + vgmstream->coding_type = coding_type; + vgmstream->meta_type = meta_NDS_SWAV; + vgmstream->layout_type = layout_none; + + + + /* open the file for reading by each channel */ + + { + 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; + vgmstream->ch[i].adpcm_step_index = read_8bit(0x1F,streamFile); + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} \ No newline at end of file diff --git a/src/vgmstream.c b/src/vgmstream.c index b7c2d73e..c2de3313 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -187,6 +187,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_aax, init_vgmstream_ngc_ffcc_str, init_vgmstream_sat_baka, + init_vgmstream_nds_swav, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2052,6 +2053,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_SAT_BAKA: snprintf(temp,TEMPSIZE,"BAKA header from Crypt Killer"); break; + case meta_NDS_SWAV: + snprintf(temp,TEMPSIZE,"SWAV Header"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index 940b51b1..86d7f8d0 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -178,6 +178,7 @@ typedef enum { meta_RSTM_SPM, /* RSTM with 44->22khz hack */ meta_THP, meta_RSTM_shrunken, /* Atlus' mutant shortened RSTM */ + meta_NDS_SWAV, /* Asphalt Urban GT 1 & 2 */ /* CRI ADX */ meta_ADX_03, /* ADX "type 03" */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 77aabeed..61ccc2f2 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -224,6 +224,7 @@ char * extension_list[] = { "mwv\0MWV Audio File (*.MWV)\0", "rwav\0RWAV Audio File (*.RWAV)\0", "baka\0BAKA Audio File (*.BAKA)\0", + "swav\0SWAV Audio File (*.SWAV)\0", }; void about(HWND hwndParent) {