2008-05-06 05:35:37 +02:00
|
|
|
#include "meta.h"
|
2008-04-02 19:50:50 +02:00
|
|
|
#include "../util.h"
|
|
|
|
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_gcsw(STREAMFILE *streamFile) {
|
2008-04-02 19:50:50 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2013-05-27 05:55:50 +02:00
|
|
|
char filename[PATH_LIMIT];
|
2008-04-02 19:50:50 +02:00
|
|
|
|
|
|
|
int channel_count;
|
|
|
|
int loop_flag;
|
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
2008-05-20 17:18:38 +02:00
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
2008-04-02 19:50:50 +02:00
|
|
|
if (strcasecmp("gcw",filename_extension(filename))) goto fail;
|
|
|
|
|
2008-05-20 17:18:38 +02:00
|
|
|
/* check header */
|
|
|
|
if ((uint32_t)read_32bitBE(0,streamFile)!=0x47435357) /* "GCSW" */
|
2008-04-02 19:50:50 +02:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* check type details */
|
|
|
|
/* guess */
|
2008-05-20 17:18:38 +02:00
|
|
|
loop_flag = read_32bitBE(0x1c,streamFile);
|
|
|
|
channel_count = read_32bitBE(0xc,streamFile);
|
2008-04-02 19:50:50 +02:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital statistics */
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->num_samples = read_32bitBE(0x10,streamFile);
|
|
|
|
vgmstream->sample_rate = read_32bitBE(0x8,streamFile);
|
2008-04-02 19:50:50 +02:00
|
|
|
/* channels and loop flag are set by allocate_vgmstream */
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->loop_start_sample = read_32bitBE(0x14,streamFile);
|
|
|
|
vgmstream->loop_end_sample = read_32bitBE(0x18,streamFile);
|
2008-04-02 19:50:50 +02:00
|
|
|
|
|
|
|
vgmstream->coding_type = coding_PCM16BE;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->meta_type = meta_GCSW;
|
|
|
|
|
|
|
|
vgmstream->interleave_block_size = 0x8000;
|
|
|
|
|
|
|
|
/* open the file for reading by each channel */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0;i<channel_count;i++) {
|
2018-08-19 22:51:14 +02:00
|
|
|
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
2008-04-02 19:50:50 +02:00
|
|
|
|
|
|
|
if (!vgmstream->ch[i].streamfile) goto fail;
|
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
|
|
|
vgmstream->ch[i].offset=
|
|
|
|
0x20+0x8000*i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|