Add .move extension + cleanup [Pop 'n Music 7 (PS2)]

This commit is contained in:
bnnm 2024-01-20 00:46:01 +01:00
parent 366c1318e1
commit d1c2516f13
7 changed files with 111 additions and 208 deletions

View File

@ -346,6 +346,7 @@ static const char* extension_list[] = {
//"m4a", //common
//"m4v", //common
//"mov", //common
"move",
//"mp+", //common [Moonshine Runners (PC)]
//"mp2", //common
//"mp3", //common
@ -1129,8 +1130,8 @@ static const meta_info meta_info_list[] = {
{meta_MUL, "Crystal Dynamics .MUL header"},
{meta_THP, "Nintendo THP header"},
{meta_STS, "Alfa System .STS header"},
{meta_PS2_P2BT, "Pop'n'Music 7 Header"},
{meta_PS2_GBTS, "Pop'n'Music 9 Header"},
{meta_P2BT_MOVE_VISA, "Konami P2BT/MOVE/VISA header"},
{meta_GBTS, "Konami GBTS header"},
{meta_NGC_DSP_IADP, "IADP Header"},
{meta_RIFF_WAVE_MWV, "RIFF WAVE header (ctrl looping)"},
{meta_FFCC_STR, "Final Fantasy: Crystal Chronicles STR header"},
@ -1326,7 +1327,6 @@ static const meta_info meta_info_list[] = {
{meta_MSV, "Sony MultiStream MSV header"},
{meta_SDF, "Beyond Reality SDF header"},
{meta_SVG, "High Voltage SVG header"},
{meta_VIS, "Konami VIS header"},
{meta_VAI, "Asobo Studio .VAI header"},
{meta_AIF_ASOBO, "Asobo Studio .AIF header"},
{meta_AO, "AlphaOgg .AO header"},

View File

@ -344,9 +344,9 @@ VGMSTREAM * init_vgmstream_thp(STREAMFILE *streamFile);
VGMSTREAM* init_vgmstream_sts(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_ps2_p2bt(STREAMFILE *streamFile);
VGMSTREAM* init_vgmstream_p2bt_move_visa(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_ps2_gbts(STREAMFILE *streamFile);
VGMSTREAM* init_vgmstream_gbts(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_wii_sng(STREAMFILE *streamFile);
@ -752,8 +752,6 @@ VGMSTREAM * init_vgmstream_sdf(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_svg(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_vis(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_vai(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_aif_asobo(STREAMFILE *streamFile);

View File

@ -1,92 +1,56 @@
#include "meta.h"
#include "../util.h"
/* GBTS : Pop'n'Music 9 Bgm File */
VGMSTREAM * init_vgmstream_ps2_gbts(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
int loop_flag=0;
int channel_count;
off_t start_offset;
off_t loopStart = 0;
off_t loopEnd = 0;
size_t filelength;
int i;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("gbts",filename_extension(filename))) goto fail;
/* check loop */
start_offset=0x801;
filelength = get_streamfile_size(streamFile);
do {
// Loop Start ...
if(read_8bit(start_offset,streamFile)==0x06) {
if(loopStart==0) loopStart = start_offset-0x801;
}
// Loop End ...
if(read_8bit(start_offset,streamFile)==0x03) {
if(loopEnd==0) loopEnd = start_offset-0x801-0x10;
}
start_offset+=0x10;
} while (start_offset<(int32_t)filelength);
loop_flag = (loopEnd!=0);
channel_count=read_32bitLE(0x1C,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x18,streamFile);;
/* Check for Compression Scheme */
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitLE(0x0C,streamFile)/16*28/vgmstream->channels;
vgmstream->interleave_block_size = 0x10;
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = (loopStart/(vgmstream->interleave_block_size)*vgmstream->interleave_block_size)/16*28;
vgmstream->loop_start_sample += (loopStart%vgmstream->interleave_block_size)/16*28;
vgmstream->loop_start_sample /=vgmstream->channels;
vgmstream->loop_end_sample = (loopEnd/(vgmstream->interleave_block_size)*vgmstream->interleave_block_size)/16*28;
vgmstream->loop_end_sample += (loopEnd%vgmstream->interleave_block_size)/16*28;
vgmstream->loop_end_sample /=vgmstream->channels;
}
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_GBTS;
start_offset = (off_t)0x800;
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_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;
}
#include "meta.h"
#include "../coding/coding.h"
/* GbTs - from KCES games [Pop'n Music 9/10 (PS2)] */
VGMSTREAM* init_vgmstream_gbts(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int loop_flag, channels;
uint32_t data_offset, sample_rate, data_size;
uint32_t loop_start, loop_end;
/* checks */
if (!is_id32be(0x00,sf, "GbTs"))
return NULL;
/* .gbts: header id (no apparent exts) */
if (!check_extensions(sf, "gbts"))
return NULL;
/* 04: always 0x24 */
data_offset = read_u32le(0x08,sf);
data_size = read_u32le(0x0C,sf);
loop_start = read_u32le(0x10,sf); /* (0x20 = start frame if not set) */
loop_end = read_u32le(0x14,sf); /* (0x00 if not set) */
sample_rate = read_s32le(0x18,sf);
channels = read_s32le(0x1C,sf);
/* 20: 1? */
/* 24: block size? */
loop_flag = loop_end > 0;
loop_end += loop_start; /* loop region matches PS-ADPCM flags */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(data_size, channels);
vgmstream->loop_start_sample = ps_bytes_to_samples(loop_start, channels);
vgmstream->loop_end_sample = ps_bytes_to_samples(loop_end, channels);
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10;
vgmstream->meta_type = meta_GBTS;
if (!vgmstream_open_stream(vgmstream, sf, data_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -1,70 +1,65 @@
#include "meta.h"
#include "../util.h"
#include "../coding/coding.h"
/* P2BT : Pop'n'Music 7 & 8 Bgm File */
VGMSTREAM * init_vgmstream_ps2_p2bt(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
/* P2BT/MOVE/VISA - from Konami/KCE Studio games [Pop'n Music 7/8/Best (PS2), AirForce Delta Strike (PS2)] */
VGMSTREAM* init_vgmstream_p2bt_move_visa(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
uint32_t data_offset;
int loop_flag, channels, sample_rate, interleave;
uint32_t loop_start, data_size;
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("p2bt",filename_extension(filename))) goto fail;
/* checks */
if (!is_id32be(0x00,sf, "P2BT") &&
!is_id32be(0x00,sf, "MOVE") &&
!is_id32be(0x00,sf, "VISA"))
return NULL;
/* .psbt/move: header id (no apparent exts)
* .vis: actual extension found in AFDS and other KCES games */
if (!check_extensions(sf, "p2bt,move,vis"))
return NULL;
if((read_32bitBE(0x00,streamFile)!=0x4d4F5645) && // MOVE
(read_32bitBE(0x00,streamFile)!=0x50324254)) // P2BT
goto fail;
/* (header is the same with different IDs, all may be used within a single same game) */
/* 04: 07FC? */
sample_rate = read_s32le(0x08,sf);
loop_start = read_s32le(0x0c,sf);
data_size = read_u32le(0x10,sf); /* without padding */
interleave = read_u32le(0x14,sf); /* usually 0x10, sometimes 0x400 */
/* 18: 1? */
/* 1c: 0x10? */
channels = read_s32le(0x20,sf);
/* 24: 1? */
/* 28: stream name (AFDS), same as basename + original ext */
/* check loop */
loop_flag = (read_32bitLE(0x0C,streamFile)!=0);
channel_count=read_32bitLE(0x20,streamFile);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
loop_flag = (loop_start != 0);
data_offset = 0x800;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);;
vgmstream->sample_rate = sample_rate;
/* Check for Compression Scheme */
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitLE(0x10,streamFile)/16*28/vgmstream->channels;
vgmstream->num_samples = ps_bytes_to_samples(data_size, channels);
vgmstream->loop_start_sample = ps_bytes_to_samples(loop_start, channels);
vgmstream->loop_end_sample = vgmstream->num_samples;
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x0C,streamFile)/16*28/vgmstream->channels;
vgmstream->loop_end_sample = vgmstream->num_samples;
}
vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile);;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->meta_type = meta_PS2_P2BT;
vgmstream->interleave_block_size = interleave;
start_offset = (off_t)0x800;
if (vgmstream->interleave_block_size)
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size * channels)) / channels;
read_string(vgmstream->stream_name,0x10+1, 0x28, sf);
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_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);
}
}
vgmstream->meta_type = meta_P2BT_MOVE_VISA;
if (!vgmstream_open_stream(vgmstream, sf, data_offset))
goto fail;
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -1,52 +0,0 @@
#include "meta.h"
#include "../coding/coding.h"
/* VIS - from Konami games [AirForce Delta Strike (PS2) (PS2)] */
VGMSTREAM * init_vgmstream_vis(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
size_t data_size;
int loop_flag, channel_count;
/* checks */
if ( !check_extensions(streamFile,"vis") )
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x56495341) /* "VISA" */
goto fail;
start_offset = 0x800;
data_size = get_streamfile_size(streamFile) - start_offset;
loop_flag = read_32bitLE(0x18,streamFile);
channel_count = read_32bitLE(0x20,streamFile); /* assumed */
/* 0x1c: always 0x10 */
/* 0x24: always 0x01 */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_VIS;
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);
vgmstream->num_samples = ps_bytes_to_samples(data_size,channel_count);
vgmstream->loop_start_sample = ps_bytes_to_samples(read_32bitLE(0x0c,streamFile),channel_count);
vgmstream->loop_end_sample = ps_bytes_to_samples(read_32bitLE(0x10,streamFile),channel_count);
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile); /* usually 0x10 or 0x4000 */
if (vgmstream->interleave_block_size)
vgmstream->interleave_last_block_size =
(data_size % (vgmstream->interleave_block_size*channel_count)) / channel_count;
read_string(vgmstream->stream_name,0x10+1, 0x28,streamFile);
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -149,8 +149,8 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_mul,
init_vgmstream_thp,
init_vgmstream_sts,
init_vgmstream_ps2_p2bt,
init_vgmstream_ps2_gbts,
init_vgmstream_p2bt_move_visa,
init_vgmstream_gbts,
init_vgmstream_wii_sng,
init_vgmstream_ngc_dsp_iadp,
init_vgmstream_aax,
@ -375,7 +375,6 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_msv,
init_vgmstream_sdf,
init_vgmstream_svg,
init_vgmstream_vis,
init_vgmstream_vai,
init_vgmstream_aif_asobo,
init_vgmstream_ao,

View File

@ -428,8 +428,8 @@ typedef enum {
meta_FFXI_BGW, /* FFXI (PC) BGW */
meta_FFXI_SPW, /* FFXI (PC) SPW */
meta_STS,
meta_PS2_P2BT, /* Pop'n'Music 7 Audio File */
meta_PS2_GBTS, /* Pop'n'Music 9 Audio File */
meta_P2BT_MOVE_VISA,
meta_GBTS,
meta_NGC_DSP_IADP, /* Gamecube Interleave DSP */
meta_PS2_MCG, /* Gunvari MCG Files (was name .GCM on disk) */
meta_ZSD, /* Dragon Booster ZSD */
@ -602,7 +602,6 @@ typedef enum {
meta_MSV,
meta_SDF,
meta_SVG, /* Hunter - The Reckoning - Wayward (PS2) */
meta_VIS, /* AirForce Delta Strike (PS2) */
meta_VAI, /* Ratatouille (GC) */
meta_AIF_ASOBO, /* Ratatouille (PC) */
meta_AO, /* Cloudphobia (PC) */