From 6917076fdcd0498f9ab156e629ecf67abe3c68a0 Mon Sep 17 00:00:00 2001 From: Henny022p Date: Mon, 15 Feb 2021 10:41:38 +0100 Subject: [PATCH] matched sub_0807DE80 --- asm/code_0807CC3C.s | 51 --------------------------------------------- src/code_0807CC3C.c | 38 ++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 54 deletions(-) diff --git a/asm/code_0807CC3C.s b/asm/code_0807CC3C.s index bd7e1630..f468bf14 100644 --- a/asm/code_0807CC3C.s +++ b/asm/code_0807CC3C.s @@ -2084,54 +2084,3 @@ _0807DE70: _0807DE7C: pop {r4, r5, pc} .align 2, 0 - - thumb_func_start sub_0807DE80 -sub_0807DE80: @ 0x0807DE80 - push {r4, lr} - adds r4, r0, #0 - adds r0, #0x80 - ldrh r3, [r0] - cmp r3, #7 - bhi _0807DEB0 - adds r0, #2 - ldrh r1, [r0] - movs r0, #1 - ands r0, r1 - cmp r0, #0 - beq _0807DEA4 - movs r1, #0xfc - ands r1, r3 - ldrb r0, [r4, #0xf] - lsrs r0, r0, #1 - adds r3, r1, r0 - b _0807DEB0 -_0807DEA4: - movs r0, #0xfc - ands r0, r3 - ldrb r2, [r4, #0x14] - lsrs r1, r2, #1 - adds r3, r0, r1 - strb r2, [r4, #0xf] -_0807DEB0: - adds r0, r4, #0 - adds r0, #0x58 - ldrb r0, [r0] - cmp r3, r0 - beq _0807DEC2 - adds r0, r4, #0 - adds r1, r3, #0 - bl InitAnimationForceUpdate -_0807DEC2: - adds r0, r4, #0 - adds r0, #0x82 - ldrh r1, [r0] - movs r0, #4 - ands r0, r1 - movs r1, #1 - cmp r0, #0 - beq _0807DED4 - movs r1, #2 -_0807DED4: - adds r0, r4, #0 - bl sub_080042BA - pop {r4, pc} diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c index 8d3c5892..37d476e2 100644 --- a/src/code_0807CC3C.c +++ b/src/code_0807CC3C.c @@ -2,14 +2,46 @@ #include "structures.h" #include "functions.h" #include "script.h" +#include "entity.h" extern u8 gUnk_0811E514[]; void sub_0807DF38(void); extern void sub_0801C4A0(u32); -void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) -{ +void sub_0807DE80(Entity* entity) { + u32 local1; + u16 local2; + + u32 temp; + + local2 = entity->field_0x80.HWORD; + if (local2 < 8) { + if (entity->field_0x82.HWORD & 1) { + u32 t1, t2; + t1 = local2 & 0xfc; + t2 = entity->field_0xf >> 1; + local2 = t1 + t2; + } else { + u32 t1, t2; + t1 = local2 & 0xfc; + t2 = entity->animationState >> 1; + local2 = t1 + t2; + entity->field_0xf = entity->animationState; + } + } + if (local2 != entity->animIndex) { + InitAnimationForceUpdate(entity, local2); + } + temp = entity->field_0x82.HWORD & 4; + local1 = 1; + if (temp) { + local1 = 2; + } + sub_080042BA(entity, local1); +} + +void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) { int temp; s32 t0, t1; @@ -22,7 +54,7 @@ void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 t1 = context->unk_20.HALF.HI - entity->y.HALF.HI; temp = sub_080045DA(t0, t1); entity->direction = temp; - entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp <<0x18)>>0x1c]; + entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp << 0x18) >> 0x1c]; } void sub_0807DF28(void) {