From c02568d249107930315af3ac676fb461d2d3eeb8 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 24 Jun 2023 17:56:09 +0200 Subject: [PATCH] cleanup: misc --- src/coding/circus_decoder_lzxpcm.h | 96 +++++++++++++------------- src/formats.c | 10 +-- src/meta/dsp_adx.c | 34 +++++----- src/meta/meta.h | 4 +- src/meta/myspd.c | 10 +-- src/meta/ngc_ymf.c | 90 +++++++++---------------- src/meta/sts.c | 24 +++---- src/meta/ydsp.c | 104 +++++++++-------------------- src/meta/zsd.c | 104 ++++++++++++----------------- src/util/m2_psb.c | 46 ++++++------- src/vgmstream.c | 4 +- src/vgmstream_types.h | 4 +- 12 files changed, 223 insertions(+), 307 deletions(-) diff --git a/src/coding/circus_decoder_lzxpcm.h b/src/coding/circus_decoder_lzxpcm.h index b457f700..c4d60f24 100644 --- a/src/coding/circus_decoder_lzxpcm.h +++ b/src/coding/circus_decoder_lzxpcm.h @@ -213,7 +213,7 @@ static int lzxpcm_decompress(lzxpcm_stream_t* strm) { default: goto fail; } - } + } buffer_end: strm->next_out += dst_pos; @@ -232,65 +232,65 @@ fail: #if 0 /* non-streamed form that XPCM originally uses, assumes buffers are big enough */ static int lzxpcm_decompress_full(uint8_t* dst, size_t dst_size, const uint8_t* src, size_t src_size) { - int src_pos = 0; - int dst_pos = 0; - uint32_t flags = 0; + int src_pos = 0; + int dst_pos = 0; + uint32_t flags = 0; - while (src_pos < src_size && dst_pos < dst_size) { - flags >>= 1; + while (src_pos < src_size && dst_pos < dst_size) { + flags >>= 1; - if ((flags & 0x0100) == 0) { - flags = 0xFF00 | src[src_pos++]; - } - - if (flags & 1) { + if ((flags & 0x0100) == 0) { + flags = 0xFF00 | src[src_pos++]; + } + + if (flags & 1) { /* uncompressed byte per bit */ - dst[dst_pos++] = src[src_pos++]; - } - else { + dst[dst_pos++] = src[src_pos++]; + } + else { /* compressed data */ - uint32_t length; - uint32_t offset; - const uint32_t token = src[src_pos++]; + uint32_t length; + uint32_t offset; + const uint32_t token = src[src_pos++]; - if (token >= 0xC0) { - length = ((token >> 2) & 0x0F) + 4; /* 6b */ + if (token >= 0xC0) { + length = ((token >> 2) & 0x0F) + 4; /* 6b */ - offset = ((token & 3) << 8) | src[src_pos++]; /* upper 2b + lower 8b */ - } - else if (token >= 0x80) { - length = ((token >> 5) & 3) + 2; /* 2b */ + offset = ((token & 3) << 8) | src[src_pos++]; /* upper 2b + lower 8b */ + } + else if (token >= 0x80) { + length = ((token >> 5) & 3) + 2; /* 2b */ - offset = token & 0x1F; /* 5b */ - if (offset == 0) { - offset = src[src_pos++]; - } - } - else if (token == 0x7F) { - length = (uint16_t)(src[src_pos] | src[src_pos+1] << 8u) + 2; - src_pos += 2; + offset = token & 0x1F; /* 5b */ + if (offset == 0) { + offset = src[src_pos++]; + } + } + else if (token == 0x7F) { + length = (uint16_t)(src[src_pos] | src[src_pos+1] << 8u) + 2; + src_pos += 2; - offset = (uint16_t)(src[src_pos] | src[src_pos+1] << 8u); - src_pos += 2; - } - else { - length = token + 4; + offset = (uint16_t)(src[src_pos] | src[src_pos+1] << 8u); + src_pos += 2; + } + else { + length = token + 4; - offset = (uint16_t)(src[src_pos] | src[src_pos+1] << 8u); - src_pos += 2; - } + offset = (uint16_t)(src[src_pos] | src[src_pos+1] << 8u); + src_pos += 2; + } - if (dst_pos + length > dst_size) { - length = dst_size - dst_pos; - } + if (dst_pos + length > dst_size) { + length = dst_size - dst_pos; + } - for (int i = 0; i < length; i++) { - dst[dst_pos] = dst[dst_pos - offset]; - dst_pos++; - } - } - } + for (int i = 0; i < length; i++) { + dst[dst_pos] = dst[dst_pos - offset]; + dst_pos++; + } + } + } return 0; } diff --git a/src/formats.c b/src/formats.c index e1802e29..56b4bc46 100644 --- a/src/formats.c +++ b/src/formats.c @@ -1094,7 +1094,7 @@ static const meta_info meta_info_list[] = { {meta_SAP, "VING .SAP header"}, {meta_DC_IDVI, "Capcom IDVI header"}, {meta_KRAW, "Geometry Wars: Galaxies KRAW header"}, - {meta_NGC_YMF, "YMF DSP Header"}, + {meta_YMF, "Yuke's .YMF Header"}, {meta_FAG, "Radical .FAG Header"}, {meta_PS2_MIHB, "Sony MultiStream MIC header"}, {meta_DSP_WII_MUS, "mus header"}, @@ -1117,7 +1117,7 @@ static const meta_info meta_info_list[] = { {meta_SPT_SPD, "SPT+SPD DSP Header"}, {meta_ISH_ISD, "ISH+ISD DSP Header"}, {meta_GSP_GSB, "Tecmo GSP+GSB Header"}, - {meta_YDSP, "Yuke's DSP (YDSP) Header"}, + {meta_YDSP, "Yuke's YDSP Header"}, {meta_NGC_SSM, "SSM DSP Header"}, {meta_PS2_JOE, "Asobo Studio .JOE header"}, {meta_VGS, "Guitar Hero VGS Header"}, @@ -1139,7 +1139,7 @@ static const meta_info meta_info_list[] = { {meta_PS2_VSF_TTA, "VSF with SMSS Header"}, {meta_ADS_MIDWAY, "Midway ADS header"}, {meta_PS2_MCG, "Gunvari MCG Header"}, - {meta_ZSD, "ZSD Header"}, + {meta_ZSD, "Konami ZSD header"}, {meta_REDSPARK, "RedSpark Header"}, {meta_IVAUD, "Rockstar .ivaud header"}, {meta_DSP_WII_WSD, ".WSD header"}, @@ -1241,7 +1241,7 @@ static const meta_info meta_info_list[] = { {meta_IDSP_NAMCO, "Namco IDSP header"}, {meta_WIIU_BTSND, "Nintendo Wii U Menu Boot Sound"}, {meta_MCA, "Capcom MCA header"}, - {meta_XB3D_ADX, "Xenoblade 3D ADX header"}, + {meta_ADX_MONSTER, "Monster Games .ADX header"}, {meta_HCA, "CRI HCA header"}, {meta_SVAG_SNK, "SNK SVAG header"}, {meta_PS2_VDS_VDM, "Procyon Studio VDS/VDM header"}, @@ -1380,7 +1380,7 @@ static const meta_info meta_info_list[] = { {meta_KWB, "Koei Tecmo WaveBank header"}, {meta_LRMD, "Sony LRMD header"}, {meta_WWISE_FX, "Audiokinetic Wwise FX header"}, - {meta_DIVA, "DIVA header"}, + {meta_DIVA, "Sega DIVA header"}, {meta_IMUSE, "LucasArts iMUSE header"}, {meta_KTSR, "Koei Tecmo KTSR header"}, {meta_KAT, "Sega KAT header"}, diff --git a/src/meta/dsp_adx.c b/src/meta/dsp_adx.c index 42cbb3d8..ac4564db 100644 --- a/src/meta/dsp_adx.c +++ b/src/meta/dsp_adx.c @@ -2,36 +2,38 @@ #include "../coding/coding.h" #include "../util.h" -/* .ADX - from Xenoblade 3D (3DS) */ -VGMSTREAM* init_vgmstream_dsp_adx(STREAMFILE *sf) { +/* .ADX - from Monster Games [Xenoblade 3D (3DS)] */ +VGMSTREAM* init_vgmstream_adx_monster(STREAMFILE *sf) { VGMSTREAM* vgmstream = NULL; int loop_flag, channels; int channel_header_spacing = 0x34; + /* checks */ - if (!check_extensions(sf,"adx")) - goto fail; - if (read_u32be(0x00,sf) != 0x02000000) + return NULL; + + /* .adx: reused from Wii version, but actually DSP */ + if (!check_extensions(sf,"adx")) + return NULL; + + channels = read_s32le(0x0, sf); + loop_flag = read_s16le(0x6e, sf); + if (channels > 2 || channels < 0) goto fail; - channels = read_32bitLE(0, sf); - loop_flag = read_16bitLE(0x6e, sf); - - if (channels > 2 || channels < 0) goto fail; - vgmstream = allocate_vgmstream(channels, loop_flag); if (!vgmstream) goto fail; + vgmstream->meta_type = meta_ADX_MONSTER; vgmstream->coding_type = coding_NGC_DSP; vgmstream->layout_type = layout_none; - vgmstream->meta_type = meta_XB3D_ADX; - vgmstream->sample_rate = read_32bitLE(0x70,sf); - vgmstream->num_samples = read_32bitLE(0x74, sf); - vgmstream->loop_start_sample = read_32bitLE(0x78, sf); - vgmstream->loop_end_sample = read_32bitLE(0x7c, sf); + vgmstream->sample_rate = read_s32le(0x70,sf); + vgmstream->num_samples = read_s32le(0x74, sf); + vgmstream->loop_start_sample = read_s32le(0x78, sf); + vgmstream->loop_end_sample = read_s32le(0x7c, sf); - dsp_read_coefs_le(vgmstream,sf, 0x4, channel_header_spacing); + dsp_read_coefs_le(vgmstream,sf, 0x04, channel_header_spacing); /* semi-interleave: manually open streams at offset */ { diff --git a/src/meta/meta.h b/src/meta/meta.h index 3995add2..fe0ac610 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -296,7 +296,7 @@ VGMSTREAM * init_vgmstream_ps2_xa2(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_idsp_ie(STREAMFILE * streamFile); -VGMSTREAM * init_vgmstream_ngc_ymf(STREAMFILE * streamFile); +VGMSTREAM* init_vgmstream_ymf(STREAMFILE* sf); VGMSTREAM * init_vgmstream_sadl(STREAMFILE * streamFile); @@ -575,7 +575,7 @@ VGMSTREAM * init_vgmstream_ps2_vds_vdm(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_cxs(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_dsp_adx(STREAMFILE *streamFile); +VGMSTREAM* init_vgmstream_adx_monster(STREAMFILE* sf); VGMSTREAM * init_vgmstream_akb(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_akb2(STREAMFILE *streamFile); diff --git a/src/meta/myspd.c b/src/meta/myspd.c index ac7cdb34..f4bf58b6 100644 --- a/src/meta/myspd.c +++ b/src/meta/myspd.c @@ -18,18 +18,18 @@ VGMSTREAM* init_vgmstream_myspd(STREAMFILE* sf) { channel_size = read_s32be(0x00,sf); /* check size */ - if (channel_size * channels + start_offset != get_streamfile_size(sf)) - goto fail; + if (channel_size * channels + start_offset != get_streamfile_size(sf)) + goto fail; - /* build the VGMSTREAM */ + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channels,loop_flag); if (!vgmstream) goto fail; - vgmstream->num_samples = ima_bytes_to_samples(channel_size*channels, channels); + vgmstream->num_samples = ima_bytes_to_samples(channel_size*channels, channels); vgmstream->sample_rate = read_s32be(0x04,sf); vgmstream->meta_type = meta_MYSPD; - vgmstream->coding_type = coding_IMA_int; + vgmstream->coding_type = coding_IMA_int; vgmstream->layout_type = layout_interleave; vgmstream->interleave_block_size = channel_size; diff --git a/src/meta/ngc_ymf.c b/src/meta/ngc_ymf.c index 9fad79ec..357d6ec6 100644 --- a/src/meta/ngc_ymf.c +++ b/src/meta/ngc_ymf.c @@ -1,77 +1,51 @@ #include "meta.h" -#include "../util.h" +#include "../coding/coding.h" -/* YMF (WWE WrestleMania X8) */ -VGMSTREAM * init_vgmstream_ngc_ymf(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[PATH_LIMIT]; - off_t start_offset; - int loop_flag; - int channel_count; +/* YMF - from Yuke's games [WWE WrestleMania X8 (GC)] */ +VGMSTREAM* init_vgmstream_ymf(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + uint32_t start_offset; + int channels, loop_flag; - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("ymf",filename_extension(filename))) goto fail; - /* check header */ - if (read_32bitBE(0x00,streamFile) != 0x00000180) - goto fail; + /* checks */ + if (read_u32be(0x00,sf) != 0x00000180 || + read_u32be(0x08,sf) != 0x00000003 || + read_u32be(0x0c,sf) != 0xCCCCCCCC) + return NULL; + /* 0x04: used data size? */ + + /* .ymf: actual extension */ + if (!check_extensions(sf, "ymf")) + return NULL; + + /* .ymf can contain audio or video, but not both (videos start with 0x100 and change minor values), + * though it's are found in ./movie/*.* and probably are considered so */ loop_flag = 0; - channel_count = 2; + channels = 2; + start_offset = read_u32be(0x00,sf); - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channels, loop_flag); if (!vgmstream) goto fail; - /* fill in the vital statistics */ - start_offset = 0x180; - vgmstream->channels = channel_count; - vgmstream->sample_rate = read_32bitBE(0xA8,streamFile); - vgmstream->coding_type = coding_NGC_DSP; - vgmstream->num_samples = read_32bitBE(0xDC,streamFile); - if (loop_flag) { - vgmstream->loop_start_sample = 0; - vgmstream->loop_end_sample = read_32bitBE(0xDC,streamFile); - } + vgmstream->meta_type = meta_YMF; + vgmstream->sample_rate = read_32bitBE(0xA8,sf); + vgmstream->num_samples = read_32bitBE(0xDC,sf); + vgmstream->coding_type = coding_NGC_DSP; vgmstream->layout_type = layout_interleave; vgmstream->interleave_block_size = 0x20000; - vgmstream->meta_type = meta_NGC_YMF; + dsp_read_coefs_be(vgmstream, sf, 0xAE, 0x60); + //dsp_read_hist_be(vgmstream, sf, 0xAE + 0x20, 0x60); - if (vgmstream->coding_type == coding_NGC_DSP) { - int i; - for (i=0;i<16;i++) { - vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0xAE +i*2,streamFile); - } - if (vgmstream->channels) { - for (i=0;i<16;i++) { - vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x10E +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; - - } - } - + if (!vgmstream_open_stream(vgmstream, sf, start_offset)) + goto fail; return vgmstream; - /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); + close_vgmstream(vgmstream); return NULL; } diff --git a/src/meta/sts.c b/src/meta/sts.c index b8f245f9..84f68224 100644 --- a/src/meta/sts.c +++ b/src/meta/sts.c @@ -9,18 +9,18 @@ VGMSTREAM* init_vgmstream_sts(STREAMFILE* sf) { /* checks */ - if (!check_extensions(sf, "sts")) - goto fail; - data_size = read_u32be(0x00,sf); if (data_size + 0x04 != get_streamfile_size(sf)) - goto fail; + return NULL; + + if (!check_extensions(sf, "sts")) + return NULL; channels = read_u8(0x08,sf) + 1; - sample_rate = read_u16be(0x0c,sf); - /* 0x10: dsp related? */ - /* 0x16: usable size */ - channel_size = read_u32be(0x1a,sf); + sample_rate = read_u16be(0x0c,sf); + /* 0x10: dsp related? */ + /* 0x16: usable size */ + channel_size = read_u32be(0x1a,sf); loop_flag = 0; //(read_s32be(0x4C,sf) != -1); /* not seen */ @@ -34,16 +34,16 @@ VGMSTREAM* init_vgmstream_sts(STREAMFILE* sf) { vgmstream->meta_type = meta_STS; vgmstream->sample_rate = sample_rate; - vgmstream->num_samples = dsp_bytes_to_samples(channel_size, 1); + vgmstream->num_samples = dsp_bytes_to_samples(channel_size, 1); vgmstream->loop_start_sample = 0; vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->coding_type = coding_NGC_DSP; vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = channel_size + 0x2e; + vgmstream->interleave_block_size = channel_size + 0x2e; - dsp_read_coefs_be(vgmstream, sf, 0x1e, start_offset - 0x1e + channel_size); - dsp_read_hist_be(vgmstream, sf, 0x1e + 0x24, start_offset - 0x1e + channel_size); + dsp_read_coefs_be(vgmstream, sf, 0x1e, start_offset - 0x1e + channel_size); + dsp_read_hist_be(vgmstream, sf, 0x1e + 0x24, start_offset - 0x1e + channel_size); if (!vgmstream_open_stream(vgmstream, sf, start_offset)) goto fail; diff --git a/src/meta/ydsp.c b/src/meta/ydsp.c index d4c46aa0..8b37f85f 100644 --- a/src/meta/ydsp.c +++ b/src/meta/ydsp.c @@ -1,92 +1,48 @@ #include "meta.h" -#include "../util.h" +#include "../coding/coding.h" -/* YDSP (from WWE Day of Reckoning) */ -VGMSTREAM * init_vgmstream_ydsp(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[PATH_LIMIT]; - int loop_flag; - int channel_count; - off_t start_offset; - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("ydsp",filename_extension(filename))) goto fail; +/* YDSP - from Yuke's games [WWE Day of Reckoning (GC), WWE WrestleMania XIX (GC)] */ +VGMSTREAM* init_vgmstream_ydsp(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + int channels, loop_flag; + uint32_t start_offset; - /* check header */ - if (read_32bitBE(0x00,streamFile) != 0x59445350) /* "YDSP" */ - goto fail; + /* checks */ + if (!is_id32be(0x00,sf, "YDSP")) + return NULL; + + /* .ydsp: header id (in bigfile, .yds is the likely extension comparing similar files) */ + if (!check_extensions(sf, "ydsp")) + return NULL; + + loop_flag = (read_s32be(0xB0,sf) != 0x0); + channels = read_u16be(0x10,sf); + start_offset = 0x120; - loop_flag = (read_32bitBE(0xB0,streamFile)!=0x0); - channel_count = (uint16_t)read_16bitBE(0x10,streamFile); - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); + vgmstream = allocate_vgmstream(channels, loop_flag); if (!vgmstream) goto fail; - /* fill in the vital statistics */ - start_offset = 0x120; - vgmstream->channels = channel_count; - vgmstream->sample_rate = read_32bitBE(0x0C,streamFile); - vgmstream->coding_type = coding_NGC_DSP; vgmstream->meta_type = meta_YDSP; + vgmstream->sample_rate = read_s32be(0x0C,sf); - vgmstream->num_samples = (read_32bitBE(0x08,streamFile))*14/8/channel_count; + vgmstream->num_samples = dsp_bytes_to_samples(read_u32be(0x08,sf), channels); + vgmstream->loop_start_sample = read_s32be(0xB0,sf); + vgmstream->loop_end_sample = read_s32be(0xB4,sf); - if (loop_flag) - { - vgmstream->loop_start_sample = read_32bitBE(0xB0,streamFile); - vgmstream->loop_end_sample = read_32bitBE(0xB4,streamFile); - } + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitBE(0x14,sf); - if (channel_count == 1) - { - vgmstream->layout_type = layout_none; - } - else if (channel_count == 2) - { - vgmstream->interleave_block_size = read_32bitBE(0x14,streamFile); - vgmstream->layout_type = layout_interleave; - } - - - - /* open the file for reading */ - - 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 == 2) - { - for (i=0;i<16;i++) - { - vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x44+i*2,streamFile); - } - } - } - - { - 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; - } - } + dsp_read_coefs_be(vgmstream, sf, 0x20, 0x24); + //dsp_read_hist_be(vgmstream, sf, 0x20 + 0x20, 0x24); + if (!vgmstream_open_stream(vgmstream, sf, start_offset)) + goto fail; return vgmstream; - /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); + close_vgmstream(vgmstream); return NULL; } diff --git a/src/meta/zsd.c b/src/meta/zsd.c index 245e49ef..c83bee2b 100644 --- a/src/meta/zsd.c +++ b/src/meta/zsd.c @@ -1,60 +1,44 @@ -#include "meta.h" -#include "../util.h" - -/* ZSD (Dragon Booster) */ -VGMSTREAM * init_vgmstream_zsd(STREAMFILE *streamFile) { - - VGMSTREAM * vgmstream = NULL; - char filename[PATH_LIMIT]; - off_t start_offset; - - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("zsd",filename_extension(filename))) goto fail; - - /* check header */ - if (read_32bitBE(0x00,streamFile) != 0x5A534400) goto fail; - - loop_flag = 0; - channel_count = 1; - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); - if (!vgmstream) goto fail; - - /* fill in the vital statistics */ - start_offset = read_32bitLE(0x20,streamFile); - vgmstream->channels = channel_count; - vgmstream->sample_rate = read_32bitLE(0x10,streamFile); - vgmstream->coding_type = coding_PCM8; - vgmstream->num_samples = read_32bitLE(0x18,streamFile)/channel_count; - vgmstream->interleave_block_size=0x0; - - vgmstream->layout_type = layout_none; - vgmstream->meta_type = meta_ZSD; - - - /* 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; -} +#include "meta.h" +#include "../util.h" + +/* ZSD - from Dragon Booster (DS) */ +VGMSTREAM* init_vgmstream_zsd(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + uint32_t start_offset; + int channels, loop_flag; + + /* checks */ + if (!is_id32be(0x00,sf, "ZSD\0")) + return NULL; + + /* .zsd: actual extension */ + if (!check_extensions(sf, "zsd")) + return NULL; + + /* 0x04: 0x1000? */ + /* 0x08: 0x0c? */ + /* 0x14: 0x08? */ + /* 0x1c: 0x1000? */ + channels = read_s32le(0x0c,sf); + + loop_flag = 0; + start_offset = read_s32le(0x20,sf); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channels, loop_flag); + if (!vgmstream) goto fail; + + vgmstream->meta_type = meta_ZSD; + vgmstream->sample_rate = read_s32le(0x10,sf); + vgmstream->num_samples = read_s32le(0x18,sf) / channels; + vgmstream->coding_type = coding_PCM8; + vgmstream->layout_type = layout_none; + + if (!vgmstream_open_stream(vgmstream, sf, start_offset)) + goto fail; + return vgmstream; + +fail: + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/util/m2_psb.c b/src/util/m2_psb.c index d38dcd77..f8e27245 100644 --- a/src/util/m2_psb.c +++ b/src/util/m2_psb.c @@ -103,20 +103,20 @@ typedef struct { } list_t; struct psb_context_t { - uint32_t header_id; - uint16_t version; - uint16_t encrypt_value; - uint32_t encrypt_offset; - uint32_t keys_offset; + uint32_t header_id; + uint16_t version; + uint16_t encrypt_value; + uint32_t encrypt_offset; + uint32_t keys_offset; - uint32_t strings_list_offset; - uint32_t strings_data_offset; - uint32_t data_offsets_offset; - uint32_t data_sizes_offset; + uint32_t strings_list_offset; + uint32_t strings_data_offset; + uint32_t data_offsets_offset; + uint32_t data_sizes_offset; - uint32_t data_offset; /* also "resources" */ - uint32_t root_offset; /* initial node */ - uint32_t unknown; /* hash/crc? (v3) */ + uint32_t data_offset; /* also "resources" */ + uint32_t root_offset; /* initial node */ + uint32_t unknown; /* hash/crc? (v3) */ /* main buf and derived stuff */ uint8_t* buf; @@ -328,19 +328,19 @@ psb_context_t* psb_init(STREAMFILE* sf) { bytes = read_streamfile(header, 0x00, sizeof(header), sf); if (bytes != sizeof(header)) goto fail; - ctx->header_id = get_u32be(header + 0x00); - ctx->version = get_u16le(header + 0x04); - ctx->encrypt_value = get_u32le(header + 0x06); - ctx->encrypt_offset = get_u32le(header + 0x08); - ctx->keys_offset = get_u32le(header + 0x0c); + ctx->header_id = get_u32be(header + 0x00); + ctx->version = get_u16le(header + 0x04); + ctx->encrypt_value = get_u32le(header + 0x06); + ctx->encrypt_offset = get_u32le(header + 0x08); + ctx->keys_offset = get_u32le(header + 0x0c); - ctx->strings_list_offset = get_u32le(header + 0x10); - ctx->strings_data_offset = get_u32le(header + 0x14); - ctx->data_offsets_offset = get_u32le(header + 0x18); - ctx->data_sizes_offset = get_u32le(header + 0x1c); + ctx->strings_list_offset = get_u32le(header + 0x10); + ctx->strings_data_offset = get_u32le(header + 0x14); + ctx->data_offsets_offset = get_u32le(header + 0x18); + ctx->data_sizes_offset = get_u32le(header + 0x1c); - ctx->data_offset = get_u32le(header + 0x20); - ctx->root_offset = get_u32le(header + 0x24); + ctx->data_offset = get_u32le(header + 0x20); + ctx->root_offset = get_u32le(header + 0x24); if (ctx->version >= PSB_VERSION3) ctx->unknown = get_u32le(header + 0x28); diff --git a/src/vgmstream.c b/src/vgmstream.c index bc9594f4..a9878383 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -126,7 +126,7 @@ init_vgmstream_t init_vgmstream_functions[] = { init_vgmstream_ps2_xa2, init_vgmstream_idsp_nl, init_vgmstream_idsp_ie, - init_vgmstream_ngc_ymf, + init_vgmstream_ymf, init_vgmstream_sadl, init_vgmstream_fag, init_vgmstream_ps2_mihb, @@ -278,7 +278,7 @@ init_vgmstream_t init_vgmstream_functions[] = { init_vgmstream_svag_snk, init_vgmstream_ps2_vds_vdm, init_vgmstream_cxs, - init_vgmstream_dsp_adx, + init_vgmstream_adx_monster, init_vgmstream_akb, init_vgmstream_akb2, #ifdef VGM_USE_FFMPEG diff --git a/src/vgmstream_types.h b/src/vgmstream_types.h index b411f10a..42cecc4b 100644 --- a/src/vgmstream_types.h +++ b/src/vgmstream_types.h @@ -369,7 +369,7 @@ typedef enum { meta_GCA, /* Metal Slug Anthology */ meta_NGC_SSM, /* Golden Gashbell Full Power */ meta_PS2_JOE, /* Wall-E / Pixar games */ - meta_NGC_YMF, /* WWE WrestleMania X8 */ + meta_YMF, meta_SADL, meta_FAG, /* Jackie Chan - Stuntmaster */ meta_PS2_MIHB, /* Merged MIH+MIB */ @@ -527,7 +527,7 @@ typedef enum { meta_KT_WIIBGM, /* Koei Tecmo WiiBGM */ meta_KTSS, /* Koei Tecmo Nintendo Stream (KNS) */ meta_MCA, /* Capcom MCA "MADP" */ - meta_XB3D_ADX, /* Xenoblade Chronicles 3D ADX */ + meta_ADX_MONSTER, meta_HCA, /* CRI HCA */ meta_SVAG_SNK, meta_PS2_VDS_VDM, /* Graffiti Kingdom */