diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 912d28077..cdec058de 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,70 +5,6 @@ .text - thumb_func_start CameraObjectReset1 -@ void CameraObjectReset1() -CameraObjectReset1: @ 808EE8C - push {lr} - bl FindCameraObject - adds r2, r0, 0 - cmp r2, 0 - beq _0808EEA4 - movs r0, 0 - strh r0, [r2, 0x30] - ldr r1, [r2, 0x1C] - adds r0, r2, 0 - bl _call_via_r1 -_0808EEA4: - pop {r0} - bx r0 - thumb_func_end CameraObjectReset1 - - thumb_func_start CameraObjectSetFollowedObjectId -@ void CameraObjectSetFollowedObjectId(u8 objectId) -CameraObjectSetFollowedObjectId: @ 808EEA8 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl FindCameraObject - cmp r0, 0 - beq _0808EEBC - strh r4, [r0, 0x2E] - bl CameraObjectReset1 -_0808EEBC: - pop {r4} - pop {r0} - bx r0 - thumb_func_end CameraObjectSetFollowedObjectId - - thumb_func_start CameraObjectGetFollowedObjectId -@ u8 CameraObjectGetFollowedObjectId() -CameraObjectGetFollowedObjectId: @ 808EEC4 - push {lr} - bl FindCameraObject - cmp r0, 0 - beq _0808EED6 - ldrh r0, [r0, 0x2E] - lsls r0, 24 - lsrs r0, 24 - b _0808EED8 -_0808EED6: - movs r0, 0x40 -_0808EED8: - pop {r1} - bx r1 - thumb_func_end CameraObjectGetFollowedObjectId - - thumb_func_start CameraObjectReset2 -@ void CameraObjectReset2() -CameraObjectReset2: @ 808EEDC - push {lr} - bl FindCameraObject - movs r1, 0x2 - strh r1, [r0, 0x30] - pop {r0} - bx r0 - thumb_func_end CameraObjectReset2 - thumb_func_start sub_808EEEC sub_808EEEC: @ 808EEEC push {r4-r7,lr} diff --git a/src/field_map_obj.c b/src/field_map_obj.c index f600db934..40b12b1b3 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -1388,7 +1388,7 @@ void ObjectCB_CameraObject(struct Sprite *sprite) sprite->data3 = 0; } -/*static*/ struct Sprite *FindCameraObject(void) +static struct Sprite *FindCameraObject(void) { u8 spriteId; @@ -1401,3 +1401,44 @@ void ObjectCB_CameraObject(struct Sprite *sprite) } return NULL; } + +void CameraObjectReset1(void) +{ + struct Sprite *cameraObject; + + cameraObject = FindCameraObject(); + if (cameraObject != NULL) + { + cameraObject->data1 = 0; + cameraObject->callback(cameraObject); + } +} + +void CameraObjectSetFollowedObjectId(u8 objectId) +{ + struct Sprite *cameraObject; + + cameraObject = FindCameraObject(); + if (cameraObject != NULL) + { + cameraObject->data0 = objectId; + CameraObjectReset1(); + } +} + +u8 CameraObjectGetFollowedObjectId(void) +{ + struct Sprite *cameraObject; + + cameraObject = FindCameraObject(); + if (cameraObject == NULL) + { + return MAX_SPRITES; + } + return cameraObject->data0; +} + +void CameraObjectReset2(void) +{ + FindCameraObject()->data1 = 2; +}