From 96bc7f3bf6659e376359f4c8aa96aff9f8dfeaa5 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Wed, 10 Dec 2008 12:30:23 +0000 Subject: [PATCH] .emff added (Eidos games) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@509 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/layout/blocked.c | 4 +- src/layout/emff_blocked.c | 18 +++++++++ src/layout/layout.h | 2 +- src/libvgmstream.vcproj | 16 ++++---- src/meta/emff.c | 77 +++++++++++++++++++++++++++++++++++++++ src/meta/meta.h | 2 +- src/vgmstream.c | 11 ++++-- src/vgmstream.h | 4 +- winamp/in_vgmstream.c | 2 +- 9 files changed, 117 insertions(+), 19 deletions(-) create mode 100644 src/layout/emff_blocked.c create mode 100644 src/meta/emff.c diff --git a/src/layout/blocked.c b/src/layout/blocked.c index 4937b652..41a51612 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -85,8 +85,8 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * case layout_de2_blocked: de2_block_update(vgmstream->next_block_offset,vgmstream); break; - case layout_test_blocked: - test_block_update(vgmstream->next_block_offset,vgmstream); + case layout_emff_blocked: + emff_block_update(vgmstream->next_block_offset,vgmstream); break; case layout_vs_blocked: vs_block_update(vgmstream->next_block_offset,vgmstream); diff --git a/src/layout/emff_blocked.c b/src/layout/emff_blocked.c new file mode 100644 index 00000000..eb39b4e6 --- /dev/null +++ b/src/layout/emff_blocked.c @@ -0,0 +1,18 @@ +#include "layout.h" +#include "../vgmstream.h" + +/* set up for the block at the given offset */ +void emff_block_update(off_t block_offset, VGMSTREAM * vgmstream) { + int i; + + vgmstream->current_block_offset = block_offset; + vgmstream->current_block_size = read_32bitLE( + vgmstream->current_block_offset+0x10, + vgmstream->ch[0].streamfile); + vgmstream->next_block_offset = vgmstream->current_block_offset + vgmstream->current_block_size+0x20; + vgmstream->current_block_size/=vgmstream->channels; + + for (i=0;ichannels;i++) { + vgmstream->ch[i].offset = vgmstream->current_block_offset+0x20+(vgmstream->current_block_size*i); + } +} diff --git a/src/layout/layout.h b/src/layout/layout.h index 8bd811a0..8e946610 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -30,7 +30,7 @@ void de2_block_update(off_t block_offset, VGMSTREAM * vgmstream); void vs_block_update(off_t block_offset, VGMSTREAM * vgmstream); -void test_block_update(off_t block_offset, VGMSTREAM * vgmstream); +void emff_block_update(off_t block_offset, VGMSTREAM * vgmstream); void xvas_block_update(off_t block_offset, VGMSTREAM * vgmstream); diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index ca25e0f0..006a163a 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -196,10 +196,6 @@ - - @@ -276,6 +272,10 @@ RelativePath=".\meta\ea_old.c" > + + @@ -862,6 +862,10 @@ RelativePath=".\layout\ea_block.c" > + + @@ -890,10 +894,6 @@ RelativePath=".\layout\str_snds_blocked.c" > - - diff --git a/src/meta/emff.c b/src/meta/emff.c new file mode 100644 index 00000000..bc7bf34b --- /dev/null +++ b/src/meta/emff.c @@ -0,0 +1,77 @@ +#include "meta.h" +#include "../util.h" + +/* + +...EMFF - Eidos Music File Format... + +*/ + +VGMSTREAM * init_vgmstream_emff(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + int loop_flag = 0; + int channel_count; + int i; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("emff",filename_extension(filename))) goto fail; + + /* check header */ +#if 0 + if (read_32bitBE(0x00,streamFile) != 0x53565300) /* "SVS\0" */ + goto fail; +#endif + + loop_flag = (read_32bitLE(0x04,streamFile) != 0xFFFFFFFF); + channel_count = read_32bitLE(0x0C,streamFile); + + /* 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 = read_32bitLE(0x00,streamFile); + vgmstream->coding_type = coding_PSX; + /* vgmstream->num_samples = read_32bitLE(0x08,streamFile); */ + if (loop_flag) { + vgmstream->loop_start_sample = loop_flag; + vgmstream->loop_end_sample = read_32bitLE(0x08,streamFile); + } + + vgmstream->layout_type = layout_emff_blocked; + vgmstream->interleave_block_size = 0x10; + vgmstream->meta_type = meta_EMFF; + + /* open the file for reading */ + { + for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,0x2000); + if (!vgmstream->ch[i].streamfile) goto fail; + } + } + + + /* Calc num_samples */ + emff_block_update(start_offset,vgmstream); + vgmstream->num_samples=0; + + do { + vgmstream->num_samples += vgmstream->current_block_size*28/16/channel_count; + emff_block_update(vgmstream->next_block_offset,vgmstream); + } while (vgmstream->next_block_offset