2008-07-17 16:20:42 +02:00
|
|
|
#include "meta.h"
|
2021-07-29 18:38:07 +02:00
|
|
|
#include "../coding/coding.h"
|
2008-07-17 16:20:42 +02:00
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
/* SFS - from Sting games [Baroque (PS2)] */
|
|
|
|
VGMSTREAM* init_vgmstream_sfs(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
2008-07-17 16:20:42 +02:00
|
|
|
off_t start_offset;
|
2021-07-29 18:38:07 +02:00
|
|
|
int loop_flag, channels, sample_rate;
|
|
|
|
size_t channel_size, loop_start;
|
2008-07-17 16:20:42 +02:00
|
|
|
|
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
/* checks */
|
|
|
|
/* .sfs: bigfile extension (no apparent names) */
|
|
|
|
if (!check_extensions(sf, "sfs"))
|
2008-07-17 16:20:42 +02:00
|
|
|
goto fail;
|
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
if (!is_id32be(0x00,sf, "STER"))
|
|
|
|
goto fail;
|
|
|
|
channel_size = read_u32le(0x04, sf);
|
|
|
|
loop_start = read_u32le(0x08, sf); /* absolute (ex. offset 0x50 for full loops) */
|
|
|
|
/* 0x0c: data size BE */
|
|
|
|
sample_rate = read_s32be(0x10,sf);
|
2008-07-17 16:20:42 +02:00
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
loop_flag = loop_start != 0xFFFFFFFF;
|
|
|
|
channels = 2;
|
2008-07-17 16:20:42 +02:00
|
|
|
start_offset = 0x30;
|
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channels, loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2008-07-17 16:20:42 +02:00
|
|
|
vgmstream->meta_type = meta_SFS;
|
2021-07-29 18:38:07 +02:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
2008-07-17 16:20:42 +02:00
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(channel_size, 1);
|
|
|
|
vgmstream->loop_start_sample = ps_bytes_to_samples(loop_start - start_offset, channels);
|
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
2008-07-17 16:20:42 +02:00
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x10;
|
2008-07-17 16:20:42 +02:00
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
read_string(vgmstream->stream_name,0x10+1, 0x20,sf);
|
2008-07-17 16:20:42 +02:00
|
|
|
|
2021-07-29 18:38:07 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
|
|
|
goto fail;
|
2008-07-17 16:20:42 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2021-07-29 18:38:07 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-07-17 16:20:42 +02:00
|
|
|
return NULL;
|
|
|
|
}
|