From 64ea8a391f21e4c07e3bc4c50b386db70bafb302 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Fri, 19 Feb 2010 11:28:29 +0000 Subject: [PATCH] .pona updated git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@744 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/meta/meta.h | 4 ++- src/meta/pona.c | 90 ++++++++++++++++++++++++++++++++++++++-------- src/meta/ps2_ikm.c | 8 ++--- src/vgmstream.c | 43 ++++++++++++---------- src/vgmstream.h | 43 +++++++++++----------- 5 files changed, 128 insertions(+), 60 deletions(-) diff --git a/src/meta/meta.h b/src/meta/meta.h index d9ba8e77..da2a7a4f 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -423,7 +423,9 @@ VGMSTREAM * init_vgmstream_wii_bns(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_wii_was(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_pona(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_pona_3do(STREAMFILE* streamFile); + +VGMSTREAM * init_vgmstream_pona_psx(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_xbox_hlwav(STREAMFILE* streamFile); diff --git a/src/meta/pona.c b/src/meta/pona.c index aa81aa67..852cfb81 100644 --- a/src/meta/pona.c +++ b/src/meta/pona.c @@ -1,33 +1,35 @@ #include "meta.h" #include "../util.h" -/* PONA (from Policenauts [3DO and PSX]) */ -VGMSTREAM * init_vgmstream_pona(STREAMFILE *streamFile) { +/* PONA (from Policenauts [3DO]) */ +VGMSTREAM * init_vgmstream_pona_3do(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; char filename[260]; off_t start_offset; int loop_flag; - int channel_count; + 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; - + if (read_32bitBE(0x00,streamFile) != 0x13020000) + goto fail; + + if ((read_32bitBE(0x06,streamFile)+0x800) != (get_streamfile_size(streamFile))) + goto fail; + loop_flag = (read_32bitBE(0x0A,streamFile) != 0xFFFFFFFF); channel_count = 1; - /* build the VGMSTREAM */ + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count,loop_flag); if (!vgmstream) goto fail; - /* fill in the vital statistics */ + /* fill in the vital statistics */ start_offset = (uint16_t)(read_16bitBE(0x04,streamFile)); - vgmstream->channels = channel_count; + vgmstream->channels = channel_count; vgmstream->sample_rate = 22050; vgmstream->coding_type = coding_SDX2; vgmstream->num_samples = (get_streamfile_size(streamFile))-start_offset; @@ -37,8 +39,70 @@ VGMSTREAM * init_vgmstream_pona(STREAMFILE *streamFile) { } vgmstream->layout_type = layout_none; - // vgmstream->interleave_block_size = 0x1; - vgmstream->meta_type = meta_PONA; + vgmstream->meta_type = meta_PONA_3DO; + + /* 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;ich[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; +} + + +/* PONA (from Policenauts [PSX]) */ +VGMSTREAM * init_vgmstream_pona_psx(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) != 0x00000800) + goto fail; + + if ((read_32bitBE(0x08,streamFile)+0x800) != (get_streamfile_size(streamFile))) + goto fail; + + loop_flag = (read_32bitBE(0xC,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 = read_32bitBE(0x04,streamFile); + vgmstream->channels = channel_count; + vgmstream->sample_rate = 44100; + vgmstream->coding_type = coding_PSX; + vgmstream->num_samples = ((get_streamfile_size(streamFile))-start_offset)/16/channel_count*28; + if (loop_flag) { + vgmstream->loop_start_sample = (read_32bitBE(0x0C,streamFile)/16/channel_count*28); + vgmstream->loop_end_sample = (read_32bitBE(0x08,streamFile)/16/channel_count*28); + } + + vgmstream->layout_type = layout_none; + vgmstream->meta_type = meta_PONA_PSX; /* open the file for reading */ { @@ -48,11 +112,9 @@ VGMSTREAM * init_vgmstream_pona(STREAMFILE *streamFile) { if (!file) goto fail; for (i=0;ich[i].streamfile = file; - vgmstream->ch[i].channel_start_offset= vgmstream->ch[i].offset=start_offset+ vgmstream->interleave_block_size*i; - } } diff --git a/src/meta/ps2_ikm.c b/src/meta/ps2_ikm.c index d6441748..a14c1c67 100644 --- a/src/meta/ps2_ikm.c +++ b/src/meta/ps2_ikm.c @@ -14,10 +14,9 @@ VGMSTREAM * init_vgmstream_ikm(STREAMFILE *streamFile) { if (strcasecmp("ikm",filename_extension(filename))) goto fail; /* check header */ - if (read_32bitBE(0x00,streamFile) != 0x494B4D00) /* "IKM\0" */ - goto fail; - if (read_32bitBE(0x40,streamFile) != 0x41535400) /* AST\0 */ - goto fail; + if ((read_32bitBE(0x00,streamFile) != 0x494B4D00) && /* "IKM\0" */ + (read_32bitBE(0x40,streamFile) != 0x41535400)) /* "AST\0" */ + goto fail; loop_flag = (read_32bitLE(0x14,streamFile)!=0); /* Not sure */ channel_count = read_32bitLE(0x50,streamFile); @@ -49,7 +48,6 @@ VGMSTREAM * init_vgmstream_ikm(STREAMFILE *streamFile) { if (!file) goto fail; for (i=0;ich[i].streamfile = file; - vgmstream->ch[i].channel_start_offset= vgmstream->ch[i].offset=start_offset+ vgmstream->interleave_block_size*i; diff --git a/src/vgmstream.c b/src/vgmstream.c index 2a24b8cb..3336b6a2 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -216,30 +216,31 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_sps, init_vgmstream_ps2_xa2_rrp, init_vgmstream_nds_hwas, - init_vgmstream_ngc_lps, + init_vgmstream_ngc_lps, init_vgmstream_ps2_snd, init_vgmstream_naomi_adpcm, - init_vgmstream_sd9, - init_vgmstream_2dx, - init_vgmstream_dsp_ygo, + init_vgmstream_sd9, + init_vgmstream_2dx, + init_vgmstream_dsp_ygo, init_vgmstream_ps2_vgv, init_vgmstream_ngc_gcub, init_vgmstream_maxis_xa, init_vgmstream_ngc_sck_dsp, init_vgmstream_apple_caff, - init_vgmstream_pc_mxst, - init_vgmstream_sab, + init_vgmstream_pc_mxst, + init_vgmstream_sab, init_vgmstream_exakt_sc, init_vgmstream_wii_bns, init_vgmstream_wii_was, - init_vgmstream_pona, + init_vgmstream_pona_3do, + init_vgmstream_pona_psx, init_vgmstream_xbox_hlwav, init_vgmstream_stx, init_vgmstream_ps2_stm, init_vgmstream_myspd, init_vgmstream_his, - init_vgmstream_ps2_ast, - init_vgmstream_dmsg, + init_vgmstream_ps2_ast, + init_vgmstream_dmsg, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -2315,7 +2316,7 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_NDS_HWAS: snprintf(temp,TEMPSIZE,"NDS 'HWAS' Header"); break; - case meta_NGC_LPS: + case meta_NGC_LPS: snprintf(temp,TEMPSIZE,"Rave Master LPS Header"); break; case meta_NAOMI_ADPCM: @@ -2324,7 +2325,7 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_SD9: snprintf(temp,TEMPSIZE,"beatmaniaIIDX SD9 header"); break; - case meta_2DX: + case meta_2DX: snprintf(temp,TEMPSIZE,"beatmaniaIIDX 2DX9 header"); break; case meta_DSP_YGO: @@ -2345,12 +2346,12 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_CAFF: snprintf(temp,TEMPSIZE,"Apple Core Audio Format Header"); break; - case meta_PC_MXST: - snprintf(temp,TEMPSIZE,"Lego Island MxSt Header"); - break; - case meta_PC_SOB_SAB: - snprintf(temp,TEMPSIZE,"Worms 4: Mayhem SOB/SAB Header"); - break; + case meta_PC_MXST: + snprintf(temp,TEMPSIZE,"Lego Island MxSt Header"); + break; + case meta_PC_SOB_SAB: + snprintf(temp,TEMPSIZE,"Worms 4: Mayhem SOB/SAB Header"); + break; case meta_MAXIS_XA: snprintf(temp,TEMPSIZE,"Maxis XAI/XAJ Header"); break; @@ -2381,11 +2382,15 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_PS2_AST: snprintf(temp,TEMPSIZE,"KOEI AST header"); break; - case meta_CAPDSP: + case meta_CAPDSP: snprintf(temp,TEMPSIZE,"Capcom custom DSP header"); break; - case meta_DMSG: + case meta_DMSG: snprintf(temp,TEMPSIZE,"RIFF/DMSGsegh header"); + break; + case meta_PONA_3DO: + case meta_PONA_PSX: + snprintf(temp,TEMPSIZE,"Policenauts BGM header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 5155a20e..537ba964 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -389,34 +389,34 @@ typedef enum { meta_RIFF_WAVE_MWV, /* .mwv RIFF w/ loop data in ctrl chunk pflt */ meta_RIFX_WAVE, /* RIFX, for big-endian WAVs */ meta_RIFX_WAVE_smpl, /* RIFX w/ loop data in smpl chunk */ - meta_PC_MXST, /* Lego Island MxSt */ - meta_PC_SOB_SAB, /* Worms 4 Mayhem SOB+SAB file */ + meta_PC_MXST, /* Lego Island MxSt */ + meta_PC_SOB_SAB, /* Worms 4 Mayhem SOB+SAB file */ meta_NWA, /* Visual Art's NWA */ meta_NWA_NWAINFOINI, /* NWA w/ NWAINFO.INI for looping */ meta_NWA_GAMEEXEINI, /* NWA w/ Gameexe.ini for looping */ - meta_DVI, /* DVI Interleaved */ - meta_KCEY, /* KCEYCOMP */ + meta_DVI, /* DVI Interleaved */ + meta_KCEY, /* KCEYCOMP */ meta_ACM, /* InterPlay ACM header */ meta_MUS_ACM, /* MUS playlist of InterPlay ACM files */ meta_DE2, /* Falcom (Gurumin) .de2 */ - meta_VS, /* Men in Black .vs */ + meta_VS, /* Men in Black .vs */ meta_FFXI_BGW, /* FFXI BGW */ meta_FFXI_SPW, /* FFXI SPW */ - meta_STS_WII, /* Shikigami No Shiro 3 STS Audio File */ - meta_PS2_P2BT, /* Pop'n'Music 7 Audio File */ - meta_PS2_GBTS, /* Pop'n'Music 9 Audio File */ - meta_NGC_IADP, /* Gamecube Interleave DSP */ - meta_PS2_TK5, /* Tekken 5 Stream Files */ - meta_WII_STR, /* House of The Dead Overkill STR+STH */ - meta_PS2_MCG, /* Gunvari MCG Files (was name .GCM on disk) */ + meta_STS_WII, /* Shikigami No Shiro 3 STS Audio File */ + meta_PS2_P2BT, /* Pop'n'Music 7 Audio File */ + meta_PS2_GBTS, /* Pop'n'Music 9 Audio File */ + meta_NGC_IADP, /* Gamecube Interleave DSP */ + meta_PS2_TK5, /* Tekken 5 Stream Files */ + meta_WII_STR, /* House of The Dead Overkill STR+STH */ + meta_PS2_MCG, /* Gunvari MCG Files (was name .GCM on disk) */ meta_ZSD, /* Dragon Booster ZSD */ meta_RedSpark, /* "RedSpark" RSD (MadWorld) */ - meta_PC_IVAUD, /* .ivaud GTA IV */ - meta_NDS_HWAS, /* Spider-Man 3, Tony Hawk's Downhill Jam, possibly more... */ - meta_NGC_LPS, /* Rave Master (Groove Adventure Rave)(GC) */ - meta_NAOMI_ADPCM, /* NAOMI/NAOMI2 ARcade games */ - meta_SD9, /* beatmaniaIIDX16 - EMPRESS (Arcade) */ - meta_2DX, /* beatmaniaIIDX16 - EMPRESS (Arcade) */ + meta_PC_IVAUD, /* .ivaud GTA IV */ + meta_NDS_HWAS, /* Spider-Man 3, Tony Hawk's Downhill Jam, possibly more... */ + meta_NGC_LPS, /* Rave Master (Groove Adventure Rave)(GC) */ + meta_NAOMI_ADPCM, /* NAOMI/NAOMI2 ARcade games */ + meta_SD9, /* beatmaniaIIDX16 - EMPRESS (Arcade) */ + meta_2DX, /* beatmaniaIIDX16 - EMPRESS (Arcade) */ meta_PS2_VGV, /* Rune: Viking Warlord */ meta_NGC_GCUB, /* Sega Soccer Slam */ meta_MAXIS_XA, /* Sim City 3000 (PC) */ @@ -424,10 +424,11 @@ 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_PONA_3DO, /* Policenauts (3DO) */ + meta_PONA_PSX, /* Policenauts (PSX) */ meta_XBOX_HLWAV, /* Half Life 2 (XBOX) */ - meta_PS2_AST, /* Some KOEI game (PS2) */ - meta_DMSG, /* Nightcaster II - Equinox (XBOX) */ + meta_PS2_AST, /* Some KOEI game (PS2) */ + meta_DMSG, /* Nightcaster II - Equinox (XBOX) */ } meta_t; typedef struct {