Skip to content

Commit 41b8076

Browse files
committed
fix fakematch in LinkHoldingItem_Action3
1 parent b32553e commit 41b8076

20 files changed

+102
-105
lines changed

include/player.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -243,23 +243,21 @@ typedef struct {
243243
} PlayerMacroEntry;
244244

245245
typedef enum {
246-
PLAYER_INPUT_1 = 0x1, // A
247-
PLAYER_INPUT_2 = 0x2, // B
248-
PLAYER_INPUT_8 = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2
249-
PLAYER_INPUT_10 = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2
250-
PLAYER_INPUT_20 = 0x20, // R sub_0807953C
251-
PLAYER_INPUT_40 = 0x40, // A CrenelBeanSprout_Action1
252-
PLAYER_INPUT_80 =
246+
INPUT_USE_ITEM1 = 0x1, // A
247+
INPUT_USE_ITEM2 = 0x2, // B
248+
INPUT_INTERACT = 0x8, // A sub_080782C0, sub_0807953C, PlayerUpdateSwimming, sub_08076518. ItemForSale_Action2
249+
INPUT_CANCEL = 0x10, // B sub_0807953C, ToggleDiving, sub_08076518, ItemForSale_Action2
250+
INPUT_CONTEXT = 0x20, // R sub_0807953C
251+
INPUT_40 = 0x40, // A CrenelBeanSprout_Action1
252+
INPUT_ACTION =
253253
0x80, // R sub_08073584, IsPreventedFromUsingItem, sub_080782C0, CrenelBeanSprout_Action1, ItemForSale_Action2
254-
PLAYER_INPUT_RIGHT = 0x100,
255-
PLAYER_INPUT_LEFT = 0x200,
256-
PLAYER_INPUT_UP = 0x400,
257-
PLAYER_INPUT_DOWN = 0x800,
258-
PLAYER_INPUT_ANY_DIRECTION = 0xf00,
259-
PLAYER_INPUT_1000 = 0x1000, // L, where is it set? sub_080782C0
260-
PLAYER_INPUT_8000 = 0x8000, // R, IsTryingToPickupObject, sub_08076518
261-
262-
// TODO What is the result of u32 result = (s32) - (keys & 0x200) >> 0x1f & 0x1000;?
254+
INPUT_RIGHT = 0x100,
255+
INPUT_LEFT = 0x200,
256+
INPUT_UP = 0x400,
257+
INPUT_DOWN = 0x800,
258+
INPUT_ANY_DIRECTION = 0xf00,
259+
INPUT_FUSE = 0x1000, // L, where is it set? sub_080782C0
260+
INPUT_LIFT_THROW = 0x8000, // R, IsTryingToPickupObject, sub_08076518
263261
} PlayerInputState;
264262

