From 87e1f9c087dddeb514c66c314fb39f0450455a4d Mon Sep 17 00:00:00 2001 From: manakoAT Date: Fri, 28 Nov 2008 16:25:52 +0000 Subject: [PATCH] GSB+GSP added (incomplete) git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@493 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/layout/blocked.c | 1 + src/libvgmstream.vcproj | 4 ++ src/meta/gsp_gsb.c | 112 ++++++++++++++++++++++++++++++++++++++++ src/meta/meta.h | 2 + src/meta/naomi_spsd.c | 3 +- src/vgmstream.c | 1 + src/vgmstream.h | 2 + winamp/in_vgmstream.c | 1 + 8 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 src/meta/gsp_gsb.c diff --git a/src/layout/blocked.c b/src/layout/blocked.c index 56fdade9..b8912ff6 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -87,6 +87,7 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * break; case layout_xvas_blocked: xvas_block_update(vgmstream->next_block_offset,vgmstream); + break; default: break; } diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index c9b8cbf2..30894331 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -283,6 +283,10 @@ RelativePath=".\meta\genh.c" > + + diff --git a/src/meta/gsp_gsb.c b/src/meta/gsp_gsb.c new file mode 100644 index 00000000..caf0ae87 --- /dev/null +++ b/src/meta/gsp_gsb.c @@ -0,0 +1,112 @@ +#include "meta.h" +#include "../util.h" + +/* GSP+GSB + + 2008-11-28 - manakoAT +*/ + +VGMSTREAM * init_vgmstream_gsp_gsb(STREAMFILE *streamFile) { + + VGMSTREAM * vgmstream = NULL; + STREAMFILE * streamFileGSP = NULL; + char filename[260]; + char filenameGSP[260]; + + int i; + int channel_count; + int loop_flag; + int header_len; + int coef1_start; + int coef2_start; + int dsp_blocks; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("gsb",filename_extension(filename))) goto fail; + + + strcpy(filenameGSP,filename); + strcpy(filenameGSP+strlen(filenameGSP)-3,"GSP"); + + streamFileGSP = streamFile->open(streamFile,filenameGSP,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!streamFileGSP) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFileGSP) != 0x47534E44) /* "GSND" */ + goto fail; + + channel_count = (uint16_t)read_16bitBE(0x3A,streamFileGSP); + loop_flag = 0; /* read_32bitBE(0x20,streamFileGSP); */ + header_len = read_32bitBE(0x1C,streamFileGSP); + + coef1_start = read_32bitBE(header_len-0x4C,streamFileGSP); + coef2_start = read_32bitBE(header_len-0x1C,streamFileGSP); + dsp_blocks = read_32bitBE(header_len-0x5C,streamFileGSP); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x34,streamFileGSP); + vgmstream->num_samples=read_32bitBE(0x2C,streamFileGSP)*14/8/channel_count; + vgmstream->coding_type = coding_NGC_DSP; + + if(loop_flag) { + vgmstream->loop_start_sample = 0; /* read_32bitBE(0x20,streamFileGSP)*14/8/channel_count; */ + vgmstream->loop_end_sample = read_32bitBE(0x48,streamFileGSP)*14/8/channel_count; + } + + if (channel_count == 1) { + vgmstream->layout_type = layout_none; + } else if (channel_count == 2) { + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitBE(header_len-0x64,streamFileGSP); + } + + + + vgmstream->meta_type = meta_GSP_GSB; + + /* open the file for reading */ + vgmstream->ch[0].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + + if (!vgmstream->ch[0].streamfile) goto fail; + + vgmstream->ch[0].channel_start_offset=0; + + if (channel_count == 2) { + vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + + if (!vgmstream->ch[1].streamfile) goto fail; + + vgmstream->ch[1].channel_start_offset=vgmstream->interleave_block_size; + } + + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(coef1_start+i*2,streamFileGSP); + } + if (vgmstream->channels == 2) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(coef2_start+i*2,streamFileGSP); + } + } + } + + + close_streamfile(streamFileGSP); streamFileGSP=NULL; + + return vgmstream; + + + /* clean up anything we may have opened */ +fail: + if (streamFileGSP) close_streamfile(streamFileGSP); + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/meta.h b/src/meta/meta.h index d4d64485..c4118ab7 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -293,4 +293,6 @@ VGMSTREAM * init_vgmstream_ish_isd(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_ydsp(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_gsp_gsb(STREAMFILE * streamFile); + #endif diff --git a/src/meta/naomi_spsd.c b/src/meta/naomi_spsd.c index 7b969548..480db391 100644 --- a/src/meta/naomi_spsd.c +++ b/src/meta/naomi_spsd.c @@ -60,7 +60,8 @@ VGMSTREAM * init_vgmstream_naomi_spsd(STREAMFILE *streamFile) { vgmstream->ch[i].channel_start_offset= vgmstream->ch[i].offset=start_offset+ vgmstream->interleave_block_size*i; - + + vgmstream->ch[i].adpcm_step_index = 0x7f; /* AICA */ } } diff --git a/src/vgmstream.c b/src/vgmstream.c index 28f54620..8481d61c 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -162,6 +162,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_gca, init_vgmstream_spt_spd, init_vgmstream_ish_isd, + init_vgmstream_gsp_gsb, init_vgmstream_ydsp, }; diff --git a/src/vgmstream.h b/src/vgmstream.h index 1883c64d..89f2d56a 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -119,6 +119,7 @@ typedef enum { layout_matx_blocked, layout_de2_blocked, layout_xvas_blocked, + #if 0 layout_strm_blocked, /* */ #endif @@ -245,6 +246,7 @@ typedef enum { meta_IDSP, /* Chronicles of Narnia */ meta_SPT_SPD, /* Variouis */ meta_ISH_ISD, /* Various */ + meta_GSP_GSB, /* Various */ meta_YDSP, /* WWE Day of Reckoning */ meta_IDSP2, /* Chronicles of Narnia */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index acb6439b..f6adb258 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -206,6 +206,7 @@ char * extension_list[] = { "spd\0SPD Audio File (*.SPD)\0", "isd\0ISD Audio File (*.ISD)\0", "ydsp\0YDSP Audio File (*.YDSP)\0", + "gsb\0GSB Audio File (*.GSB)\0", }; void about(HWND hwndParent) {