diff --git a/src/Makefile b/src/Makefile index f95c5230..f7c4ec28 100644 --- a/src/Makefile +++ b/src/Makefile @@ -112,7 +112,9 @@ META_OBJS=meta/adx_header.o \ meta/ps2_enth.o \ meta/sdt.o \ meta/aix.o \ - meta/ngc_tydsp.o + meta/ngc_tydsp.o \ + meta/ngc_vjdsp.o \ + meta/ngc_biodsp.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index b265b8a8..66434ece 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -286,6 +286,10 @@ RelativePath=".\meta\ngc_adpdtk.c" > + + @@ -298,6 +302,10 @@ RelativePath=".\meta\ngc_tydsp.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index b58dc179..d26740bc 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -87,5 +87,7 @@ libmeta_la_SOURCES += ps2_enth.c libmeta_la_SOURCES += sdt.c libmeta_la_SOURCES += aix.c libmeta_la_SOURCES += ngc_tydsp.c +libmeta_la_SOURCES += ngc_swd.c +libmeta_la_SOURCES += ngc_biodsp.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index e00d90e1..ad9ccbb4 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -187,4 +187,10 @@ VGMSTREAM * init_vgmstream_aix(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_ngc_tydsp(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_ngc_swd(STREAMFILE * streamFile); + +VGMSTREAM * init_vgmstream_ngc_vjdsp(STREAMFILE * streamFile); + +VGMSTREAM * init_vgmstream_ngc_biodsp(STREAMFILE * streamFile); + #endif diff --git a/src/meta/ngc_biodsp.c b/src/meta/ngc_biodsp.c new file mode 100644 index 00000000..a1e3b2af --- /dev/null +++ b/src/meta/ngc_biodsp.c @@ -0,0 +1,78 @@ +#include "meta.h" +#include "../util.h" + +/* BIODSP (found in Bio Hazard / Resident Evil) */ +VGMSTREAM * init_vgmstream_ngc_biodsp(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("biodsp",filename_extension(filename))) goto fail; + + /* check header */ + /* if (read_32bitBE(0x00,streamFile) != 0x53565300) /* "SVS\0" */ + /* goto fail; */ + + loop_flag = 0; /* read_32bitBE(0x14,streamFile); */ + channel_count = 2; /* read_32bitBE(0x10,streamFile); */ + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x1C0; + vgmstream->channels = channel_count; + vgmstream->sample_rate = 44100; /* read_32bitBE(0x0C,streamFile); */ + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = read_32bitBE(0x164,streamFile); + if (loop_flag) { + vgmstream->loop_start_sample = read_32bitBE(0x168,streamFile); + vgmstream->loop_end_sample = read_32bitBE(0x164,streamFile); + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x2000; + vgmstream->meta_type = meta_NGC_BIODSP; + + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<8;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x180 +i*2,streamFile); + } + if (vgmstream->channels) { + for (i=0;i<8;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x190 +i*2,streamFile); + } + } + } + + /* 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/meta/ngc_dsp_std.c b/src/meta/ngc_dsp_std.c index addfc7fa..e50b4cbe 100644 --- a/src/meta/ngc_dsp_std.c +++ b/src/meta/ngc_dsp_std.c @@ -995,3 +995,115 @@ fail: return NULL; } +#include "meta.h" +#include "../util.h" + + +/* SWD (found in Conflict - Desert Storm 1 & 2 */ +VGMSTREAM * init_vgmstream_ngc_swd(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + + off_t start_offset; + off_t interleave; + + struct dsp_header ch0_header, ch1_header; + int i; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("swd",filename_extension(filename))) goto fail; + + if (read_dsp_header(&ch0_header, 0x24, streamFile)) goto fail; + if (read_dsp_header(&ch1_header, 0x84, streamFile)) goto fail; + + /* check header magic */ + /*if (read_16bitBE(0x00,streamFile) != 0x5053 && /* PS */ + /* (read_8bit(0x02,streamFile) != 0x46)) /* F */ + /* goto fail; */ + + start_offset = 0xA8; + interleave = 0x8; + + /* check initial predictor/scale */ + if (ch0_header.initial_ps != (uint8_t)read_8bit(start_offset,streamFile)) + goto fail; + if (ch1_header.initial_ps != (uint8_t)read_8bit(start_offset+interleave,streamFile)) + goto fail; + + /* check type==0 and gain==0 */ + if (ch0_header.format || ch0_header.gain || + ch1_header.format || ch1_header.gain) + goto fail; + + /* check for agreement */ + if ( + ch0_header.sample_count != ch1_header.sample_count || + ch0_header.nibble_count != ch1_header.nibble_count || + ch0_header.sample_rate != ch1_header.sample_rate || + ch0_header.loop_flag != ch1_header.loop_flag || + ch0_header.loop_start_offset != ch1_header.loop_start_offset || + ch0_header.loop_end_offset != ch1_header.loop_end_offset + ) goto fail; + + if (ch0_header.loop_flag) { + off_t loop_off; + /* check loop predictor/scale */ + loop_off = ch0_header.loop_start_offset/16*8; + loop_off = (loop_off/interleave*interleave*2) + (loop_off%interleave); + if (ch0_header.loop_ps != (uint8_t)read_8bit(start_offset+loop_off,streamFile)) + goto fail; + if (ch1_header.loop_ps != (uint8_t)read_8bit(start_offset+loop_off+interleave,streamFile)) + goto fail; + } + + /* build the VGMSTREAM */ + + vgmstream = allocate_vgmstream(2,ch0_header.loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + vgmstream->num_samples = ch0_header.sample_count; + vgmstream->sample_rate = ch0_header.sample_rate; + + /* TODO: adjust for interleave? */ + vgmstream->loop_start_sample = dsp_nibbles_to_samples( + ch0_header.loop_start_offset); + vgmstream->loop_end_sample = dsp_nibbles_to_samples( + ch0_header.loop_end_offset)+1; + + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = interleave; + vgmstream->meta_type = meta_NGC_SWD; + + /* coeffs */ + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = ch0_header.coef[i]; + vgmstream->ch[1].adpcm_coef[i] = ch1_header.coef[i]; + } + + /* initial history */ + /* always 0 that I've ever seen, but for completeness... */ + vgmstream->ch[0].adpcm_history1_16 = ch0_header.initial_hist1; + vgmstream->ch[0].adpcm_history2_16 = ch0_header.initial_hist2; + vgmstream->ch[1].adpcm_history1_16 = ch1_header.initial_hist1; + vgmstream->ch[1].adpcm_history2_16 = ch1_header.initial_hist2; + + vgmstream->ch[0].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + vgmstream->ch[1].streamfile = vgmstream->ch[0].streamfile; + + if (!vgmstream->ch[0].streamfile) goto fail; + /* open the file for reading */ + for (i=0;i<2;i++) { + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+i*interleave; + } + + return vgmstream; + +fail: + /* clean up anything we may have opened */ + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} \ No newline at end of file diff --git a/src/meta/ngc_vjdsp.c b/src/meta/ngc_vjdsp.c new file mode 100644 index 00000000..ea62eb41 --- /dev/null +++ b/src/meta/ngc_vjdsp.c @@ -0,0 +1,78 @@ +#include "meta.h" +#include "../util.h" + +/* VJDSP (found in Viewtiful Joe) */ +VGMSTREAM * init_vgmstream_ngc_vjdsp(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("vjdsp",filename_extension(filename))) goto fail; + + /* check header */ + /* if (read_32bitBE(0x00,streamFile) != 0x53565300) /* "SVS\0" */ + /* goto fail; */ + + loop_flag = read_32bitBE(0x14,streamFile); + channel_count = read_32bitBE(0x10,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x80; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x0C,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = read_32bitBE(0x18,streamFile); + if (loop_flag) { + vgmstream->loop_start_sample = read_32bitBE(0x14,streamFile); + vgmstream->loop_end_sample = read_32bitBE(0x18,streamFile); + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x2000; + vgmstream->meta_type = meta_NGC_VJDSP; + + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x20+i*2,streamFile); + } + if (vgmstream->channels) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x40+i*2,streamFile); + } + } + } + + /* 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 a946061a..c2f8bf55 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -109,6 +109,9 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_sdt, init_vgmstream_aix, init_vgmstream_ngc_tydsp, + init_vgmstream_ngc_swd, + init_vgmstream_ngc_vjdsp, + init_vgmstream_ngc_biodsp, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) diff --git a/src/vgmstream.h b/src/vgmstream.h index 551c585a..3f43cec5 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -218,6 +218,9 @@ typedef enum { meta_PS2_ENTH, /* Enthusia */ meta_SDT, /* Baldur's Gate - Dark Alliance */ meta_NGC_TYDSP, /* Ty - The Tasmanian Tiger */ + meta_NGC_SWD, /* Conflict - Desert Storm 1 & 2 */ + meta_NGC_VJDSP, /* Viewtiful Joe */ + meta_NGC_BIODSP, /* Bio Hazard */ 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 b2d871c0..2548fbba 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -168,6 +168,9 @@ char * extension_list[] = { "sdt\0SDT Audio File (*.SDT)\0", "aix\0AIX Audio File (*.AIX)\0", "tydsp\0TYDSP Audio File (*.TYDSP)\0", + "swd\0SWD Audio File (*.SWD)\0", + "vjdsp\0VJDSP Audio File (*.VJDSP)\0", + "biodsp\0BIODSP Audio File (*.BIODSP)\0", }; void about(HWND hwndParent) {