diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index f0bb2ed2e3..b433e1aa00 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,148 +5,6 @@ .text - thumb_func_start FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive -@ bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct npc_state *fieldObject) -FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive: @ 809318C - push {lr} - ldrb r1, [r0] - movs r0, 0x42 - ands r0, r1 - cmp r0, 0 - bne _0809319C - movs r0, 0 - b _0809319E -_0809319C: - movs r0, 0x1 -_0809319E: - pop {r1} - bx r1 - thumb_func_end FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive - - thumb_func_start FieldObjectIsSpecialAnimActive -@ bool8 FieldObjectIsSpecialAnimActive(struct npc_state *fieldObject) -FieldObjectIsSpecialAnimActive: @ 80931A4 - push {lr} - adds r1, r0, 0 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - bge _080931BA - ldrb r0, [r1, 0x1C] - cmp r0, 0xFF - beq _080931BA - movs r0, 0x1 - b _080931BC -_080931BA: - movs r0, 0 -_080931BC: - pop {r1} - bx r1 - thumb_func_end FieldObjectIsSpecialAnimActive - - thumb_func_start FieldObjectSetSpecialAnim -@ bool8 FieldObjectSetSpecialAnim(struct npc_state *fieldObject, u8 animId) -FieldObjectSetSpecialAnim: @ 80931C0 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - bl FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0 - bne _08093200 - adds r0, r4, 0 - bl npc_sync_anim_pause_bits - strb r5, [r4, 0x1C] - ldrb r0, [r4] - movs r1, 0x40 - orrs r0, r1 - movs r1, 0x7F - ands r0, r1 - strb r0, [r4] - ldr r2, =gSprites - ldrb r1, [r4, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r6, [r0, 0x32] - movs r0, 0 - b _08093202 - .pool -_08093200: - movs r0, 0x1 -_08093202: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end FieldObjectSetSpecialAnim - - thumb_func_start FieldObjectForceSetSpecialAnim -@ void FieldObjectForceSetSpecialAnim(struct npc_state *fieldObject, u8 animId) -FieldObjectForceSetSpecialAnim: @ 8093208 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r4, r1, 24 - lsrs r4, 24 - bl FieldObjectClearAnimIfSpecialAnimActive - adds r0, r5, 0 - adds r1, r4, 0 - bl FieldObjectSetSpecialAnim - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldObjectForceSetSpecialAnim - - thumb_func_start FieldObjectClearAnimIfSpecialAnimActive -@ void FieldObjectClearAnimIfSpecialAnimActive(struct npc_state *fieldObject) -FieldObjectClearAnimIfSpecialAnimActive: @ 8093224 - push {lr} - adds r1, r0, 0 - ldrb r0, [r1] - lsls r0, 25 - cmp r0, 0 - bge _08093236 - adds r0, r1, 0 - bl FieldObjectClearAnim -_08093236: - pop {r0} - bx r0 - thumb_func_end FieldObjectClearAnimIfSpecialAnimActive - - thumb_func_start FieldObjectClearAnim -@ void FieldObjectClearAnim(struct npc_state *fieldObject) -FieldObjectClearAnim: @ 809323C - movs r1, 0xFF - strb r1, [r0, 0x1C] - ldrb r2, [r0] - movs r1, 0x41 - negs r1, r1 - ands r1, r2 - movs r2, 0x7F - ands r1, r2 - strb r1, [r0] - ldr r3, =gSprites - ldrb r2, [r0, 0x4] - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r3 - movs r2, 0 - strh r2, [r1, 0x30] - ldrb r1, [r0, 0x4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - strh r2, [r0, 0x32] - bx lr - .pool - thumb_func_end FieldObjectClearAnim - - .section .text.get_simple_go_anim_id - thumb_func_start GetSimpleGoAnimId @ u8 GetSimpleGoAnimId(u8 direction) GetSimpleGoAnimId: @ 809335C diff --git a/include/map_obj_8097404.h b/include/map_obj_8097404.h index e3b2b1efcf..8517391148 100644 --- a/include/map_obj_8097404.h +++ b/include/map_obj_8097404.h @@ -11,5 +11,6 @@ // Exported ROM declarations void sub_8097AC8(struct Sprite *); +void npc_sync_anim_pause_bits(struct MapObject *); #endif //GUARD_MAP_OBJ_8097404_H diff --git a/ld_script.txt b/ld_script.txt index 0217fe0fb2..2c5eb31a97 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -96,8 +96,6 @@ SECTIONS { asm/field_player_avatar.o(.text); src/field_map_obj.o(.text); asm/field_map_obj.o(.text); - src/field_map_obj.o(.text.get_face_direction_anim_id); - asm/field_map_obj.o(.text.get_simple_go_anim_id); asm/field_ground_effect.o(.text); asm/map_obj_8097404.o(.text); asm/field_message_box.o(.text); diff --git a/src/field_map_obj.c b/src/field_map_obj.c index fd03082fb1..2fd6f57e51 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -125,6 +125,8 @@ void FieldObjectUpdateSubpriority(struct MapObject *, struct Sprite *); bool8 IsCoordOutsideFieldObjectMovementRect(struct MapObject2 *fieldObject, s16 x, s16 y); bool8 IsMetatileDirectionallyImpassable(struct MapObject *, s16, s16, u8); bool8 CheckForCollisionBetweenFieldObjects(struct MapObject *, s16, s16); +void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); +void FieldObjectClearAnim(struct MapObject *); // ROM data @@ -3902,9 +3904,62 @@ void FieldObjectMoveDestCoords(struct MapObject *mapObject, u32 dirn, s16 *x, s1 MoveCoords(direction, x, y); } -asm(".section .text.get_face_direction_anim_id"); +// file boundary? -void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *); +bool8 FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_1 || mapObject->mapobj_bit_6) + { + return TRUE; + } + return FALSE; +} + +bool8 FieldObjectIsSpecialAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6 && mapObject->mapobj_unk_1C != 0xFF) + { + return TRUE; + } + return FALSE; +} + +bool8 FieldObjectSetSpecialAnim(struct MapObject *mapObject, u8 specialAnimId) +{ + if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(mapObject)) + { + return TRUE; + } + npc_sync_anim_pause_bits(mapObject); + mapObject->mapobj_unk_1C = specialAnimId; + mapObject->mapobj_bit_6 = TRUE; + mapObject->mapobj_bit_7 = FALSE; + gSprites[mapObject->spriteId].data2 = 0; + return FALSE; +} + +void FieldObjectForceSetSpecialAnim(struct MapObject *mapObject, u8 specialAnimId) +{ + FieldObjectClearAnimIfSpecialAnimActive(mapObject); + FieldObjectSetSpecialAnim(mapObject, specialAnimId); +} + +void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *mapObject) +{ + if (mapObject->mapobj_bit_6) + { + FieldObjectClearAnim(mapObject); + } +} + +void FieldObjectClearAnim(struct MapObject *mapObject) +{ + mapObject->mapobj_unk_1C = 0xFF; + mapObject->mapobj_bit_6 = FALSE; + mapObject->mapobj_bit_7 = FALSE; + gSprites[mapObject->spriteId].data1 = 0; + gSprites[mapObject->spriteId].data2 = 0; +} u8 FieldObjectCheckIfSpecialAnimFinishedOrInactive(struct MapObject *mapObject) {