2008-08-19 13:34:16 +02:00
|
|
|
#include "meta.h"
|
2008-08-19 16:14:06 +02:00
|
|
|
#include "../layout/layout.h"
|
2018-02-17 12:30:14 +01:00
|
|
|
#include "../coding/coding.h"
|
2008-08-19 13:34:16 +02:00
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
/* XVAS - found in TMNT 2 & TMNT 3 (Xbox) */
|
2008-08-19 13:34:16 +02:00
|
|
|
VGMSTREAM * init_vgmstream_xbox_xvas(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2018-02-17 12:30:14 +01:00
|
|
|
off_t start_offset;
|
|
|
|
int loop_flag, channel_count;
|
|
|
|
size_t data_size;
|
2008-08-19 13:34:16 +02:00
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
/* check extension */
|
|
|
|
if (!check_extensions(streamFile,"xvas"))
|
|
|
|
goto fail;
|
2008-08-19 13:34:16 +02:00
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
if (read_32bitLE(0x00,streamFile) != 0x69 && /* codec */
|
|
|
|
read_32bitLE(0x08,streamFile) != 0x48) /* block size (probably 0x24 for mono) */
|
|
|
|
goto fail;
|
2008-08-19 13:34:16 +02:00
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
start_offset = 0x800;
|
|
|
|
channel_count = read_32bitLE(0x04,streamFile); /* always stereo files */
|
|
|
|
loop_flag = (read_32bitLE(0x14,streamFile) == read_32bitLE(0x24,streamFile));
|
|
|
|
data_size = read_32bitLE(0x24,streamFile);
|
|
|
|
data_size -= (data_size / 0x20000) * 0x20; /* blocks of 0x20000 with padding */
|
2008-08-19 13:34:16 +02:00
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
/* build the VGMSTREAM */
|
2008-08-19 13:34:16 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->sample_rate = read_32bitLE(0x0c,streamFile);
|
2018-02-17 12:30:14 +01:00
|
|
|
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size, vgmstream->channels);
|
|
|
|
if(loop_flag) {
|
|
|
|
size_t loop_size = read_32bitLE(0x10,streamFile);
|
|
|
|
loop_size -= (loop_size / 0x20000) * 0x20;
|
|
|
|
vgmstream->loop_start_sample = xbox_ima_bytes_to_samples(loop_size, vgmstream->channels);
|
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
|
|
|
}
|
2008-08-19 13:34:16 +02:00
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
vgmstream->coding_type = coding_XBOX_IMA;
|
2018-03-29 19:00:04 +02:00
|
|
|
vgmstream->layout_type = layout_blocked_xvas;
|
2008-08-19 13:34:16 +02:00
|
|
|
vgmstream->meta_type = meta_XBOX_XVAS;
|
|
|
|
|
2018-02-17 12:30:14 +01:00
|
|
|
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
|
|
|
goto fail;
|
2008-08-19 13:34:16 +02:00
|
|
|
|
2018-03-29 19:00:04 +02:00
|
|
|
block_update_xvas(start_offset,vgmstream);
|
2008-08-19 13:34:16 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-02-17 12:30:14 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-08-19 13:34:16 +02:00
|
|
|
return NULL;
|
|
|
|
}
|