add PS2_PNB for PsychoNauts Bgm Files

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@193 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
fastelbja 2008-05-22 19:08:49 +00:00
parent 701fce7c3c
commit eac7190023
6 changed files with 81 additions and 4 deletions

View File

@ -270,6 +270,10 @@
RelativePath=".\meta\ps2_npsf.c" RelativePath=".\meta\ps2_npsf.c"
> >
</File> </File>
<File
RelativePath=".\meta\ps2_pnb.c"
>
</File>
<File <File
RelativePath=".\meta\ps2_rxw.c" RelativePath=".\meta\ps2_rxw.c"
> >

View File

@ -65,4 +65,6 @@ VGMSTREAM * init_vgmstream_ps2_str(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_ild(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_ps2_ild(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_pnb(STREAMFILE *streamFile);
#endif #endif

66
src/meta/ps2_pnb.c Normal file
View File

@ -0,0 +1,66 @@
#include "meta.h"
#include "../util.h"
/* PNB : PsychoNauts Bgm File */
VGMSTREAM * init_vgmstream_ps2_pnb(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
int loop_flag=0;
int channel_count;
off_t start_offset;
int i;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("pnb",filename_extension(filename))) goto fail;
/* check loop */
loop_flag = (read_32bitLE(0x0C,streamFile)!=0xFFFFFFFF);
channel_count=1;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = 1;
vgmstream->sample_rate = 44100;
/* Check for Compression Scheme */
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitBE(0x08,streamFile)/16*28;
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitBE(0x0C,streamFile)/16*28;
vgmstream->loop_end_sample = vgmstream->num_samples;
}
vgmstream->interleave_block_size = 0x10;
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_PNB;
start_offset = (off_t)read_32bitBE(0x00,streamFile);
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size);
if (!vgmstream->ch[i].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=
(off_t)(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

@ -15,7 +15,7 @@
* List of functions that will recognize files. These should correspond pretty * List of functions that will recognize files. These should correspond pretty
* directly to the metadata types * directly to the metadata types
*/ */
#define INIT_VGMSTREAM_FCNS 31 #define INIT_VGMSTREAM_FCNS 32
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile) = { VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile) = {
init_vgmstream_adx, /* 0 */ init_vgmstream_adx, /* 0 */
init_vgmstream_brstm, /* 1 */ init_vgmstream_brstm, /* 1 */
@ -47,7 +47,8 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(STREAMFILE *streamFile)
init_vgmstream_ps2_vag, /* 27 */ init_vgmstream_ps2_vag, /* 27 */
init_vgmstream_psx_gms, /* 28 */ init_vgmstream_psx_gms, /* 28 */
init_vgmstream_ps2_str, /* 29 */ init_vgmstream_ps2_str, /* 29 */
init_vgmstream_ps2_ild /* 30 */ init_vgmstream_ps2_ild, /* 30 */
init_vgmstream_ps2_pnb /* 31 */
}; };
/* internal version with all parameters */ /* internal version with all parameters */
@ -715,6 +716,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
break; break;
case meta_PS2_ILD: case meta_PS2_ILD:
snprintf(temp,TEMPSIZE,"ILD header"); snprintf(temp,TEMPSIZE,"ILD header");
break;
case meta_PS2_PNB:
snprintf(temp,TEMPSIZE,"assumed PNB (PsychoNauts Bgm File) by .pnb header");
break; break;
default: default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");

View File

@ -95,7 +95,7 @@ typedef enum {
meta_PSX_GMS, /* GMS File (used in PS1 & PS2) */ meta_PSX_GMS, /* GMS File (used in PS1 & PS2) */
meta_PS2_STR, /* Pacman STR+STH files */ meta_PS2_STR, /* Pacman STR+STH files */
meta_PS2_ILD, /* ILD File */ meta_PS2_ILD, /* ILD File */
meta_PS2_PNB, /* PsychoNauts Bgm File */
meta_PSX_XA, /* CD-XA with RIFF header */ meta_PSX_XA, /* CD-XA with RIFF header */
meta_RAW, /* RAW PCM file */ meta_RAW, /* RAW PCM file */

View File

@ -104,7 +104,8 @@ char * extension_list[] = {
"vag\0VAG Audio File (*.VAG)\0", "vag\0VAG Audio File (*.VAG)\0",
"gms\0GMS Audio File (*.GMS)\0", "gms\0GMS Audio File (*.GMS)\0",
"str\0STR Audio File (*.STR)\0", "str\0STR Audio File (*.STR)\0",
"ild\0ILD Audio File (*.ILD)\0" "ild\0ILD Audio File (*.ILD)\0",
"pnb\0PNB Audio File (*.PNB)\0"
}; };
void about(HWND hwndParent) { void about(HWND hwndParent) {