From 44e590add0b4f630397b9f9e206a9a66d1a41ccc Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 16 Sep 2017 22:15:54 -0400 Subject: [PATCH] sub_8093038 --- asm/field_map_obj.s | 82 ------------------------------------------ include/field_camera.h | 12 +++++++ src/field_map_obj.c | 27 ++++++++++++++ 3 files changed, 39 insertions(+), 82 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index a1d549266d..d01dce5128 100755 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,88 +5,6 @@ .text - thumb_func_start sub_8093038 -sub_8093038: @ 8093038 - push {r4-r7,lr} - adds r7, r2, 0 - mov r12, r3 - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 16 - lsrs r6, r1, 16 - ldr r0, =gUnknown_03005DEC - ldrh r0, [r0] - negs r0, r0 - ldr r1, =gUnknown_03005DD0 - ldr r2, [r1, 0x10] - subs r0, r2 - lsls r0, 16 - lsrs r3, r0, 16 - ldr r0, =gUnknown_03005DE8 - ldrh r0, [r0] - negs r0, r0 - ldr r1, [r1, 0x14] - subs r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r2, 0 - ble _08093072 - lsls r0, r3, 16 - movs r3, 0x80 - lsls r3, 13 - adds r0, r3 - lsrs r3, r0, 16 -_08093072: - cmp r2, 0 - bge _0809307E - lsls r0, r3, 16 - ldr r2, =0xfff00000 - adds r0, r2 - lsrs r3, r0, 16 -_0809307E: - cmp r1, 0 - ble _0809308C - lsls r0, r4, 16 - movs r2, 0x80 - lsls r2, 13 - adds r0, r2 - lsrs r4, r0, 16 -_0809308C: - cmp r1, 0 - bge _08093098 - lsls r0, r4, 16 - ldr r1, =0xfff00000 - adds r0, r1 - lsrs r4, r0, 16 -_08093098: - ldr r2, =gSaveBlock1Ptr - ldr r0, [r2] - ldrh r1, [r0] - lsls r0, r5, 16 - asrs r0, 16 - subs r0, r1 - lsls r0, 4 - lsls r1, r3, 16 - asrs r1, 16 - adds r1, r0 - strh r1, [r7] - ldr r0, [r2] - ldrh r1, [r0, 0x2] - lsls r0, r6, 16 - asrs r0, 16 - subs r0, r1 - lsls r0, 4 - lsls r1, r4, 16 - asrs r1, 16 - adds r1, r0 - mov r2, r12 - strh r1, [r2] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8093038 - thumb_func_start sub_80930E0 sub_80930E0: @ 80930E0 push {r4-r6,lr} diff --git a/include/field_camera.h b/include/field_camera.h index 48c182c8eb..9fbaac6a28 100644 --- a/include/field_camera.h +++ b/include/field_camera.h @@ -3,6 +3,18 @@ // Exported type declarations +struct CameraObject +{ + void (*callback)(struct CameraObject *); + u32 unk4; + s32 unk8; + s32 unkC; + s32 x; + s32 y; +}; + +extern struct CameraObject gUnknown_03005DD0; + // Exported RAM declarations extern u16 gUnknown_03005DEC; diff --git a/src/field_map_obj.c b/src/field_map_obj.c index b8be79d738..d4793b0a7a 100755 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -3836,6 +3836,33 @@ void sub_8092FF0(s16 x, s16 y, s16 *dest_x, s16 *dest_y) *dest_y -= gUnknown_03005DE8; } +void sub_8093038(s16 x, s16 y, s16 *dest_x, s16 *dest_y) +{ + s16 dx; + s16 dy; + + dx = -gUnknown_03005DEC - gUnknown_03005DD0.x; + dy = -gUnknown_03005DE8 - gUnknown_03005DD0.y; + if (gUnknown_03005DD0.x > 0) + { + dx += 0x10; + } + if (gUnknown_03005DD0.x < 0) + { + dx -= 0x10; + } + if (gUnknown_03005DD0.y > 0) + { + dy += 0x10; + } + if (gUnknown_03005DD0.y < 0) + { + dy -= 0x10; + } + *dest_x = ((x - gSaveBlock1Ptr->pos.x) << 4) + dx; + *dest_y = ((y - gSaveBlock1Ptr->pos.y) << 4) + dy; +} + asm(".section .text.get_face_direction_anim_id"); void FieldObjectClearAnimIfSpecialAnimActive(struct MapObject *);