From 7aefd4f6edf313f8b4db26d5e0be250eb8065649 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Tue, 18 Nov 2008 16:32:04 +0000 Subject: [PATCH] strm updated (Final Fantasy Tactis A2) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@479 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/meta/meta.h | 2 ++ src/meta/nds_strm.c | 66 +++++++++++++++++++++++++++++++++++++++++++++ src/vgmstream.c | 4 +++ src/vgmstream.h | 1 + 4 files changed, 73 insertions(+) diff --git a/src/meta/meta.h b/src/meta/meta.h index e0919632..734e01a6 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -277,4 +277,6 @@ VGMSTREAM * init_vgmstream_waa_wac_wad_wam(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_ps2_seg(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_nds_strm_ffta2(STREAMFILE * streamFile); + #endif diff --git a/src/meta/nds_strm.c b/src/meta/nds_strm.c index 15a68eb2..cfc60ea3 100644 --- a/src/meta/nds_strm.c +++ b/src/meta/nds_strm.c @@ -99,3 +99,69 @@ fail: if (vgmstream) close_vgmstream(vgmstream); return NULL; } + + +/* STRM (from Final Fantasy Tactics A2 - Fuuketsu no Grimoire) */ +VGMSTREAM * init_vgmstream_nds_strm_ffta2(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("strm",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x52494646 || /* RIFF */ + read_32bitBE(0x08,streamFile) != 0x494D4120) /* "IMA " */ + goto fail; + + loop_flag = (read_32bitLE(0x20,streamFile) !=0); + channel_count = read_32bitLE(0x24,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x2C; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x0C,streamFile); + vgmstream->coding_type = coding_INT_IMA; + vgmstream->num_samples = (read_32bitLE(0x04,streamFile)-start_offset); + if (loop_flag) { + vgmstream->loop_start_sample = read_32bitLE(0x20,streamFile); + vgmstream->loop_end_sample = read_32bitLE(0x28,streamFile); + } + + vgmstream->interleave_block_size = 0x80; + vgmstream->interleave_smallblock_size = (vgmstream->loop_end_sample)%((vgmstream->loop_end_sample)/vgmstream->interleave_block_size); + vgmstream->layout_type = layout_interleave_shortblock; + vgmstream->meta_type = meta_NDS_STRM_FFTA2; + + /* 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 68930dd9..c69e070a 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -155,6 +155,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_ass, init_vgmstream_waa_wac_wad_wam, init_vgmstream_ps2_seg, + init_vgmstream_nds_strm_ffta2, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -1807,6 +1808,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_PS2_SEG: snprintf(temp,TEMPSIZE,"SEG (PS2) Header"); + break; + case meta_NDS_STRM_FFTA2: + snprintf(temp,TEMPSIZE,"Final Fantasy Tactics A2 RIFF Header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 44f40796..aa78811e 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -264,6 +264,7 @@ typedef enum { meta_PS2_ASS, /* ASS */ meta_PS2_SEG, /* Eragon */ + meta_NDS_STRM_FFTA2, /* FFTA2 */ meta_XBOX_WAVM, /* XBOX WAVM File */ meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */