From 3952a4570019173954034693020ca11110f7e5dc Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 23:30:28 +0300 Subject: [PATCH] Put const data in itemOnGround --- assets/assets.json | 5 --- data/const/object/itemOnGround.s | 52 ------------------------- linker.ld | 1 - src/object/itemOnGround.c | 67 ++++++++++++++++++++++++++++---- src/scroll.c | 20 +++++++--- 5 files changed, 73 insertions(+), 72 deletions(-) delete mode 100644 data/const/object/itemOnGround.s diff --git a/assets/assets.json b/assets/assets.json index 9a48a30b..ce35da58 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -41005,11 +41005,6 @@ "DEMO_JP": -2192 } }, - { - "path": "itemOnGround/gUnk_0811E84C.bin", - "start": 1173580, - "size": 944 - }, { "path": "animations/gSpriteAnimations_DeathFx_1_0.bin", "start": 1174740, diff --git a/data/const/object/itemOnGround.s b/data/const/object/itemOnGround.s deleted file mode 100644 index 35f08bf5..00000000 --- a/data/const/object/itemOnGround.s +++ /dev/null @@ -1,52 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_0811E7C4:: @ 0811E7C4 - .4byte sub_080808D8 - .4byte sub_080808E4 - .4byte sub_08080904 - .4byte sub_08080910 - -gUnk_0811E7D4:: @ 0811E7D4 - .4byte sub_08080F20 - .4byte sub_080811EC - .4byte sub_0808122C - .4byte sub_08081328 - .4byte sub_0808136C - -gUnk_0811E7E8:: @ 0811E7E8 - .4byte sub_080810A8 - .4byte sub_080810FC - .4byte sub_08081150 - .4byte sub_08081134 - .4byte sub_08081188 - .4byte sub_080810A8 - .4byte sub_080810A8 - .4byte sub_080811AC - .4byte sub_080811C8 - .4byte sub_080811D8 - .4byte sub_080810A8 - -gUnk_0811E814:: @ 0811E814 - .4byte sub_08081248 - .4byte sub_08081248 - .4byte sub_0808126C - .4byte sub_0808127C - .4byte nullsub_113 - .4byte sub_080812A0 - .4byte sub_08081248 - .4byte sub_080812A8 - .4byte sub_080812E8 - .4byte nullsub_510 - .4byte sub_08081248 - -gUnk_0811E840:: @ 0811E840 - .4byte sub_080813D4 - .4byte sub_080813E8 - .4byte sub_080813F0 - -gUnk_0811E84C:: @ 0811E84C - .incbin "itemOnGround/gUnk_0811E84C.bin" diff --git a/linker.ld b/linker.ld index f40c3f46..63683160 100644 --- a/linker.ld +++ b/linker.ld @@ -1326,7 +1326,6 @@ SECTIONS { src/script.o(.rodata); src/scroll.o(.rodata); src/object/itemOnGround.o(.rodata); - data/const/object/itemOnGround.o(.rodata); src/object/deathFx.o(.rodata); data/animations/object/deathFx.o(.rodata); src/object/itemForSale.o(.rodata); diff --git a/src/object/itemOnGround.c b/src/object/itemOnGround.c index 8a29ce8c..55bc4208 100644 --- a/src/object/itemOnGround.c +++ b/src/object/itemOnGround.c @@ -19,13 +19,32 @@ void sub_0808153C(Entity*); void sub_08081598(Entity*); void sub_080813BC(Entity*); void sub_080810FC(Entity*); +void sub_08080F20(Entity*); +void sub_080811EC(Entity*); +void sub_0808122C(Entity*); +void sub_08081328(Entity*); +void sub_0808136C(Entity*); +void sub_080810A8(Entity*); +void sub_080810FC(Entity*); +void sub_08081150(Entity*); +void sub_08081134(Entity*); +void sub_08081188(Entity*); +void sub_080811AC(Entity*); +void sub_080811C8(Entity*); +void sub_080811D8(Entity*); +void sub_08081248(Entity*); +void sub_0808126C(Entity*); +void sub_0808127C(Entity*); +void nullsub_113(Entity*); +void sub_080812A0(Entity*); +void sub_080812A8(Entity*); +void sub_080812E8(Entity*); +void nullsub_510(Entity*); +void sub_080813D4(Entity*); +void sub_080813E8(Entity*); +void sub_080813F0(Entity*); bool32 CheckShouldPlayItemGetCutscene(Entity*); -extern void (*const gUnk_0811E7D4[])(Entity*); -extern void (*const gUnk_0811E7E8[])(Entity*); -extern void (*const gUnk_0811E814[])(Entity*); -extern void (*const gUnk_0811E840[])(Entity*); - typedef struct { u8 unk0[2]; u16 sfx; @@ -33,9 +52,10 @@ typedef struct { u8 unk5[3]; } Unk_0811E84C; -extern const Unk_0811E84C gUnk_0811E84C[]; - void ItemOnGround(Entity* this) { + static void (*const gUnk_0811E7D4[])(Entity*) = { + sub_08080F20, sub_080811EC, sub_0808122C, sub_08081328, sub_0808136C, + }; if (this->contactFlags & 0x80) { switch (this->contactFlags & 0x7F) { case 20: @@ -75,6 +95,10 @@ void ItemOnGround(Entity* this) { } void sub_08080F20(Entity* this) { + static void (*const gUnk_0811E7E8[])(Entity*) = { + sub_080810A8, sub_080810FC, sub_08081150, sub_08081134, sub_08081188, sub_080810A8, + sub_080810A8, sub_080811AC, sub_080811C8, sub_080811D8, sub_080810A8, + }; if (this->field_0x86.HWORD && CheckFlags(this->field_0x86.HWORD)) { DeleteThisEntity(); } @@ -215,6 +239,10 @@ void sub_080811EC(Entity* this) { } void sub_0808122C(Entity* this) { + static void (*const gUnk_0811E814[])(Entity*) = { + sub_08081248, sub_08081248, sub_0808126C, sub_0808127C, nullsub_113, sub_080812A0, + sub_08081248, sub_080812A8, sub_080812E8, nullsub_510, sub_08081248, + }; gUnk_0811E814[this->field_0x68.HALF.HI](this); } @@ -300,7 +328,12 @@ void sub_0808136C(Entity* this) { } void sub_080813BC(Entity* this) { - gUnk_0811E840[this->subAction](this); + static void (*const subActionFuncs[])(Entity*) = { + sub_080813D4, + sub_080813E8, + sub_080813F0, + }; + subActionFuncs[this->subAction](this); } void sub_080813D4(Entity* this) { @@ -342,6 +375,24 @@ bool32 CheckShouldPlayItemGetCutscene(Entity* this) { return ((gItemMetaData[this->type].unk3 & 0x2) || !GetInventoryValue(this->type)); } +static const Unk_0811E84C gUnk_0811E84C[118] = { + [ITEM_SHELLS] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_DUNGEON_MAP] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_COMPASS] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_BIG_KEY] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_SMALL_KEY] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_RUPEE1] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_RUPEE5] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_RUPEE20] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_RUPEE50] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_RUPEE100] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_RUPEE200] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_KINSTONE] = { { 0x0, 0x0 }, SFX_RUPEE_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_BOMBS5] = { { 0x0, 0x0 }, SFX_HEART_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_ARROWS5] = { { 0x0, 0x0 }, SFX_HEART_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, + [ITEM_HEART] = { { 0x0, 0x0 }, SFX_HEART_BOUNCE, 0x1, { 0x0, 0x0, 0x0 } }, +}; + u8 sub_0808147C(u32 arg0) { const Unk_0811E84C* var0 = &gUnk_0811E84C[arg0]; return var0->unk4; diff --git a/src/scroll.c b/src/scroll.c index 51316b08..c7ce5348 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -53,11 +53,13 @@ void sub_08080368(); void sub_08080B60(u8*); bool32 sub_08080794(const Transition* transition, u32 param_2, u32 param_3, u32 param_4); bool32 sub_08080808(const Transition* transition, u32 param_2, u32 param_3, u32 param_4); +void sub_080808D8(int); +void sub_080808E4(int); +void sub_08080904(int); +void sub_08080910(int); extern u8 gMapDataTopSpecial[]; -extern const void (*const gUnk_0811E7C4[])(int); - void UpdateScroll(void) { static void (*const gUnk_0811E768[])(RoomControls*) = { sub_0807FC64, sub_0807FC7C, sub_0807FDB0, NULL, sub_0807FEF0, sub_0807FF54, @@ -465,6 +467,12 @@ bool32 sub_08080808(const Transition* param_1, u32 param_2, u32 param_3, u32 par } void DoExitTransition(const ScreenTransitionData* data) { + static void (*const gUnk_0811E7C4[])(int) = { + sub_080808D8, + sub_080808E4, + sub_08080904, + sub_08080910, + }; PlayerRoomStatus* status; gRoomTransition.transitioningOut = 1; status = &gRoomTransition.player_status; @@ -489,11 +497,11 @@ void DoExitTransition(const ScreenTransitionData* data) { gUnk_0811E7C4[data->type](data->field_0xa); } -void sub_080808D8(void) { +void sub_080808D8(int param_1) { gRoomTransition.type = TRANSITION_DEFAULT; } -void sub_080808E4(void) { +void sub_080808E4(int param_1) { if (CheckAreaOverworld(gRoomTransition.player_status.area_next)) { gRoomTransition.type = TRANSITION_DEFAULT; } else { @@ -501,11 +509,11 @@ void sub_080808E4(void) { } } -void sub_08080904(void) { +void sub_08080904(int param_1) { gRoomTransition.type = TRANSITION_CUT; } -void sub_08080910(void) { +void sub_08080910(int param_1) { gRoomTransition.type = TRANSITION_CUT; }