mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-06 14:44:25 +01:00
Ubi SB: Implement rotating IDs for SMx
This commit is contained in:
parent
7ce512eee2
commit
2087ef84bf
@ -600,26 +600,41 @@ static int parse_sb_header(ubi_sb_header * sb, STREAMFILE *streamFile, int targe
|
|||||||
int current_is_external = 0;
|
int current_is_external = 0;
|
||||||
int type = read_32bit(offset + sb->stream_type_offset, streamFile);
|
int type = read_32bit(offset + sb->stream_type_offset, streamFile);
|
||||||
|
|
||||||
if (current_type == -1)
|
|
||||||
current_type = type;
|
|
||||||
if (current_id == -1) /* use first ID in section3 */
|
|
||||||
current_id = read_32bit(sb->section3_offset + 0x00, streamFile);
|
|
||||||
|
|
||||||
if (sb->external_flag_offset) {
|
if (sb->external_flag_offset) {
|
||||||
current_is_external = read_32bit(offset + sb->external_flag_offset, streamFile);
|
current_is_external = read_32bit(offset + sb->external_flag_offset, streamFile);
|
||||||
} else if (sb->has_extra_name_flag && read_32bit(offset + sb->extra_name_offset, streamFile) != 0xFFFFFFFF) {
|
} else if (sb->has_extra_name_flag && read_32bit(offset + sb->extra_name_offset, streamFile) != 0xFFFFFFFF) {
|
||||||
current_is_external = 1; /* -1 in extra_name means internal */
|
current_is_external = 1; /* -1 in extra_name means internal */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!current_is_external) {
|
if (!current_is_external) {
|
||||||
if (current_type != type) {
|
if (sb->is_map) {
|
||||||
current_type = type;
|
if (current_type == -1)
|
||||||
current_id++; /* rotate */
|
current_type = type;
|
||||||
if (current_id >= sb->section3_num)
|
if (current_id == -1) /* they seem to always start with 0 in maps */
|
||||||
current_id = 0; /* reset */
|
current_id = 0x00;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!current_is_external) {
|
||||||
|
if (current_type != type) {
|
||||||
|
current_type = type;
|
||||||
|
current_id++; /* rotate */
|
||||||
|
/* we'll warp it around later when parsing section 3 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (current_type == -1)
|
||||||
|
current_type = type;
|
||||||
|
if (current_id == -1) /* use first ID in section3 */
|
||||||
|
current_id = read_32bit(sb->section3_offset + 0x00, streamFile);
|
||||||
|
|
||||||
|
if (!current_is_external) {
|
||||||
|
if (current_type != type) {
|
||||||
|
current_type = type;
|
||||||
|
current_id++; /* rotate */
|
||||||
|
if (current_id >= sb->section3_num)
|
||||||
|
current_id = 0; /* reset */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,11 +855,15 @@ static int parse_sb_header(ubi_sb_header * sb, STREAMFILE *streamFile, int targe
|
|||||||
int idx = read_32bit(table_offset + 0x08 * j + 0x00, streamFile) & 0x0000FFFF;
|
int idx = read_32bit(table_offset + 0x08 * j + 0x00, streamFile) & 0x0000FFFF;
|
||||||
|
|
||||||
if (idx == sb->header_idx) {
|
if (idx == sb->header_idx) {
|
||||||
if (!sb->stream_id_offset && table2_num > 1) {
|
if (!(sb->stream_id_offset || sb->has_rotating_ids) && table2_num > 1) {
|
||||||
VGM_LOG("UBI SB: unexpected number of internal stream groups %i\n", sb->section3_num);
|
VGM_LOG("UBI SB: unexpected number of internal stream groups %i\n", table2_num);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sb->has_rotating_ids) {
|
||||||
|
sb->stream_id %= table2_num;
|
||||||
|
}
|
||||||
|
|
||||||
sb->stream_offset = read_32bit(table_offset + 0x08 * j + 0x04, streamFile);
|
sb->stream_offset = read_32bit(table_offset + 0x08 * j + 0x04, streamFile);
|
||||||
for (k = 0; k < table2_num; k++) {
|
for (k = 0; k < table2_num; k++) {
|
||||||
/* entry layout:
|
/* entry layout:
|
||||||
@ -1285,7 +1304,7 @@ static int config_sb_header_version(ubi_sb_header * sb, STREAMFILE *streamFile)
|
|||||||
sb->extra_name_offset = 0x40;
|
sb->extra_name_offset = 0x40;
|
||||||
|
|
||||||
sb->has_extra_name_flag = 1;
|
sb->has_extra_name_flag = 1;
|
||||||
//sb->has_rotating_ids = 1;
|
sb->has_rotating_ids = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1378,7 +1397,7 @@ static int config_sb_header_version(ubi_sb_header * sb, STREAMFILE *streamFile)
|
|||||||
sb->extra_name_offset = 0x4c;
|
sb->extra_name_offset = 0x4c;
|
||||||
|
|
||||||
sb->has_extra_name_flag = 1;
|
sb->has_extra_name_flag = 1;
|
||||||
//sb->has_rotating_ids = 1;
|
sb->has_rotating_ids = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user