From 08eba596c43f23d4e26822b31f145b56fb538899 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 22:01:25 +0300 Subject: [PATCH] Put const data into castorWildStatue --- assets/assets.json | 25 ---------------- data/const/npc/castorWildsStatue.s | 30 ------------------- linker.ld | 2 +- src/npc/castorWildsStatue.c | 48 ++++++++++++++++++++---------- 4 files changed, 34 insertions(+), 71 deletions(-) delete mode 100644 data/const/npc/castorWildsStatue.s diff --git a/assets/assets.json b/assets/assets.json index 5f6d3734..65b149ad 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37423,31 +37423,6 @@ "size": 6, "type": "animation" }, - { - "path": "castorWildsStatue/gUnk_08110E64.bin", - "start": 1117796, - "size": 4 - }, - { - "path": "castorWildsStatue/gUnk_08110E68.bin", - "start": 1117800, - "size": 16 - }, - { - "path": "castorWildsStatue/gUnk_08110E78.bin", - "start": 1117816, - "size": 18 - }, - { - "path": "castorWildsStatue/gUnk_08110E8A.bin", - "start": 1117834, - "size": 10 - }, - { - "path": "castorWildsStatue/gUnk_08110E94.bin", - "start": 1117844, - "size": 8 - }, { "path": "cat/gUnk_08111114.bin", "start": 1118484, diff --git a/data/const/npc/castorWildsStatue.s b/data/const/npc/castorWildsStatue.s deleted file mode 100644 index 8e825187..00000000 --- a/data/const/npc/castorWildsStatue.s +++ /dev/null @@ -1,30 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08110E4C:: @ 08110E4C - .4byte sub_080673C0 - .4byte sub_080673F4 - .4byte sub_08067410 - .4byte sub_0806752C - -gUnk_08110E5C:: @ 08110E5C - .4byte sub_08067418 - .4byte sub_08067514 - -gUnk_08110E64:: @ 08110E64 - .incbin "castorWildsStatue/gUnk_08110E64.bin" - -gUnk_08110E68:: @ 08110E68 - .incbin "castorWildsStatue/gUnk_08110E68.bin" - -gUnk_08110E78:: @ 08110E78 - .incbin "castorWildsStatue/gUnk_08110E78.bin" - -gUnk_08110E8A:: @ 08110E8A - .incbin "castorWildsStatue/gUnk_08110E8A.bin" - -gUnk_08110E94:: @ 08110E94 - .incbin "castorWildsStatue/gUnk_08110E94.bin" diff --git a/linker.ld b/linker.ld index 00076aa9..c5acbcb6 100644 --- a/linker.ld +++ b/linker.ld @@ -1225,7 +1225,7 @@ SECTIONS { data/animations/npc/mutoh.o(.rodata); src/npc/carpenter.o(.rodata); data/animations/npc/carpenter.o(.rodata); - data/const/npc/castorWildsStatue.o(.rodata); + src/npc/castorWildsStatue.o(.rodata); data/animations/npc/castorWildsStatue.o(.rodata); data/const/npc/cat.o(.rodata); data/animations/npc/cat.o(.rodata); diff --git a/src/npc/castorWildsStatue.c b/src/npc/castorWildsStatue.c index 086889da..f8aa465a 100644 --- a/src/npc/castorWildsStatue.c +++ b/src/npc/castorWildsStatue.c @@ -6,27 +6,35 @@ #include "effects.h" #include "npc.h" -extern Hitbox gUnk_08110E94; - -extern void (*gUnk_08110E4C[])(Entity*); -extern void (*gUnk_08110E5C[])(Entity*); - -extern s8 gUnk_08110E64[]; - -extern u32 gUnk_08110E68[]; +static const Hitbox gUnk_08110E94; typedef struct { s8 x; s8 y; } PACKED PosOffset; -extern PosOffset gUnk_08110E78[]; -extern PosOffset gUnk_08110E8A[]; + +void sub_080673C0(Entity*); +void sub_080673F4(Entity*); +void sub_08067410(Entity*); +void sub_0806752C(Entity*); +void sub_08067418(Entity*); +void sub_08067514(Entity*); void CastorWildsStatue(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_080673C0, + sub_080673F4, + sub_08067410, + sub_0806752C, + }; + static void (*const scriptedActionFuncs[])(Entity*) = { + sub_08067418, + sub_08067514, + }; if ((this->flags & ENT_SCRIPTED) != 0) { - gUnk_08110E5C[this->action](this); + scriptedActionFuncs[this->action](this); } else { - gUnk_08110E4C[this->action](this); + actionFuncs[this->action](this); sub_0806ED78(this); } } @@ -39,7 +47,7 @@ void sub_080673C0(Entity* this) { } this->frameIndex = this->type & 1; if ((this->type & 1) == 0) { - this->hitbox = &gUnk_08110E94; + this->hitbox = (Hitbox*)&gUnk_08110E94; } } @@ -58,7 +66,7 @@ void sub_08067418(Entity* this) { this->action = 1; this->field_0x74.HWORD = COORD_TO_TILE(this); if (this->type == 0) { - this->hitbox = &gUnk_08110E94; + this->hitbox = (Hitbox*)&gUnk_08110E94; SetTile(0x4022, this->field_0x74.HWORD - 1, this->collisionLayer); SetTile(0x4022, this->field_0x74.HWORD, this->collisionLayer); SetTile(0x4022, this->field_0x74.HWORD + 0x3f, this->collisionLayer); @@ -94,6 +102,7 @@ void sub_0806752C(Entity* this) { } void sub_08067534(Entity* this) { + static const s8 gUnk_08110E64[] = { -8, 8, 0, 0 }; Entity* entity; s32 i; for (i = 0; i < 2; ++i) { @@ -108,6 +117,7 @@ void sub_08067534(Entity* this) { } void sub_0806757C(Entity* this) { + static const u32 gUnk_08110E68[] = { 0xc8, 0xc9, 0xca, 0xc8 }; if (this->subAction != 0) { if (this->subAction >= 3) { RestorePrevTileEntity(0xe81, 1); @@ -121,7 +131,13 @@ void sub_0806757C(Entity* this) { } void sub_080675D4(Entity* this) { - PosOffset* gUnk = gUnk_08110E78; + static const PosOffset gUnk_08110E78[] = { { 0x0, 0x0 }, { 0x0, -0x10 }, { 0x0, 0x10 }, + { -0x10, 0x0 }, { 0x10, 0x0 }, { -0x10, -0x10 }, + { -0x10, 0x10 }, { 0x10, 0x10 }, { 0x10, -0x10 } }; + static const PosOffset gUnk_08110E8A[] = { + { -0xc, -0xc }, { 0xc, -0xc }, { -0xc, 0xc }, { 0xc, 0xc }, { 0x0, 0x0 } + }; + const PosOffset* gUnk = gUnk_08110E78; u32 subAction = (this->subAction << 2) - 0xc; s32 i; @@ -155,6 +171,8 @@ void sub_080675D4(Entity* this) { } } +static const Hitbox gUnk_08110E94 = { 0, 3, { 5, 3, 3, 5 }, 12, 20 }; + void sub_080676D8(Entity* this) { this->subAction += 1; }