From 85e9303b61df8cf3717b5b9715b81d53d1608c27 Mon Sep 17 00:00:00 2001 From: manakoat Date: Fri, 22 Jul 2011 05:32:10 +0000 Subject: [PATCH] added .mms support (ShellSHock Nam '67) added WIP support for Mini Minjas (.mnstr) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@965 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- fb2k/in_vgmstream.cpp | 2 + src/Makefile | 4 +- src/libvgmstream.vcproj | 10 ++++- src/meta/Makefile.unix.am | 2 + src/meta/meta.h | 4 ++ src/meta/mn_str.c | 78 +++++++++++++++++++++++++++++++++++++++ src/meta/ps2_mss.c | 68 ++++++++++++++++++++++++++++++++++ src/vgmstream.c | 12 +++++- src/vgmstream.h | 2 + winamp/in_vgmstream.c | 1 + 10 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 src/meta/mn_str.c create mode 100644 src/meta/ps2_mss.c diff --git a/fb2k/in_vgmstream.cpp b/fb2k/in_vgmstream.cpp index 03a3af95..5aaeef5c 100644 --- a/fb2k/in_vgmstream.cpp +++ b/fb2k/in_vgmstream.cpp @@ -379,6 +379,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension if(!stricmp_utf8(p_extension,"mib")) return 1; if(!stricmp_utf8(p_extension,"mic")) return 1; if(!stricmp_utf8(p_extension,"mihb")) return 1; + if(!stricmp_utf8(p_extension,"mnstr")) return 1; if(!stricmp_utf8(p_extension,"mpdsp")) return 1; if(!stricmp_utf8(p_extension,"mpds")) return 1; if(!stricmp_utf8(p_extension,"msa")) return 1; @@ -689,6 +690,7 @@ DECLARE_MULTIPLE_FILE_TYPE("PS2 MI4 Audio File (*.MI4)", mi4); DECLARE_MULTIPLE_FILE_TYPE("PS2 MIB Audio File (*.MIB)", mib); DECLARE_MULTIPLE_FILE_TYPE("PS2 MIC Audio File (*.MIC)", mic); DECLARE_MULTIPLE_FILE_TYPE("MIHB Audio File (*.MIHB)", mihb); +DECLARE_MULTIPLE_FILE_TYPE("MNSTR Audio File (*.MNSTR)", mnstr); DECLARE_MULTIPLE_FILE_TYPE("MPDSP Audio File (*.MPDSP)", mpdsp); DECLARE_MULTIPLE_FILE_TYPE("MPDS Audio File (*.MPDS)", mpds); DECLARE_MULTIPLE_FILE_TYPE("MSA Audio File (*.MSA)", msa); diff --git a/src/Makefile b/src/Makefile index e24363e7..55a7de46 100644 --- a/src/Makefile +++ b/src/Makefile @@ -282,7 +282,9 @@ META_OBJS=meta/adx_header.o \ meta/ps3_klbs.o \ meta/ps2_mtaf.o \ meta/tun.o \ - meta/wpd.o + meta/wpd.o \ + meta/mn_str.o \ + meta/ps2_mss.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 4a613d15..6b924347 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1,7 +1,7 @@  + + @@ -714,6 +718,10 @@ RelativePath=".\meta\ps2_msa.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index ed5aa9b8..4c0da76d 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -229,5 +229,7 @@ libmeta_la_SOURCES += ps2_mtaf.c libmeta_la_SOURCES += ps3_klbs.c libmeta_la_SOURCES += tun.c libmeta_la_SOURCES += wpd.c +libmeta_la_SOURCES += mn_str.c +libmeta_la_SOURCES += ps2_mss.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index 372db20b..4a99f72d 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -596,4 +596,8 @@ VGMSTREAM * init_vgmstream_wpd(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ps3_sgd(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_mn_str(STREAMFILE* streamFile); + +VGMSTREAM * init_vgmstream_ps2_mss(STREAMFILE* streamFile); + #endif diff --git a/src/meta/mn_str.c b/src/meta/mn_str.c new file mode 100644 index 00000000..41c18d2b --- /dev/null +++ b/src/meta/mn_str.c @@ -0,0 +1,78 @@ +#include "meta.h" +#include "../util.h" + +VGMSTREAM * init_vgmstream_mn_str(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + int loop_flag = 0; + int channel_count; + int bitspersample; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("mnstr",filename_extension(filename))) goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x50,streamFile); + bitspersample = read_32bitLE(0x58,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = read_32bitLE(0x20,streamFile)+0x48; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x54,streamFile); + + switch (bitspersample) { + case 0x10: + vgmstream->coding_type = coding_PCM16LE; + if (channel_count = 1) + { + vgmstream->layout_type = layout_none; + } + else + { + vgmstream->interleave_block_size = 0x2; + vgmstream->layout_type = layout_interleave; + } + break; + case 0x4: + if (read_32bitLE(0x20,streamFile) == 0x24) + { + vgmstream->interleave_block_size = 0x800; + vgmstream->layout_type = layout_none; + } + } + + vgmstream->num_samples = read_32bitLE(0x4C,streamFile); + + //vgmstream->layout_type = layout_interleave; + //vgmstream->interleave_block_size = 0x2; + vgmstream->meta_type = meta_MN_STR; + + /* 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/ps2_mss.c b/src/meta/ps2_mss.c new file mode 100644 index 00000000..2f350bd3 --- /dev/null +++ b/src/meta/ps2_mss.c @@ -0,0 +1,68 @@ +#include "meta.h" +#include "../util.h" + +VGMSTREAM * init_vgmstream_ps2_mss(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("mss",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x4D435353) /* "MCSS" */ + goto fail; + + loop_flag = 0; + channel_count = read_16bitLE(0x16,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = read_32bitLE(0x08,streamFile); + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x10,streamFile); + vgmstream->coding_type = coding_PSX; + vgmstream->num_samples = read_32bitLE(0x1C,streamFile); + + + if (channel_count == 1) + { + vgmstream->layout_type = layout_none; + } + else + { + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitLE(0x18,streamFile); + } + + vgmstream->meta_type = meta_PS2_MSS; + + /* 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 aa925e40..68a1a4d0 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -313,6 +313,8 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_tun, init_vgmstream_wpd, init_vgmstream_ps3_sgd, + init_vgmstream_mn_str, + init_vgmstream_ps2_mss, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2626,10 +2628,10 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_CAFF: snprintf(temp,TEMPSIZE,"Apple Core Audio Format Header"); break; - case meta_PC_MXST: + case meta_PC_MXST: snprintf(temp,TEMPSIZE,"Lego Island MxSt Header"); break; - case meta_PC_SOB_SAB: + case meta_PC_SOB_SAB: snprintf(temp,TEMPSIZE,"Worms 4: Mayhem SOB/SAB Header"); break; case meta_MAXIS_XA: @@ -2863,6 +2865,12 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_WPD: snprintf(temp,TEMPSIZE,"WPD 'DPW' header"); + break; + case meta_MN_STR: + snprintf(temp,TEMPSIZE,"Mini Ninjas 'STR' header"); + break; + case meta_PS2_MSS: + snprintf(temp,TEMPSIZE,"ShellShock Nam '67 'MSCC' header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index c8b9a194..1dd01118 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -526,6 +526,8 @@ typedef enum { meta_PS2_VAG2, // Metal Gear Solid 3 VAG2 meta_TUN, // LEGO Racers (PC) meta_WPD, // Shuffle! (PC) + meta_MN_STR, // Mini Ninjas (PC/PS3/WII) + meta_PS2_MSS, // ShellShock Nam '67 (PS2) } meta_t; typedef struct { diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 36bfa303..82f282d8 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -194,6 +194,7 @@ char * extension_list[] = { "mib\0PS2 MIB Audio File (*.MIB)\0", "mic\0PS2 MIC Audio File (*.MIC)\0", "mihb\0MIHB Audio File (*.MIHB)\0", + "mnstr\0MNSTR Audio File (*.MNSTR)\0", "mpdsp\0MPDSP Audio File (*.MPDSP)\0", "mpds\0MPDS Audio File (*.MPDS)\0", "msa\0MSA Audio File (*.MSA)\0",