2010-03-31 03:57:34 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../util.h"
|
|
|
|
|
|
|
|
/* VSF (from Musashi: Samurai Legend) */
|
|
|
|
VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2018-03-30 03:03:23 +02:00
|
|
|
int loop_flag, channel_count;
|
2010-03-31 03:57:34 +02:00
|
|
|
|
2018-03-30 03:03:23 +02:00
|
|
|
/* check extension, case insensitive */
|
|
|
|
if (!check_extensions(streamFile, "vsf"))
|
|
|
|
goto fail;
|
2010-03-31 03:57:34 +02:00
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x56534600) /* "VSF" */
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
loop_flag = (read_32bitLE(0x1c,streamFile)==0x13);
|
2018-03-30 03:03:23 +02:00
|
|
|
if(read_8bit(0x1C,streamFile)==0x0)
|
|
|
|
channel_count = 1;
|
|
|
|
else
|
|
|
|
channel_count = 2;
|
2010-03-31 03:57:34 +02:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital statistics */
|
|
|
|
start_offset = 0x800;
|
|
|
|
vgmstream->channels = channel_count;
|
|
|
|
vgmstream->sample_rate = 44100;
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->num_samples = read_32bitLE(0x10,streamFile)*28;
|
|
|
|
if (loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = read_32bitLE(0x18,streamFile)*28;
|
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x400;
|
|
|
|
vgmstream->meta_type = meta_PS2_VSF;
|
|
|
|
|
2018-03-30 03:03:23 +02:00
|
|
|
/* open the file for reading */
|
|
|
|
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
|
|
|
goto fail;
|
|
|
|
return vgmstream;
|
2010-03-31 03:57:34 +02:00
|
|
|
|
2018-03-30 03:03:23 +02:00
|
|
|
/* clean up anything we may have opened */
|
2010-03-31 03:57:34 +02:00
|
|
|
fail:
|
2018-03-30 03:03:23 +02:00
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
2010-03-31 03:57:34 +02:00
|
|
|
}
|