From e652f98b16ebc2dec5ad0d6ea2ffb3333ff25435 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 21:23:31 +0300 Subject: [PATCH 01/12] Put const data into smith --- assets/assets.json | 25 ------------------ data/const/npc/smith.s | 32 ---------------------- linker.ld | 2 +- src/npc/smith.c | 60 ++++++++++++++++++++++++++++++++---------- 4 files changed, 47 insertions(+), 72 deletions(-) delete mode 100644 data/const/npc/smith.s diff --git a/assets/assets.json b/assets/assets.json index 7dd1364d..eaf50413 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -36943,31 +36943,6 @@ "size": 6, "type": "animation" }, - { - "path": "smith/gUnk_08110354.bin", - "start": 1114964, - "size": 12 - }, - { - "path": "smith/gUnk_08110380.bin", - "start": 1115008, - "size": 16 - }, - { - "path": "smith/gUnk_08110390.bin", - "start": 1115024, - "size": 64 - }, - { - "path": "smith/gUnk_081103D0.bin", - "start": 1115088, - "size": 16 - }, - { - "path": "smith/gUnk_081103E0.bin", - "start": 1115104, - "size": 4 - }, { "path": "animations/gSpriteAnimations_KingDaltus_0.bin", "start": 1115392, diff --git a/data/const/npc/smith.s b/data/const/npc/smith.s deleted file mode 100644 index 8a156d82..00000000 --- a/data/const/npc/smith.s +++ /dev/null @@ -1,32 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08110354:: @ 08110354 - .incbin "smith/gUnk_08110354.bin" - -gUnk_08110360:: @ 08110360 - .4byte sub_080660EC - .4byte sub_08066118 - .4byte sub_08066170 - -gUnk_0811036C:: @ 0811036C - .4byte sub_08066178 - .4byte sub_080661B0 - .4byte sub_080661BC - .4byte sub_08066200 - .4byte sub_08066218 - -gUnk_08110380:: @ 08110380 - .incbin "smith/gUnk_08110380.bin" - -gUnk_08110390:: @ 08110390 - .incbin "smith/gUnk_08110390.bin" - -gUnk_081103D0:: @ 081103D0 - .incbin "smith/gUnk_081103D0.bin" - -gUnk_081103E0:: @ 081103E0 - .incbin "smith/gUnk_081103E0.bin" diff --git a/linker.ld b/linker.ld index 7ee2924a..11d61238 100644 --- a/linker.ld +++ b/linker.ld @@ -1209,7 +1209,7 @@ SECTIONS { data/animations/npc/milkCart.o(.rodata); src/npc/ghostBrothers.o(.rodata); data/animations/npc/ghostBrothers.o(.rodata); - data/const/npc/smith.o(.rodata); + src/npc/smith.o(.rodata); data/animations/npc/smith.o(.rodata); src/npc/npc23.o(.rodata); data/const/npc/kingDaltus.o(.rodata); diff --git a/src/npc/smith.c b/src/npc/smith.c index d6d428bb..4ea07d06 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -1,16 +1,33 @@ #include "npc.h" #include "functions.h" -extern void (*const gUnk_08110360[])(Entity*); -extern void (*const gUnk_0811036C[])(Entity*); +static const SpriteLoadData gUnk_08110354[] = { + { 0x4d, 0x38, 0x4 }, + { 0x4004, 0x38, 0x4 }, + { 0, 0, 0 }, +}; -extern u16 gUnk_08110380[]; -extern SpriteLoadData gUnk_08110354; -extern Dialog gUnk_08110390[]; -extern u16 gUnk_081103D0[]; -extern u32 gUnk_081103E0; +void sub_080660EC(Entity*); +void sub_08066118(Entity*); +void sub_08066170(Entity*); +void sub_08066178(Entity*); +void sub_080661B0(Entity*); +void sub_080661BC(Entity*); +void sub_08066200(Entity*); +void sub_08066218(Entity*); void Smith(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_080660EC, + sub_08066118, + sub_08066170, + }; + static void (*const scriptedActionFuncs[])(Entity*) = { + sub_08066178, sub_080661B0, sub_080661BC, sub_08066200, sub_08066218, + }; + static const u16 gUnk_08110380[] = { + 0xdc, 0xdd, 0xde, 0xdc, 0xdd, 0xde, 0xdc, 0xdd, + }; u32 index; if ((this->flags & ENT_SCRIPTED) != 0) { @@ -22,9 +39,9 @@ void Smith(Entity* this) { InitAnimationForceUpdate(this, index); sub_0806F118(this); } - gUnk_0811036C[this->action](this); + scriptedActionFuncs[this->action](this); } else { - gUnk_08110360[this->action](this); + actionFuncs[this->action](this); sub_0806ED78(this); } if (this->animIndex == 0xc) { @@ -54,7 +71,7 @@ void Smith_Head(Entity* this) { } void sub_080660EC(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) { + if (LoadExtraSpriteData(this, gUnk_08110354) != 0) { this->action = 1; this->field_0x68.HALF.LO = sub_0801E99C(this); InitAnimationForceUpdate(this, 2); @@ -89,7 +106,7 @@ void sub_08066170(Entity* this) { } void sub_08066178(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) { + if (LoadExtraSpriteData(this, gUnk_08110354) != 0) { this->action = 1; this->spriteSettings.draw = 1; this->field_0x68.HALF.LO = sub_0801E99C(this); @@ -126,6 +143,12 @@ void sub_08066218(Entity* this) { } void sub_0806622C(Entity* this) { + static const Dialog dialogs[] = { + { 0x15, 2, 4, 1, { 0x3201, 0x100e } }, { 0x15, 2, 4, 1, { 0x3201, 0x100e } }, + { 0x15, 2, 4, 1, { 0x3202, 0x100e } }, { 0x15, 2, 4, 1, { 0x3203, 0x100e } }, + { 0x15, 2, 4, 1, { 0x3204, 0x100e } }, { 0x15, 2, 4, 1, { 0x3205, 0x100e } }, + { 0x15, 2, 4, 1, { 0x3206, 0x100e } }, { 0x15, 2, 4, 1, { 0x3206, 0x100e } }, + }; u32 index; if (gSave.global_progress - 2 < 0) { @@ -133,17 +156,26 @@ void sub_0806622C(Entity* this) { } else { index = gSave.global_progress - 2; } - ShowNPCDialogue(this, &gUnk_08110390[index]); + ShowNPCDialogue(this, &dialogs[index]); } void nullsub_501(Entity* this) { } void sub_08066258(void) { - SoundReq(gUnk_081103D0[Random() & 7]); + static const u16 hammerSounds[] = { + SFX_HAMMER4, SFX_HAMMER5, SFX_HAMMER6, SFX_HAMMER4, SFX_HAMMER5, SFX_HAMMER6, SFX_HAMMER4, SFX_HAMMER5, + }; + SoundReq(hammerSounds[Random() & 7]); } void sub_08066274(Entity* this) { + static const u8 gUnk_081103E0[] = { + 0, + 6, + 8, + 12, + }; sub_08078850(this, 1, 0, &gUnk_081103E0); } @@ -153,7 +185,7 @@ void sub_08066288(Entity* this) { void Smith_Fusion(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) { + if (LoadExtraSpriteData(this, gUnk_08110354) != 0) { this->action++; this->spriteSettings.draw = 1; InitAnimationForceUpdate(this, 6); From 5c9f68877276294e82c57b21153806f8b27ac702 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 21:27:25 +0300 Subject: [PATCH 02/12] Put const data into kingDaltus --- assets/assets.json | 5 ----- data/const/npc/kingDaltus.s | 18 ------------------ linker.ld | 2 +- src/npc/kingDaltus.c | 32 +++++++++++++++++++++++++------- 4 files changed, 26 insertions(+), 31 deletions(-) delete mode 100644 data/const/npc/kingDaltus.s diff --git a/assets/assets.json b/assets/assets.json index eaf50413..b0d0d362 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37027,11 +37027,6 @@ "size": 39, "type": "animation" }, - { - "path": "kingDaltus/gUnk_081104F8.bin", - "start": 1115384, - "size": 8 - }, { "path": "animations/gSpriteAnimations_MinisterPotho_0.bin", "start": 1115736, diff --git a/data/const/npc/kingDaltus.s b/data/const/npc/kingDaltus.s deleted file mode 100644 index 4273aad1..00000000 --- a/data/const/npc/kingDaltus.s +++ /dev/null @@ -1,18 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_081104E0:: @ 081104E0 - .4byte sub_08066654 - .4byte sub_08066688 - .4byte sub_080666DC - -gUnk_081104EC:: @ 081104EC - .4byte sub_080666E4 - .4byte sub_0806670C - .4byte sub_08066718 - -gUnk_081104F8:: @ 081104F8 - .incbin "kingDaltus/gUnk_081104F8.bin" diff --git a/linker.ld b/linker.ld index 11d61238..9986bc6e 100644 --- a/linker.ld +++ b/linker.ld @@ -1212,7 +1212,7 @@ SECTIONS { src/npc/smith.o(.rodata); data/animations/npc/smith.o(.rodata); src/npc/npc23.o(.rodata); - data/const/npc/kingDaltus.o(.rodata); + src/npc/kingDaltus.o(.rodata); data/animations/npc/kingDaltus.o(.rodata); data/const/npc/ministerPotho.o(.rodata); data/animations/npc/ministerPotho.o(.rodata); diff --git a/src/npc/kingDaltus.c b/src/npc/kingDaltus.c index 076a78a9..401ba7d6 100644 --- a/src/npc/kingDaltus.c +++ b/src/npc/kingDaltus.c @@ -4,12 +4,24 @@ #include "npc.h" #include "item.h" -extern u16 gUnk_081104F8[]; - -extern void (*const gUnk_081104E0[])(Entity*); -extern void (*const gUnk_081104EC[])(Entity*); +void sub_08066654(Entity*); +void sub_08066688(Entity*); +void sub_080666DC(Entity*); +void sub_080666E4(Entity*); +void sub_0806670C(Entity*); +void sub_08066718(Entity*); void KingDaltus(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_08066654, + sub_08066688, + sub_080666DC, + }; + static void (*const scriptedActionFuncs[])(Entity*) = { + sub_080666E4, + sub_0806670C, + sub_08066718, + }; if ((this->flags & ENT_SCRIPTED) != 0) { if (this->interactType == 2) { this->interactType = 0; @@ -17,9 +29,9 @@ void KingDaltus(Entity* this) { InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); sub_0806F118(this); } - gUnk_081104EC[this->action](this); + scriptedActionFuncs[this->action](this); } else { - gUnk_081104E0[this->action](this); + actionFuncs[this->action](this); sub_0806ED78(this); } } @@ -79,6 +91,12 @@ void sub_0806672C(Entity* this) { } void sub_0806673C(Entity* this) { + static const u16 messageIndices[] = { + 0x1058, + 0x1326, + 0x1329, + 0x132e, + }; u32 index; if (CheckGlobalFlag(2) == 0) { index = 0; @@ -89,7 +107,7 @@ void sub_0806673C(Entity* this) { } else { index = 3; } - MessageNoOverlap(gUnk_081104F8[index], this); + MessageNoOverlap(messageIndices[index], this); } void KingDaltus_Fusion(Entity* this) { From 878ad8878e4eace3ce5d76841bbbb6c9e5707a7d Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 21:30:24 +0300 Subject: [PATCH 03/12] Put const data into ministerPotho --- assets/assets.json | 5 ----- data/const/npc/ministerPotho.s | 13 ------------- linker.ld | 2 +- src/npc/ministerPotho.c | 21 ++++++++++++++++----- 4 files changed, 17 insertions(+), 24 deletions(-) delete mode 100644 data/const/npc/ministerPotho.s diff --git a/assets/assets.json b/assets/assets.json index b0d0d362..f07c2224 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37069,11 +37069,6 @@ "size": 38, "type": "animation" }, - { - "path": "ministerPotho/gUnk_08110650.bin", - "start": 1115728, - "size": 8 - }, { "path": "animations/gSpriteAnimations_Npc26_0.bin", "start": 1115880, diff --git a/data/const/npc/ministerPotho.s b/data/const/npc/ministerPotho.s deleted file mode 100644 index 767beb71..00000000 --- a/data/const/npc/ministerPotho.s +++ /dev/null @@ -1,13 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08110644:: @ 08110644 - .4byte sub_080667E4 - .4byte sub_08066808 - .4byte sub_0806685C - -gUnk_08110650:: @ 08110650 - .incbin "ministerPotho/gUnk_08110650.bin" diff --git a/linker.ld b/linker.ld index 9986bc6e..ecf901f2 100644 --- a/linker.ld +++ b/linker.ld @@ -1214,7 +1214,7 @@ SECTIONS { src/npc/npc23.o(.rodata); src/npc/kingDaltus.o(.rodata); data/animations/npc/kingDaltus.o(.rodata); - data/const/npc/ministerPotho.o(.rodata); + src/npc/ministerPotho.o(.rodata); data/animations/npc/ministerPotho.o(.rodata); src/npc/npc26.o(.rodata); data/animations/npc/npc26.o(.rodata); diff --git a/src/npc/ministerPotho.c b/src/npc/ministerPotho.c index f7c1652a..05da19f4 100644 --- a/src/npc/ministerPotho.c +++ b/src/npc/ministerPotho.c @@ -4,16 +4,21 @@ #include "npc.h" #include "item.h" -extern void (*const gUnk_08110644[])(Entity*); void sub_08066864(Entity*); - -extern u16 gUnk_08110650[]; +void sub_080667E4(Entity*); +void sub_08066808(Entity*); +void sub_0806685C(Entity*); void MinisterPotho(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + sub_080667E4, + sub_08066808, + sub_0806685C, + }; if ((this->flags & ENT_SCRIPTED) != 0) { sub_08066864(this); } else { - gUnk_08110644[this->action](this); + actionFuncs[this->action](this); sub_0806ED78(this); } } @@ -81,6 +86,12 @@ void sub_080668F0(Entity* this) { } void sub_08066904(Entity* this) { + static const u16 messageIndices[] = { + 0x105a, + 0x1327, + 0x132a, + 0x132f, + }; u32 index; if (CheckGlobalFlag(2) == 0) { index = 0; @@ -91,7 +102,7 @@ void sub_08066904(Entity* this) { } else { index = 3; } - MessageNoOverlap(gUnk_08110650[index], this); + MessageNoOverlap(messageIndices[index], this); } void MinisterPotho_Fusion(Entity* this) { From 212dffac899055a6dc60680632621e77c069f487 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 21:41:34 +0300 Subject: [PATCH 04/12] Put const data into zelda and mutoh --- assets/assets.json | 20 -------------------- data/const/npc/mutoh.s | 11 ----------- data/const/npc/zelda.s | 15 --------------- linker.ld | 4 ++-- src/npc/mutoh.c | 27 ++++++++++++++++++++------- src/npc/zelda.c | 17 ++++++++++++----- 6 files changed, 34 insertions(+), 60 deletions(-) delete mode 100644 data/const/npc/mutoh.s delete mode 100644 data/const/npc/zelda.s diff --git a/assets/assets.json b/assets/assets.json index f07c2224..7a351941 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37285,16 +37285,6 @@ "size": 24, "type": "animation" }, - { - "path": "zelda/gUnk_08110BE0.bin", - "start": 1117152, - "size": 32 - }, - { - "path": "zelda/gUnk_08110C00.bin", - "start": 1117184, - "size": 12 - }, { "path": "animations/gSpriteAnimations_Mutoh_0.bin", "start": 1117280, @@ -37319,16 +37309,6 @@ "size": 5, "type": "animation" }, - { - "path": "mutoh/gUnk_08110C0C.bin", - "start": 1117196, - "size": 4 - }, - { - "path": "mutoh/gUnk_08110C10.bin", - "start": 1117200, - "size": 80 - }, { "path": "animations/gSpriteAnimations_Carpenter_0.bin", "start": 1117448, diff --git a/data/const/npc/mutoh.s b/data/const/npc/mutoh.s deleted file mode 100644 index 082d57e1..00000000 --- a/data/const/npc/mutoh.s +++ /dev/null @@ -1,11 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08110C0C:: @ 08110C0C - .incbin "mutoh/gUnk_08110C0C.bin" - -gUnk_08110C10:: @ 08110C10 - .incbin "mutoh/gUnk_08110C10.bin" diff --git a/data/const/npc/zelda.s b/data/const/npc/zelda.s deleted file mode 100644 index 331b8699..00000000 --- a/data/const/npc/zelda.s +++ /dev/null @@ -1,15 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08110BD8:: @ 08110BD8 - .4byte sub_08066CCC - .4byte sub_08066CF8 - -gUnk_08110BE0:: @ 08110BE0 - .incbin "zelda/gUnk_08110BE0.bin" - -gUnk_08110C00:: @ 08110C00 - .incbin "zelda/gUnk_08110C00.bin" diff --git a/linker.ld b/linker.ld index ecf901f2..fac0986a 100644 --- a/linker.ld +++ b/linker.ld @@ -1220,8 +1220,8 @@ SECTIONS { data/animations/npc/npc26.o(.rodata); src/npc/vaati.o(.rodata); data/animations/npc/vaati.o(.rodata); - data/const/npc/zelda.o(.rodata); - data/const/npc/mutoh.o(.rodata); + src/npc/zelda.o(.rodata); + src/npc/mutoh.o(.rodata); data/animations/npc/mutoh.o(.rodata); data/const/npc/carpenter.o(.rodata); data/animations/npc/carpenter.o(.rodata); diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index 1427f124..6171f818 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -6,9 +6,11 @@ #include "npc.h" #include "item.h" -extern SpriteLoadData gUnk_08110C00; -extern u16 gUnk_08110C0C[]; -extern Dialog gUnk_08110C10[]; +static const SpriteLoadData gUnk_08110C00[] = { + { 0x51, 0x3e, 0x4 }, + { 0x1051, 0x3e, 0x4 }, + { 0, 0, 0 }, +}; void Mutoh(Entity* this) { if (*(u32*)&this->cutsceneBeh == 0) { @@ -17,7 +19,7 @@ void Mutoh(Entity* this) { switch (this->action) { case 0: - if (LoadExtraSpriteData(this, &gUnk_08110C00)) { + if (LoadExtraSpriteData(this, gUnk_08110C00)) { this->action = 1; this->spriteSettings.draw = TRUE; SetDefaultPriority(this, PRIO_MESSAGE); @@ -49,6 +51,10 @@ void Mutoh_Head(Entity* this) { } void sub_080670B4(Entity* this) { + static const u16 messageIndices[] = { + 0x1b02, + 0x1b03, + }; u32 uVar2; uVar2 = 0; @@ -57,11 +63,18 @@ void sub_080670B4(Entity* this) { uVar2 = 1; } } - MessageNoOverlap(gUnk_08110C0C[uVar2], this); + MessageNoOverlap(messageIndices[uVar2], this); } void sub_080670E4(Entity* this) { - ShowNPCDialogue(this, &gUnk_08110C10[gSave.global_progress]); + static const Dialog dialogs[] = { + { 0, 0, 3, 1, { 0x4101, 0x4100 } }, { 0, 0, 3, 1, { 0x4101, 0x4100 } }, + { 0, 0, 3, 1, { 0x4101, 0x4100 } }, { 0, 0, 3, 1, { 0x4101, 0x4100 } }, + { 0, 0, 3, 1, { 0x4101, 0x4100 } }, { 0xb, 3, 4, 1, { 0x4104, 0x4102 } }, + { 0xb, 3, 4, 1, { 0x4104, 0x4103 } }, { 0xb, 3, 4, 1, { 0x4104, 0x4103 } }, + { 0xb, 3, 4, 1, { 0x4104, 0x4105 } }, { 0xb, 3, 4, 1, { 0x4104, 0x4105 } }, + }; + ShowNPCDialogue(this, &dialogs[gSave.global_progress]); } void sub_08067100(Entity* this) { @@ -71,7 +84,7 @@ void sub_08067100(Entity* this) { void Mutoh_Fusion(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_08110C00) != 0) { + if (LoadExtraSpriteData(this, gUnk_08110C00) != 0) { this->action++; this->spriteSettings.draw = TRUE; InitializeAnimation(this, 2); diff --git a/src/npc/zelda.c b/src/npc/zelda.c index be151753..df2ed8f3 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -9,11 +9,14 @@ void sub_08068680(Entity*, Entity*); void sub_08068694(Entity*, Entity*); extern Entity* GetEntityByType(u32, u32); extern void sub_080686C4(Entity*, Entity*); - -extern void (*gUnk_08110BD8[])(Entity* ent); -extern u16 gUnk_08110BE0[]; +void sub_08066CCC(Entity*); +void sub_08066CF8(Entity*); void Zelda(Entity* this) { + static void (*const gUnk_08110BD8[])(Entity * ent) = { + sub_08066CCC, + sub_08066CF8, + }; gUnk_08110BD8[this->action](this); } @@ -161,9 +164,13 @@ void sub_08066E80(Entity* this, ScriptExecutionContext* context) { gActiveScriptInfo.commandSize = 0; } +static const u16 gUnk_08110BE0[] = { + 0x81c, 0x85c, 0x89c, 0x8dc, 0x91c, 0x95c, 0x99c, 0x9dc, 0x9dd, 0x9de, 0x9df, 0x9e0, 0x9e1, 0x9e2, 0x0, 0x0, +}; + void sub_08066F94(void) { u16 uVar1; - u16* puVar2; + const u16* puVar2; puVar2 = gUnk_08110BE0; while (*puVar2 != 0) { @@ -175,7 +182,7 @@ void sub_08066F94(void) { void sub_08066FB8(void) { u16 uVar1; - u16* puVar2; + const u16* puVar2; puVar2 = gUnk_08110BE0; while (*puVar2 != 0) { From 6047d2ec3e2233ddf813c41f08482f4aa1333b67 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 21:48:44 +0300 Subject: [PATCH 05/12] Put const data into carpenter --- assets/assets.json | 15 --------------- data/const/npc/carpenter.s | 14 -------------- linker.ld | 2 +- src/npc/carpenter.c | 19 ++++++++++++------- 4 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 data/const/npc/carpenter.s diff --git a/assets/assets.json b/assets/assets.json index 7a351941..5f6d3734 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37405,21 +37405,6 @@ "size": 5, "type": "animation" }, - { - "path": "carpenter/gUnk_08110CA8.bin", - "start": 1117352, - "size": 64 - }, - { - "path": "carpenter/gUnk_08110CE8.bin", - "start": 1117416, - "size": 24 - }, - { - "path": "carpenter/gUnk_08110D00.bin", - "start": 1117440, - "size": 8 - }, { "path": "animations/gSpriteAnimations_CastorWildsStatue_0.bin", "start": 1117852, diff --git a/data/const/npc/carpenter.s b/data/const/npc/carpenter.s deleted file mode 100644 index abe3d184..00000000 --- a/data/const/npc/carpenter.s +++ /dev/null @@ -1,14 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08110CA8:: @ 08110CA8 - .incbin "carpenter/gUnk_08110CA8.bin" - -gUnk_08110CE8:: @ 08110CE8 - .incbin "carpenter/gUnk_08110CE8.bin" - -gUnk_08110D00:: @ 08110D00 - .incbin "carpenter/gUnk_08110D00.bin" diff --git a/linker.ld b/linker.ld index fac0986a..00076aa9 100644 --- a/linker.ld +++ b/linker.ld @@ -1223,7 +1223,7 @@ SECTIONS { src/npc/zelda.o(.rodata); src/npc/mutoh.o(.rodata); data/animations/npc/mutoh.o(.rodata); - data/const/npc/carpenter.o(.rodata); + src/npc/carpenter.o(.rodata); data/animations/npc/carpenter.o(.rodata); data/const/npc/castorWildsStatue.o(.rodata); data/animations/npc/castorWildsStatue.o(.rodata); diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index eae33283..846c5d5a 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -4,11 +4,12 @@ #include "npc.h" #include "item.h" -extern SpriteLoadData gUnk_08110CA8[]; - -extern u16 gUnk_08110CE8[]; - -extern Dialog gUnk_08110D00; +static const SpriteLoadData gUnk_08110CA8[] = { + { 0x51, 0x3f, 0x4 }, { 0x1451, 0x3f, 0x4 }, { 0x4001, 0x3f, 0x4 }, { 0, 0, 0 }, + { 0x51, 0x3f, 0x4 }, { 0x1451, 0x3f, 0x4 }, { 0x4001, 0x3f, 0x4 }, { 0, 0, 0 }, + { 0x51, 0x3f, 0x4 }, { 0x1451, 0x3f, 0x4 }, { 0, 0, 0 }, { 0, 0, 0 }, + { 0x51, 0x3f, 0x4 }, { 0x1451, 0x3f, 0x4 }, { 0, 0, 0 }, { 0, 0, 0 }, +}; void Carpenter(Entity* this) { if (*(u32*)&this->cutsceneBeh == 0) { @@ -67,6 +68,9 @@ void sub_080672B0(Entity* this, ScriptExecutionContext* context) { } void sub_080672C8(Entity* this) { + static const u16 messageIndices[] = { + 0x1b0d, 0x1b0e, 0x0, 0x1b18, 0x1b19, 0x0, 0x1b23, 0x1b23, 0x0, 0x1b26, 0x1b26, 0x0, + }; u32 dialog = 0; u32 tmp; if (GetInventoryValue(ITEM_GUST_JAR) == 0) { @@ -74,11 +78,12 @@ void sub_080672C8(Entity* this) { dialog = 1; } } - MessageNoOverlap(gUnk_08110CE8[(dialog * 2 + this->type * 6) / 2], this); + MessageNoOverlap(messageIndices[(dialog * 2 + this->type * 6) / 2], this); } void sub_08067304(Entity* this) { - ShowNPCDialogue(this, &gUnk_08110D00); + static const Dialog dialog = { 0xb, 3, 4, 1, { 0x3642, 0x3641 } }; + ShowNPCDialogue(this, &dialog); } void sub_08067314(Entity* this) { From 08eba596c43f23d4e26822b31f145b56fb538899 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 22:01:25 +0300 Subject: [PATCH 06/12] 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; } From 1dc422e07c4c0aa68d7965c26f93ba3b002ffd7e Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Fri, 15 Apr 2022 22:31:55 +0300 Subject: [PATCH 07/12] Put const data into cat --- assets/assets.json | 30 --------- data/const/npc/cat.s | 34 ---------- linker.ld | 2 +- src/npc/cat.c | 148 ++++++++++++++++++++++++++++++++----------- 4 files changed, 113 insertions(+), 101 deletions(-) delete mode 100644 data/const/npc/cat.s diff --git a/assets/assets.json b/assets/assets.json index 65b149ad..811fd1c2 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37517,36 +37517,6 @@ "size": 36, "type": "animation" }, - { - "path": "cat/gUnk_08110EF0.bin", - "start": 1117936, - "size": 8 - }, - { - "path": "cat/gUnk_08110EF8.bin", - "start": 1117944, - "size": 480 - }, - { - "path": "cat/gUnk_081110FC.bin", - "start": 1118460, - "size": 8 - }, - { - "path": "cat/gUnk_08111104.bin", - "start": 1118468, - "size": 8 - }, - { - "path": "cat/gUnk_0811110C.bin", - "start": 1118476, - "size": 3 - }, - { - "path": "cat/gUnk_0811110F.bin", - "start": 1118479, - "size": 5 - }, { "path": "animations/gSpriteAnimations_MountainMinish_0.bin", "start": 1119104, diff --git a/data/const/npc/cat.s b/data/const/npc/cat.s deleted file mode 100644 index 0b3867cc..00000000 --- a/data/const/npc/cat.s +++ /dev/null @@ -1,34 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08110EF0:: @ 08110EF0 - .incbin "cat/gUnk_08110EF0.bin" - -gUnk_08110EF8:: @ 08110EF8 - .incbin "cat/gUnk_08110EF8.bin" - -gCat:: @ 081110D8 - .4byte sub_080677EC - .4byte sub_080678AC - .4byte sub_08067904 - .4byte sub_0806797C - .4byte sub_0806799C - .4byte sub_080679C4 - .4byte sub_08067A0C - .4byte sub_08067A78 - .4byte sub_08067A98 - -gUnk_081110FC:: @ 081110FC - .incbin "cat/gUnk_081110FC.bin" - -gUnk_08111104:: @ 08111104 - .incbin "cat/gUnk_08111104.bin" - -gUnk_0811110C:: @ 0811110C - .incbin "cat/gUnk_0811110C.bin" - -gUnk_0811110F:: @ 0811110F - .incbin "cat/gUnk_0811110F.bin" diff --git a/linker.ld b/linker.ld index c5acbcb6..47897e6e 100644 --- a/linker.ld +++ b/linker.ld @@ -1227,7 +1227,7 @@ SECTIONS { data/animations/npc/carpenter.o(.rodata); src/npc/castorWildsStatue.o(.rodata); data/animations/npc/castorWildsStatue.o(.rodata); - data/const/npc/cat.o(.rodata); + src/npc/cat.o(.rodata); data/animations/npc/cat.o(.rodata); src/npc/mountainMinish.o(.rodata); data/animations/npc/mountainMinish.o(.rodata); diff --git a/src/npc/cat.c b/src/npc/cat.c index b93d13e1..d82b1b0f 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -6,47 +6,106 @@ #include "npc.h" #include "enemy.h" -extern void sub_08067C44(Entity*); +static const Hitbox gUnk_08110EF0 = { 0, -1, { 5, 3, 3, 5 }, 5, 4 }; -extern void (*gCat[9])(Entity*); - -extern Dialog gUnk_08110EF8; - -extern Hitbox gUnk_08110EF0; -extern void sub_08067B08(Entity*); - -extern u32 sub_08067D20(Entity*); -extern void sub_08067AAC(Entity*); -extern void sub_08067B34(Entity*); -extern void sub_08067B80(Entity*, u32); - -extern void sub_08067B70(Entity*); - -extern void sub_08067C24(Entity*); -extern void sub_08067BD4(Entity*); -extern u32 sub_08067D74(Entity*); -extern void sub_08067C18(Entity*); +void sub_08067C44(Entity*); +void sub_08067B08(Entity*); +u32 sub_08067D20(Entity*); +void sub_08067AAC(Entity*); +void sub_08067B34(Entity*); +void sub_08067B80(Entity*, u32); +void sub_08067B70(Entity*); +void sub_08067C24(Entity*); +void sub_08067BD4(Entity*); +u32 sub_08067D74(Entity*); +void sub_08067C18(Entity*); +void sub_08067DCC(Entity*, u32); +void sub_08067DDC(Entity*); +void sub_080677EC(Entity*); +void sub_080678AC(Entity*); +void sub_08067904(Entity*); +void sub_0806797C(Entity*); +void sub_0806799C(Entity*); +void sub_080679C4(Entity*); +void sub_08067A0C(Entity*); +void sub_08067A78(Entity*); +void sub_08067A98(Entity*); extern Hitbox* gUnk_08111154[8]; -extern void sub_08067DDC(Entity*); - -extern u16 gUnk_081110FC[4]; -extern void sub_08067DCC(Entity*, u32); - -extern u8 gUnk_0811110C[2]; -extern u32 gUnk_0811110F; - -extern u16 gUnk_08111104[]; - -extern u32 sub_0806FCA0(Entity*, Entity*); void sub_08067790(Entity* this) { - ShowNPCDialogue(this, &gUnk_08110EF8 + this->type * 10 + gSave.global_progress); + static const Dialog dialogs[][10] = { + { { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3503, 0x3504 }, + { 0, 0, 6, 1, 0x3603, 0x3604 }, + { 0, 0, 6, 1, 0x3703, 0x3704 }, + { 0, 0, 6, 1, 0x3803, 0x3804 }, + { 0, 0, 6, 1, 0x3902, 0x3903 }, + { 0, 0, 6, 1, 0x3902, 0x3903 } }, + { { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3503, 0x3504 }, + { 0, 0, 6, 1, 0x3603, 0x3604 }, + { 0, 0, 6, 1, 0x3703, 0x3704 }, + { 0, 0, 6, 1, 0x3803, 0x3804 }, + { 0, 0, 6, 1, 0x3902, 0x3903 }, + { 0, 0, 6, 1, 0x3902, 0x3903 } }, + { { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3503, 0x3504 }, + { 0, 0, 6, 1, 0x3603, 0x3604 }, + { 0, 0, 6, 1, 0x3703, 0x3704 }, + { 0, 0, 6, 1, 0x3803, 0x3804 }, + { 0, 0, 6, 1, 0x3902, 0x3903 }, + { 0, 0, 6, 1, 0x3902, 0x3903 } }, + { { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3503, 0x3504 }, + { 0, 0, 6, 1, 0x3603, 0x3604 }, + { 0, 0, 6, 1, 0x3703, 0x3704 }, + { 0, 0, 6, 1, 0x3803, 0x3804 }, + { 0, 0, 6, 1, 0x3902, 0x3903 }, + { 0, 0, 6, 1, 0x3902, 0x3903 } }, + { { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 }, + { 0, 0, 6, 1, 0x4e17, 0x4e18 } }, + { { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3407, 0x3408 }, + { 0, 0, 6, 1, 0x3503, 0x3504 }, + { 0, 0, 6, 1, 0x3603, 0x3604 }, + { 0, 0, 6, 1, 0x3703, 0x3704 }, + { 0, 0, 6, 1, 0x3803, 0x3804 }, + { 0, 0, 6, 1, 0x3902, 0x3903 }, + { 0, 0, 6, 1, 0x3902, 0x3903 } }, + }; + ShowNPCDialogue(this, &dialogs[this->type][gSave.global_progress]); } // Main void Cat(Entity* ent) { - gCat[ent->action](ent); + static void (*const actionFuncs[9])(Entity*) = { + sub_080677EC, sub_080678AC, sub_08067904, sub_0806797C, sub_0806799C, + sub_080679C4, sub_08067A0C, sub_08067A78, sub_08067A98, + }; + actionFuncs[ent->action](ent); sub_08067C44(ent); if (((ent->flags & ENT_COLLIDE) == 0) && (ent->type != 5)) { sub_0806ED78(ent); @@ -71,7 +130,7 @@ void sub_080677EC(Entity* this) { } this->field_0x68.HALF.LO = sub_0801E99C(this); - this->hitbox = &gUnk_08110EF0; + this->hitbox = (Hitbox*)&gUnk_08110EF0; uVar2 = sub_0805ACC0(this); if (uVar2 == 0) { uVar2 = this->x.HALF.HI; @@ -198,6 +257,23 @@ void sub_08067A98(Entity* this) { } } +static const u16 gUnk_081110FC[4] = { + 60, + 150, + 240, + 400, +}; + +static const u16 gUnk_08111104[] = { + 180, + 300, + 450, + 600, +}; + +static const u8 gUnk_0811110C[] = { 0x3c, 0x96, 0x14 }; +static const u8 gUnk_0811110F[] = { 0, -4, 8, 8, 0 }; + void sub_08067AAC(Entity* this) { this->action = 2; this->field_0x70.HALF.HI = gUnk_081110FC[(Random() & 3)]; @@ -205,7 +281,7 @@ void sub_08067AAC(Entity* this) { this->spriteSettings.flipX = this->direction >> 4 ^ 1; sub_08067DCC(this, 3); - sub_08078850(this, 0, gUnk_0811110C[2], &gUnk_0811110F); + sub_08078850(this, 0, gUnk_0811110C[2], gUnk_0811110F); } void sub_08067B08(Entity* this) { @@ -217,7 +293,7 @@ void sub_08067B08(Entity* this) { void sub_08067B34(Entity* this) { sub_08067DCC(this, 0); this->frameDuration = (Random() & 0x30) + 0xb4; - sub_08078850(this, 0, gUnk_0811110C[this->spriteSettings.flipX], &gUnk_0811110F); + sub_08078850(this, 0, gUnk_0811110C[this->spriteSettings.flipX], gUnk_0811110F); } void sub_08067B70(Entity* this) { @@ -368,7 +444,7 @@ void sub_08067DDC(Entity* this) { COLLISION_OFF(this); this->contactFlags = 0; this->iframes = 0; - this->hitbox = &gUnk_08110EF0; + this->hitbox = (Hitbox*)&gUnk_08110EF0; } void Cat_Fusion(Entity* this) { From 4b5643970633e87dbc5990176c90b2969077da14 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 00:28:35 +0300 Subject: [PATCH 08/12] Put const data in melari --- assets/assets.json | 15 --------------- data/const/npc/melari.s | 18 ------------------ linker.ld | 2 +- src/npc/melari.c | 33 +++++++++++++++++++++------------ 4 files changed, 22 insertions(+), 46 deletions(-) delete mode 100644 data/const/npc/melari.s diff --git a/assets/assets.json b/assets/assets.json index 811fd1c2..91bc1f61 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -37619,21 +37619,6 @@ "size": 8, "type": "animation" }, - { - "path": "melari/gUnk_08111520.bin", - "start": 1119520, - "size": 16 - }, - { - "path": "melari/gUnk_08111538.bin", - "start": 1119544, - "size": 6 - }, - { - "path": "melari/gUnk_0811153E.bin", - "start": 1119550, - "size": 6 - }, { "path": "animations/gSpriteAnimations_BladeBrothers_1_0.bin", "start": 1120113, diff --git a/data/const/npc/melari.s b/data/const/npc/melari.s deleted file mode 100644 index 222f7c71..00000000 --- a/data/const/npc/melari.s +++ /dev/null @@ -1,18 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08111520:: @ 08111520 - .incbin "melari/gUnk_08111520.bin" - -gUnk_08111530:: @ 08111530 - .4byte sub_08068708 - .4byte sub_08068730 - -gUnk_08111538:: @ 08111538 - .incbin "melari/gUnk_08111538.bin" - -gUnk_0811153E:: @ 0811153E - .incbin "melari/gUnk_0811153E.bin" diff --git a/linker.ld b/linker.ld index 47897e6e..b66c3561 100644 --- a/linker.ld +++ b/linker.ld @@ -1231,7 +1231,7 @@ SECTIONS { data/animations/npc/cat.o(.rodata); src/npc/mountainMinish.o(.rodata); data/animations/npc/mountainMinish.o(.rodata); - data/const/npc/melari.o(.rodata); + src/npc/melari.o(.rodata); data/animations/npc/melari.o(.rodata); data/const/npc/bladeBrothers.o(.rodata); data/animations/npc/bladeBrothers.o(.rodata); diff --git a/src/npc/melari.c b/src/npc/melari.c index 9bc4b8a4..fe4f9c71 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -1,17 +1,24 @@ #include "npc.h" #include "item.h" -extern void sub_08068780(Entity*); +void sub_08068780(Entity*); +void sub_08068708(Entity*); +void sub_08068730(Entity*); -extern void (*const gUnk_08111530[])(Entity*); - -extern SpriteLoadData gUnk_08111520; -extern u16 gUnk_0811153E[]; -extern u16 gUnk_08111538[]; +static const SpriteLoadData gUnk_08111520[] = { + { 0xb5, 0x1a, 0x4 }, + { 0x1cb5, 0x1a, 0x4 }, + { 0x50b4, 0x1c, 0x4 }, + { 0, 0, 0 }, +}; void Melari(Entity* this) { + static void (*const scriptedActionFuncs[])(Entity*) = { + sub_08068708, + sub_08068730, + }; if ((this->flags & ENT_SCRIPTED) == 0) { - gUnk_08111530[this->action](this); + scriptedActionFuncs[this->action](this); sub_0806ED78(this); } else { sub_08068780(this); @@ -19,7 +26,7 @@ void Melari(Entity* this) { } void sub_08068708(Entity* this) { - if (LoadExtraSpriteData(this, &gUnk_08111520) != 0) { + if (LoadExtraSpriteData(this, gUnk_08111520) != 0) { this->action = 1; InitializeAnimation(this, 0); sub_08078778(this); @@ -47,11 +54,13 @@ void sub_08068730(Entity* this) { } void sub_08068780(Entity* this) { + static const u16 soundOnScreen[] = { SFX_HAMMER1, SFX_HAMMER2, SFX_HAMMER3 }; + static const u16 soundNotOnScreen[] = { SFX_HAMMER4, SFX_HAMMER5, SFX_HAMMER6 }; Entity* ent; switch (this->action) { case 0: - if (LoadExtraSpriteData(this, &gUnk_08111520) == 0) { + if (LoadExtraSpriteData(this, gUnk_08111520) == 0) { return; } this->action = 1; @@ -80,9 +89,9 @@ void sub_08068780(Entity* this) { if (this->frame & 0x40) { this->frame &= 0xbf; if (CheckOnScreen(this) == 0) { - SoundReq(gUnk_0811153E[(s32)Random() % 3]); + SoundReq(soundNotOnScreen[(s32)Random() % 3]); } else { - EnqueueSFX(gUnk_08111538[(s32)Random() % 3]); + EnqueueSFX(soundOnScreen[(s32)Random() % 3]); } ent = CreateFx(this, FX_STARS2, 0x20); if (ent != NULL) { @@ -140,7 +149,7 @@ void sub_08068964(Entity* this) { void Melari_Fusion(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_08111520)) { + if (LoadExtraSpriteData(this, gUnk_08111520)) { this->action++; this->spriteSettings.draw = TRUE; InitializeAnimation(this, 6); From d93cc82ccff4e1f2921ef76818ee39e809ef2c97 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 00:37:14 +0300 Subject: [PATCH 09/12] 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]); } From 02f5e4cc5f8808c4aed3ec2bade32699ad5b2cbd Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 00:50:17 +0300 Subject: [PATCH 10/12] Match Syrup_Head and put const data in syrup --- asm/non_matching/syrup/Syrup_Head.inc | 75 --------------------------- assets/assets.json | 25 --------- data/const/npc/syrup.s | 24 --------- include/physics.h | 1 + linker.ld | 2 +- src/npc/syrup.c | 66 ++++++++++++++++++----- 6 files changed, 54 insertions(+), 139 deletions(-) delete mode 100644 asm/non_matching/syrup/Syrup_Head.inc delete mode 100644 data/const/npc/syrup.s diff --git a/asm/non_matching/syrup/Syrup_Head.inc b/asm/non_matching/syrup/Syrup_Head.inc deleted file mode 100644 index bfc12df8..00000000 --- a/asm/non_matching/syrup/Syrup_Head.inc +++ /dev/null @@ -1,75 +0,0 @@ - .syntax unified - push {r4, r5, r6, lr} - mov r6, sb - mov r5, r8 - push {r5, r6} - adds r5, r0, #0 - adds r0, #0x5b - ldrb r0, [r0] - movs r1, #1 - mov sb, r1 - mov r2, sb - ands r2, r0 - mov sb, r2 - adds r0, r5, #0 - adds r0, #0x5a - ldrb r1, [r0] - lsrs r0, r1, #4 - mov r8, r0 - movs r0, #7 - mov r2, r8 - ands r2, r0 - mov r8, r2 - movs r6, #7 - ands r6, r1 - ldrb r4, [r5, #0x14] - lsrs r4, r4, #1 - ldr r1, _0806A350 @ =gUnk_081121E4 - ldrb r0, [r5, #0x1e] - lsls r0, r0, #2 - adds r0, r4, r0 - adds r0, r0, r1 - ldrb r2, [r0] - adds r2, #0x10 - adds r0, r5, #0 - movs r1, #0 - bl SetExtraSpriteFrame - ldr r0, _0806A354 @ =gUnk_08112204 - adds r4, r4, r0 - ldrb r2, [r4] - adds r0, r5, #0 - movs r1, #0 - bl sub_0806FF48 - adds r0, r5, #0 - movs r1, #1 - mov r2, r8 - bl SetExtraSpriteFrame - adds r6, #0x1c - adds r0, r5, #0 - movs r1, #2 - adds r2, r6, #0 - bl SetExtraSpriteFrame - movs r0, #0x1a - add sb, r0 - adds r0, r5, #0 - movs r1, #3 - mov r2, sb - bl SetExtraSpriteFrame - adds r0, r5, #0 - movs r1, #1 - movs r2, #0 - bl SetSpriteSubEntryOffsetData1 - adds r0, r5, #0 - movs r1, #1 - movs r2, #3 - bl SetSpriteSubEntryOffsetData2 - adds r0, r5, #0 - bl sub_0807000C - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, pc} - .align 2, 0 -_0806A350: .4byte gUnk_081121E4 -_0806A354: .4byte gUnk_08112204 - .syntax divided diff --git a/assets/assets.json b/assets/assets.json index 4b507794..fb18e760 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -38386,31 +38386,6 @@ "size": 36, "type": "animation" }, - { - "path": "syrup/gUnk_081121B4.bin", - "start": 1122740, - "size": 16 - }, - { - "path": "syrup/gUnk_081121C4.bin", - "start": 1122756, - "size": 16 - }, - { - "path": "syrup/gUnk_081121DC.bin", - "start": 1122780, - "size": 8 - }, - { - "path": "syrup/gUnk_081121E4.bin", - "start": 1122788, - "size": 32 - }, - { - "path": "syrup/gUnk_08112204.bin", - "start": 1122820, - "size": 4 - }, { "path": "animations/gSpriteAnimations_Rem_1.bin", "start": 1123008, diff --git a/data/const/npc/syrup.s b/data/const/npc/syrup.s deleted file mode 100644 index b6586e6c..00000000 --- a/data/const/npc/syrup.s +++ /dev/null @@ -1,24 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_081121B4:: @ 081121B4 - .incbin "syrup/gUnk_081121B4.bin" - -gUnk_081121C4:: @ 081121C4 - .incbin "syrup/gUnk_081121C4.bin" - -gUnk_081121D4:: @ 081121D4 - .4byte sub_0806A1F8 - .4byte sub_0806A234 - -gUnk_081121DC:: @ 081121DC - .incbin "syrup/gUnk_081121DC.bin" - -gUnk_081121E4:: @ 081121E4 - .incbin "syrup/gUnk_081121E4.bin" - -gUnk_08112204:: @ 08112204 - .incbin "syrup/gUnk_08112204.bin" diff --git a/include/physics.h b/include/physics.h index 0046fbd5..a5aee40d 100644 --- a/include/physics.h +++ b/include/physics.h @@ -39,6 +39,7 @@ u32 sub_0806F5B0(u32); u32 sub_0806F824(Entity*, Entity*, s32, s32); u32 sub_0806F948(Entity*); void sub_0806FBB4(Entity*); +void sub_0806FF48(Entity*, u32, u32); void sub_0806FCF4(Entity*, s32, s32, s32); void sub_0806FD3C(Entity*); bool32 sub_0806FDA0(Entity*); diff --git a/linker.ld b/linker.ld index 429eeb7a..6a2126bc 100644 --- a/linker.ld +++ b/linker.ld @@ -1245,7 +1245,7 @@ SECTIONS { data/animations/npc/gorman.o(.rodata); data/const/npc/dog.o(.rodata); data/animations/npc/dog.o(.rodata); - data/const/npc/syrup.o(.rodata); + src/npc/syrup.o(.rodata); data/animations/npc/syrup.o(.rodata); src/npc/rem.o(.rodata); data/animations/npc/rem.o(.rodata); diff --git a/src/npc/syrup.c b/src/npc/syrup.c index d1535e72..51c24059 100644 --- a/src/npc/syrup.c +++ b/src/npc/syrup.c @@ -2,23 +2,37 @@ #include "functions.h" #include "object.h" -extern void (*gUnk_081121D4[])(Entity*); +static const SpriteLoadData gUnk_081121B4[] = { + { 0xc2, 0x46, 0x4 }, + { 0x44c2, 0x46, 0x4 }, + { 0x54c3, 0x46, 0x4 }, + { 0x70c2, 0x46, 0x4 }, +}; +static const SpriteLoadData gUnk_081121C4[] = { + { 0xc2, 0x46, 0x4 }, + { 0x44c2, 0x46, 0x4 }, + { 0x54c4, 0x46, 0x4 }, + { 0x70c2, 0x46, 0x4 }, +}; -extern SpriteLoadData gUnk_081121C4; -extern SpriteLoadData gUnk_081121B4; - -extern void sub_0806A26C(Entity*); +void sub_0806A26C(Entity*); +void sub_0806A1F8(Entity*); +void sub_0806A234(Entity*); void Syrup(Entity* this) { - gUnk_081121D4[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_0806A1F8, + sub_0806A234, + }; + actionFuncs[this->action](this); sub_0806ED78(this); } void sub_0806A1F8(Entity* this) { u32 iVar1; - SpriteLoadData* paVar2; + const SpriteLoadData* paVar2; - this->type == 0 ? (paVar2 = &gUnk_081121B4) : (paVar2 = &gUnk_081121C4); + this->type == 0 ? (paVar2 = gUnk_081121B4) : (paVar2 = gUnk_081121C4); iVar1 = LoadExtraSpriteData(this, paVar2); if (iVar1) { @@ -39,11 +53,10 @@ void sub_0806A234(Entity* this) { } } -extern u8 gUnk_081121DC[]; - void sub_0806A26C(Entity* this) { + static const s8 gUnk_081121DC[] = { -1, -2, -3, 0, 1, 2, 3, 0 }; u8 unk; - u8* ptr; + const s8* ptr; u32 uVar2, uVar1; Entity* pEVar1; pEVar1 = CreateObject(SPECIAL_FX, 0x2f, 0); @@ -51,11 +64,36 @@ void sub_0806A26C(Entity* this) { PositionEntityOnTop(this, pEVar1); uVar2 = uVar1 = Random(); ptr = gUnk_081121DC; - pEVar1->spriteOffsetX = (u8)ptr[uVar2 & 7]; + pEVar1->spriteOffsetX = ptr[uVar2 & 7]; uVar1 /= 256; uVar1 &= 7; - pEVar1->spriteOffsetY = (u8)ptr[uVar1] - 8; + pEVar1->spriteOffsetY = ptr[uVar1] - 8; } } -ASM_FUNC("asm/non_matching/syrup/Syrup_Head.inc", void Syrup_Head(Entity* this)) +static const u8 gUnk_081121E4[] = { 0x0, 0x5, 0x0, 0x5, 0x1, 0x6, 0x1, 0x6, 0x2, 0x7, 0x2, 0x7, 0x3, 0x8, 0x3, 0x8, + 0x4, 0x9, 0x4, 0x9, 0x3, 0x8, 0x3, 0x8, 0x2, 0x7, 0x2, 0x7, 0x1, 0x6, 0x1, 0x6 }; + +static const u8 gUnk_08112204[] = { 0, 1, 0, 0 }; + +void Syrup_Head(Entity* param_1) { + u32 bVar1; + u8 bVar2; + u32 uVar3; + u32 tmp1; + u32 tmp2; + + bVar1 = (param_1->frameSpriteSettings) & 1; + bVar2 = param_1->frame; + tmp1 = bVar2 >> 4 & 7; + tmp2 = (bVar2 & 7); + uVar3 = (u32)(param_1->animationState >> 1); + SetExtraSpriteFrame(param_1, 0, gUnk_081121E4[uVar3 + (u32)param_1->frameIndex * 4] + 0x10); + sub_0806FF48(param_1, 0, gUnk_08112204[uVar3]); + SetExtraSpriteFrame(param_1, 1, tmp1); + SetExtraSpriteFrame(param_1, 2, tmp2 + 0x1c); + SetExtraSpriteFrame(param_1, 3, bVar1 + 0x1a); + SetSpriteSubEntryOffsetData1(param_1, 1, 0); + SetSpriteSubEntryOffsetData2(param_1, 1, 3); + sub_0807000C(param_1); +} From 42db284296dbfef0aa9121b0c4425ed414f46799 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 00:54:59 +0300 Subject: [PATCH 11/12] Put const data in librari --- assets/assets.json | 10 ---------- data/const/npc/librari.s | 11 ----------- linker.ld | 2 +- src/npc/librari.c | 17 +++++++++++------ 4 files changed, 12 insertions(+), 28 deletions(-) delete mode 100644 data/const/npc/librari.s diff --git a/assets/assets.json b/assets/assets.json index fb18e760..f0837759 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -38904,16 +38904,6 @@ "size": 5, "type": "animation" }, - { - "path": "librari/gUnk_08112D48.bin", - "start": 1125704, - "size": 8 - }, - { - "path": "librari/gUnk_08112D50.bin", - "start": 1125712, - "size": 10 - }, { "path": "animations/gSpriteAnimations_Percy_0.bin", "start": 1125980, diff --git a/data/const/npc/librari.s b/data/const/npc/librari.s deleted file mode 100644 index d0e609a4..00000000 --- a/data/const/npc/librari.s +++ /dev/null @@ -1,11 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08112D48:: @ 08112D48 - .incbin "librari/gUnk_08112D48.bin" - -gUnk_08112D50:: @ 08112D50 - .incbin "librari/gUnk_08112D50.bin" diff --git a/linker.ld b/linker.ld index 6a2126bc..1c5ec8e8 100644 --- a/linker.ld +++ b/linker.ld @@ -1251,7 +1251,7 @@ SECTIONS { data/animations/npc/rem.o(.rodata); data/const/npc/townMinish.o(.rodata); data/animations/npc/townMinish.o(.rodata); - data/const/npc/librari.o(.rodata); + src/npc/librari.o(.rodata); data/animations/npc/librari.o(.rodata); data/const/npc/percy.o(.rodata); data/animations/npc/percy.o(.rodata); diff --git a/src/npc/librari.c b/src/npc/librari.c index 98ef6450..fc7be731 100644 --- a/src/npc/librari.c +++ b/src/npc/librari.c @@ -3,8 +3,6 @@ #include "npc.h" #include "item.h" -extern u16 gUnk_08112D48[]; - void Librari(Entity* this) { switch (this->action) { case 0: @@ -35,6 +33,12 @@ void Librari(Entity* this) { } void sub_0806B260(Entity* this, ScriptExecutionContext* context) { + static const u16 messageIndices[] = { + 0x4a19, + 0x4a1a, + 0x4a22, + 0x4a27, + }; u32 index; context->condition = 0; @@ -51,12 +55,13 @@ void sub_0806B260(Entity* this, ScriptExecutionContext* context) { } else { index = 3; } - MessageNoOverlap(gUnk_08112D48[index], this); + MessageNoOverlap(messageIndices[index], this); } -extern u16 gUnk_08112D50[]; - void sub_0806B2B4(Entity* this) { + static const u16 messageIndices[] = { + 0xdad, 0xdae, 0xdaf, 0xdb0, 0xdb1, + }; u32 index; if (CheckLocalFlag(0xb3)) { @@ -78,7 +83,7 @@ void sub_0806B2B4(Entity* this) { } else { index = 0; } - MessageNoOverlap(gUnk_08112D50[index], this); + MessageNoOverlap(messageIndices[index], this); } void Librari_Fusion(Entity* this) { From ea43424b1a5d7f755cd73c1d61ee65f0f923155b Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 01:03:03 +0300 Subject: [PATCH 12/12] Put const data in percy --- assets/assets.json | 20 -------------------- data/const/npc/percy.s | 17 ----------------- linker.ld | 2 +- src/npc/percy.c | 36 +++++++++++++++++++++++++++--------- 4 files changed, 28 insertions(+), 47 deletions(-) delete mode 100644 data/const/npc/percy.s diff --git a/assets/assets.json b/assets/assets.json index f0837759..b72b0d71 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -38952,26 +38952,6 @@ "size": 5, "type": "animation" }, - { - "path": "percy/gUnk_08112E1C.bin", - "start": 1125916, - "size": 16 - }, - { - "path": "percy/gUnk_08112E2C.bin", - "start": 1125932, - "size": 4 - }, - { - "path": "percy/gUnk_08112E2C_1.bin", - "start": 1125940, - "size": 28 - }, - { - "path": "percy/gUnk_08112E54.bin", - "start": 1125972, - "size": 8 - }, { "path": "animations/gSpriteAnimations_VaatiReborn_0.bin", "start": 1126280, diff --git a/data/const/npc/percy.s b/data/const/npc/percy.s deleted file mode 100644 index 724fd000..00000000 --- a/data/const/npc/percy.s +++ /dev/null @@ -1,17 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08112E1C:: @ 08112E1C - .incbin "percy/gUnk_08112E1C.bin" - -gUnk_08112E2C:: @ 08112E2C - .incbin "percy/gUnk_08112E2C.bin" - .4byte sub_0806B504 - .incbin "percy/gUnk_08112E2C_1.bin" - .4byte sub_0806B540 - -gUnk_08112E54:: @ 08112E54 - .incbin "percy/gUnk_08112E54.bin" diff --git a/linker.ld b/linker.ld index 1c5ec8e8..a1f97104 100644 --- a/linker.ld +++ b/linker.ld @@ -1253,7 +1253,7 @@ SECTIONS { data/animations/npc/townMinish.o(.rodata); src/npc/librari.o(.rodata); data/animations/npc/librari.o(.rodata); - data/const/npc/percy.o(.rodata); + src/npc/percy.o(.rodata); data/animations/npc/percy.o(.rodata); src/npc/vaatiReborn.o(.rodata); data/animations/npc/vaatiReborn.o(.rodata); diff --git a/src/npc/percy.c b/src/npc/percy.c index 3d7b5591..c06fa9b5 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -3,13 +3,18 @@ #include "npc.h" #include "functions.h" -extern void sub_0806B41C(Entity*); -extern void sub_0806B3CC(Entity*); +static const SpriteLoadData gUnk_08112E1C[] = { + { 0x30f6, 0x47, 0x4 }, + { 0xf6, 0x47, 0x4 }, + { 0x1cf6, 0x47, 0x4 }, + { 0, 0, 0 }, +}; +void sub_0806B41C(Entity*); +void sub_0806B3CC(Entity*); +void sub_0806B504(Entity*); +void sub_0806B540(Entity*); extern u16* gUnk_08001A7C[40]; -extern u16 gUnk_08112E54[4]; -extern Dialog gUnk_08112E2C[5]; -extern SpriteLoadData gUnk_08112E1C; void Percy_Head(Entity* this) { SetExtraSpriteFrame(this, 0, (this->frameSpriteSettings & 0x3f) + 0x13); @@ -30,7 +35,7 @@ void Percy(Entity* this) { void sub_0806B3CC(Entity* this) { if (this->action == 0) { - if (!LoadExtraSpriteData(this, &gUnk_08112E1C)) { + if (!LoadExtraSpriteData(this, gUnk_08112E1C)) { return; } this->action = 1; @@ -51,7 +56,7 @@ void sub_0806B41C(Entity* this) { switch (this->action) { case 0: - if (LoadExtraSpriteData(this, &gUnk_08112E1C)) { + if (LoadExtraSpriteData(this, gUnk_08112E1C)) { this->action = 1; this->spriteSettings.draw = 1; if (this->type2 == 2) { @@ -84,10 +89,23 @@ void sub_0806B41C(Entity* this) { } void sub_0806B4F0(Entity* this) { + static const Dialog gUnk_08112E2C[5] = { + { 0, 0, 5, 0, { .func = sub_0806B504 } }, + { 0, 0, 1, 1, { 0, 0x2312 } }, + { 0, 0, 1, 1, { 0, 0x2311 } }, + { 0, 0, 1, 1, { 0, 0x2519 } }, + { 0, 0, 5, 0, { .func = sub_0806B540 } }, + }; ShowNPCDialogue(this, &gUnk_08112E2C[this->type2]); } void sub_0806B504(Entity* this) { + static const u16 messageIndices[4] = { + 0x230c, + 0x230d, + 0x230e, + 0x2310, + }; int idx; idx = 1; @@ -98,7 +116,7 @@ void sub_0806B504(Entity* this) { SetLocalFlag(URO_POEMN_TALK); } - MessageNoOverlap(gUnk_08112E54[idx], this); + MessageNoOverlap(messageIndices[idx], this); } void sub_0806B540(Entity* this) { @@ -149,7 +167,7 @@ void sub_0806B60C(Entity* this) { void Percy_Fusion(Entity* this) { if (this->action == 0) { - if (LoadExtraSpriteData(this, &gUnk_08112E1C) != 0) { + if (LoadExtraSpriteData(this, gUnk_08112E1C) != 0) { this->action += 1; this->spriteSettings.draw = 1; InitializeAnimation(this, 2);