From c5304d1d7462689ab0e01c497b104fe80c18419a Mon Sep 17 00:00:00 2001 From: KEKW555 <152369890+KEKW555@users.noreply.github.com> Date: Sun, 10 Dec 2023 06:22:18 +0530 Subject: [PATCH] Match remaining playerUtils.c functions. (#642) * Nuke sub_080784E4.inc * Nuke sub_0807A2F8.inc * Match remaining playerUtils functions * Fix build failures --- asm/non_matching/playerUtils/sub_080784E4.inc | 315 ------------------ asm/non_matching/playerUtils/sub_0807A2F8.inc | 257 -------------- src/playerUtils.c | 210 +++++++++++- 3 files changed, 208 insertions(+), 574 deletions(-) delete mode 100644 asm/non_matching/playerUtils/sub_080784E4.inc delete mode 100644 asm/non_matching/playerUtils/sub_0807A2F8.inc diff --git a/asm/non_matching/playerUtils/sub_080784E4.inc b/asm/non_matching/playerUtils/sub_080784E4.inc deleted file mode 100644 index 14b6afbb65..0000000000 --- a/asm/non_matching/playerUtils/sub_080784E4.inc +++ /dev/null @@ -1,315 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - ldr r0, _080784FC @ =gPossibleInteraction - ldrb r1, [r0] - mov r8, r0 - cmp r1, #0 - beq _08078500 - ldr r0, [r0, #4] - b _0807876A - .align 2, 0 -_080784FC: .4byte gPossibleInteraction -_08078500: - ldr r2, _08078528 @ =gPlayerState - adds r0, r2, #0 - adds r0, #0x27 - adds r3, r2, #0 - adds r3, #0x26 - ldrb r1, [r0] - ldrb r0, [r3] - orrs r0, r1 - cmp r0, #0 - bne _08078598 - adds r1, r2, #0 - adds r1, #0xa8 - ldrb r0, [r1] - cmp r0, #0 - bne _0807852C - adds r0, r2, #0 - adds r0, #0xa9 - ldrb r0, [r0] - b _0807852E - .align 2, 0 -_08078528: .4byte gPlayerState -_0807852C: - ldrb r0, [r1] -_0807852E: - subs r0, #2 - cmp r0, #0x14 - bhi _080785B0 - lsls r0, r0, #2 - ldr r1, _08078540 @ =_08078544 - adds r0, r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08078540: .4byte _08078544 -_08078544: @ jump table - .4byte _08078598 @ case 0 - .4byte _08078598 @ case 1 - .4byte _080785B0 @ case 2 - .4byte _080785B0 @ case 3 - .4byte _080785B0 @ case 4 - .4byte _080785B0 @ case 5 - .4byte _080785B0 @ case 6 - .4byte _080785B0 @ case 7 - .4byte _080785B0 @ case 8 - .4byte _080785B0 @ case 9 - .4byte _080785B0 @ case 10 - .4byte _080785B0 @ case 11 - .4byte _080785B0 @ case 12 - .4byte _080785B0 @ case 13 - .4byte _080785B0 @ case 14 - .4byte _080785B0 @ case 15 - .4byte _08078598 @ case 16 - .4byte _080785B0 @ case 17 - .4byte _080785B0 @ case 18 - .4byte _08078598 @ case 19 - .4byte _08078598 @ case 20 -_08078598: - movs r0, #0xff - mov r1, r8 - strb r0, [r1, #3] - ldr r0, _080785AC @ =gNoInteraction - str r0, [r1, #4] - movs r1, #1 - mov r2, r8 - strb r1, [r2] - b _0807876A - .align 2, 0 -_080785AC: .4byte gNoInteraction -_080785B0: - ldr r0, [r2, #0x30] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - bne _080785F0 - bl HasDungeonSmallKey - cmp r0, #0 - beq _080785C4 - movs r0, #1 -_080785C4: - adds r7, r0, #0 - bl HasDungeonBigKey - cmp r0, #0 - beq _080785D2 - movs r0, #2 - orrs r7, r0 -_080785D2: - ldr r3, _080785E4 @ =gPlayerEntity - ldrb r0, [r3, #0x14] - movs r1, #6 - ands r1, r0 - ldr r0, _080785E8 @ =gPlayerInteractHitboxOffsetNormal - adds r2, r1, r0 - ldr r5, _080785EC @ =gPossibleInteraction - mov r8, r5 - b _080785FE - .align 2, 0 -_080785E4: .4byte gPlayerEntity -_080785E8: .4byte gPlayerInteractHitboxOffsetNormal -_080785EC: .4byte gPossibleInteraction -_080785F0: - ldr r3, _08078624 @ =gPlayerEntity - ldrb r0, [r3, #0x14] - movs r1, #6 - ands r1, r0 - ldr r0, _08078628 @ =gPlayerInteractHitboxOffsetMinish - adds r2, r1, r0 - movs r7, #0 -_080785FE: - mov ip, r3 - mov r0, ip - movs r3, #0x2e - ldrsh r1, [r0, r3] - movs r0, #0 - ldrsb r0, [r2, r0] - adds r1, r1, r0 - mov sl, r1 - mov r5, ip - movs r0, #0x32 - ldrsh r1, [r5, r0] - movs r0, #1 - ldrsb r0, [r2, r0] - adds r1, r1, r0 - mov sb, r1 - movs r6, #0 - ldr r5, _0807862C @ =gInteractableObjects - b _08078724 - .align 2, 0 -_08078624: .4byte gPlayerEntity -_08078628: .4byte gPlayerInteractHitboxOffsetMinish -_0807862C: .4byte gInteractableObjects -_08078630: - ldrb r1, [r5] - movs r3, #1 - adds r0, r3, #0 - ands r0, r1 - cmp r0, #0 - bne _0807864E - mov r0, ip - adds r0, #0x38 - adds r1, r2, #0 - adds r1, #0x38 - ldrb r2, [r0] - ldrb r0, [r1] - ands r0, r2 - cmp r0, #0 - beq _08078714 -_0807864E: - ldrb r1, [r5, #2] - mov r2, ip - ldrb r0, [r2, #0x14] - lsrs r0, r0, #1 - asrs r1, r0 - ands r1, r3 - cmp r1, #0 - bne _08078714 - ldrb r0, [r5, #1] - cmp r0, #0xa - bhi _080786D4 - lsls r0, r0, #2 - ldr r1, _08078670 @ =_08078674 - adds r0, r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08078670: .4byte _08078674 -_08078674: @ jump table - .4byte _08078714 @ case 0 - .4byte _080786A0 @ case 1 - .4byte _080786C4 @ case 2 - .4byte _080786A0 @ case 3 - .4byte _080786A0 @ case 4 - .4byte _080786C8 @ case 5 - .4byte _080786CC @ case 6 - .4byte _080786B4 @ case 7 - .4byte _080786A0 @ case 8 - .4byte _080786A0 @ case 9 - .4byte _080786D4 @ case 10 -_080786A0: - ldr r0, _080786B0 @ =gPlayerState - ldr r0, [r0, #0x30] - movs r1, #0x80 - ands r0, r1 - cmp r0, #0 - bne _08078714 - b _080786D4 - .align 2, 0 -_080786B0: .4byte gPlayerState -_080786B4: - ldr r0, _080786C0 @ =gPlayerState - ldr r0, [r0, #0x30] - movs r1, #0x80 - ands r0, r1 - b _080786D0 - .align 2, 0 -_080786C0: .4byte gPlayerState -_080786C4: - ldrb r0, [r5, #3] - b _080786D0 -_080786C8: - movs r0, #1 - b _080786CE -_080786CC: - movs r0, #2 -_080786CE: - ands r0, r7 -_080786D0: - cmp r0, #0 - beq _08078714 -_080786D4: - ldr r0, [r5, #8] - movs r1, #0x2e - ldrsh r3, [r0, r1] - movs r2, #0x32 - ldrsh r4, [r0, r2] - ldr r1, [r5, #4] - cmp r1, #0 - beq _080786F4 - movs r0, #0 - ldrsb r0, [r1, r0] - adds r3, r3, r0 - movs r0, #1 - ldrsb r0, [r1, r0] - adds r4, r4, r0 - adds r2, r1, #2 - b _080786F8 -_080786F4: - ldr r0, [r0, #0x48] - adds r2, r0, #6 -_080786F8: - ldrb r1, [r2] - mov r5, sl - adds r0, r1, r5 - subs r0, r0, r3 - lsls r1, r1, #1 - cmp r0, r1 - bhs _08078714 - ldrb r1, [r2, #1] - mov r2, sb - adds r0, r1, r2 - subs r0, r0, r4 - lsls r1, r1, #1 - cmp r0, r1 - blo _0807873A -_08078714: - adds r6, #1 - cmp r6, #0x1f - bhi _08078758 - lsls r0, r6, #1 - adds r0, r0, r6 - lsls r0, r0, #2 - ldr r3, _08078754 @ =gInteractableObjects - adds r5, r0, r3 -_08078724: - ldr r2, [r5, #8] - cmp r2, #0 - beq _08078714 - adds r0, r2, #0 - adds r0, #0x39 - ldrb r0, [r0] - lsls r0, r0, #0x18 - asrs r0, r0, #0x18 - cmp r0, #0 - blt _0807873A - b _08078630 -_0807873A: - cmp r6, #0x1f - bhi _08078758 - mov r5, r8 - strb r6, [r5, #3] - lsls r0, r6, #1 - adds r0, r0, r6 - lsls r0, r0, #2 - mov r1, r8 - adds r1, #8 - adds r0, r0, r1 - str r0, [r5, #4] - b _08078762 - .align 2, 0 -_08078754: .4byte gInteractableObjects -_08078758: - movs r0, #0xff - mov r1, r8 - strb r0, [r1, #3] - ldr r0, _08078774 @ =gNoInteraction - str r0, [r1, #4] -_08078762: - movs r0, #1 - mov r2, r8 - strb r0, [r2] - ldr r0, [r2, #4] -_0807876A: - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_08078774: .4byte gNoInteraction - .syntax divided diff --git a/asm/non_matching/playerUtils/sub_0807A2F8.inc b/asm/non_matching/playerUtils/sub_0807A2F8.inc deleted file mode 100644 index b777afc9c6..0000000000 --- a/asm/non_matching/playerUtils/sub_0807A2F8.inc +++ /dev/null @@ -1,257 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #4 - adds r4, r0, #0 - ldr r0, _0807A364 @ =gRoomControls - mov r8, r0 - ldrb r0, [r0, #4] - cmp r0, #8 - bne _0807A312 - b _0807A4F2 -_0807A312: - bl sub_08079778 - orrs r0, r4 - cmp r0, #0 - bne _0807A31E - b _0807A4F2 -_0807A31E: - ldr r7, _0807A368 @ =gPlayerEntity - ldrb r1, [r7, #0x14] - movs r0, #2 - ands r0, r1 - cmp r0, #0 - beq _0807A36C - movs r1, #0x2e - ldrsh r2, [r7, r1] - mov r6, r8 - ldrh r0, [r6, #6] - subs r2, r2, r0 - asrs r2, r2, #4 - movs r3, #0x3f - ands r2, r3 - movs r0, #0x32 - ldrsh r1, [r7, r0] - ldr r0, [r7, #0x48] - ldrb r5, [r0, #5] - adds r0, r1, r5 - ldrh r4, [r6, #8] - subs r0, r0, r4 - asrs r0, r0, #4 - ands r0, r3 - lsls r0, r0, #6 - orrs r0, r2 - lsls r7, r0, #1 - subs r1, r1, r5 - subs r1, r1, r4 - asrs r1, r1, #4 - ands r1, r3 - lsls r1, r1, #6 - orrs r2, r1 - lsls r6, r2, #1 - b _0807A3A2 - .align 2, 0 -_0807A364: .4byte gRoomControls -_0807A368: .4byte gPlayerEntity -_0807A36C: - movs r1, #0x2e - ldrsh r3, [r7, r1] - ldr r0, [r7, #0x48] - ldrb r6, [r0, #2] - adds r1, r3, r6 - mov r2, r8 - ldrh r5, [r2, #6] - subs r1, r1, r5 - asrs r1, r1, #4 - movs r4, #0x3f - ands r1, r4 - movs r2, #0x32 - ldrsh r0, [r7, r2] - mov r7, r8 - ldrh r2, [r7, #8] - subs r0, r0, r2 - asrs r0, r0, #4 - ands r0, r4 - lsls r0, r0, #6 - orrs r1, r0 - lsls r7, r1, #1 - subs r3, r3, r6 - subs r3, r3, r5 - asrs r3, r3, #4 - ands r3, r4 - orrs r3, r0 - lsls r6, r3, #1 -_0807A3A2: - movs r0, #0 - mov sb, r0 - ldr r1, _0807A3F4 @ =gPlayerEntity - mov sl, r1 -_0807A3AA: - movs r2, #0 - mov r8, r2 - mov r0, sl - mov r1, sp - adds r2, r7, #0 - bl sub_08004202 - adds r7, r0, #0 - lsrs r4, r7, #1 - adds r0, r4, #0 - movs r1, #1 - bl sub_080B1B44 - cmp r0, #0 - beq _0807A3FC - lsls r0, r4, #0x10 - lsrs r0, r0, #0x10 - mov r1, sl - adds r1, #0x38 - ldrb r1, [r1] - bl sub_080B1AE0 - lsls r0, r0, #0x10 - lsrs r0, r0, #0x10 - mov r2, sl - ldrb r1, [r2, #0x14] - lsrs r1, r1, #1 - lsls r1, r1, #2 - ldr r2, _0807A3F8 @ =gUnk_0811C1D8 - adds r1, r1, r2 - ldr r1, [r1] - bl sub_08007DD6 - cmp r0, #0 - beq _0807A468 - b _0807A400 - .align 2, 0 -_0807A3F4: .4byte gPlayerEntity -_0807A3F8: .4byte gUnk_0811C1D8 -_0807A3FC: - movs r0, #1 - mov r8, r0 -_0807A400: - ldr r5, _0807A444 @ =gPlayerEntity - adds r0, r5, #0 - mov r1, sp - adds r2, r6, #0 - bl sub_08004202 - adds r6, r0, #0 - lsrs r4, r6, #1 - adds r0, r4, #0 - movs r1, #1 - bl sub_080B1B44 - cmp r0, #0 - beq _0807A44C - lsls r0, r4, #0x10 - lsrs r0, r0, #0x10 - adds r1, r5, #0 - adds r1, #0x38 - ldrb r1, [r1] - bl sub_080B1AE0 - lsls r0, r0, #0x10 - lsrs r0, r0, #0x10 - ldrb r1, [r5, #0x14] - lsrs r1, r1, #1 - lsls r1, r1, #2 - ldr r2, _0807A448 @ =gUnk_0811C1D8 - adds r1, r1, r2 - ldr r1, [r1] - bl sub_08007DD6 - cmp r0, #0 - beq _0807A468 - b _0807A450 - .align 2, 0 -_0807A444: .4byte gPlayerEntity -_0807A448: .4byte gUnk_0811C1D8 -_0807A44C: - movs r0, #1 - add r8, r0 -_0807A450: - mov r1, r8 - cmp r1, #2 - bne _0807A45E - mov r2, sb - cmp r2, #0 - bne _0807A46E - b _0807A4F2 -_0807A45E: - movs r0, #1 - add sb, r0 - mov r1, sb - cmp r1, #1 - bls _0807A3AA -_0807A468: - mov r2, sb - cmp r2, #0 - beq _0807A4F2 -_0807A46E: - bl AreaIsDungeon - cmp r0, #0 - beq _0807A4B0 - ldr r4, _0807A4AC @ =gPlayerEntity - adds r0, r4, #0 - mov r1, sp - adds r2, r7, #0 - bl sub_08004202 - adds r7, r0, #0 - lsrs r0, r7, #1 - movs r1, #2 - bl sub_080B1B44 - cmp r0, #0 - bne _0807A4F2 - adds r0, r4, #0 - mov r1, sp - adds r2, r6, #0 - bl sub_08004202 - adds r6, r0, #0 - lsrs r0, r6, #1 - movs r1, #2 -_0807A4A0: - bl sub_080B1B44 - cmp r0, #0 - beq _0807A4EC - b _0807A4F2 - .align 2, 0 -_0807A4AC: .4byte gPlayerEntity -_0807A4B0: - mov r0, sb - cmp r0, #2 - bne _0807A4C2 - ldr r0, _0807A4E8 @ =gPlayerEntity - mov r1, sp - adds r2, r7, #0 - bl sub_08004202 - adds r7, r0, #0 -_0807A4C2: - lsrs r0, r7, #1 - movs r1, #1 - bl sub_080B1B44 - cmp r0, #0 - bne _0807A4F2 - mov r1, sb - cmp r1, #2 - bne _0807A4E0 - ldr r0, _0807A4E8 @ =gPlayerEntity - mov r1, sp - adds r2, r6, #0 - bl sub_08004202 - adds r6, r0, #0 -_0807A4E0: - lsrs r0, r6, #1 - movs r1, #1 - b _0807A4A0 - .align 2, 0 -_0807A4E8: .4byte gPlayerEntity -_0807A4EC: - mov r0, sb - adds r0, #1 - b _0807A4F4 -_0807A4F2: - movs r0, #0 -_0807A4F4: - add sp, #4 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7, pc} - .syntax divided diff --git a/src/playerUtils.c b/src/playerUtils.c index dc7f048291..43ec882f94 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -156,6 +156,8 @@ extern const u8 gUnk_0811BFE0[]; extern const u8 gUnk_08007DF4[]; extern const u8 gUnk_080084BC[]; +extern InteractableObject gInteractableObjects[]; + u32 sub_0807A180(Entity*, Entity*, u32, u32); extern u32 gUsedPalettes; @@ -1158,7 +1160,132 @@ void ResetPossibleInteraction(void) { } // determines which (if any) object the player is currently able to interact with -ASM_FUNC("asm/non_matching/playerUtils/sub_080784E4.inc", InteractableObject* sub_080784E4(void)) +InteractableObject* sub_080784E4(void) { + u8 uVar1; + PlayerFlags r7; + s32 r3; + PlayerFlags PVar4; + u8* puVar5; + u8* hitbox; + s8* interactOffsets; + Entity* entity; + s32 r4; + InteractableObject* iObject; + u32 index; + s32 interactX; + s32 interactY; + + if (gPossibleInteraction.isUpdated != 0) { + return gPossibleInteraction.currentObject; + } + if ((gPlayerState.field_0x27[0] | gPlayerState.swim_state) != 0) { + goto l; + } + + if (gPlayerState.framestate == 0) { + uVar1 = gPlayerState.framestate_last; + } else { + uVar1 = gPlayerState.framestate; + } + switch (uVar1) { + case 2: + case 3: + case 0x12: + case 0x15: + case 0x16: + l: + gPossibleInteraction.currentIndex = 0xFF; + gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction; + gPossibleInteraction.isUpdated = 1; + return gPossibleInteraction.currentObject; + } + + if ((gPlayerState.flags & PL_MINISH) == 0) { + r7 = HasDungeonSmallKey() ? PL_BUSY : 0; + if (HasDungeonBigKey()) { + r7 |= PL_FLAGS2; + } + interactOffsets = (s8*)gPlayerInteractHitboxOffsetNormal + (gPlayerEntity.animationState & 6); + } else { + interactOffsets = (s8*)gPlayerInteractHitboxOffsetMinish + (gPlayerEntity.animationState & 6); + r7 = 0; + } + + interactX = gPlayerEntity.x.HALF.HI + interactOffsets[0]; + interactY = gPlayerEntity.y.HALF.HI + interactOffsets[1]; + + for (index = 0; index < 0x20; index++) { + iObject = gInteractableObjects + index; + entity = iObject->entity; + if (entity == NULL) + continue; + if (entity->interactType < 0) + break; + if ((((iObject->ignoreLayer & 1) == 0) && ((gPlayerEntity.collisionLayer & entity->collisionLayer) == 0)) || + ((iObject->interactDirections >> (gPlayerEntity.animationState >> 1) & 1) != 0)) + continue; + switch (iObject->type) { + case 0: + continue; + case 1: + case 3: + case 4: + case 8: + case 9: + if ((gPlayerState.flags & PL_MINISH) != 0) + continue; + break; + case 7: + PVar4 = gPlayerState.flags & PL_MINISH; + if (PVar4 == 0) + continue; + break; + case 2: + PVar4 = (PlayerFlags)iObject->kinstoneId; + if (PVar4 == 0) + continue; + break; + case 5: + PVar4 = PL_BUSY & r7; + if (PVar4 == 0) + continue; + break; + case 6: + PVar4 = PL_FLAGS2 & r7; + if (PVar4 == 0) + continue; + break; + case 10: + default: + break; + } + + r3 = iObject->entity->x.HALF.HI; + r4 = iObject->entity->y.HALF.HI; + hitbox = (u8*)iObject->customHitbox; + if (hitbox != NULL) { + r3 += (s8)hitbox[0]; + r4 += (s8)hitbox[1]; + puVar5 = hitbox + 2; + } else { + puVar5 = &iObject->entity->hitbox->width; + } + if (((puVar5[0] + interactX) - r3 < (u32)puVar5[0] << 1) && + ((puVar5[1] + interactY) - r4 < (u32)puVar5[1] << 1)) { + break; + } + } + if (index < 0x20) { + gPossibleInteraction.currentIndex = (u8)index; + gPossibleInteraction.currentObject = &gPossibleInteraction.candidates[index]; + + } else { + gPossibleInteraction.currentIndex = 0xFF; + gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction; + } + gPossibleInteraction.isUpdated = 1; + return gPossibleInteraction.currentObject; +} void AddInteractableWhenBigObject(Entity* ent) { AddInteractableObject(ent, 1, 0); @@ -2496,7 +2623,86 @@ bool32 sub_0807A2B8(void) { } } -ASM_FUNC("asm/non_matching/playerUtils/sub_0807A2F8.inc", u32 sub_0807A2F8(u32 a1)) +u32 sub_0807A2F8(u32 param_1) { + u32 uVar1; + u32 uVar2; + u32 iVar4; + u32 uVar5; + u8 auStack36[4]; + Entity* player; + + if ((gRoomControls.area == 8) || (sub_08079778() | param_1) == 0) + return 0; + if ((gPlayerEntity.animationState & 2) != 0) { + + uVar2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, 0, -gPlayerEntity.hitbox->unk2[3]) << 1; + uVar1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, 0, gPlayerEntity.hitbox->unk2[3]) << 1; + + } else { + uVar2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -gPlayerEntity.hitbox->unk2[0], 0) << 1; + uVar1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, gPlayerEntity.hitbox->unk2[0], 0) << 1; + } + + for (uVar5 = 0; uVar5 < 2; uVar5++) { + iVar4 = 0; + uVar2 = sub_08004202(&gPlayerEntity, auStack36, uVar2); + if (sub_080B1B44(uVar2 >> 1, 1)) { + if (!sub_08007DD6((u16)sub_080B1AE0((u16)(uVar2 >> 1), gPlayerEntity.collisionLayer), + gUnk_0811C1D8[gPlayerEntity.animationState >> 1])) { + break; + } + } else { + iVar4 = 1; + } + + uVar1 = sub_08004202(&gPlayerEntity, auStack36, uVar1); + if (sub_080B1B44(uVar1 >> 1, 1)) { + if (!sub_08007DD6((u16)sub_080B1AE0((uVar1 >> 1), gPlayerEntity.collisionLayer), + gUnk_0811C1D8[gPlayerEntity.animationState >> 1])) { + break; + } + } else { + iVar4++; + } + + if (iVar4 == 2) { + if (uVar5 != 0) { + break; + } + return 0; + } + } + if (uVar5 != 0) { + if (AreaIsDungeon()) { + uVar2 = sub_08004202(&gPlayerEntity, auStack36, uVar2); + if (!sub_080B1B44(uVar2 >> 1, 2)) { + uVar1 = sub_08004202(&gPlayerEntity, auStack36, uVar1); + if (sub_080B1B44(uVar1 >> 1, 2)) { + return 0; + } + } else { + return 0; + } + } else { + if (uVar5 == 2) { + uVar2 = sub_08004202(&gPlayerEntity, auStack36, uVar2); + } + if (sub_080B1B44(uVar2 >> 1, 1) == 0) { + if (uVar5 == 2) { + uVar1 = sub_08004202(&gPlayerEntity, auStack36, uVar1); + } + if (sub_080B1B44(uVar1 >> 1, 1)) { + return 0; + } + } else { + return 0; + } + } + return uVar5 + 1; + } + + return 0; +} u32 GetPlayerTilePos(void) { switch (gPlayerEntity.animationState >> 1) {