[Decompilation] [th01] Skipping past the palette when loading .BOS files

At least the upcoming player animation load function was smart enough
to do that.

Part of P0123, funded by Yanga.
This commit is contained in:
nmlgc 2020-10-08 12:55:30 +02:00
parent 11f65e4afb
commit cacb9361c7
2 changed files with 19 additions and 5 deletions

View File

@ -29,7 +29,20 @@ struct bos_t {
bos_image_t image[BOS_IMAGES_PER_SLOT];
};
#define bos_header_load(that, plane_size, fn) \
// Shared loading and freeing subfunctions
// ---------------------------------------
// Separate function to work around the `Condition is always true/false` and
// `Unreachable code` warnings
inline void bos_header_load_palette(Palette4 &pal, bool load) {
if(load) {
arc_file_get_far(pal);
} else {
arc_file_seek(sizeof(spriteformat_header_t<bos_header_t>));
}
}
#define bos_header_load(that, plane_size, fn, needlessly_load_the_palette) \
union { \
bos_header_t outer; \
Palette4 pal; \
@ -42,8 +55,8 @@ struct bos_t {
that->vram_w = header.outer.vram_w; \
that->h = header.outer.h; \
that->bos_image_count = header.outer.inner.image_count; \
plane_size = (vram_w * h); \
arc_file_get_far(header.pal); // yeah, should have been a seek
plane_size = (that->vram_w * that->h); \
bos_header_load_palette(header.pal, needlessly_load_the_palette);
#define bos_image_new(image, plane_size) \
image.alpha = new dots16_t[plane_size / 2]; \
@ -67,6 +80,7 @@ struct bos_t {
bos_image_ptr_free(slot_ptr.image[image].planes.G); \
bos_image_ptr_free(slot_ptr.image[image].planes.E); \
}
// ---------------------------------------
/// All functions that operate on this format are implemented redundantly for
/// both CBossEntity and CBossAnim, with their own respective entity arrays.

View File

@ -49,7 +49,7 @@ int CBossEntity::load(const char fn[PF_FN_LEN], int slot)
{
int plane_size;
bos_header_load(this, plane_size, fn);
bos_header_load(this, plane_size, fn, true);
if(!bos_header_only) {
bos_entity_free(slot);
for(int i = 0; bos_image_count > i; i++) {
@ -612,7 +612,7 @@ int CBossAnim::load(const char fn[PF_FN_LEN], int slot)
{
int plane_size;
bos_header_load(this, plane_size, fn);
bos_header_load(this, plane_size, fn, true);
if(!bos_header_only) {
bos_anim_free(slot);
for(int i = 0; bos_image_count > i; i++) {