add GMS Support (PS1 & PS2)

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@174 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
fastelbja 2008-05-19 11:39:30 +00:00
parent 0b3739273f
commit 34d4d9d16f
6 changed files with 96 additions and 2 deletions

View File

@ -282,6 +282,10 @@
RelativePath=".\meta\psx_cdxa.c"
>
</File>
<File
RelativePath=".\meta\psx_gms.c"
>
</File>
<File
RelativePath=".\meta\raw.c"
>

View File

@ -59,4 +59,6 @@ VGMSTREAM * init_vgmstream_raw(const char * const filename);
VGMSTREAM * init_vgmstream_ps2_vag(const char * const filename);
VGMSTREAM * init_vgmstream_psx_gms(const char * const filename);
#endif

82
src/meta/psx_gms.c Normal file
View File

@ -0,0 +1,82 @@
#include "meta.h"
#include "../util.h"
/* GMS
PSX GMS format has no recognition ID.
This format was used essentially in Grandia Games but
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(const char * const filename) {
VGMSTREAM * vgmstream = NULL;
STREAMFILE * infile = NULL;
int loop_flag=0;
int channel_count;
off_t start_offset;
int i;
/* check extension, case insensitive */
if (strcasecmp("gms",filename_extension(filename))) goto fail;
/* try to open the file for header reading */
infile = open_streamfile(filename);
if (!infile) goto fail;
/* check loop */
loop_flag = (read_32bitLE(0x20,infile)==0);
/* Always stereo files */
channel_count=read_32bitLE(0x00,infile);
/* 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(0x04,infile);
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = read_32bitLE(0x1C,infile);
/* Get loop point values */
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x14,infile);
vgmstream->loop_end_sample = read_32bitLE(0x1C,infile);
}
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x800;
vgmstream->meta_type = meta_PSX_GMS;
start_offset = 0x800;
close_streamfile(infile); infile=NULL;
/* open the file for reading by each channel */
{
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = open_streamfile_buffer(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 (infile) close_streamfile(infile);
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -15,7 +15,7 @@
* List of functions that will recognize files. These should correspond pretty
* directly to the metadata types
*/
#define INIT_VGMSTREAM_FCNS 28
#define INIT_VGMSTREAM_FCNS 29
VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
init_vgmstream_adx, /* 0 */
init_vgmstream_brstm, /* 1 */
@ -45,6 +45,7 @@ VGMSTREAM * (*init_vgmstream_fcns[INIT_VGMSTREAM_FCNS])(const char * const) = {
init_vgmstream_ngc_dsp_std_int, /* 25 */
init_vgmstream_raw, /* 26 */
init_vgmstream_ps2_vag, /* 27 */
init_vgmstream_psx_gms /* 28 */
};
@ -678,6 +679,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
break;
case meta_PS2_pGAV:
snprintf(temp,TEMPSIZE,"Sony VAG Stereo Little Endian header (pGAV)");
break;
case meta_PSX_GMS:
snprintf(temp,TEMPSIZE,"assumed Grandia GMS file by .gms extension");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");

View File

@ -91,6 +91,7 @@ typedef enum {
meta_PS2_VAGi, /* VAGi Interleaved File */
meta_PS2_VAGp, /* VAGp Mono File */
meta_PS2_pGAV, /* VAGp with Little Endian Header */
meta_PSX_GMS, /* GMS File (used in PS1 & PS2) */
meta_PSX_XA, /* CD-XA with RIFF header */

View File

@ -74,7 +74,7 @@ int fade_samples = 0;
#define EXTENSION_LIST_SIZE 1024
char working_extension_list[EXTENSION_LIST_SIZE] = {0};
#define EXTENSION_COUNT 28
#define EXTENSION_COUNT 29
char * extension_list[EXTENSION_COUNT] = {
"adx\0ADX Audio File (*.ADX)\0",
"afc\0AFC Audio File (*.AFC)\0",
@ -104,6 +104,7 @@ char * extension_list[EXTENSION_COUNT] = {
"mss\0MSS Audio File (*.MSS)\0",
"raw\0RAW Audio File (*.RAW)\0",
"vag\0VAG Audio File (*.VAG)\0",
"gms\0GMS Audio File (*.GMS)\0",
};
void about(HWND hwndParent) {