2008-05-06 05:35:37 +02:00
|
|
|
#include "meta.h"
|
2017-08-12 11:46:28 +02:00
|
|
|
#include "../coding/coding.h"
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2017-08-12 11:46:28 +02:00
|
|
|
/* NPFS - found in Namco PS2/PSP games (Tekken 5, Ace Combat 5, Yumeria, Venus & Braves, Ridge Racer PSP) */
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_ps2_npsf(STREAMFILE *streamFile) {
|
2008-05-06 00:45:21 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2017-08-12 11:46:28 +02:00
|
|
|
int loop_flag, channel_count;
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2017-08-12 11:46:28 +02:00
|
|
|
/* check extension, case insensitive (should be .nps as per Venus & Braves data files) */
|
|
|
|
if ( !check_extensions(streamFile,"nps,npsf"))
|
2017-01-07 14:33:10 +01:00
|
|
|
goto fail;
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2017-08-12 11:46:28 +02:00
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x4E505346) /* "NPSF" */
|
2008-05-06 00:45:21 +02:00
|
|
|
goto fail;
|
|
|
|
|
2017-11-10 22:22:04 +01:00
|
|
|
loop_flag = (read_32bitLE(0x14,streamFile) != 0xFFFFFFFF);
|
2017-08-12 11:46:28 +02:00
|
|
|
channel_count = read_32bitLE(0x0C,streamFile);
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2017-11-10 22:22:04 +01:00
|
|
|
/* build the VGMSTREAM */
|
2008-05-06 00:45:21 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2017-11-10 22:22:04 +01:00
|
|
|
vgmstream->channels = read_32bitLE(0x0C,streamFile);
|
2008-05-20 17:18:38 +02:00
|
|
|
vgmstream->sample_rate = read_32bitLE(0x18,streamFile);
|
2017-08-12 11:46:28 +02:00
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(read_32bitLE(0x08,streamFile), 1); /* single channel data */
|
2017-11-10 22:22:04 +01:00
|
|
|
if(vgmstream->loop_flag) {
|
|
|
|
vgmstream->loop_start_sample = read_32bitLE(0x14,streamFile);
|
|
|
|
vgmstream->loop_end_sample = ps_bytes_to_samples(read_32bitLE(0x08,streamFile), 1);
|
|
|
|
}
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2017-08-12 11:46:28 +02:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = read_32bitLE(0x04,streamFile) / 2;
|
2008-05-06 00:45:21 +02:00
|
|
|
vgmstream->meta_type = meta_PS2_NPSF;
|
2017-08-12 11:46:28 +02:00
|
|
|
read_string(vgmstream->stream_name,STREAM_NAME_SIZE, 0x34,streamFile);
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2017-08-12 11:46:28 +02:00
|
|
|
start_offset = (off_t)read_32bitLE(0x10,streamFile);
|
2008-05-06 00:45:21 +02:00
|
|
|
|
|
|
|
|
2017-08-12 11:46:28 +02:00
|
|
|
/* open the file for reading */
|
|
|
|
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
|
|
|
goto fail;
|
2008-05-06 00:45:21 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2017-08-12 11:46:28 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-05-06 00:45:21 +02:00
|
|
|
return NULL;
|
|
|
|
}
|