2010-01-19 20:40:41 +01:00
|
|
|
#include "meta.h"
|
2019-07-28 14:47:23 +02:00
|
|
|
#include "../coding/coding.h"
|
2010-01-19 20:40:41 +01:00
|
|
|
|
|
|
|
|
2019-07-28 14:47:23 +02:00
|
|
|
/* HIS - Her Interactive games [Nancy Drew series (PC)] */
|
2021-07-29 23:20:43 +02:00
|
|
|
VGMSTREAM * init_vgmstream_his(STREAMFILE *sf) {
|
2010-01-19 20:40:41 +01:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2019-07-28 14:47:23 +02:00
|
|
|
int channel_count, loop_flag = 0, bps, sample_rate, num_samples, version;
|
2010-01-19 20:40:41 +01:00
|
|
|
off_t start_offset;
|
|
|
|
|
|
|
|
|
2019-07-28 14:47:23 +02:00
|
|
|
/* checks */
|
2021-07-29 23:20:43 +02:00
|
|
|
if (!check_extensions(sf, "his"))
|
2019-07-28 14:47:23 +02:00
|
|
|
goto fail;
|
2010-01-19 20:40:41 +01:00
|
|
|
|
2021-07-29 23:20:43 +02:00
|
|
|
if (read_32bitBE(0x00,sf) == 0x48657220) { /* "Her Interactive Sound\x1a" */
|
2019-07-28 14:47:23 +02:00
|
|
|
/* Nancy Drew: Secrets Can Kill (PC) */
|
|
|
|
version = 0;
|
2021-07-29 23:20:43 +02:00
|
|
|
channel_count = read_16bitLE(0x16,sf);
|
|
|
|
sample_rate = read_32bitLE(0x18,sf);
|
2019-07-28 14:47:23 +02:00
|
|
|
/* 0x1c: bitrate */
|
|
|
|
/* 0x20: block size */
|
2021-07-29 23:20:43 +02:00
|
|
|
bps = read_16bitLE(0x22,sf);
|
2010-01-19 20:40:41 +01:00
|
|
|
|
2021-07-29 23:20:43 +02:00
|
|
|
if (read_32bitBE(0x24,sf) != 0x64617461) /* "data" */
|
2019-07-28 14:47:23 +02:00
|
|
|
goto fail;
|
2021-07-29 23:20:43 +02:00
|
|
|
num_samples = pcm_bytes_to_samples(read_32bitLE(0x28,sf), channel_count, bps);
|
2010-01-19 20:40:41 +01:00
|
|
|
|
2019-07-28 14:47:23 +02:00
|
|
|
start_offset = 0x2c;
|
|
|
|
}
|
2021-07-29 23:20:43 +02:00
|
|
|
else if (read_32bitBE(0x00,sf) == 0x48495300) { /* HIS\0 */
|
2019-07-28 14:47:23 +02:00
|
|
|
/* most(?) others */
|
2021-07-29 23:20:43 +02:00
|
|
|
version = read_32bitLE(0x04,sf);
|
2019-07-28 14:47:23 +02:00
|
|
|
/* 0x08: codec */
|
2021-07-29 23:20:43 +02:00
|
|
|
channel_count = read_16bitLE(0x0a,sf);
|
|
|
|
sample_rate = read_32bitLE(0x0c,sf);
|
2019-07-28 14:47:23 +02:00
|
|
|
/* 0x10: bitrate */
|
|
|
|
/* 0x14: block size */
|
2021-07-29 23:20:43 +02:00
|
|
|
bps = read_16bitLE(0x16,sf);
|
2019-07-28 14:47:23 +02:00
|
|
|
|
2021-07-29 23:20:43 +02:00
|
|
|
num_samples = pcm_bytes_to_samples(read_32bitLE(0x18,sf), channel_count, bps); /* true even for Ogg */
|
2019-07-28 14:47:23 +02:00
|
|
|
|
|
|
|
/* later games use "OggS" */
|
|
|
|
if (version == 1)
|
|
|
|
start_offset = 0x1c; /* Nancy Drew: The Final Scene (PC) */
|
2021-07-29 23:20:43 +02:00
|
|
|
else if (version == 2 && read_32bitBE(0x1e,sf) == 0x4F676753)
|
2019-07-28 14:47:23 +02:00
|
|
|
start_offset = 0x1e; /* Nancy Drew: The Haunted Carousel (PC) */
|
2021-07-29 23:20:43 +02:00
|
|
|
else if (version == 2 && read_32bitBE(0x20,sf) == 0x4F676753)
|
2019-07-28 14:47:23 +02:00
|
|
|
start_offset = 0x20; /* Nancy Drew: The Silent Spy (PC) */
|
|
|
|
else
|
2010-03-03 06:14:33 +01:00
|
|
|
goto fail;
|
|
|
|
}
|
2019-07-28 14:47:23 +02:00
|
|
|
else {
|
|
|
|
goto fail;
|
|
|
|
}
|
2010-03-03 06:14:33 +01:00
|
|
|
|
2010-01-19 20:40:41 +01:00
|
|
|
|
2019-07-28 14:47:23 +02:00
|
|
|
if (version == 2) {
|
|
|
|
#ifdef VGM_USE_VORBIS
|
|
|
|
ogg_vorbis_meta_info_t ovmi = {0};
|
|
|
|
|
|
|
|
ovmi.meta_type = meta_HIS;
|
2021-07-29 23:20:43 +02:00
|
|
|
return init_vgmstream_ogg_vorbis_config(sf, start_offset, &ovmi);
|
2019-07-28 14:47:23 +02:00
|
|
|
#else
|
|
|
|
goto fail;
|
|
|
|
#endif
|
|
|
|
}
|
2010-01-19 20:40:41 +01:00
|
|
|
|
2019-07-28 14:47:23 +02:00
|
|
|
/* build the VGMSTREAM */
|
2010-01-19 20:40:41 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->meta_type = meta_HIS;
|
2019-07-28 14:47:23 +02:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = num_samples;
|
2010-01-19 20:40:41 +01:00
|
|
|
|
2019-07-28 14:47:23 +02:00
|
|
|
switch (bps) {
|
|
|
|
case 8:
|
|
|
|
vgmstream->coding_type = coding_PCM8_U;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x01;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
vgmstream->coding_type = coding_PCM16LE;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = 0x02;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto fail;
|
2010-01-19 20:40:41 +01:00
|
|
|
}
|
2019-07-28 14:47:23 +02:00
|
|
|
|
2021-07-29 23:20:43 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
|
2019-07-28 14:47:23 +02:00
|
|
|
goto fail;
|
2010-01-19 20:40:41 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2019-07-28 14:47:23 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2010-01-19 20:40:41 +01:00
|
|
|
return NULL;
|
|
|
|
}
|