2008-05-06 05:35:37 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../layout/layout.h"
|
2008-03-04 01:46:55 +01:00
|
|
|
#include "../util.h"
|
|
|
|
|
2018-08-26 13:48:14 +02:00
|
|
|
/* .AST - from Nintendo games [Super Mario Galaxy (Wii), Pac-Man Vs (GC)] */
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_ast(STREAMFILE *streamFile) {
|
2008-03-04 01:46:55 +01:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2018-08-26 13:48:14 +02:00
|
|
|
off_t start_offset;
|
|
|
|
int loop_flag, channel_count, codec;
|
2008-03-04 01:46:55 +01:00
|
|
|
|
|
|
|
|
2018-08-26 13:48:14 +02:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "ast"))
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x5354524D) /* "STRM" */
|
2008-03-04 01:46:55 +01:00
|
|
|
goto fail;
|
2018-08-26 13:48:14 +02:00
|
|
|
if (read_16bitBE(0x0a,streamFile) != 0x10) /* ? */
|
2008-03-04 01:46:55 +01:00
|
|
|
goto fail;
|
|
|
|
|
2018-08-26 13:48:14 +02:00
|
|
|
if (read_32bitBE(0x04,streamFile)+0x40 != get_streamfile_size(streamFile))
|
|
|
|
goto fail;
|
|
|
|
codec = read_16bitBE(0x08,streamFile);
|
|
|
|
channel_count = read_16bitBE(0x0c,streamFile);
|
|
|
|
loop_flag = read_16bitBE(0x0e,streamFile);
|
|
|
|
//max_block = read_32bitBE(0x20,streamFile);
|
2008-03-04 01:46:55 +01:00
|
|
|
|
2018-08-26 13:48:14 +02:00
|
|
|
start_offset = 0x40;
|
|
|
|
if (read_32bitBE(start_offset,streamFile) != 0x424C434B) /* "BLCK" */
|
|
|
|
goto fail;
|
2008-03-04 01:46:55 +01:00
|
|
|
|
|
|
|
|
2018-08-26 13:48:14 +02:00
|
|
|
/* build the VGMSTREAM */
|
2008-03-04 01:46:55 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2018-08-26 13:48:14 +02:00
|
|
|
vgmstream->meta_type = meta_AST;
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->sample_rate = read_32bitBE(0x10,streamFile);
|
2018-08-26 13:48:14 +02:00
|
|
|
vgmstream->num_samples = read_32bitBE(0x14,streamFile);
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->loop_start_sample = read_32bitBE(0x18,streamFile);
|
|
|
|
vgmstream->loop_end_sample = read_32bitBE(0x1c,streamFile);
|
2008-03-04 01:46:55 +01:00
|
|
|
|
2018-03-29 19:00:04 +02:00
|
|
|
vgmstream->layout_type = layout_blocked_ast;
|
2018-08-26 13:48:14 +02:00
|
|
|
switch (codec) {
|
|
|
|
case 0x00: /* , Pikmin 2 (GC) */
|
|
|
|
vgmstream->coding_type = coding_NGC_AFC;
|
|
|
|
break;
|
|
|
|
case 0x01: /* Mario Kart: Double Dash!! (GC) */
|
|
|
|
vgmstream->coding_type = coding_PCM16BE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
2008-03-04 01:46:55 +01:00
|
|
|
}
|
|
|
|
|
2018-08-26 13:48:14 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2008-03-04 01:46:55 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-08-26 13:48:14 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-03-04 01:46:55 +01:00
|
|
|
return NULL;
|
|
|
|
}
|