diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 1675489e1..f128ba9a4 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,174 +5,6 @@ .text - thumb_func_start FieldObjectCB_RandomlyLookSouthOrWest -FieldObjectCB_RandomlyLookSouthOrWest: @ 8090550 - push {lr} - adds r1, r0, 0 - movs r0, 0x2E - ldrsh r2, [r1, r0] - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - ldr r2, =gMapObjects - adds r0, r2 - ldr r2, =sub_8090574 - bl FieldObjectStep - pop {r0} - bx r0 - .pool - thumb_func_end FieldObjectCB_RandomlyLookSouthOrWest - - thumb_func_start sub_8090574 -sub_8090574: @ 8090574 - push {r4,lr} - ldr r3, =gUnknown_0850D80C - movs r4, 0x30 - ldrsh r2, [r1, r4] - lsls r2, 2 - adds r2, r3 - ldr r2, [r2] - bl _call_via_r2 - lsls r0, 24 - lsrs r0, 24 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090574 - - thumb_func_start sub_8090594 -sub_8090594: @ 8090594 - push {r4,lr} - adds r4, r1, 0 - bl npc_reset - movs r0, 0x1 - strh r0, [r4, 0x30] - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8090594 - - thumb_func_start sub_80905A8 -sub_80905A8: @ 80905A8 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r0, [r4, 0x18] - lsls r0, 28 - lsrs r0, 28 - bl GetFaceDirectionAnimId - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldObjectSetRegularAnim - movs r0, 0x2 - strh r0, [r5, 0x30] - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80905A8 - - thumb_func_start sub_80905D4 -sub_80905D4: @ 80905D4 - push {r4-r7,lr} - adds r6, r0, 0 - adds r7, r1, 0 - bl FieldObjectExecRegularAnim - lsls r0, 24 - cmp r0, 0 - beq _0809060A - ldr r4, =gUnknown_0850D6EC - bl Random - movs r5, 0x3 - adds r1, r5, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - movs r0, 0 - ldrsh r1, [r1, r0] - adds r0, r7, 0 - bl SetFieldObjectStepTimer - ldrb r1, [r6] - movs r0, 0x3 - negs r0, r0 - ands r0, r1 - strb r0, [r6] - strh r5, [r7, 0x30] -_0809060A: - movs r0, 0 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80905D4 - - thumb_func_start sub_8090618 -sub_8090618: @ 8090618 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r0, r5, 0 - bl RunFieldObjectStepTimer - lsls r0, 24 - cmp r0, 0 - bne _08090636 - adds r0, r4, 0 - bl FieldObjectIsTrainerAndCloseToPlayer - lsls r0, 24 - cmp r0, 0 - beq _0809063E -_08090636: - movs r0, 0x4 - strh r0, [r5, 0x30] - movs r0, 0x1 - b _08090640 -_0809063E: - movs r0, 0 -_08090640: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_8090618 - - thumb_func_start sub_8090648 -sub_8090648: @ 8090648 - push {r4,r5,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r5, r1, 0 - ldr r1, =gUnknown_0850D820 - mov r0, sp - movs r2, 0x2 - bl memcpy - adds r0, r4, 0 - movs r1, 0x5 - bl GetRunningPastFacingDirection - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0 - bne _08090678 - bl Random - movs r1, 0x1 - ands r1, r0 - mov r2, sp - adds r0, r2, r1 - ldrb r1, [r0] -_08090678: - adds r0, r4, 0 - bl FieldObjectSetDirection - movs r0, 0x1 - strh r0, [r5, 0x30] - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_8090648 - thumb_func_start FieldObjectCB_RandomlyLookSouthOrEast FieldObjectCB_RandomlyLookSouthOrEast: @ 8090690 push {lr} diff --git a/include/data3.h b/include/data3.h index debca9b73..a1aa86279 100755 --- a/include/data3.h +++ b/include/data3.h @@ -24,5 +24,6 @@ extern const u8 gUnknown_0850D770[2]; // {DIR_SOUTH, DIR_NORTH} extern const u8 gUnknown_0850D790[2]; // {DIR_WEST, DIR_EAST} extern const u8 gUnknown_0850D7F0[2]; // {DIR_NORTH, DIR_WEST} extern const u8 gUnknown_0850D808[2]; // {DIR_NORTH, DIR_EAST} +extern const u8 gUnknown_0850D820[2]; // {DIR_SOUTH, DIR_WEST} #endif //POKEEMERALD_DATA3_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 1228d93be..639267890 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -2592,3 +2592,56 @@ bool8 sub_8090508 (struct MapObject *mapObject, struct Sprite *sprite) sprite->data1 = 1; return TRUE; } + +field_object_step(RandomlyLookSouthOrWest, gUnknown_0850D80C) + +bool8 sub_8090594 (struct MapObject *mapObject, struct Sprite *sprite) +{ + npc_reset(mapObject, sprite); + sprite->data1 = 1; + return TRUE; +} + +bool8 sub_80905A8 (struct MapObject *mapObject, struct Sprite *sprite) +{ + FieldObjectSetRegularAnim(mapObject, sprite, GetFaceDirectionAnimId(mapObject->mapobj_unk_18)); + sprite->data1 = 2; + return TRUE; +} + +bool8 sub_80905D4 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (FieldObjectExecRegularAnim(mapObject, sprite)) + { + SetFieldObjectStepTimer(sprite, gUnknown_0850D6EC[Random() & 0x03]); + mapObject->mapobj_bit_1 = FALSE; + sprite->data1 = 3; + } + return FALSE; +} + +bool8 sub_8090618 (struct MapObject *mapObject, struct Sprite *sprite) +{ + if (RunFieldObjectStepTimer(sprite) || FieldObjectIsTrainerAndCloseToPlayer(mapObject)) + { + sprite->data1 = 4; + return TRUE; + } + return FALSE; +} + +bool8 sub_8090648 (struct MapObject *mapObject, struct Sprite *sprite) +{ + u8 directions[2]; + u8 direction; + + memcpy(directions, gUnknown_0850D820, sizeof gUnknown_0850D820); + direction = GetRunningPastFacingDirection(mapObject, RUNFOLLOW_SOUTH_WEST); + if (direction == 0) + { + direction = directions[Random() & 0x01]; + } + FieldObjectSetDirection(mapObject, direction); + sprite->data1 = 1; + return TRUE; +}