This commit is contained in:
bnnm 2022-07-23 15:15:16 +02:00
parent f87c75299b
commit 84a1053fd3
2 changed files with 111 additions and 106 deletions

View File

@ -2,43 +2,43 @@
#include "../coding/coding.h" #include "../coding/coding.h"
/* APC - from Cryo games [MegaRace 3 (PC)] */ /* APC - from Cryo games [MegaRace 3 (PC)] */
VGMSTREAM * init_vgmstream_apc(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_apc(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; uint32_t start_offset, data_size;
size_t data_size; int loop_flag, channels, sample_rate;
int loop_flag, channel_count;
/* checks */ /* checks */
if ( !check_extensions(streamFile,"apc") ) if (!is_id32be(0x00,sf, "CRYO"))
goto fail; goto fail;
if (read_32bitBE(0x00,streamFile) != 0x4352594F) /* "CRYO" */ if (!is_id32be(0x04,sf, "_APC"))
goto fail; goto fail;
if (read_32bitBE(0x04,streamFile) != 0x5F415043) /* "_APC" */ //if (!is_id32be(0x04,sf, "1.20"))
goto fail;
//if (read_32bitBE(0x08,streamFile) != 0x312E3230) /* "1.20" */
// goto fail; // goto fail;
/* 0x14/18: L/R hist sample? */ if (!check_extensions(sf,"apc"))
goto fail;
start_offset = 0x20; sample_rate = read_s32le(0x10,sf);
data_size = get_streamfile_size(streamFile) - start_offset; /* 0x14/18: L/R hist sample? */
channel_count = read_32bitLE(0x1c,streamFile) == 0 ? 1 : 2; channels = read_s32le(0x1c,sf) == 0 ? 1 : 2;
loop_flag = 0; loop_flag = 0;
start_offset = 0x20;
data_size = get_streamfile_size(sf) - start_offset;
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_APC; vgmstream->meta_type = meta_APC;
vgmstream->sample_rate = read_32bitLE(0x10,streamFile); vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ima_bytes_to_samples(data_size,channel_count); vgmstream->num_samples = ima_bytes_to_samples(data_size, channels);
vgmstream->coding_type = coding_IMA; vgmstream->coding_type = coding_IMA;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;

View File

@ -2,31 +2,36 @@
#include "../coding/coding.h" #include "../coding/coding.h"
/* ASF - Argonaut PC games [Croc 2 (PC), Aladdin: Nasira's Revenge (PC)] */ /* ASF - Argonaut PC games [Croc 2 (PC), Aladdin: Nasira's Revenge (PC)] */
VGMSTREAM * init_vgmstream_asf(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_asf(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; uint32_t start_offset;
int loop_flag, channel_count, version; int loop_flag, channels, type, sample_rate;
/* checks */ /* checks */
if (!is_id32be(0x00,sf, "ASF\0"))
goto fail;
/* .asf: original /* .asf: original
* .lasf: fake for plugins */ * .lasf: fake for plugins */
if (!check_extensions(streamFile, "asf,lasf")) if (!check_extensions(sf, "asf,lasf"))
goto fail; goto fail;
if (read_32bitBE(0x00,streamFile) != 0x41534600) /* "ASF\0" */ if (read_u32le(0x04,sf) != 0x00010002) /* v1.002? */
goto fail; goto fail;
if (read_32bitBE(0x04,streamFile) != 0x02000100) if (read_u32le(0x08,sf) != 0x01 &&
read_u32le(0x0c,sf) != 0x18)
goto fail; goto fail;
if (read_32bitLE(0x08,streamFile) != 0x01 && /* 0x10~18: stream name (same as filename) */
read_32bitLE(0x0c,streamFile) != 0x18 && /* 0x18: non-full size? */
read_32bitLE(0x1c,streamFile) != 0x20) if (read_u32le(0x1c,sf) != 0x20) /* samples per frame? */
goto fail; goto fail;
sample_rate = read_u16le(0x24, sf);
version = read_32bitLE(0x28,streamFile); /* assumed? */ type = read_u32le(0x28,sf); /* assumed? */
switch(version){ switch(type){
case 0x0d: channel_count = 1; break; /* Aladdin: Nasira's Revenge (PC) */ case 0x0d: channels = 1; break; /* Aladdin: Nasira's Revenge (PC) */
case 0x0f: channel_count = 2; break; /* Croc 2 (PC), The Emperor's New Groove (PC) */ case 0x0f: channels = 2; break; /* Croc 2 (PC), The Emperor's New Groove (PC) */
default: goto fail; default: goto fail;
} }
@ -34,21 +39,21 @@ VGMSTREAM * init_vgmstream_asf(STREAMFILE *streamFile) {
start_offset = 0x2c; start_offset = 0x2c;
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag); vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x24, streamFile); vgmstream->sample_rate = sample_rate;
vgmstream->meta_type = meta_ASF; vgmstream->meta_type = meta_ASF;
vgmstream->coding_type = coding_ASF; vgmstream->coding_type = coding_ASF;
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x11; vgmstream->interleave_block_size = 0x11;
vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)/(0x11*channel_count)*32; /* bytes_to_samples */ vgmstream->num_samples = (get_streamfile_size(sf) - start_offset) / (0x11 * channels) * 32; /* bytes_to_samples */
//vgmstream->num_samples = read_32bitLE(0x18,streamFile) * (0x20<<channel_count); /* something like this? */ //vgmstream->num_samples = read_32bitLE(0x18,sf) * (32 << channels); /* something like this? */
read_string(vgmstream->stream_name,0x10, 0x08+1,streamFile); read_string(vgmstream->stream_name,0x10, 0x08+1,sf);
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;