diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 342b98927b..95347c52dc 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,156 +5,6 @@ .text - thumb_func_start sub_808F6B8 -sub_808F6B8: @ 808F6B8 - push {r4-r7,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - lsls r2, 16 - asrs r6, r2, 16 - lsls r3, 16 - asrs r7, r3, 16 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808F6F4 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0808F70E - b _0808F70C -_0808F6F4: - cmp r0, 0x3 - bne _0808F70E - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0808F70E -_0808F70C: - movs r0, 0x2 -_0808F70E: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F6B8 - - thumb_func_start sub_808F714 -sub_808F714: @ 808F714 - push {r4-r7,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - lsls r2, 16 - asrs r6, r2, 16 - lsls r3, 16 - asrs r7, r3, 16 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F750 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _0808F76A - b _0808F768 -_0808F750: - cmp r0, 0x4 - bne _0808F76A - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F76A -_0808F768: - movs r0, 0x1 -_0808F76A: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F714 - - thumb_func_start sub_808F770 -sub_808F770: @ 808F770 - push {r4-r7,lr} - lsls r0, 16 - asrs r4, r0, 16 - lsls r1, 16 - asrs r5, r1, 16 - lsls r2, 16 - asrs r6, r2, 16 - lsls r3, 16 - asrs r7, r3, 16 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetRegularRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F7AC - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetEastWestRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bne _0808F7C6 - b _0808F7C4 -_0808F7AC: - cmp r0, 0x3 - bne _0808F7C6 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl GetNorthSouthRunningPastFacingDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _0808F7C6 -_0808F7C4: - movs r0, 0x1 -_0808F7C6: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_808F770 - thumb_func_start sub_808F7CC sub_808F7CC: @ 808F7CC push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 4b92a792dc..00ccb44939 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1903,3 +1903,75 @@ u8 GetNorthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) } return direction; } + +u8 GetNorthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_SOUTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_WEST) + { + direction = DIR_NORTH; + } + } + else if (direction == DIR_WEST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_SOUTH) + { + direction = DIR_NORTH; + } + } + return direction; +} + +u8 GetSouthEastRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_EAST) + { + direction = DIR_SOUTH; + } + } + else if (direction == DIR_EAST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = DIR_SOUTH; + } + } + return direction; +} + +u8 GetSouthWestRunningPastFacingDirection(s16 dx1, s16 dy1, s16 dx2, s16 dy2) +{ + u8 direction; + + direction = GetRegularRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = GetEastWestRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_WEST) + { + direction = DIR_SOUTH; + } + } + else if (direction == DIR_WEST) + { + direction = GetNorthSouthRunningPastFacingDirection(dx1, dy1, dx2, dy2); + if (direction == DIR_NORTH) + { + direction = DIR_SOUTH; + } + } + return direction; +}