2008-12-04 21:11:45 +01:00
|
|
|
#include "meta.h"
|
2008-12-10 21:54:10 +01:00
|
|
|
#include "../layout/layout.h"
|
2018-12-21 23:53:02 +01:00
|
|
|
#include "../coding/coding.h"
|
2008-12-04 21:11:45 +01:00
|
|
|
|
2018-12-21 23:53:02 +01:00
|
|
|
/* .VS - from Melbourne House games [Men in Black II (PS2), Grand Prix Challenge (PS2) */
|
2008-12-04 21:11:45 +01:00
|
|
|
VGMSTREAM * init_vgmstream_vs(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2018-12-21 23:53:02 +01:00
|
|
|
int loop_flag, channel_count;
|
2008-12-04 21:11:45 +01:00
|
|
|
|
|
|
|
|
2018-12-21 23:53:02 +01:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "vs"))
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0xC8000000)
|
2008-12-04 21:11:45 +01:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
loop_flag = 0;
|
|
|
|
channel_count = 2;
|
2018-12-21 23:53:02 +01:00
|
|
|
start_offset = 0x08;
|
|
|
|
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2008-12-04 21:11:45 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2018-12-21 23:53:02 +01:00
|
|
|
vgmstream->meta_type = meta_VS;
|
2008-12-04 21:11:45 +01:00
|
|
|
vgmstream->sample_rate = read_32bitLE(0x04,streamFile);
|
|
|
|
vgmstream->coding_type = coding_PSX;
|
2018-12-21 23:53:02 +01:00
|
|
|
vgmstream->layout_type = layout_blocked_vs;
|
2008-12-04 21:58:27 +01:00
|
|
|
|
2018-12-21 23:53:02 +01:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2008-12-04 21:11:45 +01:00
|
|
|
|
2018-12-21 23:53:02 +01:00
|
|
|
/* calc num_samples */
|
|
|
|
{
|
|
|
|
vgmstream->next_block_offset = start_offset;
|
|
|
|
do {
|
|
|
|
block_update(vgmstream->next_block_offset,vgmstream);
|
|
|
|
vgmstream->num_samples += ps_bytes_to_samples(vgmstream->current_block_size, 1);
|
2008-12-04 21:11:45 +01:00
|
|
|
}
|
2018-12-21 23:53:02 +01:00
|
|
|
while (vgmstream->next_block_offset < get_streamfile_size(streamFile));
|
|
|
|
block_update(start_offset, vgmstream);
|
2008-12-04 21:11:45 +01:00
|
|
|
|
2018-12-21 23:53:02 +01:00
|
|
|
}
|
2008-12-04 21:11:45 +01:00
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-12-21 23:53:02 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-12-04 21:11:45 +01:00
|
|
|
return NULL;
|
|
|
|
}
|