2008-07-17 03:22:23 +02:00
|
|
|
#include "meta.h"
|
2019-03-22 21:12:33 +01:00
|
|
|
#include "../coding/coding.h"
|
2008-07-17 03:22:23 +02:00
|
|
|
|
2019-03-22 21:12:33 +01:00
|
|
|
|
|
|
|
/* IKM - MiCROViSiON PS2 container [Zwei (PS2)] */
|
2020-06-14 15:49:15 +02:00
|
|
|
VGMSTREAM* init_vgmstream_ikm_ps2(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
2008-07-17 03:22:23 +02:00
|
|
|
off_t start_offset;
|
2019-03-22 21:12:33 +01:00
|
|
|
int loop_flag, channel_count;
|
2008-07-17 03:22:23 +02:00
|
|
|
|
|
|
|
|
2019-03-22 21:12:33 +01:00
|
|
|
/* checks */
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!is_id32be(0x00,sf, "IKM\0"))
|
2019-03-22 21:12:33 +01:00
|
|
|
goto fail;
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!check_extensions(sf,"ikm"))
|
2019-03-22 21:12:33 +01:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* 0x20: type 03? */
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!is_id32be(0x40,sf, "AST\0"))
|
|
|
|
goto fail;
|
2019-03-22 21:12:33 +01:00
|
|
|
|
2020-06-14 15:49:15 +02:00
|
|
|
loop_flag = (read_s32le(0x14, sf) > 0);
|
|
|
|
channel_count = read_s32le(0x50, sf);
|
2019-03-22 21:12:33 +01:00
|
|
|
start_offset = 0x800;
|
|
|
|
|
2008-07-17 03:22:23 +02:00
|
|
|
|
2009-01-05 12:58:27 +01:00
|
|
|
/* build the VGMSTREAM */
|
2019-03-22 21:12:33 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
2008-07-17 03:22:23 +02:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2019-03-22 21:12:33 +01:00
|
|
|
vgmstream->meta_type = meta_IKM;
|
2020-06-14 15:49:15 +02:00
|
|
|
vgmstream->sample_rate = read_s32le(0x44, sf);
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(read_s32le(0x4c, sf), channel_count);
|
|
|
|
vgmstream->loop_start_sample = read_s32le(0x14, sf);
|
|
|
|
vgmstream->loop_end_sample = read_s32le(0x18, sf);
|
2008-07-17 03:22:23 +02:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
2019-03-22 21:12:33 +01:00
|
|
|
vgmstream->interleave_block_size = 0x10; /* @0x40 / channels */
|
|
|
|
|
2020-06-14 15:49:15 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
2019-03-22 21:12:33 +01:00
|
|
|
goto fail;
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-06-14 15:49:15 +02:00
|
|
|
/* IKM - MiCROViSiON PC container [Chaos Legion (PC), Legend of Galactic Heroes (PC)] */
|
|
|
|
VGMSTREAM* init_vgmstream_ikm_pc(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
2019-03-22 21:12:33 +01:00
|
|
|
off_t start_offset;
|
|
|
|
|
2008-07-17 03:22:23 +02:00
|
|
|
|
2019-03-22 21:12:33 +01:00
|
|
|
/* checks */
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!is_id32be(0x00,sf, "IKM\0"))
|
2019-03-22 21:12:33 +01:00
|
|
|
goto fail;
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!check_extensions(sf,"ikm"))
|
2019-03-22 21:12:33 +01:00
|
|
|
goto fail;
|
|
|
|
/* 0x20: type 01? */
|
|
|
|
|
2020-06-14 15:49:15 +02:00
|
|
|
/* find "OggS" start */
|
2021-09-27 00:10:28 +02:00
|
|
|
if (is_id32be(0x30,sf, "OggS")) {
|
2020-06-14 15:49:15 +02:00
|
|
|
start_offset = 0x30; /* Chaos Legion (PC) */
|
2021-09-27 00:10:28 +02:00
|
|
|
}
|
|
|
|
else if (is_id32be(0x800,sf, "OggS")) {
|
2020-06-14 15:49:15 +02:00
|
|
|
start_offset = 0x800; /* Legend of Galactic Heroes (PC) */
|
2021-09-27 00:10:28 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-06-14 15:49:15 +02:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-17 03:22:23 +02:00
|
|
|
{
|
2019-03-22 21:12:33 +01:00
|
|
|
ogg_vorbis_meta_info_t ovmi = {0};
|
|
|
|
|
|
|
|
ovmi.meta_type = meta_IKM;
|
2020-06-14 15:49:15 +02:00
|
|
|
ovmi.loop_start = read_s32le(0x14, sf);
|
|
|
|
ovmi.loop_end = read_s32le(0x18, sf);
|
2019-03-22 21:12:33 +01:00
|
|
|
ovmi.loop_end_found = ovmi.loop_end;
|
|
|
|
ovmi.loop_flag = ovmi.loop_end > 0;
|
2020-06-14 15:49:15 +02:00
|
|
|
ovmi.stream_size = read_s32le(0x24, sf);
|
2019-03-22 21:12:33 +01:00
|
|
|
|
2021-07-29 23:20:43 +02:00
|
|
|
vgmstream = init_vgmstream_ogg_vorbis_config(sf, start_offset, &ovmi);
|
2008-07-17 03:22:23 +02:00
|
|
|
}
|
2019-03-22 21:12:33 +01:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IKM - MiCROViSiON PSP container [The Legend of Heroes: A Tear of Vermillion (PSP)] */
|
2020-06-14 15:49:15 +02:00
|
|
|
VGMSTREAM* init_vgmstream_ikm_psp(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
|
|
|
STREAMFILE* temp_sf = NULL;
|
2019-03-22 21:12:33 +01:00
|
|
|
off_t start_offset;
|
|
|
|
size_t data_size;
|
|
|
|
|
|
|
|
|
|
|
|
/* checks */
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!is_id32be(0x00,sf, "IKM\0"))
|
2019-03-22 21:12:33 +01:00
|
|
|
goto fail;
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!check_extensions(sf,"ikm"))
|
2019-03-22 21:12:33 +01:00
|
|
|
goto fail;
|
2021-09-27 00:10:28 +02:00
|
|
|
|
2019-03-22 21:12:33 +01:00
|
|
|
/* 0x20: type 00? */
|
2021-09-27 00:10:28 +02:00
|
|
|
if (!is_id32be(0x800,sf, "RIFF"))
|
|
|
|
goto fail;
|
2019-03-22 21:12:33 +01:00
|
|
|
|
|
|
|
/* loop values (pre-adjusted without encoder delay) at 0x14/18 are found in the RIFF too */
|
2020-06-14 15:49:15 +02:00
|
|
|
data_size = read_s32le(0x24, sf);
|
2019-03-22 21:12:33 +01:00
|
|
|
start_offset = 0x800;
|
|
|
|
|
2020-06-14 15:49:15 +02:00
|
|
|
temp_sf = setup_subfile_streamfile(sf, start_offset, data_size, "at3");
|
|
|
|
if (!temp_sf) goto fail;
|
2019-03-22 21:12:33 +01:00
|
|
|
|
2020-06-14 15:49:15 +02:00
|
|
|
vgmstream = init_vgmstream_riff(temp_sf);
|
2019-03-22 21:12:33 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->meta_type = meta_IKM;
|
2008-07-17 03:22:23 +02:00
|
|
|
|
2020-06-14 15:49:15 +02:00
|
|
|
close_streamfile(temp_sf);
|
2008-07-17 03:22:23 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2020-06-14 15:49:15 +02:00
|
|
|
close_streamfile(temp_sf);
|
2019-03-22 21:12:33 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-07-17 03:22:23 +02:00
|
|
|
return NULL;
|
|
|
|
}
|