From 19fcc3fb49d5f0d9201675f0dbd43a556a777a25 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Sat, 11 Sep 2010 17:53:33 +0000 Subject: [PATCH] add NST DSP (Animaniacs NGC) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@837 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/libvgmstream.vcproj | 6 ++- src/meta/meta.h | 2 + src/meta/ngc_nst_dsp.c | 89 +++++++++++++++++++++++++++++++++++++++++ src/vgmstream.c | 12 ++++-- src/vgmstream.h | 15 +++---- 5 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 src/meta/ngc_nst_dsp.c diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index e1c01672..3815263c 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1,7 +1,7 @@  + + diff --git a/src/meta/meta.h b/src/meta/meta.h index e315513c..6bb58944 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -523,4 +523,6 @@ VGMSTREAM * init_vgmstream_ps3_cps(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_se_scd(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_ngc_nst_dsp(STREAMFILE* streamFile); + #endif diff --git a/src/meta/ngc_nst_dsp.c b/src/meta/ngc_nst_dsp.c new file mode 100644 index 00000000..9b0dd1b3 --- /dev/null +++ b/src/meta/ngc_nst_dsp.c @@ -0,0 +1,89 @@ +#include "meta.h" +#include "../util.h" + +/* DSP (Animaniacs: The Great Edgar Hunt) */ +// NOTE: The second dsp header is just a dummy, both channels +// use the same coef table (0x20) + +VGMSTREAM * init_vgmstream_ngc_nst_dsp(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("dsp",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x0,streamFile) != read_32bitBE(0x54,streamFile)) + goto fail; + if (read_32bitBE(0x4,streamFile) != read_32bitBE(0x58,streamFile)) + goto fail; + if (read_32bitBE(0x8,streamFile) != read_32bitBE(0x5C,streamFile)) + goto fail; + if (read_32bitBE(0xC,streamFile) != read_32bitBE(0x60,streamFile)) + goto fail; + + loop_flag = 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 = 0xAC; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x14,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = read_32bitBE(0x8,streamFile); + +#if 0 + if (loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = 0; + } +#endif + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x10; + vgmstream->meta_type = meta_NGC_NST_DSP; + + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x20+i*2,streamFile); + } + if (vgmstream->channels) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x20+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 310aa3bf..144c3ef2 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -273,17 +273,18 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_dsp_xiii, init_vgmstream_dsp_cabelas, init_vgmstream_ps2_adm, - init_vgmstream_ps2_lpcm, + init_vgmstream_ps2_lpcm, init_vgmstream_dsp_bdsp, - init_vgmstream_ps2_vms, - init_vgmstream_ps2_xau, + init_vgmstream_ps2_vms, + init_vgmstream_ps2_xau, init_vgmstream_gh3_bar, init_vgmstream_ffw, init_vgmstream_dsp_dspw, init_vgmstream_ps2_jstm, init_vgmstream_ps3_xvag, - init_vgmstream_ps3_cps, + init_vgmstream_ps3_cps, init_vgmstream_se_scd, + init_vgmstream_ngc_nst_dsp, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2668,6 +2669,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_SE_SCD: snprintf(temp,TEMPSIZE,"Square-Enix SCD"); + break; + case meta_NGC_NST_DSP: + snprintf(temp,TEMPSIZE,"Animaniacs NST header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 7d2b8208..ef9a1263 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -461,7 +461,7 @@ typedef enum { meta_PS2_KHV, /* Kingdom Hearts 2 VAG streams */ meta_PC_SMP, /* Ghostbusters PC .smp */ meta_P3D, /* Prototype P3D */ - meta_PS2_TK1, /* Tekken (NamCollection) */ + meta_PS2_TK1, /* Tekken (NamCollection) */ meta_PS2_ADSC, /* Kenka Bancho 2: Full Throttle */ meta_NGC_BO2, /* Blood Omen 2 (NGC) */ meta_DSP_DDSP, /* Various (2 dsp files stuck together */ @@ -476,15 +476,16 @@ typedef enum { meta_PS2_ADM, /* Dragon Quest 5 */ meta_PS2_LPCM, /* Ah! My Goddess */ meta_DSP_BDSP, /* Ah! My Goddess */ - meta_PS2_VMS, /* Autobahn Raser - Police Madness */ - meta_PS2_XAU, // Spectral Force Chronicle + meta_PS2_VMS, /* Autobahn Raser - Police Madness */ + meta_PS2_XAU, // Spectral Force Chronicle meta_GH3_BAR, /* Guitar Hero III Mobile .bar */ - meta_FFW, /* Freedom Fighters [NGC] */ - meta_DSP_DSPW, /* Sengoku Basara 3 [WII] */ + meta_FFW, /* Freedom Fighters [NGC] */ + meta_DSP_DSPW, /* Sengoku Basara 3 [WII] */ meta_PS2_JSTM, /* Tantei Jinguji Saburo - Kind of Blue (PS2) */ - meta_PS3_XVAG, /* Ratchet & Clank Future: Quest for Booty (PS3) */ - meta_PS3_CPS, /* Eternal Sonata (PS3) */ + meta_PS3_XVAG, /* Ratchet & Clank Future: Quest for Booty (PS3) */ + meta_PS3_CPS, /* Eternal Sonata (PS3) */ meta_SE_SCD, /* Square-Enix SCD */ + meta_NGC_NST_DSP, /* Animaniacs [NGC] */ } meta_t; typedef struct {