From 7c16e8d50ae048d47e55b9d13c23be21dbae423a Mon Sep 17 00:00:00 2001 From: theo3 Date: Mon, 28 Mar 2022 15:08:37 -0700 Subject: identify all player items --- src/enemy/bobomb.c | 2 +- src/enemy/doorMimic.c | 2 +- src/enemy/likeLike.c | 2 +- src/enemy/madderpillar.c | 2 +- src/enemy/rollobite.c | 2 +- src/enemy/rupeeLike.c | 2 +- src/item.c | 4 +- src/item/itemBomb.c | 22 +-- src/item/itemBoomerang.c | 14 +- src/item/itemBow.c | 30 +-- src/item/itemDebug.c | 4 +- src/item/itemGustJar.c | 28 +-- src/item/itemJarEmpty.c | 18 +- src/item/itemLantern.c | 26 +-- src/item/itemMoleMitts.c | 22 +-- src/item/itemOcarina.c | 18 +- src/item/itemPacciCane.c | 12 +- src/item/itemPegasusBoots.c | 26 +-- src/item/itemShield.c | 18 +- src/item/itemSword.c | 86 ++++----- src/item/itemTryPickupObject.c | 51 +++--- src/movement.c | 4 +- src/npc/carlov.c | 2 +- src/object/pushableLever.c | 2 +- src/playerItem.c | 32 ++-- src/playerItem/playerItem10.c | 187 ------------------- src/playerItem/playerItem11.c | 181 ------------------ src/playerItem/playerItem12.c | 189 ------------------- src/playerItem/playerItem13.c | 219 ---------------------- src/playerItem/playerItem14.c | 59 ------ src/playerItem/playerItem15.c | 38 ---- src/playerItem/playerItem3.c | 242 ------------------------- src/playerItem/playerItemBoomerang.c | 242 +++++++++++++++++++++++++ src/playerItem/playerItemC.c | 88 --------- src/playerItem/playerItemDashSword.c | 88 +++++++++ src/playerItem/playerItemFireRodProjectile.c | 38 ++++ src/playerItem/playerItemGust.c | 218 ++++++++++++++++++++++ src/playerItem/playerItemGustBig.c | 181 ++++++++++++++++++ src/playerItem/playerItemHeldObject.c | 219 ++++++++++++++++++++++ src/playerItem/playerItemPacciCaneProjectile.c | 189 +++++++++++++++++++ src/playerItem/playerItemSpiralBeam.c | 59 ++++++ src/playerItemDefinitions.c | 16 +- src/playerUtils.c | 38 ++-- src/sound.c | 2 +- 44 files changed, 1475 insertions(+), 1449 deletions(-) delete mode 100644 src/playerItem/playerItem10.c delete mode 100644 src/playerItem/playerItem11.c delete mode 100644 src/playerItem/playerItem12.c delete mode 100644 src/playerItem/playerItem13.c delete mode 100644 src/playerItem/playerItem14.c delete mode 100644 src/playerItem/playerItem15.c delete mode 100644 src/playerItem/playerItem3.c create mode 100644 src/playerItem/playerItemBoomerang.c delete mode 100644 src/playerItem/playerItemC.c create mode 100644 src/playerItem/playerItemDashSword.c create mode 100644 src/playerItem/playerItemFireRodProjectile.c create mode 100644 src/playerItem/playerItemGust.c create mode 100644 src/playerItem/playerItemGustBig.c create mode 100644 src/playerItem/playerItemHeldObject.c create mode 100644 src/playerItem/playerItemPacciCaneProjectile.c create mode 100644 src/playerItem/playerItemSpiralBeam.c (limited to 'src') diff --git a/src/enemy/bobomb.c b/src/enemy/bobomb.c index d8130a25..8e2a03a9 100644 --- a/src/enemy/bobomb.c +++ b/src/enemy/bobomb.c @@ -243,7 +243,7 @@ void sub_0802CAF8(Entity* this) { sub_0802CBC4(this); } else { if (this->field_0x80.HALF.HI && sub_080044EC(this, 0x2800) == 1) { - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); } sub_0802CC18(this); RegisterCarryEntity(this); diff --git a/src/enemy/doorMimic.c b/src/enemy/doorMimic.c index 540ae972..1f4d6b4a 100644 --- a/src/enemy/doorMimic.c +++ b/src/enemy/doorMimic.c @@ -90,7 +90,7 @@ void sub_080220F0(Entity* this) { fx->y.HALF.HI += off->v; } } - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); } else if (this->frame & 1) { this->damage = 4; } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index a0c15d4b..da2f06c5 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -205,7 +205,7 @@ void sub_0802805C(Entity* this) { } if ((this->actionDelay & 3) == 0) { - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); } } } diff --git a/src/enemy/madderpillar.c b/src/enemy/madderpillar.c index 26ed3023..52098e08 100644 --- a/src/enemy/madderpillar.c +++ b/src/enemy/madderpillar.c @@ -452,7 +452,7 @@ void sub_0802A098(Entity* this) { if (sub_08029F48(this)) { sub_08029E0C(this); sub_08029EEC(this); - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); } sub_08029FB4(this, this->x.HALF.HI - uVar1, this->y.HALF.HI - uVar2); diff --git a/src/enemy/rollobite.c b/src/enemy/rollobite.c index c9beaa52..f86dd5b9 100644 --- a/src/enemy/rollobite.c +++ b/src/enemy/rollobite.c @@ -188,7 +188,7 @@ void Rollobite_RolledUp(Entity* this) { RegisterCarryEntity(this); } else { if (unk == 1) - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); if ((this->direction & 0x80) == 0) ProcessMovement2(this); diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c index 8cda5e02..0e6afccb 100644 --- a/src/enemy/rupeeLike.c +++ b/src/enemy/rupeeLike.c @@ -71,7 +71,7 @@ void RupeeLike_OnCollision(Entity* this) { this->field_0x82.HALF.HI = 0x41; this->flags2 &= 0xfc; this->field_0x80.HALF.LO = gPlayerEntity.spritePriority.b1; - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); } else { if (this->confusedTime != 0) { Create0x68FX(this, FX_STARS); diff --git a/src/item.c b/src/item.c index a88ae226..3e6cbb2d 100644 --- a/src/item.c +++ b/src/item.c @@ -11,6 +11,6 @@ void (*const gItemFunctions[])(ItemBehavior*, u32) = { ItemJarEmpty, ItemJarEmpty, ItemJarEmpty, ItemJarEmpty, }; -void sub_080752E8(ItemBehavior* behavior, u32 arg1) { - gItemFunctions[behavior->behaviorID](behavior, arg1); +void sub_080752E8(ItemBehavior* behavior, u32 idx) { + gItemFunctions[behavior->behaviorID](behavior, idx); } diff --git a/src/item/itemBomb.c b/src/item/itemBomb.c index 5f20f8d7..9adeaa54 100644 --- a/src/item/itemBomb.c +++ b/src/item/itemBomb.c @@ -9,15 +9,15 @@ extern void (*const gUnk_0811BD98[])(ItemBehavior*, u32); extern s8 gUnk_0811BDAC[]; -void ItemBomb(ItemBehavior* this, u32 arg1) { - gUnk_0811BD98[this->stateID](this, arg1); +void ItemBomb(ItemBehavior* this, u32 idx) { + gUnk_0811BD98[this->stateID](this, idx); } -void sub_08075FF8(ItemBehavior* this, u32 arg1) { +void sub_08075FF8(ItemBehavior* this, u32 idx) { Entity* entity; u32 maxBombs; u32 bombCount; - s8* tmp; + s8* pos; s32 x; s32 y; @@ -25,24 +25,20 @@ void sub_08075FF8(ItemBehavior* this, u32 arg1) { bombCount = 0; for (entity = FindEntityByID(PLAYER_ITEM, PLAYER_ITEM_BOMB, 2); entity != NULL; entity = FindNextDuplicateID(entity, 2)) { - bombCount += 1; + bombCount++; } maxBombs = this->behaviorID == 7 ? 3 : 1; if (maxBombs > bombCount) { entity = CreatePlayerItemWithParent(this, 2); if (entity != NULL) { - tmp = &gUnk_0811BDAC[gPlayerEntity.animationState & 6]; - // TODO fix array access - x = tmp[0] << 0x10; - y = tmp[1] << 0x10; - PositionRelative(&gPlayerEntity, entity, x, y); + pos = &gUnk_0811BDAC[gPlayerEntity.animationState & 6]; + PositionRelative(&gPlayerEntity, entity, Q_16_16(pos[0]), Q_16_16(pos[1])); ModBombs(-1); - SoundReq(SFX_104); + SoundReq(SFX_PLACE_OBJ); } } } - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } -// TODO arg1 type not yet known, called by ItemPickupCheck and sub_080762D8 ASM_FUNC("asm/non_matching/itemBomb/sub_08076088.inc", void sub_08076088(ItemBehavior* this, void* arg1)) diff --git a/src/item/itemBoomerang.c b/src/item/itemBoomerang.c index 9e402d00..22ac3849 100644 --- a/src/item/itemBoomerang.c +++ b/src/item/itemBoomerang.c @@ -3,23 +3,23 @@ extern void (*const gUnk_0811BD78[])(ItemBehavior*, u32); -void ItemBoomerang(ItemBehavior* this, u32 arg1) { - gUnk_0811BD78[this->stateID](this, arg1); +void ItemBoomerang(ItemBehavior* this, u32 idx) { + gUnk_0811BD78[this->stateID](this, idx); } -void sub_08075D2C(ItemBehavior* this, u32 arg1) { +void sub_08075D2C(ItemBehavior* this, u32 idx) { if (((gPlayerState.field_0x3[1] & 8) == 0) && (sub_08077C94(this, this->behaviorID) == NULL)) { this->field_0x5[4] |= 0xf; sub_0806F948(&gPlayerEntity); sub_08077C0C(this, 0xb); - sub_08077D38(this, arg1); + sub_08077D38(this, idx); gPlayerState.field_0x3[1] |= 8; } else { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } -void sub_08075D88(ItemBehavior* this, u32 arg1) { +void sub_08075D88(ItemBehavior* this, u32 idx) { if ((gPlayerState.field_0x3[1] & 0x80) == 0) { if (((this->behaviorID == 0xc) && ((gPlayerState.field_0xa & 0x80) != 0)) && ((this->field_0x5[9] & 2) != 0)) { ResetPlayerVelocity(); @@ -30,5 +30,5 @@ void sub_08075D88(ItemBehavior* this, u32 arg1) { return; } } - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } diff --git a/src/item/itemBow.c b/src/item/itemBow.c index bc8244f9..586a0505 100644 --- a/src/item/itemBow.c +++ b/src/item/itemBow.c @@ -4,23 +4,23 @@ extern void (*const gUnk_0811BD80[])(ItemBehavior*, u32); -void ItemBow(ItemBehavior* this, u32 arg1) { - gUnk_0811BD80[this->stateID](this, arg1); +void ItemBow(ItemBehavior* this, u32 idx) { + gUnk_0811BD80[this->stateID](this, idx); } -void sub_08075DF4(ItemBehavior* this, u32 arg1) { +void sub_08075DF4(ItemBehavior* this, u32 idx) { if ((gPlayerState.field_0x3[1] & 8) == 0) { this->field_0x5[4] |= 0x80; sub_0806F948(&gPlayerEntity); sub_08077BB8(this); - sub_08077D38(this, arg1); + sub_08077D38(this, idx); gPlayerState.field_0x1f[2] = 1; } else { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } -void sub_08075E40(ItemBehavior* this, u32 arg1) { +void sub_08075E40(ItemBehavior* this, u32 idx) { u8 bVar1; if (gPlayerState.field_0x1f[2] != 0) { @@ -32,17 +32,17 @@ void sub_08075E40(ItemBehavior* this, u32 arg1) { this->field_0x5[4] &= 0x7f; if (gSave.stats.arrowCount != 0) { this->field_0xf = bVar1; - gPlayerState.field_0xa &= ~(8 >> arg1); + gPlayerState.field_0xa &= ~(8 >> idx); } } return; } } gPlayerState.field_0x1f[2] = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } -void sub_08075EC0(ItemBehavior* this, u32 arg1) { +void sub_08075EC0(ItemBehavior* this, u32 idx) { u8 arrowCount; s32 iVar2; @@ -51,10 +51,10 @@ void sub_08075EC0(ItemBehavior* this, u32 arg1) { if (iVar2 != 0 && arrowCount != 0) { if (((gPlayerState.field_0x3[1] & 0x80) != 0) || (gPlayerState.field_0x1f[2] == 0)) { gPlayerState.field_0x1f[2] = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } else { - gPlayerState.field_0xa = (8 >> arg1) | gPlayerState.field_0xa; + gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa; sub_08077DF4(this, 0x27c); this->field_0xf = 0xf; this->field_0x5[4] |= 0xf; @@ -62,7 +62,7 @@ void sub_08075EC0(ItemBehavior* this, u32 arg1) { } } -void sub_08075F38(ItemBehavior* this, u32 arg1) { +void sub_08075F38(ItemBehavior* this, u32 idx) { if (((gPlayerState.field_0x3[1] & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) { UpdateItemAnim(this); if ((this->field_0x5[9] & 1) != 0) { @@ -70,11 +70,11 @@ void sub_08075F38(ItemBehavior* this, u32 arg1) { } } else { gPlayerState.field_0x1f[2] = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } -void sub_08075F84(ItemBehavior* this, u32 arg1) { +void sub_08075F84(ItemBehavior* this, u32 idx) { if (((gPlayerState.field_0x3[1] & 0x80) == 0) && (gPlayerState.field_0x1f[2] != 0)) { if (GetInventoryValue(ITEM_ARROW_BUTTERFLY) == 1) { sub_08077E3C(this, 5); @@ -86,5 +86,5 @@ void sub_08075F84(ItemBehavior* this, u32 arg1) { } } gPlayerState.field_0x1f[2] = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } diff --git a/src/item/itemDebug.c b/src/item/itemDebug.c index deec580d..e0d9f2f9 100644 --- a/src/item/itemDebug.c +++ b/src/item/itemDebug.c @@ -3,7 +3,7 @@ extern Entity* sub_08077BD4(ItemBehavior*); extern void DeletePlayerItem(ItemBehavior*, u32); -void ItemDebug(ItemBehavior* beh, u32 arg1) { +void ItemDebug(ItemBehavior* beh, u32 idx) { sub_08077BD4(beh); - DeletePlayerItem(beh, arg1); + DeletePlayerItem(beh, idx); } diff --git a/src/item/itemGustJar.c b/src/item/itemGustJar.c index ea3cd42d..a749ea37 100644 --- a/src/item/itemGustJar.c +++ b/src/item/itemGustJar.c @@ -5,15 +5,15 @@ void (*const ItemGustJar_StateFunctions[])(ItemBehavior* beh, u32); -void ItemGustJar(ItemBehavior* this, u32 arg1) { +void ItemGustJar(ItemBehavior* this, u32 idx) { gPlayerState.framestate = PL_STATE_GUSTJAR; - ItemGustJar_StateFunctions[this->stateID](this, arg1); + ItemGustJar_StateFunctions[this->stateID](this, idx); } -void sub_08076DF4(ItemBehavior* this, u32 arg1) { +void sub_08076DF4(ItemBehavior* this, u32 idx) { if (sub_0807A894(&gPlayerEntity) != 0x29 && gPlayerState.floor_type != SURFACE_DOOR && gPlayerState.floor_type != SURFACE_DOOR_13 && gPlayerState.jump_status == 0) { - sub_08077D38(this, arg1); + sub_08077D38(this, idx); this->field_0x5[2] = 0; this->field_0x5[5] = gPlayerEntity.animationState; this->field_0x5[4] |= 0x80; @@ -23,20 +23,20 @@ void sub_08076DF4(ItemBehavior* this, u32 arg1) { gPlayerState.field_0x1c = 1; sub_08077BB8(this); } else { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } -void sub_08076E60(ItemBehavior* this, u32 arg1) { +void sub_08076E60(ItemBehavior* this, u32 idx) { Entity* playerItem; if ((gPlayerState.field_0x1c & 0xf) == 0) { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } if ((this->field_0x5[9] & 0x80) != 0) { this->stateID = 2; sub_08077DF4(this, 0x504); - gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> arg1); + gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx); playerItem = CreatePlayerItem(0x10, 0, 0, 0); if (playerItem != NULL) { playerItem->parent = &gPlayerEntity; @@ -46,9 +46,9 @@ void sub_08076E60(ItemBehavior* this, u32 arg1) { } } -void sub_08076EC8(ItemBehavior* this, u32 arg1) { +void sub_08076EC8(ItemBehavior* this, u32 idx) { if ((gPlayerState.field_0x1c & 0xf) == 0) { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); return; } @@ -81,10 +81,10 @@ void sub_08076EC8(ItemBehavior* this, u32 arg1) { } this->stateID++; - gPlayerState.field_0xa |= 8 >> arg1; + gPlayerState.field_0xa |= 8 >> idx; } -void sub_08076F64(ItemBehavior* this, u32 arg1) { +void sub_08076F64(ItemBehavior* this, u32 idx) { Entity* item; Entity* player; switch (gPlayerState.field_0x1c & 0xf) { @@ -97,7 +97,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { player = &gPlayerEntity; *(u32*)&player->field_0x74 = 0; gPlayerState.field_0x1c = 1; - gPlayerState.field_0xa &= ~(8 >> arg1); + gPlayerState.field_0xa &= ~(8 >> idx); this->stateID = 2; sub_08077DF4(this, 0x504); item = CreatePlayerItem(0x10, 0, 0, 0); @@ -169,7 +169,7 @@ void sub_08076F64(ItemBehavior* this, u32 arg1) { case0: gPlayerState.field_0x1c = 0; gPlayerEntity.field_0x70.WORD = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); break; } } diff --git a/src/item/itemJarEmpty.c b/src/item/itemJarEmpty.c index c50dee06..b8519e25 100644 --- a/src/item/itemJarEmpty.c +++ b/src/item/itemJarEmpty.c @@ -6,13 +6,13 @@ extern void (*const gUnk_0811BE28[])(ItemBehavior*, u32); extern u8 gUnk_02002AC8[]; -void ItemJarEmpty(ItemBehavior* this, u32 arg1) { - gUnk_0811BE28[this->stateID](this, arg1); +void ItemJarEmpty(ItemBehavior* this, u32 idx) { + gUnk_0811BE28[this->stateID](this, idx); } -void sub_08077534(ItemBehavior* this, u32 arg1) { +void sub_08077534(ItemBehavior* this, u32 idx) { u32 tmp; - sub_08077D38(this, arg1); + sub_08077D38(this, idx); sub_0806F948(&gPlayerEntity); sub_08077BB8(this); this->field_0x5[4] |= 0xf; @@ -49,7 +49,7 @@ void sub_08077534(ItemBehavior* this, u32 arg1) { gPlayerEntity.flags &= ~ENT_COLLIDE; } -void sub_08077618(ItemBehavior* this, u32 arg1) { +void sub_08077618(ItemBehavior* this, u32 idx) { if ((this->field_0x5[9] & 0x80) != 0) { sub_08077DF4(this, 0x618); this->stateID += 1; @@ -58,18 +58,18 @@ void sub_08077618(ItemBehavior* this, u32 arg1) { } } -void sub_08077640(ItemBehavior* this, u32 arg1) { +void sub_08077640(ItemBehavior* this, u32 idx) { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } -void sub_0807766C(ItemBehavior* this, u32 arg1) { +void sub_0807766C(ItemBehavior* this, u32 idx) { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } diff --git a/src/item/itemLantern.c b/src/item/itemLantern.c index c05b8d01..102232e7 100644 --- a/src/item/itemLantern.c +++ b/src/item/itemLantern.c @@ -13,11 +13,11 @@ extern bool32 sub_08077F10(ItemBehavior*); extern void sub_0807AB44(Entity*, s32, s32); -void ItemLantern(ItemBehavior* this, u32 arg1) { - gUnk_0811BD68[this->stateID](this, arg1); +void ItemLantern(ItemBehavior* this, u32 idx) { + gUnk_0811BD68[this->stateID](this, idx); } -void sub_08075A0C(ItemBehavior* this, u32 arg1) { +void sub_08075A0C(ItemBehavior* this, u32 idx) { Entity* object; u32 itemSlot; s8* tmp; @@ -27,10 +27,10 @@ void sub_08075A0C(ItemBehavior* this, u32 arg1) { ForceEquipItem(ITEM_LANTERN_OFF, itemSlot); gPlayerState.flags &= ~PL_USE_LANTERN; ForceEquipItem(ITEM_LANTERN_OFF, itemSlot); - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } else { this->field_0x5[4] |= 0x80; - sub_08077D38(this, arg1); + sub_08077D38(this, idx); sub_08077BD4(this); sub_0806F948(&gPlayerEntity); this->behaviorID = 0x10; @@ -45,7 +45,7 @@ void sub_08075A0C(ItemBehavior* this, u32 arg1) { } } -void sub_08075ADC(ItemBehavior* this, u32 arg1) { +void sub_08075ADC(ItemBehavior* this, u32 idx) { u32 bVar1; if ( @@ -57,7 +57,7 @@ void sub_08075ADC(ItemBehavior* this, u32 arg1) { this->field_0xf = 0; this->stateID += 1; gPlayerState.flags |= PL_USE_LANTERN; - bVar1 = 8 >> arg1; + bVar1 = 8 >> idx; gPlayerState.field_0x3[1] = gPlayerState.field_0x3[1] & ~((bVar1 << 4) | bVar1); bVar1 = ~bVar1; gPlayerState.field_0xa = bVar1 & gPlayerState.field_0xa; @@ -68,7 +68,7 @@ void sub_08075ADC(ItemBehavior* this, u32 arg1) { } } -void sub_08075B54(ItemBehavior* this, u32 arg1) { +void sub_08075B54(ItemBehavior* this, u32 idx) { u32 bVar1; u32 itemSlot; Entity* object; @@ -79,7 +79,7 @@ void sub_08075B54(ItemBehavior* this, u32 arg1) { if (!(((sub_08077F10(this) == 0) && (itemSlot < 2)) || (gPlayerState.jump_status != 0))) { ForceEquipItem(ITEM_LANTERN_OFF, itemSlot); gPlayerState.flags &= ~PL_USE_LANTERN; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); SoundReq(SFX_ITEM_LANTERN_OFF); } else { if (((gPlayerState.queued_action != PLAYER_ROLL) && (gPlayerEntity.frameIndex < 0x37)) && @@ -99,7 +99,7 @@ void sub_08075B54(ItemBehavior* this, u32 arg1) { object->y.HALF.HI = tmp[1] + object->y.HALF.HI; } sub_08077DF4(this, 0x60c); - bVar1 = (8 >> (arg1)); + bVar1 = (8 >> (idx)); gPlayerState.field_0xa |= bVar1; gPlayerState.keepFacing |= bVar1; } @@ -108,7 +108,7 @@ void sub_08075B54(ItemBehavior* this, u32 arg1) { } } -void sub_08075C9C(ItemBehavior* this, u32 arg1) { +void sub_08075C9C(ItemBehavior* this, u32 idx) { s8* tmp; UpdateItemAnim(this); @@ -119,8 +119,8 @@ void sub_08075C9C(ItemBehavior* this, u32 arg1) { if ((this->field_0x5[9] & 0x80) != 0) { this->field_0xf = 0; this->stateID -= 1; - gPlayerState.field_0xa = (~(8 >> arg1)) & gPlayerState.field_0xa; - gPlayerState.keepFacing = (~(8 >> arg1)) & gPlayerState.keepFacing; + gPlayerState.field_0xa = (~(8 >> idx)) & gPlayerState.field_0xa; + gPlayerState.keepFacing = (~(8 >> idx)) & gPlayerState.keepFacing; } else { gPlayerEntity.field_0x7a.HWORD += 1; } diff --git a/src/item/itemMoleMitts.c b/src/item/itemMoleMitts.c index 3dd4bc59..bd80a910 100644 --- a/src/item/itemMoleMitts.c +++ b/src/item/itemMoleMitts.c @@ -18,15 +18,15 @@ extern bool32 sub_0807B5B0(Entity*); extern const s16 gUnk_0811BE16[]; -void ItemMoleMitts(ItemBehavior* this, u32 arg1) { - gUnk_0811BE04[this->stateID](this, arg1); +void ItemMoleMitts(ItemBehavior* this, u32 idx) { + gUnk_0811BE04[this->stateID](this, idx); } -void sub_08077130(ItemBehavior* this, u32 arg1) { +void sub_08077130(ItemBehavior* this, u32 idx) { s32 iVar1; if (gPlayerState.jump_status == 0) { - sub_08077D38(this, arg1); + sub_08077D38(this, idx); gPlayerState.field_0x3c[1] = 1; this->field_0x5[4] |= 0x80; iVar1 = sub_080774A0(); @@ -47,17 +47,17 @@ void sub_08077130(ItemBehavior* this, u32 arg1) { this->stateID = 1; } } else { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); gPlayerState.field_0x3c[1] = 0; } } -void sub_080771C8(ItemBehavior* this, u32 arg1) { +void sub_080771C8(ItemBehavior* this, u32 idx) { Entity* object; UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); gPlayerState.field_0x3c[1] = 0; } else { if (((this->field_0x5[9] & 0x20) != 0) && (this->field_0x5[3] == 0xff)) { @@ -89,7 +89,7 @@ void sub_080771C8(ItemBehavior* this, u32 arg1) { } } -void sub_080772A8(ItemBehavior* this, u32 param_2) { +void sub_080772A8(ItemBehavior* this, u32 idx) { Entity* effect; if (((this->field_0x5[9] & 8) != 0) && sub_08077F10(this)) { @@ -119,7 +119,7 @@ void sub_080772A8(ItemBehavior* this, u32 param_2) { return; } } - DeletePlayerItem(this, param_2); + DeletePlayerItem(this, idx); gPlayerState.field_0x3c[1] = 0; } else { if ((this->field_0x5[9] & 0x60) != 0) { @@ -148,7 +148,7 @@ void sub_080772A8(ItemBehavior* this, u32 param_2) { } } -void sub_08077448(ItemBehavior* this, u32 arg1) { +void sub_08077448(ItemBehavior* this, u32 idx) { gPlayerEntity.direction = gPlayerEntity.animationState << 2 ^ 0x10; gPlayerEntity.speed = 0x100; if (((this->field_0x5[9] & 1) != 0) && (this->field_0x5[0] != 0)) { @@ -157,7 +157,7 @@ void sub_08077448(ItemBehavior* this, u32 arg1) { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { gPlayerState.field_0x3c[1] = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } diff --git a/src/item/itemOcarina.c b/src/item/itemOcarina.c index f73e3d48..ce7d0c4f 100644 --- a/src/item/itemOcarina.c +++ b/src/item/itemOcarina.c @@ -8,14 +8,14 @@ extern void ResetPlayerVelocity(void); extern void CreateBird(void); -void ItemOcarina(ItemBehavior* this, u32 arg1) { - gOcarinaStates[this->stateID](this, arg1); +void ItemOcarina(ItemBehavior* this, u32 idx) { + gOcarinaStates[this->stateID](this, idx); gPlayerEntity.field_0x7a.HWORD += 1; } -void OcarinaUse(ItemBehavior* this, u32 arg1) { +void OcarinaUse(ItemBehavior* this, u32 idx) { if (gPlayerState.queued_action == PLAYER_ROLL) { - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } else { this->field_0x5[4] |= 0xf; gPlayerEntity.animationState = 0x04; @@ -25,16 +25,16 @@ void OcarinaUse(ItemBehavior* this, u32 arg1) { gPlayerState.flags |= PL_USE_OCARINA; gPlayerState.field_0x27[0] = -1; gPauseMenuOptions.disabled = 1; - gPlayerState.field_0xa = (8 >> arg1) | gPlayerState.field_0xa; - gPlayerState.keepFacing = (8 >> arg1) | gPlayerState.keepFacing; + gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa; + gPlayerState.keepFacing = (8 >> idx) | gPlayerState.keepFacing; ResetPlayerVelocity(); - sub_08077D38(this, arg1); + sub_08077D38(this, idx); SoundReq(SFX_216); SetPlayerEventPriority(); } } -NONMATCH("asm/non_matching/ocarina/OcarinaUpdate.inc", void OcarinaUpdate(ItemBehavior* this, u32 arg1)) { +NONMATCH("asm/non_matching/ocarina/OcarinaUpdate.inc", void OcarinaUpdate(ItemBehavior* this, u32 idx)) { // TODO regalloc UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { @@ -44,7 +44,7 @@ NONMATCH("asm/non_matching/ocarina/OcarinaUpdate.inc", void OcarinaUpdate(ItemBe gPauseMenuOptions.disabled = 0; CreateBird(); ResetPlayerEventPriority(); - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } END_NONMATCH diff --git a/src/item/itemPacciCane.c b/src/item/itemPacciCane.c index ada5d308..dbf9681d 100644 --- a/src/item/itemPacciCane.c +++ b/src/item/itemPacciCane.c @@ -5,20 +5,20 @@ extern void (*const gUnk_0811BDE0[])(ItemBehavior* beh, u32); -void ItemPacciCane(ItemBehavior* beh, u32 arg1) { - gUnk_0811BDE0[beh->stateID](beh, arg1); +void ItemPacciCane(ItemBehavior* beh, u32 idx) { + gUnk_0811BDE0[beh->stateID](beh, idx); } -void sub_08076C98(ItemBehavior* beh, u32 arg1) { +void sub_08076C98(ItemBehavior* beh, u32 idx) { beh->field_0x5[4] |= 0xf; - sub_08077D38(beh, arg1); + sub_08077D38(beh, idx); sub_0806F948(&gPlayerEntity); sub_08077BB8(beh); } -void sub_08076CBC(ItemBehavior* beh, u32 arg1) { +void sub_08076CBC(ItemBehavior* beh, u32 idx) { if ((beh->field_0x5[9] & 0x80) != 0) { - DeletePlayerItem(beh, arg1); + DeletePlayerItem(beh, idx); } else { if ((beh->field_0x5[9] & 0x40) != 0) { CreatePlayerItemWithParent(beh, 0x12); diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 2a32cfd9..28479b75 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -13,7 +13,7 @@ void sub_08076A88(ItemBehavior*, u32); extern u16 gUnk_0800275C[]; extern u8 gUnk_0811BE38[]; -void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { +void ItemPegasusBoots(ItemBehavior* this, u32 idx) { static void (*const ItemPegasusBoots_StateFunctions[])(ItemBehavior * beh, u32) = { sub_080768F8, sub_08076964, @@ -26,7 +26,7 @@ void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { if (gPlayerEntity.field_0x7a.HWORD != 0) { gPlayerState.dash_state = 0; gPlayerState.field_0xe = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } else { bVar1 = this->field_0x5[2] - 1; this->field_0x5[2] = bVar1; @@ -54,11 +54,11 @@ void ItemPegasusBoots(ItemBehavior* this, u32 arg1) { } } } - ItemPegasusBoots_StateFunctions[this->stateID](this, arg1); + ItemPegasusBoots_StateFunctions[this->stateID](this, idx); } } -void sub_080768F8(ItemBehavior* this, u32 arg1) { +void sub_080768F8(ItemBehavior* this, u32 idx) { u32 bVar1; u32 bVar2; @@ -73,16 +73,16 @@ void sub_080768F8(ItemBehavior* this, u32 arg1) { } else { gPlayerState.animation = 0xc14; } - sub_08077D38(this, arg1); - sub_08076964(this, arg1); + sub_08077D38(this, idx); + sub_08076964(this, idx); } else { gPlayerState.dash_state = 0; gPlayerState.field_0xe = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } -void sub_08076964(ItemBehavior* this, u32 arg1) { +void sub_08076964(ItemBehavior* this, u32 idx) { Entity* bombEntity; u32 uVar3; if (sub_08077EFC(this) && gPlayerEntity.z.WORD == 0 && gPlayerState.dash_state) { @@ -95,11 +95,11 @@ void sub_08076964(ItemBehavior* this, u32 arg1) { if ((++gPlayerState.dash_state) == 0x1e) { if ((gPlayerState.flags & PL_FLAGS2) != 0) { gPlayerState.dash_state = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); return; } gPlayerState.dash_state = 0x40; - gPlayerState.field_0xa &= ~(8 >> arg1); + gPlayerState.field_0xa &= ~(8 >> idx); this->stateID++; if (HasSwordEquipped() && (gPlayerState.flags & PL_MINISH) == 0 && (gPlayerState.skills & SKILL_DASH_ATTACK) != 0) { @@ -127,10 +127,10 @@ void sub_08076964(ItemBehavior* this, u32 arg1) { } } gPlayerState.dash_state = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } -void sub_08076A88(ItemBehavior* this, u32 arg1) { +void sub_08076A88(ItemBehavior* this, u32 idx) { u32 uVar1; u32 uVar2; u8* ptr; @@ -170,5 +170,5 @@ void sub_08076A88(ItemBehavior* this, u32 arg1) { } } gPlayerState.dash_state = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } diff --git a/src/item/itemShield.c b/src/item/itemShield.c index d8cd9ace..fe5eacea 100644 --- a/src/item/itemShield.c +++ b/src/item/itemShield.c @@ -6,40 +6,40 @@ extern void (*const gUnk_0811BDE8[])(ItemBehavior* beh, u32); -void ItemShield(ItemBehavior* beh, u32 arg1) { - gUnk_0811BDE8[beh->stateID](beh, arg1); +void ItemShield(ItemBehavior* beh, u32 idx) { + gUnk_0811BDE8[beh->stateID](beh, idx); } -void sub_08076D04(ItemBehavior* beh, u32 arg1) { +void sub_08076D04(ItemBehavior* beh, u32 idx) { gPlayerState.field_0x3[0] = 0x81; beh->field_0x5[4] = 2; sub_0806F948(&gPlayerEntity); - sub_08077D38(beh, arg1); + sub_08077D38(beh, idx); sub_08077BB8(beh); } -void sub_08076D34(ItemBehavior* beh, u32 arg1) { +void sub_08076D34(ItemBehavior* beh, u32 idx) { if (sub_08077EFC(beh) != 0) { gPlayerState.field_0x3[0] |= 1; UpdateItemAnim(beh); if (beh->field_0x5[9] != 0) { beh->stateID++; beh->field_0xf = 0; - gPlayerState.field_0xa &= ~(u8)(8 >> arg1); + gPlayerState.field_0xa &= ~(u8)(8 >> idx); SoundReq(SFX_15D); } } else { gPlayerState.field_0x3[0] = 0; - DeletePlayerItem(beh, arg1); + DeletePlayerItem(beh, idx); } } -void sub_08076D94(ItemBehavior* beh, u32 arg1) { +void sub_08076D94(ItemBehavior* beh, u32 idx) { if (sub_08077EFC(beh)) { gPlayerState.field_0x3[0] |= 1; UpdateItemAnim(beh); } else { gPlayerState.field_0x3[0] = 0; - DeletePlayerItem(beh, arg1); + DeletePlayerItem(beh, idx); } } diff --git a/src/item/itemSword.c b/src/item/itemSword.c index f55a1275..c0a24c68 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -11,18 +11,18 @@ void sub_080754B8(ItemBehavior*, u32); void sub_08075898(ItemBehavior*, u32); void sub_08075580(ItemBehavior*, u32); -void sub_08075694(ItemBehavior* this, u32 arg1); +void sub_08075694(ItemBehavior* this, u32 idx); -void ItemSword(ItemBehavior* this, u32 arg1) { +void ItemSword(ItemBehavior* this, u32 idx) { gPlayerState.framestate = PL_STATE_SWORD; - gUnk_0811BD44[this->stateID](this, arg1); + gUnk_0811BD44[this->stateID](this, idx); } -void sub_08075338(ItemBehavior* this, u32 arg1) { +void sub_08075338(ItemBehavior* this, u32 idx) { u32 temp, temp2; if (gPlayerState.flags & PL_MINISH) { this->field_0x5[4] |= 0x80; - sub_08077D38(this, arg1); + sub_08077D38(this, idx); gPlayerState.animation = 0xc00; SoundReq(SFX_PLY_VO1); return; @@ -34,19 +34,19 @@ void sub_08075338(ItemBehavior* this, u32 arg1) { (gPlayerState.skills & SKILL_DOWN_THRUST) && gPlayerEntity.z.WORD) { gPlayerState.jump_status |= 0x20; gPlayerState.field_0xab = 7; - gPlayerState.field_0x3[1] |= (8 >> arg1) | ((8 >> arg1) << 4); + gPlayerState.field_0x3[1] |= (8 >> idx) | ((8 >> idx) << 4); sub_08077B98(this); this->stateID = 6; - sub_08075898(this, arg1); + sub_08075898(this, idx); return; } } #ifndef EU - sub_080759B8(this, arg1); + sub_080759B8(this, idx); return; } else if (gPlayerEntity.z.WORD) { #endif - sub_080759B8(this, arg1); + sub_080759B8(this, idx); return; } @@ -60,9 +60,9 @@ void sub_08075338(ItemBehavior* this, u32 arg1) { } // Do the roll attack. - sub_08077D38(this, arg1); + sub_08077D38(this, idx); sub_08077B98(this); - temp = (8 >> arg1); + temp = (8 >> idx); gPlayerState.field_0x3[1] |= temp | (temp << 4); gPlayerState.field_0xa |= temp; gPlayerState.keepFacing |= temp; @@ -89,15 +89,15 @@ void sub_08075338(ItemBehavior* this, u32 arg1) { } } - sub_08077D38(this, arg1); + sub_08077D38(this, idx); sub_08077B98(this); } -void sub_080754B8(ItemBehavior* this, u32 arg1) { +void sub_080754B8(ItemBehavior* this, u32 idx) { u32 iVar1; if ((gPlayerState.sword_state & 0x80) != 0) { - sub_08075694(this, arg1); + sub_08075694(this, idx); } else if (gPlayerState.field_0x3[1] != 0) { UpdateItemAnim(this); if (this->field_0x5[9] != 0) { @@ -118,19 +118,19 @@ void sub_080754B8(ItemBehavior* this, u32 arg1) { if ((this->field_0x5[9] & 0x80) != 0) { if (((gPlayerState.flags & 0x80) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } else { - sub_08075580(this, arg1); + sub_08075580(this, idx); } } } else { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } } -void sub_08075580(ItemBehavior* this, u32 arg1) { +void sub_08075580(ItemBehavior* this, u32 idx) { if ((sub_08077EFC(this) != 0) && (gPlayerState.jump_status == 0)) { - gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> arg1); + gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx); gPlayerState.sword_state = 1; gPlayerState.item->hurtType = 0xd; this->field_0xf = 0; @@ -144,10 +144,10 @@ void sub_08075580(ItemBehavior* this, u32 arg1) { CreateObject(OBJECT_43, 0, 0); return; } - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } -void sub_080755F0(ItemBehavior* this, u32 arg1) { +void sub_080755F0(ItemBehavior* this, u32 idx) { if (sub_08077EFC(this) != 0) { if (sub_08077EC8(this) == 0) { if ((gPlayerState.sword_state | gPlayerState.field_0x3[1]) != 0) { @@ -157,25 +157,25 @@ void sub_080755F0(ItemBehavior* this, u32 arg1) { gPlayerState.sword_state = gPlayerState.sword_state | 0x20; } } else { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } } } else { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } } -void sub_0807564C(ItemBehavior* this, u32 arg1) { +void sub_0807564C(ItemBehavior* this, u32 idx) { if ((gPlayerState.sword_state | gPlayerState.field_0x3[1]) == 0) { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } else { if ((sub_08077EC8(this) == 0) && ((sub_08077EFC(this) == 0 || ((gPlayerState.sword_state & 0x80) != 0)))) { - sub_08075694(this, arg1); + sub_08075694(this, idx); } } } -void sub_08075694(ItemBehavior* this, u32 arg1) { +void sub_08075694(ItemBehavior* this, u32 idx) { this->field_0x5[2] = 1; if (gPlayerState.flags & PL_SWORD_THRUST) { gPlayerState.flags &= ~PL_SWORD_THRUST; @@ -185,7 +185,7 @@ void sub_08075694(ItemBehavior* this, u32 arg1) { gPlayerState.field_0xab = 1; sub_08077DF4(this, 0x124); } - gPlayerState.field_0xa = (8 >> arg1) | gPlayerState.field_0xa; + gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa; this->stateID = 4; this->field_0xf = 6; gPlayerEntity.hurtType = 0x1e; @@ -198,11 +198,11 @@ void sub_08075694(ItemBehavior* this, u32 arg1) { SoundReq(SFX_PLY_VO2); } -void sub_08075738(ItemBehavior* this, u32 arg1) { +void sub_08075738(ItemBehavior* this, u32 idx) { u32 bVar6; if (gPlayerState.field_0x3[1] == 0) { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } else { UpdateItemAnim(this); if (sub_08077F10(this)) { @@ -222,7 +222,7 @@ void sub_08075738(ItemBehavior* this, u32 arg1) { } if ((bVar6 <= ++this->field_0x5[3]) || (--this->field_0x5[2] == 0)) { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } } } else { @@ -241,26 +241,26 @@ void sub_08075738(ItemBehavior* this, u32 arg1) { this->field_0x5[6] = gPlayerEntity.animationState << 2; this->field_0x5[2] = 1; this->field_0x5[3] = 1; - gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> arg1); + gPlayerState.field_0xa = gPlayerState.field_0xa & ~(8 >> idx); sub_08077DF4(this, 0x128); } if ((this->field_0x5[9] & 0x80) != 0) { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } } } } -void sub_08075898(ItemBehavior* this, u32 arg1) { +void sub_08075898(ItemBehavior* this, u32 idx) { if (gPlayerState.field_0x3[1] == 0) { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } } -void sub_080758B0(ItemBehavior* this, u32 arg1) { +void sub_080758B0(ItemBehavior* this, u32 idx) { if (gPlayerState.field_0x3[1] == 0) { - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } else { UpdateItemAnim(this); if ((this->field_0x5[9] & 0x80) != 0) { @@ -275,15 +275,15 @@ void sub_080758B0(ItemBehavior* this, u32 arg1) { } } -void sub_08075900(ItemBehavior* this, u32 arg1) { +void sub_08075900(ItemBehavior* this, u32 idx) { if (gPlayerState.floor_type == SURFACE_SWAMP) { gPlayerState.flags &= ~PL_ROLLING; - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } else { UpdateItemAnim(this); if ((gPlayerState.sword_state & 0x80) != 0) { gPlayerState.sword_state = 0xa0; - sub_0807564C(this, arg1); + sub_0807564C(this, idx); } else { if (this->field_0x5[2] != 0) { @@ -299,19 +299,19 @@ void sub_08075900(ItemBehavior* this, u32 arg1) { } else { if ((this->field_0x5[9] & 0x80) != 0) { gPlayerState.flags &= ~PL_ROLLING; - sub_080759B8(this, arg1); + sub_080759B8(this, idx); } } } } } -void sub_080759B8(ItemBehavior* this, u32 arg1) { +void sub_080759B8(ItemBehavior* this, u32 idx) { if ((gPlayerState.flags & PL_MINISH) == 0) { gPlayerEntity.hurtType = 0; } gPlayerState.flags &= ~PL_SWORD_THRUST; gPlayerState.sword_state = 0; gPlayerState.item = NULL; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index e03b9c5a..e2c71d66 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -4,18 +4,18 @@ extern void (*const gUnk_0811BDB4[])(ItemBehavior*, u32); -u32 sub_08077F64(ItemBehavior* arg0, u32 unk); +u32 sub_08077F64(ItemBehavior* arg0, u32 idx); u32 sub_080789A8(void); void sub_080762C4(ItemBehavior*, void*, u8, u32); void sub_08076088(ItemBehavior*, void*, u32); -void ItemTryPickupObject(ItemBehavior* this, u32 arg1) { - gUnk_0811BDB4[this->stateID](this, arg1); +void ItemTryPickupObject(ItemBehavior* this, u32 idx) { + gUnk_0811BDB4[this->stateID](this, idx); } -void ItemPickupCheck(ItemBehavior* this, u32 param_2) { - Entity* entity; +void ItemPickupCheck(ItemBehavior* this, u32 idx) { + Entity* carried; if (!(((gPlayerState.field_0x3[1] != 0) || (((gPlayerState.jump_status != 0 && ((gPlayerState.flags & (PL_BUSY | PL_FALLING | PL_IN_MINECART)) == 0)) || @@ -24,28 +24,28 @@ void ItemPickupCheck(ItemBehavior* this, u32 param_2) { switch (sub_080789A8()) { case 2: if (((gCarriedEntity.unk_8)->field_0x16 & 0xf) == 0) { - sub_08076088(this, gCarriedEntity.unk_8, param_2); + sub_08076088(this, gCarriedEntity.unk_8, idx); return; } - entity = gCarriedEntity.unk_8; - this->field_0x18 = entity; - entity->action = 2; - entity->subAction = 5; + carried = gCarriedEntity.unk_8; + this->field_0x18 = carried; + carried->action = 2; + carried->subAction = 5; gPlayerState.framestate = 5; - sub_080762C4(this, entity, 2, param_2); + sub_080762C4(this, carried, 2, idx); gUnk_0200AF00.unk_2e = 8; SoundReq(SFX_102); break; case 1: - sub_080762C4(this, 0, 1, param_2); + sub_080762C4(this, 0, 1, idx); SoundReq(SFX_102); break; case 0: this->stateID = 5; this->field_0x5[2] = 0x0f; this->field_0xf = 6; - gPlayerState.field_0xa = (8 >> param_2) | gPlayerState.field_0xa; - gPlayerState.keepFacing = (8 >> param_2) | gPlayerState.keepFacing; + gPlayerState.field_0xa = (8 >> idx) | gPlayerState.field_0xa; + gPlayerState.keepFacing = (8 >> idx) | gPlayerState.keepFacing; if ((gPlayerState.flags & PL_NO_CAP) == 0) { sub_08077DF4(this, 0x378); } else { @@ -56,9 +56,8 @@ void ItemPickupCheck(ItemBehavior* this, u32 param_2) { default: break; } - } else { - PlayerCancelHoldItem(this, param_2); + PlayerCancelHoldItem(this, idx); } } @@ -68,14 +67,14 @@ void sub_080762C4(ItemBehavior* this, void* arg1, u8 arg2, u32 arg3) { sub_08077D38(this, arg3); } -ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 arg1)) +ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 idx)) -void sub_08076488(ItemBehavior* this, u32 arg1) { +void sub_08076488(ItemBehavior* this, u32 idx) { u32 bVar1; s32 iVar2; if (this->field_0x5[2] == 0) { - if (PlayerTryDropObject(this, arg1) != 0) { + if (PlayerTryDropObject(this, idx) != 0) { if ((((this->field_0x18->field_0x16) & 0xf0) == 0x10) && ((gRoomTransition.frameCount & 1U) != 0)) { return; } @@ -83,7 +82,7 @@ void sub_08076488(ItemBehavior* this, u32 arg1) { if ((this->field_0x5[9] & 0x80) != 0) { gPlayerEntity.flags |= ENT_COLLIDE; gPlayerState.heldObject = 4; - bVar1 = ~(8 >> arg1); + bVar1 = ~(8 >> idx); gPlayerState.keepFacing = bVar1 & gPlayerState.keepFacing; gPlayerState.field_0xa = bVar1 & gPlayerState.field_0xa; this->stateID += 1; @@ -96,22 +95,22 @@ void sub_08076488(ItemBehavior* this, u32 arg1) { gPlayerState.framestate = PL_STATE_HOLD; } -ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_08076518.inc", void sub_08076518(ItemBehavior* this, u32 arg1)) +ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_08076518.inc", void sub_08076518(ItemBehavior* this, u32 idx)) -void sub_080765E0(ItemBehavior* this, u32 arg1) { - if (PlayerTryDropObject(this, arg1) != 0) { +void sub_080765E0(ItemBehavior* this, u32 idx) { + if (PlayerTryDropObject(this, idx) != 0) { if ((this->field_0x5[9] & 0x80) != 0) { - PlayerCancelHoldItem(this, arg1); + PlayerCancelHoldItem(this, idx); } else { UpdateItemAnim(this); } } } -void sub_0807660C(ItemBehavior* this, u32 arg1) { +void sub_0807660C(ItemBehavior* this, u32 idx) { UpdateItemAnim(this); if ((this->field_0x5[2]-- == 0) || (gPlayerState.field_0x0[1] == 0)) { gPlayerState.field_0x0[1] = 0; - DeletePlayerItem(this, arg1); + DeletePlayerItem(this, idx); } } diff --git a/src/movement.c b/src/movement.c index 1e54b3c5..66cfb465 100644 --- a/src/movement.c +++ b/src/movement.c @@ -16,7 +16,7 @@ bool32 sub_080AF0C8(Entity*); typedef enum { CollisionType0, // Normal/common? Used by most enemies and NPCs. CollisionType1, // chaser, enemy50, fallingBoulder, ghini, keese, pesto, sensorBladeTrap, vaatiRebornEnemy, - // playerItem10, playerItem13 + // PlayerItemGust, PlayerItemHeldObject CollisionType2, // acroBandits, beetle, chuchu, fireballGuy, flyingSkull, helmasaur, keaton, lakitu, // miniFireballGuy, peahat, rollobite, spikedBeetle, spinyChuchu, stalfos, itemOnGround, // smallIceBlock, flyingPot, object1F @@ -30,7 +30,7 @@ typedef enum { CollisionType7, // not used? CollisionType8, // not used? CollisionType9, // not used? - CollisionType10, // playerItem13, rollobite + CollisionType10, // PlayerItemHeldObject, rollobite CollisionType11, // not used? CollisionType12, // chaser, sensorBladeTrap } CollisionType; diff --git a/src/npc/carlov.c b/src/npc/carlov.c index 8f830b11..6267b19b 100644 --- a/src/npc/carlov.c +++ b/src/npc/carlov.c @@ -12,7 +12,7 @@ void Carlov(Entity* this) { } if ((this->frame & 0x10) != 0) { this->frame = this->frame & 0xef; - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); InitScreenShake(0x10, 0); } if ((this->frame & 0x20) != 0) { diff --git a/src/object/pushableLever.c b/src/object/pushableLever.c index c546d23e..8142a0f9 100644 --- a/src/object/pushableLever.c +++ b/src/object/pushableLever.c @@ -127,7 +127,7 @@ void PushableLever_CalculateSpriteOffsets(PushableLeverEntity* this) { super->spriteOffsetX = offsets[0]; super->spriteOffsetY = offsets[1]; if ((this->timer & 3) == 0) { - EnqueueSFX(SFX_104); + EnqueueSFX(SFX_PLACE_OBJ); } } diff --git a/src/playerItem.c b/src/playerItem.c index a588f264..7ea36d9e 100644 --- a/src/playerItem.c +++ b/src/playerItem.c @@ -6,23 +6,23 @@ typedef void(PlayerItemFunc)(Entity*); PlayerItemFunc PlayerItemSword; PlayerItemFunc PlayerItemBomb; -PlayerItemFunc PlayerItem3; +PlayerItemFunc PlayerItemBoomerang; PlayerItemFunc PlayerItemBow; PlayerItemFunc PlayerItemShield; PlayerItemFunc PlayerItemLantern; PlayerItemFunc PlayerItemNulled; PlayerItemFunc PlayerItemGustJar; PlayerItemFunc PlayerItemPacciCane; -PlayerItemFunc PlayerItemC; +PlayerItemFunc PlayerItemDashSword; PlayerItemFunc PlayerItemCellOverwriteSet; PlayerItemFunc PlayerItemBottle; PlayerItemFunc PlayerItemSwordBeam; -PlayerItemFunc PlayerItem10; -PlayerItemFunc PlayerItem11; -PlayerItemFunc PlayerItem12; -PlayerItemFunc PlayerItem13; -PlayerItemFunc PlayerItem14; -PlayerItemFunc PlayerItem15; +PlayerItemFunc PlayerItemGust; +PlayerItemFunc PlayerItemGustBig; +PlayerItemFunc PlayerItemPacciCaneProjectile; +PlayerItemFunc PlayerItemHeldObject; +PlayerItemFunc PlayerItemSpiralBeam; +PlayerItemFunc PlayerItemFireRodProjectile; PlayerItemFunc PlayerItemNulled2; typedef struct { @@ -41,7 +41,7 @@ PlayerItemFunc* const gPlayerItemFunctions[] = { DeleteEntity, PlayerItemSword, PlayerItemBomb, - PlayerItem3, + PlayerItemBoomerang, PlayerItemBow, PlayerItemShield, PlayerItemLantern, @@ -50,16 +50,16 @@ PlayerItemFunc* const gPlayerItemFunctions[] = { PlayerItemPacciCane, DeleteEntity, DeleteEntity, - PlayerItemC, + PlayerItemDashSword, PlayerItemCellOverwriteSet, PlayerItemBottle, PlayerItemSwordBeam, - PlayerItem10, - PlayerItem11, - PlayerItem12, - PlayerItem13, - PlayerItem14, - PlayerItem15, + PlayerItemGust, + PlayerItemGustBig, + PlayerItemPacciCaneProjectile, + PlayerItemHeldObject, + PlayerItemSpiralBeam, + PlayerItemFireRodProjectile, PlayerItemSwordBeam, PlayerItemNulled2, PlayerItemCellOverwriteSet, diff --git a/src/playerItem/playerItem10.c b/src/playerItem/playerItem10.c deleted file mode 100644 index c4debda4..00000000 --- a/src/playerItem/playerItem10.c +++ /dev/null @@ -1,187 +0,0 @@ -#include "entity.h" -#include "player.h" -#include "functions.h" -#include "asm.h" -#include "object.h" - -extern void (*const gUnk_0812AA80[])(Entity*); - -bool32 sub_080ACDB0(Entity*); - -void sub_080ACC78(Entity*); -void sub_080ACECC(Entity*); - -typedef struct { - u16 bits; - u8 type2; - u8 actionDelay; - u8 _4; - u8 type; - u16 tileID; -} Obj11; - -Obj11* sub_08008782(Entity*, u32, u32, u32); - -const s8 gUnk_0812AA88[] = { - -4, -4, 4, -4, -4, 4, 4, 4, 0, -}; - -const s8 gUnk_0812AA91[] = { - -5, -5, 5, -5, -5, 5, 5, 5, 0, -}; - -const s8 gUnk_0812AA9A[] = { - -9, -9, 1, -9, 9, -9, -9, 1, 9, 1, -9, 9, 1, 9, 9, 9, 0, 0, -}; - -const s8* const gUnk_0812AAAC[] = { - gUnk_0812AA88, - gUnk_0812AA91, - gUnk_0812AA91, - gUnk_0812AA9A, -}; - -const s8 gUnk_0812AABC[] = { - 0x78, - 0x50, - 0x28, - 0x4, -}; - -const Hitbox gUnk_0812AAC0 = { - 0, 0, 4, 2, 2, 4, 4, 4, -}; - -const Hitbox gUnk_0812AAC8 = { - 0, 0, 4, 3, 3, 4, 9, 9, -}; - -const Hitbox gUnk_0812AAD0 = { - 0, 0, 8, 7, 7, 8, 14, 14, -}; - -const Hitbox* const gUnk_0812AAD8[] = { - &gUnk_0812AAC0, - &gUnk_0812AAC8, - &gUnk_0812AAC8, - &gUnk_0812AAD0, -}; - -const u8 gUnk_0812AAE8[] = { - 0, - 12, - 16, - 16, -}; - -void PlayerItem10(Entity* this) { - if ((gPlayerState.field_0x1c & 0x7f) != 1) { - DeleteThisEntity(); - } - gUnk_0812AA80[this->action](this); - this->iframes = 0; -} - -void sub_080ACC04(Entity* this) { - this->action = 1; - this->flags2 = gPlayerEntity.flags2; - this->direction = this->animationState << 2; - this->speed = 0x200; - this->flags |= ENT_COLLIDE | ENT_PERSIST; - this->field_0x3c = 2; - this->hitbox = (Hitbox*)gUnk_0812AAD8[this->type]; - this->field_0x70.WORD = 0x10; - sub_080ACDB0(this); - sub_0801766C(this); -} - -void sub_080ACC5C(Entity* this) { - if (sub_080ACDB0(this) == FALSE) { - sub_080ACC78(this); - sub_080ACECC(this); - } -} - -void sub_080ACC78(Entity* this) { - s32 width; - Obj11* o; - Entity* child; - s32 offset; - const s8* puVar8; - - if ((this->type + gRoomTransition.frameCount) & 1) { - puVar8 = gUnk_0812AAAC[this->type]; - if (puVar8[*(u32*)&this->field_0x74] == 0) { - *(u32*)&this->field_0x74 = 0; - } - o = sub_08008782(this, 0xe, puVar8[*(u32*)&this->field_0x74], puVar8[*(u32*)&this->field_0x74 + 1]); - if (o != NULL) { - child = CreateObject(OBJECT_11, o->type, o->type2); - if (child != NULL) { - child->actionDelay = o->actionDelay; - child->x.HALF.HI = puVar8[*(u32*)&this->field_0x74] + this->x.HALF.HI; - child->y.HALF.HI = puVar8[*(u32*)&this->field_0x74 + 1] + this->y.HALF.HI; - } - } - *(u32*)&this->field_0x74 += 2; - } - if (this->child == NULL && (u32)this->field_0x70.WORD > 2) { - this->field_0x70.WORD = 1; - } - - if (--this->field_0x70.WORD != -1) { - return; - } - if (this->child == NULL) { - this->field_0x70.WORD = 2; - } else { - this->field_0x70.WORD = gUnk_0812AABC[this->type]; - } - child = CreateObject(OBJECT_17, 0, 0); - if (child == NULL) { - return; - } - offset = Random() % 16; - width = this->hitbox->width; - if (width < offset) { - offset = width; - } - if (offset & 1) { - offset = -offset; - } - switch (this->animationState >> 1) { - case 0: - child->y.HALF.HI = this->y.HALF.HI - this->hitbox->height; - child->x.HALF.HI = this->x.HALF.HI + offset; - break; - case 2: - child->y.HALF.HI = this->y.HALF.HI + this->hitbox->height; - child->x.HALF.HI = this->x.HALF.HI + offset; - break; - case 1: - child->x.HALF.HI = this->x.HALF.HI + this->hitbox->width; - child->y.HALF.HI = this->y.HALF.HI + offset; - break; - case 3: - child->x.HALF.HI = this->x.HALF.HI - this->hitbox->width; - child->y.HALF.HI = this->y.HALF.HI + offset; - break; - } -} - -ASM_FUNC("asm/non_matching/playerItem10/sub_080ACDB0.inc", bool32 sub_080ACDB0(Entity* this)) - -void sub_080ACECC(Entity* this) { - Entity* entity; - - if (this->type < 3 && this->child == NULL && (s32) * (u32*)&this->field_0x78 >= 0 && - gUnk_0812AAE8[this->type] <= *(u32*)&this->field_0x78) { - entity = CreatePlayerItem(0x10, this->type + 1, 0, 0); - if (entity != NULL) { - entity->parent = this; - this->child = entity; - entity->x.HALF.HI = this->x.HALF.HI; - entity->y.HALF.HI = this->y.HALF.HI; - } - } -} diff --git a/src/playerItem/playerItem11.c b/src/playerItem/playerItem11.c deleted file mode 100644 index 1ae35f07..00000000 --- a/src/playerItem/playerItem11.c +++ /dev/null @@ -1,181 +0,0 @@ -#include "global.h" -#include "entity.h" -#include "player.h" -#include "functions.h" -#include "sound.h" - -extern void sub_08078CD0(Entity*); -extern void sub_08018FA0(Entity*); -extern void sub_08018F6C(Entity*); - -extern void (*const gUnk_080B3DD0[])(Entity*); - -extern Hitbox gUnk_080B3E18; -extern u8 gUnk_080B3DE0[]; -extern Hitbox* gUnk_080B3DE8[]; - -extern u32 sub_08007DD6(u32, const u16*); - -extern const u16 gUnk_080B3DF4[]; -extern const u8 gUnk_08003E44[]; - -void PlayerItem11(Entity* this) { - if (this->health) { - this->iframes = 0; - gUnk_080B3DD0[this->action](this); - } else { - DeleteThisEntity(); - } -} - -void sub_08018CBC(Entity* this) { - u32 PVar1; - u8 uVar2; - Entity* pEVar3; - - *(u32*)&this->cutsceneBeh = this->x.WORD = gPlayerEntity.x.WORD; - *(u32*)&this->field_0x80 = this->y.WORD = gPlayerEntity.y.WORD; - uVar2 = this->animationState = gPlayerEntity.animationState & 0xe; - this->direction = (u8)(uVar2 << 2); - this->speed = 0x400; - this->hitType = 0x96; - this->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x80; - this->flags2 = gPlayerEntity.flags2; - pEVar3 = this->child; - if (pEVar3 != NULL) { - this->action = 1; - COLLISION_OFF(this); - this->actionDelay = 0x56; - this->hurtType = 0x1c; - this->damage = 6; - this->hitbox = &gUnk_080B3E18; - this->child->spriteOffsetX = 0; - this->child->spriteSettings.draw = 0; - } else { - if (gPlayerState.field_0x1c == 0) { - DeleteThisEntity(); - } - this->action = 2; - this->spriteSettings.draw = 1; - this->spriteIndex = 0xa6; - this->palette.raw = 0x33; - this->spriteVramOffset = 0; - this->type = gPlayerState.gustJarSpeed - 1; - this->actionDelay = gUnk_080B3DE0[this->type * 2]; - this->damage = gUnk_080B3DE0[this->type * 2 + 1]; - this->hurtType = 0x1b; - this->hitbox = gUnk_080B3DE8[this->type]; - (u32*)gPlayerEntity.field_0x70.WORD = this; - sub_08078CD0(&gPlayerEntity); - (u32*)gPlayerEntity.field_0x70.WORD = pEVar3; - InitializeAnimation(this, this->type + 10); - sub_08018FA0(this); - } - sub_0801766C(this); -} - -void sub_08018DE8(Entity* this) { - u8 bVar1; - - bVar1 = this->child->field_0x3a & 4; - if (bVar1 == 0) { - gPlayerState.field_0x1c = bVar1; - DeleteThisEntity(); - } - switch (gPlayerState.field_0x1c) { - case 0: - sub_08018F6C(this); - break; - case 5: - this->child->subAction = 4; - COLLISION_ON(this); - this->action = 2; - this->spritePriority.b0 = 2; - this->child->spriteSettings.draw = 1; - sub_08018FA0(this); - break; - } - sub_08078CD0(&gPlayerEntity); -} - -void sub_08018E68(Entity* this) { - s32 y; - s32 x; - if (this->child == NULL) { - GetNextFrame(this); - sub_08008790(this, 5); - } else { - if ((this->child->field_0x3a & 4) == 0) { - DeleteThisEntity(); - } - if ((this->bitfield & 0x80) != 0) { - sub_08018F6C(this); - return; - } - } - if (this->actionDelay-- != 0) { - LinearMoveUpdate(this); - - switch (this->direction) { - case DirectionNorth: - x = 0; - y = -4; - break; - case DirectionSouth: - x = 0; - y = 4; - break; - case DirectionWest: - x = -4; - y = 0; - break; - case DirectionEast: - x = 4; - y = 0; - break; - } - if (this->child != NULL) { - this->child->direction = this->direction; - CopyPosition(this, this->child); - } - if (this->type2 == 0) { - sub_0800451C(this); - } - if (sub_08007DD6(sub_080B1A0C(this, x, y), gUnk_080B3DF4) != 0) { - return; - } - if (GetRelativeCollisionTile(this, x, y) == 0x74) { - return; - } - if (sub_080040D8(this, (u8*)gUnk_08003E44, this->x.HALF.HI + x, this->y.HALF.HI + y) == 0) { - return; - } - } - - if (this->child == NULL) { - InitializeAnimation(this, this->type + 0xd); - } - this->action++; - sub_08018F6C(this); -} - -void sub_08018F6C(Entity* this) { - if (this->child != NULL) { - this->child->subAction = 5; - this->child->spriteSettings.draw = 1; - } else { - GetNextFrame(this); - if (this->frame == 0) { - return; - } - } - DeleteThisEntity(); -} - -void sub_08018FA0(Entity* this) { - this->collisionLayer = gPlayerEntity.collisionLayer; - if (this->collisionLayer == 0x02) { - this->type2 = 0x01; - } - SoundReq(this->type + SFX_EA); -} diff --git a/src/playerItem/playerItem12.c b/src/playerItem/playerItem12.c deleted file mode 100644 index cadb27f0..00000000 --- a/src/playerItem/playerItem12.c +++ /dev/null @@ -1,189 +0,0 @@ -#include "asm.h" -#include "entity.h" -#include "functions.h" -#include "sound.h" -#include "object.h" - -static const Hitbox gUnk_0811B9D0; - -void PlayerItem12_Init(Entity* this); -void sub_080701F8(Entity* this); -void sub_0807037C(Entity* this); -void sub_08070398(Entity* this); -void sub_080703BC(Entity* this); -void sub_08070458(Entity* this); - -extern void sub_08017744(Entity*); -extern u8* sub_08008782(Entity*, u32, u32, u32); - -void PlayerItem12(Entity* this) { - static void (*const PlayerItem12_Actions[])(Entity*) = { - PlayerItem12_Init, sub_080701F8, sub_0807037C, sub_08070398, sub_080703BC, - }; - PlayerItem12_Actions[this->action](this); -} - -extern u8 gUnk_08003E44; - -typedef struct { - u8 flipX; - u8 flipY; - s8 unk2; - s8 unk3; - u8 animIndex; - u8 filler[3]; -} gUnk_0811B9A8_struct; - -void PlayerItem12_Init(Entity* this) { - static const s8 gUnk_0811B9A0[] = { - 0, -18, 14, 0, 0, 14, -14, 0, - }; - static const gUnk_0811B9A8_struct gUnk_0811B9A8[] = { - { 0, 0, 0, -5, 17, { 0, 0, 0 } }, - { 1, 0, 5, 0, 18, { 0, 0, 0 } }, - { 0, 1, 0, 5, 17, { 0, 0, 0 } }, - { 0, 0, -5, 0, 18, { 0, 0, 0 } }, - }; - const gUnk_0811B9A8_struct* ptr; - - this->action = 1; - this->spriteSettings.draw = 1; - COLLISION_ON(this); - this->direction = this->animationState << 2; - this->speed = 0x200; - *(u32*)&this->field_0x74 = 0x40; - *(u32*)&this->field_0x78 = 0x1e0; - this->x.HALF.HI = gPlayerEntity.x.HALF.HI + gUnk_0811B9A0[this->animationState]; - this->y.HALF.HI = gPlayerEntity.y.HALF.HI + gUnk_0811B9A0[this->animationState + 1]; - this->field_0x3c = 7; - this->flags2 = 0x8a; - this->hitbox = (Hitbox*)&gUnk_0811B9D0; - if (this->collisionLayer == 2) { - this->type = 1; - } else { - this->type = 0; - } - this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; - ptr = &gUnk_0811B9A8[(this->animationState >> 1)]; - this->spriteSettings.flipX = ptr->flipX; - this->spriteSettings.flipY = ptr->flipY; - this->animIndex = ptr->animIndex; - *(int*)&this->field_0x6c = ptr->unk2; - this->field_0x70.WORD = ptr->unk3; - sub_0801766C(this); - InitializeAnimation(this, this->animIndex); - SoundReq(SFX_1DD); -} - -void sub_080701F8(Entity* this) { - static const s8 gUnk_0811B9C8[] = { - 0, -4, 4, 0, 0, 4, -4, 0, - }; - u32 cVar1; - u32 cVar2; - u8* iVar3; - Entity* pEVar4; - - cVar1 = gUnk_0811B9C8[this->animationState]; - cVar2 = gUnk_0811B9C8[this->animationState + 1]; - iVar3 = sub_08008782(this, 10, cVar1, cVar2); - if (iVar3) { - pEVar4 = CreateObject(OBJECT_53, iVar3[5], iVar3[2]); - if (pEVar4) { - pEVar4->actionDelay = iVar3[3]; - pEVar4->x.HALF.HI = this->x.HALF.HI + cVar1; - pEVar4->y.HALF.HI = this->y.HALF.HI + cVar2; - } - - sub_08070458(this); - return; - } - - if ((--(*(int*)&this->field_0x74) == -1) || (--(*(int*)&this->field_0x78) == -1)) { - sub_08070458(this); - } else { - GetNextFrame(this); - LinearMoveUpdate(this); - if (this->type == 0) { - sub_0800451C(this); - } - if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { - if (sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI) == 0) { - if (GetTileUnderEntity(this) == 0x19) { - this->action = 4; - COLLISION_OFF(this); - this->x.HALF.HI = (this->x.HALF.HI & 0xfff0) | 8; - this->y.HALF.HI = (this->y.HALF.HI & 0xfff0) | 8; - this->spritePriority.b0 = 7; - this->field_0x7c.WORD = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer); - InitializeAnimation(this, 0x14); - SetTile(0x4020, COORD_TO_TILE(this), this->collisionLayer); - return; - } - } else { - sub_08070458(this); - } - } - if (this->bitfield != 0) { - sub_08070458(this); - } - } -} - -void sub_0807037C(Entity* this) { - GetNextFrame(this); - if ((this->frame & ANIM_DONE) != 0) { - DeleteThisEntity(); - } -} - -void sub_08070398(Entity* this) { - GetNextFrame(this); - LinearMoveUpdate(this); - if (GravityUpdate(this, 0x2000) == 0) { - DeleteThisEntity(); - } -} - -void sub_080703BC(Entity* this) { - GetNextFrame(this); - switch (GetTileIndex(COORD_TO_TILE(this), this->collisionLayer)) { - default: - this->field_0x7c.WORD = 0; - sub_08070458(this); - break; - case 0x4021: - sub_08070458(this); - break; - case 0x4070: - *(int*)&this->field_0x78 = 0xff; - case 0x4020: - if (--(*(int*)&this->field_0x78) == -1) { - sub_08070458(this); - } else { - if (this->bitfield == 0) { - return; - } - if (((this->bitfield & 0x7f) == 0) && (this->action != 0x1a)) { - return; - } - sub_08070458(this); - return; - } - break; - } -} - -void sub_08070458(Entity* this) { - this->action = 2; - COLLISION_OFF(this); - this->speed = 0; - if (this->field_0x7c.WORD != 0) { - SetTile(this->field_0x7c.WORD, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); - } - InitializeAnimation(this, 0x13); - sub_08017744(this); - SoundReq(SFX_199); -} - -static const Hitbox gUnk_0811B9D0 = { 0, 0, 4, 2, 2, 4, 4, 4 }; diff --git a/src/playerItem/playerItem13.c b/src/playerItem/playerItem13.c deleted file mode 100644 index e76faf89..00000000 --- a/src/playerItem/playerItem13.c +++ /dev/null @@ -1,219 +0,0 @@ -#define NENT_DEPRECATED -#include "entity.h" -#include "functions.h" -#include "player.h" -#include "new_player.h" -#include "asm.h" -#include "effects.h" -#include "functions.h" -#include "player.h" -#include "new_player.h" -#include "sound.h" -#include "functions.h" -#include "new_player.h" -#include "player.h" - -extern void (*const gUnk_081320A8[])(Entity*); - -typedef struct { - Entity base; - u8 unk_68[4]; - u16 unk_6c; - u16 unk_6e; -} PlayerItem13Entity; -extern bool32 ProcessMovement10(Entity*); - -extern const s8 gUnk_081320C4[]; - -bool32 sub_080AD32C(PlayerItem13Entity*); -void sub_080AD27C(PlayerItem13Entity*); -u32 sub_0806F8DC(Entity*); - -extern const u16 gUnk_081320CC[]; -extern const u32 gUnk_081320D4[]; - -void PlayerItem13(Entity* this) { - gUnk_081320A8[this->subAction](this); -} - -ASM_FUNC("asm/non_matching/playerItem13/sub_080ACF2C.inc", void sub_080ACF2C(Entity* this)) - -void sub_080ACFCC(PlayerItem13Entity* this) { - Entity* child = super->child; - if ((this->unk_6c == child->kind) || (this->unk_6e == child->id)) { - if (child->action != 2) { - PlayerDropHeldObject(); - DeleteThisEntity(); - } else { - if ((gPlayerState.heldObject == 0) || ((gNewPlayerEntity.unk_79 & 0x7f) != 0)) { - sub_080AD27C(this); - super->subAction++; - super->flags &= 0x7f; - super->direction = 0xff; - super->zVelocity = 0; - } - } - } else { - PlayerDropHeldObject(); - DeleteThisEntity(); - } -} - -void sub_080AD040(PlayerItem13Entity* this) { - PlayerItem13Entity* child; - u32 tile; - u32 tmp; - - child = (PlayerItem13Entity*)super->child; - if ((child->base).action != 2) { - DeleteThisEntity(); - } - if ((super->bitfield & 0x80) != 0) { - super->z.WORD = 0; - } - if (super->speed != 0) { - - if ((super->knockbackDuration & 0x80) != 0) { - super->direction = super->knockbackDirection; - super->knockbackDuration = 0; - } - if (GetRelativeCollisionTile(super, gUnk_081320C4[super->direction >> 2], - gUnk_081320C4[(super->direction >> 2) + 1]) == 0x74) { - LinearMoveUpdate(super); - } else { - tile = sub_080B1B0C(super); - if ((tile != 0x24) && (tile != 0x26)) { - ProcessMovement10(super); - } - } - if (GravityUpdate(super, 0x2000) == 0) { - (child->base).zVelocity = super->zVelocity; - (child->base).x = super->x; - (child->base).y = super->y; - (child->base).z = super->z; - tile = GetTileUnderEntity(super); - switch (tile) { - case 0xd: - case 0x10: - case 0x11: - case 0x13: - case 0x5a: - if (child == this) { - - switch (tile) { - case 0xd: - CreateFx(super, FX_FALL_DOWN, 0); - break; - case 0x5a: - CreateFx(super, FX_LAVA_SPLASH, 0); - break; - case 0x10: - case 0x11: - CreateFx(super, FX_WATER_SPLASH, 0); - break; - case 0x13: - CreateFx(super, FX_GREEN_SPLASH, 0); - break; - } - (child->base).subAction = 4; - } else { - (child->base).subAction = 3; - } - DeleteThisEntity(); - break; - } - if (super->child == super) { - if (super->type2 != 0xff) { - if (super->type2 == 0x0f) { - CreateFx(super, super->actionDelay, 0x80); - } else { - CreateObjectWithParent(super, super->type2, super->actionDelay, 0); - } - } - DeleteThisEntity(); - } else { - if (super->actionDelay != 0 || sub_080AD32C(child)) { - if (super->actionDelay == 1) { - SoundReq(SFX_104); - } - UpdateSpriteForCollisionLayer(super); - child->base.subAction = 3; - child->base.spriteRendering.b3 = super->spriteRendering.b3; - child->base.spriteOrientation.flipY = super->spriteOrientation.flipY; - child->base.spritePriority.b0 = super->spritePriority.b0; - DeleteThisEntity(); - } else { - SoundReq(SFX_104); - super->actionDelay++; - super->zVelocity = 0x10000; - super->speed /= 2; - return; - } - } - } else { - sub_0800451C(super); - sub_0806F8DC(super); - CopyPosition(super, (Entity*)child); - (child->base).zVelocity = super->zVelocity; - (child->base).direction = super->direction; - return; - } - - } else { - tmp = gPlayerEntity.frame & 1; - if (tmp != 0) { - SoundReq(SFX_PLY_VO5); - sub_080AD27C(this); - return; - } - if ((gPlayerState.heldObject != 0) && ((gNewPlayerEntity.unk_79 & 0x80) == 0)) { - return; - } - sub_080AD27C(this); - super->flags &= 0x7f; - super->direction = 0xff; - super->zVelocity = tmp & 1; - return; - } -} - -void sub_080AD274(Entity* this) { - DeleteThisEntity(); -} - -void sub_080AD27C(PlayerItem13Entity* this) { - u32 tmp; - PlayerItem13Entity* child = (PlayerItem13Entity*)super->child; - gNewPlayerEntity.unk_74 = NULL; - if ((this->unk_6c == (u16)(child->base).kind) && (this->unk_6e == (u16)(child->base).id)) { - if (child != this) { - (child->base).subAction = 2; - } else { - super->spritePriority.b1 = 3; - } - super->hitbox = (child->base).hitbox; - tmp = super->field_0x16 >> 4; - super->speed = gUnk_081320CC[tmp]; - super->zVelocity = gUnk_081320D4[tmp]; - (child->base).z.HALF.HI += 8; - super->z.HALF.HI = (child->base).z.HALF.HI; - super->collisionLayer = (child->base).collisionLayer; - super->y.HALF.HI = gPlayerEntity.y.HALF.HI; - super->x.HALF.HI = gPlayerEntity.x.HALF.HI; - super->field_0x3c = gPlayerEntity.field_0x3c; - super->flags |= 0x80; - sub_0801766C(super); - } else { - PlayerDropHeldObject(); - DeleteThisEntity(); - } -} - -bool32 sub_080AD32C(PlayerItem13Entity* this) { - bool32 result = FALSE; - if (((super->field_0x16 & 0xf0) == 0x10) || - ((super->kind == OBJECT && ((super->id == 5 || (super->id == 0x7d)))))) { - result = TRUE; - } - return result; -} diff --git a/src/playerItem/playerItem14.c b/src/playerItem/playerItem14.c deleted file mode 100644 index b4e400a8..00000000 --- a/src/playerItem/playerItem14.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "entity.h" -#include "sound.h" -#include "functions.h" -#include "effects.h" -#include "asm.h" - -extern void (*const gUnk_08109AC8[])(Entity*); -extern Hitbox gUnk_08109AD0; -extern u8 gUnk_08003E44; - -void sub_0805FC74(Entity*); - -void PlayerItem14(Entity* this) { - gUnk_08109AC8[this->action](this); -} - -void sub_0805FBE8(Entity* this) { - CopyPosition(&gPlayerEntity, this); - this->action++; - this->spriteSettings.draw = TRUE; - this->field_0x3c = gPlayerEntity.field_0x3c + 1; - this->hitbox = &gUnk_08109AD0; - this->speed = 0x380; - this->animationState = this->animationState & 0x7f; - if (this->collisionLayer == 2) { - this->type2 = 1; - } - this->direction = this->animationState << 2; - *(u32*)&this->field_0x6c = 0x3c; - InitializeAnimation(this, (this->animationState >> 1) + 0xc); - sub_0801766C(this); - LinearMoveUpdate(this); - sub_0805FC74(this); - SoundReq(SFX_ITEM_SWORD_BEAM); -} - -void sub_0805FC74(Entity* this) { - int iVar1; - - if (--*(int*)&this->field_0x6c != -1) { - GetNextFrame(this); - LinearMoveUpdate(this); - this->actionDelay++; - if (this->type2 == 0) { - sub_0800451C(this); - } - if (!sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) && - sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI)) { - CreateFx(this, FX_SWORD_MAGIC, 0); - DeleteThisEntity(); - } - if (this->bitfield != 0) { - CreateFx(this, FX_SWORD_MAGIC, 0); - DeleteThisEntity(); - } - } else { - DeleteThisEntity(); - } -} diff --git a/src/playerItem/playerItem15.c b/src/playerItem/playerItem15.c deleted file mode 100644 index 16d0e35c..00000000 --- a/src/playerItem/playerItem15.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "entity.h" -#include "sound.h" -#include "coord.h" -#include "functions.h" - -extern void (*const gUnk_08127270[])(Entity*); - -extern Hitbox gUnk_08127278; -void sub_080A310C(Entity*); - -void PlayerItem15(Entity* this) { - gUnk_08127270[this->action](this); -} - -void sub_080A3084(Entity* this) { - this->spriteSettings.draw = 1; - this->action = 0x01; - CopyPosition(this->parent, this); - if (this->type == 0) { - this->field_0x3c = gPlayerEntity.field_0x3c + 0x01; - this->hitbox = &gUnk_08127278; - this->speed = 0x400; - if (this->collisionLayer == 0x02) { - this->type2 = 0x01; - } - this->direction = this->animationState << 2; - *(u32*)&this->field_0x6c = 0x3c; - sub_0801766C(this); - LinearMoveUpdate(this); - SoundReq(SFX_ITEM_SWORD_BEAM); - } else { - this->actionDelay = 0x06; - } - InitializeAnimation(this, 0x18); - sub_080A310C(this); -} - -ASM_FUNC("asm/non_matching/playerItem15/sub_080A310C.inc", void sub_080A310C(Entity* this)) diff --git a/src/playerItem/playerItem3.c b/src/playerItem/playerItem3.c deleted file mode 100644 index a461e043..00000000 --- a/src/playerItem/playerItem3.c +++ /dev/null @@ -1,242 +0,0 @@ -#include "entity.h" -#include "sound.h" -#include "functions.h" -#include "asm.h" -#include "item.h" - -void sub_0801B804(Entity*); -Entity* sub_0801B864(Entity*); -void sub_0801B584(Entity*); -void PlayerItem3_Init(Entity*); -void sub_0801B680(Entity*); -void sub_0801B7A8(Entity*); - -extern Entity* sub_08008782(Entity*, u32, s32, s32); -extern bool32 sub_080040E2(Entity*, u8*); -extern Hitbox gUnk_081271CC; -extern u8 gUnk_08003E44; - -void PlayerItem3(Entity* this) { - static void (*const PlayerItem3_Actions[])(Entity*) = { - PlayerItem3_Init, - sub_0801B584, - sub_0801B680, - sub_0801B7A8, - }; - - // Unused - static const u16 gUnk_080B780C[] = { 0x75, 0x1, 0x76, 0x1, 0x3ac, 0x1, 0x4050, 0x1, 0x377, 0x1, 0x378, 0x1, 0x0 }; - - PlayerItem3_Actions[this->action](this); - if (this->animIndex != 0xb) { - if (this->animationState == 6) { - this->field_0x86.HWORD += 0x2000; - } else { - this->field_0x86.HWORD -= 0x2000; - } - SetAffineInfo(this, 0x100, 0x100, this->field_0x86.HWORD); - } - - this->field_0xf--; - if ((this->field_0xf & 0xf) == 0) { - EnqueueSFX(SFX_FB); - } -} - -void PlayerItem3_Init(Entity* this) { - u32 uVar1; - - gPlayerState.item = this; - this->action = 1; - this->hitbox = &gUnk_081271CC; - this->frameIndex = 0xff; - this->field_0x80.HALF.LO = 0; -#ifdef EU - this->spriteVramOffset = gPlayerEntity.spriteVramOffset; -#endif - this->animIndex = 11; - this->parent = &gPlayerEntity; - this->field_0x86.HWORD = 0; - if ((this->animationState & 2) != 0) { - this->spriteSettings.flipX = ~gPlayerEntity.spriteSettings.flipX; - } - if (this->field_0x68.HALF.LO == 12) { - this->speed = 0x280; - uVar1 = 60; - } else { - this->speed = 0x200; - uVar1 = 30; - } - this->actionDelay = uVar1; - if (((s8)gPlayerState.field_0xd) >= 0) { - this->direction = gPlayerState.field_0xd; - } else { - this->direction = this->animationState << 2; - } - this->field_0x82.HALF.HI = this->direction; - if (this->collisionLayer == 2) { - this->type2 = 1; - } - LoadSwapGFX(this, 1, 3); - sub_0801766C(this); - sub_0801B584(this); -} - -void sub_0801B584(Entity* this) { - static const s8 gUnk_080B7826[] = { 0, -8, 8, -4, 0, 8, -8, -4 }; - u32 frameIndex; - int iVar2; - u32 cVar3; - - sub_0801B804(this); - if ((gPlayerState.field_0x3[1] == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != this || - (gPlayerState.item == this && gPlayerEntity.action != 1)) { - if (gPlayerState.item == this) { - gPlayerState.item = NULL; - } - DeleteThisEntity(); - } - - if ((gPlayerEntity.frame & 1) == 0) { - if (this->field_0x68.HALF.LO == 12) { - cVar3 = 6; - } else { - cVar3 = 0; - } - frameIndex = (gPlayerEntity.frame >> 4) + cVar3; - if (this->frameIndex != frameIndex) { - this->frameIndex = frameIndex; - sub_080042D0(this, this->frameIndex, this->spriteIndex); - } - sub_08078E84(this, &gPlayerEntity); - } else { - this->action = 2; - this->spriteVramOffset = 0xd5; - COLLISION_ON(this); - this->field_0x3c |= 1; - this->flags2 = gPlayerEntity.flags2; - this->spriteIndex = 0xa6; - this->spriteSettings.flipX = 0; - this->spriteSettings.draw = 1; - - iVar2 = (this->animationState >> 1) * 2; - this->x.HALF.HI += gUnk_080B7826[iVar2]; - this->y.HALF.HI += gUnk_080B7826[iVar2 + 1]; - InitializeAnimation(this, 0); - gPlayerState.item = NULL; - gPlayerState.field_0x3[1] |= 0x80; - } -} - -void sub_0801B680(Entity* this) { - u32 uvar1; - u32 uVar6; - - sub_0801B804(this); - if ((this->field_0x68.HALF.LO == 12) && (this->field_0x80.HALF.LO == 0) && ((gPlayerState.field_0xd & 0x80) == 0)) { - if (((this->field_0x82.HALF.HI - gPlayerState.field_0xd) & 0x1f) > 0x10) { - this->field_0x82.HWORD += 0x40; - this->field_0x82.HALF.HI &= 0x1f; - this->direction = this->field_0x82.HALF.HI; - } else { - this->field_0x82.HWORD -= 0x40; - this->field_0x82.HALF.HI &= 0x1f; - this->direction = this->field_0x82.HALF.HI; - } - } - LinearMoveUpdate(this); - uVar6 = 0; - if (sub_0801B864(this)) { - uvar1 = this->field_0x68.HALF.LO; - uvar1 ^= 0xc; - uVar6 = ((u32)(-uvar1 | uvar1)) >> 0x1f; - } - - if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { - if (uVar6 == 0) { - uVar6 = sub_080040E2(this, &gUnk_08003E44); - } - } - - if (uVar6 == 0) { - if (--this->actionDelay < 0xc) { - this->speed = this->speed + -0x10; - } - if (this->actionDelay == 0) { - uVar6 = 1; - } - if (this->bitfield & 0x80) { - uVar6 = 1; - } - if (uVar6 == 0) { - return; - } - if (this->field_0x68.HALF.LO == 12) { - this->actionDelay = 30; - } else { - this->actionDelay = 12; - } - } else { - this->actionDelay = 1; - } - - if (uVar6) { - this->action++; - this->speed = 0x1c0; - } -} - -void sub_0801B7A8(Entity* this) { - sub_0801B804(this); - if (this->actionDelay != 0) { - this->actionDelay -= 1; - } else { - sub_0801B864(this); - if (this->speed < 0x280) { - this->speed += 8; - } - this->direction = GetFacingDirection(this, &gPlayerEntity); - LinearMoveUpdate(this); - if (sub_0800419C(this, &gPlayerEntity, 2, 2) != 0) { - DeleteThisEntity(); - } - } -} - -void sub_0801B804(Entity* this) { - u32 itemSlot; - u32 uVar1; - - itemSlot = IsItemEquipped(ITEM_MAGIC_BOOMERANG); - switch (itemSlot) { - case 0: - uVar1 = 1; - break; - case 1: - uVar1 = 2; - break; - case 2: - uVar1 = 0; - break; - } - - if ((uVar1 & gPlayerState.field_0x90) == 0) { - this->field_0x80.HALF.LO = 1; - gPlayerState.field_0xa &= 0x7f; - gPlayerState.keepFacing &= 0x7f; - } else { - gPlayerState.field_0xa |= 0x80; - gPlayerState.keepFacing |= 0x80; - } -} - -Entity* sub_0801B864(Entity* this) { - static const s8 gUnk_080B782E[] = { 0, -6, 4, -4, 4, 0, 4, 4, 0, 4, -4, 4, -4, 0, -4, 0, 0, 0 }; - s32 iVar1; - - if (this->type2 == 0) { - sub_0800451C(this); - } - iVar1 = (this->direction >> 2) * 2; - return sub_08008782(this, 2, gUnk_080B782E[iVar1], gUnk_080B782E[iVar1 + 1]); -} diff --git a/src/playerItem/playerItemBoomerang.c b/src/playerItem/playerItemBoomerang.c new file mode 100644 index 00000000..dabceb37 --- /dev/null +++ b/src/playerItem/playerItemBoomerang.c @@ -0,0 +1,242 @@ +#include "entity.h" +#include "sound.h" +#include "functions.h" +#include "asm.h" +#include "item.h" + +void sub_0801B804(Entity*); +Entity* sub_0801B864(Entity*); +void sub_0801B584(Entity*); +void PlayerItemBoomerang_Init(Entity*); +void sub_0801B680(Entity*); +void sub_0801B7A8(Entity*); + +extern Entity* sub_08008782(Entity*, u32, s32, s32); +extern bool32 sub_080040E2(Entity*, u8*); +extern Hitbox gUnk_081271CC; +extern u8 gUnk_08003E44; + +void PlayerItemBoomerang(Entity* this) { + static void (*const PlayerItemBoomerang_Actions[])(Entity*) = { + PlayerItemBoomerang_Init, + sub_0801B584, + sub_0801B680, + sub_0801B7A8, + }; + + // Unused + static const u16 gUnk_080B780C[] = { 0x75, 0x1, 0x76, 0x1, 0x3ac, 0x1, 0x4050, 0x1, 0x377, 0x1, 0x378, 0x1, 0x0 }; + + PlayerItemBoomerang_Actions[this->action](this); + if (this->animIndex != 0xb) { + if (this->animationState == 6) { + this->field_0x86.HWORD += 0x2000; + } else { + this->field_0x86.HWORD -= 0x2000; + } + SetAffineInfo(this, 0x100, 0x100, this->field_0x86.HWORD); + } + + this->field_0xf--; + if ((this->field_0xf & 0xf) == 0) { + EnqueueSFX(SFX_FB); + } +} + +void PlayerItemBoomerang_Init(Entity* this) { + u32 uVar1; + + gPlayerState.item = this; + this->action = 1; + this->hitbox = &gUnk_081271CC; + this->frameIndex = 0xff; + this->field_0x80.HALF.LO = 0; +#ifdef EU + this->spriteVramOffset = gPlayerEntity.spriteVramOffset; +#endif + this->animIndex = 11; + this->parent = &gPlayerEntity; + this->field_0x86.HWORD = 0; + if ((this->animationState & 2) != 0) { + this->spriteSettings.flipX = ~gPlayerEntity.spriteSettings.flipX; + } + if (this->field_0x68.HALF.LO == 12) { + this->speed = 0x280; + uVar1 = 60; + } else { + this->speed = 0x200; + uVar1 = 30; + } + this->actionDelay = uVar1; + if (((s8)gPlayerState.field_0xd) >= 0) { + this->direction = gPlayerState.field_0xd; + } else { + this->direction = this->animationState << 2; + } + this->field_0x82.HALF.HI = this->direction; + if (this->collisionLayer == 2) { + this->type2 = 1; + } + LoadSwapGFX(this, 1, 3); + sub_0801766C(this); + sub_0801B584(this); +} + +void sub_0801B584(Entity* this) { + static const s8 gUnk_080B7826[] = { 0, -8, 8, -4, 0, 8, -8, -4 }; + u32 frameIndex; + int iVar2; + u32 cVar3; + + sub_0801B804(this); + if ((gPlayerState.field_0x3[1] == 0) || (gPlayerState.mobility != 0) || gPlayerState.item != this || + (gPlayerState.item == this && gPlayerEntity.action != 1)) { + if (gPlayerState.item == this) { + gPlayerState.item = NULL; + } + DeleteThisEntity(); + } + + if ((gPlayerEntity.frame & 1) == 0) { + if (this->field_0x68.HALF.LO == 12) { + cVar3 = 6; + } else { + cVar3 = 0; + } + frameIndex = (gPlayerEntity.frame >> 4) + cVar3; + if (this->frameIndex != frameIndex) { + this->frameIndex = frameIndex; + sub_080042D0(this, this->frameIndex, this->spriteIndex); + } + sub_08078E84(this, &gPlayerEntity); + } else { + this->action = 2; + this->spriteVramOffset = 0xd5; + COLLISION_ON(this); + this->field_0x3c |= 1; + this->flags2 = gPlayerEntity.flags2; + this->spriteIndex = 0xa6; + this->spriteSettings.flipX = 0; + this->spriteSettings.draw = 1; + + iVar2 = (this->animationState >> 1) * 2; + this->x.HALF.HI += gUnk_080B7826[iVar2]; + this->y.HALF.HI += gUnk_080B7826[iVar2 + 1]; + InitializeAnimation(this, 0); + gPlayerState.item = NULL; + gPlayerState.field_0x3[1] |= 0x80; + } +} + +void sub_0801B680(Entity* this) { + u32 uvar1; + u32 uVar6; + + sub_0801B804(this); + if ((this->field_0x68.HALF.LO == 12) && (this->field_0x80.HALF.LO == 0) && ((gPlayerState.field_0xd & 0x80) == 0)) { + if (((this->field_0x82.HALF.HI - gPlayerState.field_0xd) & 0x1f) > 0x10) { + this->field_0x82.HWORD += 0x40; + this->field_0x82.HALF.HI &= 0x1f; + this->direction = this->field_0x82.HALF.HI; + } else { + this->field_0x82.HWORD -= 0x40; + this->field_0x82.HALF.HI &= 0x1f; + this->direction = this->field_0x82.HALF.HI; + } + } + LinearMoveUpdate(this); + uVar6 = 0; + if (sub_0801B864(this)) { + uvar1 = this->field_0x68.HALF.LO; + uvar1 ^= 0xc; + uVar6 = ((u32)(-uvar1 | uvar1)) >> 0x1f; + } + + if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { + if (uVar6 == 0) { + uVar6 = sub_080040E2(this, &gUnk_08003E44); + } + } + + if (uVar6 == 0) { + if (--this->actionDelay < 0xc) { + this->speed = this->speed + -0x10; + } + if (this->actionDelay == 0) { + uVar6 = 1; + } + if (this->bitfield & 0x80) { + uVar6 = 1; + } + if (uVar6 == 0) { + return; + } + if (this->field_0x68.HALF.LO == 12) { + this->actionDelay = 30; + } else { + this->actionDelay = 12; + } + } else { + this->actionDelay = 1; + } + + if (uVar6) { + this->action++; + this->speed = 0x1c0; + } +} + +void sub_0801B7A8(Entity* this) { + sub_0801B804(this); + if (this->actionDelay != 0) { + this->actionDelay -= 1; + } else { + sub_0801B864(this); + if (this->speed < 0x280) { + this->speed += 8; + } + this->direction = GetFacingDirection(this, &gPlayerEntity); + LinearMoveUpdate(this); + if (sub_0800419C(this, &gPlayerEntity, 2, 2) != 0) { + DeleteThisEntity(); + } + } +} + +void sub_0801B804(Entity* this) { + u32 itemSlot; + u32 uVar1; + + itemSlot = IsItemEquipped(ITEM_MAGIC_BOOMERANG); + switch (itemSlot) { + case 0: + uVar1 = 1; + break; + case 1: + uVar1 = 2; + break; + case 2: + uVar1 = 0; + break; + } + + if ((uVar1 & gPlayerState.field_0x90) == 0) { + this->field_0x80.HALF.LO = 1; + gPlayerState.field_0xa &= 0x7f; + gPlayerState.keepFacing &= 0x7f; + } else { + gPlayerState.field_0xa |= 0x80; + gPlayerState.keepFacing |= 0x80; + } +} + +Entity* sub_0801B864(Entity* this) { + static const s8 gUnk_080B782E[] = { 0, -6, 4, -4, 4, 0, 4, 4, 0, 4, -4, 4, -4, 0, -4, 0, 0, 0 }; + s32 iVar1; + + if (this->type2 == 0) { + sub_0800451C(this); + } + iVar1 = (this->direction >> 2) * 2; + return sub_08008782(this, 2, gUnk_080B782E[iVar1], gUnk_080B782E[iVar1 + 1]); +} diff --git a/src/playerItem/playerItemC.c b/src/playerItem/playerItemC.c deleted file mode 100644 index 2ca10e84..00000000 --- a/src/playerItem/playerItemC.c +++ /dev/null @@ -1,88 +0,0 @@ - -#include "entity.h" -#include "player.h" -#include "functions.h" - -extern Entity* sub_08008782(Entity*, u32, s32, s32); - -void sub_0801B8FC(Entity*); -void sub_0801B8B0(Entity*); -void sub_0801B938(Entity*); - -extern void sub_08017744(Entity*); - -void PlayerItemC(Entity* this) { - static void (*const PlayerItemC_Actions[])(Entity*) = { - sub_0801B8B0, - sub_0801B8FC, - }; - PlayerItemC_Actions[this->action](this); -} - -void sub_0801B8B0(Entity* this) { - if (gPlayerState.dash_state != 0) { - gPlayerState.item = this; - this->flags |= ENT_PERSIST; - this->action = 0x01; - this->flags2 = 8; - LoadSwapGFX(this, 1, 3); - sub_08079BD8(this); - sub_0801766C(this); - sub_0801B8FC(this); - } else { - DeleteThisEntity(); - } -} - -void sub_0801B8FC(Entity* this) { - Entity* pbVar1; - pbVar1 = (Entity*)gPlayerState.item; - if ((Entity*)gPlayerState.item != this) { - DeleteThisEntity(); - } else { - if (gPlayerState.dash_state == 0) { - gPlayerState.item = NULL; - DeleteThisEntity(); - } else { - pbVar1->flags |= ENT_COLLIDE; - pbVar1->field_0x3c = 0x21; - sub_0801B938(pbVar1); - } - } -} - -void sub_0801B938(Entity* this) { - static const s8 gUnk_080B7848[] = { - 0, -15, 12, -3, 0, 9, -12, -3, - }; - static const Hitbox gUnk_080B7850[] = { - { 0, -18, { 0 }, 4, 8 }, - { 16, 0, { 0 }, 8, 4 }, - { 2, 11, { 0 }, 4, 8 }, - { -16, 0, { 0 }, 8, 4 }, - }; - const s8* ptr; - - if ((this->animationState & 2)) { - this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX ^ 1; - } else { - this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; - } - - if ((u8)(gPlayerEntity.animIndex + 0x68) < 4) { - this->frameIndex = gPlayerEntity.frameIndex + 0x2e; - sub_080042D0(this, this->frameIndex, this->spriteIndex); - } else { - this->frameIndex = 0xff; - } - - this->hitbox = (Hitbox*)&gUnk_080B7850[this->animationState >> 1]; - ptr = &gUnk_080B7848[(this->animationState >> 1) * 2]; - sub_08008782(this, -(gPlayerState.skills & SKILL_ROCK_BREAKER) != 0, ptr[0], ptr[1]); - sub_08078E84(this, &gPlayerEntity); -} - -void sub_0801B9F0(Entity* this) { - COLLISION_OFF(this); - sub_08017744(this); -} diff --git a/src/playerItem/playerItemDashSword.c b/src/playerItem/playerItemDashSword.c new file mode 100644 index 00000000..fccbf329 --- /dev/null +++ b/src/playerItem/playerItemDashSword.c @@ -0,0 +1,88 @@ + +#include "entity.h" +#include "player.h" +#include "functions.h" + +extern Entity* sub_08008782(Entity*, u32, s32, s32); + +void sub_0801B8FC(Entity*); +void sub_0801B8B0(Entity*); +void sub_0801B938(Entity*); + +extern void sub_08017744(Entity*); + +void PlayerItemDashSword(Entity* this) { + static void (*const PlayerItemC_Actions[])(Entity*) = { + sub_0801B8B0, + sub_0801B8FC, + }; + PlayerItemC_Actions[this->action](this); +} + +void sub_0801B8B0(Entity* this) { + if (gPlayerState.dash_state != 0) { + gPlayerState.item = this; + this->flags |= ENT_PERSIST; + this->action = 0x01; + this->flags2 = 8; + LoadSwapGFX(this, 1, 3); + sub_08079BD8(this); + sub_0801766C(this); + sub_0801B8FC(this); + } else { + DeleteThisEntity(); + } +} + +void sub_0801B8FC(Entity* this) { + Entity* pbVar1; + pbVar1 = (Entity*)gPlayerState.item; + if ((Entity*)gPlayerState.item != this) { + DeleteThisEntity(); + } else { + if (gPlayerState.dash_state == 0) { + gPlayerState.item = NULL; + DeleteThisEntity(); + } else { + pbVar1->flags |= ENT_COLLIDE; + pbVar1->field_0x3c = 0x21; + sub_0801B938(pbVar1); + } + } +} + +void sub_0801B938(Entity* this) { + static const s8 gUnk_080B7848[] = { + 0, -15, 12, -3, 0, 9, -12, -3, + }; + static const Hitbox gUnk_080B7850[] = { + { 0, -18, { 0 }, 4, 8 }, + { 16, 0, { 0 }, 8, 4 }, + { 2, 11, { 0 }, 4, 8 }, + { -16, 0, { 0 }, 8, 4 }, + }; + const s8* ptr; + + if ((this->animationState & 2)) { + this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX ^ 1; + } else { + this->spriteSettings.flipX = gPlayerEntity.spriteSettings.flipX; + } + + if ((u8)(gPlayerEntity.animIndex + 0x68) < 4) { + this->frameIndex = gPlayerEntity.frameIndex + 0x2e; + sub_080042D0(this, this->frameIndex, this->spriteIndex); + } else { + this->frameIndex = 0xff; + } + + this->hitbox = (Hitbox*)&gUnk_080B7850[this->animationState >> 1]; + ptr = &gUnk_080B7848[(this->animationState >> 1) * 2]; + sub_08008782(this, -(gPlayerState.skills & SKILL_ROCK_BREAKER) != 0, ptr[0], ptr[1]); + sub_08078E84(this, &gPlayerEntity); +} + +void sub_0801B9F0(Entity* this) { + COLLISION_OFF(this); + sub_08017744(this); +} diff --git a/src/playerItem/playerItemFireRodProjectile.c b/src/playerItem/playerItemFireRodProjectile.c new file mode 100644 index 00000000..5bb88269 --- /dev/null +++ b/src/playerItem/playerItemFireRodProjectile.c @@ -0,0 +1,38 @@ +#include "entity.h" +#include "sound.h" +#include "coord.h" +#include "functions.h" + +extern void (*const gUnk_08127270[])(Entity*); + +extern Hitbox gUnk_08127278; +void sub_080A310C(Entity*); + +void PlayerItemFireRodProjectile(Entity* this) { + gUnk_08127270[this->action](this); +} + +void sub_080A3084(Entity* this) { + this->spriteSettings.draw = 1; + this->action = 0x01; + CopyPosition(this->parent, this); + if (this->type == 0) { + this->field_0x3c = gPlayerEntity.field_0x3c + 0x01; + this->hitbox = &gUnk_08127278; + this->speed = 0x400; + if (this->collisionLayer == 0x02) { + this->type2 = 0x01; + } + this->direction = this->animationState << 2; + *(u32*)&this->field_0x6c = 0x3c; + sub_0801766C(this); + LinearMoveUpdate(this); + SoundReq(SFX_ITEM_SWORD_BEAM); + } else { + this->actionDelay = 0x06; + } + InitializeAnimation(this, 0x18); + sub_080A310C(this); +} + +ASM_FUNC("asm/non_matching/playerItem15/sub_080A310C.inc", void sub_080A310C(Entity* this)) diff --git a/src/playerItem/playerItemGust.c b/src/playerItem/playerItemGust.c new file mode 100644 index 00000000..ad0a1a12 --- /dev/null +++ b/src/playerItem/playerItemGust.c @@ -0,0 +1,218 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "player.h" +#include "functions.h" +#include "asm.h" +#include "object.h" + +enum { + GUST_INIT, + GUST_UPDATE, +}; + +typedef struct { + Entity base; + u32 filler68[2]; + u32 timer; + u32 offset_iter; + u32 unk78; +} GustEntity; +typedef void(GustActionFunc)(GustEntity*); + +static GustActionFunc PlayerItemGust_Init; +static GustActionFunc PlayerItemGust_Update; + +static void sub_080ACC78(GustEntity*); +/*static*/ bool32 sub_080ACDB0(GustEntity*); +static void sub_080ACECC(GustEntity*); + +typedef struct { + u16 bits; + u8 type2; + u8 actionDelay; + u8 _4; + u8 type; + u16 tileID; +} Obj11; + +Obj11* sub_08008782(Entity*, u32, u32, u32); + +extern const s8* const sOffsets[]; +extern const s8 gUnk_0812AABC[]; +extern const Hitbox* const sHitboxes[]; +extern const u8 gUnk_0812AAE8[]; + +// specifically, the little gusts that come out while the item is active +// type 0: stays close to jar? +// type 1: causes the particles to move away from the jar +// type 2: same as 1? +// type 3: horizontal spread +void PlayerItemGust(Entity* this) { + static GustActionFunc* const sActions[] = { + PlayerItemGust_Init, + PlayerItemGust_Update, + }; + + if ((gPlayerState.field_0x1c & 0x7f) != 1) { + DeleteThisEntity(); + } + sActions[this->action]((GustEntity*)this); + this->iframes = 0; +} + +static void PlayerItemGust_Init(GustEntity* this) { + super->action = GUST_UPDATE; + super->flags2 = gPlayerEntity.flags2; + super->direction = super->animationState << 2; + super->speed = 0x200; + super->flags |= ENT_COLLIDE | ENT_PERSIST; + super->field_0x3c = 2; + super->hitbox = (Hitbox*)sHitboxes[super->type]; + this->timer = 16; + sub_080ACDB0(this); + sub_0801766C(super); +} + +static void PlayerItemGust_Update(GustEntity* this) { + if (sub_080ACDB0(this) == FALSE) { + sub_080ACC78(this); + sub_080ACECC(this); + } +} + +static void sub_080ACC78(GustEntity* this) { + s32 width; + Obj11* o; + Entity* child; + s32 offset; + const s8* child_offsets; + + // this is what makes types 1 and 2 different? + if ((super->type + gRoomTransition.frameCount) & 1) { + child_offsets = sOffsets[super->type]; + if (child_offsets[this->offset_iter] == 0) { + this->offset_iter = 0; + } + o = sub_08008782(super, 0xe, child_offsets[this->offset_iter], child_offsets[this->offset_iter + 1]); + if (o != NULL) { + child = CreateObject(OBJECT_11, o->type, o->type2); + if (child != NULL) { + child->actionDelay = o->actionDelay; + child->x.HALF.HI = child_offsets[this->offset_iter] + super->x.HALF.HI; + child->y.HALF.HI = child_offsets[this->offset_iter + 1] + super->y.HALF.HI; + } + } + this->offset_iter += 2; + } + + if (super->child == NULL && (u32)this->timer > 2) { + this->timer = 1; + } + + if (this->timer-- != 0) { + return; + } + if (super->child == NULL) { + this->timer = 2; + } else { + this->timer = gUnk_0812AABC[super->type]; + } + child = CreateObject(OBJECT_17, 0, 0); + if (child == NULL) { + return; + } + offset = Random() % 16; + width = super->hitbox->width; + if (width < offset) { + offset = width; + } + if (offset & 1) { + offset = -offset; + } + switch (super->animationState >> 1) { + case 0: + child->y.HALF.HI = super->y.HALF.HI - super->hitbox->height; + child->x.HALF.HI = super->x.HALF.HI + offset; + break; + case 2: + child->y.HALF.HI = super->y.HALF.HI + super->hitbox->height; + child->x.HALF.HI = super->x.HALF.HI + offset; + break; + case 1: + child->x.HALF.HI = super->x.HALF.HI + super->hitbox->width; + child->y.HALF.HI = super->y.HALF.HI + offset; + break; + case 3: + child->x.HALF.HI = super->x.HALF.HI - super->hitbox->width; + child->y.HALF.HI = super->y.HALF.HI + offset; + break; + } +} + +/*static*/ ASM_FUNC("asm/non_matching/playerItem10/sub_080ACDB0.inc", bool32 sub_080ACDB0(GustEntity* this)) + +static void sub_080ACECC(GustEntity* this) { + Entity* entity; + + if (super->type < 3 && super->child == NULL && (s32)this->unk78 >= 0 && gUnk_0812AAE8[super->type] <= this->unk78) { + entity = CreatePlayerItem(0x10, super->type + 1, 0, 0); + if (entity != NULL) { + entity->parent = super; + super->child = entity; + entity->x.HALF.HI = super->x.HALF.HI; + entity->y.HALF.HI = super->y.HALF.HI; + } + } +} + +static const s8 sOffsets0[] = { + -4, -4, 4, -4, -4, 4, 4, 4, 0, +}; + +static const s8 sOffsets1And2[] = { + -5, -5, 5, -5, -5, 5, 5, 5, 0, +}; + +static const s8 sOffsets3[] = { + -9, -9, 1, -9, 9, -9, -9, 1, 9, 1, -9, 9, 1, 9, 9, 9, 0, 0, +}; + +static const s8* const sOffsets[] = { + sOffsets0, + sOffsets1And2, + sOffsets1And2, + sOffsets3, +}; + +static const s8 gUnk_0812AABC[] = { + 120, + 80, + 40, + 4, +}; + +static const Hitbox sHitbox0 = { + 0, 0, 4, 2, 2, 4, 4, 4, +}; + +static const Hitbox sHitbox1And2 = { + 0, 0, 4, 3, 3, 4, 9, 9, +}; + +static const Hitbox sHitbox3 = { + 0, 0, 8, 7, 7, 8, 14, 14, +}; + +static const Hitbox* const sHitboxes[] = { + &sHitbox0, + &sHitbox1And2, + &sHitbox1And2, + &sHitbox3, +}; + +static const u8 gUnk_0812AAE8[] = { + 0, + 12, + 16, + 16, +}; diff --git a/src/playerItem/playerItemGustBig.c b/src/playerItem/playerItemGustBig.c new file mode 100644 index 00000000..f357fb97 --- /dev/null +++ b/src/playerItem/playerItemGustBig.c @@ -0,0 +1,181 @@ +#include "global.h" +#include "entity.h" +#include "player.h" +#include "functions.h" +#include "sound.h" + +extern void sub_08078CD0(Entity*); +extern void sub_08018FA0(Entity*); +extern void sub_08018F6C(Entity*); + +extern void (*const gUnk_080B3DD0[])(Entity*); + +extern Hitbox gUnk_080B3E18; +extern u8 gUnk_080B3DE0[]; +extern Hitbox* gUnk_080B3DE8[]; + +extern u32 sub_08007DD6(u32, const u16*); + +extern const u16 gUnk_080B3DF4[]; +extern const u8 gUnk_08003E44[]; + +void PlayerItemGustBig(Entity* this) { + if (this->health) { + this->iframes = 0; + gUnk_080B3DD0[this->action](this); + } else { + DeleteThisEntity(); + } +} + +void sub_08018CBC(Entity* this) { + u32 PVar1; + u8 uVar2; + Entity* pEVar3; + + *(u32*)&this->cutsceneBeh = this->x.WORD = gPlayerEntity.x.WORD; + *(u32*)&this->field_0x80 = this->y.WORD = gPlayerEntity.y.WORD; + uVar2 = this->animationState = gPlayerEntity.animationState & 0xe; + this->direction = (u8)(uVar2 << 2); + this->speed = 0x400; + this->hitType = 0x96; + this->field_0x3c = (gPlayerEntity.field_0x3c + 1) | 0x80; + this->flags2 = gPlayerEntity.flags2; + pEVar3 = this->child; + if (pEVar3 != NULL) { + this->action = 1; + COLLISION_OFF(this); + this->actionDelay = 0x56; + this->hurtType = 0x1c; + this->damage = 6; + this->hitbox = &gUnk_080B3E18; + this->child->spriteOffsetX = 0; + this->child->spriteSettings.draw = 0; + } else { + if (gPlayerState.field_0x1c == 0) { + DeleteThisEntity(); + } + this->action = 2; + this->spriteSettings.draw = 1; + this->spriteIndex = 0xa6; + this->palette.raw = 0x33; + this->spriteVramOffset = 0; + this->type = gPlayerState.gustJarSpeed - 1; + this->actionDelay = gUnk_080B3DE0[this->type * 2]; + this->damage = gUnk_080B3DE0[this->type * 2 + 1]; + this->hurtType = 0x1b; + this->hitbox = gUnk_080B3DE8[this->type]; + (u32*)gPlayerEntity.field_0x70.WORD = this; + sub_08078CD0(&gPlayerEntity); + (u32*)gPlayerEntity.field_0x70.WORD = pEVar3; + InitializeAnimation(this, this->type + 10); + sub_08018FA0(this); + } + sub_0801766C(this); +} + +void sub_08018DE8(Entity* this) { + u8 bVar1; + + bVar1 = this->child->field_0x3a & 4; + if (bVar1 == 0) { + gPlayerState.field_0x1c = bVar1; + DeleteThisEntity(); + } + switch (gPlayerState.field_0x1c) { + case 0: + sub_08018F6C(this); + break; + case 5: + this->child->subAction = 4; + COLLISION_ON(this); + this->action = 2; + this->spritePriority.b0 = 2; + this->child->spriteSettings.draw = 1; + sub_08018FA0(this); + break; + } + sub_08078CD0(&gPlayerEntity); +} + +void sub_08018E68(Entity* this) { + s32 y; + s32 x; + if (this->child == NULL) { + GetNextFrame(this); + sub_08008790(this, 5); + } else { + if ((this->child->field_0x3a & 4) == 0) { + DeleteThisEntity(); + } + if ((this->bitfield & 0x80) != 0) { + sub_08018F6C(this); + return; + } + } + if (this->actionDelay-- != 0) { + LinearMoveUpdate(this); + + switch (this->direction) { + case DirectionNorth: + x = 0; + y = -4; + break; + case DirectionSouth: + x = 0; + y = 4; + break; + case DirectionWest: + x = -4; + y = 0; + break; + case DirectionEast: + x = 4; + y = 0; + break; + } + if (this->child != NULL) { + this->child->direction = this->direction; + CopyPosition(this, this->child); + } + if (this->type2 == 0) { + sub_0800451C(this); + } + if (sub_08007DD6(sub_080B1A0C(this, x, y), gUnk_080B3DF4) != 0) { + return; + } + if (GetRelativeCollisionTile(this, x, y) == 0x74) { + return; + } + if (sub_080040D8(this, (u8*)gUnk_08003E44, this->x.HALF.HI + x, this->y.HALF.HI + y) == 0) { + return; + } + } + + if (this->child == NULL) { + InitializeAnimation(this, this->type + 0xd); + } + this->action++; + sub_08018F6C(this); +} + +void sub_08018F6C(Entity* this) { + if (this->child != NULL) { + this->child->subAction = 5; + this->child->spriteSettings.draw = 1; + } else { + GetNextFrame(this); + if (this->frame == 0) { + return; + } + } + DeleteThisEntity(); +} + +void sub_08018FA0(Entity* this) { + this->collisionLayer = gPlayerEntity.collisionLayer; + if (this->collisionLayer == 0x02) { + this->type2 = 0x01; + } + SoundReq(this->type + SFX_EA); +} diff --git a/src/playerItem/playerItemHeldObject.c b/src/playerItem/playerItemHeldObject.c new file mode 100644 index 00000000..2eec6a4a --- /dev/null +++ b/src/playerItem/playerItemHeldObject.c @@ -0,0 +1,219 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "functions.h" +#include "player.h" +#include "new_player.h" +#include "asm.h" +#include "effects.h" +#include "functions.h" +#include "player.h" +#include "new_player.h" +#include "sound.h" +#include "functions.h" +#include "new_player.h" +#include "player.h" + +extern void (*const gUnk_081320A8[])(Entity*); + +typedef struct { + Entity base; + u8 unk_68[4]; + u16 unk_6c; + u16 unk_6e; +} PlayerItemHeldObjectEntity; +extern bool32 ProcessMovement10(Entity*); + +extern const s8 gUnk_081320C4[]; + +bool32 sub_080AD32C(PlayerItemHeldObjectEntity*); +void sub_080AD27C(PlayerItemHeldObjectEntity*); +u32 sub_0806F8DC(Entity*); + +extern const u16 gUnk_081320CC[]; +extern const u32 gUnk_081320D4[]; + +void PlayerItemHeldObject(Entity* this) { + gUnk_081320A8[this->subAction](this); +} + +ASM_FUNC("asm/non_matching/playerItem13/sub_080ACF2C.inc", void sub_080ACF2C(Entity* this)) + +void sub_080ACFCC(PlayerItemHeldObjectEntity* this) { + Entity* child = super->child; + if ((this->unk_6c == child->kind) || (this->unk_6e == child->id)) { + if (child->action != 2) { + PlayerDropHeldObject(); + DeleteThisEntity(); + } else { + if ((gPlayerState.heldObject == 0) || ((gNewPlayerEntity.unk_79 & 0x7f) != 0)) { + sub_080AD27C(this); + super->subAction++; + super->flags &= 0x7f; + super->direction = 0xff; + super->zVelocity = 0; + } + } + } else { + PlayerDropHeldObject(); + DeleteThisEntity(); + } +} + +void sub_080AD040(PlayerItemHeldObjectEntity* this) { + PlayerItemHeldObjectEntity* child; + u32 tile; + u32 tmp; + + child = (PlayerItemHeldObjectEntity*)super->child; + if ((child->base).action != 2) { + DeleteThisEntity(); + } + if ((super->bitfield & 0x80) != 0) { + super->z.WORD = 0; + } + if (super->speed != 0) { + + if ((super->knockbackDuration & 0x80) != 0) { + super->direction = super->knockbackDirection; + super->knockbackDuration = 0; + } + if (GetRelativeCollisionTile(super, gUnk_081320C4[super->direction >> 2], + gUnk_081320C4[(super->direction >> 2) + 1]) == 0x74) { + LinearMoveUpdate(super); + } else { + tile = sub_080B1B0C(super); + if ((tile != 0x24) && (tile != 0x26)) { + ProcessMovement10(super); + } + } + if (GravityUpdate(super, 0x2000) == 0) { + (child->base).zVelocity = super->zVelocity; + (child->base).x = super->x; + (child->base).y = super->y; + (child->base).z = super->z; + tile = GetTileUnderEntity(super); + switch (tile) { + case 0xd: + case 0x10: + case 0x11: + case 0x13: + case 0x5a: + if (child == this) { + + switch (tile) { + case 0xd: + CreateFx(super, FX_FALL_DOWN, 0); + break; + case 0x5a: + CreateFx(super, FX_LAVA_SPLASH, 0); + break; + case 0x10: + case 0x11: + CreateFx(super, FX_WATER_SPLASH, 0); + break; + case 0x13: + CreateFx(super, FX_GREEN_SPLASH, 0); + break; + } + (child->base).subAction = 4; + } else { + (child->base).subAction = 3; + } + DeleteThisEntity(); + break; + } + if (super->child == super) { + if (super->type2 != 0xff) { + if (super->type2 == 0x0f) { + CreateFx(super, super->actionDelay, 0x80); + } else { + CreateObjectWithParent(super, super->type2, super->actionDelay, 0); + } + } + DeleteThisEntity(); + } else { + if (super->actionDelay != 0 || sub_080AD32C(child)) { + if (super->actionDelay == 1) { + SoundReq(SFX_PLACE_OBJ); + } + UpdateSpriteForCollisionLayer(super); + child->base.subAction = 3; + child->base.spriteRendering.b3 = super->spriteRendering.b3; + child->base.spriteOrientation.flipY = super->spriteOrientation.flipY; + child->base.spritePriority.b0 = super->spritePriority.b0; + DeleteThisEntity(); + } else { + SoundReq(SFX_PLACE_OBJ); + super->actionDelay++; + super->zVelocity = 0x10000; + super->speed /= 2; + return; + } + } + } else { + sub_0800451C(super); + sub_0806F8DC(super); + CopyPosition(super, (Entity*)child); + (child->base).zVelocity = super->zVelocity; + (child->base).direction = super->direction; + return; + } + + } else { + tmp = gPlayerEntity.frame & 1; + if (tmp != 0) { + SoundReq(SFX_PLY_VO5); + sub_080AD27C(this); + return; + } + if ((gPlayerState.heldObject != 0) && ((gNewPlayerEntity.unk_79 & 0x80) == 0)) { + return; + } + sub_080AD27C(this); + super->flags &= 0x7f; + super->direction = 0xff; + super->zVelocity = tmp & 1; + return; + } +} + +void sub_080AD274(Entity* this) { + DeleteThisEntity(); +} + +void sub_080AD27C(PlayerItemHeldObjectEntity* this) { + u32 tmp; + PlayerItemHeldObjectEntity* child = (PlayerItemHeldObjectEntity*)super->child; + gNewPlayerEntity.unk_74 = NULL; + if ((this->unk_6c == (u16)(child->base).kind) && (this->unk_6e == (u16)(child->base).id)) { + if (child != this) { + (child->base).subAction = 2; + } else { + super->spritePriority.b1 = 3; + } + super->hitbox = (child->base).hitbox; + tmp = super->field_0x16 >> 4; + super->speed = gUnk_081320CC[tmp]; + super->zVelocity = gUnk_081320D4[tmp]; + (child->base).z.HALF.HI += 8; + super->z.HALF.HI = (child->base).z.HALF.HI; + super->collisionLayer = (child->base).collisionLayer; + super->y.HALF.HI = gPlayerEntity.y.HALF.HI; + super->x.HALF.HI = gPlayerEntity.x.HALF.HI; + super->field_0x3c = gPlayerEntity.field_0x3c; + super->flags |= 0x80; + sub_0801766C(super); + } else { + PlayerDropHeldObject(); + DeleteThisEntity(); + } +} + +bool32 sub_080AD32C(PlayerItemHeldObjectEntity* this) { + bool32 result = FALSE; + if (((super->field_0x16 & 0xf0) == 0x10) || + ((super->kind == OBJECT && ((super->id == 5 || (super->id == 0x7d)))))) { + result = TRUE; + } + return result; +} diff --git a/src/playerItem/playerItemPacciCaneProjectile.c b/src/playerItem/playerItemPacciCaneProjectile.c new file mode 100644 index 00000000..eee2bec5 --- /dev/null +++ b/src/playerItem/playerItemPacciCaneProjectile.c @@ -0,0 +1,189 @@ +#include "asm.h" +#include "entity.h" +#include "functions.h" +#include "sound.h" +#include "object.h" + +static const Hitbox gUnk_0811B9D0; + +void PlayerItemPacciCaneProjectile_Init(Entity* this); +void sub_080701F8(Entity* this); +void sub_0807037C(Entity* this); +void sub_08070398(Entity* this); +void sub_080703BC(Entity* this); +void sub_08070458(Entity* this); + +extern void sub_08017744(Entity*); +extern u8* sub_08008782(Entity*, u32, u32, u32); + +void PlayerItemPacciCaneProjectile(Entity* this) { + static void (*const PlayerItemPacciCaneProjectile_Actions[])(Entity*) = { + PlayerItemPacciCaneProjectile_Init, sub_080701F8, sub_0807037C, sub_08070398, sub_080703BC, + }; + PlayerItemPacciCaneProjectile_Actions[this->action](this); +} + +extern u8 gUnk_08003E44; + +typedef struct { + u8 flipX; + u8 flipY; + s8 unk2; + s8 unk3; + u8 animIndex; + u8 filler[3]; +} gUnk_0811B9A8_struct; + +void PlayerItemPacciCaneProjectile_Init(Entity* this) { + static const s8 gUnk_0811B9A0[] = { + 0, -18, 14, 0, 0, 14, -14, 0, + }; + static const gUnk_0811B9A8_struct gUnk_0811B9A8[] = { + { 0, 0, 0, -5, 17, { 0, 0, 0 } }, + { 1, 0, 5, 0, 18, { 0, 0, 0 } }, + { 0, 1, 0, 5, 17, { 0, 0, 0 } }, + { 0, 0, -5, 0, 18, { 0, 0, 0 } }, + }; + const gUnk_0811B9A8_struct* ptr; + + this->action = 1; + this->spriteSettings.draw = 1; + COLLISION_ON(this); + this->direction = this->animationState << 2; + this->speed = 0x200; + *(u32*)&this->field_0x74 = 0x40; + *(u32*)&this->field_0x78 = 0x1e0; + this->x.HALF.HI = gPlayerEntity.x.HALF.HI + gUnk_0811B9A0[this->animationState]; + this->y.HALF.HI = gPlayerEntity.y.HALF.HI + gUnk_0811B9A0[this->animationState + 1]; + this->field_0x3c = 7; + this->flags2 = 0x8a; + this->hitbox = (Hitbox*)&gUnk_0811B9D0; + if (this->collisionLayer == 2) { + this->type = 1; + } else { + this->type = 0; + } + this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + ptr = &gUnk_0811B9A8[(this->animationState >> 1)]; + this->spriteSettings.flipX = ptr->flipX; + this->spriteSettings.flipY = ptr->flipY; + this->animIndex = ptr->animIndex; + *(int*)&this->field_0x6c = ptr->unk2; + this->field_0x70.WORD = ptr->unk3; + sub_0801766C(this); + InitializeAnimation(this, this->animIndex); + SoundReq(SFX_1DD); +} + +void sub_080701F8(Entity* this) { + static const s8 gUnk_0811B9C8[] = { + 0, -4, 4, 0, 0, 4, -4, 0, + }; + u32 cVar1; + u32 cVar2; + u8* iVar3; + Entity* pEVar4; + + cVar1 = gUnk_0811B9C8[this->animationState]; + cVar2 = gUnk_0811B9C8[this->animationState + 1]; + iVar3 = sub_08008782(this, 10, cVar1, cVar2); + if (iVar3) { + pEVar4 = CreateObject(OBJECT_53, iVar3[5], iVar3[2]); + if (pEVar4) { + pEVar4->actionDelay = iVar3[3]; + pEVar4->x.HALF.HI = this->x.HALF.HI + cVar1; + pEVar4->y.HALF.HI = this->y.HALF.HI + cVar2; + } + + sub_08070458(this); + return; + } + + if ((--(*(int*)&this->field_0x74) == -1) || (--(*(int*)&this->field_0x78) == -1)) { + sub_08070458(this); + } else { + GetNextFrame(this); + LinearMoveUpdate(this); + if (this->type == 0) { + sub_0800451C(this); + } + if (sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) == 0) { + if (sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI) == 0) { + if (GetTileUnderEntity(this) == 0x19) { + this->action = 4; + COLLISION_OFF(this); + this->x.HALF.HI = (this->x.HALF.HI & 0xfff0) | 8; + this->y.HALF.HI = (this->y.HALF.HI & 0xfff0) | 8; + this->spritePriority.b0 = 7; + this->field_0x7c.WORD = GetTileIndex(COORD_TO_TILE(this), this->collisionLayer); + InitializeAnimation(this, 0x14); + SetTile(0x4020, COORD_TO_TILE(this), this->collisionLayer); + return; + } + } else { + sub_08070458(this); + } + } + if (this->bitfield != 0) { + sub_08070458(this); + } + } +} + +void sub_0807037C(Entity* this) { + GetNextFrame(this); + if ((this->frame & ANIM_DONE) != 0) { + DeleteThisEntity(); + } +} + +void sub_08070398(Entity* this) { + GetNextFrame(this); + LinearMoveUpdate(this); + if (GravityUpdate(this, 0x2000) == 0) { + DeleteThisEntity(); + } +} + +void sub_080703BC(Entity* this) { + GetNextFrame(this); + switch (GetTileIndex(COORD_TO_TILE(this), this->collisionLayer)) { + default: + this->field_0x7c.WORD = 0; + sub_08070458(this); + break; + case 0x4021: + sub_08070458(this); + break; + case 0x4070: + *(int*)&this->field_0x78 = 0xff; + case 0x4020: + if (--(*(int*)&this->field_0x78) == -1) { + sub_08070458(this); + } else { + if (this->bitfield == 0) { + return; + } + if (((this->bitfield & 0x7f) == 0) && (this->action != 0x1a)) { + return; + } + sub_08070458(this); + return; + } + break; + } +} + +void sub_08070458(Entity* this) { + this->action = 2; + COLLISION_OFF(this); + this->speed = 0; + if (this->field_0x7c.WORD != 0) { + SetTile(this->field_0x7c.WORD, TILE(this->x.HALF.HI, this->y.HALF.HI), this->collisionLayer); + } + InitializeAnimation(this, 0x13); + sub_08017744(this); + SoundReq(SFX_199); +} + +static const Hitbox gUnk_0811B9D0 = { 0, 0, 4, 2, 2, 4, 4, 4 }; diff --git a/src/playerItem/playerItemSpiralBeam.c b/src/playerItem/playerItemSpiralBeam.c new file mode 100644 index 00000000..bbd501b3 --- /dev/null +++ b/src/playerItem/playerItemSpiralBeam.c @@ -0,0 +1,59 @@ +#include "entity.h" +#include "sound.h" +#include "functions.h" +#include "effects.h" +#include "asm.h" + +extern void (*const gUnk_08109AC8[])(Entity*); +extern Hitbox gUnk_08109AD0; +extern u8 gUnk_08003E44; + +void sub_0805FC74(Entity*); + +void PlayerItemSpiralBeam(Entity* this) { + gUnk_08109AC8[this->action](this); +} + +void sub_0805FBE8(Entity* this) { + CopyPosition(&gPlayerEntity, this); + this->action++; + this->spriteSettings.draw = TRUE; + this->field_0x3c = gPlayerEntity.field_0x3c + 1; + this->hitbox = &gUnk_08109AD0; + this->speed = 0x380; + this->animationState = this->animationState & 0x7f; + if (this->collisionLayer == 2) { + this->type2 = 1; + } + this->direction = this->animationState << 2; + *(u32*)&this->field_0x6c = 0x3c; + InitializeAnimation(this, (this->animationState >> 1) + 0xc); + sub_0801766C(this); + LinearMoveUpdate(this); + sub_0805FC74(this); + SoundReq(SFX_ITEM_SWORD_BEAM); +} + +void sub_0805FC74(Entity* this) { + int iVar1; + + if (--*(int*)&this->field_0x6c != -1) { + GetNextFrame(this); + LinearMoveUpdate(this); + this->actionDelay++; + if (this->type2 == 0) { + sub_0800451C(this); + } + if (!sub_080B1BA4(COORD_TO_TILE(this), gPlayerEntity.collisionLayer, 0x80) && + sub_080040D8(this, &gUnk_08003E44, this->x.HALF.HI, this->y.HALF.HI)) { + CreateFx(this, FX_SWORD_MAGIC, 0); + DeleteThisEntity(); + } + if (this->bitfield != 0) { + CreateFx(this, FX_SWORD_MAGIC, 0); + DeleteThisEntity(); + } + } else { + DeleteThisEntity(); + } +} diff --git a/src/playerItemDefinitions.c b/src/playerItemDefinitions.c index fbe11832..1eaaff4c 100644 --- a/src/playerItemDefinitions.c +++ b/src/playerItemDefinitions.c @@ -8,7 +8,7 @@ const SpriteDataC gPlayerItemDefinitions[] = { { 0, 0, 16384, 1, SPRITE_0, 0 }, // DeleteEntity MULTI_FORM(0, 1), // PlayerItemSword { 1, 12, 5644, 169, SPRITE_166, 192 }, // PlayerItemBomb - { 0, 3, 5130, 118, SPRITE_22, 0 }, // PlayerItem3 + { 0, 3, 5130, 118, SPRITE_22, 0 }, // PlayerItemBoomerang { 1, 3, 5391, 171, SPRITE_21, 203 }, // PlayerItemBow MULTI_FORM(2, 13), // PlayerItemShield { 0, 0, 1792, 1, SPRITE_18, 0 }, // PlayerItemLantern @@ -17,16 +17,16 @@ const SpriteDataC gPlayerItemDefinitions[] = { { 4, 0, 16384, 1, SPRITE_20, 0 }, // PlayerItemPacciCane { 0, 0, 16384, 1, SPRITE_0, 0 }, // DeleteEntity { 0, 0, 16384, 1, SPRITE_0, 0 }, // DeleteEntity - MULTI_FORM(1, 1), // PlayerItemC + MULTI_FORM(1, 1), // PlayerItemDashSword MULTI_FORM(0, 1), // PlayerItemCellOverwriteSet { 0, 0, 7936, 1, SPRITE_19, 0 }, // PlayerItemSwordSpin { 0, 4, 8204, 152, SPRITE_166, 0x8000 }, // PlayerItemSwordBeam - { 0, 0, 4864, 109, SPRITE_0, 0 }, // PlayerItem10 - { 3, 0, 7183, 150, SPRITE_166, 0 }, // PlayerItem11 - { 4, 0, 7424, 1, SPRITE_166, 57 }, // PlayerItem12 - { 0, 3, 5900, 1, SPRITE_POT, 0 }, // PlayerItem13 - { 1, 4, 8460, 152, SPRITE_OBJECT43, 0x8000 }, // PlayerItem14 - { 1, 4, 8204, 152, SPRITE_166, 0x8000 }, // PlayerItem15 + { 0, 0, 4864, 109, SPRITE_0, 0 }, // PlayerItemGust + { 3, 0, 7183, 150, SPRITE_166, 0 }, // PlayerItemGustBig + { 4, 0, 7424, 1, SPRITE_166, 57 }, // PlayerItemPacciCaneProjectile + { 0, 3, 5900, 1, SPRITE_POT, 0 }, // PlayerItemHeldObject + { 1, 4, 8460, 152, SPRITE_OBJECT43, 0x8000 }, // PlayerItemSpiralBeam + { 1, 4, 8204, 152, SPRITE_166, 0x8000 }, // PlayerItemFireRodProjectile { 1, 4, 1036, 151, SPRITE_14, 0 }, // PlayerItemSwordBeam { 1, 4, 1036, 151, SPRITE_14, 0 } // PlayerItemNulled2 }; diff --git a/src/playerUtils.c b/src/playerUtils.c index 10b17c9d..5c80261b 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -78,7 +78,7 @@ void sub_0807BFD0(void); void sub_08077698(PlayerEntity* this) { ItemBehavior* puVar2; - u32 uVar3; + u32 idx; gPlayerState.field_0x3[0] &= 0xfe; gPlayerState.field_0x3[1] &= 0xf; @@ -90,15 +90,15 @@ void sub_08077698(PlayerEntity* this) { sub_08077880(gSave.stats.itemButtons[1], 2, 0); sub_080778CC(); } - uVar3 = 0; + idx = 0; puVar2 = gUnk_03000B80; do { if (puVar2->field_0x5[4] != 0) { - sub_080752E8(puVar2, uVar3); + sub_080752E8(puVar2, idx); } puVar2++; - uVar3++; - } while (uVar3 < 4); + idx++; + } while (idx < 4); } void sub_08077728(u32 param_1) { @@ -432,12 +432,12 @@ Entity* sub_08077CF8(u32 subtype, u32 form, u32 parameter, u32 unk) { return &ent->base; } -void sub_08077D38(ItemBehavior* beh, u32 arg2) { +void sub_08077D38(ItemBehavior* beh, u32 idx) { u32 r6; struct_0811BE48* ptr; - gPlayerState.field_0xa |= 8 >> arg2; - gPlayerState.keepFacing |= 8 >> arg2; + gPlayerState.field_0xa |= 8 >> idx; + gPlayerState.keepFacing |= 8 >> idx; beh->field_0x5[5] = gPlayerEntity.animationState; if (beh->stateID == 0) { beh->stateID++; @@ -465,7 +465,7 @@ void sub_08077D38(ItemBehavior* beh, u32 arg2) { beh->field_0xf = ptr->unk6[0]; if (ptr->unk6[1]) { - gPlayerState.field_0x3[1] |= (8 >> arg2) | ((8 >> arg2) << 4); + gPlayerState.field_0x3[1] |= (8 >> idx) | ((8 >> idx) << 4); } } @@ -478,13 +478,13 @@ typedef struct { u8 unk[16]; } Unk_struct_in_08077EC8; -void sub_08077DF4(ItemBehavior* beh, u32 arg1) { - beh->field_0x10 = arg1; - if ((arg1 & 0xff) > 0xb8) { - arg1 += beh->field_0x5[5] >> 1; +void sub_08077DF4(ItemBehavior* beh, u32 animation) { + beh->field_0x10 = animation; + if ((animation & 0xff) > 0xb8) { + animation += beh->field_0x5[5] >> 1; } - gPlayerEntity.spriteIndex = (short)(arg1 >> 8); - InitAnimationForceUpdate(&gPlayerEntity, (u8)arg1); + gPlayerEntity.spriteIndex = (short)(animation >> 8); + InitAnimationForceUpdate(&gPlayerEntity, (u8)animation); sub_08077E54(beh); } @@ -505,10 +505,10 @@ void sub_08077E54(ItemBehavior* beh) { beh->field_0x5[9] = gPlayerEntity.frame; } -void DeletePlayerItem(ItemBehavior* arg0, u32 bits) { +void DeletePlayerItem(ItemBehavior* arg0, u32 idx) { u32 not ; - if (bits == 0) { + if (idx == 0) { if (gPlayerState.item != NULL) { ((Unk_bitfield*)gPlayerState.item)[0x11].b0 = 6; gPlayerState.item = NULL; @@ -517,8 +517,8 @@ void DeletePlayerItem(ItemBehavior* arg0, u32 bits) { } } - not = (8 >> bits); - gPlayerState.field_0x3[1] &= ~((u8)((8 >> bits) << 4) | not ); + not = (8 >> idx); + gPlayerState.field_0x3[1] &= ~((u8)((8 >> idx) << 4) | not ); not = ~not ; gPlayerState.field_0xa &= not ; gPlayerState.keepFacing &= not ; diff --git a/src/sound.c b/src/sound.c index e0c772b9..bc152269 100644 --- a/src/sound.c +++ b/src/sound.c @@ -1086,7 +1086,7 @@ const Song gSongTable[] = { [SFX_101] = { &sfx101, MUSIC_PLAYER_10, MUSIC_PLAYER_10 }, [SFX_102] = { &sfx102, MUSIC_PLAYER_0F, MUSIC_PLAYER_0F }, [SFX_103] = { &sfx103, MUSIC_PLAYER_00, MUSIC_PLAYER_00 }, - [SFX_104] = { &sfx104, MUSIC_PLAYER_0D, MUSIC_PLAYER_0D }, + [SFX_PLACE_OBJ] = { &sfx104, MUSIC_PLAYER_0D, MUSIC_PLAYER_0D }, [SFX_105] = { &sfx105, MUSIC_PLAYER_1E, MUSIC_PLAYER_1E }, [SFX_106] = { &sfx106, MUSIC_PLAYER_0B, MUSIC_PLAYER_0B }, [SFX_107] = { &sfx107, MUSIC_PLAYER_0A, MUSIC_PLAYER_0A }, -- cgit v1.2.3