From d4e2f18106bfaac894a6a219c9c73c85a1f38a3f Mon Sep 17 00:00:00 2001 From: bxaimc Date: Wed, 18 May 2011 20:33:00 +0000 Subject: [PATCH] Added initial support for .TUN (LEGO Racers (PC)), broken though (for now) Added .WPD support for Shuffle! (PC) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@951 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- fb2k/in_vgmstream.cpp | 4 +++ src/Makefile | 4 ++- src/libvgmstream.vcproj | 8 ++++++ src/meta/Makefile.unix.am | 2 ++ src/meta/meta.h | 4 +++ src/meta/tun.c | 59 +++++++++++++++++++++++++++++++++++++++ src/meta/wpd.c | 59 +++++++++++++++++++++++++++++++++++++++ src/vgmstream.c | 8 ++++++ src/vgmstream.h | 2 ++ unix/data.c | 2 ++ winamp/in_vgmstream.c | 2 ++ 11 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 src/meta/tun.c create mode 100644 src/meta/wpd.c diff --git a/fb2k/in_vgmstream.cpp b/fb2k/in_vgmstream.cpp index 787a8d34..4a878a22 100644 --- a/fb2k/in_vgmstream.cpp +++ b/fb2k/in_vgmstream.cpp @@ -478,6 +478,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension if(!stricmp_utf8(p_extension,"tk1")) return 1; if(!stricmp_utf8(p_extension,"tk5")) return 1; if(!stricmp_utf8(p_extension,"tra")) return 1; + if(!stricmp_utf8(p_extension,"tun")) return 1; if(!stricmp_utf8(p_extension,"tydsp")) return 1; if(!stricmp_utf8(p_extension,"um3")) return 1; @@ -504,6 +505,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension if(!stricmp_utf8(p_extension,"wii")) return 1; if(!stricmp_utf8(p_extension,"wmus")) return 1; if(!stricmp_utf8(p_extension,"wp2")) return 1; + if(!stricmp_utf8(p_extension,"wpd")) return 1; if(!stricmp_utf8(p_extension,"wsd")) return 1; if(!stricmp_utf8(p_extension,"wsi")) return 1; if(!stricmp_utf8(p_extension,"wvs")) return 1; @@ -784,6 +786,7 @@ DECLARE_MULTIPLE_FILE_TYPE("TEC Audio File (*.TEC)", tec); DECLARE_MULTIPLE_FILE_TYPE("THP Audio File (*.THP)", thp); DECLARE_MULTIPLE_FILE_TYPE("TK1 Audio File (*.TK1)", tk1); DECLARE_MULTIPLE_FILE_TYPE("TK5 Audio File (*.TK5)", tk5); +DECLARE_MULTIPLE_FILE_TYPE("TUN Audio File (*.TUN)", tun); DECLARE_MULTIPLE_FILE_TYPE("TYDSP Audio File (*.TYDSP)", tydsp); DECLARE_MULTIPLE_FILE_TYPE("UM3 Audio File (*.UM3)", um3); @@ -809,6 +812,7 @@ DECLARE_MULTIPLE_FILE_TYPE("WAS Audio File (*.WAS)", was); DECLARE_MULTIPLE_FILE_TYPE("WII Audio File (*.WII)", wii); DECLARE_MULTIPLE_FILE_TYPE("WMUS Audio File (*.WMUS)", wmus); DECLARE_MULTIPLE_FILE_TYPE("WP2 Audio File (*.WP2)", wp2); +DECLARE_MULTIPLE_FILE_TYPE("WPD Audio File (*.WPD)", wpd); DECLARE_MULTIPLE_FILE_TYPE("WSD Audio File (*.WSD)", wsd); DECLARE_MULTIPLE_FILE_TYPE("WSI Audio File (*.WSI)", wsi); DECLARE_MULTIPLE_FILE_TYPE("WVS Audio File (*.WVS)", wvs); diff --git a/src/Makefile b/src/Makefile index e05de0f7..e24363e7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -280,7 +280,9 @@ META_OBJS=meta/adx_header.o \ meta/pc_adp.o \ meta/excitebots.o \ meta/ps3_klbs.o \ - meta/ps2_mtaf.o + meta/ps2_mtaf.o \ + meta/tun.o \ + meta/wpd.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 0c817ffe..4a613d15 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1006,6 +1006,10 @@ RelativePath=".\meta\thp.c" > + + @@ -1046,6 +1050,10 @@ RelativePath=".\meta\wii_sts.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 542abe01..ed5aa9b8 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -227,5 +227,7 @@ libmeta_la_SOURCES += pc_adp.c libmeta_la_SOURCES += excitebots.c libmeta_la_SOURCES += ps2_mtaf.c libmeta_la_SOURCES += ps3_klbs.c +libmeta_la_SOURCES += tun.c +libmeta_la_SOURCES += wpd.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index 2604bd13..bf951c4d 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -577,4 +577,8 @@ VGMSTREAM * init_vgmstream_ps3_sgx(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ps2_mtaf(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_tun(STREAMFILE* streamFile); + +VGMSTREAM * init_vgmstream_wpd(STREAMFILE* streamFile); + #endif diff --git a/src/meta/tun.c b/src/meta/tun.c new file mode 100644 index 00000000..086e9fb2 --- /dev/null +++ b/src/meta/tun.c @@ -0,0 +1,59 @@ +#include "meta.h" +#include "../util.h" + +/* TUN (from LEGO Racers (PC)) */ +VGMSTREAM * init_vgmstream_tun(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + int channel_count; + int loop_flag; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("tun",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x414C5020) /* "ALP " */ + goto fail; + + channel_count = 2; + loop_flag = 0; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x10; + vgmstream->channels = channel_count; + vgmstream->sample_rate = 22050; + vgmstream->coding_type = coding_DVI_IMA; + vgmstream->num_samples = (get_streamfile_size(streamFile)) - 0x10; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 1; + vgmstream->meta_type = meta_TUN; + + /* 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/wpd.c b/src/meta/wpd.c new file mode 100644 index 00000000..12a6ffd1 --- /dev/null +++ b/src/meta/wpd.c @@ -0,0 +1,59 @@ +#include "meta.h" +#include "../util.h" + +/* WPD (from Shuffle! (PC)) */ +VGMSTREAM * init_vgmstream_wpd(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + int channel_count; + int loop_flag; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("wpd",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x20445057) /* " DPW" */ + goto fail; + + channel_count = read_32bitLE(0x4,streamFile); + loop_flag = 0; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x30; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x10,streamFile); + vgmstream->coding_type = coding_PCM16LE; + vgmstream->num_samples = (read_32bitLE(0x14,streamFile))/2/channel_count; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 2; + vgmstream->meta_type = meta_WPD; + + /* 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 d3cdcf4a..bf02bbc7 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -310,6 +310,8 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps3_klbs, init_vgmstream_ps3_sgx, init_vgmstream_ps2_mtaf, + init_vgmstream_tun, + init_vgmstream_wpd, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2854,6 +2856,12 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_PS2_VAG2: snprintf(temp,TEMPSIZE,"Konami VAG Stereo header (VAG2)"); + break; + case meta_TUN: + snprintf(temp,TEMPSIZE,"TUN 'ALP' header"); + break; + case meta_WPD: + snprintf(temp,TEMPSIZE,"WPD 'DPW' header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 8bedcd34..c4b7c682 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -524,6 +524,8 @@ typedef enum { meta_PS2_MTAF, // Metal Gear Solid 3 MTAF meta_PS2_VAG1, // Metal Gear Solid 3 VAG1 meta_PS2_VAG2, // Metal Gear Solid 3 VAG2 + meta_TUN, // LEGO Racers (PC) + meta_WPD, // Shuffle! (PC) } meta_t; typedef struct { diff --git a/unix/data.c b/unix/data.c index d44f3984..975e1523 100644 --- a/unix/data.c +++ b/unix/data.c @@ -225,6 +225,7 @@ gchar *vgmstream_exts [] = { "tk1", "tk5", "tra", + "tun", "tydsp", "um3", @@ -251,6 +252,7 @@ gchar *vgmstream_exts [] = { "wii", "wmus", "wp2", + "wpd", "wsd", "wsi", "wvs", diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index d5a015ee..76b51835 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -295,6 +295,7 @@ char * extension_list[] = { "tk1\0TK1 Audio File (*.TK1)\0", "tk5\0TK5 Audio File (*.TK5)\0", "tra\0TRA Audio File (*.TRA)\0", + "tun\0TUN Audio File (*.TUN)\0", "tydsp\0TYDSP Audio File (*.TYDSP)\0", "um3\0UM3 Audio File (*.UM3)\0", @@ -322,6 +323,7 @@ char * extension_list[] = { "wii\0WII Audio File (*.WII)\0", "wmus\0WMUS Audio File (*.WMUS)\0", "wp2\0WP2 Audio File (*.WP2)\0", + "wpd\0WPD Audio File (*.WPD)\0", "wsd\0WSD Audio File (*.WSD)\0", "wsi\0WSI Audio File (*.WSI)\0", "wvs\0WVS Audio File (*.WVS)\0",