2008-07-18 21:40:14 +02:00
|
|
|
#include "meta.h"
|
2023-07-08 10:52:28 +02:00
|
|
|
#include "../coding/coding.h"
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
/* BG00 - from Cave games [Ibara (PS2), Mushihime-sama (PS2)] */
|
|
|
|
VGMSTREAM* init_vgmstream_bg00(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
|
|
|
uint32_t start_offset;
|
|
|
|
int channels, loop_flag = 0;
|
2008-07-18 21:40:14 +02:00
|
|
|
|
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
/* check */
|
|
|
|
if (!is_id32be(0x00,sf, "BG00"))
|
|
|
|
return NULL;
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
/* .bg00: header ID (no filenames or debug strings) */
|
|
|
|
if (!check_extensions(sf,"bg00"))
|
|
|
|
return NULL;
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
if (!is_id32be(0x40,sf, "VAGp"))
|
|
|
|
return NULL;
|
|
|
|
if (!is_id32be(0x70,sf, "VAGp"))
|
|
|
|
return NULL;
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
loop_flag = 0; /* flag at 0x08? loop points seem external */
|
|
|
|
channels = 2; /* mono files use regular VAG */
|
|
|
|
start_offset = 0x800;
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channels,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
vgmstream->meta_type = meta_BG00;
|
|
|
|
vgmstream->sample_rate = read_s32be(0x80,sf);
|
|
|
|
vgmstream->num_samples = ps_bytes_to_samples(read_32bitBE(0x4C,sf), 1);
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = read_32bitLE(0x10,sf);
|
2008-07-18 21:40:14 +02:00
|
|
|
|
2023-07-08 10:52:28 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
|
|
|
goto fail;
|
2008-07-18 21:40:14 +02:00
|
|
|
return vgmstream;
|
|
|
|
fail:
|
2023-07-08 10:52:28 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-07-18 21:40:14 +02:00
|
|
|
return NULL;
|
|
|
|
}
|