Clean psx_gms

This commit is contained in:
bnnm 2019-08-15 22:07:12 +02:00
parent badf3477e3
commit 3e4f64fda8
5 changed files with 39 additions and 61 deletions

View File

@ -394,6 +394,7 @@ static const char* extension_list[] = {
"sd9", "sd9",
"sdf", "sdf",
"sdt", "sdt",
"seb",
"seg", "seg",
"sf0", "sf0",
"sfl", "sfl",
@ -820,8 +821,8 @@ static const meta_info meta_info_list[] = {
{meta_PS2_VAGi, "Sony VAGi header"}, {meta_PS2_VAGi, "Sony VAGi header"},
{meta_PS2_VAGp, "Sony VAGp header"}, {meta_PS2_VAGp, "Sony VAGp header"},
{meta_PS2_pGAV, "Sony pGAV header"}, {meta_PS2_pGAV, "Sony pGAV header"},
{meta_PSX_GMS, "assumed Grandia GMS file by .gms extension"}, {meta_SEB, "Game Arts .SEB header"},
{meta_STR_WAV, "Blitz Games STR+WAV header"}, {meta_STR_WAV, "Blitz Games .STR+WAV header"},
{meta_PS2_ILD, "ILD header"}, {meta_PS2_ILD, "ILD header"},
{meta_PS2_PNB, "assumed PNB (PsychoNauts Bgm File) by .pnb extension"}, {meta_PS2_PNB, "assumed PNB (PsychoNauts Bgm File) by .pnb extension"},
{meta_XBOX_WAVM, "Xbox WAVM raw header"}, {meta_XBOX_WAVM, "Xbox WAVM raw header"},

View File

@ -88,7 +88,7 @@ VGMSTREAM * init_vgmstream_raw(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_vag(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_vag(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_psx_gms(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_seb(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_ild(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_ps2_ild(STREAMFILE *streamFile);

View File

@ -1,76 +1,53 @@
#include "meta.h" #include "meta.h"
#include "../util.h"
/* GMS
PSX GMS format has no recognition ID. /* .seb - Game Arts games [Grandia (PS1), Grandia II/III/X (PS2)] */
This format was used essentially in Grandia Games but VGMSTREAM * init_vgmstream_seb(STREAMFILE *streamFile) {
can be easily used by other header format as the format of the header is very simple
known extensions : GMS
2008-05-19 - Fastelbja : First version ...
*/
VGMSTREAM * init_vgmstream_psx_gms(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
int loop_flag=0;
int channel_count;
off_t start_offset; off_t start_offset;
int i; int loop_flag, channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("gms",filename_extension(filename))) goto fail;
/* check loop */ /* checks */
loop_flag = (read_32bitLE(0x20,streamFile)==0); /* .seb: found in Grandia II (PS2) .idx */
/* .gms: fake? (.stz+idx bigfile without names, except in Grandia II) */
/* Always stereo files */ if (!check_extensions(streamFile, "seb,gms,"))
channel_count=read_32bitLE(0x00,streamFile); goto fail;
/* build the VGMSTREAM */ channel_count = read_32bitLE(0x00,streamFile);
if (channel_count > 2) goto fail; /* mono or stereo */
/* 0x08/0c: unknown count, possibly related to looping */
start_offset = 0x800;
if (read_32bitLE(0x10,streamFile) > get_streamfile_size(streamFile) || /* loop start offset */
read_32bitLE(0x18,streamFile) > get_streamfile_size(streamFile)) /* loop end offset */
goto fail;
/* in Grandia III sometimes there is a value at 0x24/34 */
loop_flag = (read_32bitLE(0x20,streamFile) == 0);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
/* fill in the vital statistics */ vgmstream->meta_type = meta_SEB;
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x04,streamFile); vgmstream->sample_rate = read_32bitLE(0x04,streamFile);
vgmstream->coding_type = coding_PSX; vgmstream->num_samples = read_32bitLE(0x1c,streamFile);
vgmstream->num_samples = read_32bitLE(0x1C,streamFile); vgmstream->loop_start_sample = read_32bitLE(0x14,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x1c,streamFile);
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x14,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x1C,streamFile);
}
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x800; vgmstream->interleave_block_size = 0x800;
vgmstream->meta_type = meta_PSX_GMS;
start_offset = 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);
}
}
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
return vgmstream; return vgmstream;
/* clean up anything we may have opened */
fail: fail:
if (vgmstream) close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }

View File

@ -51,7 +51,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_ps2_mic, init_vgmstream_ps2_mic,
init_vgmstream_ngc_dsp_std_int, init_vgmstream_ngc_dsp_std_int,
init_vgmstream_vag, init_vgmstream_vag,
init_vgmstream_psx_gms, init_vgmstream_seb,
init_vgmstream_ps2_ild, init_vgmstream_ps2_ild,
init_vgmstream_ps2_pnb, init_vgmstream_ps2_pnb,
init_vgmstream_xbox_wavm, init_vgmstream_xbox_wavm,

View File

@ -349,7 +349,7 @@ typedef enum {
meta_PS2_VAGi, /* VAGi Interleaved File */ meta_PS2_VAGi, /* VAGi Interleaved File */
meta_PS2_VAGp, /* VAGp Mono File */ meta_PS2_VAGp, /* VAGp Mono File */
meta_PS2_pGAV, /* VAGp with Little Endian Header */ meta_PS2_pGAV, /* VAGp with Little Endian Header */
meta_PSX_GMS, /* GMS File (used in PS1 & PS2) [no header_id] */ meta_SEB,
meta_STR_WAV, /* Blitz Games STR+WAV files */ meta_STR_WAV, /* Blitz Games STR+WAV files */
meta_PS2_ILD, /* ILD File */ meta_PS2_ILD, /* ILD File */
meta_PS2_PNB, /* PsychoNauts Bgm File */ meta_PS2_PNB, /* PsychoNauts Bgm File */