mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 07:44:43 +01:00
Add .wua IDSP and cleanup [Lego Dimensions (Wii U)]
This commit is contained in:
parent
c7f9a47fcd
commit
efb01a921c
@ -422,6 +422,7 @@ static const char* extension_list[] = {
|
||||
"wpd",
|
||||
"wsd",
|
||||
"wsi",
|
||||
"wua",
|
||||
"wv2", //txth/reserved [Slave Zero (PC)]
|
||||
"wv6",
|
||||
"wve",
|
||||
@ -699,7 +700,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_DSP_JETTERS, "Double DSP header stereo by _lr.dsp extension"},
|
||||
{meta_DSP_MSS, "Double DSP header stereo by .mss extension"},
|
||||
{meta_DSP_GCM, "Double DSP header stereo by .gcm extension"},
|
||||
{meta_DSP_WII_IDSP, "Wii IDSP Double DSP header"},
|
||||
{meta_IDSP_TT, "Traveller's Tales IDSP header"},
|
||||
{meta_RSTM_SPM, "Nintendo RSTM header and .brstmspm extension"},
|
||||
{meta_RAW, "assumed RAW PCM file by .raw extension"},
|
||||
{meta_PS2_VAGi, "Sony VAG Interleaved header (VAGi)"},
|
||||
|
@ -597,17 +597,18 @@ VGMSTREAM * init_vgmstream_ngc_dsp_std_int(STREAMFILE *streamFile) {
|
||||
dspm.start_offset = 0xc0;
|
||||
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strlen(filename) > 7 && !strcasecmp("_lr.dsp",filename+strlen(filename)-7)) {
|
||||
if (strlen(filename) > 7 && !strcasecmp("_lr.dsp",filename+strlen(filename)-7)) { //todo improve
|
||||
dspm.interleave = 0x14180;
|
||||
dspm.meta_type = meta_DSP_JETTERS; /* Bomberman Jetters (GC) */
|
||||
} else if (!strcasecmp("mss",filename_extension(filename))) {
|
||||
} else if (check_extensions(streamFile, "mss")) {
|
||||
dspm.interleave = 0x1000;
|
||||
dspm.meta_type = meta_DSP_MSS; /* Free Radical GC games */
|
||||
/* Timesplitters 2 GC's ts2_atom_smasher_44_fx.mss differs slightly in samples but plays ok */
|
||||
dspm.ignore_header_agreement = 1;
|
||||
} else if (!strcasecmp("gcm",filename_extension(filename))) {
|
||||
} else if (check_extensions(streamFile, "gcm")) {
|
||||
/* older Traveller's Tales games [Lego Star Wars (GC), The Chronicles of Narnia (GC), Sonic R (GC)] */
|
||||
dspm.interleave = 0x8000;
|
||||
dspm.meta_type = meta_DSP_GCM; /* some of Traveller's Tales games */
|
||||
dspm.meta_type = meta_DSP_GCM;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
@ -866,137 +867,60 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* IDSP .gcm files, two standard DSP headers */
|
||||
/* found in: Lego Batman (Wii)
|
||||
Lego Indiana Jones - The Original Adventures (Wii)
|
||||
Lego Indiana Jones 2 - The Adventure Continues (Wii)
|
||||
Lego Star Wars - The Complete Saga (Wii)
|
||||
Lego The Lord of the Rings (Wii)
|
||||
The Chronicles of Narnia - Prince Caspian (Wii) */
|
||||
/* IDSP - Traveller's Tales header + interleaved dsps [Lego Batman (Wii), Lego Dimensions (Wii U)] */
|
||||
VGMSTREAM * init_vgmstream_wii_idsp(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
off_t interleave;
|
||||
struct dsp_header ch0_header,ch1_header;
|
||||
int i;
|
||||
dsp_meta dspm = {0};
|
||||
int version_main, version_sub;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if ((strcasecmp("gcm",filename_extension(filename))) &&
|
||||
(strcasecmp("idsp",filename_extension(filename))))
|
||||
goto fail;
|
||||
|
||||
/* check header magic */
|
||||
if (read_32bitBE(0x0,streamFile) != 0x49445350) goto fail; /* "IDSP" */
|
||||
|
||||
/* different versions? */
|
||||
if (read_32bitBE(0x4, streamFile) == 1 &&
|
||||
read_32bitBE(0x8, streamFile) == 0xc8)
|
||||
{
|
||||
if (read_dsp_header(&ch0_header, 0x10, streamFile)) goto fail;
|
||||
if (read_dsp_header(&ch1_header, 0x70, streamFile)) goto fail;
|
||||
|
||||
start_offset = 0xd0;
|
||||
}
|
||||
else if (read_32bitBE(0x4, streamFile) == 2 &&
|
||||
read_32bitBE(0x8, streamFile) == 0xd2)
|
||||
{
|
||||
if (read_dsp_header(&ch0_header, 0x20, streamFile)) goto fail;
|
||||
if (read_dsp_header(&ch1_header, 0x80, streamFile)) goto fail;
|
||||
|
||||
start_offset = 0xe0;
|
||||
}
|
||||
else if (read_32bitBE(0x4, streamFile) == 3 && //Lego The Lord of the Rings (Wii)
|
||||
read_32bitBE(0x8, streamFile) == 0x12c)
|
||||
{
|
||||
if (read_dsp_header(&ch0_header, 0x20, streamFile)) goto fail;
|
||||
if (read_dsp_header(&ch1_header, 0x80, streamFile)) goto fail;
|
||||
|
||||
start_offset = 0xe0;
|
||||
}
|
||||
else goto fail;
|
||||
|
||||
interleave = read_32bitBE(0xc, streamFile);
|
||||
|
||||
/* check initial predictor/scale */
|
||||
if (ch0_header.initial_ps != (uint8_t)read_8bit(start_offset,streamFile))
|
||||
goto fail;
|
||||
if (ch1_header.initial_ps != (uint8_t)read_8bit(start_offset+interleave,streamFile))
|
||||
/* checks */
|
||||
/* .gcm: standard
|
||||
* .idsp: header id?
|
||||
* .wua: Lego Dimensions (Wii U) */
|
||||
if (!check_extensions(streamFile, "gcm,idsp,wua"))
|
||||
goto fail;
|
||||
|
||||
/* check type==0 and gain==0 */
|
||||
if (ch0_header.format || ch0_header.gain ||
|
||||
ch1_header.format || ch1_header.gain)
|
||||
if (read_32bitBE(0x00,streamFile) != 0x49445350) /* "IDSP" */
|
||||
goto fail;
|
||||
|
||||
/* check for agreement */
|
||||
if (
|
||||
ch0_header.sample_count != ch1_header.sample_count ||
|
||||
ch0_header.nibble_count != ch1_header.nibble_count ||
|
||||
ch0_header.sample_rate != ch1_header.sample_rate ||
|
||||
ch0_header.loop_flag != ch1_header.loop_flag ||
|
||||
ch0_header.loop_start_offset != ch1_header.loop_start_offset ||
|
||||
ch0_header.loop_end_offset != ch1_header.loop_end_offset
|
||||
) goto fail;
|
||||
|
||||
if (ch0_header.loop_flag) {
|
||||
off_t loop_off;
|
||||
/* check loop predictor/scale */
|
||||
loop_off = ch0_header.loop_start_offset/16*8;
|
||||
loop_off = (loop_off/interleave*interleave*2) + (loop_off%interleave);
|
||||
if (ch0_header.loop_ps != (uint8_t)read_8bit(start_offset+loop_off,streamFile))
|
||||
goto fail;
|
||||
if (ch1_header.loop_ps != (uint8_t)read_8bit(start_offset+loop_off+interleave,streamFile))
|
||||
goto fail;
|
||||
version_main = read_32bitBE(0x04, streamFile);
|
||||
version_sub = read_32bitBE(0x08, streamFile); /* extra check since there are other IDSPs */
|
||||
if (version_main == 0x01 && version_sub == 0xc8) {
|
||||
/* Transformers: The Game (Wii) */
|
||||
dspm.channel_count = 2;
|
||||
dspm.max_channels = 2;
|
||||
dspm.header_offset = 0x10;
|
||||
}
|
||||
else if (version_main == 0x02 && version_sub == 0xd2) {
|
||||
/* Lego Batman (Wii)
|
||||
* The Chronicles of Narnia: Prince Caspian (Wii)
|
||||
* Lego Indiana Jones 2 (Wii)
|
||||
* Lego Star Wars: The Complete Saga (Wii)
|
||||
* Lego Pirates of the Caribbean (Wii)
|
||||
* Lego Harry Potter: Years 1-4 (Wii) */
|
||||
dspm.channel_count = 2;
|
||||
dspm.max_channels = 2;
|
||||
dspm.header_offset = 0x20;
|
||||
/* 0x10+: null */
|
||||
}
|
||||
else if (version_main == 0x03 && version_sub == 0x12c) {
|
||||
/* Lego The Lord of the Rings (Wii) */
|
||||
/* Lego Dimensions (Wii U) */
|
||||
dspm.channel_count = read_32bitBE(0x10, streamFile);
|
||||
dspm.max_channels = 2;
|
||||
dspm.header_offset = 0x20;
|
||||
/* 0x14+: "I_AM_PADDING" */
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
|
||||
vgmstream = allocate_vgmstream(2,ch0_header.loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->num_samples = ch0_header.sample_count;
|
||||
vgmstream->sample_rate = ch0_header.sample_rate;
|
||||
|
||||
/* TODO: adjust for interleave? */
|
||||
vgmstream->loop_start_sample = dsp_nibbles_to_samples(ch0_header.loop_start_offset);
|
||||
vgmstream->loop_end_sample = dsp_nibbles_to_samples(ch0_header.loop_end_offset)+1;
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = interleave;
|
||||
vgmstream->meta_type = meta_DSP_WII_IDSP;
|
||||
|
||||
/* coeffs */
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[0].adpcm_coef[i] = ch0_header.coef[i];
|
||||
vgmstream->ch[1].adpcm_coef[i] = ch1_header.coef[i];
|
||||
}
|
||||
|
||||
/* initial history */
|
||||
/* always 0 that I've ever seen, but for completeness... */
|
||||
vgmstream->ch[0].adpcm_history1_16 = ch0_header.initial_hist1;
|
||||
vgmstream->ch[0].adpcm_history2_16 = ch0_header.initial_hist2;
|
||||
vgmstream->ch[1].adpcm_history1_16 = ch1_header.initial_hist1;
|
||||
vgmstream->ch[1].adpcm_history2_16 = ch1_header.initial_hist2;
|
||||
|
||||
vgmstream->ch[0].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
vgmstream->ch[1].streamfile = vgmstream->ch[0].streamfile;
|
||||
|
||||
if (!vgmstream->ch[0].streamfile) goto fail;
|
||||
/* open the file for reading */
|
||||
for (i=0;i<2;i++) {
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+i*interleave;
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
dspm.header_spacing = 0x60;
|
||||
dspm.start_offset = dspm.header_offset + 0x60 * dspm.channel_count;
|
||||
dspm.interleave = read_32bitBE(0x0c, streamFile);
|
||||
|
||||
dspm.meta_type = meta_IDSP_TT;
|
||||
return init_vgmstream_dsp_common(streamFile, &dspm);
|
||||
fail:
|
||||
/* clean up anything we may have opened */
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ typedef enum {
|
||||
meta_DSP_STR, /* Conan .str files */
|
||||
meta_DSP_SADB, /* .sad */
|
||||
meta_DSP_WSI, /* .wsi */
|
||||
meta_DSP_WII_IDSP, /* .gcm with IDSP header */
|
||||
meta_IDSP_TT, /* Traveller's Tales games */
|
||||
meta_DSP_WII_MUS, /* .mus */
|
||||
meta_DSP_WII_WSD, /* Phantom Brave (WII) */
|
||||
meta_WII_NDP, /* Vertigo (Wii) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user