fixed capcom hack in .genh

added .sng (WII)

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@532 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2008-12-24 00:00:10 +00:00
parent bbe32bdad6
commit 4b578db302
8 changed files with 197 additions and 63 deletions

View File

@ -169,7 +169,8 @@ META_OBJS=meta/adx_header.o \
meta/emff.o \
meta/thp.o \
meta/wii_sts.o \
meta/capdsp.o
meta/capdsp.o \
meta/wii_sng.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)

View File

@ -678,6 +678,10 @@
RelativePath=".\meta\wii_smp.c"
>
</File>
<File
RelativePath=".\meta\wii_sng.c"
>
</File>
<File
RelativePath=".\meta\wii_sts.c"
>

View File

@ -133,5 +133,6 @@ libmeta_la_SOURCES += emff.c
libmeta_la_SOURCES += thp.c
libmeta_la_SOURCES += wii_sts.c
libmeta_la_SOURCES += capdsp.c
libmeta_la_SOURCES += wii_sng.c
EXTRA_DIST = meta.h

View File

@ -10,19 +10,19 @@
VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
VGMSTREAM * vgmstream = NULL;
int32_t channel_count;
int32_t channel_count;
int32_t interleave;
int32_t sample_rate;
int32_t loop_start;
int32_t loop_end;
int32_t start_offset;
int32_t header_size;
int32_t coef[2];
int32_t coef_splitted[2];
int32_t dsp_interleave_type;
int32_t coef_type;
int32_t coef[2];
int32_t coef_splitted[2];
int32_t dsp_interleave_type;
int32_t coef_type;
char filename[260];
int coding;
@ -56,7 +56,7 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
/* 11 = MS ADPCM */
/* 12 = NGC DSP */
/* 13 = 8bit unsingned PCM */
/* 14 = PSX ADPCM (bad flagged) */
/* 14 = PSX ADPCM (bad flagged) */
/* ... others to come */
switch (read_32bitLE(0x18,streamFile)) {
case 0:
@ -102,10 +102,10 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
case 12:
coding = coding_NGC_DSP;
break;
case 13:
case 13:
coding = coding_PCM8_U_int;
break;
case 14:
case 14:
coding = coding_PSX_badflags;
break;
default:
@ -128,14 +128,14 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
sample_rate = read_32bitLE(0xc,streamFile);
loop_start = read_32bitLE(0x10,streamFile);
loop_end = read_32bitLE(0x14,streamFile);
coef[0] = read_32bitLE(0x24,streamFile);
coef[1] = read_32bitLE(0x28,streamFile);
dsp_interleave_type = read_32bitLE(0x2C,streamFile);
coef_type = read_32bitLE(0x30,streamFile); /* 0 - normal coefs
1 - splitted coefs (16byte rows) */
coef_splitted[0] = read_32bitLE(0x34,streamFile);
coef_splitted[1] = read_32bitLE(0x38,streamFile);
coef[0] = read_32bitLE(0x24,streamFile);
coef[1] = read_32bitLE(0x28,streamFile);
dsp_interleave_type = read_32bitLE(0x2C,streamFile);
coef_type = read_32bitLE(0x30,streamFile); /* 0 - normal coefs
1 - splitted coefs (16byte rows) */
coef_splitted[0] = read_32bitLE(0x34,streamFile);
coef_splitted[1] = read_32bitLE(0x38,streamFile);
//if (coding == coding_XBOX && channel_count != 2) goto fail;
/* build the VGMSTREAM */
@ -153,14 +153,14 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
switch (coding) {
case coding_PCM8_U_int:
vgmstream->layout_type=layout_none;
break;
case coding_PCM16LE:
vgmstream->layout_type=layout_none;
break;
case coding_PCM16LE:
case coding_PCM16BE:
case coding_PCM8:
case coding_SDX2:
case coding_PSX:
case coding_PSX_badflags:
case coding_PSX_badflags:
case coding_DVI_IMA:
case coding_IMA:
case coding_AICA:
@ -171,15 +171,15 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
coding = coding_SDX2_int;
vgmstream->coding_type = coding_SDX2_int;
}
if(vgmstream->interleave_block_size==0xffffffff)
vgmstream->layout_type=layout_none;
else {
vgmstream->layout_type = layout_interleave;
if(coding==coding_DVI_IMA)
coding=coding_INT_DVI_IMA;
if(coding==coding_IMA)
coding=coding_INT_IMA;
}
if(vgmstream->interleave_block_size==0xffffffff)
vgmstream->layout_type=layout_none;
else {
vgmstream->layout_type = layout_interleave;
if(coding==coding_DVI_IMA)
coding=coding_INT_DVI_IMA;
if(coding==coding_IMA)
coding=coding_INT_IMA;
}
} else {
vgmstream->layout_type = layout_none;
}
@ -196,16 +196,16 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
vgmstream->layout_type = layout_dtk_interleave;
break;
case coding_NGC_DSP:
if (dsp_interleave_type == 0) {
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
} else if (dsp_interleave_type == 1) {
vgmstream->layout_type = layout_interleave_byte;
vgmstream->interleave_block_size = interleave;
} else if (dsp_interleave_type == 2) {
vgmstream->layout_type = layout_none;
}
break;
if (dsp_interleave_type == 0) {
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
} else if (dsp_interleave_type == 1) {
vgmstream->layout_type = layout_interleave_byte;
vgmstream->interleave_block_size = interleave;
} else if (dsp_interleave_type == 2) {
vgmstream->layout_type = layout_none;
}
break;
#ifdef VGM_USE_MPEG
case coding_MPEG1_L3:
@ -214,13 +214,13 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
#endif
}
vgmstream->coding_type = coding;
vgmstream->meta_type = meta_GENH;
vgmstream->coding_type = coding;
vgmstream->meta_type = meta_GENH;
/* open the file for reading by each channel */
{
int i;
int j;
int j;
STREAMFILE * chstreamfile = NULL;
@ -229,7 +229,7 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
switch (coding) {
case coding_PSX:
case coding_PSX_badflags:
case coding_PSX_badflags:
case coding_PCM16BE:
case coding_PCM16LE:
case coding_SDX2:
@ -239,8 +239,8 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
case coding_PCM8:
case coding_PCM8_U_int:
case coding_AICA:
case coding_INT_DVI_IMA:
case coding_INT_IMA:
case coding_INT_DVI_IMA:
case coding_INT_IMA:
if (vgmstream->layout_type == layout_interleave) {
if (interleave >= 512) {
chstreamfile =
@ -276,22 +276,18 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
chstreamfile =
streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (coef_type == 0) {
for (j=0;j<16;j++) {
vgmstream->ch[i].adpcm_coef[j] = read_16bitBE(coef[i]+j*2,streamFile);
chstart_offset =start_offset+vgmstream->interleave_block_size*i;
}
} else if (coef_type == 1) {
for (j=0;j<8;j++) {
vgmstream->ch[0].adpcm_coef[j*2]=read_16bitBE(coef[0]+j*2,streamFile);
vgmstream->ch[0].adpcm_coef[j*2+1]=read_16bitBE(coef_splitted[0]+j*2,streamFile);
vgmstream->ch[1].adpcm_coef[j*2]=read_16bitBE(coef[1]+j*2,streamFile);
vgmstream->ch[1].adpcm_coef[j*2+1]=read_16bitBE(coef_splitted[1]+j*2,streamFile);
}
}
chstart_offset =start_offset+vgmstream->interleave_block_size*i;
break;
if (coef_type == 0) {
for (j=0;j<16;j++) {
vgmstream->ch[i].adpcm_coef[j] = read_16bitBE(coef[i]+j*2,streamFile);
}
} else if (coef_type == 1) {
for (j=0;j<8;j++) {
vgmstream->ch[i].adpcm_coef[j*2]=read_16bitBE(coef[i]+j*2,streamFile);
vgmstream->ch[i].adpcm_coef[j*2+1]=read_16bitBE(coef_splitted[i]+j*2,streamFile);
}
}
chstart_offset =start_offset+vgmstream->interleave_block_size*i;
break;
#ifdef VGM_USE_MPEG
case coding_MPEG1_L3:

View File

@ -320,4 +320,6 @@ VGMSTREAM * init_vgmstream_thp(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_wii_sts(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_wii_sng(STREAMFILE *streamFile);
#endif

125
src/meta/wii_sng.c Normal file
View File

@ -0,0 +1,125 @@
#include "meta.h"
#include "../util.h"
/* SNG (from Excite Truck [WII]) */
VGMSTREAM * init_vgmstream_wii_sng(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
int i;
int loop_flag;
int channel_count;
int coef1;
int coef2;
int first_block_len;
int second_channel_start;
int dataBuffer = 0;
int Founddata = 0;
size_t file_size;
off_t current_chunk;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("sng",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x30545352) /* "0STR" */
goto fail;
if (read_32bitBE(0x04,streamFile) != 0x34000000) /* 0x34000000 */
goto fail;
if (read_32bitBE(0x08,streamFile) != 0x08000000) /* 0x08000000" */
goto fail;
if (read_32bitBE(0x0C,streamFile) != 0x01000000) /* 0x01000000 */
goto fail;
if (read_32bitLE(0x10,streamFile) != (get_streamfile_size(streamFile)))
goto fail;
loop_flag = (read_32bitLE(0x130,streamFile) !=0); /* not sure */
channel_count = 2;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x180;
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x110,streamFile);
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->num_samples = read_32bitLE(0x100,streamFile)/16*14*2;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitBE(0x130,streamFile)/16*14;
vgmstream->loop_end_sample = read_32bitBE(0x134,streamFile)/16*14;
}
vgmstream->layout_type = layout_none;
vgmstream->meta_type = meta_WII_SNG;
/* scan file until we find a "data" string */
first_block_len = read_32bitLE(0x100,streamFile);
file_size = get_streamfile_size(streamFile);
{
current_chunk = first_block_len;
/* Start at 0 and loop until we reached the
file size, or until we found a "data string */
while (!Founddata && current_chunk < file_size) {
dataBuffer = (read_32bitLE(current_chunk,streamFile));
if (dataBuffer == first_block_len) { /* The value from the first block length */
/* if "data" string found, retrieve the needed infos */
Founddata = 1;
second_channel_start = current_chunk+0x80;
/* We will cancel the search here if we have a match */
break;
}
/* else we will increase the search offset by 1 */
current_chunk = current_chunk + 1;
}
}
coef1 = 0x13C;
if (Founddata == 0) {
goto fail;
} else if (Founddata == 1) {
coef2 = current_chunk+0x3C;
}
for (i=0;i<16;i++)
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(coef1+i*2,streamFile);
if (channel_count == 2) {
for (i=0;i<16;i++)
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(coef2+i*2,streamFile);
}
/* open the file for reading */
{
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;
/* The first channel */
vgmstream->ch[0].channel_start_offset=
vgmstream->ch[0].offset=start_offset;
/* The second channel */
if (channel_count == 2) {
vgmstream->ch[1].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!vgmstream->ch[1].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[1].offset=second_channel_start;
}
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -178,6 +178,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ss_stream,
init_vgmstream_thp,
init_vgmstream_wii_sts,
init_vgmstream_wii_sng,
};
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
@ -1824,6 +1825,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
break;
case meta_DSP_WII_MUS:
snprintf(temp,TEMPSIZE,"mus header");
break;
case meta_WII_SNG:
snprintf(temp,TEMPSIZE,"SNG DSP Header");
break;
case meta_RSD2VAG:
snprintf(temp,TEMPSIZE,"RSD2/VAG Header");

View File

@ -293,6 +293,7 @@ typedef enum {
meta_VGS, /* Guitar Hero Encore - Rocks the 80s */
meta_DC_WAV_DCS, /* Evil Twin - Cypriens Chronicles (DC) */
meta_WII_SMP, /* Mushroom Men - The Spore Wars */
meta_WII_SNG, /* Excite Trucks */
meta_EMFF_PS2, /* Eidos Music File Format for PS2*/
meta_EMFF_NGC, /* Eidos Music File Format for NGC/WII */