From 7239c05a1ac0c7c8e17c398f0543919575f5e658 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Tue, 19 Apr 2022 19:51:17 +0300 Subject: [PATCH] Put const data in cow --- assets/assets.json | 5 ----- data/const/npc/cow.s | 21 --------------------- linker.ld | 2 +- src/npc/cow.c | 35 ++++++++++++++++++++++++++--------- 4 files changed, 27 insertions(+), 36 deletions(-) delete mode 100644 data/const/npc/cow.s diff --git a/assets/assets.json b/assets/assets.json index 4cf6c012..8fb062be 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37598,11 +37598,6 @@ "size": 8, "type": "animation" }, - { - "path": "cow/gUnk_08111938.bin", - "start": 1120568, - "size": 40 - }, { "path": "animations/gSpriteAnimations_Goron_0.bin", "start": 1120964, diff --git a/data/const/npc/cow.s b/data/const/npc/cow.s deleted file mode 100644 index 1d66d9e7..00000000 --- a/data/const/npc/cow.s +++ /dev/null @@ -1,21 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08111914:: @ 08111914 - .4byte sub_08068FC0 - .4byte sub_08069018 - .4byte sub_08069068 - .4byte sub_08069124 - .4byte sub_080691E0 - -gUnk_08111928:: @ 08111928 - .4byte sub_08069148 - .4byte sub_08069168 - .4byte sub_08069188 - .4byte sub_080691BC - -gUnk_08111938:: @ 08111938 - .incbin "cow/gUnk_08111938.bin" diff --git a/linker.ld b/linker.ld index 5e7b9e8c..db61337a 100644 --- a/linker.ld +++ b/linker.ld @@ -1234,7 +1234,7 @@ SECTIONS { data/animations/npc/melari.o(.rodata); data/const/npc/bladeBrothers.o(.rodata); data/animations/npc/bladeBrothers.o(.rodata); - data/const/npc/cow.o(.rodata); + src/npc/cow.o(.rodata); data/animations/npc/cow.o(.rodata); src/npc/goron.o(.rodata); data/animations/npc/goron.o(.rodata); diff --git a/src/npc/cow.c b/src/npc/cow.c index 4ebbf928..7333a0a0 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -7,13 +7,21 @@ void sub_0806920C(Entity* ent); void sub_0806924C(Entity* ent); - -extern void (*gUnk_08111914[])(Entity*); -extern void (*gUnk_08111928[])(Entity*); -extern Dialog gUnk_08111938[]; +void sub_08068FC0(Entity* ent); +void sub_08069018(Entity* ent); +void sub_08069068(Entity* ent); +void sub_08069124(Entity* ent); +void sub_080691E0(Entity* ent); +void sub_08069148(Entity* ent); +void sub_08069168(Entity* ent); +void sub_08069188(Entity* ent); +void sub_080691BC(Entity* ent); void Cow(Entity* ent) { - gUnk_08111914[ent->action](ent); + static void (*const actionFuncs[])(Entity*) = { + sub_08068FC0, sub_08069018, sub_08069068, sub_08069124, sub_080691E0, + }; + actionFuncs[ent->action](ent); sub_0806ED78(ent); sub_0806920C(ent); } @@ -127,8 +135,14 @@ void sub_08069068(Entity* ent) { } void sub_08069124(Entity* ent) { + static void (*const subActionFuncs[])(Entity*) = { + sub_08069148, + sub_08069168, + sub_08069188, + sub_080691BC, + }; UpdateAnimationSingleFrame(ent); - gUnk_08111928[ent->subAction](ent); + subActionFuncs[ent->subAction](ent); sub_0806924C(ent); } @@ -152,7 +166,7 @@ void sub_08069188(Entity* ent) { return; ent->frame = 0; - if (((s8)--ent->subtimer) != 0) + if (--ent->subtimer != 0) return; ent->subAction = 3; InitAnimationForceUpdate(ent, ent->animationState + 16); @@ -175,11 +189,15 @@ void sub_080691E0(Entity* ent) { // Show dialogue void Cow_ShowDialogue(Entity* ent) { + static const Dialog gUnk_08111938[] = { { 0x0, 0x0, 6, 1, { 0x2018, 0x3f34 } }, + { 0x0, 0x0, 6, 1, { 0x2018, 0x3f35 } }, + { 0x0, 0x0, 6, 1, { 0x2018, 0x3f36 } }, + { 0x0, 0x0, 6, 1, { 0x2018, 0x3f37 } }, + { 0x0, 0x0, 6, 1, { 0x2018, 0x3f38 } } }; ShowNPCDialogue(ent, &gUnk_08111938[ent->type]); } void sub_0806920C(Entity* ent) { - // TODO: figure out what bitfield flag this is u32 var0 = gPlayerState.flags & PL_MINISH; u32 var1 = -var0 >> 0x1F; @@ -198,7 +216,6 @@ void sub_0806920C(Entity* ent) { void sub_0806924C(Entity* ent) { s8 itype = ent->interactType; if (itype != 0) { - // TODO: figure out what bitfield flag this is if ((gPlayerState.flags & PL_MINISH) != 0) { if (itype == 2) { ent->action = 4;