Wii IDSP .gcm.

I had apparently planned for it early on but it wasn't implemented.


git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@426 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
halleyscometsw 2008-08-22 00:24:15 +00:00
parent 84ea2fd232
commit 30107db223
4 changed files with 154 additions and 42 deletions

View File

@ -215,4 +215,6 @@ VGMSTREAM * init_vgmstream_dc_idvi(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_rnd(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_wii_idsp(STREAMFILE *streamFile);
#endif

View File

@ -1107,3 +1107,112 @@ fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
/* IDSP .gcm files, two standard DSP headers */
/* found in LEGO Star Wars Complete Collection for Wii */
VGMSTREAM * init_vgmstream_wii_idsp(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
off_t interleave;
struct dsp_header ch0_header,ch1_header;
int i;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("gcm",filename_extension(filename))) goto fail;
if (read_dsp_header(&ch0_header, 0x20, streamFile)) goto fail;
if (read_dsp_header(&ch1_header, 0x80, streamFile)) goto fail;
/* check header magic */
if (read_32bitBE(0x0,streamFile) != 0x49445350) goto fail; /* "IDSP" */
start_offset = 0xe0;
interleave = 8;
/* 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))
goto fail;
/* check type==0 and gain==0 */
if (ch0_header.format || ch0_header.gain ||
ch1_header.format || ch1_header.gain)
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;
}
/* 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;
fail:
/* clean up anything we may have opened */
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -74,55 +74,56 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_riff,
init_vgmstream_pos,
init_vgmstream_nwa,
init_vgmstream_eacs,
init_vgmstream_eacs,
init_vgmstream_xss,
init_vgmstream_sl3,
init_vgmstream_hgc1,
init_vgmstream_aus,
init_vgmstream_rws,
init_vgmstream_rsd,
init_vgmstream_fsb,
init_vgmstream_rwx,
init_vgmstream_xwb,
init_vgmstream_xa30,
init_vgmstream_musc,
init_vgmstream_musx,
init_vgmstream_leg,
init_vgmstream_filp,
init_vgmstream_ikm,
init_vgmstream_sfs,
init_vgmstream_bg00,
init_vgmstream_dvi,
init_vgmstream_kcey,
init_vgmstream_ps2_rstm,
init_vgmstream_rsd,
init_vgmstream_fsb,
init_vgmstream_rwx,
init_vgmstream_xwb,
init_vgmstream_xa30,
init_vgmstream_musc,
init_vgmstream_musx,
init_vgmstream_leg,
init_vgmstream_filp,
init_vgmstream_ikm,
init_vgmstream_sfs,
init_vgmstream_bg00,
init_vgmstream_dvi,
init_vgmstream_kcey,
init_vgmstream_ps2_rstm,
init_vgmstream_acm,
init_vgmstream_mus_acm,
init_vgmstream_ps2_kces,
init_vgmstream_ps2_dxh,
init_vgmstream_ps2_psh,
init_vgmstream_pcm,
init_vgmstream_ps2_rkv,
init_vgmstream_ps2_psw,
init_vgmstream_ps2_vas,
init_vgmstream_ps2_tec,
init_vgmstream_ps2_enth,
init_vgmstream_sdt,
init_vgmstream_ps2_kces,
init_vgmstream_ps2_dxh,
init_vgmstream_ps2_psh,
init_vgmstream_pcm,
init_vgmstream_ps2_rkv,
init_vgmstream_ps2_psw,
init_vgmstream_ps2_vas,
init_vgmstream_ps2_tec,
init_vgmstream_ps2_enth,
init_vgmstream_sdt,
init_vgmstream_aix,
init_vgmstream_ngc_tydsp,
init_vgmstream_ngc_swd,
init_vgmstream_ngc_vjdsp,
init_vgmstream_xbox_wvs,
init_vgmstream_dc_str,
init_vgmstream_xbox_stma,
init_vgmstream_xbox_matx,
init_vgmstream_ngc_tydsp,
init_vgmstream_ngc_swd,
init_vgmstream_ngc_vjdsp,
init_vgmstream_xbox_wvs,
init_vgmstream_dc_str,
init_vgmstream_xbox_stma,
init_vgmstream_xbox_matx,
init_vgmstream_de2,
init_vgmstream_dc_str,
init_vgmstream_xbox_xmu,
init_vgmstream_xbox_xvas,
init_vgmstream_ngc_bh2pcm,
init_vgmstream_sat_sap,
init_vgmstream_dc_idvi,
init_vgmstream_ps2_rnd,
init_vgmstream_xbox_xmu,
init_vgmstream_xbox_xvas,
init_vgmstream_ngc_bh2pcm,
init_vgmstream_sat_sap,
init_vgmstream_dc_idvi,
init_vgmstream_ps2_rnd,
init_vgmstream_wii_idsp,
};
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
@ -1401,8 +1402,8 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_DSP_GCM:
snprintf(temp,TEMPSIZE,"Double DSP header stereo by .gcm extension");
break;
case meta_DSP_IDSP:
snprintf(temp,TEMPSIZE,"GCM file with IDSP Header");
case meta_DSP_WII_IDSP:
snprintf(temp,TEMPSIZE,"Wii IDSP Double DSP header");
break;
case meta_RSTM_SPM:
snprintf(temp,TEMPSIZE,"Nintendo RSTM header and .brstmspm extension");

View File

@ -149,7 +149,7 @@ typedef enum {
meta_DSP_SADB, /* .sad */
meta_DSP_WSI, /* .wsi */
meta_DSP_AMTS, /* .amts */
meta_DSP_IDSP, /* .gcm with IDSP header */
meta_DSP_WII_IDSP, /* .gcm with IDSP header */
/* Nintendo */
meta_STRM, /* STRM */