2008-12-18 07:51:26 +01:00
|
|
|
#include "meta.h"
|
2008-12-18 08:33:13 +01:00
|
|
|
#include "../layout/layout.h"
|
2008-12-18 07:51:26 +01:00
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
/* FILp (Resident Evil - Dead Aim) */
|
|
|
|
VGMSTREAM * init_vgmstream_filp(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2013-05-27 05:55:50 +02:00
|
|
|
char filename[PATH_LIMIT];
|
2008-12-18 07:51:26 +01:00
|
|
|
off_t start_offset;
|
|
|
|
int loop_flag = 0;
|
2017-11-10 22:22:04 +01:00
|
|
|
int channel_count;
|
|
|
|
int i;
|
2008-12-18 07:51:26 +01:00
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
|
|
|
if (strcasecmp("filp",filename_extension(filename))) goto fail;
|
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x46494C70) /* "FILp" */
|
|
|
|
goto fail;
|
2017-11-10 22:22:04 +01:00
|
|
|
if (read_32bitBE(0x100,streamFile) != 0x56414770) /* "VAGp" */
|
2008-12-18 07:51:26 +01:00
|
|
|
goto fail;
|
2017-11-10 22:22:04 +01:00
|
|
|
if (read_32bitBE(0x130,streamFile) != 0x56414770) /* "VAGp" */
|
|
|
|
goto fail;
|
|
|
|
if (get_streamfile_size(streamFile) != read_32bitLE(0xC,streamFile))
|
2008-12-18 07:51:26 +01:00
|
|
|
goto fail;
|
|
|
|
|
2008-12-18 20:44:40 +01:00
|
|
|
loop_flag = (read_32bitLE(0x34,streamFile) == 0);
|
2008-12-18 07:51:26 +01:00
|
|
|
channel_count = read_32bitLE(0x4,streamFile);
|
|
|
|
|
2017-11-10 22:22:04 +01:00
|
|
|
/* build the VGMSTREAM */
|
2008-12-18 07:51:26 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2017-11-10 22:22:04 +01:00
|
|
|
/* fill in the vital statistics */
|
2008-12-18 07:51:26 +01:00
|
|
|
start_offset = 0x0;
|
2017-11-10 22:22:04 +01:00
|
|
|
vgmstream->channels = channel_count;
|
2008-12-18 07:51:26 +01:00
|
|
|
vgmstream->sample_rate = read_32bitLE(0x110,streamFile);
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
2018-03-29 19:00:04 +02:00
|
|
|
vgmstream->layout_type = layout_blocked_filp;
|
2008-12-18 07:51:26 +01:00
|
|
|
vgmstream->meta_type = meta_FILP;
|
|
|
|
|
|
|
|
/* open the file for reading */
|
|
|
|
{
|
|
|
|
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;
|
2017-11-10 22:22:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-29 19:00:04 +02:00
|
|
|
block_update_filp(start_offset,vgmstream);
|
2008-12-18 20:24:15 +01:00
|
|
|
vgmstream->num_samples = read_32bitLE(0x10C,streamFile)/16*28;
|
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = 0;
|
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
|
|
|
}
|
2008-12-18 07:51:26 +01:00
|
|
|
|
2017-11-10 22:22:04 +01:00
|
|
|
|
2008-12-18 20:24:15 +01:00
|
|
|
return vgmstream;
|
2008-12-18 07:51:26 +01:00
|
|
|
|
|
|
|
/* clean up anything we may have opened */
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|