From d93cc82ccff4e1f2921ef76818ee39e809ef2c97 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 00:37:14 +0300 Subject: [PATCH] Put const data in goron --- assets/assets.json | 5 ----- data/const/npc/goron.s | 17 ----------------- linker.ld | 2 +- src/npc/goron.c | 34 +++++++++++++++++++++++++--------- 4 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 data/const/npc/goron.s diff --git a/assets/assets.json b/assets/assets.json index 91bc1f61..4b507794 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37920,11 +37920,6 @@ "size": 37, "type": "animation" }, - { - "path": "goron/gUnk_08111A94.bin", - "start": 1120916, - "size": 48 - }, { "path": "animations/gSpriteAnimations_GoronMerchant_1.bin", "start": 1121214, diff --git a/data/const/npc/goron.s b/data/const/npc/goron.s deleted file mode 100644 index d4ac93f6..00000000 --- a/data/const/npc/goron.s +++ /dev/null @@ -1,17 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08111A80:: @ 08111A80 - .4byte sub_08069310 - .4byte sub_08069328 - .4byte sub_08069390 - -gUnk_08111A8C:: @ 08111A8C - .4byte sub_080693C4 - .4byte sub_080693D0 - -gUnk_08111A94:: @ 08111A94 - .incbin "goron/gUnk_08111A94.bin" diff --git a/linker.ld b/linker.ld index b66c3561..429eeb7a 100644 --- a/linker.ld +++ b/linker.ld @@ -1237,7 +1237,7 @@ SECTIONS { data/animations/npc/bladeBrothers.o(.rodata); data/const/npc/cow.o(.rodata); data/animations/npc/cow.o(.rodata); - data/const/npc/goron.o(.rodata); + src/npc/goron.o(.rodata); data/animations/npc/goron.o(.rodata); src/npc/goronMerchant.o(.rodata); data/animations/npc/goronMerchant.o(.rodata); diff --git a/src/npc/goron.c b/src/npc/goron.c index 4212123b..912847e3 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -5,15 +5,26 @@ #include "effects.h" #include "npc.h" -extern void (*gUnk_08111A80[])(Entity*); -extern void (*gUnk_08111A8C[])(Entity*); -extern Dialog gUnk_08111A94[]; +void sub_08069310(Entity*); +void sub_08069328(Entity*); +void sub_08069390(Entity*); +void sub_080693C4(Entity*); +void sub_080693D0(Entity*); void Goron(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_08069310, + sub_08069328, + sub_08069390, + }; + static void (*const scriptedActionFuncs[])(Entity*) = { + sub_080693C4, + sub_080693D0, + }; if (this->flags & ENT_SCRIPTED) { - gUnk_08111A8C[this->action](this); + scriptedActionFuncs[this->action](this); } else { - gUnk_08111A80[this->action](this); + actionFuncs[this->action](this); sub_0806ED78(this); } } @@ -25,7 +36,7 @@ void sub_08069310(Entity* this) { } void sub_08069328(Entity* this) { - if (((u32)(++this->subtimer << 24) >> 24) > 16) { + if (++this->subtimer > 16) { int action; this->subtimer = 0; @@ -94,16 +105,16 @@ void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) { } u32 sub_08069480(Entity* this) { - return (sub_0801E99C(this) << 24) >> 24; + return (u8)sub_0801E99C(this); } void sub_0806948C(Entity* this, ScriptExecutionContext* context) { - context->condition = CheckKinstoneFused((sub_08069480(this) << 24) >> 24); + context->condition = CheckKinstoneFused((u8)sub_08069480(this)); gActiveScriptInfo.flags |= 1; } void sub_080694B0(Entity* this) { - u32 kinstone = (sub_08069480(this) << 24) >> 24; + u32 kinstone = (u8)sub_08069480(this); if (CheckKinstoneFused(kinstone)) { sub_08078778(this); } else { @@ -112,6 +123,11 @@ void sub_080694B0(Entity* this) { } void sub_080694D8(Entity* this) { + static const Dialog gUnk_08111A94[] = { + { 0x2f, 3, 4, 1, { 0x3f13, 0x3f0e } }, { 0x2f, 3, 4, 1, { 0x3f14, 0x3f0f } }, + { 0x2f, 3, 4, 1, { 0x3f15, 0x3f10 } }, { 0x2f, 3, 4, 1, { 0x3f16, 0x3f11 } }, + { 0x2f, 3, 4, 1, { 0x3f17, 0x3f12 } }, { 0, 0, 1, 1, { 0, 0x3f18 } }, + }; ShowNPCDialogue(this, &gUnk_08111A94[this->type]); }