265263
typedef struct {
@@ -505,7 +503,7 @@ typedef struct {
505503
/*0x80*/ u16 speed_modifier;
506504
/*0x82*/ u8 field_0x82;
507505
/*0x83*/ u8 playerPalette;
508-
/*0x84*/ Entity* lilypad; /**< Last lilypad the player was standing on? */
506+
/*0x84*/ Entity* lilypad; /**< Last lilypad the player was standing on? */
509507
/*0x88*/ u8 field_0x88;
510508
/*0x89*/ u8 remainingDiveTime; /**< Frames that the player can continue to dive. */
511509
/*0x8a*/ u8 field_0x8a;
@@ -535,7 +533,7 @@ typedef struct {
535533
/*0x09*/ u8 _hasAllFigurines;
536534
/*0x0a*/ u8 charm;
537535
/*0x0b*/ u8 picolyteType;
538-
/*0x0c*/ u8 itemButtons[2];
536+
/*0x0c*/ u8 equipped[2];
539537
/*0x0e*/ u8 bottles[4];
540538
/*0x12*/ u8 effect;
541539
/*0x13*/ u8 hasAllFigurines;
@@ -566,7 +564,7 @@ typedef struct {
566564
/*0xc*/ u8 playerAnimIndex; /**< Stored animIndex of the player entity. */
567565
/*0xd*/ u8 playerFrameDuration; /**< Stored frameDuration of the player entity. */
568566
/*0xe*/ u8
569-
playerFrame; /**< Stored frame of the player entity. But also used for general purpose in item behaviours? */
567+
playerFrame; /**< Stored frame of the player entity. But also used for general purpose in item behaviours? */
570568
/*0xf*/ u8
571569
animPriority; /**< In sub_08079064 the animIndex of the ItemBehavior with the max animPriority is selected. */
572570
/*0x10*/ u16 animIndex;

src/beanstalkSubtask.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ u32 UpdatePlayerCollision(void) {
313313
return 0;
314314
}
315315
gUnk_0200AF00.rActionInteractTile = R_ACTION_READ;
316-
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
316+
if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) {
317317
return 0;
318318
}
319319
gPlayerState.mobility = 1;
@@ -327,7 +327,7 @@ u32 UpdatePlayerCollision(void) {
327327
return 0;
328328
}
329329
gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN;
330-
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
330+
if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) {
331331
return 0;
332332
}
333333
gPlayerState.mobility = 1;
@@ -338,7 +338,7 @@ u32 UpdatePlayerCollision(void) {
338338
return 0;
339339
}
340340
gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN;
341-
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
341+
if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_INTERACT)) == 0) {
342342
return 0;
343343
}
344344
gPlayerState.mobility = 1;

src/code_0805EC04.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,40 +138,40 @@ void UpdatePlayerInput(void) {
138138
gPlayerState.playerInput.heldInput = state;
139139
gPlayerState.playerInput.newInput = state & prevState;
140140
// Calculate the direction from the currently held input.
141-
gPlayerState.direction = gUnk_08109202[(state & PLAYER_INPUT_ANY_DIRECTION) >> 8];
141+
gPlayerState.direction = gUnk_08109202[(state & INPUT_ANY_DIRECTION) >> 8];
142142
}
143143

144144
u32 ConvInputToState(u32 keys) {
145145
u32 result;
146146
if (keys & L_BUTTON) {
147-
result = 0x1000;
147+
result = INPUT_FUSE;
148148
} else {
149149
result = 0;
150150
}
151151
if (keys & R_BUTTON) {
152-
result |= PLAYER_INPUT_20;
153-
result |= PLAYER_INPUT_8000;
154-
result |= PLAYER_INPUT_80;
152+
result |= INPUT_CONTEXT;
153+
result |= INPUT_LIFT_THROW;
154+
result |= INPUT_ACTION;
155155
}
156156
if (keys & A_BUTTON) {
157-
result |= PLAYER_INPUT_8;
158-
result |= PLAYER_INPUT_40 | PLAYER_INPUT_1;
157+
result |= INPUT_INTERACT;
158+
result |= INPUT_40 | INPUT_USE_ITEM1;
159159
}
160160
if (keys & B_BUTTON) {
161-
result |= PLAYER_INPUT_10;
162-
result |= PLAYER_INPUT_2;
161+
result |= INPUT_CANCEL;
162+
result |= INPUT_USE_ITEM2;
163163
}
164164
if (keys & DPAD_RIGHT) {
165-
result |= PLAYER_INPUT_RIGHT;
165+
result |= INPUT_RIGHT;
166166
}
167167
if (keys & DPAD_LEFT) {
168-
result |= PLAYER_INPUT_LEFT;
168+
result |= INPUT_LEFT;
169169
}
170170
if (keys & DPAD_UP) {
171-
result |= PLAYER_INPUT_UP;
171+
result |= INPUT_UP;
172172
}
173173
if (keys & DPAD_DOWN) {
174-
result |= PLAYER_INPUT_DOWN;
174+
result |= INPUT_DOWN;
175175
}
176176
return result;
177177
}

