From c11656570c5e78fe3ada4c33778c505af1eef175 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Thu, 27 Nov 2008 21:08:48 +0000 Subject: [PATCH] added new musx format gca added (Metal SLug Anthology) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@491 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 4 +++ src/meta/Makefile.unix.am | 1 + src/meta/fsb.c | 1 + src/meta/gca.c | 74 +++++++++++++++++++++++++++++++++++++++ src/meta/meta.h | 2 ++ src/meta/musx.c | 3 ++ src/vgmstream.c | 4 +++ src/vgmstream.h | 1 + winamp/in_vgmstream.c | 1 + 10 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/meta/gca.c diff --git a/src/Makefile b/src/Makefile index b9c5cf69..3ac62e93 100644 --- a/src/Makefile +++ b/src/Makefile @@ -148,7 +148,8 @@ META_OBJS=meta/adx_header.o \ meta/ngc_waa_wac_wad_wam.o \ meta/ps2_seg.o \ meta/str_asr.o \ - meta/zwdsp.o + meta/zwdsp.o \ + meta/gca.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 c94f85df..c49b3a40 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -271,6 +271,10 @@ RelativePath=".\meta\fsb.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index d9d69a00..bee83838 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -117,4 +117,5 @@ libmeta_la_SOURCES += ngc_waa_wac_wad_wam.c libmeta_la_SOURCES += ps2_seg.c libmeta_la_SOURCES += str_asr.c libmeta_la_SOURCES += zwdsp.c +libmeta_la_SOURCES += gca.c EXTRA_DIST = meta.h diff --git a/src/meta/fsb.c b/src/meta/fsb.c index aff54fad..0962ec89 100644 --- a/src/meta/fsb.c +++ b/src/meta/fsb.c @@ -139,6 +139,7 @@ VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) { case 0x41008800: /* PS2 (Flat Out) */ case 0x42008800: /* PS2 (Jackass - The Game) */ case 0x01008804: /* PS2 (Cold Fear) */ + case 0x02008804: /* PS2 (Shrek - Smash 'n Crash */ vgmstream->coding_type = coding_PSX; vgmstream->layout_type = layout_interleave; vgmstream->interleave_block_size = 0x10; diff --git a/src/meta/gca.c b/src/meta/gca.c new file mode 100644 index 00000000..f34d780d --- /dev/null +++ b/src/meta/gca.c @@ -0,0 +1,74 @@ +#include "meta.h" +#include "../util.h" + +/* GCA (from Metal Slug Anthology [Wii]) */ +VGMSTREAM * init_vgmstream_gca(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag = 0; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("gca",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x47434131) /* "GCA1" */ + goto fail; + + loop_flag = 0; + channel_count = 1; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x40; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x2A,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = read_32bitBE(0x26,streamFile)*7/8; + if (loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = read_32bitBE(0x26,streamFile)*7/8; + } + + /* We have no interleave, so we have no layout */ + vgmstream->layout_type = layout_none; + vgmstream->meta_type = meta_GCA; + + /* 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; + + } + } + + /*Retrieving the coef table */ + { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x04+i*2,streamFile); + } + } + + + 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 3424442f..e98cf256 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -285,4 +285,6 @@ VGMSTREAM * init_vgmstream_str_asr(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_zwdsp(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_gca(STREAMFILE * streamFile); + #endif diff --git a/src/meta/musx.c b/src/meta/musx.c index 9a47bfb8..c4bc12b8 100644 --- a/src/meta/musx.c +++ b/src/meta/musx.c @@ -285,6 +285,9 @@ VGMSTREAM * init_vgmstream_musx_v201(STREAMFILE *streamFile) { loop_detect = read_32bitBE(0x800,streamFile); switch (loop_detect) { + case 0x02000000: + loop_offsets = 0x8E0; + break; case 0x03000000: loop_offsets = 0x880; break; diff --git a/src/vgmstream.c b/src/vgmstream.c index 64900f56..d399b9fc 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -159,6 +159,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_nds_strm_ffta2, init_vgmstream_str_asr, init_vgmstream_zwdsp, + init_vgmstream_gca, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -1835,6 +1836,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_ZWDSP: snprintf(temp,TEMPSIZE,"Zack and Wiki custom DSP Header"); + break; + case meta_GCA: + snprintf(temp,TEMPSIZE,"GCA DSP Header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 3e049097..02bb036d 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -246,6 +246,7 @@ typedef enum { meta_IDSP2, /* Chronicles of Narnia */ meta_WAA_WAC_WAD_WAM, /* Beyond Good & Evil */ + meta_GCA, /* Metal Slug Anthology */ meta_NGC_YMF, /* WWE WrestleMania X8 */ meta_SADL, /* .sad */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index cf07a42c..c545cfe2 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -202,6 +202,7 @@ char * extension_list[] = { "seg\0SEG Audio File (*.SEG)\0", "asr\0ASR Audio File (*.ASR)\0", "zwdsp\0ZWDSP Audio File (*.ZWDSP)\0", + "gca\0GCA Audio File (*.GCA)\0", }; void about(HWND hwndParent) {