diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 700845a5..43094807 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -832,6 +832,10 @@ RelativePath=".\meta\kraw.c" > + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 923c154b..417e23b7 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -193,6 +193,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index b7770b0b..376800e7 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -1747,6 +1747,9 @@ meta\Source Files + + meta\Source Files + meta\Source Files diff --git a/src/meta/ktsc.c b/src/meta/ktsc.c new file mode 100644 index 00000000..e438075c --- /dev/null +++ b/src/meta/ktsc.c @@ -0,0 +1,60 @@ +#include "meta.h" +#include "../coding/coding.h" +#include "../layout/layout.h" + + +/* KTSC - Koei Tecmo KTSR container */ +VGMSTREAM* init_vgmstream_ktsc(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + STREAMFILE *temp_sf = NULL; + int target_subsong = sf->stream_index, total_subsongs; + off_t offset, subfile_offset; + size_t subfile_size; + + + /* checks */ + /* .ktsl2asbin: common [Atelier Ryza (PC)] */ + if (!check_extensions(sf, "ktsl2asbin")) + goto fail; + + /* KTSC is a container of KTSRs, but can't be extracted easily as they use absolute pointers to the + * same stream companion file. KTSRs may have subsongs, but only seem to have 1, so use KTSC's subsongs. */ + if (read_u32be(0x00, sf) != 0x4B545343) /* "KTSC" */ + goto fail; + if (read_u32be(0x04, sf) != 0x01000001) /* version? */ + goto fail; + + if (target_subsong == 0) target_subsong = 1; + total_subsongs = read_u32le(0x08, sf); + if (target_subsong > total_subsongs) + goto fail; + + /* 0x0c: CRC(?) table start */ + offset = read_u32le(0x10, sf); + /* 0x14: file size */ + /* 0x18: header end */ + /* 0x1c: null */ + /* 0x20+: CRC(?) table, 1 entry per file */ + + subfile_offset = read_u32le(offset + 0x04 * (target_subsong - 1), sf); + subfile_size = read_u32le(subfile_offset + 0x1c, sf); /* from header, meh */ + + temp_sf = setup_subfile_streamfile(sf, subfile_offset, subfile_size, NULL); + if (!temp_sf) goto fail; + + temp_sf->stream_index = 1; + vgmstream = init_vgmstream_ktsr(temp_sf); + if (!vgmstream) goto fail; + + if (vgmstream->num_streams > 1) + goto fail; + vgmstream->num_streams = total_subsongs; + + close_streamfile(temp_sf); + return vgmstream; + +fail: + close_streamfile(temp_sf); + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/ktsr.c b/src/meta/ktsr.c index 63223977..83a1f1a5 100644 --- a/src/meta/ktsr.c +++ b/src/meta/ktsr.c @@ -312,6 +312,7 @@ static int parse_ktsr_subfile(ktsr_header* ktsr, STREAMFILE* sf, off_t offset) { switch(type) { /* hash-id? */ case 0x38D0437D: /* external [Nioh (PC), Atelier Ryza (PC)] */ + case 0xDF92529F: /* external [Atelier Ryza (PC)] */ /* 08 subtype? (ex. 0x522B86B9) * 0c channels * 10 ? (always 0x002706B8) diff --git a/src/meta/meta.h b/src/meta/meta.h index 8063e203..763138a8 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -907,4 +907,6 @@ VGMSTREAM* init_vgmstream_kat(STREAMFILE* sf); VGMSTREAM* init_vgmstream_pcm_success(STREAMFILE* sf); +VGMSTREAM* init_vgmstream_ktsc(STREAMFILE* sf); + #endif /*_META_H*/ diff --git a/src/vgmstream.c b/src/vgmstream.c index 4e845683..308e1a42 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -501,6 +501,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_mups, init_vgmstream_kat, init_vgmstream_pcm_success, + init_vgmstream_ktsc, /* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */ init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */