From 1267ee74f6bf5368ca23a625aaa7403eb2a73be1 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Thu, 14 Apr 2022 22:58:13 +0300 Subject: [PATCH] Put const data into talon --- assets/assets.json | 10 ---------- data/const/npc/talon.s | 22 ---------------------- linker.ld | 2 +- src/npc/talon.c | 37 ++++++++++++++++++++++++++++--------- 4 files changed, 29 insertions(+), 42 deletions(-) delete mode 100644 data/const/npc/talon.s diff --git a/assets/assets.json b/assets/assets.json index 97812d1b..5b245cc6 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -36733,16 +36733,6 @@ "size": 17, "type": "animation" }, - { - "path": "talon/gUnk_0810FEB0.bin", - "start": 1113776, - "size": 12 - }, - { - "path": "talon/gUnk_0810FED8.bin", - "start": 1113816, - "size": 8 - }, { "path": "animations/gSpriteAnimations_Malon_0.bin", "start": 1113968, diff --git a/data/const/npc/talon.s b/data/const/npc/talon.s deleted file mode 100644 index 1dc9e4e1..00000000 --- a/data/const/npc/talon.s +++ /dev/null @@ -1,22 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0810FEB0:: @ 0810FEB0 - .incbin "talon/gUnk_0810FEB0.bin" - -gUnk_0810FEBC:: @ 0810FEBC - .4byte sub_08065570 - .4byte sub_0806559C - -gUnk_0810FEC4:: @ 0810FEC4 - .4byte sub_08065608 - .4byte sub_08065648 - .4byte sub_080656D4 - .4byte sub_080656A4 - .4byte sub_08065680 - -gUnk_0810FED8:: @ 0810FED8 - .incbin "talon/gUnk_0810FED8.bin" diff --git a/linker.ld b/linker.ld index 08006750..dcab069a 100644 --- a/linker.ld +++ b/linker.ld @@ -1199,7 +1199,7 @@ SECTIONS { data/animations/npc/tingleSiblings.o(.rodata); src/npc/stockwell.o(.rodata); data/animations/npc/stockwell.o(.rodata); - data/const/npc/talon.o(.rodata); + src/npc/talon.o(.rodata); data/animations/npc/talon.o(.rodata); data/const/npc/malon.o(.rodata); data/animations/npc/malon.o(.rodata); diff --git a/src/npc/talon.c b/src/npc/talon.c index c9f09dad..67845700 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -2,24 +2,40 @@ #include "functions.h" #include "item.h" -extern void (*gUnk_0810FEC4[])(Entity* this); -extern void (*gUnk_0810FEBC[])(Entity* this); -extern SpriteLoadData gUnk_0810FEB0; +static const SpriteLoadData gUnk_0810FEB0[] = { + { 0x4b, 0x8b, 0 }, + { 0x4b, 0x8b, 0 }, + { 0, 0, 0 }, +}; + extern u8 script_TalonGotKey; -extern u8 gUnk_0810FED8[]; void sub_0806574C(Entity* this); +void sub_08065570(Entity* this); +void sub_0806559C(Entity* this); +void sub_08065608(Entity* this); +void sub_08065648(Entity* this); +void sub_080656D4(Entity* this); +void sub_080656A4(Entity* this); +void sub_08065680(Entity* this); void Talon(Entity* this) { + static void (*const actionFuncs[])(Entity * this) = { + sub_08065570, + sub_0806559C, + }; + static void (*const scriptedActionFuncs[])(Entity * this) = { + sub_08065608, sub_08065648, sub_080656D4, sub_080656A4, sub_08065680, + }; if (this->flags & ENT_SCRIPTED) { - gUnk_0810FEC4[this->action](this); + scriptedActionFuncs[this->action](this); } else { - gUnk_0810FEBC[this->action](this); + actionFuncs[this->action](this); } } void sub_08065570(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810FEB0) != 0) { InitializeAnimation(this, 0); sub_08078778(this); this->action = 1; @@ -59,7 +75,7 @@ void sub_0806559C(Entity* this) { } void sub_08065608(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810FEB0) != 0) { this->action = 1; this->spriteSettings.draw = 1; this->field_0x68.HALF.LO = sub_0801E99C(this); @@ -129,6 +145,9 @@ void sub_0806574C(Entity* this) { } void sub_08065780(Entity* this, ScriptExecutionContext* context) { + static const u8 gUnk_0810FED8[] = { + 10, 20, 30, 18, 28, 38, 12, 24, + }; u32 rand; rand = Random(); @@ -145,7 +164,7 @@ void Talon_Head(Entity* this) { void Talon_Fusion(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { + if (LoadExtraSpriteData(this, gUnk_0810FEB0) != 0) { this->action++; this->spriteSettings.draw = 1; InitializeAnimation(this, 6);