2008-07-12 17:20:39 +02:00
|
|
|
#include "meta.h"
|
2023-07-08 10:52:28 +02:00
|
|
|
#include "../coding/coding.h"
|
2008-07-12 17:20:39 +02:00
|
|
|
|
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
/* .XSS - found in Dino Crisis 3 (Xbox) */
|
|
|
|
VGMSTREAM* init_vgmstream_xss(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
|
|
|
uint32_t start_offset;
|
|
|
|
int channels, loop_flag, sample_rate;
|
2008-07-12 17:20:39 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
/* checks */
|
|
|
|
/* 00: name + garbage data up to ?
|
|
|
|
* (due to garbage it's hard which values are from this header, but these seem consistent) */
|
|
|
|
if (read_u32le(0x0c,sf) != 0x3a)
|
|
|
|
return NULL;
|
|
|
|
if (read_u32le(0x10,sf) != 0x00)
|
|
|
|
return NULL;
|
2009-01-05 12:58:27 +01:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
if (!check_extensions(sf,"xss"))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* some floats and stuff up to 0x100, then some sizes, then RIFF fmt-like header */
|
2008-07-12 17:20:39 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
uint32_t head_offset = 0x140;
|
|
|
|
if (read_u32le(head_offset+0x00, sf) != 0x40)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
loop_flag = (read_u32le(head_offset + 0x04,sf) != 0);
|
|
|
|
if (read_u16le(head_offset + 0x0c,sf) != 0x01)
|
|
|
|
return NULL;
|
|
|
|
channels = read_u16le(head_offset + 0x0E,sf);
|
|
|
|
sample_rate = read_u32le(head_offset + 0x10,sf);
|
|
|
|
/* 14: bitrate */
|
|
|
|
/* 18: block size */
|
|
|
|
if (read_u16le(head_offset + 0x1A,sf) != 0x10)
|
|
|
|
return NULL;
|
2008-07-12 17:20:39 +02:00
|
|
|
|
|
|
|
start_offset = 0x800;
|
2023-07-08 10:52:28 +02:00
|
|
|
|
2008-07-12 17:20:39 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channels,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
2009-01-05 12:58:27 +01:00
|
|
|
|
2008-07-12 17:20:39 +02:00
|
|
|
vgmstream->meta_type = meta_XSS;
|
2023-07-08 10:52:28 +02:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = pcm16_bytes_to_samples(get_streamfile_size(sf) - start_offset, channels);
|
|
|
|
vgmstream->loop_start_sample = pcm16_bytes_to_samples(read_u32le(head_offset + 0x04,sf), channels);
|
|
|
|
vgmstream->loop_end_sample = pcm16_bytes_to_samples(read_u32le(head_offset + 0x08,sf), channels);
|
2008-07-12 17:20:39 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
vgmstream->coding_type = coding_PCM16LE;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x2;
|
2008-07-12 17:20:39 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
|
|
|
goto fail;
|
2008-07-12 17:20:39 +02:00
|
|
|
return vgmstream;
|
|
|
|
fail:
|
2023-07-08 10:52:28 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-07-12 17:20:39 +02:00
|
|
|
return NULL;
|
|
|
|
}
|