fix fakematch in LinkHoldingItem_Action3

This commit is contained in:
theo3 2023-12-28 17:48:05 -08:00
parent b32553e490
commit 7c1c612c9b
21 changed files with 101 additions and 104 deletions

View File

@ -243,23 +243,21 @@ typedef struct {
} PlayerMacroEntry; } PlayerMacroEntry;
typedef enum { typedef enum {
PLAYER_INPUT_1 = 0x1, // A INPUT_USE_ITEM1 = 0x1, // A
PLAYER_INPUT_2 = 0x2, // B INPUT_USE_ITEM2 = 0x2, // B
PLAYER_INPUT_8 = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2 INPUT_INTERACT = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2
PLAYER_INPUT_10 = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2 INPUT_CANCEL = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2
PLAYER_INPUT_20 = 0x20, // R sub_0807953C INPUT_CONTEXT = 0x20, // R sub_0807953C
PLAYER_INPUT_40 = 0x40, // A CrenelBeanSprout_Action1 INPUT_40 = 0x40, // A CrenelBeanSprout_Action1
PLAYER_INPUT_80 = INPUT_ACTION =
0x80, // R sub_08073584, IsPreventedFromUsingItem, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2 0x80, // R sub_08073584, IsPreventedFromUsingItem, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2
PLAYER_INPUT_RIGHT = 0x100, INPUT_RIGHT = 0x100,
PLAYER_INPUT_LEFT = 0x200, INPUT_LEFT = 0x200,
PLAYER_INPUT_UP = 0x400, INPUT_UP = 0x400,
PLAYER_INPUT_DOWN = 0x800, INPUT_DOWN = 0x800,
PLAYER_INPUT_ANY_DIRECTION = 0xf00, INPUT_ANY_DIRECTION = 0xf00,
PLAYER_INPUT_1000 = 0x1000, // L, where is it set? sub_080782C0 INPUT_FUSE = 0x1000, // L, where is it set? sub_080782C0
PLAYER_INPUT_8000 = 0x8000, // R, IsTryingToPickupObject, sub_08076518 INPUT_LIFT_THROW = 0x8000, // R, IsTryingToPickupObject, sub_08076518
// TODO What is the result of u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000;?
} PlayerInputState; } PlayerInputState;
typedef struct { typedef struct {
@ -535,7 +533,7 @@ typedef struct {
/*0x09*/ u8 _hasAllFigurines; /*0x09*/ u8 _hasAllFigurines;
/*0x0a*/ u8 charm; /*0x0a*/ u8 charm;
/*0x0b*/ u8 picolyteType; /*0x0b*/ u8 picolyteType;
/*0x0c*/ u8 itemButtons[2]; /*0x0c*/ u8 equipped[2];
/*0x0e*/ u8 bottles[4]; /*0x0e*/ u8 bottles[4];
/*0x12*/ u8 effect; /*0x12*/ u8 effect;
/*0x13*/ u8 hasAllFigurines; /*0x13*/ u8 hasAllFigurines;

View File

@ -313,7 +313,7 @@ u32 UpdatePlayerCollision(void) {
return 0; return 0;
} }
gUnk_0200AF00.rActionInteractTile = R_ACTION_READ; 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; return 0;
} }
gPlayerState.mobility = 1; gPlayerState.mobility = 1;
@ -327,7 +327,7 @@ u32 UpdatePlayerCollision(void) {
return 0; return 0;
} }
gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN; 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; return 0;
} }
gPlayerState.mobility = 1; gPlayerState.mobility = 1;
@ -338,7 +338,7 @@ u32 UpdatePlayerCollision(void) {
return 0; return 0;
} }
gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN; 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; return 0;
} }
gPlayerState.mobility = 1; gPlayerState.mobility = 1;

View File

