From c0018fea1c69d914240cd7b564e77abbddecbbd6 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sun, 1 May 2022 13:40:19 +0300 Subject: [PATCH] Match sub_08079064 --- asm/non_matching/playerUtils/sub_08079064.inc | 68 ------------------- src/playerUtils.c | 27 +++++++- 2 files changed, 26 insertions(+), 69 deletions(-) delete mode 100644 asm/non_matching/playerUtils/sub_08079064.inc diff --git a/asm/non_matching/playerUtils/sub_08079064.inc b/asm/non_matching/playerUtils/sub_08079064.inc deleted file mode 100644 index 3261523d..00000000 --- a/asm/non_matching/playerUtils/sub_08079064.inc +++ /dev/null @@ -1,68 +0,0 @@ - .syntax unified - push {r4, r5, r6, lr} - adds r6, r0, #0 - ldr r0, _0807909C @ =gPlayerState - ldr r1, [r0, #0x30] - ldr r2, _080790A0 @ =0x00100080 - ands r1, r2 - adds r5, r0, #0 - cmp r1, #0 - bne _080790DE - movs r3, #0 - movs r2, #0 - ldr r1, _080790A4 @ =gUnk_03000B80 -_0807907C: - ldrb r0, [r1, #0xf] - cmp r0, r3 - bls _08079086 - adds r3, r0, #0 - ldrh r4, [r1, #0x10] -_08079086: - adds r1, #0x1c - adds r2, #1 - cmp r2, #3 - bls _0807907C - adds r2, r5, #0 - ldrb r0, [r2, #0xe] - cmp r0, r3 - bhs _080790A8 - strh r4, [r2, #8] - b _080790DE - .align 2, 0 -_0807909C: .4byte gPlayerState -_080790A0: .4byte 0x00100080 -_080790A4: .4byte gUnk_03000B80 -_080790A8: - adds r0, r2, #0 - adds r0, #0x26 - ldrb r1, [r0] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _080790C0 - ldr r0, _080790BC @ =0x000002BE - strh r0, [r2, #8] - b _080790DE - .align 2, 0 -_080790BC: .4byte 0x000002BE -_080790C0: - ldrh r1, [r5, #8] - movs r0, #0xc1 - lsls r0, r0, #3 - cmp r1, r0 - beq _080790D8 - movs r0, #0x82 - lsls r0, r0, #1 - cmp r1, r0 - beq _080790D8 - ldr r0, _080790E0 @ =0x00000404 - cmp r1, r0 - bne _080790DE -_080790D8: - adds r0, r6, #0 - bl sub_080790E4 -_080790DE: - pop {r4, r5, r6, pc} - .align 2, 0 -_080790E0: .4byte 0x00000404 - .syntax divided diff --git a/src/playerUtils.c b/src/playerUtils.c index 4ccd5a99..35a80159 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -24,6 +24,7 @@ extern void sub_0809D738(Entity*); extern s32 Mod(s32, s32); extern void sub_08003FDE(Entity*, u32, u32, u32); extern u32 sub_080B1B84(u32, u32); +void sub_080790E4(Entity* this); typedef struct { u8 unk0[4]; @@ -1233,7 +1234,31 @@ bool32 sub_08078F74(Entity* this) { ASM_FUNC("asm/non_matching/playerUtils/sub_08078FB0.inc", void sub_08078FB0(Entity* a)) -ASM_FUNC("asm/non_matching/playerUtils/sub_08079064.inc", void sub_08079064()) +void sub_08079064(Entity* this) { + u32 i; + u32 bVar4; + u32 animation; + + if ((gPlayerState.flags & (PL_IN_HOLE | PL_MINISH)) == 0) { + bVar4 = 0; + for (i = 0; i < 4; i++) { + if (gUnk_03000B80[i].field_0xf > bVar4) { + bVar4 = gUnk_03000B80[i].field_0xf; + animation = gUnk_03000B80[i].field_0x10; + } + } + + if (gPlayerState.field_0xe < bVar4) { + gPlayerState.animation = animation; + } else if ((gPlayerState.swim_state & 0x80) != 0) { + gPlayerState.animation = 0x2be; + } else { + if (gPlayerState.animation == 0x608 || gPlayerState.animation == 0x104 || gPlayerState.animation == 0x404) { + sub_080790E4(this); + } + } + } +} void sub_080790E4(Entity* this) { if (gPlayerState.keepFacing != 0) {