2009-04-19 11:49:08 +02:00
|
|
|
#include "meta.h"
|
2017-07-23 13:16:59 +02:00
|
|
|
#include "../layout/layout.h"
|
|
|
|
#include "../coding/coding.h"
|
2009-04-19 11:49:08 +02:00
|
|
|
|
2017-07-23 13:16:59 +02:00
|
|
|
/* HWAS - found in Vicarious Visions NDS games (Spider-Man 3, Tony Hawk's Downhill Jam, etc) */
|
2009-04-19 11:49:08 +02:00
|
|
|
VGMSTREAM * init_vgmstream_nds_hwas(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2017-07-23 13:16:59 +02:00
|
|
|
int channel_count, loop_flag = 0;
|
2009-04-19 11:49:08 +02:00
|
|
|
|
2018-04-18 20:11:42 +02:00
|
|
|
/* checks */
|
|
|
|
/* .hwas: usually in archives but also found named (ex. Guitar Hero On Tour) */
|
2017-07-23 13:16:59 +02:00
|
|
|
if (!check_extensions(streamFile,"hwas"))
|
|
|
|
goto fail;
|
2009-04-22 03:17:49 +02:00
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x73617768) /* "sawh" */
|
2009-04-19 11:49:08 +02:00
|
|
|
goto fail;
|
|
|
|
|
2017-07-23 13:16:59 +02:00
|
|
|
loop_flag = 1; /* almost all files seem to loop (usually if num_samples != loop_end doesn't loop, but not always) */
|
2009-04-19 11:49:08 +02:00
|
|
|
channel_count = read_32bitLE(0x0C,streamFile);
|
2017-07-23 13:16:59 +02:00
|
|
|
if (channel_count > 1) goto fail; /* unknown block layout when stereo, not seen */
|
|
|
|
|
|
|
|
start_offset = 0x200;
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2009-04-19 11:49:08 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2018-08-26 13:47:48 +02:00
|
|
|
vgmstream->meta_type = meta_NDS_HWAS;
|
2009-04-19 11:49:08 +02:00
|
|
|
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);
|
2017-07-23 13:16:59 +02:00
|
|
|
vgmstream->num_samples = ima_bytes_to_samples(read_32bitLE(0x14,streamFile), channel_count);
|
|
|
|
vgmstream->loop_start_sample = ima_bytes_to_samples(read_32bitLE(0x10,streamFile), channel_count); //assumed, always 0
|
|
|
|
vgmstream->loop_end_sample = ima_bytes_to_samples(read_32bitLE(0x18,streamFile), channel_count);
|
2009-04-19 11:49:08 +02:00
|
|
|
|
2017-11-19 03:34:25 +01:00
|
|
|
vgmstream->coding_type = coding_IMA_int;
|
2018-02-25 16:52:57 +01:00
|
|
|
vgmstream->layout_type = layout_blocked_hwas;
|
2017-07-23 13:16:59 +02:00
|
|
|
vgmstream->full_block_size = read_32bitLE(0x04,streamFile); /* usually 0x2000, 0x4000 or 0x8000 */
|
|
|
|
|
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2009-04-19 11:49:08 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-07-23 13:16:59 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2009-04-19 11:49:08 +02:00
|
|
|
return NULL;
|
|
|
|
}
|