@ -138,40 +138,40 @@ void UpdatePlayerInput(void) {
gPlayerState.playerInput.heldInput = state; gPlayerState.playerInput.heldInput = state;
gPlayerState.playerInput.newInput = state & prevState; gPlayerState.playerInput.newInput = state & prevState;
// Calculate the direction from the currently held input. // 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 ConvInputToState(u32 keys) {
u32 result; u32 result;
if (keys & L_BUTTON) { if (keys & L_BUTTON) {
result = 0x1000; result = INPUT_FUSE;
} else { } else {
result = 0; result = 0;
} }
if (keys & R_BUTTON) { if (keys & R_BUTTON) {
result |= PLAYER_INPUT_20; result |= INPUT_CONTEXT;
result |= PLAYER_INPUT_8000; result |= INPUT_LIFT_THROW;
result |= PLAYER_INPUT_80; result |= INPUT_ACTION;
} }
if (keys & A_BUTTON) { if (keys & A_BUTTON) {
result |= PLAYER_INPUT_8; result |= INPUT_INTERACT;
result |= PLAYER_INPUT_40 | PLAYER_INPUT_1; result |= INPUT_40 | INPUT_USE_ITEM1;
} }
if (keys & B_BUTTON) { if (keys & B_BUTTON) {
result |= PLAYER_INPUT_10; result |= INPUT_CANCEL;
result |= PLAYER_INPUT_2; result |= INPUT_USE_ITEM2;
} }
if (keys & DPAD_RIGHT) { if (keys & DPAD_RIGHT) {
result |= PLAYER_INPUT_RIGHT; result |= INPUT_RIGHT;
} }
if (keys & DPAD_LEFT) { if (keys & DPAD_LEFT) {
result |= PLAYER_INPUT_LEFT; result |= INPUT_LEFT;
} }
if (keys & DPAD_UP) { if (keys & DPAD_UP) {
result |= PLAYER_INPUT_UP; result |= INPUT_UP;
} }
if (keys & DPAD_DOWN) { if (keys & DPAD_DOWN) {
result |= PLAYER_INPUT_DOWN; result |= INPUT_DOWN;
} }
return result; return result;
} }

View File

