diff --git a/src/formats.c b/src/formats.c index eafd3ffd..5d103499 100644 --- a/src/formats.c +++ b/src/formats.c @@ -354,6 +354,7 @@ static const char* extension_list[] = { "waa", "wac", "wad", + "waf", "wam", "was", //"wav", //common @@ -963,6 +964,7 @@ static const meta_info meta_info_list[] = { {meta_SQEX_SAB, "Square-Enix SAB header"}, {meta_SQEX_MAB, "Square-Enix MAB header"}, {meta_OGG_L2SD, "Ogg Vorbis (L2SD)"}, + {meta_WAF, "KID WAF header"}, #ifdef VGM_USE_MP4V2 {meta_MP4, "AAC header"}, diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index a79658dd..74fe5834 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -1278,6 +1278,10 @@ RelativePath=".\meta\waa_wac_wad_wam.c" > + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index af5d6330..d85a8f76 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -397,6 +397,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index 806c4005..902d34b9 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -781,6 +781,9 @@ meta\Source Files + + meta\Source Files + meta\Source Files diff --git a/src/meta/waf.c b/src/meta/waf.c new file mode 100644 index 00000000..c8efd92b --- /dev/null +++ b/src/meta/waf.c @@ -0,0 +1,43 @@ +#include "meta.h" +#include "../coding/coding.h" + +/* WAF - KID's earlier PC games [ever17 (PC)] (for RLE-compressed WAFs see https://github.com/dsp2003/e17p) */ +VGMSTREAM * init_vgmstream_waf(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + off_t start_offset; + int loop_flag, channel_count; + + + /* check extension */ + if (!check_extensions(streamFile, "waf")) + goto fail; + + if (read_32bitBE(0x00,streamFile) != 0x57414600) /* "WAF\0" "*/ + goto fail; + if (read_32bitLE(0x34,streamFile) + 0x38 != get_streamfile_size(streamFile)) + goto fail; + + channel_count = read_16bitLE(0x06,streamFile); + loop_flag = 0; + start_offset = 0x38; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count, loop_flag); + if (!vgmstream) goto fail; + + vgmstream->sample_rate = read_32bitLE(0x08, streamFile); + vgmstream->meta_type = meta_WAF; + vgmstream->coding_type = coding_MSADPCM; + vgmstream->layout_type = layout_none; + vgmstream->interleave_block_size = read_16bitLE(0x10, streamFile); + vgmstream->num_samples = msadpcm_bytes_to_samples(read_32bitLE(0x34,streamFile), vgmstream->interleave_block_size, channel_count); + /* 0x04: null?, 0x0c: avg br, 0x12: bps, 0x14: s_p_f, 0x16~34: count + standard MSADPCM coefs (a modified RIFF fmt) */ + + if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) + goto fail; + return vgmstream; + +fail: + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index 72046001..2fd82d33 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -379,6 +379,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_sps_n1, init_vgmstream_atx, init_vgmstream_sqex_sead, + init_vgmstream_waf, init_vgmstream_txth, /* should go at the end (lower priority) */ #ifdef VGM_USE_FFMPEG diff --git a/src/vgmstream.h b/src/vgmstream.h index 5121be79..39c60dde 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -661,6 +661,7 @@ typedef enum { meta_SQEX_SAB, /* Square-Enix newest middleware (sound) */ meta_SQEX_MAB, /* Square-Enix newest middleware (music) */ meta_OGG_L2SD, /* Ogg Vorbis with obfuscation [Lineage II Chronicle 4 (PC)] */ + meta_WAF, /* KID WAF [Ever 17 (PC)] */ #ifdef VGM_USE_MP4V2 meta_MP4, /* AAC (iOS) */