From 7c1c612c9ba95b47f33cfd217ab99c4c9102531e Mon Sep 17 00:00:00 2001 From: theo3 Date: Thu, 28 Dec 2023 17:48:05 -0800 Subject: [PATCH] fix fakematch in LinkHoldingItem_Action3 --- include/player.h | 32 +++++++++++------------ src/beanstalkSubtask.c | 6 ++--- src/code_0805EC04.c | 26 +++++++++---------- src/enemy/likeLike.c | 8 +++--- src/item/itemPegasusBoots.c | 6 ++--- src/item/itemTryPickupObject.c | 4 +-- src/itemUtils.c | 20 +++++++------- src/manager/miscManager.c | 2 +- src/menu/pauseMenu.c | 4 +-- src/npc/bigGoron.c | 2 +- src/npc/bladeBrothers.c | 4 +-- src/npc/npc4E.c | 4 +-- src/object/crenelBeanSprout.c | 2 +- src/object/houseDoorExterior.c | 2 +- src/object/itemForSale.c | 4 +-- src/object/linkHoldingItem.c | 10 +++---- src/player.c | 15 +++++------ src/playerItem/playerItemBomb.c | 4 +-- src/playerUtils.c | 46 ++++++++++++++++----------------- src/title.c | 2 +- src/ui.c | 2 +- 21 files changed, 101 insertions(+), 104 deletions(-) diff --git a/include/player.h b/include/player.h index 49a4bce74..19be9997d 100644 --- a/include/player.h +++ b/include/player.h @@ -243,23 +243,21 @@ typedef struct { } PlayerMacroEntry; typedef enum { - PLAYER_INPUT_1 = 0x1, // A - PLAYER_INPUT_2 = 0x2, // B - PLAYER_INPUT_8 = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2 - PLAYER_INPUT_10 = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2 - PLAYER_INPUT_20 = 0x20, // R sub_0807953C - PLAYER_INPUT_40 = 0x40, // A CrenelBeanSprout_Action1 - PLAYER_INPUT_80 = + INPUT_USE_ITEM1 = 0x1, // A + INPUT_USE_ITEM2 = 0x2, // B + INPUT_INTERACT = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2 + INPUT_CANCEL = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2 + INPUT_CONTEXT = 0x20, // R sub_0807953C + INPUT_40 = 0x40, // A CrenelBeanSprout_Action1 + INPUT_ACTION = 0x80, // R sub_08073584, IsPreventedFromUsingItem, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2 - PLAYER_INPUT_RIGHT = 0x100, - PLAYER_INPUT_LEFT = 0x200, - PLAYER_INPUT_UP = 0x400, - PLAYER_INPUT_DOWN = 0x800, - PLAYER_INPUT_ANY_DIRECTION = 0xf00, - PLAYER_INPUT_1000 = 0x1000, // L, where is it set? sub_080782C0 - PLAYER_INPUT_8000 = 0x8000, // R, IsTryingToPickupObject, sub_08076518 - - // TODO What is the result of u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000;? + INPUT_RIGHT = 0x100, + INPUT_LEFT = 0x200, + INPUT_UP = 0x400, + INPUT_DOWN = 0x800, + INPUT_ANY_DIRECTION = 0xf00, + INPUT_FUSE = 0x1000, // L, where is it set? sub_080782C0 + INPUT_LIFT_THROW = 0x8000, // R, IsTryingToPickupObject, sub_08076518 } PlayerInputState; typedef struct { @@ -535,7 +533,7 @@ typedef struct { /*0x09*/ u8 _hasAllFigurines; /*0x0a*/ u8 charm; /*0x0b*/ u8 picolyteType; - /*0x0c*/ u8 itemButtons[2]; + /*0x0c*/ u8 equipped[2]; /*0x0e*/ u8 bottles[4]; /*0x12*/ u8 effect; /*0x13*/ u8 hasAllFigurines; diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 3d4258175..a115acc1b 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -313,7 +313,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_READ; - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) { return 0; } gPlayerState.mobility = 1; @@ -327,7 +327,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN; - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) { return 0; } gPlayerState.mobility = 1; @@ -338,7 +338,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN; - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) { return 0; } gPlayerState.mobility = 1; diff --git a/src/code_0805EC04.c b/src/code_0805EC04.c index 1a040933f..4d584da9f 100644 --- a/src/code_0805EC04.c +++ b/src/code_0805EC04.c @@ -138,40 +138,40 @@ void UpdatePlayerInput(void) { gPlayerState.playerInput.heldInput = state; gPlayerState.playerInput.newInput = state & prevState; // Calculate the direction from the currently held input. - gPlayerState.direction = gUnk_08109202[(state & PLAYER_INPUT_ANY_DIRECTION) >> 8]; + gPlayerState.direction = gUnk_08109202[(state & INPUT_ANY_DIRECTION) >> 8]; } u32 ConvInputToState(u32 keys) { u32 result; if (keys & L_BUTTON) { - result = 0x1000; + result = INPUT_FUSE; } else { result = 0; } if (keys & R_BUTTON) { - result |= PLAYER_INPUT_20; - result |= PLAYER_INPUT_8000; - result |= PLAYER_INPUT_80; + result |= INPUT_CONTEXT; + result |= INPUT_LIFT_THROW; + result |= INPUT_ACTION; } if (keys & A_BUTTON) { - result |= PLAYER_INPUT_8; - result |= PLAYER_INPUT_40 | PLAYER_INPUT_1; + result |= INPUT_INTERACT; + result |= INPUT_40 | INPUT_USE_ITEM1; } if (keys & B_BUTTON) { - result |= PLAYER_INPUT_10; - result |= PLAYER_INPUT_2; + result |= INPUT_CANCEL; + result |= INPUT_USE_ITEM2; } if (keys & DPAD_RIGHT) { - result |= PLAYER_INPUT_RIGHT; + result |= INPUT_RIGHT; } if (keys & DPAD_LEFT) { - result |= PLAYER_INPUT_LEFT; + result |= INPUT_LEFT; } if (keys & DPAD_UP) { - result |= PLAYER_INPUT_UP; + result |= INPUT_UP; } if (keys & DPAD_DOWN) { - result |= PLAYER_INPUT_DOWN; + result |= INPUT_DOWN; } return result; } diff --git a/src/enemy/likeLike.c b/src/enemy/likeLike.c index 886aa8b78..782a51b21 100644 --- a/src/enemy/likeLike.c +++ b/src/enemy/likeLike.c @@ -260,12 +260,12 @@ void sub_080281A0(LikeLikeEntity* this) { bool32 LikeLike_StealItem(u32 item) { bool32 ret = FALSE; if (GetInventoryValue(item) == 1) { - if (ItemIsShield(gSave.stats.itemButtons[SLOT_A])) { - gSave.stats.itemButtons[SLOT_A] = ITEM_NONE; + if (ItemIsShield(gSave.stats.equipped[SLOT_A])) { + gSave.stats.equipped[SLOT_A] = ITEM_NONE; } - if (ItemIsShield(gSave.stats.itemButtons[SLOT_B])) { - gSave.stats.itemButtons[SLOT_B] = ITEM_NONE; + if (ItemIsShield(gSave.stats.equipped[SLOT_B])) { + gSave.stats.equipped[SLOT_B] = ITEM_NONE; } SetInventoryValue(item, 0); diff --git a/src/item/itemPegasusBoots.c b/src/item/itemPegasusBoots.c index 1f4aa52a8..550889840 100644 --- a/src/item/itemPegasusBoots.c +++ b/src/item/itemPegasusBoots.c @@ -107,10 +107,10 @@ void sub_08076964(ItemBehavior* this, u32 index) { SetItemAnim(this, ANIM_DASH); entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD); if (entity != NULL) { - if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) { - uVar3 = gSave.stats.itemButtons[SLOT_A]; + if (ItemIsSword(gSave.stats.equipped[SLOT_A]) != 0) { + uVar3 = gSave.stats.equipped[SLOT_A]; } else { - uVar3 = gSave.stats.itemButtons[SLOT_B]; + uVar3 = gSave.stats.equipped[SLOT_B]; } entity->field_0x68.HALF.LO = uVar3; return; diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index c1fc697e9..1eb76da5c 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -145,7 +145,7 @@ void sub_080762D8(ItemBehavior* this, u32 index) { if (gPlayerEntity.iframes < 9 && gPlayerEntity.knockbackDuration == 0) { if (this->field_0x18 != NULL) { if (this->field_0x18->action == 2 && this->field_0x18->subAction == 5) { - if (!(gPlayerState.playerInput.heldInput & PLAYER_INPUT_80)) { // Pressing R + if (!(gPlayerState.playerInput.heldInput & INPUT_ACTION)) { // Pressing R this->field_0x18->subAction = 6; PlayerCancelHoldItem(this, index); return; @@ -263,7 +263,7 @@ void sub_08076518(ItemBehavior* this, u32 index) { if (gPlayerEntity.knockbackDuration != 0) { PlayerCancelHoldItem(this, index); } else { - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_8000 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_LIFT_THROW | INPUT_CANCEL | INPUT_INTERACT)) != 0) { sub_0806F948(&gPlayerEntity); gPlayerState.heldObject = 5; this->field_0x18->subAction = 2; diff --git a/src/itemUtils.c b/src/itemUtils.c index 1b3cf9486..c78c0da36 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -255,9 +255,9 @@ void ModArrows(s32 arrows) { EquipSlot IsItemEquipped(u32 itemId) { EquipSlot equipSlot; - if (itemId == gSave.stats.itemButtons[SLOT_A]) { + if (itemId == gSave.stats.equipped[SLOT_A]) { equipSlot = EQUIP_SLOT_A; - } else if (itemId == gSave.stats.itemButtons[SLOT_B]) { + } else if (itemId == gSave.stats.equipped[SLOT_B]) { equipSlot = EQUIP_SLOT_B; } else { equipSlot = EQUIP_SLOT_NONE; @@ -273,17 +273,17 @@ void PutItemOnSlot(u32 itemId) { } if (itemId2 - 1 < 0x1f) { equipSlot = EQUIP_SLOT_NONE; - if (gSave.stats.itemButtons[SLOT_A] == ITEM_NONE) { + if (gSave.stats.equipped[SLOT_A] == ITEM_NONE) { equipSlot = EQUIP_SLOT_A; - } else if (gSave.stats.itemButtons[SLOT_B] == ITEM_NONE) { + } else if (gSave.stats.equipped[SLOT_B] == ITEM_NONE) { equipSlot = EQUIP_SLOT_B; } if (equipSlot == EQUIP_SLOT_NONE) { u32 temp = gItemMetaData[itemId2].menuSlot; - if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_A]].menuSlot) { + if (temp == gItemMetaData[gSave.stats.equipped[SLOT_A]].menuSlot) { equipSlot = EQUIP_SLOT_A; } else { - if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_B]].menuSlot) { + if (temp == gItemMetaData[gSave.stats.equipped[SLOT_B]].menuSlot) { equipSlot = EQUIP_SLOT_B; } } @@ -302,13 +302,13 @@ void ForceEquipItem(u32 itemId, u32 equipSlot) { if ((itemId - 1 < 0x1f) && (equipSlot < EQUIP_SLOT_NONE)) { otherItemSlot = equipSlot == EQUIP_SLOT_A; - replacedItem = gSave.stats.itemButtons[equipSlot]; - otherItem = gSave.stats.itemButtons[otherItemSlot]; + replacedItem = gSave.stats.equipped[equipSlot]; + otherItem = gSave.stats.equipped[otherItemSlot]; if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemId].menuSlot) { otherItem = replacedItem; } - gSave.stats.itemButtons[equipSlot] = itemId; - gSave.stats.itemButtons[otherItemSlot] = otherItem; + gSave.stats.equipped[equipSlot] = itemId; + gSave.stats.equipped[otherItemSlot] = otherItem; gUnk_0200AF00.unk_13 = 0x7f; gUnk_0200AF00.unk_14 = 0x7f; } diff --git a/src/manager/miscManager.c b/src/manager/miscManager.c index 5ae26ace5..80d4cffc7 100644 --- a/src/manager/miscManager.c +++ b/src/manager/miscManager.c @@ -364,7 +364,7 @@ void MiscManager_TypeB(MiscManager* this) { bool32 sub_080593CC(MiscManager* this) { if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 && - (gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) == PLAYER_INPUT_UP) { + (gPlayerState.playerInput.heldInput & INPUT_ANY_DIRECTION) == INPUT_UP) { return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6); } return FALSE; diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index 2ea791136..6b1d0cefd 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -529,14 +529,14 @@ void PauseMenu_ItemMenu_Draw(void) { gOamCmd._8 = 0x800; DrawDirect(sub_080A5384_draw_constant0, 0x22); } - i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_A]); + i = GetMenuSlotForItem(gSave.stats.equipped[SLOT_A]); if (i < MENU_SLOT_COUNT) { entry = &gItemMenuTable[i]; gOamCmd.x = entry->x; gOamCmd.y = entry->y; DrawDirect(sub_080A5384_draw_constant0, 3); } - i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_B]); + i = GetMenuSlotForItem(gSave.stats.equipped[SLOT_B]); if (i < MENU_SLOT_COUNT) { entry = &gItemMenuTable[i]; gOamCmd.x = entry->x; diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c index 83205c441..059f61638 100644 --- a/src/npc/bigGoron.c +++ b/src/npc/bigGoron.c @@ -434,7 +434,7 @@ void sub_0806D5D4(void) { InitBiggoronTimer(); equipSlot = IsItemEquipped(ITEM_SHIELD); if (equipSlot != EQUIP_SLOT_NONE) { - gSave.stats.itemButtons[equipSlot] = ITEM_NONE; + gSave.stats.equipped[equipSlot] = ITEM_NONE; } SetInventoryValue(ITEM_SHIELD, 0); } diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index ecb97fe28..598b05237 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -339,10 +339,10 @@ void BladeBrothers_StartPlayerDemonstration(Entity* this, ScriptExecutionContext } void sub_08068BB4(BladeBrothersEntity* this) { - u32 item = gSave.stats.itemButtons[SLOT_A]; + u32 item = gSave.stats.equipped[SLOT_A]; this->itemSlotA = item; - item = gSave.stats.itemButtons[SLOT_B]; + item = gSave.stats.equipped[SLOT_B]; this->itemSlotB = item; } diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 910fb485c..e60812b23 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -186,8 +186,8 @@ Item NPC4E_GetItemWithSwordUpgraded(Item itemId) { } void NPC4E_SaveEquippedItems(NPC4EEntity* this) { - this->unk_68 = gSave.stats.itemButtons[SLOT_A]; - this->unk_69 = gSave.stats.itemButtons[SLOT_B]; + this->unk_68 = gSave.stats.equipped[SLOT_A]; + this->unk_69 = gSave.stats.equipped[SLOT_B]; } void NPC4E_RestoreEquippedItems(NPC4EEntity* this) { diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index a9d500cd5..1e28d988c 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -179,7 +179,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { RestorePrevTileEntity(0xdc, super->collisionLayer); sub_08096A78(this); } - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) { return; } if (gUnk_0200AF00.rActionPlayerState != R_ACTION_THROW) { diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 5b0a94f61..a921f8ba3 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -184,7 +184,7 @@ void sub_0808692C(HouseDoorExteriorEntity* this) { static u8 sub_08086954(HouseDoorExteriorEntity* this) { if (sub_0800445C(super)) { if (GetAnimationStateInRectRadius(super, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && - (u16)gPlayerState.playerInput.heldInput == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) { + (u16)gPlayerState.playerInput.heldInput == INPUT_UP && gPlayerState.jump_status == 0) { super->timer--; } } else { diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index 7dcef6c5e..aca8b2fd8 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -118,8 +118,8 @@ void ItemForSale_Action2(ItemForSaleEntity* this) { ptr = sub_080784E4(); if (((*(int*)(ptr + 8) == 0) || ((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.rActionPlayerState = R_ACTION_SPEAK, (gPlayerState.playerInput.newInput & - (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) && - ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) { + (INPUT_ACTION | INPUT_INTERACT)) == 0)))) && + ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_CANCEL | INPUT_INTERACT)) != 0)) { sub_080819B4(this); } } diff --git a/src/object/linkHoldingItem.c b/src/object/linkHoldingItem.c index ae9826373..cf14269a9 100644 --- a/src/object/linkHoldingItem.c +++ b/src/object/linkHoldingItem.c @@ -123,8 +123,8 @@ void LinkHoldingItem_Action2(LinkHoldingItemEntity* this) { } void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) { - u32 tmp; - if ((super->parent)->action == 8) { + u32 bottle_no; + if (super->parent->action == PLAYER_ITEMGET) { return; } switch (super->timer) { @@ -149,9 +149,9 @@ void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) { ModHealth(160); break; case 3: - tmp = GetBottleContaining(super->type); - if (tmp != 0) { - gSave.stats.itemButtons[tmp + 1] = ITEM_BOTTLE_EMPTY; + bottle_no = GetBottleContaining(super->type); + if (bottle_no != 0) { + gSave.stats.bottles[bottle_no - 1] = ITEM_BOTTLE_EMPTY; } else { SetInventoryValue(super->type, ITEM_GREEN_SWORD); } diff --git a/src/player.c b/src/player.c index 12b1ff453..cc028dbab 100644 --- a/src/player.c +++ b/src/player.c @@ -2750,7 +2750,7 @@ static void sub_08073504(Entity* this) { static void sub_08073584(Entity* this) { u32 state, dir, idx; - if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_80) || this->iframes > 0 || gPlayerState.field_0x3c || + if ((gPlayerState.playerInput.newInput & INPUT_ACTION) || this->iframes > 0 || gPlayerState.field_0x3c || (gPlayerState.flags & PL_PARACHUTE) == 0) { gPlayerState.jump_status |= 0x40; PlayerSetNormalAndCollide(); @@ -3447,10 +3447,10 @@ void SurfaceAction_14(Entity* this) { void SurfaceAction_CloneTile(Entity* this) { if (gPlayerState.chargeState.action == 4) { u32 item, n, i; - if (ItemIsSword(gSave.stats.itemButtons[SLOT_A])) { - item = gSave.stats.itemButtons[SLOT_A]; + if (ItemIsSword(gSave.stats.equipped[SLOT_A])) { + item = gSave.stats.equipped[SLOT_A]; } else { - item = gSave.stats.itemButtons[SLOT_B]; + item = gSave.stats.equipped[SLOT_B]; } switch (item) { case 1: @@ -3523,8 +3523,7 @@ void SurfaceAction_ShallowWater(Entity* this) { this->spritePriority.b0 = 4; gPlayerState.swim_state = 0; } - if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) || - gPlayerState.surfacePositionSameTimer == 1) + if ((gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) || gPlayerState.surfacePositionSameTimer == 1) SoundReq(SFX_WATER_WALK); } } @@ -3567,7 +3566,7 @@ void SurfaceAction_Swamp(Entity* this) { CreateObjectWithParent(this, OBJECT_70, 0, 0); CreateFx(this, FX_GREEN_SPLASH, 0); SoundReq(SFX_161); - } else if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) != 0) { + } else if ((gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) != 0) { SoundReq(SFX_161); } else if ((gRoomTransition.frameCount & 0xf) == 0) { SoundReq(SFX_161); @@ -3723,7 +3722,7 @@ void SurfaceAction_Dust(Entity* this) { if (!sub_080741C4()) { gPlayerState.speed_modifier -= 128; if (gPlayerState.surfacePositionSameTimer == 1 || - (gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) != 0) { + (gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) != 0) { if (gPlayerState.floor_type == SURFACE_DUST) CreateObjectWithParent(this, DIRT_PARTICLE, 1, 0); else diff --git a/src/playerItem/playerItemBomb.c b/src/playerItem/playerItemBomb.c index 636474597..af4432668 100644 --- a/src/playerItem/playerItemBomb.c +++ b/src/playerItem/playerItemBomb.c @@ -113,10 +113,10 @@ void PlayerItemBomb_Action1(PlayerItemBombEntity* this) { } switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) { case EQUIP_SLOT_A: - input = PLAYER_INPUT_1; + input = INPUT_USE_ITEM1; break; case EQUIP_SLOT_B: - input = PLAYER_INPUT_2; + input = INPUT_USE_ITEM2; break; case EQUIP_SLOT_NONE: input = 0; diff --git a/src/playerUtils.c b/src/playerUtils.c index cddb108a3..cff07abb7 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -175,8 +175,8 @@ void UpdateActiveItems(PlayerEntity* this) { gPlayerState.attack_status &= 0xf; if (((gPlayerState.field_0x7 | gPlayerState.jump_status) & 0x80) == 0 && (gPlayerState.jump_status & 0x40) == 0 && gPlayerState.swim_state == 0 && IsAbleToUseItem(this) && !IsPreventedFromUsingItem()) { - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_A], PLAYER_INPUT_1, FALSE); - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_B], PLAYER_INPUT_2, FALSE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_A], INPUT_USE_ITEM1, FALSE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_B], INPUT_USE_ITEM2, FALSE); IsTryingToPickupObject(); } @@ -189,9 +189,9 @@ void UpdateActiveItems(PlayerEntity* this) { void CreateItemEquippedAtSlot(EquipSlot equipSlot) { if (equipSlot == EQUIP_SLOT_A) { - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_A], PLAYER_INPUT_1, TRUE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_A], INPUT_USE_ITEM1, TRUE); } else { - CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_B], PLAYER_INPUT_2, TRUE); + CreateItemIfInputMatches(gSave.stats.equipped[SLOT_B], INPUT_USE_ITEM2, TRUE); } } @@ -210,7 +210,7 @@ bool32 IsAbleToUseItem(PlayerEntity* this) { } bool32 IsPreventedFromUsingItem(void) { - if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_80) != 0) { + if ((gPlayerState.playerInput.newInput & INPUT_ACTION) != 0) { if ((gPlayerState.flags & PL_CLONING) != 0) { gPlayerState.chargeState.action = 1; DeleteClones(); @@ -233,7 +233,7 @@ bool32 IsPreventedFromUsingItem(void) { default: if ((((gUnk_0200AF00.rActionInteractObject == R_ACTION_ROLL) && (gPlayerState.field_0x1c == 0)) && (gPlayerState.floor_type != SURFACE_SWAMP)) && - ((((gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) != 0 && + ((((gPlayerState.playerInput.heldInput & INPUT_ANY_DIRECTION) != 0 && ((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) && ((gPlayerState.jump_status == 0 && (gPlayerState.attack_status == 0)))))) { gPlayerState.queued_action = PLAYER_ROLL; @@ -274,9 +274,9 @@ bool32 IsTryingToPickupObject(void) { if (!((((gPlayerState.flags & (PL_USE_PORTAL | PL_MINISH | PL_ROLLING)) == 0) && (((gNewPlayerEntity.unk_79 != 0 || (gPlayerState.heldObject != 0)) || - ((gPlayerState.playerInput.newInput & PLAYER_INPUT_8000) != 0)))) && + ((gPlayerState.playerInput.newInput & INPUT_LIFT_THROW) != 0)))) && (((sub_080789A8() != 0 || ((gPlayerState.playerInput.heldInput & - (PLAYER_INPUT_ANY_DIRECTION | PLAYER_INPUT_1 | PLAYER_INPUT_2)) == 0)))))) { + (INPUT_ANY_DIRECTION | INPUT_USE_ITEM1 | INPUT_USE_ITEM2)) == 0)))))) { return FALSE; } item = CreateItem(ITEM_TRY_PICKUP_OBJECT); @@ -631,10 +631,10 @@ bool32 IsItemActiveByInput(ItemBehavior* this, PlayerInputState input) { u32 val; Stats* stats = &gSave.stats; u32 id = this->behaviorId; - if (stats->itemButtons[SLOT_A] == id) { - val = PLAYER_INPUT_1; - } else if (stats->itemButtons[SLOT_B] == id) { - val = PLAYER_INPUT_2; + if (stats->equipped[SLOT_A] == id) { + val = INPUT_USE_ITEM1; + } else if (stats->equipped[SLOT_B] == id) { + val = INPUT_USE_ITEM2; } else { val = 0; } @@ -901,10 +901,10 @@ bool32 sub_08077FEC(u32 action) { bool32 sub_08078008(ChargeState* state) { Item swordType; - if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != ITEM_NONE) { - swordType = gSave.stats.itemButtons[SLOT_A]; - } else if (ItemIsSword(gSave.stats.itemButtons[SLOT_B]) != ITEM_NONE) { - swordType = gSave.stats.itemButtons[SLOT_B]; + if (ItemIsSword(gSave.stats.equipped[SLOT_A]) != ITEM_NONE) { + swordType = gSave.stats.equipped[SLOT_A]; + } else if (ItemIsSword(gSave.stats.equipped[SLOT_B]) != ITEM_NONE) { + swordType = gSave.stats.equipped[SLOT_B]; } else { swordType = ITEM_NONE; } @@ -1110,7 +1110,7 @@ bool32 sub_080782C0(void) { return FALSE; } } - if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && + if (((gPlayerState.playerInput.newInput & INPUT_FUSE) != 0) && ((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) < 100)) { AddKinstoneToBag(KINSTONE_NONE); if (gSave.kinstones.amounts[0] != 0) { @@ -1123,7 +1123,7 @@ bool32 sub_080782C0(void) { ForceSetPlayerState(PL_STATE_TALKEZLO); return TRUE; } - if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { + if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) { return FALSE; } switch (gPossibleInteraction.currentObject->type) { @@ -1973,7 +1973,7 @@ void sub_08079520(Entity* this) { } u32 sub_0807953C(void) { - u32 tmp = PLAYER_INPUT_ANY_DIRECTION | PLAYER_INPUT_20 | PLAYER_INPUT_10 | PLAYER_INPUT_8; + u32 tmp = INPUT_ANY_DIRECTION | INPUT_CONTEXT | INPUT_CANCEL | INPUT_INTERACT; return gPlayerState.playerInput.newInput & tmp; } @@ -2549,10 +2549,10 @@ void DeleteClones(void) { } bool32 HasSwordEquipped(void) { - if (ItemIsSword((u32)gSave.stats.itemButtons[SLOT_A]) != 0) { + if (ItemIsSword((u32)gSave.stats.equipped[SLOT_A]) != 0) { return TRUE; } else { - return ItemIsSword((u32)gSave.stats.itemButtons[SLOT_B]); + return ItemIsSword((u32)gSave.stats.equipped[SLOT_B]); } } @@ -3009,7 +3009,7 @@ void PlayerSwimming(Entity* this) { } bool32 ToggleDiving(Entity* this) { - if (gPlayerState.playerInput.newInput & PLAYER_INPUT_10) { + if (gPlayerState.playerInput.newInput & INPUT_CANCEL) { gPlayerState.swim_state ^= 0x80; if (gPlayerState.swim_state & 0x80) { gPlayerState.remainingDiveTime = 0x78; @@ -3026,7 +3026,7 @@ bool32 ToggleDiving(Entity* this) { void PlayerUpdateSwimming(Entity* this) { if ((((this->action != 0x17) || (gPlayerState.field_0xa == 0)) && (gRoomControls.reload_flags == 0)) && - ((gPlayerState.playerInput.newInput & PLAYER_INPUT_8) != 0)) { + ((gPlayerState.playerInput.newInput & INPUT_INTERACT) != 0)) { if (GetInventoryValue(ITEM_SWIM_BUTTERFLY) == 1) { this->speed = 0x1c0; } else { diff --git a/src/title.c b/src/title.c index 353604e3c..238e11d1a 100644 --- a/src/title.c +++ b/src/title.c @@ -89,7 +89,7 @@ static const SaveFile gDemoSave = { .stats = { .health = 40, .maxHealth = 40, - .itemButtons = { ITEM_SHIELD, ITEM_SMITH_SWORD }, + .equipped = { ITEM_SHIELD, ITEM_SMITH_SWORD }, .rupees = 5, }, .inventory = { diff --git a/src/ui.c b/src/ui.c index dcc5b5738..1bff0dae7 100644 --- a/src/ui.c +++ b/src/ui.c @@ -663,7 +663,7 @@ void ButtonUIElement_Action1(UIElement* element) { u32 sub_0801CC80(UIElement* element) { u8 type = element->type; u32 buttonId = (type ^ 3) != 0; - u32 itemId = gSave.stats.itemButtons[buttonId]; + u32 itemId = gSave.stats.equipped[buttonId]; if (ItemIsBottle(itemId)) { itemId = gSave.stats.bottles[itemId - ITEM_BOTTLE1]; }