From b1548c42a2164f2a3d7e3fddddf4bcb110c97aba Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sun, 6 Feb 2022 00:14:27 +0200 Subject: Decompile the rest of itemPegasusBoots --- src/item/itemPegasusBoots.c | 107 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 755362bf..7e272158 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -3,10 +3,17 @@ #include "sound.h" #include "functions.h" #include "effects.h" +#include "game.h" +#include "save.h" -extern void (*const gUnk_0811BDCC[])(ItemBehavior* beh, u32); +void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior* beh, u32); void sub_08076964(ItemBehavior*, u32); +extern bool32 sub_0807A158(); +extern Entity* CreatePlayerBomb(ItemBehavior*, u32); + +extern u16 gUnk_0800275C[]; +extern u8 gUnk_0811BE38[]; void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { u32 bVar1; @@ -44,7 +51,7 @@ void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { } } } - gUnk_0811BDCC[this->stateID](this, arg1); + ItemPegasusBoots_StateFunctions[this->stateID](this, arg1); } } @@ -72,6 +79,98 @@ void sub_080768F8(ItemBehavior* this, u32 arg1) { } } -ASM_FUNC("asm/non_matching/itemPegasusBoots/sub_08076964.inc", void sub_08076964(ItemBehavior* this, u32 arg1)) +void sub_08076964(ItemBehavior* this, u32 arg1) { + Entity* bombEntity; + u32 uVar3; + if (sub_08077EFC(this) && gPlayerEntity.z.WORD == 0 && gPlayerState.dash_state) { + UpdateItemAnim(this); + + if ((gPlayerState.flags & PL_MINISH) == 0) { + UpdateItemAnim(this); + } + + if ((++gPlayerState.dash_state) == 0x1e) { + if ((gPlayerState.flags & PL_FLAGS2) != 0) { + gPlayerState.dash_state = 0; + sub_08077E78(this, arg1); + return; + } + gPlayerState.dash_state = 0x40; + gPlayerState.field_0xa &= ~(8 >> arg1); + this->stateID++; + if (sub_0807A158() && (gPlayerState.flags & PL_MINISH) == 0 && (gPlayerState.field_0xac & 4) != 0) { + gPlayerState.field_0xab = 3; + sub_08077DF4(this, 0x298); + bombEntity = CreatePlayerBomb(this, 0xc); + if (bombEntity != NULL) { + if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) { + uVar3 = gSave.stats.itemButtons[SLOT_A]; + } else { + uVar3 = gSave.stats.itemButtons[SLOT_B]; + } + bombEntity->field_0x68.HALF.LO = uVar3; + return; + } + } else if ((gPlayerState.flags & PL_MINISH) == 0) { + sub_08077DF4(this, 0x104); + return; + } else { + gPlayerState.animation = 0xc10; + return; + } + } else { + return; + } + } + gPlayerState.dash_state = 0; + sub_08077E78(this, arg1); +} + +void sub_08076A88(ItemBehavior* this, u32 arg1) { + u32 uVar1; + u32 uVar2; + u8* ptr; + + if ((sub_08077EFC(this) != 0) && (gPlayerState.dash_state != 0)) { + if ((gPlayerState.flags & PL_MINISH) == 0) { + gPlayerEntity.speed = 0x300; + } else { + gPlayerEntity.speed = 0x280; + } + uVar2 = gUnk_0800275C[(gPlayerEntity.animationState & 0xe) * 4]; + if (uVar2 == (gPlayerEntity.collisions & uVar2)) { + if (this->field_0x5[3] != 0) { + gPlayerEntity.action = 6; + gPlayerEntity.subAction = 0; + COLLISION_OFF(&gPlayerEntity); + gPlayerState.field_0x38 = 0; + gPlayerState.field_0xd = 0xff; + return; + } + this->field_0x5[3] = 1; + return; + } + ptr = gUnk_0811BE38; + if ((*(u16*)&ptr[(gPlayerEntity.animationState & 0xfe)] & gPlayerState.field_0x90) == 0) { + this->field_0x5[6] = (this->field_0x5[5] & 0xe) * 4; + if ((gPlayerState.field_0xd != 0xff) && (gPlayerState.field_0xd != this->field_0x5[6])) { + if (((gPlayerState.field_0xd - this->field_0x5[6]) & 0x1f) < 0x10) { + this->field_0x5[6] = this->field_0x5[6] + 2; + } + this->field_0x5[6]--; + this->field_0x5[6] &= 0x1f; + } + gPlayerState.field_0xd = this->field_0x5[6]; + UpdateItemAnim(this); + return; + } + } + gPlayerState.dash_state = 0; + sub_08077E78(this, arg1); +} -ASM_FUNC("asm/non_matching/itemPegasusBoots/sub_08076A88.inc", void sub_08076A88(ItemBehavior* this, u32 arg1)) +void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior* beh, u32) = { + sub_080768F8, + sub_08076964, + sub_08076A88, +}; -- cgit v1.2.3 From 0027cf38d62936bcd276accb42be6aeedfe90b61 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sun, 6 Feb 2022 23:44:36 +0200 Subject: Move constant array inside function --- src/item/itemPegasusBoots.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 7e272158..6a2c3782 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -6,9 +6,9 @@ #include "game.h" #include "save.h" -void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior* beh, u32); - void sub_08076964(ItemBehavior*, u32); +void sub_080768F8(ItemBehavior*, u32); +void sub_08076A88(ItemBehavior*, u32); extern bool32 sub_0807A158(); extern Entity* CreatePlayerBomb(ItemBehavior*, u32); @@ -16,6 +16,11 @@ extern u16 gUnk_0800275C[]; extern u8 gUnk_0811BE38[]; void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { + static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior * beh, u32) = { + sub_080768F8, + sub_08076964, + sub_08076A88, + }; u32 bVar1; Entity* fx; u32 uVar4; @@ -168,9 +173,3 @@ void sub_08076A88(ItemBehavior* this, u32 arg1) { gPlayerState.dash_state = 0; sub_08077E78(this, arg1); } - -void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior* beh, u32) = { - sub_080768F8, - sub_08076964, - sub_08076A88, -}; -- cgit v1.2.3