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

@ -1,48 +1,48 @@
#include "meta.h" #include "meta.h"
#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 (!is_id32be(0x00,sf, "CRYO"))
if ( !check_extensions(streamFile,"apc") ) goto fail;
goto fail; if (!is_id32be(0x04,sf, "_APC"))
if (read_32bitBE(0x00,streamFile) != 0x4352594F) /* "CRYO" */ goto fail;
goto fail; //if (!is_id32be(0x04,sf, "1.20"))
if (read_32bitBE(0x04,streamFile) != 0x5F415043) /* "_APC" */ // goto fail;
goto fail;
//if (read_32bitBE(0x08,streamFile) != 0x312E3230) /* "1.20" */ if (!check_extensions(sf,"apc"))
// goto fail; goto fail;
/* 0x14/18: L/R hist sample? */ sample_rate = read_s32le(0x10,sf);
/* 0x14/18: L/R hist sample? */
start_offset = 0x20; channels = read_s32le(0x1c,sf) == 0 ? 1 : 2;
data_size = get_streamfile_size(streamFile) - start_offset; loop_flag = 0;
channel_count = read_32bitLE(0x1c,streamFile) == 0 ? 1 : 2; start_offset = 0x20;
loop_flag = 0; 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;
fail: fail:
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }

View File

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