vgmstream/src/meta/tgc.c

43 lines
923 B
C
Raw Normal View History

2020-01-11 11:52:24 +01:00
#include "meta.h"
#include "../coding/coding.h"
/* Tiger Game.com ADPCM file */
VGMSTREAM* init_vgmstream_tgc(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
uint16_t size;
off_t start_offset;
2020-01-11 11:52:24 +01:00
2020-01-11 12:33:27 +01:00
/* checks */
if (read_u8(0x00, sf) != 0)
goto fail;
if (!check_extensions(sf, "4"))
2020-01-11 12:33:27 +01:00
goto fail;
2020-01-11 11:52:24 +01:00
size = read_u16be(0x01, sf);
if (size != get_streamfile_size(sf))
goto fail;
start_offset = 0x03;
2020-01-11 12:33:27 +01:00
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(1, 0);
if (!vgmstream) goto fail;
2020-01-11 11:52:24 +01:00
2020-01-11 12:33:27 +01:00
vgmstream->sample_rate = 8000;
vgmstream->num_samples = (size - 0x03) * 2;
2020-01-11 12:33:27 +01:00
vgmstream->meta_type = meta_TGC;
vgmstream->layout_type = layout_none;
vgmstream->coding_type = coding_TGC;
2020-01-11 11:52:24 +01:00
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
2020-01-11 12:33:27 +01:00
goto fail;
2020-01-11 11:52:24 +01:00
2020-01-11 12:33:27 +01:00
return vgmstream;
2020-01-11 11:52:24 +01:00
fail:
2020-01-11 12:33:27 +01:00
close_vgmstream(vgmstream);
return NULL;
2020-01-12 08:00:44 +01:00
}