mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 16:30:54 +01:00
Fix Next Level IDSP last interleave/jingles [Mario Strikers Charged]
This commit is contained in:
parent
751d5c5f0f
commit
0231d635ed
@ -92,81 +92,6 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* IDSP - from Next Level games [Mario Strikers Charged (Wii)] */
|
||||
VGMSTREAM * init_vgmstream_idsp_nl(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
int loop_flag = 1;
|
||||
int channel_count;
|
||||
off_t start_offset;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("idsp",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x49445350) /* IDSP */
|
||||
goto fail;
|
||||
|
||||
channel_count = read_32bitBE(0x24,streamFile);
|
||||
|
||||
if (channel_count > 8)
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
start_offset = (channel_count*0x60)+0xC;
|
||||
vgmstream->sample_rate = read_32bitBE(0x14,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = read_32bitBE(0x0C,streamFile);
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0x0C,streamFile));
|
||||
}
|
||||
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x04,streamFile);
|
||||
vgmstream->interleave_last_block_size = ((vgmstream->num_samples/7*8)%(vgmstream->interleave_block_size)/vgmstream->channels);
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
|
||||
vgmstream->meta_type = meta_IDSP_NL;
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
int i;
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x28+i*2,streamFile);
|
||||
}
|
||||
if (vgmstream->channels) {
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x88+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;i<channel_count;i++) {
|
||||
vgmstream->ch[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;
|
||||
}
|
||||
|
||||
/* IDSP - from Inevitable Entertainment games [Defender (GC)] */
|
||||
VGMSTREAM * init_vgmstream_idsp_ie(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
|
@ -77,11 +77,13 @@ typedef struct {
|
||||
size_t header_spacing; /* distance between DSP header of other channels */
|
||||
off_t start_offset; /* data start */
|
||||
size_t interleave; /* distance between data of other channels */
|
||||
size_t interleave_last; /* same, in the last block */
|
||||
|
||||
meta_t meta_type;
|
||||
|
||||
/* hacks */
|
||||
int force_loop; /* force full loop */
|
||||
int force_loop_seconds; /* force loop, but must be longer than this (to catch jingles) */
|
||||
int fix_looping; /* fix loop end going past num_samples */
|
||||
int fix_loop_start; /* weird files with bad loop start */
|
||||
int single_header; /* all channels share header, thus totals are off */
|
||||
@ -177,8 +179,13 @@ static VGMSTREAM * init_vgmstream_dsp_common(STREAMFILE *streamFile, dsp_meta *d
|
||||
/* all done, must be DSP */
|
||||
|
||||
loop_flag = ch_header[0].loop_flag;
|
||||
if (dspm->force_loop)
|
||||
if (!loop_flag && dspm->force_loop) {
|
||||
loop_flag = 1;
|
||||
if (dspm->force_loop_seconds &&
|
||||
ch_header[0].sample_count < dspm->force_loop_seconds*ch_header[0].sample_rate) {
|
||||
loop_flag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
@ -198,6 +205,7 @@ static VGMSTREAM * init_vgmstream_dsp_common(STREAMFILE *streamFile, dsp_meta *d
|
||||
if (dspm->interleave == 0 || vgmstream->coding_type == coding_NGC_DSP_subint)
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = dspm->interleave;
|
||||
vgmstream->interleave_last_block_size = dspm->interleave_last;
|
||||
|
||||
{
|
||||
/* set coefs and initial history (usually 0) */
|
||||
@ -747,6 +755,43 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* IDSP - from Next Level games [Super Mario Strikers (GC), Mario Strikers: Charged (Wii)] */
|
||||
VGMSTREAM * init_vgmstream_idsp_nl(STREAMFILE *streamFile) {
|
||||
dsp_meta dspm = {0};
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "idsp"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x49445350) /* "IDSP" */
|
||||
goto fail;
|
||||
|
||||
dspm.channel_count = 2;
|
||||
dspm.max_channels = 2;
|
||||
|
||||
dspm.header_offset = 0x0c;
|
||||
dspm.header_spacing = 0x60;
|
||||
dspm.start_offset = dspm.header_offset + dspm.header_spacing*dspm.channel_count;
|
||||
dspm.interleave = read_32bitBE(0x04,streamFile);
|
||||
/* 0x08: usable channel size */
|
||||
{
|
||||
size_t stream_size = get_streamfile_size(streamFile);
|
||||
if (read_32bitBE(stream_size - 0x04,streamFile) == 0x30303030)
|
||||
stream_size -= 0x14; /* remove padding */
|
||||
stream_size -= dspm.start_offset;
|
||||
|
||||
dspm.interleave_last = (stream_size / dspm.channel_count) % dspm.interleave;
|
||||
}
|
||||
|
||||
dspm.fix_looping = 1;
|
||||
dspm.force_loop = 1;
|
||||
dspm.force_loop_seconds = 15;
|
||||
|
||||
dspm.meta_type = meta_IDSP_NL;
|
||||
return init_vgmstream_dsp_common(streamFile, &dspm);
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* .wsd - Custom header + full interleaved dsp [Phantom Brave (Wii)] */
|
||||
VGMSTREAM * init_vgmstream_wii_wsd(STREAMFILE *streamFile) {
|
||||
dsp_meta dspm = {0};
|
||||
@ -889,7 +934,8 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Cabela's series (Magic Wand dev?) - header + interleaved dsp [Cabela's Big Game Hunt 2005 Adventures (GC), Cabela's Outdoor Adventures (GC)] */
|
||||
/* Cabela's series (Magic Wand dev?) - header + interleaved dsp
|
||||
* [Cabela's Big Game Hunt 2005 Adventures (GC), Cabela's Outdoor Adventures (GC)] */
|
||||
VGMSTREAM * init_vgmstream_dsp_cabelas(STREAMFILE *streamFile) {
|
||||
dsp_meta dspm = {0};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user