From f514642b763890d65632848e92427620347eeb75 Mon Sep 17 00:00:00 2001 From: manakoat Date: Tue, 15 Feb 2011 18:24:50 +0000 Subject: [PATCH] add Mattel Hyperscan format git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@923 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 6 +++- src/meta/Makefile.unix.am | 1 + src/meta/mattel_hyperscan.c | 66 +++++++++++++++++++++++++++++++++++++ src/meta/meta.h | 2 ++ src/vgmstream.c | 4 +++ src/vgmstream.h | 1 + winamp/in_vgmstream.c | 1 + 8 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/meta/mattel_hyperscan.c diff --git a/src/Makefile b/src/Makefile index c8078752..bbaa41b5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -274,7 +274,8 @@ META_OBJS=meta/adx_header.o \ meta/lsf.o \ meta/ps3_vawx.o \ meta/pc_snds.o \ - meta/ps2_wmus.o + meta/ps2_wmus.o \ + meta/mattel_hyperscan.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 a9adb107..b92a3dad 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 bc1b2dd9..1d09d6c3 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -222,5 +222,6 @@ libmeta_la_SOURCES += lsf.c libmeta_la_SOURCES += ps3_vawx.c libmeta_la_SOURCES += pc_snds.c libmeta_la_SOURCES += ps2_wmus.c +libmeta_la_SOURCES += mattel_hyperscan.c EXTRA_DIST = meta.h diff --git a/src/meta/mattel_hyperscan.c b/src/meta/mattel_hyperscan.c new file mode 100644 index 00000000..50bdd7ee --- /dev/null +++ b/src/meta/mattel_hyperscan.c @@ -0,0 +1,66 @@ +#include "meta.h" +#include "../util.h" + +/* Mattel Hyperscan, +- Place all metas for this console here (there are just 5 games) */ +VGMSTREAM * init_vgmstream_hyperscan_kvag(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("bvg",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x4B564147) /* "KVAG" */ + goto fail; + + channel_count = 1; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0xE; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x8,streamFile); + vgmstream->coding_type = coding_DVI_IMA; + vgmstream->num_samples = read_32bitLE(0x4,streamFile)*2; + +#if 0 + if (loop_flag) { + vgmstream->loop_start_sample = (read_32bitLE(0x08,streamFile)-1)*28; + vgmstream->loop_end_sample = (read_32bitLE(0x0c,streamFile)-1)*28; + } +#endif + + vgmstream->layout_type = layout_none; + vgmstream->meta_type = meta_HYPERSCAN_KVAG; + + /* 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 9cce0141..bd1a449e 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -561,4 +561,6 @@ VGMSTREAM * init_vgmstream_pc_snds(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ps2_wmus(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_hyperscan_kvag(STREAMFILE* streamFile); + #endif diff --git a/src/vgmstream.c b/src/vgmstream.c index 4935559d..5ce3b385 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -302,6 +302,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps3_vawx, init_vgmstream_pc_snds, init_vgmstream_ps2_wmus, + init_vgmstream_hyperscan_kvag, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2806,6 +2807,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_PS2_WMUS: snprintf(temp,TEMPSIZE,"assumed The Warriors Sony ADPCM by .wmus extension"); + break; + case meta_HYPERSCAN_KVAG: + snprintf(temp,TEMPSIZE,"Mattel Hyperscan KVAG"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 093cf42f..446ab906 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -515,6 +515,7 @@ typedef enum { meta_PS3_VAWX, // No More Heroes: Heroes Paradise (PS3) meta_PC_SNDS, // Incredibles PC .snds meta_PS2_WMUS, // The Warriors (PS2) + meta_HYPERSCAN_KVAG, // Hyperscan KVAG/BVG } meta_t; typedef struct { diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 8fc421ab..7be63001 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -114,6 +114,7 @@ char * extension_list[] = { "bnsf\0BNSF Audio File (*.BNSF)\0", "bo2\0BO2 Audio File (*.BO2)\0", "brstm;brstmspm\0BRSTM Audio File (*.BRSTM)\0", + "bvg\0BVG Audio File (*.BVG)\0", "caf\0CAF Audio File (*.CAF)\0", "capdsp\0CAPDSP Audio File (*.CAPDSP)\0", /* Capcom custom coefs */