From d003418862e754f704a2b45836a156cad571da10 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Sun, 23 Aug 2009 08:42:14 +0000 Subject: [PATCH] .gcub added for "Sega Soccer Slam" git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@669 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 4 +++ src/meta/Makefile.unix.am | 1 + src/meta/meta.h | 2 ++ src/meta/ngc_gcub.c | 76 +++++++++++++++++++++++++++++++++++++++ src/vgmstream.c | 4 +++ src/vgmstream.h | 1 + winamp/in_vgmstream.c | 1 + 8 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/meta/ngc_gcub.c diff --git a/src/Makefile b/src/Makefile index 1c8e80a6..f596ff48 100644 --- a/src/Makefile +++ b/src/Makefile @@ -200,7 +200,8 @@ META_OBJS=meta/adx_header.o \ meta/sd9.o \ meta/2dx.o \ meta/ngc_dsp_ygo.o \ - meta/ps2_vgv.o + meta/ps2_vgv.o \ + meta/ngc_gcub.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 af824890..f1a7f990 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -422,6 +422,10 @@ RelativePath=".\meta\ngc_ffcc_str.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 16131342..fa419bac 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -160,5 +160,6 @@ libmeta_la_SOURCES += sd9.c libmeta_la_SOURCES += 2dx.c libmeta_la_SOURCES += ngc_dsp_ygo.c libmeta_la_SOURCES += ps2_vgv.c +libmeta_la_SOURCES += ngc_gcub.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index e01ab8d2..d8366c69 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -397,4 +397,6 @@ VGMSTREAM * init_vgmstream_dsp_ygo(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_ps2_vgv(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_ngc_gcub(STREAMFILE * streamFile); + #endif diff --git a/src/meta/ngc_gcub.c b/src/meta/ngc_gcub.c new file mode 100644 index 00000000..6bc5b5b7 --- /dev/null +++ b/src/meta/ngc_gcub.c @@ -0,0 +1,76 @@ +#include "meta.h" +#include "../util.h" + +/* GCUB - found in 'Sega Soccer Slam' */ +VGMSTREAM * init_vgmstream_ngc_gcub(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("gcub",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x47437562) /* "GCub" */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitBE(0x04,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x60; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x08,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = (read_32bitBE(0x0C,streamFile)-start_offset)/8/channel_count*14; + if (loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = (read_32bitBE(0x0C,streamFile)-start_offset)/8/channel_count*14; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x8000; // read_32bitBE(0x04,streamFile); + vgmstream->meta_type = meta_NGC_GCUB; + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x10+i*2,streamFile); + } + if (vgmstream->channels) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x30+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/vgmstream.c b/src/vgmstream.c index 9c864123..971e161b 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -218,6 +218,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_2dx, init_vgmstream_dsp_ygo, init_vgmstream_ps2_vgv, + init_vgmstream_ngc_gcub, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2218,6 +2219,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_PS2_VGV: snprintf(temp,TEMPSIZE,"Rune: Viking Warlord VGV Header"); break; + case meta_NGC_GCUB: + snprintf(temp,TEMPSIZE,"Sega Soccer Slam GCub Header"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index 9c8fe764..9794ee0e 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -400,6 +400,7 @@ typedef enum { meta_SD9, /* beatmaniaIIDX16 - EMPRESS (Arcade) */ meta_2DX, /* beatmaniaIIDX16 - EMPRESS (Arcade) */ meta_PS2_VGV, /* Rune: Viking Warlord */ + meta_NGC_GCUB, /* Rune: Viking Warlord */ } meta_t; typedef struct { diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 7e7c85e1..dac064db 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -132,6 +132,7 @@ char * extension_list[] = { "gbts\0GBTS Audio File (*.GBTS)\0", "gca\0GCA Audio File (*.GCA)\0", "gcm\0GCM Audio File (*.GCM)\0", + "gcub\0GCUB Audio File (*.GCUB)\0", "gcw\0GCW Audio File (*.GCW)\0", "genh\0GENH Audio File (*.GENH)\0", "gms\0GMS Audio File (*.GMS)\0",