From 4751e57f524d4abd184aaef6b2893b2d3ef6d49f Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Tue, 6 Dec 2022 19:24:37 +0100 Subject: [PATCH 1/5] wip doc keepon4 cam func and linked things --- include/functions.h | 3 +- include/z64camera.h | 66 ++-- include/z64player.h | 6 + src/code/z_camera.c | 302 +++++++++--------- src/code/z_camera_data.inc.c | 9 +- src/code/z_onepointdemo.c | 2 +- src/code/z_player_lib.c | 34 +- .../z_bg_mori_rakkatenjo.c | 3 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 6 +- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 3 +- .../actors/ovl_player_actor/z_player.c | 60 ++-- 11 files changed, 270 insertions(+), 224 deletions(-) diff --git a/include/functions.h b/include/functions.h index ad6eea2dff1..615a984871c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -664,8 +664,7 @@ s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 a s16 timer3); s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera); Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera); -void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, - UNK_TYPE arg6); +void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, s32 data4); s32 func_8005B198(void); s16 func_8005B1A4(Camera* camera); DamageTable* DamageTable_Get(s32 index); diff --git a/include/z64camera.h b/include/z64camera.h index 8129f56b705..37dde2ff0a0 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -118,6 +118,12 @@ #define CAM_VIEW_FOV (1 << 5) // camera->fov #define CAM_VIEW_ROLL (1 << 6) // camera->roll +#define CAM_SET_CAMERA_DATA_0 (1 << 0) +#define CAM_SET_CAMERA_DATA_1 (1 << 1) +#define CAM_SET_CAMERA_DATA_2 (1 << 2) +#define CAM_SET_CAMERA_DATA_3 (1 << 3) +#define CAM_SET_CAMERA_DATA_4 (1 << 4) + // All scenes using `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT` or `SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT` are expected // to have their first two bgCamInfo entries be the following: #define BGCAM_INDEX_TOGGLE_LOCKED 0 @@ -821,7 +827,7 @@ typedef struct { #define KEEPON3_FLAG_5 (1 << 5) #define KEEPON3_FLAG_7 (1 << 7) -#define CAM_FUNCDATA_KEEP3(yOffset, eyeDist, eyeDistNext, swingYawInit, swingYawFinal, swingPitchInit, swingPitchFinal, swingPitchAdj, fov, atLerpStepScale, yawUpdateRateTarget, interfaceField) \ +#define CAM_FUNCDATA_KEEP3(yOffset, eyeDist, eyeDistNext, swingYawInit, swingYawFinal, swingPitchInit, swingPitchFinal, swingPitchAdj, fov, atLerpStepScale, initTimer, interfaceField) \ { yOffset, CAM_DATA_Y_OFFSET }, \ { eyeDist, CAM_DATA_EYE_DIST }, \ { eyeDistNext, CAM_DATA_EYE_DIST_NEXT }, \ @@ -832,30 +838,46 @@ typedef struct { { swingPitchAdj, CAM_DATA_SWING_PITCH_ADJ }, \ { fov, CAM_DATA_FOV }, \ { atLerpStepScale, CAM_DATA_AT_LERP_STEP_SCALE }, \ - { yawUpdateRateTarget, CAM_DATA_YAW_UPDATE_RATE_TARGET }, \ + { initTimer, CAM_DATA_YAW_UPDATE_RATE_TARGET }, \ { interfaceField, CAM_DATA_INTERFACE_FIELD } typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ f32 unk_04; - /* 0x08 */ f32 unk_08; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ f32 unk_10; - /* 0x14 */ f32 unk_14; - /* 0x18 */ f32 unk_18; + /* 0x00 */ f32 yOffset; + /* 0x04 */ f32 eyeDist; + /* 0x08 */ f32 unk_08; // pitch related, angle in degrees + /* 0x0C */ f32 unk_0C; // yaw related, angle in degrees + /* 0x10 */ f32 atOffsetPlayerForwards; // distance to offset at by in the player's forwards direction + /* 0x14 */ f32 unk_14; // scale for stepping yaw and pitch of "at to eye" to target + /* 0x18 */ f32 fovTarget; /* 0x1C */ s16 interfaceField; - /* 0x1E */ s16 unk_1E; + /* 0x1E */ s16 initTimer; } KeepOn4ReadOnlyData; // size = 0x20 -typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ f32 unk_04; - /* 0x08 */ f32 unk_08; - /* 0x0C */ s16 unk_0C; - /* 0x0E */ s16 unk_0E; - /* 0x10 */ s16 unk_10; - /* 0x12 */ s16 unk_12; - /* 0x14 */ s16 unk_14; +typedef enum { + /* 1 */ KEEPON4_ITEM_TYPE_1=1, // drop fish from bottle and something with ruto's letter + /* 2 */ KEEPON4_ITEM_TYPE_2, // drink from bottle? + /* 3 */ KEEPON4_ITEM_TYPE_3, // use bottled fairy + /* 4 */ KEEPON4_ITEM_TYPE_4, // something with farore's wind, something with exchange items, catching things into bottles + /* 5 */ KEEPON4_ITEM_TYPE_5, // drop bugs and blue fire from bottle + /* 8 */ KEEPON4_ITEM_TYPE_8=8, // ??? get item after underwater? + /* 9 */ KEEPON4_ITEM_TYPE_9, // get item + /* 10 */ KEEPON4_ITEM_TYPE_10, // used farore's wind or nayru's love + /* 11 */ KEEPON4_ITEM_TYPE_11, // talking to navi? + /* 12 */ KEEPON4_ITEM_TYPE_12, // onepointdemo 9806 + /* 81 */ KEEPON4_ITEM_TYPE_81=81, // horse-related + /* 90 */ KEEPON4_ITEM_TYPE_90=90, // play ocarina (on its own)? + /* 91 */ KEEPON4_ITEM_TYPE_91 // play ocarina for an actor? +} KeepOn4_item_type; + +typedef struct { + /* 0x00 */ f32 atToEyeTargetStepYaw; + /* 0x04 */ f32 atToEyeTargetStepPitch; + /* 0x08 */ f32 unk_08; // unused + /* 0x0C */ s16 atToEyeTargetYaw; + /* 0x0E */ s16 atToEyeTargetPitch; + /* 0x10 */ s16 animTimer; + /* 0x12 */ s16 unk_12; // unused + /* 0x14 */ s16 keepOn4_rw_item_type_; } KeepOn4ReadWriteData; // size = 0x18 typedef struct { @@ -872,16 +894,16 @@ typedef struct { #define KEEPON4_FLAG_6 (1 << 6) #define KEEPON4_FLAG_7 (1 << 7) -#define CAM_FUNCDATA_KEEP4(yOffset, eyeDist, pitchTarget, yawTarget, atOffsetZ, fov, interfaceField, yawUpdateRateTarget, unk_22) \ +#define CAM_FUNCDATA_KEEP4(yOffset, eyeDist, pitchTarget, yawTarget, atOffsetPlayerForwards, fov, interfaceField, yawUpdateRateTarget, initTimer) \ { yOffset, CAM_DATA_Y_OFFSET }, \ { eyeDist, CAM_DATA_EYE_DIST }, \ { pitchTarget, CAM_DATA_PITCH_TARGET }, \ { yawTarget, CAM_DATA_YAW_TARGET }, \ - { atOffsetZ, CAM_DATA_AT_OFFSET_Z }, \ + { atOffsetPlayerForwards, CAM_DATA_AT_OFFSET_Z }, \ { fov, CAM_DATA_FOV }, \ { interfaceField, CAM_DATA_INTERFACE_FIELD }, \ { yawUpdateRateTarget, CAM_DATA_YAW_UPDATE_RATE_TARGET }, \ - { unk_22, CAM_DATA_UNK_22 } + { initTimer, CAM_DATA_UNK_22 } typedef struct { /* 0x00 */ f32 fovScale; diff --git a/include/z64player.h b/include/z64player.h index 8a75c4d5bdc..d08995754b6 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -140,6 +140,12 @@ typedef enum { /* 0x43 */ PLAYER_IA_MAX } PlayerItemAction; +#define PLAYER_MAGIC_SPELL(playerItemActionMagicSpell) ((playerItemActionMagicSpell) - PLAYER_IA_MAGIC_SPELL_15) +#define PLAYER_MAGIC_SPELL_MAX (1 + PLAYER_MAGIC_SPELL(PLAYER_IA_DINS_FIRE)) + +#define PLAYER_BOTTLE(playerItemActionBottle) ((playerItemActionBottle) - PLAYER_IA_BOTTLE) +#define PLAYER_BOTTLE_MAX (1 + PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FAIRY)) + typedef enum { /* 0x00 */ PLAYER_LIMB_NONE, /* 0x01 */ PLAYER_LIMB_ROOT, diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 37a08200d6a..65ea467e28b 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3473,7 +3473,7 @@ s32 Camera_KeepOn3(Camera* camera) { playerHeadPos = camPlayerPosRot->pos; playerHeadPos.y += playerHeight; Camera_AddVecGeoToVec3f(&rwData->atTarget, &playerHeadPos, &targetToPlayerDir); - angleCnt = ARRAY_COUNT(D_8011D3B0); + angleCnt = ARRAY_COUNT(sCamCheckAroundYawOffsets); i = 0; targetToPlayerDir.r = prevTargetPlayerDist; atToEyeAdj.r = roData->minDist + (targetToPlayerDir.r * (1 - 0.5f)) - atToEyeNextDir.r + atToEyeNextDir.r; @@ -3485,8 +3485,8 @@ s32 Camera_KeepOn3(Camera* camera) { !Camera_BGCheck(camera, &rwData->atTarget, &lineChkPointB)) { break; } - atToEyeAdj.yaw = sp80 + D_8011D3B0[i]; - atToEyeAdj.pitch = sp82 + D_8011D3CC[i]; + atToEyeAdj.yaw = sp80 + sCamCheckAroundYawOffsets[i]; + atToEyeAdj.pitch = sp82 + sCamCheckAroundPitchOffsets[i]; Camera_AddVecGeoToVec3f(&lineChkPointB, &rwData->atTarget, &atToEyeAdj); i++; } @@ -3541,24 +3541,24 @@ s32 Camera_KeepOn3(Camera* camera) { } s32 Camera_KeepOn4(Camera* camera) { - static Vec3f D_8015BD50; + static Vec3f sAtTarget; static Vec3f D_8015BD60; - static Vec3f D_8015BD70; + static Vec3f sEyeCandidate; Vec3f* eye = &camera->eye; Vec3f* at = &camera->at; Vec3f* eyeNext = &camera->eyeNext; - Actor* spCC[2]; + Actor* lineOCCheckExclusions[2]; f32 t = -0.5f; - f32 temp_f0_2; - CollisionPoly* spC0; - VecGeo spB8; - VecGeo spB0; - VecGeo spA8; - s16* temp_s0 = &camera->data2; - s16 spA2; - s16 spA0; - s16 sp9E; - s16 sp9C; + f32 camFloorY; + CollisionPoly* outPoly; + VecGeo vecGeo; + VecGeo atToEye_unused_; + VecGeo atToEyeNext_; + s16* keepOn4_item_type_ = &camera->data2; + s16 basePitch; + s16 baseYaw; + s16 camTargetYawTowardsPlayer; + s16 lineOCCheckNumExclusions; PosRot* playerPosRot = &camera->playerPosRot; KeepOn4ReadOnlyData* roData = &camera->paramData.keep4.roData; KeepOn4ReadWriteData* rwData = &camera->paramData.keep4.rwData; @@ -3575,13 +3575,13 @@ s32 Camera_KeepOn4(Camera* camera) { camera->play->view.unk_124 = camera->camId | 0x50; return 1; } - rwData->unk_14 = *temp_s0; + rwData->keepOn4_rw_item_type_ = *keepOn4_item_type_; camera->stateFlags &= ~CAM_STATE_5; } - if (rwData->unk_14 != *temp_s0) { - osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: item: item type changed %d -> %d\n" VT_RST, rwData->unk_14, - *temp_s0); + if (rwData->keepOn4_rw_item_type_ != *keepOn4_item_type_) { + osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: item: item type changed %d -> %d\n" VT_RST, + rwData->keepOn4_rw_item_type_, *keepOn4_item_type_); camera->animState = 20; camera->stateFlags |= CAM_STATE_5; camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); @@ -3595,115 +3595,115 @@ s32 Camera_KeepOn4(Camera* camera) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; f32 yNormal = 1.0f + t - (68.0f / playerHeight * t); - roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; - roData->unk_04 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; + roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; + roData->eyeDist = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->unk_08 = GET_NEXT_RO_DATA(values); roData->unk_0C = GET_NEXT_RO_DATA(values); - roData->unk_10 = GET_NEXT_RO_DATA(values); - roData->unk_18 = GET_NEXT_RO_DATA(values); + roData->atOffsetPlayerForwards = GET_NEXT_RO_DATA(values); + roData->fovTarget = GET_NEXT_RO_DATA(values); roData->interfaceField = GET_NEXT_RO_DATA(values); roData->unk_14 = GET_NEXT_SCALED_RO_DATA(values); - roData->unk_1E = GET_NEXT_RO_DATA(values); - osSyncPrintf("camera: item: type %d\n", *temp_s0); - switch (*temp_s0) { - case 1: - roData->unk_00 = playerHeight * -0.6f * yNormal; - roData->unk_04 = playerHeight * 2.0f * yNormal; + roData->initTimer = GET_NEXT_RO_DATA(values); + osSyncPrintf("camera: item: type %d\n", *keepOn4_item_type_); + switch (*keepOn4_item_type_) { + case KEEPON4_ITEM_TYPE_1: + roData->yOffset = playerHeight * -0.6f * yNormal; + roData->eyeDist = playerHeight * 2.0f * yNormal; roData->unk_08 = 10.0f; break; - case 2: - case 3: + case KEEPON4_ITEM_TYPE_2: + case KEEPON4_ITEM_TYPE_3: roData->unk_08 = -20.0f; - roData->unk_18 = 80.0f; + roData->fovTarget = 80.0f; break; - case 4: - roData->unk_00 = playerHeight * -0.2f * yNormal; + case KEEPON4_ITEM_TYPE_4: + roData->yOffset = playerHeight * -0.2f * yNormal; roData->unk_08 = 25.0f; break; - case 8: - roData->unk_00 = playerHeight * -0.2f * yNormal; - roData->unk_04 = playerHeight * 0.8f * yNormal; + case KEEPON4_ITEM_TYPE_8: + roData->yOffset = playerHeight * -0.2f * yNormal; + roData->eyeDist = playerHeight * 0.8f * yNormal; roData->unk_08 = 50.0f; - roData->unk_18 = 70.0f; + roData->fovTarget = 70.0f; break; - case 9: - roData->unk_00 = playerHeight * 0.1f * yNormal; - roData->unk_04 = playerHeight * 0.5f * yNormal; + case KEEPON4_ITEM_TYPE_9: + roData->yOffset = playerHeight * 0.1f * yNormal; + roData->eyeDist = playerHeight * 0.5f * yNormal; roData->unk_08 = -20.0f; roData->unk_0C = 0.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_6); break; - case 5: - roData->unk_00 = playerHeight * -0.4f * yNormal; + case KEEPON4_ITEM_TYPE_5: + roData->yOffset = playerHeight * -0.4f * yNormal; roData->unk_08 = -10.0f; roData->unk_0C = 45.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON4_FLAG_1); break; - case 10: - roData->unk_00 = playerHeight * -0.5f * yNormal; - roData->unk_04 = playerHeight * 1.5f * yNormal; + case KEEPON4_ITEM_TYPE_10: + roData->yOffset = playerHeight * -0.5f * yNormal; + roData->eyeDist = playerHeight * 1.5f * yNormal; roData->unk_08 = -15.0f; roData->unk_0C = 175.0f; - roData->unk_18 = 70.0f; + roData->fovTarget = 70.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_1); - roData->unk_1E = 0x3C; + roData->initTimer = 60; break; - case 12: - roData->unk_00 = playerHeight * -0.6f * yNormal; - roData->unk_04 = playerHeight * 1.6f * yNormal; + case KEEPON4_ITEM_TYPE_12: + roData->yOffset = playerHeight * -0.6f * yNormal; + roData->eyeDist = playerHeight * 1.6f * yNormal; roData->unk_08 = -2.0f; roData->unk_0C = 120.0f; - roData->unk_10 = player->stateFlags1 & PLAYER_STATE1_27 ? 0.0f : 20.0f; + roData->atOffsetPlayerForwards = player->stateFlags1 & PLAYER_STATE1_27 ? 0.0f : 20.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_4 | KEEPON4_FLAG_1); - roData->unk_1E = 0x1E; - roData->unk_18 = 50.0f; + roData->initTimer = 30; + roData->fovTarget = 50.0f; break; - case 0x5A: - roData->unk_00 = playerHeight * -0.3f * yNormal; - roData->unk_18 = 45.0f; + case KEEPON4_ITEM_TYPE_90: + roData->yOffset = playerHeight * -0.3f * yNormal; + roData->fovTarget = 45.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1); break; - case 0x5B: - roData->unk_00 = playerHeight * -0.1f * yNormal; - roData->unk_04 = playerHeight * 1.5f * yNormal; + case KEEPON4_ITEM_TYPE_91: + roData->yOffset = playerHeight * -0.1f * yNormal; + roData->eyeDist = playerHeight * 1.5f * yNormal; roData->unk_08 = -3.0f; roData->unk_0C = 10.0f; - roData->unk_18 = 55.0f; + roData->fovTarget = 55.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3); break; - case 0x51: - roData->unk_00 = playerHeight * -0.3f * yNormal; - roData->unk_04 = playerHeight * 1.5f * yNormal; + case KEEPON4_ITEM_TYPE_81: + roData->yOffset = playerHeight * -0.3f * yNormal; + roData->eyeDist = playerHeight * 1.5f * yNormal; roData->unk_08 = 2.0f; roData->unk_0C = 20.0f; - roData->unk_10 = 20.0f; + roData->atOffsetPlayerForwards = 20.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_7); - roData->unk_1E = 0x1E; - roData->unk_18 = 45.0f; + roData->initTimer = 30; + roData->fovTarget = 45.0f; break; - case 11: - roData->unk_00 = playerHeight * -0.19f * yNormal; - roData->unk_04 = playerHeight * 0.7f * yNormal; + case KEEPON4_ITEM_TYPE_11: + roData->yOffset = playerHeight * -0.19f * yNormal; + roData->eyeDist = playerHeight * 0.7f * yNormal; roData->unk_0C = 130.0f; - roData->unk_10 = 10.0f; + roData->atOffsetPlayerForwards = 10.0f; roData->interfaceField = CAM_INTERFACE_FIELD( CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_5 | KEEPON4_FLAG_1); break; @@ -3719,111 +3719,114 @@ s32 Camera_KeepOn4(Camera* camera) { sUpdateCameraDirection = 1; sCameraInterfaceField = roData->interfaceField; - OLib_Vec3fDiffToVecGeo(&spB0, at, eye); - OLib_Vec3fDiffToVecGeo(&spA8, at, eyeNext); - D_8015BD50 = playerPosRot->pos; - D_8015BD50.y += playerHeight; - temp_f0_2 = BgCheck_CameraRaycastDown2(&camera->play->colCtx, &spC0, &i, &D_8015BD50); - if (temp_f0_2 > (roData->unk_00 + D_8015BD50.y)) { - D_8015BD50.y = temp_f0_2 + 10.0f; + OLib_Vec3fDiffToVecGeo(&atToEye_unused_, at, eye); + OLib_Vec3fDiffToVecGeo(&atToEyeNext_, at, eyeNext); + sAtTarget = playerPosRot->pos; + sAtTarget.y += playerHeight; + camFloorY = BgCheck_CameraRaycastDown2(&camera->play->colCtx, &outPoly, &i, &sAtTarget); + if (camFloorY > (sAtTarget.y + roData->yOffset)) { + sAtTarget.y = camFloorY + 10.0f; } else { - D_8015BD50.y += roData->unk_00; + sAtTarget.y = sAtTarget.y + roData->yOffset; } - sp9C = 0; + lineOCCheckNumExclusions = 0; switch (camera->animState) { case 0: case 20: - spCC[sp9C] = &camera->player->actor; - sp9C++; + lineOCCheckExclusions[0] = &camera->player->actor; + lineOCCheckNumExclusions++; func_80043ABC(camera); camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); - rwData->unk_10 = roData->unk_1E; + rwData->animTimer = roData->initTimer; rwData->unk_08 = playerPosRot->pos.y - camera->playerPosDelta.y; if (roData->interfaceField & KEEPON4_FLAG_1) { - spA2 = CAM_DEG_TO_BINANG(roData->unk_08); - spA0 = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - spA8.yaw) > 0 - ? (s16)(playerPosRot->rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->unk_0C) - : (s16)(playerPosRot->rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->unk_0C); + basePitch = CAM_DEG_TO_BINANG(roData->unk_08); + baseYaw = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNext_.yaw) > 0 + ? (s16)(playerPosRot->rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->unk_0C) + : (s16)(playerPosRot->rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->unk_0C); } else if (roData->interfaceField & KEEPON4_FLAG_2) { - spA2 = CAM_DEG_TO_BINANG(roData->unk_08); - spA0 = CAM_DEG_TO_BINANG(roData->unk_0C); + basePitch = CAM_DEG_TO_BINANG(roData->unk_08); + baseYaw = CAM_DEG_TO_BINANG(roData->unk_0C); } else if ((roData->interfaceField & KEEPON4_FLAG_3) && camera->target != NULL) { - PosRot sp60; - - Actor_GetWorldPosShapeRot(&sp60, camera->target); - spA2 = CAM_DEG_TO_BINANG(roData->unk_08) - sp60.rot.x; - spA0 = (s16)((s16)(sp60.rot.y - 0x7FFF) - spA8.yaw) > 0 - ? (s16)(sp60.rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->unk_0C) - : (s16)(sp60.rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->unk_0C); - spCC[1] = camera->target; - sp9C++; + PosRot camTargetPosRot; + + Actor_GetWorldPosShapeRot(&camTargetPosRot, camera->target); + basePitch = CAM_DEG_TO_BINANG(roData->unk_08) - camTargetPosRot.rot.x; + baseYaw = (s16)((s16)(camTargetPosRot.rot.y - 0x7FFF) - atToEyeNext_.yaw) > 0 + ? (s16)(camTargetPosRot.rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->unk_0C) + : (s16)(camTargetPosRot.rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->unk_0C); + lineOCCheckExclusions[1] = camera->target; + lineOCCheckNumExclusions++; } else if ((roData->interfaceField & KEEPON4_FLAG_7) && camera->target != NULL) { - PosRot sp4C; - - Actor_GetWorld(&sp4C, camera->target); - spA2 = CAM_DEG_TO_BINANG(roData->unk_08); - sp9E = Camera_XZAngle(&sp4C.pos, &playerPosRot->pos); - spA0 = ((s16)(sp9E - spA8.yaw) > 0) ? sp9E + CAM_DEG_TO_BINANG(roData->unk_0C) - : sp9E - CAM_DEG_TO_BINANG(roData->unk_0C); - spCC[1] = camera->target; - sp9C++; + PosRot camTargetPosRot; + + Actor_GetWorld(&camTargetPosRot, camera->target); + basePitch = CAM_DEG_TO_BINANG(roData->unk_08); + camTargetYawTowardsPlayer = Camera_XZAngle(&camTargetPosRot.pos, &playerPosRot->pos); + baseYaw = ((s16)(camTargetYawTowardsPlayer - atToEyeNext_.yaw) > 0) + ? camTargetYawTowardsPlayer + CAM_DEG_TO_BINANG(roData->unk_0C) + : camTargetYawTowardsPlayer - CAM_DEG_TO_BINANG(roData->unk_0C); + lineOCCheckExclusions[1] = camera->target; + lineOCCheckNumExclusions++; } else if (roData->interfaceField & KEEPON4_FLAG_6) { - spA2 = CAM_DEG_TO_BINANG(roData->unk_08); - spA0 = spA8.yaw; + basePitch = CAM_DEG_TO_BINANG(roData->unk_08); + baseYaw = atToEyeNext_.yaw; } else { - spA2 = spA8.pitch; - spA0 = spA8.yaw; + basePitch = atToEyeNext_.pitch; + baseYaw = atToEyeNext_.yaw; } - spB8.pitch = spA2; - spB8.yaw = spA0; - spB8.r = roData->unk_04; - Camera_AddVecGeoToVec3f(&D_8015BD70, &D_8015BD50, &spB8); + vecGeo.pitch = basePitch; + vecGeo.yaw = baseYaw; + vecGeo.r = roData->eyeDist; + Camera_AddVecGeoToVec3f(&sEyeCandidate, &sAtTarget, &vecGeo); if (!(roData->interfaceField & KEEPON4_FLAG_0)) { - angleCnt = ARRAY_COUNT(D_8011D3B0); + angleCnt = ARRAY_COUNT(sCamCheckAroundYawOffsets); for (i = 0; i < angleCnt; i++) { - if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &D_8015BD50, &D_8015BD70, - spCC, sp9C) && - !Camera_BGCheck(camera, &D_8015BD50, &D_8015BD70)) { + if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &sAtTarget, &sEyeCandidate, + lineOCCheckExclusions, lineOCCheckNumExclusions) && + !Camera_BGCheck(camera, &sAtTarget, &sEyeCandidate)) { break; } - spB8.yaw = D_8011D3B0[i] + spA0; - spB8.pitch = D_8011D3CC[i] + spA2; - Camera_AddVecGeoToVec3f(&D_8015BD70, &D_8015BD50, &spB8); + vecGeo.yaw = baseYaw + sCamCheckAroundYawOffsets[i]; + vecGeo.pitch = basePitch + sCamCheckAroundPitchOffsets[i]; + Camera_AddVecGeoToVec3f(&sEyeCandidate, &sAtTarget, &vecGeo); } osSyncPrintf("camera: item: BG&collision check %d time(s)\n", i); } - rwData->unk_04 = (s16)(spB8.pitch - spA8.pitch) / (f32)rwData->unk_10; - rwData->unk_00 = (s16)(spB8.yaw - spA8.yaw) / (f32)rwData->unk_10; - rwData->unk_0C = spA8.yaw; - rwData->unk_0E = spA8.pitch; + rwData->atToEyeTargetStepPitch = (s16)(vecGeo.pitch - atToEyeNext_.pitch) / (f32)rwData->animTimer; + rwData->atToEyeTargetStepYaw = (s16)(vecGeo.yaw - atToEyeNext_.yaw) / (f32)rwData->animTimer; + rwData->atToEyeTargetYaw = atToEyeNext_.yaw; + rwData->atToEyeTargetPitch = atToEyeNext_.pitch; camera->animState++; rwData->unk_12 = 1; break; + case 10: rwData->unk_08 = playerPosRot->pos.y - camera->playerPosDelta.y; + FALLTHROUGH; default: break; } camera->xzOffsetUpdateRate = 0.25f; camera->yOffsetUpdateRate = 0.25f; camera->atLERPStepScale = 0.75f; - Camera_LERPCeilVec3f(&D_8015BD50, at, 0.5f, 0.5f, 0.2f); - if (roData->unk_10 != 0.0f) { - spB8.r = roData->unk_10; - spB8.pitch = 0; - spB8.yaw = playerPosRot->rot.y; - Camera_AddVecGeoToVec3f(at, at, &spB8); + Camera_LERPCeilVec3f(&sAtTarget, at, 0.5f, 0.5f, 0.2f); + if (roData->atOffsetPlayerForwards != 0.0f) { + vecGeo.r = roData->atOffsetPlayerForwards; + vecGeo.pitch = 0; + vecGeo.yaw = playerPosRot->rot.y; + Camera_AddVecGeoToVec3f(at, at, &vecGeo); } camera->atLERPStepScale = 0.0f; - camera->dist = Camera_LERPCeilF(roData->unk_04, camera->dist, 0.25f, 2.0f); - spB8.r = camera->dist; - if (rwData->unk_10 != 0) { + camera->dist = Camera_LERPCeilF(roData->eyeDist, camera->dist, 0.25f, 2.0f); + vecGeo.r = camera->dist; + if (rwData->animTimer != 0) { camera->stateFlags |= CAM_STATE_5; - rwData->unk_0C += (s16)rwData->unk_00; - rwData->unk_0E += (s16)rwData->unk_04; - rwData->unk_10--; + rwData->atToEyeTargetYaw += (s16)rwData->atToEyeTargetStepYaw; + rwData->atToEyeTargetPitch += (s16)rwData->atToEyeTargetStepPitch; + rwData->animTimer--; } else if (roData->interfaceField & KEEPON4_FLAG_4) { camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); camera->stateFlags |= (CAM_STATE_1 | CAM_STATE_2); @@ -3845,12 +3848,12 @@ s32 Camera_KeepOn4(Camera* camera) { } } } - spB8.yaw = Camera_LERPCeilS(rwData->unk_0C, spA8.yaw, roData->unk_14, 4); - spB8.pitch = Camera_LERPCeilS(rwData->unk_0E, spA8.pitch, roData->unk_14, 4); - Camera_AddVecGeoToVec3f(eyeNext, at, &spB8); + vecGeo.yaw = Camera_LERPCeilS(rwData->atToEyeTargetYaw, atToEyeNext_.yaw, roData->unk_14, 4); + vecGeo.pitch = Camera_LERPCeilS(rwData->atToEyeTargetPitch, atToEyeNext_.pitch, roData->unk_14, 4); + Camera_AddVecGeoToVec3f(eyeNext, at, &vecGeo); *eye = *eyeNext; Camera_BGCheck(camera, at, eye); - camera->fov = Camera_LERPCeilF(roData->unk_18, camera->fov, camera->fovUpdateRate, 1.0f); + camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, camera->fovUpdateRate, 1.0f); camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA); } @@ -8320,25 +8323,24 @@ Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera) { return quakeOffset; } -void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, - UNK_TYPE arg6) { - if (setDataFlags & 0x1) { +void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, s32 data4) { + if (setDataFlags & CAM_SET_CAMERA_DATA_0) { camera->data0 = data0; } - if (setDataFlags & 0x2) { + if (setDataFlags & CAM_SET_CAMERA_DATA_1) { camera->data1 = data1; } - if (setDataFlags & 0x4) { + if (setDataFlags & CAM_SET_CAMERA_DATA_2) { camera->data2 = data2; } - if (setDataFlags & 0x8) { + if (setDataFlags & CAM_SET_CAMERA_DATA_3) { camera->data3 = data3; } - if (setDataFlags & 0x10) { + if (setDataFlags & CAM_SET_CAMERA_DATA_4) { osSyncPrintf(VT_COL(RED, WHITE) "camera: setCameraData: last argument not alive!\n" VT_RST); } } diff --git a/src/code/z_camera_data.inc.c b/src/code/z_camera_data.inc.c index 77e56f45be5..711204a0277 100644 --- a/src/code/z_camera_data.inc.c +++ b/src/code/z_camera_data.inc.c @@ -2563,12 +2563,13 @@ s32 sCameraLetterboxSize = 32; s32 D_8011D3AC = -1; -s16 D_8011D3B0[] = { - 0x0AAA, 0xF556, 0x1555, 0xEAAB, 0x2AAA, 0xD556, 0x3FFF, 0xC001, 0x5555, 0xAAAB, 0x6AAA, 0x9556, 0x7FFF, 0x0000, +s16 sCamCheckAroundYawOffsets[] = { + 0x0AAA, -0x0AAA, 0x1555, -0x1555, 0x2AAA, -0x2AAA, 0x3FFF, + -0x3FFF, 0x5555, -0x5555, 0x6AAA, -0x6AAA, 0x7FFF, 0x0000, }; -s16 D_8011D3CC[] = { - 0x0000, 0x02C6, 0x058C, 0x0000, 0x0000, 0xFD3A, 0x0000, 0x0852, 0x0000, 0x0000, 0x0B18, 0x02C6, 0xFA74, 0x0000, +s16 sCamCheckAroundPitchOffsets[] = { + 0x0000, 0x02C6, 0x058C, 0x0000, 0x0000, -0x02C6, 0x0000, 0x0852, 0x0000, 0x0000, 0x0B18, 0x02C6, -0x058C, 0x0000, }; s32 sUpdateCameraDirection = 0; diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 406e8f54763..67b29c4c914 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -963,7 +963,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act subCam->timer = -99; if (Play_CamIsNotFixed(play)) { func_800C0808(play, subCamId, player, CAM_SET_TURN_AROUND); - subCam->data2 = 0xC; + subCam->data2 = KEEPON4_ITEM_TYPE_12; } else { Play_CopyCamera(play, subCamId, CAM_ID_MAIN); Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 29cb897b7de..50e334f44d2 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -691,9 +691,9 @@ s32 Player_HasMirrorShieldSetToDraw(PlayState* play) { } s32 Player_ActionToMagicSpell(Player* this, s32 itemAction) { - s32 magicSpell = itemAction - PLAYER_IA_MAGIC_SPELL_15; + s32 magicSpell = PLAYER_MAGIC_SPELL(itemAction); - if ((magicSpell >= 0) && (magicSpell < 6)) { + if ((magicSpell >= 0) && (magicSpell < PLAYER_MAGIC_SPELL_MAX)) { return magicSpell; } else { return -1; @@ -735,9 +735,9 @@ s32 Player_HoldsBrokenKnife(Player* this) { } s32 Player_ActionToBottle(Player* this, s32 itemAction) { - s32 bottle = itemAction - PLAYER_IA_BOTTLE; + s32 bottle = PLAYER_BOTTLE(itemAction); - if ((bottle >= 0) && (bottle < 13)) { + if ((bottle >= 0) && (bottle < PLAYER_BOTTLE_MAX)) { return bottle; } else { return -1; @@ -1388,19 +1388,19 @@ f32 sMeleeWeaponLengths[] = { Gfx* sBottleDLists[] = { gLinkAdultBottleDL, gLinkChildBottleDL }; Color_RGB8 sBottleColors[] = { - { 255, 255, 255 }, // Empty - { 80, 80, 255 }, // Fish - { 255, 100, 255 }, // Fire - { 0, 0, 255 }, // Bug - { 255, 0, 255 }, // Poe - { 255, 0, 255 }, // Big Poe - { 200, 200, 100 }, // Letter - { 255, 0, 0 }, // Red Potion - { 0, 0, 255 }, // Blue Potion - { 0, 255, 0 }, // Green Potion - { 255, 255, 255 }, // Milk - { 255, 255, 255 }, // Half Milk - { 80, 80, 255 }, // Fairy + { 255, 255, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE) + { 80, 80, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH) + { 255, 100, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FIRE) + { 0, 0, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_BUG) + { 255, 0, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_POE) + { 255, 0, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_BIG_POE) + { 200, 200, 100 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_RUTOS_LETTER) + { 255, 0, 0 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_POTION_RED) + { 0, 0, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_POTION_BLUE) + { 0, 255, 0 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_POTION_GREEN) + { 255, 255, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_MILK_FULL) + { 255, 255, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_MILK_HALF) + { 80, 80, 255 }, // PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FAIRY) }; Vec3f D_80126128 = { 398.0f, 1419.0f, 244.0f }; diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c index e25fb4386f4..cbfb94c625e 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c +++ b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c @@ -209,7 +209,8 @@ void BgMoriRakkatenjo_Update(Actor* thisx, PlayState* play) { if (sCamSetting == CAM_SET_NONE) { osSyncPrintf("camera changed (mori rakka tenjyo) ... \n"); sCamSetting = play->cameraPtrs[CAM_ID_MAIN]->setting; - Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], 1, &this->dyna.actor, NULL, 0, 0, 0); + Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_0, &this->dyna.actor, NULL, 0, 0, + 0); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_FOREST_BIRDS_EYE); } } else if (sCamSetting != CAM_SET_NONE) { diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 9af82e60b70..c7139feefbf 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -1749,7 +1749,8 @@ void EnHorse_Inactive(EnHorse* this, PlayState* play2) { // Focus the camera on Epona Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); - Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], 4, NULL, NULL, 0x51, 0, 0); + Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, KEEPON4_ITEM_TYPE_81, + 0, 0); } } if (!(this->stateFlags & ENHORSE_INACTIVE)) { @@ -1823,7 +1824,8 @@ void EnHorse_Idle(EnHorse* this, PlayState* play) { EnHorse_SetFollowAnimation(this, play); Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); - Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], 4, NULL, NULL, 0x51, 0, 0); + Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, + KEEPON4_ITEM_TYPE_81, 0, 0); } } else { Audio_PlaySfxGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index c587270062c..97c9bdfe90f 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -544,7 +544,8 @@ void EnOssan_TalkHappyMaskShopkeeper(PlayState* play) { void EnOssan_UpdateCameraDirection(EnOssan* this, PlayState* play, f32 cameraFaceAngle) { this->cameraFaceAngle = cameraFaceAngle; - Camera_SetCameraData(GET_ACTIVE_CAM(play), 0xC, NULL, NULL, cameraFaceAngle, 0, 0); + Camera_SetCameraData(GET_ACTIVE_CAM(play), CAM_SET_CAMERA_DATA_3 | CAM_SET_CAMERA_DATA_2, NULL, NULL, + cameraFaceAngle, 0, 0); } s32 EnOssan_TryGetObjBankIndices(EnOssan* this, PlayState* play, s16* objectIds) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 07aeed2cb0c..7c9f3eaa351 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -1531,7 +1531,14 @@ static u8 D_80854384[2] = { PLAYER_MWA_BIG_SPIN_1H, PLAYER_MWA_BIG_SPIN_2H }; static u16 D_80854388[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; -static u8 sMagicSpellCosts[] = { 12, 24, 24, 12, 24, 12 }; +static u8 sMagicSpellCosts[] = { + 12, // PLAYER_MAGIC_SPELL(PLAYER_IA_MAGIC_SPELL_15) + 24, // PLAYER_MAGIC_SPELL(PLAYER_IA_MAGIC_SPELL_16) + 24, // PLAYER_MAGIC_SPELL(PLAYER_IA_MAGIC_SPELL_17) + 12, // PLAYER_MAGIC_SPELL(PLAYER_IA_FARORES_WIND) + 24, // PLAYER_MAGIC_SPELL(PLAYER_IA_NAYRUS_LOVE) + 12, // PLAYER_MAGIC_SPELL(PLAYER_IA_DINS_FIRE) +}; static u16 D_80854398[] = { NA_SE_IT_BOW_DRAW, NA_SE_IT_SLING_DRAW, NA_SE_IT_HOOKSHOT_READY }; @@ -3114,9 +3121,10 @@ void func_80835E44(PlayState* play, s16 camSetting) { } } -void func_80835EA4(PlayState* play, s32 arg1) { +void func_80835EA4(PlayState* play, s32 keepOn4_item_type_) { func_80835E44(play, CAM_SET_TURN_AROUND); - Camera_SetCameraData(Play_GetCamera(play, CAM_ID_MAIN), 4, NULL, NULL, arg1, 0, 0); + Camera_SetCameraData(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_CAMERA_DATA_2, NULL, NULL, keepOn4_item_type_, 0, + 0); } void func_80835EFC(Player* this) { @@ -5148,15 +5156,15 @@ void func_8083AE40(Player* this, s16 objectId) { void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { func_80835DE4(play, this, func_808507F4, 0); - this->unk_84F = magicSpell - 3; + this->unk_84F = magicSpell - PLAYER_MAGIC_SPELL(PLAYER_IA_FARORES_WIND); Magic_RequestChange(play, sMagicSpellCosts[magicSpell], MAGIC_CONSUME_WAIT_PREVIEW); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, &gPlayerAnim_link_magic_tame, 0.83f); - if (magicSpell == 5) { + if (magicSpell == PLAYER_MAGIC_SPELL(PLAYER_IA_DINS_FIRE)) { this->subCamId = OnePointCutscene_Init(play, 1100, -101, NULL, CAM_ID_MAIN); } else { - func_80835EA4(play, 10); + func_80835EA4(play, KEEPON4_ITEM_TYPE_10); } } @@ -5218,13 +5226,14 @@ s32 func_8083B040(Player* this, PlayState* play) { if (this->unk_6AD == 4) { sp2C = Player_ActionToMagicSpell(this, this->itemAction); if (sp2C >= 0) { - if ((sp2C != 3) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { + if ((sp2C != PLAYER_MAGIC_SPELL(PLAYER_IA_FARORES_WIND)) || + (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { func_8083AF44(play, this, sp2C); } else { func_80835C58(play, this, func_8085063C, 1); this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; func_80832264(play, this, func_80833338(this)); - func_80835EA4(play, 4); + func_80835EA4(play, KEEPON4_ITEM_TYPE_4); } func_80832224(this); @@ -5234,7 +5243,8 @@ s32 func_8083B040(Player* this, PlayState* play) { sp2C = this->itemAction - PLAYER_IA_ZELDAS_LETTER; if ((sp2C >= 0) || (sp28 = Player_ActionToBottle(this, this->itemAction) - 1, - ((sp28 >= 0) && (sp28 < 6) && + ((sp28 >= (PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH) - 1)) && + (sp28 <= (PLAYER_BOTTLE(PLAYER_IA_BOTTLE_RUTOS_LETTER) - 1)) && ((this->itemAction > PLAYER_IA_BOTTLE_POE) || ((this->targetActor != NULL) && (((this->itemAction == PLAYER_IA_BOTTLE_POE) && (this->exchangeItemId == EXCH_ITEM_BOTTLE_POE)) || @@ -5251,9 +5261,9 @@ s32 func_8083B040(Player* this, PlayState* play) { this->stateFlags1 |= PLAYER_STATE1_6 | PLAYER_STATE1_28 | PLAYER_STATE1_29; if (sp2C >= 0) { - sp2C = sp2C + 1; + sp2C = EXCH_ITEM_ZELDAS_LETTER + sp2C; } else { - sp2C = sp28 + 0x18; + sp2C = EXCH_ITEM_BOTTLE_FISH + (sp28 - (PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH) - 1)); } targetActor = this->targetActor; @@ -5278,11 +5288,11 @@ s32 func_8083B040(Player* this, PlayState* play) { } else if (sp2C == EXCH_ITEM_BOTTLE_RUTOS_LETTER) { this->unk_84F = 1; this->actor.textId = 0x4005; - func_80835EA4(play, 1); + func_80835EA4(play, KEEPON4_ITEM_TYPE_1); } else { this->unk_84F = 2; this->actor.textId = 0xCF; - func_80835EA4(play, 4); + func_80835EA4(play, KEEPON4_ITEM_TYPE_4); } this->actor.flags |= ACTOR_FLAG_8; @@ -5301,24 +5311,26 @@ s32 func_8083B040(Player* this, PlayState* play) { sp2C = Player_ActionToBottle(this, this->itemAction); if (sp2C >= 0) { - if (sp2C == 0xC) { + if (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FAIRY)) { func_80835DE4(play, this, func_8084EED8, 0); func_808322D0(play, this, &gPlayerAnim_link_bottle_bug_out); - func_80835EA4(play, 3); - } else if ((sp2C > 0) && (sp2C < 4)) { + func_80835EA4(play, KEEPON4_ITEM_TYPE_3); + } else if ((sp2C >= PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) && + (sp2C <= PLAYER_BOTTLE(PLAYER_IA_BOTTLE_BUG))) { func_80835DE4(play, this, func_8084EFC0, 0); func_808322D0(play, this, &gPlayerAnim_link_bottle_fish_out); - func_80835EA4(play, (sp2C == 1) ? 1 : 5); + func_80835EA4(play, (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) ? KEEPON4_ITEM_TYPE_1 + : KEEPON4_ITEM_TYPE_5); } else { func_80835DE4(play, this, func_8084EAC0, 0); func_80832B78(play, this, &gPlayerAnim_link_bottle_drink_demo_start); - func_80835EA4(play, 2); + func_80835EA4(play, KEEPON4_ITEM_TYPE_2); } } else { func_80835DE4(play, this, func_8084E3C4, 0); func_808322D0(play, this, &gPlayerAnim_link_normal_okarina_start); this->stateFlags2 |= PLAYER_STATE2_27; - func_80835EA4(play, (this->unk_6A8 != NULL) ? 0x5B : 0x5A); + func_80835EA4(play, (this->unk_6A8 != NULL) ? KEEPON4_ITEM_TYPE_91 : KEEPON4_ITEM_TYPE_90); if (this->unk_6A8 != NULL) { this->stateFlags2 |= PLAYER_STATE2_25; Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, this->unk_6A8); @@ -6431,7 +6443,7 @@ s32 func_8083E5A8(Player* this, PlayState* play) { if (!(this->stateFlags2 & PLAYER_STATE2_10) || (this->currentBoots == PLAYER_BOOTS_IRON)) { func_80836898(play, this, func_8083A434); func_808322D0(play, this, &gPlayerAnim_link_demo_get_itemB); - func_80835EA4(play, 9); + func_80835EA4(play, KEEPON4_ITEM_TYPE_9); } this->stateFlags1 |= PLAYER_STATE1_10 | PLAYER_STATE1_11 | PLAYER_STATE1_29; @@ -12470,7 +12482,7 @@ void func_8084E1EC(Player* this, PlayState* play) { if ((this->stateFlags1 & PLAYER_STATE1_10) && LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { func_808332F4(this, play); func_80832340(play, this); - func_80835EA4(play, 8); + func_80835EA4(play, KEEPON4_ITEM_TYPE_8); } else if (LinkAnimation_OnFrame(&this->skelAnime, 5.0f)) { func_80832698(this, NA_SE_VO_LI_BREATH_DRINK); } @@ -12635,7 +12647,7 @@ void func_8084E6D4(Player* this, PlayState* play) { } this->unk_850 = 2; - func_80835EA4(play, 9); + func_80835EA4(play, KEEPON4_ITEM_TYPE_9); } } else { if (this->unk_850 == 0) { @@ -12806,7 +12818,7 @@ void func_8084ECA4(Player* this, PlayState* play) { this->interactRangeActor->parent = &this->actor; Player_UpdateBottleHeld(play, this, catchInfo->itemId, ABS(catchInfo->itemAction)); func_808322D0(play, this, sp24->unk_04); - func_80835EA4(play, 4); + func_80835EA4(play, KEEPON4_ITEM_TYPE_4); } } } @@ -14801,6 +14813,6 @@ void func_80853148(PlayState* play, Actor* actor) { if ((this->naviActor == this->targetActor) && ((this->targetActor->textId & 0xFF00) != 0x200)) { this->naviActor->flags |= ACTOR_FLAG_8; - func_80835EA4(play, 0xB); + func_80835EA4(play, KEEPON4_ITEM_TYPE_11); } } From f781c2acd7bc9afe888f40006570956ec3501702 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Wed, 7 Dec 2022 21:49:45 +0100 Subject: [PATCH 2/5] more --- include/z64camera.h | 10 ++--- src/code/z_camera.c | 106 ++++++++++++++++++++++---------------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/include/z64camera.h b/include/z64camera.h index 37dde2ff0a0..7fe9fe2be7f 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -844,8 +844,8 @@ typedef struct { typedef struct { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 eyeDist; - /* 0x08 */ f32 unk_08; // pitch related, angle in degrees - /* 0x0C */ f32 unk_0C; // yaw related, angle in degrees + /* 0x08 */ f32 pitchTarget; // degrees + /* 0x0C */ f32 yawTarget; // degrees /* 0x10 */ f32 atOffsetPlayerForwards; // distance to offset at by in the player's forwards direction /* 0x14 */ f32 unk_14; // scale for stepping yaw and pitch of "at to eye" to target /* 0x18 */ f32 fovTarget; @@ -877,7 +877,7 @@ typedef struct { /* 0x0E */ s16 atToEyeTargetPitch; /* 0x10 */ s16 animTimer; /* 0x12 */ s16 unk_12; // unused - /* 0x14 */ s16 keepOn4_rw_item_type_; + /* 0x14 */ s16 itemType; } KeepOn4ReadWriteData; // size = 0x18 typedef struct { @@ -886,8 +886,8 @@ typedef struct { } KeepOn4; // size = 0x38 #define KEEPON4_FLAG_0 (1 << 0) -#define KEEPON4_FLAG_1 (1 << 1) -#define KEEPON4_FLAG_2 (1 << 2) +#define KEEPON4_FLAG_1 (1 << 1) // pitch: provided, yaw: facing player's front + offset away +#define KEEPON4_FLAG_2 (1 << 2) // pitch: provided, yaw: provided #define KEEPON4_FLAG_3 (1 << 3) #define KEEPON4_FLAG_4 (1 << 4) #define KEEPON4_FLAG_5 (1 << 5) diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 65ea467e28b..79db0d0d3f3 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3552,9 +3552,9 @@ s32 Camera_KeepOn4(Camera* camera) { f32 camFloorY; CollisionPoly* outPoly; VecGeo vecGeo; - VecGeo atToEye_unused_; - VecGeo atToEyeNext_; - s16* keepOn4_item_type_ = &camera->data2; + VecGeo atToEyeDir; + VecGeo atToEyeNextDir; + s16* itemType = &camera->data2; s16 basePitch; s16 baseYaw; s16 camTargetYawTowardsPlayer; @@ -3575,13 +3575,13 @@ s32 Camera_KeepOn4(Camera* camera) { camera->play->view.unk_124 = camera->camId | 0x50; return 1; } - rwData->keepOn4_rw_item_type_ = *keepOn4_item_type_; + rwData->itemType = *itemType; camera->stateFlags &= ~CAM_STATE_5; } - if (rwData->keepOn4_rw_item_type_ != *keepOn4_item_type_) { + if (rwData->itemType != *itemType) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: item: item type changed %d -> %d\n" VT_RST, - rwData->keepOn4_rw_item_type_, *keepOn4_item_type_); + rwData->itemType, *itemType); camera->animState = 20; camera->stateFlags |= CAM_STATE_5; camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); @@ -3597,52 +3597,52 @@ s32 Camera_KeepOn4(Camera* camera) { roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->eyeDist = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; - roData->unk_08 = GET_NEXT_RO_DATA(values); - roData->unk_0C = GET_NEXT_RO_DATA(values); + roData->pitchTarget = GET_NEXT_RO_DATA(values); + roData->yawTarget = GET_NEXT_RO_DATA(values); roData->atOffsetPlayerForwards = GET_NEXT_RO_DATA(values); roData->fovTarget = GET_NEXT_RO_DATA(values); roData->interfaceField = GET_NEXT_RO_DATA(values); roData->unk_14 = GET_NEXT_SCALED_RO_DATA(values); roData->initTimer = GET_NEXT_RO_DATA(values); - osSyncPrintf("camera: item: type %d\n", *keepOn4_item_type_); - switch (*keepOn4_item_type_) { + osSyncPrintf("camera: item: type %d\n", *itemType); + switch (*itemType) { case KEEPON4_ITEM_TYPE_1: roData->yOffset = playerHeight * -0.6f * yNormal; roData->eyeDist = playerHeight * 2.0f * yNormal; - roData->unk_08 = 10.0f; + roData->pitchTarget = 10.0f; break; case KEEPON4_ITEM_TYPE_2: case KEEPON4_ITEM_TYPE_3: - roData->unk_08 = -20.0f; + roData->pitchTarget = -20.0f; roData->fovTarget = 80.0f; break; case KEEPON4_ITEM_TYPE_4: roData->yOffset = playerHeight * -0.2f * yNormal; - roData->unk_08 = 25.0f; + roData->pitchTarget = 25.0f; break; case KEEPON4_ITEM_TYPE_8: roData->yOffset = playerHeight * -0.2f * yNormal; roData->eyeDist = playerHeight * 0.8f * yNormal; - roData->unk_08 = 50.0f; + roData->pitchTarget = 50.0f; roData->fovTarget = 70.0f; break; case KEEPON4_ITEM_TYPE_9: roData->yOffset = playerHeight * 0.1f * yNormal; roData->eyeDist = playerHeight * 0.5f * yNormal; - roData->unk_08 = -20.0f; - roData->unk_0C = 0.0f; + roData->pitchTarget = -20.0f; + roData->yawTarget = 0.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_6); break; case KEEPON4_ITEM_TYPE_5: roData->yOffset = playerHeight * -0.4f * yNormal; - roData->unk_08 = -10.0f; - roData->unk_0C = 45.0f; + roData->pitchTarget = -10.0f; + roData->yawTarget = 45.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON4_FLAG_1); break; @@ -3650,8 +3650,8 @@ s32 Camera_KeepOn4(Camera* camera) { case KEEPON4_ITEM_TYPE_10: roData->yOffset = playerHeight * -0.5f * yNormal; roData->eyeDist = playerHeight * 1.5f * yNormal; - roData->unk_08 = -15.0f; - roData->unk_0C = 175.0f; + roData->pitchTarget = -15.0f; + roData->yawTarget = 175.0f; roData->fovTarget = 70.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_1); @@ -3661,8 +3661,8 @@ s32 Camera_KeepOn4(Camera* camera) { case KEEPON4_ITEM_TYPE_12: roData->yOffset = playerHeight * -0.6f * yNormal; roData->eyeDist = playerHeight * 1.6f * yNormal; - roData->unk_08 = -2.0f; - roData->unk_0C = 120.0f; + roData->pitchTarget = -2.0f; + roData->yawTarget = 120.0f; roData->atOffsetPlayerForwards = player->stateFlags1 & PLAYER_STATE1_27 ? 0.0f : 20.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_4 | KEEPON4_FLAG_1); @@ -3680,8 +3680,8 @@ s32 Camera_KeepOn4(Camera* camera) { case KEEPON4_ITEM_TYPE_91: roData->yOffset = playerHeight * -0.1f * yNormal; roData->eyeDist = playerHeight * 1.5f * yNormal; - roData->unk_08 = -3.0f; - roData->unk_0C = 10.0f; + roData->pitchTarget = -3.0f; + roData->yawTarget = 10.0f; roData->fovTarget = 55.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3); @@ -3690,8 +3690,8 @@ s32 Camera_KeepOn4(Camera* camera) { case KEEPON4_ITEM_TYPE_81: roData->yOffset = playerHeight * -0.3f * yNormal; roData->eyeDist = playerHeight * 1.5f * yNormal; - roData->unk_08 = 2.0f; - roData->unk_0C = 20.0f; + roData->pitchTarget = 2.0f; + roData->yawTarget = 20.0f; roData->atOffsetPlayerForwards = 20.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_7); @@ -3702,7 +3702,7 @@ s32 Camera_KeepOn4(Camera* camera) { case KEEPON4_ITEM_TYPE_11: roData->yOffset = playerHeight * -0.19f * yNormal; roData->eyeDist = playerHeight * 0.7f * yNormal; - roData->unk_0C = 130.0f; + roData->yawTarget = 130.0f; roData->atOffsetPlayerForwards = 10.0f; roData->interfaceField = CAM_INTERFACE_FIELD( CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_5 | KEEPON4_FLAG_1); @@ -3719,8 +3719,8 @@ s32 Camera_KeepOn4(Camera* camera) { sUpdateCameraDirection = 1; sCameraInterfaceField = roData->interfaceField; - OLib_Vec3fDiffToVecGeo(&atToEye_unused_, at, eye); - OLib_Vec3fDiffToVecGeo(&atToEyeNext_, at, eyeNext); + OLib_Vec3fDiffToVecGeo(&atToEyeDir, at, eye); + OLib_Vec3fDiffToVecGeo(&atToEyeNextDir, at, eyeNext); sAtTarget = playerPosRot->pos; sAtTarget.y += playerHeight; camFloorY = BgCheck_CameraRaycastDown2(&camera->play->colCtx, &outPoly, &i, &sAtTarget); @@ -3741,40 +3741,40 @@ s32 Camera_KeepOn4(Camera* camera) { rwData->animTimer = roData->initTimer; rwData->unk_08 = playerPosRot->pos.y - camera->playerPosDelta.y; if (roData->interfaceField & KEEPON4_FLAG_1) { - basePitch = CAM_DEG_TO_BINANG(roData->unk_08); - baseYaw = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNext_.yaw) > 0 - ? (s16)(playerPosRot->rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->unk_0C) - : (s16)(playerPosRot->rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->unk_0C); + basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); + baseYaw = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNextDir.yaw) > 0 + ? (s16)(playerPosRot->rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->yawTarget) + : (s16)(playerPosRot->rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->yawTarget); } else if (roData->interfaceField & KEEPON4_FLAG_2) { - basePitch = CAM_DEG_TO_BINANG(roData->unk_08); - baseYaw = CAM_DEG_TO_BINANG(roData->unk_0C); + basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); + baseYaw = CAM_DEG_TO_BINANG(roData->yawTarget); } else if ((roData->interfaceField & KEEPON4_FLAG_3) && camera->target != NULL) { PosRot camTargetPosRot; Actor_GetWorldPosShapeRot(&camTargetPosRot, camera->target); - basePitch = CAM_DEG_TO_BINANG(roData->unk_08) - camTargetPosRot.rot.x; - baseYaw = (s16)((s16)(camTargetPosRot.rot.y - 0x7FFF) - atToEyeNext_.yaw) > 0 - ? (s16)(camTargetPosRot.rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->unk_0C) - : (s16)(camTargetPosRot.rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->unk_0C); + basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget) - camTargetPosRot.rot.x; + baseYaw = (s16)((s16)(camTargetPosRot.rot.y - 0x7FFF) - atToEyeNextDir.yaw) > 0 + ? (s16)(camTargetPosRot.rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->yawTarget) + : (s16)(camTargetPosRot.rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->yawTarget); lineOCCheckExclusions[1] = camera->target; lineOCCheckNumExclusions++; } else if ((roData->interfaceField & KEEPON4_FLAG_7) && camera->target != NULL) { PosRot camTargetPosRot; Actor_GetWorld(&camTargetPosRot, camera->target); - basePitch = CAM_DEG_TO_BINANG(roData->unk_08); + basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); camTargetYawTowardsPlayer = Camera_XZAngle(&camTargetPosRot.pos, &playerPosRot->pos); - baseYaw = ((s16)(camTargetYawTowardsPlayer - atToEyeNext_.yaw) > 0) - ? camTargetYawTowardsPlayer + CAM_DEG_TO_BINANG(roData->unk_0C) - : camTargetYawTowardsPlayer - CAM_DEG_TO_BINANG(roData->unk_0C); + baseYaw = ((s16)(camTargetYawTowardsPlayer - atToEyeNextDir.yaw) > 0) + ? camTargetYawTowardsPlayer + CAM_DEG_TO_BINANG(roData->yawTarget) + : camTargetYawTowardsPlayer - CAM_DEG_TO_BINANG(roData->yawTarget); lineOCCheckExclusions[1] = camera->target; lineOCCheckNumExclusions++; } else if (roData->interfaceField & KEEPON4_FLAG_6) { - basePitch = CAM_DEG_TO_BINANG(roData->unk_08); - baseYaw = atToEyeNext_.yaw; + basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); + baseYaw = atToEyeNextDir.yaw; } else { - basePitch = atToEyeNext_.pitch; - baseYaw = atToEyeNext_.yaw; + basePitch = atToEyeNextDir.pitch; + baseYaw = atToEyeNextDir.yaw; } vecGeo.pitch = basePitch; @@ -3795,10 +3795,10 @@ s32 Camera_KeepOn4(Camera* camera) { } osSyncPrintf("camera: item: BG&collision check %d time(s)\n", i); } - rwData->atToEyeTargetStepPitch = (s16)(vecGeo.pitch - atToEyeNext_.pitch) / (f32)rwData->animTimer; - rwData->atToEyeTargetStepYaw = (s16)(vecGeo.yaw - atToEyeNext_.yaw) / (f32)rwData->animTimer; - rwData->atToEyeTargetYaw = atToEyeNext_.yaw; - rwData->atToEyeTargetPitch = atToEyeNext_.pitch; + rwData->atToEyeTargetStepPitch = (s16)(vecGeo.pitch - atToEyeNextDir.pitch) / (f32)rwData->animTimer; + rwData->atToEyeTargetStepYaw = (s16)(vecGeo.yaw - atToEyeNextDir.yaw) / (f32)rwData->animTimer; + rwData->atToEyeTargetYaw = atToEyeNextDir.yaw; + rwData->atToEyeTargetPitch = atToEyeNextDir.pitch; camera->animState++; rwData->unk_12 = 1; break; @@ -3848,8 +3848,8 @@ s32 Camera_KeepOn4(Camera* camera) { } } } - vecGeo.yaw = Camera_LERPCeilS(rwData->atToEyeTargetYaw, atToEyeNext_.yaw, roData->unk_14, 4); - vecGeo.pitch = Camera_LERPCeilS(rwData->atToEyeTargetPitch, atToEyeNext_.pitch, roData->unk_14, 4); + vecGeo.yaw = Camera_LERPCeilS(rwData->atToEyeTargetYaw, atToEyeNextDir.yaw, roData->unk_14, 4); + vecGeo.pitch = Camera_LERPCeilS(rwData->atToEyeTargetPitch, atToEyeNextDir.pitch, roData->unk_14, 4); Camera_AddVecGeoToVec3f(eyeNext, at, &vecGeo); *eye = *eyeNext; Camera_BGCheck(camera, at, eye); From 699d9b8cd68f9cac4635d0476bf20bd5f3975398 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Thu, 8 Dec 2022 01:02:43 +0100 Subject: [PATCH 3/5] try to cleanup --- include/z64camera.h | 24 +-- src/code/z_camera.c | 168 +++++++++++------- src/code/z_camera_data.inc.c | 11 +- src/code/z_onepointdemo.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 6 +- 5 files changed, 123 insertions(+), 88 deletions(-) diff --git a/include/z64camera.h b/include/z64camera.h index 7fe9fe2be7f..415fcbb5f2c 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -844,8 +844,8 @@ typedef struct { typedef struct { /* 0x00 */ f32 yOffset; /* 0x04 */ f32 eyeDist; - /* 0x08 */ f32 pitchTarget; // degrees - /* 0x0C */ f32 yawTarget; // degrees + /* 0x08 */ f32 pitchTarget; // degrees, usage varies with KEEPON4_FLAG_EYE_ + /* 0x0C */ f32 yawTarget; // degrees, usage varies with KEEPON4_FLAG_EYE_ /* 0x10 */ f32 atOffsetPlayerForwards; // distance to offset at by in the player's forwards direction /* 0x14 */ f32 unk_14; // scale for stepping yaw and pitch of "at to eye" to target /* 0x18 */ f32 fovTarget; @@ -863,8 +863,8 @@ typedef enum { /* 9 */ KEEPON4_ITEM_TYPE_9, // get item /* 10 */ KEEPON4_ITEM_TYPE_10, // used farore's wind or nayru's love /* 11 */ KEEPON4_ITEM_TYPE_11, // talking to navi? - /* 12 */ KEEPON4_ITEM_TYPE_12, // onepointdemo 9806 - /* 81 */ KEEPON4_ITEM_TYPE_81=81, // horse-related + /* 12 */ KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806, + /* 81 */ KEEPON4_ITEM_TYPE_HORSE=81, /* 90 */ KEEPON4_ITEM_TYPE_90=90, // play ocarina (on its own)? /* 91 */ KEEPON4_ITEM_TYPE_91 // play ocarina for an actor? } KeepOn4_item_type; @@ -885,14 +885,14 @@ typedef struct { /* 0x20 */ KeepOn4ReadWriteData rwData; } KeepOn4; // size = 0x38 -#define KEEPON4_FLAG_0 (1 << 0) -#define KEEPON4_FLAG_1 (1 << 1) // pitch: provided, yaw: facing player's front + offset away -#define KEEPON4_FLAG_2 (1 << 2) // pitch: provided, yaw: provided -#define KEEPON4_FLAG_3 (1 << 3) -#define KEEPON4_FLAG_4 (1 << 4) -#define KEEPON4_FLAG_5 (1 << 5) -#define KEEPON4_FLAG_6 (1 << 6) -#define KEEPON4_FLAG_7 (1 << 7) +#define KEEPON4_FLAG_NO_CHECK_COL (1 << 0) // If set, disables checking for colliders and collision to place the camera eye. Never set +#define KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER (1 << 1) // pitch: provided, yaw: offset from behind player +#define KEEPON4_FLAG_EYE_ABS (1 << 2) // pitch: provided, yaw: provided. Unused +#define KEEPON4_FLAG_EYE_FROM_TARGET (1 << 3) // pitch and yaw: depends on x/y rotations of the camera `target`, plus offsets +#define KEEPON4_FLAG_ONEPOINTDEMO9806 (1 << 4) // Camera timer ticks down, and other things (TODO). Only set for KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806 +#define KEEPON4_FLAG_NOOP (1 << 5) // No effect. Only set for KEEPON4_ITEM_TYPE_11 +#define KEEPON4_FLAG_EYE_KEEP_YAW (1 << 6) // pitch: provided, yaw: retain current yaw +#define KEEPON4_FLAG_HORSE (1 << 7) // (partly a KEEPON4_FLAG_EYE_) pitch: provided, yaw: offset from the side opposite to the camera `target` compared to player #define CAM_FUNCDATA_KEEP4(yOffset, eyeDist, pitchTarget, yawTarget, atOffsetPlayerForwards, fov, interfaceField, yawUpdateRateTarget, initTimer) \ { yOffset, CAM_DATA_Y_OFFSET }, \ diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 79db0d0d3f3..a9ebb0983a3 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3473,7 +3473,7 @@ s32 Camera_KeepOn3(Camera* camera) { playerHeadPos = camPlayerPosRot->pos; playerHeadPos.y += playerHeight; Camera_AddVecGeoToVec3f(&rwData->atTarget, &playerHeadPos, &targetToPlayerDir); - angleCnt = ARRAY_COUNT(sCamCheckAroundYawOffsets); + angleCnt = ARRAY_COUNT(sCamCheckAroundOffsetsYaw); i = 0; targetToPlayerDir.r = prevTargetPlayerDist; atToEyeAdj.r = roData->minDist + (targetToPlayerDir.r * (1 - 0.5f)) - atToEyeNextDir.r + atToEyeNextDir.r; @@ -3485,8 +3485,8 @@ s32 Camera_KeepOn3(Camera* camera) { !Camera_BGCheck(camera, &rwData->atTarget, &lineChkPointB)) { break; } - atToEyeAdj.yaw = sp80 + sCamCheckAroundYawOffsets[i]; - atToEyeAdj.pitch = sp82 + sCamCheckAroundPitchOffsets[i]; + atToEyeAdj.yaw = sp80 + sCamCheckAroundOffsetsYaw[i]; + atToEyeAdj.pitch = sp82 + sCamCheckAroundOffsetsPitch[i]; Camera_AddVecGeoToVec3f(&lineChkPointB, &rwData->atTarget, &atToEyeAdj); i++; } @@ -3555,8 +3555,8 @@ s32 Camera_KeepOn4(Camera* camera) { VecGeo atToEyeDir; VecGeo atToEyeNextDir; s16* itemType = &camera->data2; - s16 basePitch; - s16 baseYaw; + s16 atToEyeBasePitch; + s16 atToEyeBaseYaw; s16 camTargetYawTowardsPlayer; s16 lineOCCheckNumExclusions; PosRot* playerPosRot = &camera->playerPosRot; @@ -3580,8 +3580,8 @@ s32 Camera_KeepOn4(Camera* camera) { } if (rwData->itemType != *itemType) { - osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: item: item type changed %d -> %d\n" VT_RST, - rwData->itemType, *itemType); + osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: item: item type changed %d -> %d\n" VT_RST, rwData->itemType, + *itemType); camera->animState = 20; camera->stateFlags |= CAM_STATE_5; camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); @@ -3604,6 +3604,7 @@ s32 Camera_KeepOn4(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); roData->unk_14 = GET_NEXT_SCALED_RO_DATA(values); roData->initTimer = GET_NEXT_RO_DATA(values); + osSyncPrintf("camera: item: type %d\n", *itemType); switch (*itemType) { case KEEPON4_ITEM_TYPE_1: @@ -3635,16 +3636,16 @@ s32 Camera_KeepOn4(Camera* camera) { roData->eyeDist = playerHeight * 0.5f * yNormal; roData->pitchTarget = -20.0f; roData->yawTarget = 0.0f; - roData->interfaceField = - CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_6); + roData->interfaceField = CAM_INTERFACE_FIELD( + CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_EYE_KEEP_YAW); break; case KEEPON4_ITEM_TYPE_5: roData->yOffset = playerHeight * -0.4f * yNormal; roData->pitchTarget = -10.0f; roData->yawTarget = 45.0f; - roData->interfaceField = - CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON4_FLAG_1); + roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER); break; case KEEPON4_ITEM_TYPE_10: @@ -3653,19 +3654,20 @@ s32 Camera_KeepOn4(Camera* camera) { roData->pitchTarget = -15.0f; roData->yawTarget = 175.0f; roData->fovTarget = 70.0f; - roData->interfaceField = - CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_1); + roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, + KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER); roData->initTimer = 60; break; - case KEEPON4_ITEM_TYPE_12: + case KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806: roData->yOffset = playerHeight * -0.6f * yNormal; roData->eyeDist = playerHeight * 1.6f * yNormal; roData->pitchTarget = -2.0f; roData->yawTarget = 120.0f; roData->atOffsetPlayerForwards = player->stateFlags1 & PLAYER_STATE1_27 ? 0.0f : 20.0f; - roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NOTHING_ALT, - KEEPON4_FLAG_4 | KEEPON4_FLAG_1); + roData->interfaceField = + CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NOTHING_ALT, + KEEPON4_FLAG_ONEPOINTDEMO9806 | KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER); roData->initTimer = 30; roData->fovTarget = 50.0f; break; @@ -3673,8 +3675,8 @@ s32 Camera_KeepOn4(Camera* camera) { case KEEPON4_ITEM_TYPE_90: roData->yOffset = playerHeight * -0.3f * yNormal; roData->fovTarget = 45.0f; - roData->interfaceField = - CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1); + roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, + KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER); break; case KEEPON4_ITEM_TYPE_91: @@ -3684,17 +3686,17 @@ s32 Camera_KeepOn4(Camera* camera) { roData->yawTarget = 10.0f; roData->fovTarget = 55.0f; roData->interfaceField = - CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3); + CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_EYE_FROM_TARGET); break; - case KEEPON4_ITEM_TYPE_81: + case KEEPON4_ITEM_TYPE_HORSE: roData->yOffset = playerHeight * -0.3f * yNormal; roData->eyeDist = playerHeight * 1.5f * yNormal; roData->pitchTarget = 2.0f; roData->yawTarget = 20.0f; roData->atOffsetPlayerForwards = 20.0f; roData->interfaceField = - CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_7); + CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_NOTHING_ALT, KEEPON4_FLAG_HORSE); roData->initTimer = 30; roData->fovTarget = 45.0f; break; @@ -3704,8 +3706,9 @@ s32 Camera_KeepOn4(Camera* camera) { roData->eyeDist = playerHeight * 0.7f * yNormal; roData->yawTarget = 130.0f; roData->atOffsetPlayerForwards = 10.0f; - roData->interfaceField = CAM_INTERFACE_FIELD( - CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_5 | KEEPON4_FLAG_1); + roData->interfaceField = + CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, + KEEPON4_FLAG_NOOP | KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER); break; default: @@ -3734,125 +3737,156 @@ s32 Camera_KeepOn4(Camera* camera) { switch (camera->animState) { case 0: case 20: + // Init + lineOCCheckExclusions[0] = &camera->player->actor; lineOCCheckNumExclusions++; + func_80043ABC(camera); camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); rwData->animTimer = roData->initTimer; rwData->unk_08 = playerPosRot->pos.y - camera->playerPosDelta.y; - if (roData->interfaceField & KEEPON4_FLAG_1) { - basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); - baseYaw = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNextDir.yaw) > 0 - ? (s16)(playerPosRot->rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->yawTarget) - : (s16)(playerPosRot->rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->yawTarget); - } else if (roData->interfaceField & KEEPON4_FLAG_2) { - basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); - baseYaw = CAM_DEG_TO_BINANG(roData->yawTarget); - } else if ((roData->interfaceField & KEEPON4_FLAG_3) && camera->target != NULL) { + + // Get base pitch and yaw to position the eye + if (roData->interfaceField & KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER) { + atToEyeBasePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); + atToEyeBaseYaw = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNextDir.yaw) > 0 + ? (s16)(playerPosRot->rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->yawTarget) + : (s16)(playerPosRot->rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->yawTarget); + } else if (roData->interfaceField & KEEPON4_FLAG_EYE_ABS) { + atToEyeBasePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); + atToEyeBaseYaw = CAM_DEG_TO_BINANG(roData->yawTarget); + } else if ((roData->interfaceField & KEEPON4_FLAG_EYE_FROM_TARGET) && camera->target != NULL) { PosRot camTargetPosRot; Actor_GetWorldPosShapeRot(&camTargetPosRot, camera->target); - basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget) - camTargetPosRot.rot.x; - baseYaw = (s16)((s16)(camTargetPosRot.rot.y - 0x7FFF) - atToEyeNextDir.yaw) > 0 - ? (s16)(camTargetPosRot.rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->yawTarget) - : (s16)(camTargetPosRot.rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->yawTarget); + atToEyeBasePitch = CAM_DEG_TO_BINANG(roData->pitchTarget) - camTargetPosRot.rot.x; + atToEyeBaseYaw = (s16)((s16)(camTargetPosRot.rot.y - 0x7FFF) - atToEyeNextDir.yaw) > 0 + ? (s16)(camTargetPosRot.rot.y - 0x7FFF) + CAM_DEG_TO_BINANG(roData->yawTarget) + : (s16)(camTargetPosRot.rot.y - 0x7FFF) - CAM_DEG_TO_BINANG(roData->yawTarget); + lineOCCheckExclusions[1] = camera->target; lineOCCheckNumExclusions++; - } else if ((roData->interfaceField & KEEPON4_FLAG_7) && camera->target != NULL) { + } else if ((roData->interfaceField & KEEPON4_FLAG_HORSE) && camera->target != NULL) { PosRot camTargetPosRot; Actor_GetWorld(&camTargetPosRot, camera->target); - basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); + atToEyeBasePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); camTargetYawTowardsPlayer = Camera_XZAngle(&camTargetPosRot.pos, &playerPosRot->pos); - baseYaw = ((s16)(camTargetYawTowardsPlayer - atToEyeNextDir.yaw) > 0) - ? camTargetYawTowardsPlayer + CAM_DEG_TO_BINANG(roData->yawTarget) - : camTargetYawTowardsPlayer - CAM_DEG_TO_BINANG(roData->yawTarget); + atToEyeBaseYaw = ((s16)(camTargetYawTowardsPlayer - atToEyeNextDir.yaw) > 0) + ? camTargetYawTowardsPlayer + CAM_DEG_TO_BINANG(roData->yawTarget) + : camTargetYawTowardsPlayer - CAM_DEG_TO_BINANG(roData->yawTarget); + lineOCCheckExclusions[1] = camera->target; lineOCCheckNumExclusions++; - } else if (roData->interfaceField & KEEPON4_FLAG_6) { - basePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); - baseYaw = atToEyeNextDir.yaw; + } else if (roData->interfaceField & KEEPON4_FLAG_EYE_KEEP_YAW) { + atToEyeBasePitch = CAM_DEG_TO_BINANG(roData->pitchTarget); + atToEyeBaseYaw = atToEyeNextDir.yaw; } else { - basePitch = atToEyeNextDir.pitch; - baseYaw = atToEyeNextDir.yaw; + atToEyeBasePitch = atToEyeNextDir.pitch; + atToEyeBaseYaw = atToEyeNextDir.yaw; } - vecGeo.pitch = basePitch; - vecGeo.yaw = baseYaw; + // Find a position for the eye such that no colider or collision is in the way + vecGeo.pitch = atToEyeBasePitch; + vecGeo.yaw = atToEyeBaseYaw; vecGeo.r = roData->eyeDist; Camera_AddVecGeoToVec3f(&sEyeCandidate, &sAtTarget, &vecGeo); - if (!(roData->interfaceField & KEEPON4_FLAG_0)) { - angleCnt = ARRAY_COUNT(sCamCheckAroundYawOffsets); + if (!(roData->interfaceField & KEEPON4_FLAG_NO_CHECK_COL)) { + angleCnt = ARRAY_COUNT(sCamCheckAroundOffsetsYaw); for (i = 0; i < angleCnt; i++) { if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &sAtTarget, &sEyeCandidate, lineOCCheckExclusions, lineOCCheckNumExclusions) && !Camera_BGCheck(camera, &sAtTarget, &sEyeCandidate)) { break; } - vecGeo.yaw = baseYaw + sCamCheckAroundYawOffsets[i]; - vecGeo.pitch = basePitch + sCamCheckAroundPitchOffsets[i]; + vecGeo.yaw = atToEyeBaseYaw + sCamCheckAroundOffsetsYaw[i]; + vecGeo.pitch = atToEyeBasePitch + sCamCheckAroundOffsetsPitch[i]; Camera_AddVecGeoToVec3f(&sEyeCandidate, &sAtTarget, &vecGeo); } osSyncPrintf("camera: item: BG&collision check %d time(s)\n", i); } + rwData->atToEyeTargetStepPitch = (s16)(vecGeo.pitch - atToEyeNextDir.pitch) / (f32)rwData->animTimer; rwData->atToEyeTargetStepYaw = (s16)(vecGeo.yaw - atToEyeNextDir.yaw) / (f32)rwData->animTimer; rwData->atToEyeTargetYaw = atToEyeNextDir.yaw; rwData->atToEyeTargetPitch = atToEyeNextDir.pitch; + + // Init done camera->animState++; + rwData->unk_12 = 1; + break; case 10: + // Also init but do nothing? rwData->unk_08 = playerPosRot->pos.y - camera->playerPosDelta.y; FALLTHROUGH; default: break; } + camera->xzOffsetUpdateRate = 0.25f; camera->yOffsetUpdateRate = 0.25f; camera->atLERPStepScale = 0.75f; + + // Step at towards the at target Camera_LERPCeilVec3f(&sAtTarget, at, 0.5f, 0.5f, 0.2f); + + // Offset at if (roData->atOffsetPlayerForwards != 0.0f) { vecGeo.r = roData->atOffsetPlayerForwards; vecGeo.pitch = 0; vecGeo.yaw = playerPosRot->rot.y; Camera_AddVecGeoToVec3f(at, at, &vecGeo); } + camera->atLERPStepScale = 0.0f; + camera->dist = Camera_LERPCeilF(roData->eyeDist, camera->dist, 0.25f, 2.0f); vecGeo.r = camera->dist; + if (rwData->animTimer != 0) { + // Step eye yaw and pitch targets camera->stateFlags |= CAM_STATE_5; rwData->atToEyeTargetYaw += (s16)rwData->atToEyeTargetStepYaw; rwData->atToEyeTargetPitch += (s16)rwData->atToEyeTargetStepPitch; rwData->animTimer--; - } else if (roData->interfaceField & KEEPON4_FLAG_4) { - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); - camera->stateFlags |= (CAM_STATE_1 | CAM_STATE_2); - camera->stateFlags &= ~CAM_STATE_3; - if (camera->timer > 0) { - camera->timer--; - } } else { - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); - if ((camera->stateFlags & CAM_STATE_3) || (roData->interfaceField & KEEPON4_FLAG_7)) { - sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); + if (roData->interfaceField & KEEPON4_FLAG_ONEPOINTDEMO9806) { + camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); camera->stateFlags |= (CAM_STATE_1 | CAM_STATE_2); camera->stateFlags &= ~CAM_STATE_3; - if (camera->prevBgCamIndex < 0) { - Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); - } else { - Camera_ChangeBgCamIndex(camera, camera->prevBgCamIndex); - camera->prevBgCamIndex = -1; + if (camera->timer > 0) { + camera->timer--; + } + } else { + camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); + if ((camera->stateFlags & CAM_STATE_3) || (roData->interfaceField & KEEPON4_FLAG_HORSE)) { + sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); + camera->stateFlags |= (CAM_STATE_1 | CAM_STATE_2); + camera->stateFlags &= ~CAM_STATE_3; + if (camera->prevBgCamIndex < 0) { + Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); + } else { + Camera_ChangeBgCamIndex(camera, camera->prevBgCamIndex); + camera->prevBgCamIndex = -1; + } } } } + + // Step eye yaw and pitch vecGeo.yaw = Camera_LERPCeilS(rwData->atToEyeTargetYaw, atToEyeNextDir.yaw, roData->unk_14, 4); vecGeo.pitch = Camera_LERPCeilS(rwData->atToEyeTargetPitch, atToEyeNextDir.pitch, roData->unk_14, 4); + // Compute eyeNext Camera_AddVecGeoToVec3f(eyeNext, at, &vecGeo); + // Compute eye (accounting for collision) *eye = *eyeNext; Camera_BGCheck(camera, at, eye); + + // Step fov, roll camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, camera->fovUpdateRate, 1.0f); camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA); } diff --git a/src/code/z_camera_data.inc.c b/src/code/z_camera_data.inc.c index 711204a0277..aa3a80e6e6e 100644 --- a/src/code/z_camera_data.inc.c +++ b/src/code/z_camera_data.inc.c @@ -1259,9 +1259,10 @@ CameraModeValue sSetFireBirdsEyeModeClimbData[] = { */ CameraModeValue sSetTurnAroundModeNormalData[] = { - CAM_FUNCDATA_KEEP4( - -30, 120, -10, 170, 0, 60, - CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_1), 25, 6), + CAM_FUNCDATA_KEEP4(-30, 120, -10, 170, 0, 60, + CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, + KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER), + 25, 6), }; /** @@ -2563,12 +2564,12 @@ s32 sCameraLetterboxSize = 32; s32 D_8011D3AC = -1; -s16 sCamCheckAroundYawOffsets[] = { +s16 sCamCheckAroundOffsetsYaw[] = { 0x0AAA, -0x0AAA, 0x1555, -0x1555, 0x2AAA, -0x2AAA, 0x3FFF, -0x3FFF, 0x5555, -0x5555, 0x6AAA, -0x6AAA, 0x7FFF, 0x0000, }; -s16 sCamCheckAroundPitchOffsets[] = { +s16 sCamCheckAroundOffsetsPitch[] = { 0x0000, 0x02C6, 0x058C, 0x0000, 0x0000, -0x02C6, 0x0000, 0x0852, 0x0000, 0x0000, 0x0B18, 0x02C6, -0x058C, 0x0000, }; diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 67b29c4c914..ec50e5dde71 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -963,7 +963,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act subCam->timer = -99; if (Play_CamIsNotFixed(play)) { func_800C0808(play, subCamId, player, CAM_SET_TURN_AROUND); - subCam->data2 = KEEPON4_ITEM_TYPE_12; + subCam->data2 = KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806; } else { Play_CopyCamera(play, subCamId, CAM_ID_MAIN); Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index c7139feefbf..59716c83603 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -1749,8 +1749,8 @@ void EnHorse_Inactive(EnHorse* this, PlayState* play2) { // Focus the camera on Epona Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); - Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, KEEPON4_ITEM_TYPE_81, - 0, 0); + Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, + KEEPON4_ITEM_TYPE_HORSE, 0, 0); } } if (!(this->stateFlags & ENHORSE_INACTIVE)) { @@ -1825,7 +1825,7 @@ void EnHorse_Idle(EnHorse* this, PlayState* play) { Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, - KEEPON4_ITEM_TYPE_81, 0, 0); + KEEPON4_ITEM_TYPE_HORSE, 0, 0); } } else { Audio_PlaySfxGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, From 714a3205dd2d1414cbd5361f84c220b033ebc9df Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Tue, 13 Dec 2022 00:12:13 +0100 Subject: [PATCH 4/5] `KEEPON4_ITEM_TYPE_` -> `CAM_ITEM_TYPE_` --- include/z64camera.h | 32 +++++++++---------- src/code/z_camera.c | 26 +++++++-------- src/code/z_onepointdemo.c | 2 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 4 +-- .../actors/ovl_player_actor/z_player.c | 32 +++++++++---------- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/include/z64camera.h b/include/z64camera.h index 5fe7fbffad7..df2968d89b3 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -854,20 +854,20 @@ typedef struct { } KeepOn4ReadOnlyData; // size = 0x20 typedef enum { - /* 1 */ KEEPON4_ITEM_TYPE_1=1, // drop fish from bottle and something with ruto's letter - /* 2 */ KEEPON4_ITEM_TYPE_2, // drink from bottle? - /* 3 */ KEEPON4_ITEM_TYPE_3, // use bottled fairy - /* 4 */ KEEPON4_ITEM_TYPE_4, // something with farore's wind, something with exchange items, catching things into bottles - /* 5 */ KEEPON4_ITEM_TYPE_5, // drop bugs and blue fire from bottle - /* 8 */ KEEPON4_ITEM_TYPE_8=8, // ??? get item after underwater? - /* 9 */ KEEPON4_ITEM_TYPE_9, // get item - /* 10 */ KEEPON4_ITEM_TYPE_10, // used farore's wind or nayru's love - /* 11 */ KEEPON4_ITEM_TYPE_11, // talking to navi? - /* 12 */ KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806, - /* 81 */ KEEPON4_ITEM_TYPE_HORSE=81, - /* 90 */ KEEPON4_ITEM_TYPE_90=90, // play ocarina (on its own)? - /* 91 */ KEEPON4_ITEM_TYPE_91 // play ocarina for an actor? -} KeepOn4_item_type; + /* 1 */ CAM_ITEM_TYPE_1=1, // drop fish from bottle and something with ruto's letter + /* 2 */ CAM_ITEM_TYPE_2, // drink from bottle? + /* 3 */ CAM_ITEM_TYPE_3, // use bottled fairy + /* 4 */ CAM_ITEM_TYPE_4, // something with farore's wind, something with exchange items, catching things into bottles + /* 5 */ CAM_ITEM_TYPE_5, // drop bugs and blue fire from bottle + /* 8 */ CAM_ITEM_TYPE_8=8, // ??? get item after underwater? + /* 9 */ CAM_ITEM_TYPE_9, // get item + /* 10 */ CAM_ITEM_TYPE_10, // used farore's wind or nayru's love + /* 11 */ CAM_ITEM_TYPE_11, // talking to navi? + /* 12 */ CAM_ITEM_TYPE_ONEPOINTDEMO9806, + /* 81 */ CAM_ITEM_TYPE_HORSE=81, + /* 90 */ CAM_ITEM_TYPE_90=90, // play ocarina (on its own)? + /* 91 */ CAM_ITEM_TYPE_91 // play ocarina for an actor? +} CameraItemType; typedef struct { /* 0x00 */ f32 atToEyeTargetStepYaw; @@ -889,8 +889,8 @@ typedef struct { #define KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER (1 << 1) // pitch: provided, yaw: offset from behind player #define KEEPON4_FLAG_EYE_ABS (1 << 2) // pitch: provided, yaw: provided. Unused #define KEEPON4_FLAG_EYE_FROM_TARGET (1 << 3) // pitch and yaw: depends on x/y rotations of the camera `target`, plus offsets -#define KEEPON4_FLAG_ONEPOINTDEMO9806 (1 << 4) // Camera timer ticks down, and other things (TODO). Only set for KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806 -#define KEEPON4_FLAG_NOOP (1 << 5) // No effect. Only set for KEEPON4_ITEM_TYPE_11 +#define KEEPON4_FLAG_ONEPOINTDEMO9806 (1 << 4) // Camera timer ticks down, and other things (TODO). Only set for CAM_ITEM_TYPE_ONEPOINTDEMO9806 +#define KEEPON4_FLAG_NOOP (1 << 5) // No effect. Only set for CAM_ITEM_TYPE_11 #define KEEPON4_FLAG_EYE_KEEP_YAW (1 << 6) // pitch: provided, yaw: retain current yaw #define KEEPON4_FLAG_HORSE (1 << 7) // (partly a KEEPON4_FLAG_EYE_) pitch: provided, yaw: offset from the side opposite to the camera `target` compared to player diff --git a/src/code/z_camera.c b/src/code/z_camera.c index d5d271017af..3bffd379a90 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -3607,31 +3607,31 @@ s32 Camera_KeepOn4(Camera* camera) { osSyncPrintf("camera: item: type %d\n", *itemType); switch (*itemType) { - case KEEPON4_ITEM_TYPE_1: + case CAM_ITEM_TYPE_1: roData->yOffset = playerHeight * -0.6f * yNormal; roData->eyeDist = playerHeight * 2.0f * yNormal; roData->pitchTarget = 10.0f; break; - case KEEPON4_ITEM_TYPE_2: - case KEEPON4_ITEM_TYPE_3: + case CAM_ITEM_TYPE_2: + case CAM_ITEM_TYPE_3: roData->pitchTarget = -20.0f; roData->fovTarget = 80.0f; break; - case KEEPON4_ITEM_TYPE_4: + case CAM_ITEM_TYPE_4: roData->yOffset = playerHeight * -0.2f * yNormal; roData->pitchTarget = 25.0f; break; - case KEEPON4_ITEM_TYPE_8: + case CAM_ITEM_TYPE_8: roData->yOffset = playerHeight * -0.2f * yNormal; roData->eyeDist = playerHeight * 0.8f * yNormal; roData->pitchTarget = 50.0f; roData->fovTarget = 70.0f; break; - case KEEPON4_ITEM_TYPE_9: + case CAM_ITEM_TYPE_9: roData->yOffset = playerHeight * 0.1f * yNormal; roData->eyeDist = playerHeight * 0.5f * yNormal; roData->pitchTarget = -20.0f; @@ -3640,7 +3640,7 @@ s32 Camera_KeepOn4(Camera* camera) { CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, KEEPON4_FLAG_EYE_KEEP_YAW); break; - case KEEPON4_ITEM_TYPE_5: + case CAM_ITEM_TYPE_5: roData->yOffset = playerHeight * -0.4f * yNormal; roData->pitchTarget = -10.0f; roData->yawTarget = 45.0f; @@ -3648,7 +3648,7 @@ s32 Camera_KeepOn4(Camera* camera) { KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER); break; - case KEEPON4_ITEM_TYPE_10: + case CAM_ITEM_TYPE_10: roData->yOffset = playerHeight * -0.5f * yNormal; roData->eyeDist = playerHeight * 1.5f * yNormal; roData->pitchTarget = -15.0f; @@ -3659,7 +3659,7 @@ s32 Camera_KeepOn4(Camera* camera) { roData->initTimer = 60; break; - case KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806: + case CAM_ITEM_TYPE_ONEPOINTDEMO9806: roData->yOffset = playerHeight * -0.6f * yNormal; roData->eyeDist = playerHeight * 1.6f * yNormal; roData->pitchTarget = -2.0f; @@ -3672,14 +3672,14 @@ s32 Camera_KeepOn4(Camera* camera) { roData->fovTarget = 50.0f; break; - case KEEPON4_ITEM_TYPE_90: + case CAM_ITEM_TYPE_90: roData->yOffset = playerHeight * -0.3f * yNormal; roData->fovTarget = 45.0f; roData->interfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_EYE_YAW_REL_TO_PLAYER); break; - case KEEPON4_ITEM_TYPE_91: + case CAM_ITEM_TYPE_91: roData->yOffset = playerHeight * -0.1f * yNormal; roData->eyeDist = playerHeight * 1.5f * yNormal; roData->pitchTarget = -3.0f; @@ -3689,7 +3689,7 @@ s32 Camera_KeepOn4(Camera* camera) { CAM_INTERFACE_FIELD(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_EYE_FROM_TARGET); break; - case KEEPON4_ITEM_TYPE_HORSE: + case CAM_ITEM_TYPE_HORSE: roData->yOffset = playerHeight * -0.3f * yNormal; roData->eyeDist = playerHeight * 1.5f * yNormal; roData->pitchTarget = 2.0f; @@ -3701,7 +3701,7 @@ s32 Camera_KeepOn4(Camera* camera) { roData->fovTarget = 45.0f; break; - case KEEPON4_ITEM_TYPE_11: + case CAM_ITEM_TYPE_11: roData->yOffset = playerHeight * -0.19f * yNormal; roData->eyeDist = playerHeight * 0.7f * yNormal; roData->yawTarget = 130.0f; diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 9b48cd26b6f..ba568bb2a5f 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -963,7 +963,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act subCam->timer = -99; if (Play_CamIsNotFixed(play)) { func_800C0808(play, subCamId, player, CAM_SET_TURN_AROUND); - subCam->data2 = KEEPON4_ITEM_TYPE_ONEPOINTDEMO9806; + subCam->data2 = CAM_ITEM_TYPE_ONEPOINTDEMO9806; } else { Play_CopyCamera(play, subCamId, CAM_ID_MAIN); Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 59716c83603..832b0074866 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -1750,7 +1750,7 @@ void EnHorse_Inactive(EnHorse* this, PlayState* play2) { Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, - KEEPON4_ITEM_TYPE_HORSE, 0, 0); + CAM_ITEM_TYPE_HORSE, 0, 0); } } if (!(this->stateFlags & ENHORSE_INACTIVE)) { @@ -1825,7 +1825,7 @@ void EnHorse_Idle(EnHorse* this, PlayState* play) { Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, - KEEPON4_ITEM_TYPE_HORSE, 0, 0); + CAM_ITEM_TYPE_HORSE, 0, 0); } } else { Audio_PlaySfxGeneral(NA_SE_EV_HORSE_NEIGH, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index e14d5adcf1a..b99a8d9adc3 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -3122,9 +3122,9 @@ void func_80835E44(PlayState* play, s16 camSetting) { } } -void func_80835EA4(PlayState* play, s32 keepOn4_item_type_) { +void func_80835EA4(PlayState* play, s32 camItemType) { func_80835E44(play, CAM_SET_TURN_AROUND); - Camera_SetCameraData(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_CAMERA_DATA_2, NULL, NULL, keepOn4_item_type_, 0, + Camera_SetCameraData(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_CAMERA_DATA_2, NULL, NULL, camItemType, 0, 0); } @@ -5165,7 +5165,7 @@ void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { if (magicSpell == PLAYER_MAGIC_SPELL(PLAYER_IA_DINS_FIRE)) { this->subCamId = OnePointCutscene_Init(play, 1100, -101, NULL, CAM_ID_MAIN); } else { - func_80835EA4(play, KEEPON4_ITEM_TYPE_10); + func_80835EA4(play, CAM_ITEM_TYPE_10); } } @@ -5234,7 +5234,7 @@ s32 func_8083B040(Player* this, PlayState* play) { func_80835C58(play, this, func_8085063C, 1); this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; func_80832264(play, this, func_80833338(this)); - func_80835EA4(play, KEEPON4_ITEM_TYPE_4); + func_80835EA4(play, CAM_ITEM_TYPE_4); } func_80832224(this); @@ -5289,11 +5289,11 @@ s32 func_8083B040(Player* this, PlayState* play) { } else if (sp2C == EXCH_ITEM_BOTTLE_RUTOS_LETTER) { this->unk_84F = 1; this->actor.textId = 0x4005; - func_80835EA4(play, KEEPON4_ITEM_TYPE_1); + func_80835EA4(play, CAM_ITEM_TYPE_1); } else { this->unk_84F = 2; this->actor.textId = 0xCF; - func_80835EA4(play, KEEPON4_ITEM_TYPE_4); + func_80835EA4(play, CAM_ITEM_TYPE_4); } this->actor.flags |= ACTOR_FLAG_8; @@ -5315,23 +5315,23 @@ s32 func_8083B040(Player* this, PlayState* play) { if (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FAIRY)) { func_80835DE4(play, this, func_8084EED8, 0); func_808322D0(play, this, &gPlayerAnim_link_bottle_bug_out); - func_80835EA4(play, KEEPON4_ITEM_TYPE_3); + func_80835EA4(play, CAM_ITEM_TYPE_3); } else if ((sp2C >= PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) && (sp2C <= PLAYER_BOTTLE(PLAYER_IA_BOTTLE_BUG))) { func_80835DE4(play, this, func_8084EFC0, 0); func_808322D0(play, this, &gPlayerAnim_link_bottle_fish_out); - func_80835EA4(play, (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) ? KEEPON4_ITEM_TYPE_1 - : KEEPON4_ITEM_TYPE_5); + func_80835EA4(play, (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) ? CAM_ITEM_TYPE_1 + : CAM_ITEM_TYPE_5); } else { func_80835DE4(play, this, func_8084EAC0, 0); func_80832B78(play, this, &gPlayerAnim_link_bottle_drink_demo_start); - func_80835EA4(play, KEEPON4_ITEM_TYPE_2); + func_80835EA4(play, CAM_ITEM_TYPE_2); } } else { func_80835DE4(play, this, func_8084E3C4, 0); func_808322D0(play, this, &gPlayerAnim_link_normal_okarina_start); this->stateFlags2 |= PLAYER_STATE2_27; - func_80835EA4(play, (this->unk_6A8 != NULL) ? KEEPON4_ITEM_TYPE_91 : KEEPON4_ITEM_TYPE_90); + func_80835EA4(play, (this->unk_6A8 != NULL) ? CAM_ITEM_TYPE_91 : CAM_ITEM_TYPE_90); if (this->unk_6A8 != NULL) { this->stateFlags2 |= PLAYER_STATE2_25; Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, this->unk_6A8); @@ -6444,7 +6444,7 @@ s32 func_8083E5A8(Player* this, PlayState* play) { if (!(this->stateFlags2 & PLAYER_STATE2_10) || (this->currentBoots == PLAYER_BOOTS_IRON)) { func_80836898(play, this, func_8083A434); func_808322D0(play, this, &gPlayerAnim_link_demo_get_itemB); - func_80835EA4(play, KEEPON4_ITEM_TYPE_9); + func_80835EA4(play, CAM_ITEM_TYPE_9); } this->stateFlags1 |= PLAYER_STATE1_10 | PLAYER_STATE1_11 | PLAYER_STATE1_29; @@ -12483,7 +12483,7 @@ void func_8084E1EC(Player* this, PlayState* play) { if ((this->stateFlags1 & PLAYER_STATE1_10) && LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { func_808332F4(this, play); func_80832340(play, this); - func_80835EA4(play, KEEPON4_ITEM_TYPE_8); + func_80835EA4(play, CAM_ITEM_TYPE_8); } else if (LinkAnimation_OnFrame(&this->skelAnime, 5.0f)) { func_80832698(this, NA_SE_VO_LI_BREATH_DRINK); } @@ -12648,7 +12648,7 @@ void func_8084E6D4(Player* this, PlayState* play) { } this->unk_850 = 2; - func_80835EA4(play, KEEPON4_ITEM_TYPE_9); + func_80835EA4(play, CAM_ITEM_TYPE_9); } } else { if (this->unk_850 == 0) { @@ -12819,7 +12819,7 @@ void func_8084ECA4(Player* this, PlayState* play) { this->interactRangeActor->parent = &this->actor; Player_UpdateBottleHeld(play, this, catchInfo->itemId, ABS(catchInfo->itemAction)); func_808322D0(play, this, sp24->unk_04); - func_80835EA4(play, KEEPON4_ITEM_TYPE_4); + func_80835EA4(play, CAM_ITEM_TYPE_4); } } } @@ -14814,6 +14814,6 @@ void func_80853148(PlayState* play, Actor* actor) { if ((this->naviActor == this->targetActor) && ((this->targetActor->textId & 0xFF00) != 0x200)) { this->naviActor->flags |= ACTOR_FLAG_8; - func_80835EA4(play, KEEPON4_ITEM_TYPE_11); + func_80835EA4(play, CAM_ITEM_TYPE_11); } } From d461c1e369948a4f6d06c983bea9b348de207bc2 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Tue, 13 Dec 2022 00:14:39 +0100 Subject: [PATCH 5/5] `func_80835EA4` -> `Player_CameraChangeSettingTurnAround` --- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 4 +-- .../actors/ovl_player_actor/z_player.c | 34 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 832b0074866..c00b44fe70f 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -1749,8 +1749,8 @@ void EnHorse_Inactive(EnHorse* this, PlayState* play2) { // Focus the camera on Epona Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); - Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, - CAM_ITEM_TYPE_HORSE, 0, 0); + Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_CAMERA_DATA_2, NULL, NULL, CAM_ITEM_TYPE_HORSE, + 0, 0); } } if (!(this->stateFlags & ENHORSE_INACTIVE)) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index b99a8d9adc3..8cbc3aef4e0 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -3122,10 +3122,9 @@ void func_80835E44(PlayState* play, s16 camSetting) { } } -void func_80835EA4(PlayState* play, s32 camItemType) { +void Player_CameraChangeSettingTurnAround(PlayState* play, s32 camItemType) { func_80835E44(play, CAM_SET_TURN_AROUND); - Camera_SetCameraData(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_CAMERA_DATA_2, NULL, NULL, camItemType, 0, - 0); + Camera_SetCameraData(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_CAMERA_DATA_2, NULL, NULL, camItemType, 0, 0); } void func_80835EFC(Player* this) { @@ -5165,7 +5164,7 @@ void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { if (magicSpell == PLAYER_MAGIC_SPELL(PLAYER_IA_DINS_FIRE)) { this->subCamId = OnePointCutscene_Init(play, 1100, -101, NULL, CAM_ID_MAIN); } else { - func_80835EA4(play, CAM_ITEM_TYPE_10); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_10); } } @@ -5234,7 +5233,7 @@ s32 func_8083B040(Player* this, PlayState* play) { func_80835C58(play, this, func_8085063C, 1); this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; func_80832264(play, this, func_80833338(this)); - func_80835EA4(play, CAM_ITEM_TYPE_4); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_4); } func_80832224(this); @@ -5289,11 +5288,11 @@ s32 func_8083B040(Player* this, PlayState* play) { } else if (sp2C == EXCH_ITEM_BOTTLE_RUTOS_LETTER) { this->unk_84F = 1; this->actor.textId = 0x4005; - func_80835EA4(play, CAM_ITEM_TYPE_1); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_1); } else { this->unk_84F = 2; this->actor.textId = 0xCF; - func_80835EA4(play, CAM_ITEM_TYPE_4); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_4); } this->actor.flags |= ACTOR_FLAG_8; @@ -5315,23 +5314,24 @@ s32 func_8083B040(Player* this, PlayState* play) { if (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FAIRY)) { func_80835DE4(play, this, func_8084EED8, 0); func_808322D0(play, this, &gPlayerAnim_link_bottle_bug_out); - func_80835EA4(play, CAM_ITEM_TYPE_3); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_3); } else if ((sp2C >= PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) && (sp2C <= PLAYER_BOTTLE(PLAYER_IA_BOTTLE_BUG))) { func_80835DE4(play, this, func_8084EFC0, 0); func_808322D0(play, this, &gPlayerAnim_link_bottle_fish_out); - func_80835EA4(play, (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) ? CAM_ITEM_TYPE_1 - : CAM_ITEM_TYPE_5); + Player_CameraChangeSettingTurnAround( + play, (sp2C == PLAYER_BOTTLE(PLAYER_IA_BOTTLE_FISH)) ? CAM_ITEM_TYPE_1 : CAM_ITEM_TYPE_5); } else { func_80835DE4(play, this, func_8084EAC0, 0); func_80832B78(play, this, &gPlayerAnim_link_bottle_drink_demo_start); - func_80835EA4(play, CAM_ITEM_TYPE_2); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_2); } } else { func_80835DE4(play, this, func_8084E3C4, 0); func_808322D0(play, this, &gPlayerAnim_link_normal_okarina_start); this->stateFlags2 |= PLAYER_STATE2_27; - func_80835EA4(play, (this->unk_6A8 != NULL) ? CAM_ITEM_TYPE_91 : CAM_ITEM_TYPE_90); + Player_CameraChangeSettingTurnAround(play, + (this->unk_6A8 != NULL) ? CAM_ITEM_TYPE_91 : CAM_ITEM_TYPE_90); if (this->unk_6A8 != NULL) { this->stateFlags2 |= PLAYER_STATE2_25; Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, this->unk_6A8); @@ -6444,7 +6444,7 @@ s32 func_8083E5A8(Player* this, PlayState* play) { if (!(this->stateFlags2 & PLAYER_STATE2_10) || (this->currentBoots == PLAYER_BOOTS_IRON)) { func_80836898(play, this, func_8083A434); func_808322D0(play, this, &gPlayerAnim_link_demo_get_itemB); - func_80835EA4(play, CAM_ITEM_TYPE_9); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_9); } this->stateFlags1 |= PLAYER_STATE1_10 | PLAYER_STATE1_11 | PLAYER_STATE1_29; @@ -12483,7 +12483,7 @@ void func_8084E1EC(Player* this, PlayState* play) { if ((this->stateFlags1 & PLAYER_STATE1_10) && LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { func_808332F4(this, play); func_80832340(play, this); - func_80835EA4(play, CAM_ITEM_TYPE_8); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_8); } else if (LinkAnimation_OnFrame(&this->skelAnime, 5.0f)) { func_80832698(this, NA_SE_VO_LI_BREATH_DRINK); } @@ -12648,7 +12648,7 @@ void func_8084E6D4(Player* this, PlayState* play) { } this->unk_850 = 2; - func_80835EA4(play, CAM_ITEM_TYPE_9); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_9); } } else { if (this->unk_850 == 0) { @@ -12819,7 +12819,7 @@ void func_8084ECA4(Player* this, PlayState* play) { this->interactRangeActor->parent = &this->actor; Player_UpdateBottleHeld(play, this, catchInfo->itemId, ABS(catchInfo->itemAction)); func_808322D0(play, this, sp24->unk_04); - func_80835EA4(play, CAM_ITEM_TYPE_4); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_4); } } } @@ -14814,6 +14814,6 @@ void func_80853148(PlayState* play, Actor* actor) { if ((this->naviActor == this->targetActor) && ((this->targetActor->textId & 0xFF00) != 0x200)) { this->naviActor->flags |= ACTOR_FLAG_8; - func_80835EA4(play, CAM_ITEM_TYPE_11); + Player_CameraChangeSettingTurnAround(play, CAM_ITEM_TYPE_11); } }