Add Success PCM [Metal Saga (PS2), Duel Masters: RoSD (PS2)]

This commit is contained in:
bnnm 2020-06-06 16:15:06 +02:00
parent e5e0076f37
commit 3ea177e1d7
8 changed files with 81 additions and 0 deletions

View File

@ -1299,6 +1299,7 @@ static const meta_info meta_info_list[] = {
{meta_IMUSE, "LucasArts iMUSE header"},
{meta_KTSR, "Koei Tecmo KTSR header"},
{meta_KAT, "Sega KAT header"},
{meta_PCM_SUCCESS, "Success PCM header"},
};
void get_vgmstream_coding_description(VGMSTREAM *vgmstream, char *out, size_t out_size) {

View File

@ -1137,6 +1137,10 @@
<File
RelativePath=".\meta\pcm_sre.c"
>
</File>
<File
RelativePath=".\meta\pcm_success.c"
>
</File>
<File
RelativePath=".\meta\scd_pcm.c"

View File

@ -404,6 +404,7 @@
<ClCompile Include="meta\sab.c" />
<ClCompile Include="meta\xa_xa30.c" />
<ClCompile Include="meta\pcm_sre.c" />
<ClCompile Include="meta\pcm_success.c" />
<ClCompile Include="meta\scd_pcm.c" />
<ClCompile Include="meta\pona.c" />
<ClCompile Include="meta\pos.c" />

View File

@ -724,6 +724,9 @@
<ClCompile Include="meta\pcm_sre.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\pcm_success.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\scd_pcm.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

View File

@ -905,4 +905,6 @@ VGMSTREAM* init_vgmstream_mups(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_kat(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_pcm_success(STREAMFILE* sf);
#endif /*_META_H*/

68
src/meta/pcm_success.c Normal file
View File

@ -0,0 +1,68 @@
#include "meta.h"
#include "../coding/coding.h"
/* PCM - from Success (related) games [Metal Saga (PS2), Tetris Kiwamemichi (PS2), Duel Masters: Rebirth of Super Dragon (PS2)] */
VGMSTREAM* init_vgmstream_pcm_success(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag, channels, sample_rate, interleave;
size_t data_size, loop_start, loop_end, loop_adjust;
/* checks */
if (!check_extensions(sf, "pcm"))
goto fail;
if (read_u32be(0x00,sf) != 0x50434D20) /* "PCM " */
goto fail;
if (read_u32le(0x04,sf) != 0x00010000) /* version? */
goto fail;
if (read_u32le(0x08,sf) + 0x8000 < get_streamfile_size(sf)) /* data size without padding */
goto fail;
interleave = 0x800;
start_offset = 0x800;
sample_rate = read_s32le(0x0c,sf);
channels = read_s32le(0x10,sf);
loop_flag = read_s32le(0x14,sf);
data_size = read_s32le(0x18,sf) * interleave * channels;
/* loops seems slightly off, so 'adjust' meaning may need to be tweaked */
loop_adjust = read_s32le(0x1c,sf) * channels; /* from 0..<0x800 */
loop_start = read_s32le(0x20,sf) * interleave * channels + loop_adjust;
loop_adjust = read_s32le(0x24,sf) * channels; /* always 0x800 (0 if no loop flag) */
loop_end = read_s32le(0x28,sf) * interleave * channels + (interleave * channels - loop_adjust);
/* 0x2c: always 1? */
/* 0x30/40: padding garbage (also at file end) */
/* not always accurate and has padding */
if (data_size > get_streamfile_size(sf) - start_offset)
data_size = get_streamfile_size(sf) - start_offset;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_PCM_SUCCESS;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(data_size, channels);
vgmstream->loop_start_sample = ps_bytes_to_samples(loop_start, channels);
vgmstream->loop_end_sample = ps_bytes_to_samples(loop_end, channels);
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -500,6 +500,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_ktsr,
init_vgmstream_mups,
init_vgmstream_kat,
init_vgmstream_pcm_success,
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */

View File

@ -732,6 +732,7 @@ typedef enum {
meta_IMUSE,
meta_KTSR,
meta_KAT,
meta_PCM_SUCCESS,
} meta_t;
/* standard WAVEFORMATEXTENSIBLE speaker positions */