add .pona (Policenauts)

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@699 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2009-09-15 06:22:01 +00:00
parent cc6912b2d5
commit c4137c39d2
10 changed files with 212 additions and 155 deletions

View File

@ -211,8 +211,10 @@ META_OBJS=meta/adx_header.o \
meta/pc_sob.o \
meta/exakt_sc.o \
meta/wii_bns.o \
meta/wii_was.o
meta/wii_was.o \
meta/pona.o \
meta/fsb_test.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)
libvgmstream.a: $(OBJECTS)

View File

@ -304,6 +304,10 @@
RelativePath=".\meta\fsb.c"
>
</File>
<File
RelativePath=".\meta\fsb_test.c"
>
</File>
<File
RelativePath=".\meta\gca.c"
>
@ -486,6 +490,10 @@
RelativePath=".\meta\pcm.c"
>
</File>
<File
RelativePath=".\meta\pona.c"
>
</File>
<File
RelativePath=".\meta\pos.c"
>

View File

@ -169,5 +169,7 @@ libmeta_la_SOURCES += pc_sob.c
libmeta_la_SOURCES += exakt_sc.c
libmeta_la_SOURCES += wii_bns.c
libmeta_la_SOURCES += wii_was.c
libmeta_la_SOURCES += pona.c
libmeta_la_SOURCES += fsb_test.c
EXTRA_DIST = meta.h

View File

