mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-17 19:19:16 +01:00
Fix some Reflections .xa [Emergency Heroes (Wii)]
This commit is contained in:
parent
6074da0f4c
commit
0e2023767b
@ -1,58 +1,66 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../coding/coding.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* 04SW - found in Driver: Parallel Lines (Wii) */
|
/* 04SW - Reflections games [Driver: Parallel Lines (Wii), Emergency Heroes (Wii)] */
|
||||||
VGMSTREAM * init_vgmstream_xa_04sw(STREAMFILE *streamFile) {
|
VGMSTREAM* init_vgmstream_xa_04sw(STREAMFILE* sf) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM* vgmstream = NULL;
|
||||||
off_t start_offset;
|
off_t start_offset;
|
||||||
int loop_flag, channel_count;
|
int loop_flag, channels, sample_rate;
|
||||||
size_t file_size, data_size;
|
int32_t num_samples;
|
||||||
|
uint32_t data_size;
|
||||||
|
|
||||||
/* checks */
|
|
||||||
/* ".04sw" is just the ID, the real filename inside the file uses .XA */
|
/* checks */
|
||||||
if (!check_extensions(streamFile,"xa,04sw"))
|
if (!is_id32be(0x00,sf, "04SW"))
|
||||||
goto fail;
|
goto fail;
|
||||||
if (read_32bitBE(0x00,streamFile) != 0x30345357) /* "04SW" */
|
|
||||||
goto fail;
|
/* .xa: standard
|
||||||
|
* .04sw: header ID / renamed */
|
||||||
/* after the ID goes a semi-standard DSP header */
|
if (!check_extensions(sf,"xa,04sw"))
|
||||||
if (read_32bitBE(0x10,streamFile) != 0) goto fail; /* should be non looping */
|
goto fail;
|
||||||
loop_flag = 0;
|
|
||||||
/* not in header it seems so just dual header check */
|
/* after the ID goes a modified DSP header x2 */
|
||||||
channel_count = (read_32bitBE(0x04,streamFile) == read_32bitBE(0x64,streamFile)) ? 2 : 1;
|
if (read_u32be(0x04 + 0x0c,sf) != 0) /* should be non looping */
|
||||||
|
goto fail;
|
||||||
start_offset = read_32bitBE(0x04 + 0x60*channel_count,streamFile);
|
loop_flag = 0;
|
||||||
|
/* not in header it seems, so just dual header check */
|
||||||
file_size = get_streamfile_size(streamFile);
|
|
||||||
data_size = read_32bitBE(0x04 + 0x60*channel_count + 0x04,streamFile);
|
num_samples = read_s32be(0x04 + 0x00,sf);
|
||||||
if (data_size+start_offset != file_size) goto fail;
|
data_size = read_u32be(0x04 + 0x04,sf);
|
||||||
|
sample_rate = read_u32be(0x0c,sf);
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
channels = (read_u32be(0x04 + 0x00,sf) == read_u32be(0x04 + 0x60,sf)) ? 2 : 1; /* some voice .xa */
|
||||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
||||||
if (!vgmstream) goto fail;
|
/* After DSP header goes a base header with mostly unknown values (several repeats) and the filename.
|
||||||
|
* Emergency Heroes has extra 0x10 at 0x10. */
|
||||||
vgmstream->sample_rate = read_32bitBE(0x0c,streamFile);
|
start_offset = read_u32be(0x04 + 0x60 * 2 + 0x00, sf);
|
||||||
vgmstream->num_samples = read_32bitBE(0x04,streamFile);
|
/* 0x04: data size (includes padding after DSP data in Driver, doesn't in Emergency Heroes */
|
||||||
|
/* 0x1c/2c: channels LE? */
|
||||||
vgmstream->coding_type = coding_NGC_DSP;
|
/* 0x74/84: utf-16 path+filename */
|
||||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
|
|
||||||
vgmstream->interleave_block_size = 0x8000;
|
|
||||||
vgmstream->interleave_last_block_size = (read_32bitBE(0x08,streamFile) / 2 % vgmstream->interleave_block_size + 7) / 8 * 8;
|
/* build the VGMSTREAM */
|
||||||
|
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||||
dsp_read_coefs_be(vgmstream,streamFile,0x20, 0x60);
|
if (!vgmstream) goto fail;
|
||||||
/* the initial history offset seems different thatn standard DSP and possibly always zero */
|
|
||||||
|
vgmstream->sample_rate = sample_rate;
|
||||||
vgmstream->meta_type = meta_XA_04SW;
|
vgmstream->num_samples = num_samples;
|
||||||
/* the rest of the header has unknown values (several repeats) and the filename */
|
|
||||||
|
vgmstream->coding_type = coding_NGC_DSP;
|
||||||
|
vgmstream->layout_type = channels == 1 ? layout_none : layout_interleave;
|
||||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
vgmstream->interleave_block_size = 0x8000;
|
||||||
goto fail;
|
vgmstream->interleave_last_block_size = (data_size / 2 % vgmstream->interleave_block_size + 7) / 8 * 8;
|
||||||
return vgmstream;
|
|
||||||
|
dsp_read_coefs_be(vgmstream, sf, 0x04 + 0x1c, 0x60);
|
||||||
fail:
|
/* initial history offset seems different than standard DSP and possibly fixed/invalid */
|
||||||
close_vgmstream(vgmstream);
|
|
||||||
return NULL;
|
vgmstream->meta_type = meta_XA_04SW;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||||
|
goto fail;
|
||||||
|
return vgmstream;
|
||||||
|
fail:
|
||||||
|
close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user