From 7d58ce75ad421762f9820492d77b6b05c632f60b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 18:52:20 -0400 Subject: [PATCH] sub_8092C8C --- asm/field_map_obj.s | 103 -------------------------------------------- src/field_map_obj.c | 42 ++++++++++++++++-- 2 files changed, 38 insertions(+), 107 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 2c94181653..166383b240 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,109 +5,6 @@ .text - thumb_func_start sub_8092C8C -sub_8092C8C: @ 8092C8C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r7, r0, 0 - lsls r1, 16 - lsls r2, 16 - lsls r3, 24 - lsrs r3, 24 - mov r8, r3 - lsrs r0, r1, 16 - mov r9, r0 - asrs r6, r1, 16 - lsrs r0, r2, 16 - mov r10, r0 - asrs r5, r2, 16 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - bl IsCoordOutsideFieldObjectMovementRect - lsls r0, 24 - lsrs r0, 24 - negs r1, r0 - orrs r1, r0 - lsrs r4, r1, 31 - adds r0, r6, 0 - adds r1, r5, 0 - bl MapGridIsImpassableAt - lsls r0, 24 - cmp r0, 0 - bne _08092D04 - adds r0, r6, 0 - adds r1, r5, 0 - bl GetMapBorderIdAt - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - beq _08092D04 - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - mov r3, r8 - bl IsMetatileDirectionallyImpassable - lsls r0, 24 - cmp r0, 0 - bne _08092D04 - ldrb r0, [r7, 0x1] - lsrs r0, 7 - cmp r0, 0 - beq _08092D08 - mov r0, r8 - bl CanCameraMoveInDirection - cmp r0, 0 - bne _08092D08 -_08092D04: - movs r0, 0x2 - orrs r4, r0 -_08092D08: - ldrb r0, [r7, 0xB] - lsls r0, 28 - lsrs r0, 28 - mov r2, r9 - lsls r1, r2, 16 - asrs r6, r1, 16 - mov r2, r10 - lsls r1, r2, 16 - asrs r5, r1, 16 - adds r1, r6, 0 - adds r2, r5, 0 - bl IsZCoordMismatchAt - lsls r0, 24 - cmp r0, 0 - beq _08092D30 - movs r0, 0x4 - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08092D30: - adds r0, r7, 0 - adds r1, r6, 0 - adds r2, r5, 0 - bl CheckForCollisionBetweenFieldObjects - lsls r0, 24 - cmp r0, 0 - beq _08092D48 - movs r0, 0x8 - orrs r4, r0 - lsls r0, r4, 24 - lsrs r4, r0, 24 -_08092D48: - adds r0, r4, 0 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_8092C8C - thumb_func_start IsCoordOutsideFieldObjectMovementRect @ bool8 IsCoordOutsideFieldObjectMovementRect(struct npc_state *fieldObject, u16 x, u16 y) IsCoordOutsideFieldObjectMovementRect: @ 8092D58 diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 5ec5e68f49..a876797a41 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3658,18 +3658,52 @@ u8 npc_block_way(struct MapObject *mapObject, s16 x, s16 y, u32 dirn) direction = dirn; if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + { return 1; - else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) + } + if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction)) + { return 2; - else if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + } + if (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction)) + { return 2; - else if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + } + if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + { return 3; - else if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + } + if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + { return 4; + } return 0; } +u8 sub_8092C8C(struct MapObject *mapObject, s16 x, s16 y, u8 direction) +{ + u8 retval; + + retval = 0x00; + if (IsCoordOutsideFieldObjectMovementRect(mapObject, x, y)) + { + retval |= 1; + } + if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(mapObject, x, y, direction) || (mapObject->mapobj_bit_15 && !CanCameraMoveInDirection(direction))) + { + retval |= 2; + } + if (IsZCoordMismatchAt(mapObject->mapobj_unk_0B_0, x, y)) + { + retval |= 4; + } + if (CheckForCollisionBetweenFieldObjects(mapObject, x, y)) + { + retval |= 8; + } + return retval; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *);