diff --git a/src/base/render.c b/src/base/render.c index d8a1b07f..fa76dae0 100644 --- a/src/base/render.c +++ b/src/base/render.c @@ -302,6 +302,7 @@ int render_layout(sample_t* buf, int32_t sample_count, VGMSTREAM* vgmstream) { case layout_blocked_vid1: case layout_blocked_ubi_sce: case layout_blocked_tt_ad: + case layout_blocked_vas: render_vgmstream_blocked(buf, sample_count, vgmstream); break; case layout_segmented: diff --git a/src/formats.c b/src/formats.c index c2fa8e36..3061f97c 100644 --- a/src/formats.c +++ b/src/formats.c @@ -630,6 +630,7 @@ static const char* extension_list[] = { "wavebatch", "wavm", "wavx", //txth/reserved [LEGO Star Wars (Xbox)] + "wax", "way", "wb", "wb2", @@ -971,6 +972,7 @@ static const layout_info layout_info_list[] = { {layout_blocked_vid1, "blocked (VID1)"}, {layout_blocked_ubi_sce, "blocked (Ubi SCE)"}, {layout_blocked_tt_ad, "blocked (TT AD)"}, + {layout_blocked_vas, "blocked (VAS)"}, }; static const meta_info meta_info_list[] = { @@ -1429,6 +1431,7 @@ static const meta_info meta_info_list[] = { {meta_NXOF, "Nihon Falcom FDK header"}, {meta_GWB_GWD, "Ubisoft GWB+GWD header"}, {meta_CBX, "Traveller's Tales CBX header"}, + {meta_VAS, "Manhunt 2 .VAS header"}, }; void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) { diff --git a/src/layout/blocked.c b/src/layout/blocked.c index 637502ee..09870526 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -207,6 +207,9 @@ void block_update(off_t block_offset, VGMSTREAM* vgmstream) { case layout_blocked_tt_ad: block_update_tt_ad(block_offset,vgmstream); break; + case layout_blocked_vas: + block_update_vas(block_offset,vgmstream); + break; default: /* not a blocked layout */ break; } diff --git a/src/layout/blocked_vas.c b/src/layout/blocked_vas.c new file mode 100644 index 00000000..5e951509 --- /dev/null +++ b/src/layout/blocked_vas.c @@ -0,0 +1,17 @@ +#include "layout.h" +#include "../vgmstream.h" + +/* VAS - Manhunt 2 PSP VAGs/2AGs blocked audio layout */ +void block_update_vas(off_t block_offset, VGMSTREAM* vgmstream) { + size_t block_size; + int num_streams; + + /* no headers */ + block_size = 0x40; + num_streams = vgmstream->num_streams; + + vgmstream->current_block_offset = block_offset; + vgmstream->next_block_offset = block_offset + (block_size * num_streams); + vgmstream->current_block_size = block_size; + vgmstream->ch[0].offset = block_offset; +} diff --git a/src/layout/layout.h b/src/layout/layout.h index 11a7d9aa..b0e530ec 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -48,6 +48,7 @@ void block_update_vs_square(off_t block_offset, VGMSTREAM* vgmstream); void block_update_vid1(off_t block_offset, VGMSTREAM* vgmstream); void block_update_ubi_sce(off_t block_offset, VGMSTREAM* vgmstream); void block_update_tt_ad(off_t block_offset, VGMSTREAM* vgmstream); +void block_update_vas(off_t block_offset, VGMSTREAM* vgmstream); /* other layouts */ void render_vgmstream_interleave(sample_t* buffer, int32_t sample_count, VGMSTREAM* vgmstream); diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 9de1b449..5214404d 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -319,6 +319,7 @@ + @@ -692,6 +693,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index 81d9d348..6ab9eb91 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -778,6 +778,9 @@ layout\Source Files + + layout\Source Files + layout\Source Files @@ -1897,6 +1900,9 @@ meta\Source Files + + meta\Source Files + meta\Source Files diff --git a/src/meta/meta.h b/src/meta/meta.h index c3bce0d5..c2bd7397 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -1002,4 +1002,6 @@ VGMSTREAM* init_vgmstream_gwb_gwd(STREAMFILE* sf); VGMSTREAM* init_vgmstream_cbx(STREAMFILE* sf); +VGMSTREAM* init_vgmstream_vas(STREAMFILE* sf); + #endif /*_META_H*/ diff --git a/src/meta/riff.c b/src/meta/riff.c index 0f5166f7..3a35c8d3 100644 --- a/src/meta/riff.c +++ b/src/meta/riff.c @@ -399,8 +399,9 @@ VGMSTREAM* init_vgmstream_riff(STREAMFILE* sf) { * .dat/ldat: RollerCoaster Tycoon 1/2 (PC) * .wma/lwma: SRS: Street Racing Syndicate (Xbox), Fast and the Furious (Xbox) * .caf: Topple (iOS) + * .wax: Lamborghini (Xbox) */ - if (!check_extensions(sf, "wav,lwav,xwav,mwv,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd,,sbv,wvx,str,at3,rws,aud,at9,ckd,saf,ima,nsa,pcm,xvag,ogg,logg,p1d,xms,mus,dat,ldat,wma,lwma,caf")) { + if (!check_extensions(sf, "wav,lwav,xwav,mwv,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd,,sbv,wvx,str,at3,rws,aud,at9,ckd,saf,ima,nsa,pcm,xvag,ogg,logg,p1d,xms,mus,dat,ldat,wma,lwma,caf,wax")) { return NULL; } diff --git a/src/meta/vas.c b/src/meta/vas.c new file mode 100644 index 00000000..a582842e --- /dev/null +++ b/src/meta/vas.c @@ -0,0 +1,75 @@ +#include "meta.h" +#include "../coding/coding.h" + +/* VAS - Manhunt 2 [PSP] blocked audio format */ +VGMSTREAM* init_vgmstream_vas(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + off_t stream_offset; + size_t data_size, stream_size, block_size = 0x40; + int sample_rate, num_streams, channels, loop_flag = 0; + int is_v2, target_subsong = sf->stream_index; + + + /* checks */ + /* VAGs: v1, used in prerelease builds + * 2AGs: v2, used in the final release */ + if (!is_id32be(0x00, sf, "VAGs") && !is_id32be(0x00, sf, "2AGs")) + goto fail; + + if (!check_extensions(sf, "vas")) + goto fail; + + + /* parse header */ + data_size = read_u32le(0x04, sf); + sample_rate = read_u16le(0x08, sf); + if (read_u8(0x0A, sf)) goto fail; /* always 0? */ + num_streams = read_u8(0x0B, sf); + + if (num_streams < 1 || num_streams > 32) goto fail; + if (!target_subsong) target_subsong = 1; + + channels = 1; /* might be read_u8(0x0A, sf) + 1? */ + + + /* set up stream */ + is_v2 = read_u8(0x00, sf) == 0x32; /* 2AGs */ + + stream_offset = 0x0C; + /* only in v2, 32 byte buffer of the intended order for stream blocks(?) */ + /* always 00 01 02 03 04 05 06 in the multi-stream music/ambience files */ + if (is_v2) stream_offset += 0x20; + + /* might conflict with the standard VAG otherwise */ + if (data_size + stream_offset != get_streamfile_size(sf)) + goto fail; + + target_subsong -= 1; /* zero index */ + /* currently threre are no known v1 multi-stream blocked sounds, prerelease + * builds also use v2 for those, but this should be how v1 works in theory */ + stream_offset += block_size * (is_v2 ? read_u8(0x0C + target_subsong, sf) : target_subsong); + + stream_size = data_size / num_streams; + + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channels, loop_flag); + if (!vgmstream) goto fail; + + vgmstream->meta_type = meta_VAS; + vgmstream->coding_type = coding_PSX; + vgmstream->num_streams = num_streams; + vgmstream->sample_rate = sample_rate; + vgmstream->stream_size = stream_size; + vgmstream->interleave_block_size = 0; + vgmstream->layout_type = layout_blocked_vas; + vgmstream->num_samples = ps_bytes_to_samples(stream_size, channels); + + if (!vgmstream_open_stream(vgmstream, sf, stream_offset)) + goto fail; + return vgmstream; + +fail: + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index b8eeac44..e5d763f2 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -524,6 +524,7 @@ init_vgmstream_t init_vgmstream_functions[] = { init_vgmstream_gwb_gwd, init_vgmstream_s_pack, init_vgmstream_cbx, + init_vgmstream_vas, /* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */ init_vgmstream_scd_pcm, diff --git a/src/vgmstream_types.h b/src/vgmstream_types.h index 4f72b25b..050ca9fa 100644 --- a/src/vgmstream_types.h +++ b/src/vgmstream_types.h @@ -233,6 +233,7 @@ typedef enum { layout_blocked_vid1, layout_blocked_ubi_sce, layout_blocked_tt_ad, + layout_blocked_vas, /* otherwise odd */ layout_segmented, /* song divided in segments (song sections) */ @@ -704,6 +705,7 @@ typedef enum { meta_NXOF, meta_GWB_GWD, meta_CBX, + meta_VAS, } meta_t;