diff --git a/src/Makefile b/src/Makefile index c38208b0..125743b2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -156,7 +156,10 @@ META_OBJS=meta/adx_header.o \ meta/gsp_gsb.o \ meta/ngc_ssm.o \ meta/msvp.o \ - meta/ps2_joe.o + meta/ps2_joe.o \ + meta/vgs.o \ + meta/vs.o \ + meta/dc_wav_dcs.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/layout/Makefile.unix.am b/src/layout/Makefile.unix.am index 409c8efc..98704fee 100644 --- a/src/layout/Makefile.unix.am +++ b/src/layout/Makefile.unix.am @@ -22,5 +22,6 @@ liblayout_la_SOURCES += aix_layout.c liblayout_la_SOURCES += ims_block.c liblayout_la_SOURCES += de2_blocked.c liblayout_la_SOURCES += xvas_block.c +liblayout_la_SOURCES += vs_blocked.c EXTRA_DIST = layout.h diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 44e9fc31..04568dd5 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -255,6 +255,10 @@ RelativePath=".\meta\dc_str.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index c84df266..63100bc6 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -125,4 +125,8 @@ libmeta_la_SOURCES += gsp_gsb.c libmeta_la_SOURCES += ngc_ssm.c libmeta_la_SOURCES += msvp.c libmeta_la_SOURCES += ps2_joe.c +libmeta_la_SOURCES += vs.c +libmeta_la_SOURCES += vgs.c +libmeta_la_SOURCES += dc_wav_dcs.c + EXTRA_DIST = meta.h diff --git a/src/meta/dc_wav_dcs.c b/src/meta/dc_wav_dcs.c new file mode 100644 index 00000000..197ea8a0 --- /dev/null +++ b/src/meta/dc_wav_dcs.c @@ -0,0 +1,132 @@ +#include "meta.h" +#include "../util.h" + +/* WAV+DCS + + 2008-12-06 - manakoAT : Evil Twin - Cypriens Chronicles... + 2008-12-07 - manakoAT : Added a function to read the Header file and for + retrieving the channels/frequency, Frequency starts + always at a "data" chunk - 0x0C bytes, Channels + always - 0x0E bytes... +*/ + +VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE *streamFile) { + + VGMSTREAM * vgmstream = NULL; + STREAMFILE * streamFileWAV = NULL; + char filename[260]; + char filenameWAV[260]; + int i; + int channel_count; + int loop_flag; + int frequency; + int channels; + int dataBuffer = 0; + int Founddata = 0; + size_t file_size; + off_t current_chunk; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("dcs",filename_extension(filename))) goto fail; + + /* Getting the Header file name... */ + strcpy(filenameWAV,filename); + strcpy(filenameWAV+strlen(filenameWAV)-3,"WAV"); + + /* Look if the Header file is present, else cancel vgmstream */ + streamFileWAV = streamFile->open(streamFile,filenameWAV,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!streamFileWAV) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFileWAV) != 0x52494646 || /* "RIFF" */ + read_32bitBE(0x08,streamFileWAV) != 0x57415645 || /* "WAVE" */ + read_32bitBE(0x0C,streamFileWAV) != 0x34582E76 || /* 0x34582E76 */ + read_32bitBE(0x3C,streamFileWAV) != 0x406E616D) /* "@nam" */ + goto fail; + + + /* scan file until we find a "data" string */ + file_size = get_streamfile_size(streamFileWAV); + + { + + current_chunk = 0; + + /* Start at 0 and loop until we reached the + file size, or until we found a "data string */ + while (!Founddata && current_chunk < file_size) { + dataBuffer = (read_32bitBE(current_chunk,streamFileWAV)); + if (dataBuffer == 0x64617461) { /* "data" */ + /* if "data" string found, retrieve the needed infos */ + Founddata = 1; + /* We will cancel the search here if we have a match */ + break; + } + /* else we will increase the search offset by 1 */ + current_chunk = current_chunk + 1; + } + } + + + if (Founddata == 0) { + goto fail; + } else if (Founddata == 1) { + channel_count = (uint16_t)read_16bitLE(current_chunk-0x0E,streamFileWAV); + frequency = read_32bitLE(current_chunk-0x0C,streamFileWAV); + } + + loop_flag = 0; + + + /* 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 = frequency; + vgmstream->num_samples=(get_streamfile_size(streamFile))*2/channel_count; + + if(loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = (get_streamfile_size(streamFile))*2/channel_count; + } + + switch (channel_count) { + case 1: + vgmstream->layout_type = layout_none; + break; + case 2: + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x4000; + break; + default: + goto fail; + } + + vgmstream->coding_type = coding_AICA; + vgmstream->meta_type = meta_DC_WAV_DCS; + + /* open the file for reading */ + { + for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,0x8000); + vgmstream->ch[i].offset = 0; + vgmstream->ch[i].adpcm_step_index = 0x7f; /* AICA */ + if (!vgmstream->ch[i].streamfile) goto fail; + } + } + + + + close_streamfile(streamFileWAV); streamFileWAV=NULL; + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (streamFileWAV) close_streamfile(streamFileWAV); + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/meta.h b/src/meta/meta.h index e6f97cb3..8c516504 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -309,4 +309,6 @@ VGMSTREAM * init_vgmstream_ps2_joe(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_vgs(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_dc_wav_dcs(STREAMFILE * streamFile); + #endif diff --git a/src/vgmstream.c b/src/vgmstream.c index 14c32a67..cd9dba96 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -171,6 +171,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ngc_ssm, init_vgmstream_ps2_joe, init_vgmstream_vgs, + init_vgmstream_dc_wav_dcs, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -1884,6 +1885,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_VGS: snprintf(temp,TEMPSIZE,"Guitar Hero Encore Rocks the 80's Header"); + break; + case meta_DC_WAV_DCS: + snprintf(temp,TEMPSIZE,"Evil Twin WAV+DCS Header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index e2b2698a..fe591260 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -283,6 +283,7 @@ typedef enum { meta_STR_ASR, /* Donkey Kong Jet Race */ meta_ZWDSP, /* Zack and Wiki */ meta_VGS, /* Guitar Hero Encore - Rocks the 80s */ + meta_DC_WAV_DCS, /* Evil Twin - Cypriens Chronicles (DC) */ meta_XBOX_WAVM, /* XBOX WAVM File */ meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index c4018f19..a050d2f8 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -212,6 +212,7 @@ char * extension_list[] = { "joe\0JOE Audio File (*.JOE)\0", "vgs\0VGS Audio File (*.VGS)\0", "vs\0VS Audio File (*.VS)\0", + "dcs\0DCS Audio File (*.DCS)\0", }; void about(HWND hwndParent) {