From 0e3dbf32350d41ff871bffcdb4700dc635b243b7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 23:03:04 -0400 Subject: [PATCH] GetOppositeDirection --- asm/field_map_obj.s | 30 ------------------------------ src/field_map_obj.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 5a7c4061b1..8066cfd1a1 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,36 +5,6 @@ .text - thumb_func_start GetOppositeDirection -@ u8 GetOppositeDirection(u8 direction) -GetOppositeDirection: @ 8093800 - push {r4,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r4, r0, 24 - ldr r1, =gUnknown_0850DC27 - mov r0, sp - movs r2, 0x8 - bl memcpy - subs r1, r4, 0x1 - lsls r0, r1, 24 - lsrs r0, 24 - cmp r0, 0x7 - bhi _08093828 - mov r2, sp - adds r0, r2, r1 - ldrb r0, [r0] - b _0809382A - .pool -_08093828: - adds r0, r4, 0 -_0809382A: - add sp, 0x8 - pop {r4} - pop {r1} - bx r1 - thumb_func_end GetOppositeDirection - thumb_func_start zffu_offset_calc zffu_offset_calc: @ 8093834 lsls r0, 24 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index d0673fdbe1..d17f77c1bb 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4058,3 +4058,17 @@ dirn2anim_2(sub_8093750, gUnknown_0850DC13); dirn2anim_2(sub_809377C, gUnknown_0850DC18); dirn2anim_2(sub_80937A8, gUnknown_0850DC1D); dirn2anim_2(d2s_08064034, gUnknown_0850DC22); + +extern const u8 gUnknown_0850DC27[8]; + +u8 GetOppositeDirection(u8 direction) +{ + u8 directions[sizeof gUnknown_0850DC27]; + + memcpy(directions, gUnknown_0850DC27, sizeof gUnknown_0850DC27); + if (direction < 1 || direction > (sizeof gUnknown_0850DC27)) + { + return direction; + } + return directions[direction - 1]; +}