Add .hd3+bd3 [Elevator Action Deluxe (PS3), R-Type Dimensions (PS3)]

This commit is contained in:
bnnm 2018-08-14 00:28:15 +02:00
parent 36c6168c27
commit b36646aacf
8 changed files with 129 additions and 1 deletions

View File

@ -67,7 +67,7 @@ static const char* extension_list[] = {
"bar",
"bcstm",
"bcwav",
"bd3", //txth/reserved [Elevator Action Deluxe (PS3)]
"bd3",
"bdsp",
"bfstm",
"bfwav",
@ -1062,6 +1062,7 @@ static const meta_info meta_info_list[] = {
{meta_CKB, "Cricket Audio CKB header"},
{meta_WV6, "Gorilla Systems WV6 header"},
{meta_WAVEBATCH, "Firebrand Games WBAT header"},
{meta_HD3_BD3, "Sony HD3+BD3 header"},
#ifdef VGM_USE_FFMPEG
{meta_FFmpeg, "FFmpeg supported file format"},

View File

@ -512,6 +512,10 @@
RelativePath=".\meta\hca.c"
>
</File>
<File
RelativePath=".\meta\hd3_bd3.c"
>
</File>
<File
RelativePath=".\meta\his.c"
>

View File

@ -243,6 +243,7 @@
<ClCompile Include="meta\h4m.c" />
<ClCompile Include="meta\halpst.c" />
<ClCompile Include="meta\hca.c" />
<ClCompile Include="meta\hd3_bd3.c" />
<ClCompile Include="meta\his.c" />
<ClCompile Include="meta\idsp.c" />
<ClCompile Include="meta\ish_isd.c" />

View File

@ -316,6 +316,9 @@
<ClCompile Include="meta\hca.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\hd3_bd3.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\his.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

115
src/meta/hd3_bd3.c Normal file
View File

@ -0,0 +1,115 @@
#include "meta.h"
#include "../coding/coding.h"
/* HD3+BD3 - Sony PS3 bank format [Elevator Action Deluxe (PS3), R-Type Dimensions (PS3)] */
VGMSTREAM * init_vgmstream_hd3_bd3(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
STREAMFILE * streamHeader = NULL;
off_t start_offset;
int channel_count, loop_flag, sample_rate;
size_t interleave, stream_size;
int total_subsongs, target_subsong = streamFile->stream_index;
/* checks */
if (!check_extensions(streamFile, "bd3"))
goto fail;
streamHeader = open_streamfile_by_ext(streamFile,"hd3");
if (!streamHeader) goto fail;
if (read_32bitBE(0x00,streamHeader) != 0x50334844) /* "P3HD" */
goto fail;
/* 0x04: section size (not including first 0x08) */
/* 0x08: version? 0x00020000 */
/* 0x10: "P3PG" offset (seems mostly empty and contains number of subsongs towards the end) */
/* 0x14: "P3TN" offset (some kind of config?) */
/* 0x18: "P3VA" offset (VAG headers) */
{
off_t section_offset = read_32bitBE(0x18,streamHeader);
off_t header_offset;
size_t section_size;
int i, entries, is_bgm = 0;
if (read_32bitBE(section_offset+0x00,streamHeader) != 0x50335641) /* "P3VA" */
goto fail;
section_size = read_32bitBE(section_offset+0x04,streamHeader); /* (not including first 0x08) */
/* 0x08 always 0x10? */
entries = read_32bitBE(section_offset+0x14,streamHeader) + 1;
if (entries != (section_size-0x18) / 0x10)
goto fail;
/* autodetect use of N bank entries as channels [Elevator Action Deluxe (PS3)] */
if (entries > 1) {
size_t channel_size = read_32bitBE(section_offset+0x20+0x08,streamHeader);
is_bgm = 1;
for (i = 1; i < entries; i++) {
size_t next_size = read_32bitBE(section_offset+0x20+(i*0x10)+0x08,streamHeader);
if (channel_size != next_size) {
is_bgm = 0;
break;
}
}
}
if (is_bgm) {
total_subsongs = 1;
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
header_offset = section_offset+0x20+(0)*0x10;
start_offset = read_32bitBE(header_offset+0x00,streamHeader); /* 0x00 */
sample_rate = read_32bitBE(header_offset+0x04,streamHeader);
stream_size = get_streamfile_size(streamFile);
if (read_32bitBE(header_offset+0x0c,streamHeader) != -1)
goto fail;
channel_count = entries;
interleave = stream_size / channel_count;
}
else {
total_subsongs = entries;
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
header_offset = section_offset+0x20+(target_subsong-1)*0x10;
start_offset = read_32bitBE(header_offset+0x00,streamHeader);
sample_rate = read_32bitBE(header_offset+0x04,streamHeader);
stream_size = read_32bitBE(header_offset+0x08,streamHeader);
if (read_32bitBE(header_offset+0x0c,streamHeader) != -1)
goto fail;
channel_count = 1;
interleave = 0;
}
}
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(stream_size, channel_count);
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size;
vgmstream->meta_type = meta_HD3_BD3;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = (channel_count == 1) ? layout_none : layout_interleave;
vgmstream->interleave_block_size = interleave;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
close_streamfile(streamHeader);
return vgmstream;
fail:
close_streamfile(streamHeader);
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -769,4 +769,6 @@ VGMSTREAM * init_vgmstream_str_wav(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_hd3_bd3(STREAMFILE *streamFile);
#endif /*_META_H*/

View File

@ -421,6 +421,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_wv6,
init_vgmstream_str_wav,
init_vgmstream_wavebatch,
init_vgmstream_hd3_bd3,
init_vgmstream_txth, /* should go at the end (lower priority) */
#ifdef VGM_USE_FFMPEG

View File

@ -697,6 +697,7 @@ typedef enum {
meta_CKB, /* Cricket Audio bank [Fire Emblem Heroes (Android), Mega Man 1-6 (Android)] */
meta_WV6, /* Gorilla Systems PC games */
meta_WAVEBATCH, /* Firebrand Games */
meta_HD3_BD3, /* Sony PS3 bank */
#ifdef VGM_USE_FFMPEG
meta_FFmpeg,