@ -1,6 +1,7 @@
#include "meta.h"
#include "../util.h"
/* comment from hcs:
((uint8_t)read_8bit(offset, file))&0xf for the low nibble,
((uint8_t)read_8bit(offset, file)) >> 4 for the high one
@ -8,6 +9,7 @@
*/
/* FSB1 */
VGMSTREAM * init_vgmstream_fsb1(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
@ -87,156 +89,6 @@ fail:
}
/* FSB3 */
VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
/* int fsb3_included_files; */
int fsb3_headerlen = 0x18;
int fsb3_format;
int loop_flag = 0;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("fsb",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x46534233) /* "FSB3" */
goto fail;
/* "Check if the FSB is used as
conatiner or as single file" */
if (read_32bitBE(0x04,streamFile) != 0x01000000)
goto fail;
if (read_32bitBE(0x48,streamFile) == 0x02000806) {
loop_flag = 1;
} else {
loop_flag = 0; /* (read_32bitLE(0x08,streamFile)!=0); */
}
/* Channel check
if (read_16bitLE(0x56,streamFile) == 2) {
channel_count = 2;
} else {
goto fail;
}
*/
channel_count = read_16bitLE(0x56,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* This will be tricky ;o) */
fsb3_format = read_32bitBE(0x48,streamFile);
switch (fsb3_format) {
case 0x40008800: /* PS2 (Agent Hugo, Flat Out 2) */
case 0x41008800: /* PS2 (Flat Out) */
case 0x42008800: /* PS2 (Jackass - The Game) */
case 0x01008804: /* PS2 (Cold Fear) */
case 0x02008804: /* PS2 (Shrek - Smash 'n Crash */
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
}
break;
case 0x00000806: /* WII (de Blob) */
case 0x00000886: /* WII (de Blob) */
case 0x01000806: /* WII (Metroid Prime 3) */
case 0x02000806: /* WII (Metroid Prime 3) */
case 0x20100002: /* WII (de Blob) */
case 0x21100002: /* NGC (The Incredibles: Rise of the Underminer */
case 0x40000802: /* WII (WWE Smackdown Vs. Raw 2008) */
case 0x40000882: /* WII (Bully) */
case 0x41000802: /* NGC (Dysney's Incredibles, The) */
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave_byte;
vgmstream->interleave_block_size = 2;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
}
break;
case 0x40004020: /* WII (Guitar Hero III), uses Xbox-ish IMA */
case 0x400040A0: /* WII (Guitar Hero III), uses Xbox-ish IMA */
case 0x41004800: /* XBOX (FlatOut, Rainbow Six - Lockdown) */
case 0x01004804: /* XBOX (Cold Fear) <- maybe IMA??? */
case 0x40004000: /* PC (Bioshock) */
case 0x20004000: /* PC (Bioshock) */
case 0x20004080: /* PC (Bioshock) */
vgmstream->coding_type = coding_XBOX;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
}
break;
default:
goto fail;
}
/* fill in the vital statistics */
start_offset = (read_32bitLE(0x08,streamFile))+fsb3_headerlen;
vgmstream->sample_rate = read_32bitLE(0x4C,streamFile);
vgmstream->meta_type = meta_FSB3;
if (vgmstream->coding_type == coding_NGC_DSP) {
int i,c;
for (c=0;c<channel_count;c++) {
for (i=0;i<16;i++) {
vgmstream->ch[c].adpcm_coef[i] =
read_16bitBE(0x68+c*0x2e +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;
if (vgmstream->coding_type == coding_XBOX) {
/* xbox interleaving is a little odd */
vgmstream->ch[i].channel_start_offset=start_offset;
} else {
vgmstream->ch[i].channel_start_offset=
start_offset+vgmstream->interleave_block_size*i;
}
vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
/* FSB4 */
VGMSTREAM * init_vgmstream_fsb4(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;

118
src/meta/fsb_test.c Normal file
View File

@ -0,0 +1,118 @@
#include "meta.h"
#include "../util.h"
/* FSB3.0 */
VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
int fsb_headerlen;
int loop_flag;
int channel_count;
off_t start_offset;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("fsb",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x46534233) goto fail; /* "FSB3" */
/* "Check if the FSB is used as conatiner or as single file" */
if (read_32bitLE(0x04,streamFile) != 0x1) goto fail;
/* Check if we're dealing with a FSB3.1 file */
if ((read_32bitBE(0x10,streamFile) != 0x00000300) &&
(read_32bitBE(0x10,streamFile) != 0x01000300))
goto fail;
loop_flag = 0; // for now...
channel_count = read_16bitLE(0x56,streamFile);
fsb_headerlen = read_32bitLE(0x08,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
// fsb_format = ;
switch (((uint8_t)read_8bit(0x4A, streamFile)) >> 4) {
case 0x0: // Nintendo DSP
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave_byte;
vgmstream->interleave_block_size = 2;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*14/8/channel_count;
}
break;
case 0x4: // XBOX IMA ADPCM
vgmstream->coding_type = coding_XBOX;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile)*64/36/channel_count;
}
break;
case 0x8: // PS2 APDCM
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10;
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile);
vgmstream->loop_end_sample = (read_32bitLE(0x0C,streamFile))*28/16/channel_count;
}
break;
default:
goto fail;
}
/* fill in the vital statistics */
start_offset = fsb_headerlen+0x18;
vgmstream->sample_rate = (read_32bitLE(0x4C, streamFile));
if (read_32bitBE(0x10,streamFile) == 0x00000300) {
vgmstream->meta_type = meta_FSB3_0;
} else if (read_32bitBE(0x10,streamFile) == 0x01000300) {
vgmstream->meta_type = meta_FSB3_1;
}
if (vgmstream->coding_type == coding_NGC_DSP) {
int i,c;
for (c=0;c<channel_count;c++) {
for (i=0;i<16;i++) {
vgmstream->ch[c].adpcm_coef[i] =
read_16bitBE(0x68+c*0x2e +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;
if (vgmstream->coding_type == coding_XBOX) {
/* xbox interleaving is a little odd */
vgmstream->ch[i].channel_start_offset=start_offset;
} else {
vgmstream->ch[i].channel_start_offset=
start_offset+vgmstream->interleave_block_size*i;
}
vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

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

65
src/meta/pona.c Normal file
View File

@ -0,0 +1,65 @@
#include "meta.h"
#include "../util.h"
/* PONA (from Policenauts [3DO and PSX]) */
VGMSTREAM * init_vgmstream_pona(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("pona",filename_extension(filename))) goto fail;
/* check header */
if (((read_32bitBE(0x00,streamFile) != 0x13020000) ||
(((uint16_t)read_16bitBE(0x04,streamFile)) != 0x0800))) /* 0x0800 */
goto fail;
loop_flag = (read_32bitBE(0x0A,streamFile) != 0xFFFFFFFF);
channel_count = 1;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = (uint16_t)(read_16bitBE(0x04,streamFile));
vgmstream->channels = channel_count;
vgmstream->sample_rate = 22050;
vgmstream->coding_type = coding_SDX2;
vgmstream->num_samples = (get_streamfile_size(streamFile))-start_offset;
if (loop_flag) {
vgmstream->loop_start_sample = (read_32bitBE(0x0A,streamFile));
vgmstream->loop_end_sample = (read_32bitBE(0x06,streamFile));
}
vgmstream->layout_type = layout_none;
// vgmstream->interleave_block_size = 0x1;
vgmstream->meta_type = meta_PONA;
/* 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;
}

View File

@ -82,6 +82,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_aus,
init_vgmstream_rws,
init_vgmstream_fsb1,
// init_vgmstream_fsb2,
init_vgmstream_fsb3,
init_vgmstream_fsb4,
init_vgmstream_fsb4_wav,
@ -229,6 +230,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_exakt_sc,
init_vgmstream_wii_bns,
init_vgmstream_wii_was,
init_vgmstream_pona,
};
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
@ -1937,8 +1939,11 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_FSB1:
snprintf(temp,TEMPSIZE,"FMOD Sample Bank (FSB1) Header");
break;
case meta_FSB3:
snprintf(temp,TEMPSIZE,"FMOD Sample Bank (FSB3) Header");
case meta_FSB3_0:
snprintf(temp,TEMPSIZE,"FMOD Sample Bank (FSB3.0) Header");
break;
case meta_FSB3_1:
snprintf(temp,TEMPSIZE,"FMOD Sample Bank (FSB3.1) Header");
break;
case meta_FSB4:
snprintf(temp,TEMPSIZE,"FMOD Sample Bank (FSB4) Header");

View File

@ -240,7 +240,8 @@ typedef enum {
meta_AUS, /* Variuos Capcom Games */
meta_RWS, /* Variuos Konami Games */
meta_FSB1, /* FMOD Sample Bank, version 1 */
meta_FSB3, /* FMOD Sample Bank, version 3 */
meta_FSB3_0, /* FMOD Sample Bank, version 3.0 */
meta_FSB3_1, /* FMOD Sample Bank, version 3.1 */
meta_FSB4, /* FMOD Sample Bank, version 4 */
meta_FSB4_WAV, /* FMOD Sample Bank, version 4 with "WAV" Header */
meta_RWX, /* Air Force Delta Storm (XBOX) */
@ -417,6 +418,7 @@ typedef enum {
meta_CAFF, /* iPhone .caf */
meta_EXAKT_SC, /* Activision EXAKT .SC (PS2) */
meta_WII_WAS, /* DiRT 2 (WII) */
meta_PONA, /* Policenauts (3DO + PSX) */
} meta_t;
typedef struct {

View File

@ -189,6 +189,7 @@ char * extension_list[] = {
"pcm\0PCM Audio File (*.PCM)\0",
"pdt\0PDT Audio File (*.PDT)\0",
"pnb\0PNB Audio File (*.PNB)\0",
"pona\0PONA Audio File (*.PONA)\0",
"pos\0POS Audio File (*.POS)\0",
"psh\0PSH Audio File (*.PSH)\0",
"psw\0PSW Audio File (*.PSW)\0",