Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match sub_080762D8 #640

Merged
merged 4 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 0 additions & 219 deletions asm/non_matching/itemTryPickupObject/sub_080762D8.inc

This file was deleted.

101 changes: 100 additions & 1 deletion src/item/itemTryPickupObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ void sub_08076518(ItemBehavior*, u32);
void sub_080765E0(ItemBehavior*, u32);
void sub_0807660C(ItemBehavior*, u32);

extern s32 sub_0800875A(Entity*, u32, ItemBehavior*);

extern const u16 gUnk_0811BE38[];
extern const u16 gUnk_0811BE40[];

void sub_08076088(ItemBehavior* this, Entity* param_2, u32 param_3) {
if (param_2 != NULL) {
if ((param_2->carryFlags & 1) != 0) {
Expand Down Expand Up @@ -129,7 +134,101 @@ void sub_080762C4(ItemBehavior* this, Entity* arg1, u8 arg2, u32 arg3) {
sub_08077D38(this, arg3);
}

ASM_FUNC("asm/non_matching/itemTryPickupObject/sub_080762D8.inc", void sub_080762D8(ItemBehavior* this, u32 index))
void sub_080762D8(ItemBehavior* this, u32 index) {
u32 animIndex;

gPlayerState.heldObject &= 0xcf;
if (PlayerTryDropObject(this, index) == 0) {
return;
}

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 & 0x80) == 0) {
this->field_0x18->subAction = 6; //
PlayerCancelHoldItem(this, index);
return;
}
} else {
PlayerCancelHoldItem(this, index);
return;
}
}

gPlayerState.framestate = 5;
gUnk_0200AF00.rActionGrabbing = 8;
} else {
if (this->field_0x18 != NULL) {
this->field_0x18->subAction = 6;
}
PlayerCancelHoldItem(this, index);
return;
}

if (gPlayerState.jump_status == 0) {

if ((gPlayerState.heldObject == 1) && (sub_0800875A(&gPlayerEntity, 6, this) != 0)) {
sub_08076088(this, NULL, index);
return;
} else if ((gUnk_0811BE38[(gPlayerEntity.animationState >> 1)] & gPlayerState.playerInput.heldInput) != 0) {
UpdateItemAnim(this);

if ((gPlayerState.flags & 8) == 0) {
animIndex = 0x340;
} else {
animIndex = 0x940;
}

if (animIndex != this->animIndex) {
SetItemAnim(this, animIndex);
}

gPlayerState.heldObject |= 0x10;
gPlayerState.framestate = 0x1a;

if (gPlayerState.heldObject == 1) {
return;
}

sub_08076088(this, this->field_0x18, index);
} else {
if ((gPlayerState.playerInput.heldInput & gUnk_0811BE40[(gPlayerEntity.animationState >> 1)]) != 0) {
if (gPlayerEntity.subtimer < 6) {
gPlayerEntity.subtimer++;
return;
}

gPlayerState.field_0x35 = this->playerAnimationState;
gPlayerState.pushedObject |= 0x80;
gPlayerState.heldObject |= 0x20;
gPlayerState.framestate = 0x19;

if ((gPlayerState.flags & 8) == 0) {
animIndex = 0x33c;
} else {
animIndex = 0x93c;
}

if (animIndex == this->animIndex) {
UpdateItemAnim(this);
} else {
SetItemAnim(this, animIndex);
}
} else {
gPlayerEntity.subtimer = 0;

if ((gPlayerState.flags & 8) == 0) {
SetItemAnim(this, 0x340);
} else {
SetItemAnim(this, 0x940);
}
}
}
} else {
PlayerCancelHoldItem(this, index);
}
}

void sub_08076488(ItemBehavior* this, u32 index) {
u32 bVar1;
Expand Down
Loading