2008-02-13 15:31:21 +01:00
|
|
|
#include <math.h>
|
2008-05-06 05:35:37 +02:00
|
|
|
#include "meta.h"
|
2008-02-13 15:31:21 +01:00
|
|
|
#include "../util.h"
|
|
|
|
|
2018-03-08 22:56:06 +01:00
|
|
|
/* DTK - headerless Nintendo DTK file [Harvest Moon - Another Wonderful Life (GC), XGRA (GC)] */
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_ngc_adpdtk(STREAMFILE *streamFile) {
|
2008-02-13 15:31:21 +01:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2017-07-15 11:27:43 +02:00
|
|
|
off_t start_offset = 0;
|
|
|
|
int channel_count = 2, loop_flag = 0; /* always stereo, no loop */
|
2008-02-13 15:31:21 +01:00
|
|
|
|
2018-03-08 22:56:06 +01:00
|
|
|
/* checks */
|
|
|
|
/* dtk: standard [XGRA (GC)], adp: standard [Harvest Moon AWL (GC)], wav/lwav: Alien Hominid (GC) */
|
|
|
|
if ( !check_extensions(streamFile,"dtk,adp,wav,lwav"))
|
2017-07-15 11:27:43 +02:00
|
|
|
goto fail;
|
|
|
|
|
2018-03-08 22:56:06 +01:00
|
|
|
/* files have no header, and the ext is common, so all we can do is look for valid first frames */
|
|
|
|
if (check_extensions(streamFile,"adp,wav,lwav")) {
|
2017-07-15 11:27:43 +02:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < 10; i++) { /* try a bunch of frames */
|
|
|
|
if (read_8bit(0x00 + i*0x20,streamFile) != read_8bit(0x02 + i*0x20,streamFile) ||
|
|
|
|
read_8bit(0x01 + i*0x20,streamFile) != read_8bit(0x03 + i*0x20,streamFile))
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
2008-02-13 15:31:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2017-07-15 11:27:43 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
2008-02-13 15:31:21 +01:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2017-07-15 11:27:43 +02:00
|
|
|
vgmstream->num_samples = get_streamfile_size(streamFile) / 32 * 28;
|
2008-02-13 15:31:21 +01:00
|
|
|
vgmstream->sample_rate = 48000;
|
|
|
|
vgmstream->coding_type = coding_NGC_DTK;
|
2017-01-08 01:09:20 +01:00
|
|
|
vgmstream->layout_type = layout_none;
|
2008-02-13 15:31:21 +01:00
|
|
|
vgmstream->meta_type = meta_NGC_ADPDTK;
|
|
|
|
|
2008-05-20 22:19:46 +02:00
|
|
|
|
2017-07-15 11:27:43 +02:00
|
|
|
/* open the file for reading */
|
|
|
|
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
|
|
|
goto fail;
|
2008-02-13 15:31:21 +01:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-07-15 11:27:43 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-02-13 15:31:21 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|