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
|
|
|
|
2020-03-08 19:37:29 +01:00
|
|
|
/* NPFS - found in Namco NuSound v1 games [Tekken 5 (PS2), Venus & Braves (PS2), Ridge Racer (PSP)] */
|
|
|
|
VGMSTREAM* init_vgmstream_nps(STREAMFILE* sf) {
|
2008-05-06 00:45:21 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2020-03-08 19:37:29 +01:00
|
|
|
uint32_t channel_size;
|
|
|
|
int loop_flag, channel_count, loop_start, sample_rate;
|
|
|
|
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2019-03-11 14:49:29 +01:00
|
|
|
/* checks */
|
2020-03-08 19:37:29 +01:00
|
|
|
/* .nps: referenced extension (ex. Venus & Braves, Ridge Racer data files)
|
2019-03-11 14:49:29 +01:00
|
|
|
* .npsf: header id (Namco Production Sound File?) */
|
2020-03-08 19:37:29 +01:00
|
|
|
if ( !check_extensions(sf,"nps,npsf"))
|
2017-01-07 14:33:10 +01:00
|
|
|
goto fail;
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2020-03-08 19:37:29 +01:00
|
|
|
if (read_u32be(0x00, sf) != 0x4E505346) /* "NPSF" */
|
2008-05-06 00:45:21 +02:00
|
|
|
goto fail;
|
|
|
|
|
2020-03-08 19:37:29 +01:00
|
|
|
/* 0x04: version? (0x00001000 = 1.00?) */
|
|
|
|
channel_size = read_s32le(0x08, sf);
|
|
|
|
channel_count = read_s32le(0x0C, sf);
|
|
|
|
start_offset = read_s32le(0x10, sf); /* interleave? */
|
|
|
|
loop_start = read_s32le(0x14, sf);
|
|
|
|
sample_rate = read_s32le(0x18, sf);
|
|
|
|
/* 0x1c: volume? (0x3e8 = 1000 = max) */
|
|
|
|
/* 0x20: flags? (varies between sound types in a game, but no clear pattern vs other games) */
|
|
|
|
/* 0x24: flag? (0/1) */
|
|
|
|
/* 0x28: null */
|
|
|
|
/* 0x2c: null */
|
|
|
|
/* 0x30: always 0x40 */
|
|
|
|
/* 0x34: name (usually null terminated but may contain garbage) */
|
|
|
|
/* rest: null or 0xFF until start */
|
|
|
|
loop_flag = loop_start != -1;
|
|
|
|
|
2019-03-11 14:49:29 +01:00
|
|
|
|
2017-11-10 22:22:04 +01:00
|
|
|
/* build the VGMSTREAM */
|
2020-03-08 19:37:29 +01:00
|
|
|
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
2008-05-06 00:45:21 +02:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2020-03-08 19:37:29 +01:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(channel_size, 1);
|
|
|
|
vgmstream->loop_start_sample = loop_start;
|
|
|
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
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;
|
2020-03-08 19:37:29 +01:00
|
|
|
vgmstream->interleave_block_size = 0x800;
|
2019-03-11 14:49:29 +01:00
|
|
|
vgmstream->meta_type = meta_NPS;
|
2020-03-08 19:37:29 +01:00
|
|
|
read_string(vgmstream->stream_name, STREAM_NAME_SIZE, 0x34, sf);
|
2008-05-06 00:45:21 +02:00
|
|
|
|
2020-03-08 19:37:29 +01:00
|
|
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
2017-08-12 11:46:28 +02:00
|
|
|
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;
|
|
|
|
}
|