mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
Fix some broken .bnk [Fat Princess (PS3)]
This commit is contained in:
parent
1b06bf45d2
commit
279b2994d2
@ -11,7 +11,7 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
|
||||
uint32_t start_offset, stream_offset, name_offset = 0;
|
||||
uint32_t stream_size, interleave = 0;
|
||||
int channels = 0, loop_flag, sample_rate, big_endian;
|
||||
int loop_start = 0, loop_end = 0;
|
||||
int32_t loop_start = 0, loop_end = 0;
|
||||
uint32_t center_note, center_fine, flags;
|
||||
uint32_t atrac9_info = 0;
|
||||
|
||||
@ -43,7 +43,7 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
|
||||
if (!check_extensions(sf, "bnk"))
|
||||
return NULL;
|
||||
|
||||
uint32_t sblk_offset, sblk_size, data_offset, data_size, zlsd_size = 0;
|
||||
uint32_t sblk_offset, data_offset, data_size;
|
||||
int parts, sblk_version;
|
||||
|
||||
parts = read_u32(0x04,sf);
|
||||
@ -51,17 +51,19 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
|
||||
return NULL;
|
||||
/* in theory a bank can contain multiple blocks */
|
||||
|
||||
/* section sizes don't include padding (sometimes aligned to 0x10/0x800) */
|
||||
sblk_offset = read_u32(0x08,sf);
|
||||
sblk_size = read_u32(0x0c,sf);
|
||||
//sblk_size = read_u32(0x0c,sf);
|
||||
data_offset = read_u32(0x10,sf);
|
||||
data_size = read_u32(0x14,sf);
|
||||
if (sblk_offset >= 0x20) {
|
||||
/* ZLSD small footer, rare in earlier versions and more common later [Yakuza 6's Puyo Puyo (PS4)] */
|
||||
//zlsd_offset = read_u32(0x18,sf);
|
||||
zlsd_size = read_u32(0x1c,sf);
|
||||
}
|
||||
|
||||
if (sblk_offset + sblk_size + data_size + zlsd_size != get_streamfile_size(sf))
|
||||
/* ZLSD small footer, rare in earlier versions and more common later [Yakuza 6's Puyo Puyo (PS4)] */
|
||||
//if (sblk_offset >= 0x20) {
|
||||
// zlsd_offset = read_u32(0x18,sf);
|
||||
// zlsd_size = read_u32(0x1c,sf);
|
||||
//}
|
||||
|
||||
if (sblk_offset > 0x20)
|
||||
return NULL;
|
||||
|
||||
/* SE banks, also used for music. Most table fields seems reserved/defaults and
|
||||
@ -231,7 +233,7 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
|
||||
}
|
||||
|
||||
|
||||
//;VGM_LOG("BNK: subsongs %i, table2_entry=%lx, table3_entry=%lx\n", total_subsongs,table2_entry_offset,table3_entry_offset);
|
||||
//;VGM_LOG("BNK: subsongs %i, table2_entry=%x, table3_entry=%x\n", total_subsongs,table2_entry_offset,table3_entry_offset);
|
||||
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
/* this means some subsongs repeat streams, that can happen in some sfx banks, whatevs */
|
||||
@ -322,6 +324,7 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
|
||||
break;
|
||||
|
||||
default:
|
||||
VGM_LOG("BNK: missing version\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -469,8 +472,10 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
|
||||
|
||||
case 0x02: /* ATRAC9 mono */
|
||||
case 0x05: /* ATRAC9 stereo */
|
||||
if (read_u32(start_offset+0x08,sf) + 0x08 != extradata_size) /* repeat? */
|
||||
if (read_u32(start_offset+0x08,sf) + 0x08 != extradata_size) { /* repeat? */
|
||||
VGM_LOG("BNK: unknown subtype\n");
|
||||
goto fail;
|
||||
}
|
||||
channels = (type == 0x02) ? 1 : 2;
|
||||
|
||||
atrac9_info = read_u32be(start_offset+0x0c,sf);
|
||||
@ -493,8 +498,10 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
|
||||
case 0x0f:
|
||||
case 0x10:
|
||||
type = read_u16(start_offset+0x00,sf);
|
||||
if (read_u32(start_offset+0x04,sf) != 0x01) /* type? */
|
||||
if (read_u32(start_offset+0x04,sf) != 0x01) { /* type? */
|
||||
VGM_LOG("BNK: unknown subtype\n");
|
||||
goto fail;
|
||||
}
|
||||
extradata_size = 0x10 + read_u32(start_offset+0x08,sf); /* 0x80 for AT9, 0x10 for PCM/PS-ADPCM */
|
||||
/* 0x0c: null? */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user