diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 61d3ba1522..9b26899518 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,84 +5,6 @@ .text - thumb_func_start npc_apply_direction -@ void npc_apply_direction(struct npc_state *fieldObject, struct obj *object, u8 direction, u8 speed) -npc_apply_direction: @ 8093990 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - adds r7, r0, 0 - mov r8, r1 - adds r4, r2, 0 - adds r6, r3, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r6, 24 - lsrs r6, 24 - ldrh r1, [r7, 0x10] - mov r0, sp - strh r1, [r0] - ldrh r0, [r7, 0x12] - mov r5, sp - adds r5, 0x2 - strh r0, [r5] - adds r0, r7, 0 - adds r1, r4, 0 - bl FieldObjectSetDirection - adds r0, r4, 0 - mov r1, sp - adds r2, r5, 0 - bl MoveCoords - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r5, r0] - adds r0, r7, 0 - bl npc_coords_shift - mov r0, r8 - adds r1, r4, 0 - adds r2, r6, 0 - bl oamt_npc_ministep_reset - mov r4, r8 - adds r4, 0x2C - ldrb r1, [r4] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r4] - ldr r0, =gUnknown_020375B8 - ldr r0, [r0] - cmp r0, 0 - beq _08093A0E - adds r0, r7, 0 - bl sub_8097F78 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x10 - beq _08093A0E - ldrb r0, [r4] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r4] -_08093A0E: - ldrb r0, [r7] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r7] - movs r0, 0x1 - mov r1, r8 - strh r0, [r1, 0x32] - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end npc_apply_direction - thumb_func_start do_go_anim @ void do_go_anim(struct npc_state *fieldObject, struct obj *object, u8 direction, u8 speed) do_go_anim: @ 8093A2C diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index 8517391148..afa7a3baeb 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -8,9 +8,12 @@ // Exported type declarations // Exported RAM declarations +extern void *gUnknown_020375B8; // Exported ROM declarations void sub_8097AC8(struct Sprite *); void npc_sync_anim_pause_bits(struct MapObject *); +void oamt_npc_ministep_reset(struct Sprite *, u8, u8); +u8 sub_8097F78(struct MapObject *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 80f628bb59..4f2a359e49 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4154,3 +4154,23 @@ bool8 sub_8093980(struct MapObject *mapObject, struct Sprite *sprite) an_look_any(mapObject, sprite, DIR_EAST); return TRUE; } + +void npc_apply_direction(struct MapObject *mapObject, struct Sprite *sprite, u8 direction, u8 speed) +{ + s16 x; + s16 y; + + x = mapObject->coords2.x; + y = mapObject->coords2.y; + FieldObjectSetDirection(mapObject, direction); + MoveCoords(direction, &x, &y); + npc_coords_shift(mapObject, x, y); + oamt_npc_ministep_reset(sprite, direction, speed); + sprite->animPaused = FALSE; + if (gUnknown_020375B8 != NULL && sub_8097F78(mapObject) != 0x10) + { + sprite->animPaused = TRUE; + } + mapObject->mapobj_bit_2 = TRUE; + sprite->data2 = 1; +}