Name all possible R button actions

This commit is contained in:
Catobat 2023-04-30 16:00:33 +02:00
parent 985eeb67a1
commit 06c0f111e7
9 changed files with 60 additions and 45 deletions

View File

@ -452,6 +452,22 @@ typedef enum {
INTERACTION_NULL = 0xFF,
} InteractionType;
typedef enum {
R_ACTION_NONE,
R_ACTION_CANCEL,
R_ACTION_DROP,
R_ACTION_THROW,
R_ACTION_READ,
R_ACTION_CHECK,
R_ACTION_OPEN,
R_ACTION_SPEAK,
R_ACTION_GRAB,
R_ACTION_LIFT,
R_ACTION_GROW,
R_ACTION_SHRINK,
R_ACTION_ROLL,
} ActionRButton;
// playerUtils.c
void DeleteClones(void);
void CreateItemEquippedAtSlot(/*EquipSlot*/ u32 equipSlot);

View File

@ -310,7 +310,7 @@ u32 UpdatePlayerCollision(void) {
if (gPlayerEntity.animationState != 0) {
return 0;
}
gUnk_0200AF00.rActionInteractTile = 4;
gUnk_0200AF00.rActionInteractTile = R_ACTION_READ;
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
return 0;
}
@ -324,7 +324,7 @@ u32 UpdatePlayerCollision(void) {
if ((gPlayerState.flags & 0x4080) != 0) {
return 0;
}
gUnk_0200AF00.rActionInteractTile = 6;
gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN;
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
return 0;
}
@ -335,7 +335,7 @@ u32 UpdatePlayerCollision(void) {
if (HasDungeonSmallKey() == 0) {
return 0;
}
gUnk_0200AF00.rActionInteractTile = 6;
gUnk_0200AF00.rActionInteractTile = R_ACTION_OPEN;
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) {
return 0;
}

View File

@ -225,9 +225,9 @@ void PlayerUpdate(Entity* this) {
static void HandlePlayerLife(Entity* this) {
u32 temp;
gUnk_0200AF00.rActionPlayerState = 0;
gUnk_0200AF00.rActionInteractTile = 0;
gUnk_0200AF00.rActionGrabbing = 0;
gUnk_0200AF00.rActionPlayerState = R_ACTION_NONE;
gUnk_0200AF00.rActionInteractTile = R_ACTION_NONE;
gUnk_0200AF00.rActionGrabbing = R_ACTION_NONE;
if ((gPlayerEntity.contactFlags & 0x80) && (gPlayerEntity.iframes > 0))
SoundReq(SFX_86);
@ -323,7 +323,7 @@ static void sub_080171F0(void) {
sub_080028E0(&gPlayerEntity);
if (gPlayerState.flags & PL_CLONING)
gUnk_0200AF00.rActionPlayerState = 1;
gUnk_0200AF00.rActionPlayerState = R_ACTION_CANCEL;
sub_08078180();
gPlayerState.field_0x7 &= ~0x80;

View File

@ -95,7 +95,7 @@ void ItemPickupCheck(ItemBehavior* this, u32 index) {
carried->subAction = 5;
gPlayerState.framestate = PL_STATE_THROW;
sub_080762C4(this, carried, 2, index);
gUnk_0200AF00.rActionGrabbing = 8;
gUnk_0200AF00.rActionGrabbing = R_ACTION_GRAB;
SoundReq(SFX_102);
break;
case 1:

View File

@ -172,9 +172,9 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
this->unk_70 = ((super->x.HALF.HI + (s8)gUnk_08123184[tmp]) & -0x10) | 8;
this->unk_72 = ((super->y.HALF.HI + (s8)gUnk_08123184[(tmp) + 1]) & -0x10) | 8;
if (sub_080B1AB4(this->unk_70, this->unk_72, super->collisionLayer) == 0x19) {
gUnk_0200AF00.rActionPlayerState = 3;
gUnk_0200AF00.rActionPlayerState = R_ACTION_THROW;
} else {
gUnk_0200AF00.rActionPlayerState = 0;
gUnk_0200AF00.rActionPlayerState = R_ACTION_NONE;
}
PositionRelative(&gPlayerEntity, super, 0, 0x10000);
if (GetTileUnderEntity(super) == 0x19) {
@ -184,7 +184,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) {
if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) {
return;
}
if (gUnk_0200AF00.rActionPlayerState != 3) {
if (gUnk_0200AF00.rActionPlayerState != R_ACTION_THROW) {
return;
}
gPlayerState.heldObject = 0;

View File

@ -102,7 +102,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
ResetActiveItems();
gPlayerState.heldObject = 4;
gNewPlayerEntity.unk_74 = super;
gUnk_0200AF00.rActionPlayerState = 2;
gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP;
MessageClose();
}
}
@ -112,14 +112,14 @@ void ItemForSale_Action1(ItemForSaleEntity* this) {
void ItemForSale_Action2(ItemForSaleEntity* this) {
void* ptr;
gUnk_0200AF00.rActionPlayerState = 2;
gUnk_0200AF00.rActionPlayerState = R_ACTION_DROP;
super->spriteSettings.draw = gPlayerEntity.spriteSettings.draw;
if ((gPlayerState.heldObject == 0) || (super != gNewPlayerEntity.unk_74)) {
sub_080819B4(this);
} else {
ptr = sub_080784E4();
if (((*(int*)(ptr + 8) == 0) ||
((*(u8*)(ptr + 1) != 1 || (gUnk_0200AF00.rActionPlayerState = 7, (gPlayerState.playerInput.newInput &
((*(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)) {
sub_080819B4(this);
@ -142,8 +142,8 @@ void sub_080819B4(ItemForSaleEntity* this) {
gNewPlayerEntity.unk_74 = 0;
ptr = &gUnk_0200AF00;
gRoomVars.shopItemType = 0;
ptr->rActionInteractObject = 0;
ptr->rActionPlayerState = 0;
ptr->rActionInteractObject = R_ACTION_NONE;
ptr->rActionPlayerState = R_ACTION_NONE;
gRoomVars.shopItemType2 = 0;
super->x.HALF.HI = this->unk_80 + gRoomControls.origin_x;
super->y.HALF.HI = this->unk_82 + gRoomControls.origin_y;

View File

@ -1830,7 +1830,7 @@ static void PlayerPull(Entity* this) {
gPlayerState.framestate = PL_STATE_PULL;
sPlayerPullStates[this->subAction](this);
gUnk_0200AF00.rActionGrabbing = 8;
gUnk_0200AF00.rActionGrabbing = R_ACTION_GRAB;
}
static void sub_08072214(Entity* this) {
@ -2756,7 +2756,7 @@ static void sub_08073584(Entity* this) {
return;
}
gUnk_0200AF00.rActionPlayerState = 1;
gUnk_0200AF00.rActionPlayerState = R_ACTION_CANCEL;
if (sub_0807A2F8(0)) {
this->subAction++;
this->direction = 4 * (this->animationState & 6);

View File

@ -211,7 +211,7 @@ bool32 IsPreventedFromUsingItem(void) {
}
return FALSE;
default:
if ((((gUnk_0200AF00.rActionInteractObject == 0xc) && (gPlayerState.field_0x1c == 0)) &&
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.flags & (PL_BURNING | PL_ROLLING)) == 0)) &&
@ -972,49 +972,48 @@ void ForceSetPlayerState(u32 framestate) {
}
void sub_08078180(void) {
u8 uVar1;
u8 uVar3;
InteractableObject* ptr;
u8 rAction;
InteractableObject* interaction;
if (gUnk_0200AF00.rActionPlayerState != 0)
if (gUnk_0200AF00.rActionPlayerState != R_ACTION_NONE)
return;
uVar1 = 0;
rAction = R_ACTION_NONE;
if ((gPlayerState.jump_status == 0) &&
((gPlayerState.flags & (PL_IN_HOLE | PL_FROZEN | PL_BURNING | PL_DISABLE_ITEMS | PL_DRUGGED)) == 0)) {
if ((u8)(gPlayerState.heldObject - 1) < 4) {
if (gUnk_0200AF00.rActionGrabbing != 0) {
uVar1 = gUnk_0200AF00.rActionGrabbing;
if (gUnk_0200AF00.rActionGrabbing != R_ACTION_NONE) {
rAction = gUnk_0200AF00.rActionGrabbing;
} else {
uVar1 = 3;
rAction = R_ACTION_THROW;
}
} else {
if (gUnk_0200AF00.rActionInteractTile != 0) {
uVar1 = gUnk_0200AF00.rActionInteractTile;
if (gUnk_0200AF00.rActionInteractTile != R_ACTION_NONE) {
rAction = gUnk_0200AF00.rActionInteractTile;
} else {
ptr = sub_080784E4();
if (ptr->entity->interactType == 0) {
interaction = sub_080784E4();
if (interaction->entity->interactType == 0) {
switch (ptr->type) {
switch (interaction->type) {
case INTERACTION_TALK:
case INTERACTION_TALK_MINISH:
uVar1 = 7;
rAction = R_ACTION_SPEAK;
break;
case INTERACTION_LIFT_SHOP_ITEM:
if (gRoomVars.shopItemType == ITEM_NONE) {
uVar1 = 9;
rAction = R_ACTION_LIFT;
}
break;
case INTERACTION_OPEN_CHEST:
case INTERACTION_USE_SMALL_KEY:
case INTERACTION_USE_BIG_KEY:
uVar1 = 6;
rAction = R_ACTION_OPEN;
break;
case INTERACTION_CHECK:
uVar1 = 5;
rAction = R_ACTION_CHECK;
break;
case INTERACTION_DROP_PEDESTAL:
uVar1 = 2;
rAction = R_ACTION_DROP;
break;
}
} else {
@ -1022,25 +1021,25 @@ void sub_08078180(void) {
if (((gPlayerState.framestate != PL_STATE_USEPORTAL))) {
if ((gCarriedEntity.unk_1 == 2) && ((gCarriedEntity.unk_8)->carryFlags == 1)) {
uVar1 = 8;
rAction = R_ACTION_GRAB;
} else {
uVar1 = 9;
rAction = R_ACTION_LIFT;
}
} else {
return;
}
} else {
if ((gPlayerState.framestate == PL_STATE_WALK) && (gPlayerState.mobility == 0)) {
uVar1 = 0xc;
rAction = R_ACTION_ROLL;
} else {
uVar1 = 0;
rAction = R_ACTION_NONE;
}
}
}
}
}
}
gUnk_0200AF00.rActionInteractObject = uVar1;
gUnk_0200AF00.rActionInteractObject = rAction;
}
bool32 sub_080782C0(void) {

View File

@ -743,13 +743,13 @@ void TextUIElement(UIElement* element) {
if (element->type2 == 9) {
frameIndex = gUnk_0200AF00.rActionPlayerState;
if (frameIndex == 0) {
if (frameIndex == R_ACTION_NONE) {
switch (gArea.portal_mode) {
case 2:
frameIndex = 0xb;
frameIndex = R_ACTION_SHRINK;
break;
case 3:
frameIndex = 0xa;
frameIndex = R_ACTION_GROW;
break;
default:
frameIndex = gUnk_0200AF00.rActionInteractObject;