From 8257e32f71c2ec4bc67203d3f68df06fd53a5046 Mon Sep 17 00:00:00 2001 From: fastelbja Date: Tue, 13 May 2008 11:47:51 +0000 Subject: [PATCH] ps2 EXST support added git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@112 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/libvgmstream.vcproj | 4 ++ src/meta/ps2_exst.c | 85 +++++++++++++++++++++++++++++++++ src/meta/ps2_int.c | 102 ++++++++++++++++++++-------------------- src/vgmstream.c | 3 ++ src/vgmstream.h | 2 +- winamp/in_vgmstream.c | 3 +- 6 files changed, 146 insertions(+), 53 deletions(-) create mode 100644 src/meta/ps2_exst.c diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index ca6d5ca2..6ae6b710 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -246,6 +246,10 @@ RelativePath=".\meta\ps2_ads.c" > + + diff --git a/src/meta/ps2_exst.c b/src/meta/ps2_exst.c new file mode 100644 index 00000000..ecf26e9b --- /dev/null +++ b/src/meta/ps2_exst.c @@ -0,0 +1,85 @@ +#include "meta.h" +#include "../util.h" + +/* EXST + + PS2 INT format is an interleaved format found in Shadow of the Colossus + The header start with a EXST id. + The headers and bgm datas was separated in the game, and joined in order + to add support for vgmstream + + The interleave value is allways 0x400 + known extensions : .STS + + 2008-05-13 - Fastelbja : First version ... +*/ + +VGMSTREAM * init_vgmstream_ps2_ads(const char * const filename) { + VGMSTREAM * vgmstream = NULL; + STREAMFILE * infile = NULL; + + int loop_flag=0; + int channel_count; + int i; + + /* check extension, case insensitive */ + if (strcasecmp("sts",filename_extension(filename))) goto fail; + + /* try to open the file for header reading */ + infile = open_streamfile(filename); + if (!infile) goto fail; + + /* check EXST Header */ + if (read_32bitBE(0x00,infile) != 0x45585354) + goto fail; + + /* check loop */ + loop_flag = (read_32bitLE(0x0C,infile)==1); + + channel_count=read_16bitLE(0x06,infile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + vgmstream->channels = read_16bitLE(0x06,infile); + vgmstream->sample_rate = read_32bitLE(0x08,infile); + + /* Compression Scheme */ + vgmstream->coding_type = coding_PSX; + vgmstream->num_samples = (read_32bitLE(0x14,infile)*0x400)/16*28; + + /* Get loop point values */ + if(vgmstream->loop_flag) { + vgmstream->loop_start_sample = (read_32bitLE(0x10,infile)*0x400)/16*28; + vgmstream->loop_end_sample = (read_32bitLE(0x14,infile)*0x400)/16*28; + } + + vgmstream->interleave_block_size = 0x400; + vgmstream->layout_type = layout_interleave; + vgmstream->meta_type = meta_PS2_EXST; + + close_streamfile(infile); infile=NULL; + + /* open the file for reading by each channel */ + { + for (i=0;ich[i].streamfile = open_streamfile_buffer(filename,0x8000); + + if (!vgmstream->ch[i].streamfile) goto fail; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset= + 0x800+vgmstream->interleave_block_size*i; + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (infile) close_streamfile(infile); + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/ps2_int.c b/src/meta/ps2_int.c index 287ae9ad..bfc2406b 100644 --- a/src/meta/ps2_int.c +++ b/src/meta/ps2_int.c @@ -1,5 +1,5 @@ -#include "meta.h" -#include "../util.h" +#include "meta.h" +#include "../util.h" /* INT @@ -12,52 +12,52 @@ 2008-05-11 - Fastelbja : First version ... */ -VGMSTREAM * init_vgmstream_ps2_int(const char * const filename) { - VGMSTREAM * vgmstream = NULL; - STREAMFILE * infile = NULL; - int i; - - /* check extension, case insensitive */ - if (strcasecmp("int",filename_extension(filename))) goto fail; - - /* try to open the file for header reading */ - infile = open_streamfile(filename); - if (!infile) goto fail; - - /* No check to do as they are raw pcm */ - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(2,0); - if (!vgmstream) goto fail; - - /* fill in the vital statistics */ - vgmstream->channels = 2; - vgmstream->sample_rate = 48000; - vgmstream->coding_type = coding_PCM16LE; - vgmstream->num_samples = get_streamfile_size(infile)/4; - vgmstream->interleave_block_size = 0x200; - vgmstream->layout_type = layout_interleave; - vgmstream->meta_type = meta_PS2_RAW; - - close_streamfile(infile); infile=NULL; - - /* open the file for reading by each channel */ - { - for (i=0;i<2;i++) { - vgmstream->ch[i].streamfile = open_streamfile_buffer(filename,0x8000); - - if (!vgmstream->ch[i].streamfile) goto fail; - - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=0; - } - } - - return vgmstream; - - /* clean up anything we may have opened */ -fail: - if (infile) close_streamfile(infile); - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} +VGMSTREAM * init_vgmstream_ps2_int(const char * const filename) { + VGMSTREAM * vgmstream = NULL; + STREAMFILE * infile = NULL; + int i; + + /* check extension, case insensitive */ + if (strcasecmp("int",filename_extension(filename))) goto fail; + + /* try to open the file for header reading */ + infile = open_streamfile(filename); + if (!infile) goto fail; + + /* No check to do as they are raw pcm */ + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(2,0); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + vgmstream->channels = 2; + vgmstream->sample_rate = 48000; + vgmstream->coding_type = coding_PCM16LE; + vgmstream->num_samples = get_streamfile_size(infile)/4; + vgmstream->interleave_block_size = 0x200; + vgmstream->layout_type = layout_interleave; + vgmstream->meta_type = meta_PS2_RAW; + + close_streamfile(infile); infile=NULL; + + /* open the file for reading by each channel */ + { + for (i=0;i<2;i++) { + vgmstream->ch[i].streamfile = open_streamfile_buffer(filename,0x8000); + + if (!vgmstream->ch[i].streamfile) goto fail; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=0; + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (infile) close_streamfile(infile); + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index dd5ad043..550c6a7e 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -598,6 +598,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_DSP_STM: snprintf(temp,TEMPSIZE,"Nintendo STM header"); break; + case meta_PS2_EXST: + snprintf(temp,TEMPSIZE,"EXST File (Shadow of the Colossus)"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index 7658122c..80d1024d 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -78,7 +78,7 @@ typedef enum { meta_PS2_NPSF, /* Namco Production Sound File */ meta_PS2_RXW, /* Sony Arc The Lad Sound File */ meta_PS2_RAW, /* RAW Interleaved Format */ - + meta_PS2_EXST, /* Shadow of Colossus EXST */ meta_PSX_XA, /* CD-XA with RIFF header */ } meta_t; diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 283ec7cc..0952c3cc 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -45,7 +45,7 @@ int fade_samples = 0; #define EXTENSION_LIST_SIZE 1024 char working_extension_list[EXTENSION_LIST_SIZE] = {0}; -#define EXTENSION_COUNT 18 +#define EXTENSION_COUNT 19 char * extension_list[EXTENSION_COUNT] = { "adx\0ADX Audio File (*.ADX)\0", "afc\0AFC Audio File (*.AFC)\0", @@ -65,6 +65,7 @@ char * extension_list[EXTENSION_COUNT] = { "xa\0PSX CD-XA File (*.XA)\0", "rxw\0PS2 RXWS File (*.RXW)\0", "int\0PS2 RAW Interleaved PCM (*.INT)\0", + "sts\0PS2 EXST Audio File (*.STS)\0", }; /* stubs, we don't do anything fancy yet */