From a1797ac9eeaab8e63e11bf928b4fae39f48bbed6 Mon Sep 17 00:00:00 2001 From: bxaimc Date: Mon, 12 Apr 2010 01:06:18 +0000 Subject: [PATCH] Add TK1 from Tekken (NamCollection) to avoid conflict with TK5 infos. Add ADSC .ads from Kenka Bancho 2: Full Throttle git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@776 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 6 +- src/libvgmstream.vcproj | 4 + src/meta/Makefile.unix.am | 1 + src/meta/meta.h | 4 + src/meta/ps2_adsc.c | 63 ++++++++++++ src/meta/ps2_tk5.c | 204 ++++++++++++++++++++++++-------------- src/vgmstream.c | 8 ++ src/vgmstream.h | 2 + unix/data.c | 1 + winamp/in_vgmstream.c | 1 + 10 files changed, 217 insertions(+), 77 deletions(-) create mode 100644 src/meta/ps2_adsc.c diff --git a/src/Makefile b/src/Makefile index 54430acb..3efe3d06 100644 --- a/src/Makefile +++ b/src/Makefile @@ -232,8 +232,10 @@ META_OBJS=meta/adx_header.o \ meta/ps2_smpl.o \ meta/ps2_msa.o \ meta/pc_smp.o \ - meta/p3d.o - + meta/p3d.o \ + meta/ps2_tk1.o \ + meta/ps2_adsc.o + OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) libvgmstream.a: $(OBJECTS) diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 50e40e8d..93d5b062 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -534,6 +534,10 @@ RelativePath=".\meta\ps2_ads.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 549b5445..5d3eb7a3 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -189,5 +189,6 @@ libmeta_la_SOURCES += ps2_smpl.c libmeta_la_SOURCES += ps2_msa.c libmeta_la_SOURCES += pc_smp.c libmeta_la_SOURCES += p3d.c +libmeta_la_SOURCES += ps2_adsc.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index e3a3fb1a..74bb7c2a 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -463,4 +463,8 @@ VGMSTREAM * init_vgmstream_pc_smp(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_p3d(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_ps2_tk1(STREAMFILE* streamFile); + +VGMSTREAM * init_vgmstream_ps2_adsc(STREAMFILE* streamFile); + #endif diff --git a/src/meta/ps2_adsc.c b/src/meta/ps2_adsc.c new file mode 100644 index 00000000..eaaa0401 --- /dev/null +++ b/src/meta/ps2_adsc.c @@ -0,0 +1,63 @@ +#include "meta.h" +#include "../util.h" + +/* ADSC (from Kenka Bancho 2: Full Throttle) */ +VGMSTREAM * init_vgmstream_ps2_adsc(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("ads",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x41445343) /* ADSC */ + goto fail; + + loop_flag = 0; + channel_count = read_32bitLE(0x18,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x1000; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x14,streamFile); + vgmstream->coding_type = coding_PSX; + if(read_32bitLE(0x18,streamFile)==0x01) + vgmstream->num_samples = read_32bitLE(0x2c,streamFile)*56/32; + else + vgmstream->num_samples = read_32bitLE(0x2c,streamFile)*28/32; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x400; + vgmstream->meta_type = meta_PS2_ADSC; + + /* 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_tk5.c b/src/meta/ps2_tk5.c index 673778e2..e43abf5e 100644 --- a/src/meta/ps2_tk5.c +++ b/src/meta/ps2_tk5.c @@ -1,75 +1,129 @@ - -#include "meta.h" -#include "../util.h" - -/* TK5 (Tekken 5 Streams) */ -VGMSTREAM * init_vgmstream_ps2_tk5(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[260]; - off_t start_offset; - int loop_flag = 0; - int channel_count; - int freq_switch; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("tk5",filename_extension(filename))) goto fail; - - /* check header */ - if (read_32bitBE(0x00,streamFile) != 0x544B3553) - goto fail; - - loop_flag = (read_32bitLE(0x0C,streamFile)!=0); - channel_count = 2; - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); - if (!vgmstream) goto fail; - - /* fill in the vital statistics */ - start_offset = 0x800; - vgmstream->channels = channel_count; - freq_switch = read_16bitLE(0x7,streamFile); - switch (freq_switch){ - case 0x30: - vgmstream->sample_rate = 48000; - break; - case 0x31: - vgmstream->sample_rate = 44100; - break; - } - vgmstream->coding_type = coding_PSX_badflags; - vgmstream->num_samples = ((get_streamfile_size(streamFile)-0x800))/16*28/2; - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x10; - vgmstream->meta_type = meta_PS2_TK5; - - if (vgmstream->loop_flag) - { - vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile)/16*28; - vgmstream->loop_end_sample = vgmstream->loop_start_sample + (read_32bitLE(0x0C,streamFile)/16*28); - } - - /* 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; -} + +#include "meta.h" +#include "../util.h" + +/* TK5 (Tekken 5 Streams) */ +VGMSTREAM * init_vgmstream_ps2_tk5(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("tk5",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x544B3553) + goto fail; + + loop_flag = (read_32bitLE(0x0C,streamFile)!=0); + channel_count = 2; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x800; + vgmstream->channels = channel_count; + vgmstream->sample_rate = 48000; + vgmstream->coding_type = coding_PSX_badflags; + vgmstream->num_samples = ((get_streamfile_size(streamFile)-0x800))/16*28/2; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x10; + vgmstream->meta_type = meta_PS2_TK5; + + if (vgmstream->loop_flag) + { + vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile)/16*28; + vgmstream->loop_end_sample = vgmstream->loop_start_sample + (read_32bitLE(0x0C,streamFile)/16*28); + } + + /* 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; +} + +/* TK1 (Tekken 5 Streams from Tekken (NamCollection)) */ +VGMSTREAM * init_vgmstream_ps2_tk1(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("tk1",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x544B3553) + goto fail; + + loop_flag = (read_32bitLE(0x0C,streamFile)!=0); + channel_count = 2; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x800; + vgmstream->channels = channel_count; + vgmstream->sample_rate = 44100; + vgmstream->coding_type = coding_PSX_badflags; + vgmstream->num_samples = read_32bitLE(0x08,streamFile)/16*28; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x10; + vgmstream->meta_type = meta_PS2_TK1; + + if (vgmstream->loop_flag) + { + vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile)/16*28; + vgmstream->loop_end_sample = vgmstream->loop_start_sample + (read_32bitLE(0x0C,streamFile)/16*28); + } + + /* 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 ba342302..fc6de7a2 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -254,6 +254,8 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_msa, init_vgmstream_pc_smp, init_vgmstream_p3d, + init_vgmstream_ps2_tk1, + init_vgmstream_ps2_adsc, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2521,6 +2523,12 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_P3D: snprintf(temp,TEMPSIZE,"P3D Header"); + break; + case meta_PS2_TK1: + snprintf(temp,TEMPSIZE,"Tekken TK5STRM1 Header"); + break; + case meta_PS2_ADSC: + snprintf(temp,TEMPSIZE,"ADSC Header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 1f4f6ec0..ab3475b7 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -453,6 +453,8 @@ typedef enum { meta_PS2_MSA, /* Psyvariar -Complete Edition- */ meta_PC_SMP, /* unknown PC game .smp */ meta_P3D, /* Prototype P3D */ + meta_PS2_TK1, /* Tekken (NamCollection) */ + meta_PS2_ADSC, /* Kenka Bancho 2: Full Throttle */ } meta_t; typedef struct { diff --git a/unix/data.c b/unix/data.c index ea7ea02e..e0c5b836 100644 --- a/unix/data.c +++ b/unix/data.c @@ -191,6 +191,7 @@ gchar *vgmstream_exts [] = { "tec", "thp", + "tk1", "tk5", "tydsp", diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index c2f1281b..739903d7 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -259,6 +259,7 @@ char * extension_list[] = { "tec\0TEC Audio File (*.TEC)\0", "thp\0THP Audio File (*.THP)\0", + "tk1\0TK1 Audio File (*.TK1)\0", "tk5\0TK5 Audio File (*.TK5)\0", "tydsp\0TYDSP Audio File (*.TYDSP)\0",