2010-01-26 18:57:49 +01:00
|
|
|
#include "meta.h"
|
2017-05-20 01:26:57 +02:00
|
|
|
#include "../coding/coding.h"
|
2010-01-26 18:57:49 +01:00
|
|
|
|
2021-10-09 12:51:33 +02:00
|
|
|
/* AST - from MicroVision lib games [P.T.O. IV (PS2), Naval Ops: Warship Gunner (PS2)] */
|
|
|
|
VGMSTREAM* init_vgmstream_ast_mv(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
|
|
|
uint32_t start_offset, data_size, check;
|
|
|
|
int loop_flag, channels, interleave, sample_rate;
|
|
|
|
|
|
|
|
/* checks */
|
|
|
|
if (!is_id32be(0x00,sf, "AST\0"))
|
|
|
|
goto fail;
|
2010-01-26 18:57:49 +01:00
|
|
|
|
2021-10-09 12:51:33 +02:00
|
|
|
if (!check_extensions(sf,"ast"))
|
2010-01-26 18:57:49 +01:00
|
|
|
goto fail;
|
|
|
|
|
2021-10-09 12:51:33 +02:00
|
|
|
channels = 2;
|
|
|
|
sample_rate = read_s32le(0x04, sf);
|
|
|
|
interleave = read_u32le(0x08,sf);
|
|
|
|
data_size = read_u32le(0x0c,sf); /* may have garbage */
|
|
|
|
check = read_u32be(0x10, sf);
|
|
|
|
/* rest: null/garbage */
|
2010-05-05 04:39:47 +02:00
|
|
|
|
|
|
|
loop_flag = 0;
|
2021-10-09 12:51:33 +02:00
|
|
|
start_offset = 0x800;
|
|
|
|
|
|
|
|
/* there is a variation in .ikm (Zwei), with loops and different start offset */
|
|
|
|
if (check != 0x20002000 && /* NO:WG (garbage up to start) */
|
|
|
|
check != 0x00000000) /* PTO4 */
|
|
|
|
goto fail;
|
|
|
|
|
2010-05-05 04:39:47 +02:00
|
|
|
|
2017-05-20 01:26:57 +02:00
|
|
|
/* build the VGMSTREAM */
|
2021-10-09 12:51:33 +02:00
|
|
|
vgmstream = allocate_vgmstream(channels, loop_flag);
|
2010-01-26 18:57:49 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2021-10-09 12:51:33 +02:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(data_size - start_offset, channels);
|
|
|
|
vgmstream->interleave_block_size = interleave;
|
2010-05-05 04:39:47 +02:00
|
|
|
|
2017-05-20 01:26:57 +02:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
2021-10-09 12:51:33 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->meta_type = meta_AST_MV;
|
2010-01-26 18:57:49 +01:00
|
|
|
|
2021-10-09 12:51:33 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
2017-05-20 01:26:57 +02:00
|
|
|
goto fail;
|
2010-01-26 18:57:49 +01:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-05-20 01:26:57 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2010-01-26 18:57:49 +01:00
|
|
|
return NULL;
|
|
|
|
}
|