mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-15 02:57:38 +01:00
Improve PS2 XA30 [Driver: Parallel Lines (PS2)]
This commit is contained in:
parent
64500f025d
commit
f617e5e762
@ -631,7 +631,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_FSB5, "FMOD Sample Bank (FSB5) Header"},
|
||||
{meta_RWX, "RWX Header"},
|
||||
{meta_XWB, "Microsoft XWB Header"},
|
||||
{meta_XA30, "XA30 Header"},
|
||||
{meta_PS2_XA30, "Reflections XA30 PS2 header"},
|
||||
{meta_MUSC, "MUSC Header"},
|
||||
{meta_MUSX_V004, "MUSX / Version 004 Header"},
|
||||
{meta_MUSX_V005, "MUSX / Version 005 Header"},
|
||||
|
@ -188,7 +188,7 @@ VGMSTREAM * init_vgmstream_rwx(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_xwb(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_xa30(STREAMFILE * streamFile);
|
||||
VGMSTREAM * init_vgmstream_ps2_xa30(STREAMFILE * streamFile);
|
||||
|
||||
VGMSTREAM * init_vgmstream_musc(STREAMFILE * streamFile);
|
||||
|
||||
|
@ -1,63 +1,55 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* XA30 (found in Driver - Parallel Lines) */
|
||||
VGMSTREAM * init_vgmstream_xa30(STREAMFILE *streamFile) {
|
||||
/* XA30 - found in Driver: Parallel Lines (PS2) */
|
||||
VGMSTREAM * init_vgmstream_ps2_xa30(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
int loop_flag, channel_count;
|
||||
size_t file_size, data_size;
|
||||
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("xa30",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x58413330) /* "XA30 */
|
||||
/* ".xa30" is just the ID, the real filename inside the file uses .XA */
|
||||
if (!check_extensions(streamFile,"xa,xa30"))
|
||||
goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x58413330) /* "XA30" */
|
||||
goto fail;
|
||||
if (read_32bitLE(0x04,streamFile) <= 2) goto fail; /* extra check to avoid PS2/PC XA30 mixup */
|
||||
|
||||
loop_flag = 0;
|
||||
channel_count = 1;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
channel_count = 1 ; /* 0x08(2): interleave? 0x0a(2): channels? (always 1 in practice) */
|
||||
|
||||
start_offset = read_32bitLE(0x0C,streamFile);
|
||||
|
||||
file_size = get_streamfile_size(streamFile);
|
||||
data_size = read_32bitLE(0x14,streamFile); /* always off by 0x800 */
|
||||
if (data_size-0x0800 != file_size) goto fail;
|
||||
data_size = file_size - start_offset;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = read_32bitLE(0x0C,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x04,streamFile);
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = read_32bitLE(0x14,streamFile)*28/16/channel_count;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x14,streamFile)*28/16/channel_count;
|
||||
}
|
||||
vgmstream->num_samples = ps_bytes_to_samples(data_size,channel_count); /* 0x10: some num_samples value (but smaller) */
|
||||
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->meta_type = meta_XA30;
|
||||
vgmstream->meta_type = meta_PS2_XA30;
|
||||
/* the rest of the header has unknown values (and several repeats) and the filename */
|
||||
|
||||
|
||||
/* 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;
|
||||
|
||||
}
|
||||
}
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_fsb5,
|
||||
init_vgmstream_rwx,
|
||||
init_vgmstream_xwb,
|
||||
init_vgmstream_xa30,
|
||||
init_vgmstream_ps2_xa30,
|
||||
init_vgmstream_musc,
|
||||
init_vgmstream_musx_v004,
|
||||
init_vgmstream_musx_v005,
|
||||
|
@ -350,7 +350,7 @@ typedef enum {
|
||||
meta_FSB5, /* FMOD Sample Bank, version 5 */
|
||||
meta_RWX, /* Air Force Delta Storm (XBOX) */
|
||||
meta_XWB, /* Microsoft XACT framework (Xbox, X360, Windows) */
|
||||
meta_XA30, /* Driver - Parallel Lines (PS2) */
|
||||
meta_PS2_XA30, /* Driver - Parallel Lines (PS2) */
|
||||
meta_MUSC, /* Spyro Games, possibly more */
|
||||
meta_MUSX_V004, /* Spyro Games, possibly more */
|
||||
meta_MUSX_V005, /* Spyro Games, possibly more */
|
||||
|
Loading…
Reference in New Issue
Block a user