src/enemy/likeLike.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,12 @@ void sub_080281A0(LikeLikeEntity* this) {
260260
bool32 LikeLike_StealItem(u32 item) {
261261
bool32 ret = FALSE;
262262
if (GetInventoryValue(item) == 1) {
263-
if (ItemIsShield(gSave.stats.itemButtons[SLOT_A])) {
264-
gSave.stats.itemButtons[SLOT_A] = ITEM_NONE;
263+
if (ItemIsShield(gSave.stats.equipped[SLOT_A])) {
264+
gSave.stats.equipped[SLOT_A] = ITEM_NONE;
265265
}
266266

267-
if (ItemIsShield(gSave.stats.itemButtons[SLOT_B])) {
268-
gSave.stats.itemButtons[SLOT_B] = ITEM_NONE;
267+
if (ItemIsShield(gSave.stats.equipped[SLOT_B])) {
268+
gSave.stats.equipped[SLOT_B] = ITEM_NONE;
269269
}
270270

271271
SetInventoryValue(item, 0);

src/item/itemPegasusBoots.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ void sub_08076964(ItemBehavior* this, u32 index) {
107107
SetItemAnim(this, ANIM_DASH);
108108
entity = CreatePlayerItemWithParent(this, PLAYER_ITEM_DASH_SWORD);
109109
if (entity != NULL) {
110-
if (ItemIsSword(gSave.stats.itemButtons[SLOT_A]) != 0) {
111-
uVar3 = gSave.stats.itemButtons[SLOT_A];
110+
if (ItemIsSword(gSave.stats.equipped[SLOT_A]) != 0) {
111+
uVar3 = gSave.stats.equipped[SLOT_A];
112112
} else {
113-
uVar3 = gSave.stats.itemButtons[SLOT_B];
113+
uVar3 = gSave.stats.equipped[SLOT_B];
114114
}
115115
entity->field_0x68.HALF.LO = uVar3;
116116
return;

src/item/itemTryPickupObject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void sub_080762D8(ItemBehavior* this, u32 index) {
145145
if (gPlayerEntity.iframes < 9 && gPlayerEntity.knockbackDuration == 0) {
146146
if (this->field_0x18 != NULL) {
147147
if (this->field_0x18->action == 2 && this->field_0x18->subAction == 5) {
148-
if (!(gPlayerState.playerInput.heldInput & PLAYER_INPUT_80)) { // Pressing R
148+
if (!(gPlayerState.playerInput.heldInput & INPUT_ACTION)) { // Pressing R
149149
this->field_0x18->subAction = 6;
150150
PlayerCancelHoldItem(this, index);
151151
return;
@@ -263,7 +263,7 @@ void sub_08076518(ItemBehavior* this, u32 index) {
263263
if (gPlayerEntity.knockbackDuration != 0) {
264264
PlayerCancelHoldItem(this, index);
265265
} else {
266-
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_8000 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0) {
266+
if ((gPlayerState.playerInput.newInput & (INPUT_LIFT_THROW | INPUT_CANCEL | INPUT_INTERACT)) != 0) {
267267
sub_0806F948(&gPlayerEntity);
268268
gPlayerState.heldObject = 5;
269269
this->field_0x18->subAction = 2;

src/itemUtils.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ void ModArrows(s32 arrows) {
255255
EquipSlot IsItemEquipped(u32 itemId) {
256256
EquipSlot equipSlot;
257257

258-
if (itemId == gSave.stats.itemButtons[SLOT_A]) {
258+
if (itemId == gSave.stats.equipped[SLOT_A]) {
259259
equipSlot = EQUIP_SLOT_A;
260-
} else if (itemId == gSave.stats.itemButtons[SLOT_B]) {
260+
} else if (itemId == gSave.stats.equipped[SLOT_B]) {
261261
equipSlot = EQUIP_SLOT_B;
262262
} else {
263263
equipSlot = EQUIP_SLOT_NONE;
@@ -273,17 +273,17 @@ void PutItemOnSlot(u32 itemId) {
273273
}
274274
if (itemId2 - 1 < 0x1f) {
275275
equipSlot = EQUIP_SLOT_NONE;
276-
if (gSave.stats.itemButtons[SLOT_A] == ITEM_NONE) {
276+
if (gSave.stats.equipped[SLOT_A] == ITEM_NONE) {
277277
equipSlot = EQUIP_SLOT_A;
278-
} else if (gSave.stats.itemButtons[SLOT_B] == ITEM_NONE) {
278+
} else if (gSave.stats.equipped[SLOT_B] == ITEM_NONE) {
279279
equipSlot = EQUIP_SLOT_B;
280280
}
281281
if (equipSlot == EQUIP_SLOT_NONE) {
282282
u32 temp = gItemMetaData[itemId2].menuSlot;
283-
if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_A]].menuSlot) {
283+
if (temp == gItemMetaData[gSave.stats.equipped[SLOT_A]].menuSlot) {
284284
equipSlot = EQUIP_SLOT_A;
285285
} else {
286-
if (temp == gItemMetaData[gSave.stats.itemButtons[SLOT_B]].menuSlot) {
286+
if (temp == gItemMetaData[gSave.stats.equipped[SLOT_B]].menuSlot) {
287287
equipSlot = EQUIP_SLOT_B;
288288
}
289289
}
@@ -302,13 +302,13 @@ void ForceEquipItem(u32 itemId, u32 equipSlot) {
302302

303303
if ((itemId - 1 < 0x1f) && (equipSlot < EQUIP_SLOT_NONE)) {
304304
otherItemSlot = equipSlot == EQUIP_SLOT_A;
305-
replacedItem = gSave.stats.itemButtons[equipSlot];
306-
otherItem = gSave.stats.itemButtons[otherItemSlot];
305+
replacedItem = gSave.stats.equipped[equipSlot];
306+
otherItem = gSave.stats.equipped[otherItemSlot];
307307
if (gItemMetaData[otherItem].menuSlot == gItemMetaData[itemId].menuSlot) {
308308
otherItem = replacedItem;
309309
}
310-
gSave.stats.itemButtons[equipSlot] = itemId;
311-
gSave.stats.itemButtons[otherItemSlot] = otherItem;
310+
gSave.stats.equipped[equipSlot] = itemId;
311+
gSave.stats.equipped[otherItemSlot] = otherItem;
312312
gUnk_0200AF00.unk_13 = 0x7f;
313313
gUnk_0200AF00.unk_14 = 0x7f;
314314
}

src/manager/miscManager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ void MiscManager_TypeB(MiscManager* this) {
364364

365365
bool32 sub_080593CC(MiscManager* this) {
366366
if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 &&
367-
(gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) == PLAYER_INPUT_UP) {
367+
(gPlayerState.playerInput.heldInput & INPUT_ANY_DIRECTION) == INPUT_UP) {
368368
return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
369369
}
370370
return FALSE;

src/menu/pauseMenu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,14 @@ void PauseMenu_ItemMenu_Draw(void) {
529529
gOamCmd._8 = 0x800;
530530
DrawDirect(sub_080A5384_draw_constant0, 0x22);
531531
}
532-
i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_A]);
532+
i = GetMenuSlotForItem(gSave.stats.equipped[SLOT_A]);
533533
if (i < MENU_SLOT_COUNT) {
534534
entry = &gItemMenuTable[i];
535535
gOamCmd.x = entry->x;
536536
gOamCmd.y = entry->y;
537537
DrawDirect(sub_080A5384_draw_constant0, 3);
538538
}
539-
i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_B]);
539+
i = GetMenuSlotForItem(gSave.stats.equipped[SLOT_B]);
540540
if (i < MENU_SLOT_COUNT) {
541541
entry = &gItemMenuTable[i];
542542
gOamCmd.x = entry->x;

src/npc/bigGoron.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void sub_0806D5D4(void) {
434434
InitBiggoronTimer();
435435
equipSlot = IsItemEquipped(ITEM_SHIELD);
436436
if (equipSlot != EQUIP_SLOT_NONE) {
437-
gSave.stats.itemButtons[equipSlot] = ITEM_NONE;
437+
gSave.stats.equipped[equipSlot] = ITEM_NONE;
438438
}
439439
SetInventoryValue(ITEM_SHIELD, 0);
440440
}

src/npc/bladeBrothers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ void BladeBrothers_StartPlayerDemonstration(Entity* this, ScriptExecutionContext
339339
}
340340

341341
void sub_08068BB4(BladeBrothersEntity* this) {
342-
u32 item = gSave.stats.itemButtons[SLOT_A];
342+
u32 item = gSave.stats.equipped[SLOT_A];
343343

344344
this->itemSlotA = item;
345-
item = gSave.stats.itemButtons[SLOT_B];
345+
item = gSave.stats.equipped[SLOT_B];
346346
this->itemSlotB = item;
347347
}
348348

src/npc/npc4E.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ Item NPC4E_GetItemWithSwordUpgraded(Item itemId) {
186186
}
187187

188188
void NPC4E_SaveEquippedItems(NPC4EEntity* this) {
189-
this->unk_68 = gSave.stats.itemButtons[SLOT_A];
190-
this->unk_69 = gSave.stats.itemButtons[SLOT_B];
189+
this->unk_68 = gSave.stats.equipped[SLOT_A];
190+
this->unk_69 = gSave.stats.equipped[SLOT_B];
191191
}
192192

193193
void NPC4E_RestoreEquippedItems(NPC4EEntity* this) {

src/object/crenelBeanSprout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
179179
RestorePrevTileEntity(0xdc, super->collisionLayer);
180180
sub_08096A78(this);
181181
}
182-
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
182+
if ((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_40)) == 0) {
183183
return;
184184
}
185185
if (gUnk_0200AF00.rActionPlayerState != R_ACTION_THROW) {

src/object/houseDoorExterior.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void sub_0808692C(HouseDoorExteriorEntity* this) {
184184
static u8 sub_08086954(HouseDoorExteriorEntity* this) {
185185
if (sub_0800445C(super)) {
186186
if (GetAnimationStateInRectRadius(super, 6, 20) >= 0 && gPlayerEntity.animationState == 0 &&
187-
(u16)gPlayerState.playerInput.heldInput == PLAYER_INPUT_UP && gPlayerState.jump_status == 0) {
187+
(u16)gPlayerState.playerInput.heldInput == INPUT_UP && gPlayerState.jump_status == 0) {
188188
super->timer--;
189189
}
190190
} else {

src/object/itemForSale.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ void ItemForSale_Action2(ItemForSaleEntity* this) {
118118
ptr = sub_080784E4();
119119
if (((*(int*)(ptr + 8) == 0) || ((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.rActionPlayerState = R_ACTION_SPEAK,
120120
(gPlayerState.playerInput.newInput &
121-
(PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) &&
122-
((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) {
121+
(INPUT_ACTION | INPUT_INTERACT)) == 0)))) &&
122+
((gPlayerState.playerInput.newInput & (INPUT_ACTION | INPUT_CANCEL | INPUT_INTERACT)) != 0)) {
123123
sub_080819B4(this);
124124
}
125125
}

src/object/linkHoldingItem.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ void LinkHoldingItem_Action2(LinkHoldingItemEntity* this) {
123123
}
124124

125125
void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) {
126-
u32 tmp;
127-
if ((super->parent)->action == 8) {
126+
u32 bottle_no;
127+
if (super->parent->action == PLAYER_ITEMGET) {
128128
return;
129129
}
130130
switch (super->timer) {
@@ -149,9 +149,9 @@ void LinkHoldingItem_Action3(LinkHoldingItemEntity* this) {
149149
ModHealth(160);
150150
break;
151151
case 3:
152-
tmp = GetBottleContaining(super->type);
153-
if (tmp != 0) {
154-
gSave.stats.itemButtons[tmp + 1] = ITEM_BOTTLE_EMPTY;
152+
bottle_no = GetBottleContaining(super->type);
153+
if (bottle_no != 0) {
154+
gSave.stats.bottles[bottle_no - 1] = ITEM_BOTTLE_EMPTY;
155155
} else {
156156
SetInventoryValue(super->type, ITEM_GREEN_SWORD);
157157
}

0 commit comments

Comments
 (0)