Add .bgm NXOpus [Cotton Reboot (Switch)]

This commit is contained in:
bnnm 2021-03-04 19:57:32 +01:00
parent 4ad77d4d10
commit 4aaf5ea3e6

View File

@ -13,24 +13,24 @@ static VGMSTREAM* init_vgmstream_opus(STREAMFILE* sf, meta_t meta_type, off_t of
size_t data_size, skip = 0;
if ((uint32_t)read_32bitLE(offset + 0x00,sf) != 0x80000001)
if (read_u32le(offset + 0x00,sf) != 0x80000001)
goto fail;
channel_count = read_8bit(offset + 0x09, sf);
channel_count = read_u8(offset + 0x09, sf);
/* 0x0a: packet size if CBR, 0 if VBR */
data_offset = offset + read_32bitLE(offset + 0x10, sf);
skip = read_16bitLE(offset + 0x1c, sf);
data_offset = offset + read_u32le(offset + 0x10, sf);
skip = read_u16le(offset + 0x1c, sf);
/* 0x1e: ? (seen in Lego Movie 2 (Switch)) */
/* recent >2ch info [Clannad (Switch)] */
if ((uint32_t)read_32bitLE(offset + 0x20, sf) == 0x80000005) {
if (read_u32le(offset + 0x20, sf) == 0x80000005) {
multichannel_offset = offset + 0x20;
}
if ((uint32_t)read_32bitLE(data_offset, sf) != 0x80000004)
if (read_u32le(data_offset, sf) != 0x80000004)
goto fail;
data_size = read_32bitLE(data_offset + 0x04, sf);
data_size = read_u32le(data_offset + 0x04, sf);
start_offset = data_offset + 0x08;
loop_flag = (loop_end > 0); /* -1 when not set */
@ -41,7 +41,7 @@ static VGMSTREAM* init_vgmstream_opus(STREAMFILE* sf, meta_t meta_type, off_t of
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_type;
vgmstream->sample_rate = read_32bitLE(offset + 0x0c,sf);
vgmstream->sample_rate = read_u32le(offset + 0x0c,sf);
if (vgmstream->sample_rate == 16000)
vgmstream->sample_rate = 48000; // Grandia HD Collection contains a false sample_rate in header
vgmstream->num_samples = num_samples;
@ -59,10 +59,10 @@ static VGMSTREAM* init_vgmstream_opus(STREAMFILE* sf, meta_t meta_type, off_t of
if (multichannel_offset && vgmstream->channels <= 8) {
int i;
cfg.stream_count = read_8bit(multichannel_offset + 0x08,sf);
cfg.coupled_count = read_8bit(multichannel_offset + 0x09,sf);
cfg.stream_count = read_u8(multichannel_offset + 0x08,sf);
cfg.coupled_count = read_u8(multichannel_offset + 0x09,sf);
for (i = 0; i < vgmstream->channels; i++) {
cfg.channel_mapping[i] = read_8bit(multichannel_offset + 0x0a + i,sf);
cfg.channel_mapping[i] = read_u8(multichannel_offset + 0x0a + i,sf);
}
}
@ -80,7 +80,7 @@ static VGMSTREAM* init_vgmstream_opus(STREAMFILE* sf, meta_t meta_type, off_t of
goto fail;
#endif
if ( !vgmstream_open_stream(vgmstream, sf, start_offset) )
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
@ -92,24 +92,26 @@ fail:
/* standard Switch Opus, Nintendo header + raw data (generated by opus_test.c?) [Lego City Undercover (Switch)] */
VGMSTREAM* init_vgmstream_opus_std(STREAMFILE* sf) {
STREAMFILE * PSIFile = NULL;
STREAMFILE* psi_sf = NULL;
off_t offset;
int num_samples, loop_start, loop_end;
/* checks */
if (!check_extensions(sf,"opus,lopus"))
/* .opus: standard
* .bgm: Cotton Reboot (Switch) */
if (!check_extensions(sf,"opus,lopus,bgm"))
goto fail;
offset = 0x00;
/* BlazBlue: Cross Tag Battle (Switch) PSI Metadata for corresponding Opus */
/* Maybe future Arc System Works games will use this too? */
PSIFile = open_streamfile_by_ext(sf, "psi");
if (PSIFile) {
num_samples = read_32bitLE(0x8C, PSIFile);
loop_start = read_32bitLE(0x84, PSIFile);
loop_end = read_32bitLE(0x88, PSIFile);
close_streamfile(PSIFile);
psi_sf = open_streamfile_by_ext(sf, "psi");
if (psi_sf) {
num_samples = read_s32le(0x8C, psi_sf);
loop_start = read_s32le(0x84, psi_sf);
loop_end = read_s32le(0x88, psi_sf);
close_streamfile(psi_sf);
}
else {
num_samples = 0;