From cc8256d17864c7f19a8638719d549691cdb9725c Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 9 Dec 2017 19:01:36 +0100 Subject: [PATCH] Fix some VAWX multichannel files --- src/formats.c | 1 + src/layout/blocked.c | 3 +++ src/layout/blocked_vawx.c | 25 +++++++++++++++++++++++++ src/layout/layout.h | 1 + src/meta/vawx.c | 7 +++++-- src/vgmstream.c | 1 + src/vgmstream.h | 1 + 7 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/layout/blocked_vawx.c diff --git a/src/formats.c b/src/formats.c index 7f68e6de..14ff77b1 100644 --- a/src/formats.c +++ b/src/formats.c @@ -564,6 +564,7 @@ static const layout_info layout_info_list[] = { {layout_blocked_ea_sns, "blocked (EA SNS)"}, {layout_blocked_awc, "blocked (AWC)"}, {layout_blocked_vgs, "blocked (VGS)"}, + {layout_blocked_vawx, "blocked (VAWX)"}, #ifdef VGM_USE_VORBIS {layout_ogg_vorbis, "Ogg"}, #endif diff --git a/src/layout/blocked.c b/src/layout/blocked.c index e9e0793d..645ec694 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -161,6 +161,9 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * case layout_blocked_vgs: block_update_vgs(vgmstream->next_block_offset,vgmstream); break; + case layout_blocked_vawx: + block_update_vawx(vgmstream->next_block_offset,vgmstream); + break; default: break; } diff --git a/src/layout/blocked_vawx.c b/src/layout/blocked_vawx.c new file mode 100644 index 00000000..dd28dc7e --- /dev/null +++ b/src/layout/blocked_vawx.c @@ -0,0 +1,25 @@ +#include "layout.h" +#include "../vgmstream.h" + +/* pseudo-blocks that must skip last 0x20 every 0x8000 */ +void block_update_vawx(off_t block_offset, VGMSTREAM * vgmstream) { + int i; + size_t block_size; + + /* no header */ + block_size = vgmstream->channels * 0x10; + + vgmstream->current_block_offset = block_offset; + vgmstream->next_block_offset = block_offset + block_size; + vgmstream->current_block_size = block_size / vgmstream->channels; + + if ((vgmstream->next_block_offset - 0x800) > 0 + && ((vgmstream->next_block_offset - 0x800 + 0x20) % 0x8000) == 0) { + vgmstream->next_block_offset += 0x20; + } + + + for (i=0;ichannels;i++) { + vgmstream->ch[i].offset = block_offset + 0x10*i; + } +} diff --git a/src/layout/layout.h b/src/layout/layout.h index 9cdf13f5..9e946ed2 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -65,6 +65,7 @@ void hwas_block_update(off_t block_offset, VGMSTREAM * vgmstream); void block_update_ea_sns(off_t block_offset, VGMSTREAM * vgmstream); void block_update_awc(off_t block_offset, VGMSTREAM * vgmstream); void block_update_vgs(off_t block_offset, VGMSTREAM * vgmstream); +void block_update_vawx(off_t block_offset, VGMSTREAM * vgmstream); /* other layouts */ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream); diff --git a/src/meta/vawx.c b/src/meta/vawx.c index befdaef2..a7d3347b 100644 --- a/src/meta/vawx.c +++ b/src/meta/vawx.c @@ -1,4 +1,5 @@ #include "meta.h" +#include "../layout/layout.h" #include "../coding/coding.h" @@ -37,12 +38,11 @@ VGMSTREAM * init_vgmstream_vawx(STREAMFILE *streamFile) { switch(type) { case 2: /* VAG */ vgmstream->coding_type = coding_PSX; - vgmstream->layout_type = layout_interleave; + vgmstream->layout_type = channel_count == 6 ? layout_blocked_vawx : layout_interleave ; vgmstream->interleave_block_size = 0x10; vgmstream->loop_start_sample = read_32bitBE(0x44,streamFile); vgmstream->loop_end_sample = read_32bitBE(0x48,streamFile); - /* todo 6ch has 0x8000 blocks and must skip last 0x20 each block (or, skip 0x20 every 0x1550*6 */ break; @@ -110,6 +110,9 @@ VGMSTREAM * init_vgmstream_vawx(STREAMFILE *streamFile) { if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) goto fail; + if (vgmstream->layout_type == layout_blocked_vawx) + block_update_vawx(start_offset,vgmstream); + return vgmstream; fail: diff --git a/src/vgmstream.c b/src/vgmstream.c index c38a54f9..4fa9e678 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -959,6 +959,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre case layout_blocked_ea_sns: case layout_blocked_awc: case layout_blocked_vgs: + case layout_blocked_vawx: render_vgmstream_blocked(buffer,sample_count,vgmstream); break; case layout_acm: diff --git a/src/vgmstream.h b/src/vgmstream.h index d393ac10..7a722d3a 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -242,6 +242,7 @@ typedef enum { layout_blocked_ea_sns, /* newest Electronic Arts blocks, found in SNS/SNU/SPS/etc formats */ layout_blocked_awc, /* Rockstar AWC */ layout_blocked_vgs, /* Guitar Hero II (PS2) */ + layout_blocked_vawx, /* No More Heroes 6ch (PS3) */ /* otherwise odd */ layout_acm, /* libacm layout */