2008-07-18 21:35:29 +02:00
|
|
|
#include "meta.h"
|
|
|
|
|
2017-11-15 23:26:38 +01:00
|
|
|
/* DVI - from Konami KCE Nayoga SAT games (Castlevania Symphony of the Night, Jikkyou Oshaberi Parodius - Forever with Me) */
|
|
|
|
VGMSTREAM * init_vgmstream_sat_dvi(STREAMFILE *streamFile) {
|
2008-07-18 21:35:29 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2017-11-15 23:26:38 +01:00
|
|
|
int loop_flag, channel_count;
|
2008-07-18 21:35:29 +02:00
|
|
|
|
2017-11-15 23:26:38 +01:00
|
|
|
/* check extension (.pcm: original, .dvi: renamed to header id) */
|
|
|
|
if ( !check_extensions(streamFile,"pcm,dvi") )
|
|
|
|
goto fail;
|
2008-07-18 21:35:29 +02:00
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x4456492E) /* "DVI." */
|
|
|
|
goto fail;
|
|
|
|
|
2017-11-15 23:26:38 +01:00
|
|
|
start_offset = read_32bitBE(0x04,streamFile);
|
|
|
|
loop_flag = (read_32bitBE(0x0C,streamFile) != 0xFFFFFFFF);
|
|
|
|
channel_count = 2; /* no mono files seem to exists */
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2008-07-18 21:35:29 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->sample_rate = 44100;
|
|
|
|
vgmstream->num_samples = read_32bitBE(0x08,streamFile);
|
2017-11-15 23:26:38 +01:00
|
|
|
vgmstream->loop_start_sample = read_32bitBE(0x0C,streamFile);
|
|
|
|
vgmstream->loop_end_sample = read_32bitBE(0x08,streamFile);
|
2008-07-18 21:35:29 +02:00
|
|
|
|
2017-11-15 23:26:38 +01:00
|
|
|
vgmstream->coding_type = coding_DVI_IMA_int;
|
2008-07-18 21:35:29 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
2017-11-17 19:12:28 +01:00
|
|
|
vgmstream->interleave_block_size = 0x4;
|
2017-11-15 23:26:38 +01:00
|
|
|
vgmstream->meta_type = meta_SAT_DVI;
|
2008-07-18 21:35:29 +02:00
|
|
|
|
2017-11-15 23:26:38 +01:00
|
|
|
/* at 0x10 (L) / 0x20 (R): probably ADPCM loop history @+0x00 and step @+0x17 (not init values) */
|
2008-07-18 21:35:29 +02:00
|
|
|
|
2017-11-15 23:26:38 +01:00
|
|
|
/* open the file for reading */
|
|
|
|
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
|
|
|
goto fail;
|
2017-11-17 19:12:28 +01:00
|
|
|
|
|
|
|
/* for some reason right channel goes first (tested in SOTN vs emu and PS/OST version), swap offsets */
|
|
|
|
if (channel_count == 2) {
|
|
|
|
off_t temp = vgmstream->ch[0].offset;
|
|
|
|
vgmstream->ch[0].channel_start_offset =
|
|
|
|
vgmstream->ch[0].offset = vgmstream->ch[1].offset;
|
|
|
|
vgmstream->ch[1].channel_start_offset =
|
|
|
|
vgmstream->ch[1].offset = temp;
|
|
|
|
}
|
|
|
|
|
2008-07-18 21:35:29 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
2008-07-18 22:12:52 +02:00
|
|
|
}
|