diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 25ec2cc28..c8fb45942 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,418 +5,6 @@ .text - thumb_func_start sub_8093AF0 -@ void sub_8093AF0(struct npc_state *fieldObject, struct obj *object, u8 direction) -sub_8093AF0: @ 8093AF0 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x4 - adds r6, r0, 0 - mov r8, r1 - lsls r5, r2, 24 - lsrs r5, 24 - ldrh r1, [r6, 0x10] - mov r0, sp - strh r1, [r0] - ldrh r0, [r6, 0x12] - mov r4, sp - adds r4, 0x2 - strh r0, [r4] - adds r0, r6, 0 - adds r1, r5, 0 - bl FieldObjectSetDirection - adds r0, r5, 0 - mov r1, sp - adds r2, r4, 0 - bl MoveCoords - mov r0, sp - movs r2, 0 - ldrsh r1, [r0, r2] - movs r0, 0 - ldrsh r2, [r4, r0] - adds r0, r6, 0 - bl npc_coords_shift - mov r0, r8 - adds r1, r5, 0 - bl sub_80976DC - mov r2, r8 - adds r2, 0x2C - ldrb r1, [r2] - movs r0, 0x41 - negs r0, r0 - ands r0, r1 - strb r0, [r2] - ldrb r0, [r6] - movs r1, 0x4 - orrs r0, r1 - strb r0, [r6] - movs r0, 0x1 - mov r1, r8 - strh r0, [r1, 0x32] - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_8093AF0 - - thumb_func_start sub_8093B60 -@ void sub_8093B60(struct npc_state *fieldObject, struct obj *object, u8 direction) -sub_8093B60: @ 8093B60 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - lsls r2, 24 - lsrs r2, 24 - bl sub_8093AF0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl get_go_image_anim_num - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl npc_apply_anim_looping - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8093B60 - - thumb_func_start an_walk_any_2 -@ bool8 an_walk_any_2(struct npc_state *fieldObject, struct obj *object) -an_walk_any_2: @ 8093B8C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl sub_80976EC - lsls r0, 24 - cmp r0, 0 - bne _08093BA2 - movs r0, 0 - b _08093BBE -_08093BA2: - adds r0, r4, 0 - bl npc_coords_shift_still - ldrb r0, [r4] - movs r1, 0x8 - orrs r0, r1 - strb r0, [r4] - adds r2, r5, 0 - adds r2, 0x2C - ldrb r0, [r2] - movs r1, 0x40 - orrs r0, r1 - strb r0, [r2] - movs r0, 0x1 -_08093BBE: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end an_walk_any_2 - - thumb_func_start sub_8093BC4 -sub_8093BC4: @ 8093BC4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x7 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093BE4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093BC4 - - thumb_func_start sub_8093BE4 -sub_8093BE4: @ 8093BE4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093BF6 - movs r0, 0 - b _08093BFC -_08093BF6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093BFC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093BE4 - - thumb_func_start sub_8093C04 -sub_8093C04: @ 8093C04 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x8 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093C24 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093C04 - - thumb_func_start sub_8093C24 -sub_8093C24: @ 8093C24 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093C36 - movs r0, 0 - b _08093C3C -_08093C36: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093C3C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093C24 - - thumb_func_start sub_8093C44 -sub_8093C44: @ 8093C44 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x5 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093C64 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093C44 - - thumb_func_start sub_8093C64 -sub_8093C64: @ 8093C64 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093C76 - movs r0, 0 - b _08093C7C -_08093C76: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093C7C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093C64 - - thumb_func_start sub_8093C84 -sub_8093C84: @ 8093C84 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x6 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093CA4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093C84 - - thumb_func_start sub_8093CA4 -sub_8093CA4: @ 8093CA4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093CB6 - movs r0, 0 - b _08093CBC -_08093CB6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093CBC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093CA4 - - thumb_func_start sub_8093CC4 -@ bool8 sub_8093CC4(struct npc_state *fieldObject, struct obj *object) -sub_8093CC4: @ 8093CC4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093CE4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093CC4 - - thumb_func_start sub_8093CE4 -@ bool8 sub_8093CE4(struct npc_state *fieldObject, struct obj *object) -sub_8093CE4: @ 8093CE4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093CF6 - movs r0, 0 - b _08093CFC -_08093CF6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093CFC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093CE4 - - thumb_func_start sub_8093D04 -sub_8093D04: @ 8093D04 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x2 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093D24 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093D04 - - thumb_func_start sub_8093D24 -sub_8093D24: @ 8093D24 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093D36 - movs r0, 0 - b _08093D3C -_08093D36: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093D3C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093D24 - - thumb_func_start sub_8093D44 -sub_8093D44: @ 8093D44 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x3 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093D64 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093D44 - - thumb_func_start sub_8093D64 -sub_8093D64: @ 8093D64 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093D76 - movs r0, 0 - b _08093D7C -_08093D76: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093D7C: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093D64 - - thumb_func_start sub_8093D84 -sub_8093D84: @ 8093D84 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x4 - bl sub_8093B60 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_8093DA4 - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8093D84 - - thumb_func_start sub_8093DA4 -sub_8093DA4: @ 8093DA4 - push {r4,lr} - adds r4, r1, 0 - bl an_walk_any_2 - lsls r0, 24 - cmp r0, 0 - bne _08093DB6 - movs r0, 0 - b _08093DBC -_08093DB6: - movs r0, 0x2 - strh r0, [r4, 0x32] - movs r0, 0x1 -_08093DBC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8093DA4 - thumb_func_start sub_8093DC4 sub_8093DC4: @ 8093DC4 push {r4,r5,lr} diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index e5e6fba70..85153f941 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -16,5 +16,7 @@ void npc_sync_anim_pause_bits(struct MapObject *); void oamt_npc_ministep_reset(struct Sprite *, u8, u8); u8 sub_8097F78(struct MapObject *); bool8 obj_npc_ministep(struct Sprite *sprite); +bool8 sub_80976EC(struct Sprite *sprite); +void sub_80976DC(struct Sprite *, u8); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index cd840ba70..bffce24ac 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -4194,3 +4194,64 @@ bool8 npc_obj_ministep_stop_on_arrival(struct MapObject *mapObject, struct Sprit } return FALSE; } + +void sub_8093AF0(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + 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); + sub_80976DC(sprite, direction); + sprite->animPaused = FALSE; + mapObject->mapobj_bit_2 = TRUE; + sprite->data2 = 1; +} + +void sub_8093B60(struct MapObject *mapObject, struct Sprite *sprite, u8 direction) +{ + sub_8093AF0(mapObject, sprite, direction); + npc_apply_anim_looping(mapObject, sprite, get_go_image_anim_num(mapObject->mapobj_unk_18)); +} + +bool8 an_walk_any_2(struct MapObject *mapObject, struct Sprite *sprite) +{ + if (sub_80976EC(sprite)) + { + npc_coords_shift_still(mapObject); + mapObject->mapobj_bit_3 = TRUE; + sprite->animPaused = TRUE; + return TRUE; + } + return FALSE; +} + +#define an_walk_any_2_macro(name, dirn) \ +static bool8 name##_2(struct MapObject *, struct Sprite *);\ +bool8 name(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + sub_8093B60(mapObject, sprite, dirn);\ + return name##_2(mapObject, sprite);\ +}\ +static bool8 name##_2(struct MapObject *mapObject, struct Sprite *sprite)\ +{\ + if (an_walk_any_2(mapObject, sprite))\ + {\ + sprite->data2 = 2;\ + return TRUE;\ + }\ + return FALSE;\ +} + +an_walk_any_2_macro(sub_8093BC4, 7) +an_walk_any_2_macro(sub_8093C04, 8) +an_walk_any_2_macro(sub_8093C44, 5) +an_walk_any_2_macro(sub_8093C84, 6) +an_walk_any_2_macro(sub_8093CC4, 1) +an_walk_any_2_macro(sub_8093D04, 2) +an_walk_any_2_macro(sub_8093D44, 3) +an_walk_any_2_macro(sub_8093D84, 4) +