@ -260,12 +260,12 @@ void sub_080281A0(LikeLikeEntity* this) {
bool32 LikeLike_StealItem(u32 item) { bool32 LikeLike_StealItem(u32 item) {
bool32 ret = FALSE; bool32 ret = FALSE;
if (GetInventoryValue(item) == 1) { if (GetInventoryValue(item) == 1) {
if (ItemIsShield(gSave.stats.itemButtons[SLOT_A])) { if (ItemIsShield(gSave.stats.equipped[SLOT_A])) {
gSave.stats.itemButtons[SLOT_A] = ITEM_NONE; gSave.stats.equipped[SLOT_A] = ITEM_NONE;
} }
if (ItemIsShield(gSave.stats.itemButtons[SLOT_B])) { if (ItemIsShield(gSave.stats.equipped[SLOT_B])) {
gSave.stats.itemButtons[SLOT_B] = ITEM_NONE; gSave.stats.equipped[SLOT_B] = ITEM_NONE;
} }
SetInventoryValue(item, 0); SetInventoryValue(item, 0);

View File

@ -107,10 +107,10 @@ void sub_08076964(ItemBehavior* this, u32 index) {
SetItemAnim(this, ANIM_DASH); SetItemAnim(this, ANIM_DASH);
entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD); entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD);
if (entity != NULL) { if (entity != NULL) {
if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) { if (ItemIsSword(gSave.stats.equipped[SLOT_A]) != 0) {
uVar3 = gSave.stats.itemButtons[SLOT_A]; uVar3 = gSave.stats.equipped[SLOT_A];
} else { } else {
uVar3 = gSave.stats.itemButtons[SLOT_B]; uVar3 = gSave.stats.equipped[SLOT_B];
} }
entity->field_0x68.HALF.LO = uVar3; entity->field_0x68.HALF.LO = uVar3;
return; return;

View File

@ -145,7 +145,7 @@ void sub_080762D8(ItemBehavior* this, u32 index) {
if (gPlayerEntity.iframes < 9 && gPlayerEntity.knockbackDuration == 0) { if (gPlayerEntity.iframes < 9 && gPlayerEntity.knockbackDuration == 0) {
if (this->field_0x18 != NULL) { if (this->field_0x18 != NULL) {
if (this->field_0x18->action == 2 && this->field_0x18->subAction == 5) { 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; this->field_0x18->subAction = 6;
PlayerCancelHoldItem(this, index); PlayerCancelHoldItem(this, index);
return; return;
@ -263,7 +263,7 @@ void sub_08076518(ItemBehavior* this, u32 index) {
if (gPlayerEntity.knockbackDuration != 0) { if (gPlayerEntity.knockbackDuration != 0) {
PlayerCancelHoldItem(this, index); PlayerCancelHoldItem(this, index);
} else { } 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); sub_0806F948(&gPlayerEntity);
gPlayerState.heldObject = 5; gPlayerState.heldObject = 5;
this->field_0x18->subAction = 2; this->field_0x18->subAction = 2;

View File

@ -255,9 +255,9 @@ void ModArrows(s32 arrows) {
EquipSlot IsItemEquipped(u32 itemId) { EquipSlot IsItemEquipped(u32 itemId) {
EquipSlot equipSlot; EquipSlot equipSlot;
if (itemId == gSave.stats.itemButtons[SLOT_A]) { if (itemId == gSave.stats.equipped[SLOT_A]) {
equipSlot = EQUIP_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; equipSlot = EQUIP_SLOT_B;
} else { } else {
equipSlot = EQUIP_SLOT_NONE; equipSlot = EQUIP_SLOT_NONE;
@ -273,17 +273,17 @@ void PutItemOnSlot(u32 itemId) {
} }
if (itemId2 - 1 < 0x1f) { if (itemId2 - 1 < 0x1f) {
equipSlot = EQUIP_SLOT_NONE; equipSlot = EQUIP_SLOT_NONE;
if (gSave.stats.itemButtons[SLOT_A] == ITEM_NONE) { if (gSave.stats.equipped[SLOT_A] == ITEM_NONE) {
equipSlot = EQUIP_SLOT_A; 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; equipSlot = EQUIP_SLOT_B;
} }
if (equipSlot == EQUIP_SLOT_NONE) { if (equipSlot == EQUIP_SLOT_NONE) {
u32 temp = gItemMetaData[itemId2].menuSlot; 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; equipSlot = EQUIP_SLOT_A;
} else { } else {
if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_B]].menuSlot) { if (temp == gItemMetaData[gSave.stats.equipped[SLOT_B]].menuSlot) {
equipSlot = EQUIP_SLOT_B; equipSlot = EQUIP_SLOT_B;
} }
} }
@ -302,13 +302,13 @@ void ForceEquipItem(u32 itemId, u32 equipSlot) {
if ((itemId - 1 < 0x1f) && (equipSlot < EQUIP_SLOT_NONE)) { if ((itemId - 1 < 0x1f) && (equipSlot < EQUIP_SLOT_NONE)) {
otherItemSlot = equipSlot == EQUIP_SLOT_A; otherItemSlot = equipSlot == EQUIP_SLOT_A;
replacedItem = gSave.stats.itemButtons[equipSlot]; replacedItem = gSave.stats.equipped[equipSlot];
otherItem = gSave.stats.itemButtons[otherItemSlot]; otherItem = gSave.stats.equipped[otherItemSlot];
if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemId].menuSlot) { if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemId].menuSlot) {
otherItem = replacedItem; otherItem = replacedItem;
} }
gSave.stats.itemButtons[equipSlot] = itemId; gSave.stats.equipped[equipSlot] = itemId;
gSave.stats.itemButtons[otherItemSlot] = otherItem; gSave.stats.equipped[otherItemSlot] = otherItem;
gUnk_0200AF00.unk_13 = 0x7f; gUnk_0200AF00.unk_13 = 0x7f;
gUnk_0200AF00.unk_14 = 0x7f; gUnk_0200AF00.unk_14 = 0x7f;
} }

View File

@ -364,7 +364,7 @@ void MiscManager_TypeB(MiscManager* this) {
bool32 sub_080593CC(MiscManager* this) { bool32 sub_080593CC(MiscManager* this) {
if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 && 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 EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
} }
return FALSE; return FALSE;

View File

@ -529,14 +529,14 @@ void PauseMenu_ItemMenu_Draw(void) {
gOamCmd._8 = 0x800; gOamCmd._8 = 0x800;
DrawDirect(sub_080A5384_draw_constant0, 0x22); 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) { if (i < MENU_SLOT_COUNT) {
entry = &gItemMenuTable[i]; entry = &gItemMenuTable[i];
gOamCmd.x = entry->x; gOamCmd.x = entry->x;
gOamCmd.y = entry->y; gOamCmd.y = entry->y;
DrawDirect(sub_080A5384_draw_constant0, 3); 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) { if (i < MENU_SLOT_COUNT) {
entry = &gItemMenuTable[i]; entry = &gItemMenuTable[i];
gOamCmd.x = entry->x; gOamCmd.x = entry->x;

View File

@ -434,7 +434,7 @@ void sub_0806D5D4(void) {
InitBiggoronTimer(); InitBiggoronTimer();
equipSlot = IsItemEquipped(ITEM_SHIELD); equipSlot = IsItemEquipped(ITEM_SHIELD);
if (equipSlot != EQUIP_SLOT_NONE) { if (equipSlot != EQUIP_SLOT_NONE) {
gSave.stats.itemButtons[equipSlot] = ITEM_NONE; gSave.stats.equipped[equipSlot] = ITEM_NONE;
} }
SetInventoryValue(ITEM_SHIELD, 0); SetInventoryValue(ITEM_SHIELD, 0);
} }

View File

@ -339,10 +339,10 @@ void BladeBrothers_StartPlayerDemonstration(Entity* this, ScriptExecutionContext
} }
void sub_08068BB4(BladeBrothersEntity* this) { void sub_08068BB4(BladeBrothersEntity* this) {
u32 item = gSave.stats.itemButtons[SLOT_A]; u32 item = gSave.stats.equipped[SLOT_A];
this->itemSlotA = item; this->itemSlotA = item;
item = gSave.stats.itemButtons[SLOT_B]; item = gSave.stats.equipped[SLOT_B];
this->itemSlotB = item; this->itemSlotB = item;
} }

View File

@ -186,8 +186,8 @@ Item NPC4E_GetItemWithSwordUpgraded(Item itemId) {
} }
void NPC4E_SaveEquippedItems(NPC4EEntity* this) { void NPC4E_SaveEquippedItems(NPC4EEntity* this) {
this->unk_68 = gSave.stats.itemButtons[SLOT_A]; this->unk_68 = gSave.stats.equipped[SLOT_A];
this->unk_69 = gSave.stats.itemButtons[SLOT_B]; this->unk_69 = gSave.stats.equipped[SLOT_B];
} }
void NPC4E_RestoreEquippedItems(NPC4EEntity* this) { void NPC4E_RestoreEquippedItems(NPC4EEntity* this) {

View File

@ -179,7 +179,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
RestorePrevTileEntity(0xdc, super->collisionLayer); RestorePrevTileEntity(0xdc, super->collisionLayer);
sub_08096A78(this); sub_08096A78(this);
} }
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) { if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) {
return; return;
} }
if (gUnk_0200AF00.rActionPlayerState != R_ACTION_THROW) { if (gUnk_0200AF00.rActionPlayerState != R_ACTION_THROW) {

View File

@ -184,7 +184,7 @@ void sub_0808692C(HouseDoorExteriorEntity* this) {
static u8 sub_08086954(HouseDoorExteriorEntity* this) { static u8 sub_08086954(HouseDoorExteriorEntity* this) {
if (sub_0800445C(super)) { if (sub_0800445C(super)) {
if (GetAnimationStateInRectRadius(super, 6, 20) >= 0 && gPlayerEntity.animationState == 0 && 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--; super->timer--;
} }
} else { } else {

View File

@ -118,8 +118,8 @@ void ItemForSale_Action2(ItemForSaleEntity* this) {
ptr = sub_080784E4(); ptr = sub_080784E4();
if (((*(int*)(ptr + 8) == 0) || ((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.rActionPlayerState = R_ACTION_SPEAK, if (((*(int*)(ptr + 8) == 0) || ((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.rActionPlayerState = R_ACTION_SPEAK,
(gPlayerState.playerInput.newInput & (gPlayerState.playerInput.newInput &
(PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) && (INPUT_ACTION | INPUT_INTERACT)) == 0)))) &&
((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) { ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_CANCEL | INPUT_INTERACT)) != 0)) {
sub_080819B4(this); sub_080819B4(this);
} }
} }

View File

@ -123,8 +123,8 @@ void LinkHoldingItem_Action2(LinkHoldingItemEntity* this) {
} }
void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) { void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) {
u32 tmp; u32 bottle_no;
if ((super->parent)->action == 8) { if (super->parent->action == PLAYER_ITEMGET) {
return; return;
} }
switch (super->timer) { switch (super->timer) {
@ -149,9 +149,9 @@ void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) {
ModHealth(160); ModHealth(160);
break; break;
case 3: case 3:
tmp = GetBottleContaining(super->type); bottle_no = GetBottleContaining(super->type);
if (tmp != 0) { if (bottle_no != 0) {
gSave.stats.itemButtons[tmp + 1] = ITEM_BOTTLE_EMPTY; gSave.stats.bottles[bottle_no - 1] = ITEM_BOTTLE_EMPTY;
} else { } else {
SetInventoryValue(super->type, ITEM_GREEN_SWORD); SetInventoryValue(super->type, ITEM_GREEN_SWORD);
} }

View File

@ -2750,7 +2750,7 @@ static void sub_08073504(Entity* this) {
static void sub_08073584(Entity* this) { static void sub_08073584(Entity* this) {
u32 state, dir, idx; 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.flags & PL_PARACHUTE) == 0) {
gPlayerState.jump_status |= 0x40; gPlayerState.jump_status |= 0x40;
PlayerSetNormalAndCollide(); PlayerSetNormalAndCollide();
@ -3447,10 +3447,10 @@ void SurfaceAction_14(Entity* this) {
void SurfaceAction_CloneTile(Entity* this) { void SurfaceAction_CloneTile(Entity* this) {
if (gPlayerState.chargeState.action == 4) { if (gPlayerState.chargeState.action == 4) {
u32 item, n, i; u32 item, n, i;
if (ItemIsSword(gSave.stats.itemButtons[SLOT_A])) { if (ItemIsSword(gSave.stats.equipped[SLOT_A])) {
item = gSave.stats.itemButtons[SLOT_A]; item = gSave.stats.equipped[SLOT_A];
} else { } else {
item = gSave.stats.itemButtons[SLOT_B]; item = gSave.stats.equipped[SLOT_B];
} }
switch (item) { switch (item) {
case 1: case 1:
@ -3523,8 +3523,7 @@ void SurfaceAction_ShallowWater(Entity* this) {
this->spritePriority.b0 = 4; this->spritePriority.b0 = 4;
gPlayerState.swim_state = 0; gPlayerState.swim_state = 0;
} }
if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_ANY_DIRECTION) || if ((gPlayerState.playerInput.newInput & INPUT_ANY_DIRECTION) || gPlayerState.surfacePositionSameTimer == 1)
gPlayerState.surfacePositionSameTimer == 1)
SoundReq(SFX_WATER_WALK); SoundReq(SFX_WATER_WALK);
} }
} }
@ -3567,7 +3566,7 @@ void SurfaceAction_Swamp(Entity* this) {
CreateObjectWithParent(this, OBJECT_70, 0, 0); CreateObjectWithParent(this, OBJECT_70, 0, 0);
CreateFx(this, FX_GREEN_SPLASH, 0); CreateFx(this, FX_GREEN_SPLASH, 0);
SoundReq(SFX_161); 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); SoundReq(SFX_161);
} else if ((gRoomTransition.frameCount & 0xf) == 0) { } else if ((gRoomTransition.frameCount & 0xf) == 0) {
SoundReq(SFX_161); SoundReq(SFX_161);
@ -3723,7 +3722,7 @@ void SurfaceAction_Dust(Entity* this) {
if (!sub_080741C4()) { if (!sub_080741C4()) {
gPlayerState.speed_modifier -= 128; gPlayerState.speed_modifier -= 128;
if (gPlayerState.surfacePositionSameTimer == 1 || 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) if (gPlayerState.floor_type == SURFACE_DUST)
CreateObjectWithParent(this, DIRT_PARTICLE, 1, 0); CreateObjectWithParent(this, DIRT_PARTICLE, 1, 0);
else else

View File

@ -113,10 +113,10 @@ void PlayerItemBomb_Action1(PlayerItemBombEntity* this) {
} }
switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) { switch (IsItemEquipped(ITEM_REMOTE_BOMBS)) {
case EQUIP_SLOT_A: case EQUIP_SLOT_A:
input = PLAYER_INPUT_1; input = INPUT_USE_ITEM1;
break; break;
case EQUIP_SLOT_B: case EQUIP_SLOT_B:
input = PLAYER_INPUT_2; input = INPUT_USE_ITEM2;
break; break;
case EQUIP_SLOT_NONE: case EQUIP_SLOT_NONE:
input = 0; input = 0;

View File

@ -175,8 +175,8 @@ void UpdateActiveItems(PlayerEntity* this) {
gPlayerState.attack_status &= 0xf; gPlayerState.attack_status &= 0xf;
if (((gPlayerState.field_0x7 | gPlayerState.jump_status) & 0x80) == 0 && (gPlayerState.jump_status & 0x40) == 0 && if (((gPlayerState.field_0x7 | gPlayerState.jump_status) & 0x80) == 0 && (gPlayerState.jump_status & 0x40) == 0 &&
gPlayerState.swim_state == 0 && IsAbleToUseItem(this) && !IsPreventedFromUsingItem()) { gPlayerState.swim_state == 0 && IsAbleToUseItem(this) && !IsPreventedFromUsingItem()) {
CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_A], PLAYER_INPUT_1, FALSE); CreateItemIfInputMatches(gSave.stats.equipped[SLOT_A], INPUT_USE_ITEM1, FALSE);
CreateItemIfInputMatches(gSave.stats.itemButtons[SLOT_B], PLAYER_INPUT_2, FALSE); CreateItemIfInputMatches(gSave.stats.equipped[SLOT_B], INPUT_USE_ITEM2, FALSE);
IsTryingToPickupObject(); IsTryingToPickupObject();
} }
@ -189,9 +189,9 @@ void UpdateActiveItems(PlayerEntity* this) {
void CreateItemEquippedAtSlot(EquipSlot equipSlot) { void CreateItemEquippedAtSlot(EquipSlot equipSlot) {
if (equipSlot == EQUIP_SLOT_A) { 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 { } 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) { bool32 IsPreventedFromUsingItem(void) {
if ((gPlayerState.playerInput.newInput & PLAYER_INPUT_80) != 0) { if ((gPlayerState.playerInput.newInput & INPUT_ACTION) != 0) {
if ((gPlayerState.flags & PL_CLONING) != 0) { if ((gPlayerState.flags & PL_CLONING) != 0) {
gPlayerState.chargeState.action = 1; gPlayerState.chargeState.action = 1;
DeleteClones(); DeleteClones();
@ -233,7 +233,7 @@ bool32 IsPreventedFromUsingItem(void) {
default: default:
if ((((gUnk_0200AF00.rActionInteractObject == R_ACTION_ROLL) && (gPlayerState.field_0x1c == 0)) && if ((((gUnk_0200AF00.rActionInteractObject == R_ACTION_ROLL) && (gPlayerState.field_0x1c == 0)) &&
(gPlayerState.floor_type != SURFACE_SWAMP)) && (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.flags & (PL_BURNING | PL_ROLLING)) == 0)) &&
((gPlayerState.jump_status == 0 && (gPlayerState.attack_status == 0)))))) { ((gPlayerState.jump_status == 0 && (gPlayerState.attack_status == 0)))))) {
gPlayerState.queued_action = PLAYER_ROLL; gPlayerState.queued_action = PLAYER_ROLL;
@ -274,9 +274,9 @@ bool32 IsTryingToPickupObject(void) {
if (!((((gPlayerState.flags & (PL_USE_PORTAL | PL_MINISH | PL_ROLLING)) == 0) && if (!((((gPlayerState.flags & (PL_USE_PORTAL | PL_MINISH | PL_ROLLING)) == 0) &&
(((gNewPlayerEntity.unk_79 != 0 || (gPlayerState.heldObject != 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 & (((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; return FALSE;
} }
item = CreateItem(ITEM_TRY_PICKUP_OBJECT); item = CreateItem(ITEM_TRY_PICKUP_OBJECT);
@ -631,10 +631,10 @@ bool32 IsItemActiveByInput(ItemBehavior* this, PlayerInputState input) {
u32 val; u32 val;
Stats* stats = &gSave.stats; Stats* stats = &gSave.stats;
u32 id = this->behaviorId; u32 id = this->behaviorId;
if (stats->itemButtons[SLOT_A] == id) { if (stats->equipped[SLOT_A] == id) {
val = PLAYER_INPUT_1; val = INPUT_USE_ITEM1;
} else if (stats->itemButtons[SLOT_B] == id) { } else if (stats->equipped[SLOT_B] == id) {
val = PLAYER_INPUT_2; val = INPUT_USE_ITEM2;
} else { } else {
val = 0; val = 0;
} }
@ -901,10 +901,10 @@ bool32 sub_08077FEC(u32 action) {
bool32 sub_08078008(ChargeState* state) { bool32 sub_08078008(ChargeState* state) {
Item swordType; Item swordType;
if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != ITEM_NONE) { if (ItemIsSword(gSave.stats.equipped[SLOT_A]) != ITEM_NONE) {
swordType = gSave.stats.itemButtons[SLOT_A]; swordType = gSave.stats.equipped[SLOT_A];
} else if (ItemIsSword(gSave.stats.itemButtons[SLOT_B]) != ITEM_NONE) { } else if (ItemIsSword(gSave.stats.equipped[SLOT_B]) != ITEM_NONE) {
swordType = gSave.stats.itemButtons[SLOT_B]; swordType = gSave.stats.equipped[SLOT_B];
} else { } else {
swordType = ITEM_NONE; swordType = ITEM_NONE;
} }
@ -1110,7 +1110,7 @@ bool32 sub_080782C0(void) {
return FALSE; return FALSE;
} }
} }
if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && if (((gPlayerState.playerInput.newInput & INPUT_FUSE) != 0) &&
((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) < 100)) { ((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) < 100)) {
AddKinstoneToBag(KINSTONE_NONE); AddKinstoneToBag(KINSTONE_NONE);
if (gSave.kinstones.amounts[0] != 0) { if (gSave.kinstones.amounts[0] != 0) {
@ -1123,7 +1123,7 @@ bool32 sub_080782C0(void) {
ForceSetPlayerState(PL_STATE_TALKEZLO); ForceSetPlayerState(PL_STATE_TALKEZLO);
return TRUE; return TRUE;
} }
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) {
return FALSE; return FALSE;
} }
switch (gPossibleInteraction.currentObject->type) { switch (gPossibleInteraction.currentObject->type) {
@ -1973,7 +1973,7 @@ void sub_08079520(Entity* this) {
} }
u32 sub_0807953C(void) { 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; return gPlayerState.playerInput.newInput & tmp;
} }
@ -2549,10 +2549,10 @@ void DeleteClones(void) {
} }
bool32 HasSwordEquipped(void) { bool32 HasSwordEquipped(void) {
if (ItemIsSword((u32)gSave.stats.itemButtons[SLOT_A]) != 0) { if (ItemIsSword((u32)gSave.stats.equipped[SLOT_A]) != 0) {
return TRUE; return TRUE;
} else { } 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) { bool32 ToggleDiving(Entity* this) {
if (gPlayerState.playerInput.newInput & PLAYER_INPUT_10) { if (gPlayerState.playerInput.newInput & INPUT_CANCEL) {
gPlayerState.swim_state ^= 0x80; gPlayerState.swim_state ^= 0x80;
if (gPlayerState.swim_state & 0x80) { if (gPlayerState.swim_state & 0x80) {
gPlayerState.remainingDiveTime = 0x78; gPlayerState.remainingDiveTime = 0x78;
@ -3026,7 +3026,7 @@ bool32 ToggleDiving(Entity* this) {
void PlayerUpdateSwimming(Entity* this) { void PlayerUpdateSwimming(Entity* this) {
if ((((this->action != 0x17) || (gPlayerState.field_0xa == 0)) && (gRoomControls.reload_flags == 0)) && 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) { if (GetInventoryValue(ITEM_SWIM_BUTTERFLY) == 1) {
this->speed = 0x1c0; this->speed = 0x1c0;
} else { } else {

View File

@ -89,7 +89,7 @@ static const SaveFile gDemoSave = {
.stats = { .stats = {
.health = 40, .health = 40,
.maxHealth = 40, .maxHealth = 40,
.itemButtons = { ITEM_SHIELD, ITEM_SMITH_SWORD }, .equipped = { ITEM_SHIELD, ITEM_SMITH_SWORD },
.rupees = 5, .rupees = 5,
}, },
.inventory = { .inventory = {

View File

@ -663,7 +663,7 @@ void ButtonUIElement_Action1(UIElement* element) {
u32 sub_0801CC80(UIElement* element) { u32 sub_0801CC80(UIElement* element) {
u8 type = element->type; u8 type = element->type;
u32 buttonId = (type ^ 3) != 0; u32 buttonId = (type ^ 3) != 0;
u32 itemId = gSave.stats.itemButtons[buttonId]; u32 itemId = gSave.stats.equipped[buttonId];
if (ItemIsBottle(itemId)) { if (ItemIsBottle(itemId)) {
itemId = gSave.stats.bottles[itemId - ITEM_BOTTLE1]; itemId = gSave.stats.bottles[itemId - ITEM_BOTTLE1];
} }