state_to_direction memes

This commit is contained in:
PikalaxALT 2017-09-16 23:05:53 -04:00
parent 0e3dbf3235
commit 5f189fa53b
3 changed files with 21 additions and 53 deletions

View File

@ -5,58 +5,6 @@
.text
thumb_func_start zffu_offset_calc
zffu_offset_calc: @ 8093834
lsls r0, 24
lsls r1, 24
lsrs r1, 24
ldr r2, =gUnknown_0850DC2F
lsrs r0, 22
subs r0, 0x5
adds r1, r0
adds r1, r2
ldrb r0, [r1]
bx lr
.pool
thumb_func_end zffu_offset_calc
thumb_func_start state_to_direction
state_to_direction: @ 809384C
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
lsls r1, 24
lsrs r1, 24
adds r0, r1, 0
lsls r2, 24
lsrs r2, 24
cmp r1, 0
beq _0809386C
cmp r2, 0
beq _0809386C
cmp r1, 0x4
bhi _0809386C
cmp r2, 0x4
bls _08093870
_0809386C:
movs r0, 0
b _08093882
_08093870:
adds r1, r2, 0
bl zffu_offset_calc
ldr r2, =gUnknown_0850DC3F
lsls r1, r4, 2
subs r1, 0x5
adds r0, r1
adds r0, r2
ldrb r0, [r0]
_08093882:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end state_to_direction
thumb_func_start FieldObjectExecSpecialAnim
@ void FieldObjectExecSpecialAnim(struct npc_state *fieldObject, struct obj *object)
FieldObjectExecSpecialAnim: @ 809388C

View File

@ -36,7 +36,9 @@ extern const u8 gUnknown_0850D8E8[4];
extern bool8 (*const gUnknown_0850DA64[])(struct MapObject *, struct Sprite *, u8, bool8(u8));
extern bool8 (*const gUnknown_0850DB5C[])(u8);
extern bool8 (*const gUnknown_0850DB6C[])(u8);
extern struct Coords16 gUnknown_0850DB7C[4];
extern const struct Coords16 gUnknown_0850DB7C[4];
extern const u8 gUnknown_0850DC2F[4][4];
extern const u8 gUnknown_0850DC3F[4][4];
extern const u8 gUnknown_0850DBA0[5];

View File

@ -4072,3 +4072,21 @@ u8 GetOppositeDirection(u8 direction)
}
return directions[direction - 1];
}
u32 zffu_offset_calc(u8 a0, u8 a1)
{
return gUnknown_0850DC2F[a0 - 1][a1 - 1];
}
u32 state_to_direction(u8 a0, u32 a1, u32 a2)
{
u32 zffuOffset;
u8 a1_2 = a1;
u8 a2_2 = a2;
if (a1_2 == 0 || a2_2 == 0 || a1_2 > DIR_EAST || a2_2 > DIR_EAST)
{
return 0;
}
zffuOffset = zffu_offset_calc(a1_2, a2);
return gUnknown_0850DC3F[a0 - 1][zffuOffset - 1];
}