vgmstream/src/meta/svag_snk.c

47 lines
1.4 KiB
C
Raw Normal View History

2016-10-27 23:21:12 +02:00
#include "meta.h"
#include "../util.h"
2020-07-16 22:07:20 +02:00
/* .SVAG - from SNK games [World Heroes Anthology (PS2), Fatal Fury Battle Archives 2 (PS2)] */
VGMSTREAM* init_vgmstream_svag_snk(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag, channel_count, loop_start_block, loop_end_block;
/* checks */
if (!check_extensions(sf, "svag"))
goto fail;
if (read_32bitBE(0x00,sf) != 0x5641476D) /* "VAGm" */
2016-10-27 23:21:12 +02:00
goto fail;
2020-07-16 22:07:20 +02:00
channel_count = read_32bitLE(0x0c,sf);
loop_start_block = read_32bitLE(0x18,sf);
loop_end_block = read_32bitLE(0x1c,sf);
2016-10-30 10:36:29 +01:00
loop_flag = loop_end_block > 0; /* loop_start_block can be 0 */
2020-07-16 22:07:20 +02:00
start_offset = 0x20;
2016-10-27 23:21:12 +02:00
/* build the VGMSTREAM */
2020-07-16 22:07:20 +02:00
vgmstream = allocate_vgmstream(channel_count, loop_flag);
2016-10-27 23:21:12 +02:00
if (!vgmstream) goto fail;
2020-07-16 22:07:20 +02:00
vgmstream->meta_type = meta_SVAG_SNK;
vgmstream->sample_rate = read_32bitLE(0x08,sf);
vgmstream->num_samples = read_32bitLE(0x10,sf) * 28; /* size in blocks */
vgmstream->loop_start_sample = loop_start_block * 28;
vgmstream->loop_end_sample = loop_end_block * 28;
2016-10-27 23:21:12 +02:00
2020-07-16 22:07:20 +02:00
vgmstream->coding_type = coding_PSX;
2016-10-27 23:21:12 +02:00
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x10;
2020-07-16 22:07:20 +02:00
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
2016-10-27 23:21:12 +02:00
return vgmstream;
fail:
2020-07-16 22:07:20 +02:00
close_vgmstream(vgmstream);
2016-10-27 23:21:12 +02:00
return NULL;
}