2008-05-06 05:35:37 +02:00
|
|
|
#include "meta.h"
|
2008-03-03 22:38:11 +01:00
|
|
|
#include "../util.h"
|
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
|
|
|
|
/* .AFC - from Nintendo games [Super Mario Sunshine (GC), The Legend of Zelda: Wind Waker (GC)] */
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_afc(STREAMFILE *streamFile) {
|
2008-03-03 22:38:11 +01:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2019-11-02 16:10:23 +01:00
|
|
|
off_t start_offset;
|
|
|
|
int loop_flag, channel_count;
|
2008-03-03 22:38:11 +01:00
|
|
|
|
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
/* checks */
|
|
|
|
/* .afc: common
|
|
|
|
* .stx: Pikmin (GC) */
|
|
|
|
if (!check_extensions(streamFile, "afc,stx"))
|
|
|
|
goto fail;
|
2008-03-03 22:38:11 +01:00
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
if (read_u32be(0x00, streamFile) > get_streamfile_size(streamFile)) /* size without padding */
|
2008-07-01 18:11:59 +02:00
|
|
|
goto fail;
|
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
if (read_u16be(0x0a, streamFile) != 4) /* bps? */
|
|
|
|
goto fail;
|
|
|
|
if (read_u16be(0x0c, streamFile) != 16) /* samples per frame? */
|
|
|
|
goto fail;
|
|
|
|
/* 0x0e: always 0x1E? */
|
2008-03-03 22:38:11 +01:00
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
channel_count = 2;
|
|
|
|
loop_flag = read_s32be(0x10, streamFile);
|
|
|
|
start_offset = 0x20;
|
2008-03-03 22:38:11 +01:00
|
|
|
|
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
/* build the VGMSTREAM */
|
2008-03-03 22:38:11 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
vgmstream->meta_type = meta_AFC;
|
|
|
|
vgmstream->num_samples = read_s32be(0x04, streamFile);
|
|
|
|
vgmstream->sample_rate = read_u16be(0x08, streamFile);
|
|
|
|
vgmstream->loop_start_sample = read_s32be(0x14, streamFile);
|
2008-03-03 22:38:11 +01:00
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
|
|
|
|
|
|
|
vgmstream->coding_type = coding_NGC_AFC;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
2019-11-02 16:10:23 +01:00
|
|
|
vgmstream->interleave_block_size = 0x09;
|
2008-03-03 22:38:11 +01:00
|
|
|
|
2019-11-02 16:10:23 +01:00
|
|
|
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
|
|
|
goto fail;
|
2008-03-03 22:38:11 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2019-11-02 16:10:23 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-03-03 22:38:11 +01:00
|
|
|
return NULL;
|
|
|
|
}
|