add .was (DiRT 2)

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@697 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2009-09-11 18:40:26 +00:00
parent be5c926321
commit 4d8e5ee8ae
9 changed files with 109 additions and 23 deletions

View File

@ -210,7 +210,8 @@ META_OBJS=meta/adx_header.o \
meta/pc_mxst.o \
meta/pc_sob.o \
meta/exakt_sc.o \
meta/wii_bns.o
meta/wii_bns.o \
meta/wii_was.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)

View File

@ -818,6 +818,10 @@
RelativePath=".\meta\wii_sts.c"
>
</File>
<File
RelativePath=".\meta\wii_was.c"
>
</File>
<File
RelativePath=".\meta\ws_aud.c"
>
@ -966,6 +970,10 @@
RelativePath=".\coding\psx_decoder.c"
>
</File>
<File
RelativePath=".\coding\SASSC_decoder.c"
>
</File>
<File
RelativePath=".\coding\sdx2_decoder.c"
>
@ -978,10 +986,6 @@
RelativePath=".\coding\xa_decoder.c"
>
</File>
<File
RelativePath=".\coding\SASSC_decoder.c"
>
</File>
</Filter>
</Filter>
<Filter

View File

@ -168,5 +168,6 @@ libmeta_la_SOURCES += pc_mxst.c
libmeta_la_SOURCES += pc_sob.c
libmeta_la_SOURCES += exakt_sc.c
libmeta_la_SOURCES += wii_bns.c
libmeta_la_SOURCES += wii_was.c
EXTRA_DIST = meta.h

View File

@ -415,4 +415,6 @@ VGMSTREAM * init_vgmstream_exakt_sc(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_wii_bns(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_wii_was(STREAMFILE* streamFile);
#endif

View File

@ -91,24 +91,24 @@ VGMSTREAM * init_vgmstream_waa_wac_wad_wam(STREAMFILE *streamFile) {
goto fail;
}
/* 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[1].channel_start_offset=
vgmstream->ch[1].offset=second_channel_start;
}
/* 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[1].channel_start_offset=
vgmstream->ch[1].offset=second_channel_start;
}
}

72
src/meta/wii_was.c Normal file
View File

@ -0,0 +1,72 @@
#include "meta.h"
#include "../util.h"
/* WAS (from DiRT 2 (Wii)) */
VGMSTREAM * init_vgmstream_wii_was(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
int loop_flag;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("was",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x0,streamFile) != 0x69535753) /* iWAS */
goto fail;
loop_flag = 0;
channel_count = read_32bitBE(0x8,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0xE0;
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitBE(0x28,streamFile);
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->num_samples = read_32bitBE(0x20,streamFile);
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitBE(0x10,streamFile);
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_WII_WAS;
if (vgmstream->coding_type == coding_NGC_DSP) {
int i;
for (i=0;i<16;i++) {
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x3C+i*2,streamFile);
}
if (vgmstream->channels) {
for (i=0;i<16;i++) {
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x9C+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;
fail:
/* clean up anything we may have opened */
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -227,6 +227,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_sab,
init_vgmstream_exakt_sc,
init_vgmstream_wii_bns,
init_vgmstream_wii_was,
};
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
@ -2311,6 +2312,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_WII_BNS:
snprintf(temp,TEMPSIZE,"Nintendo BNS header");
break;
case meta_WII_WAS:
snprintf(temp,TEMPSIZE,"DiRT2 WAS header");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
}

View File

@ -414,6 +414,7 @@ typedef enum {
meta_NGC_SCK_DSP, /* Scorpion King (NGC) */
meta_CAFF, /* iPhone .caf */
meta_EXAKT_SC, /* Activision EXAKT .SC (PS2) */
meta_WII_WAS, /* DiRT 2 (WII) */
} meta_t;
typedef struct {

View File

@ -261,6 +261,7 @@ char * extension_list[] = {
"wad\0WAD Audio File (*.WAD)\0",
"wam\0WAM Audio File (*.WAM)\0",
"wavm\0WAVM Audio File (*.WAVM)\0",
"was\0WAS Audio File (*.WAS)\0",
"wii\0WII Audio File (*.WII)\0",
"wp2\0WP2 Audio File (*.WP2)\0",
"wsd\0WSD Audio File (*.WSD)\0",