2008-07-12 17:20:39 +02:00
|
|
|
#include "meta.h"
|
2023-07-08 10:52:28 +02:00
|
|
|
#include "../coding/coding.h"
|
|
|
|
|
|
|
|
/* hgC1 - from Knights of the Temple 2 (PS2) */
|
|
|
|
VGMSTREAM* init_vgmstream_hgc1(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
|
|
|
uint32_t start_offset;
|
|
|
|
int channels, loop_flag = 0;
|
|
|
|
|
|
|
|
/* checks */
|
|
|
|
if (!is_id32be(0x00,sf, "hgC1"))
|
|
|
|
return NULL;
|
|
|
|
if (!is_id32be(0x04,sf, "strm"))
|
|
|
|
return NULL;
|
|
|
|
if (!check_extensions(sf,"str"))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
start_offset = 0x20;
|
|
|
|
loop_flag = 0;
|
|
|
|
channels = read_s32le(0x08,sf); /* always stereo? */
|
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);
|
2008-07-12 17:20:39 +02:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
vgmstream->meta_type = meta_HGC1;
|
|
|
|
vgmstream->sample_rate = read_s32le(0x10,sf);
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(read_u32le(0x0C,sf) * 0x10, 1); /* mono frames*/
|
2008-07-12 17:20:39 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
2008-07-12 17:20:39 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x10;
|
|
|
|
|
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;
|
|
|
|
}
|