From 8bd599588caf04f10f6035ac4c6510feb8760dc1 Mon Sep 17 00:00:00 2001 From: cadmic Date: Sat, 30 Mar 2024 20:48:06 -0700 Subject: [PATCH] Match retail camera (#1917) * Create CAM_DEBUG_RELOAD_PARAMS and CAM_DEBUG_RELOAD_PREG macros * Create debug macros for camera OREGs * Move static data into Camera_Demo5 * Match retail camera functions, except Camera_Battle1 * Match camera data and bss sizes * Restore R_CAM reg names, remove OREG_DEBUG[_SCALED] * CAM_DATA_n -> CAM_GLOBAL_n * Remove old debug macros * Add braces to CAM_DEBUG_RELOAD_PREG macro * Hackily match Camera_Battle1 * Format * Better Camera_Battle1 match * Format * Revert R_CAM_N comments for sOREGInit --- src/code/z_camera.c | 1482 ++++++++++++++++++++++------------ src/code/z_camera_data.inc.c | 380 +-------- 2 files changed, 983 insertions(+), 879 deletions(-) diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 7410dbb2e8..a54d640700 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -6,13 +6,32 @@ s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags); s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange); -s32 Camera_QRegInit(void); s32 Camera_UpdateWater(Camera* camera); +#if OOT_DEBUG +s32 Camera_QRegInit(void); +#endif + +#if OOT_DEBUG +#define CAM_DEBUG_RELOAD_PREG(camera) \ + if (R_RELOAD_CAM_PARAMS) { \ + Camera_CopyPREGToModeValues(camera); \ + } \ + (void)0 +#else +#define CAM_DEBUG_RELOAD_PREG(camera) (void)0 +#endif + // Camera will reload its paramData. Usually that means setting the read-only data from what is stored in // CameraModeValue arrays. Although sometimes some read-write data is reset as well #define RELOAD_PARAMS(camera) (camera->animState == 0 || camera->animState == 10 || camera->animState == 20) +#if OOT_DEBUG +#define CAM_DEBUG_RELOAD_PARAMS R_RELOAD_CAM_PARAMS +#else +#define CAM_DEBUG_RELOAD_PARAMS true +#endif + /** * Camera data is stored in both read-only data and OREG as s16, and then converted to the appropriate type during * runtime. If a small f32 is being stored as an s16, it is common to store that value 100 times larger than the @@ -25,6 +44,120 @@ s32 Camera_UpdateWater(Camera* camera); // Load the next value and scale down from camera read-only data stored in CameraModeValue #define GET_NEXT_SCALED_RO_DATA(values) CAM_DATA_SCALED(GET_NEXT_RO_DATA(values)) +#if OOT_DEBUG + +#define CAM_GLOBAL_0 OREG(0) +#define CAM_GLOBAL_1 OREG(1) +#define CAM_XZ_OFFSET_UPDATE_RATE CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE) +#define CAM_Y_OFFSET_UPDATE_RATE CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE) +#define CAM_FOV_UPDATE_RATE CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE) +#define CAM_MAX_PITCH R_CAM_MAX_PITCH +#define CAM_R_UPDATE_RATE_INV R_CAM_R_UPDATE_RATE_INV +#define CAM_PITCH_UPDATE_RATE_INV R_CAM_PITCH_UPDATE_RATE_INV +#define CAM_GLOBAL_8 CAM_DATA_SCALED(OREG(8)) +#define CAM_SLOPE_Y_ADJ_AMOUNT R_CAM_SLOPE_Y_ADJ_AMOUNT +#define CAM_GLOBAL_10 CAM_DATA_SCALED(OREG(10)) +#define CAM_GLOBAL_11 CAM_DATA_SCALED(OREG(11)) +#define CAM_GLOBAL_12 CAM_DATA_SCALED(OREG(12)) +#define CAM_GLOBAL_13 OREG(13) +#define CAM_GLOBAL_14 OREG(14) +#define CAM_GLOBAL_15 OREG(15) +#define CAM_GLOBAL_16 OREG(16) +#define CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC) +#define CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC) +#define CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC) +#define CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT) +#define CAM_GLOBAL_21 OREG(21) +#define CAM_GLOBAL_22 CAM_DATA_SCALED(OREG(22)) +#define CAM_DEFAULT_ANIM_TIME R_CAM_DEFAULT_ANIM_TIME +#define CAM_GLOBAL_24 OREG(24) +#define CAM_UPDATE_RATE_STEP_SCALE_XZ CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) +#define CAM_UPDATE_RATE_STEP_SCALE_Y CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) +#define CAM_GLOBAL_27 OREG(27) +#define CAM_GLOBAL_28 CAM_DATA_SCALED(OREG(28)) +#define CAM_GLOBAL_29 CAM_DATA_SCALED(OREG(29)) +#define CAM_GLOBAL_30 CAM_DATA_SCALED(OREG(30)) +#define CAM_JUMP1_EYE_Y_STEP_SCALE CAM_DATA_SCALED(R_CAM_JUMP1_EYE_Y_STEP_SCALE) +#define CAM_GLOBAL_32 OREG(32) +#define CAM_GLOBAL_33 OREG(33) +#define CAM_MIN_PITCH_1 R_CAM_MIN_PITCH_1 +#define CAM_MIN_PITCH_2 R_CAM_MIN_PITCH_2 +#define CAM_BATTLE1_ROLL_TARGET_BASE R_CAM_BATTLE1_ROLL_TARGET_BASE +#define CAM_BATTLE1_ROLL_STEP_SCALE CAM_DATA_SCALED(R_CAM_BATTLE1_ROLL_STEP_SCALE) +#define CAM_GLOBAL_38 CAM_DATA_SCALED(OREG(38)) +#define CAM_GLOBAL_39 CAM_DATA_SCALED(OREG(39)) +#define CAM_BATTLE1_XYZ_OFFSET_UPDATE_RATE_TARGET CAM_DATA_SCALED(R_CAM_BATTLE1_XYZ_OFFSET_UPDATE_RATE_TARGET) +#define CAM_AT_LERP_STEP_SCALE_MIN CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_MIN) +#define CAM_AT_LERP_STEP_SCALE_FAC CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_FAC) +#define CAM_GLOBAL_43 CAM_DATA_SCALED(OREG(43)) +#define CAM_GLOBAL_44 OREG(44) +#define CAM_GLOBAL_45 OREG(45) +#define CAM_YOFFSET_NORM CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) +#define CAM_GLOBAL_47 OREG(47) +#define CAM_GLOBAL_48 CAM_DATA_SCALED(OREG(48)) +#define CAM_GLOBAL_49 CAM_DATA_SCALED(OREG(49)) +#define CAM_GLOBAL_50 OREG(50) +#define CAM_GLOBAL_51 OREG(51) +#define CAM_GLOBAL_52 OREG(52) + +#else + +#define CAM_GLOBAL_0 0 +#define CAM_GLOBAL_1 1 +#define CAM_XZ_OFFSET_UPDATE_RATE .05f +#define CAM_Y_OFFSET_UPDATE_RATE .05f +#define CAM_FOV_UPDATE_RATE .05f +#define CAM_MAX_PITCH 14500 +#define CAM_R_UPDATE_RATE_INV 20 +#define CAM_PITCH_UPDATE_RATE_INV 16 +#define CAM_GLOBAL_8 1.5f +#define CAM_SLOPE_Y_ADJ_AMOUNT 25 +#define CAM_GLOBAL_10 1.5f +#define CAM_GLOBAL_11 0.06f +#define CAM_GLOBAL_12 .10f +#define CAM_GLOBAL_13 10 +#define CAM_GLOBAL_14 0 +#define CAM_GLOBAL_15 0 +#define CAM_GLOBAL_16 1 +#define CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC 1.0f +#define CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC 2.5f +#define CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC 1.2f +#define CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT 0.8f +#define CAM_GLOBAL_21 30 +#define CAM_GLOBAL_22 1.2f +#define CAM_DEFAULT_ANIM_TIME 4 +#define CAM_GLOBAL_24 1 +#define CAM_UPDATE_RATE_STEP_SCALE_XZ .50f +#define CAM_UPDATE_RATE_STEP_SCALE_Y .20f +#define CAM_GLOBAL_27 1800 +#define CAM_GLOBAL_28 0.5f +#define CAM_GLOBAL_29 0.5f +#define CAM_GLOBAL_30 0.5f +#define CAM_JUMP1_EYE_Y_STEP_SCALE 0.2f +#define CAM_GLOBAL_32 20 +#define CAM_GLOBAL_33 -10 +#define CAM_MIN_PITCH_1 -5460 +#define CAM_MIN_PITCH_2 -9100 +#define CAM_BATTLE1_ROLL_TARGET_BASE -6 +#define CAM_BATTLE1_ROLL_STEP_SCALE 0.08f +#define CAM_GLOBAL_38 0.15f +#define CAM_GLOBAL_39 0.75f +#define CAM_BATTLE1_XYZ_OFFSET_UPDATE_RATE_TARGET 0.6f +#define CAM_AT_LERP_STEP_SCALE_MIN 0.12f +#define CAM_AT_LERP_STEP_SCALE_FAC 1.1f +#define CAM_GLOBAL_43 0.4f +#define CAM_GLOBAL_44 50 +#define CAM_GLOBAL_45 250 +#define CAM_YOFFSET_NORM -0.1f +#define CAM_GLOBAL_47 30 +#define CAM_GLOBAL_48 0.3f +#define CAM_GLOBAL_49 0.7f +#define CAM_GLOBAL_50 20 +#define CAM_GLOBAL_51 20 +#define CAM_GLOBAL_52 20 + +#endif + #define DISTORTION_HOT_ROOM (1 << 0) #define DISTORTION_UNDERWATER_WEAK (1 << 1) #define DISTORTION_UNDERWATER_MEDIUM (1 << 2) @@ -160,17 +293,17 @@ void Camera_LERPCeilVec3f(Vec3f* target, Vec3f* cur, f32 yStepScale, f32 xzStepS void func_80043ABC(Camera* camera) { camera->yawUpdateRateInv = 100.0f; - camera->pitchUpdateRateInv = R_CAM_PITCH_UPDATE_RATE_INV; - camera->rUpdateRateInv = R_CAM_R_UPDATE_RATE_INV; - camera->xzOffsetUpdateRate = CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE); - camera->yOffsetUpdateRate = CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE); - camera->fovUpdateRate = CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE); + camera->pitchUpdateRateInv = CAM_PITCH_UPDATE_RATE_INV; + camera->rUpdateRateInv = CAM_R_UPDATE_RATE_INV; + camera->xzOffsetUpdateRate = CAM_XZ_OFFSET_UPDATE_RATE; + camera->yOffsetUpdateRate = CAM_Y_OFFSET_UPDATE_RATE; + camera->fovUpdateRate = CAM_FOV_UPDATE_RATE; } void func_80043B60(Camera* camera) { - camera->rUpdateRateInv = OREG(27); - camera->yawUpdateRateInv = OREG(27); - camera->pitchUpdateRateInv = OREG(27); + camera->rUpdateRateInv = CAM_GLOBAL_27; + camera->yawUpdateRateInv = CAM_GLOBAL_27; + camera->pitchUpdateRateInv = CAM_GLOBAL_27; camera->xzOffsetUpdateRate = 0.001f; camera->yOffsetUpdateRate = 0.001f; camera->fovUpdateRate = 0.001f; @@ -439,9 +572,13 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) { break; } } + +#if OOT_DEBUG if (i == 0) { PRINTF(VT_COL(YELLOW, BLACK) "camera: foward check: too many layer!\n" VT_RST); } +#endif + return floorY; } @@ -598,9 +735,9 @@ s16 Camera_GetPitchAdjFromFloorHeightDiffs(Camera* camera, s16 viewYaw, s16 init viewForwardsUnitZ = Math_CosS(viewYaw); playerHeight = Player_GetHeight(camera->player); - checkOffsetY = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC) * playerHeight; - nearDist = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC) * playerHeight; - farDist = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC) * playerHeight; + checkOffsetY = playerHeight * CAM_PITCH_FLOOR_CHECK_OFFSET_Y_FAC; + nearDist = playerHeight * CAM_PITCH_FLOOR_CHECK_NEAR_DIST_FAC; + farDist = playerHeight * CAM_PITCH_FLOOR_CHECK_FAR_DIST_FAC; playerPos.x = camera->playerPosRot.pos.x; playerPos.y = camera->playerGroundY + checkOffsetY; @@ -644,9 +781,8 @@ s16 Camera_GetPitchAdjFromFloorHeightDiffs(Camera* camera, s16 viewYaw, s16 init } } - floorYDiffNear = CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT) * (sFloorYNear - camera->playerGroundY); - floorYDiffFar = - (1.0f - CAM_DATA_SCALED(R_CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT)) * (sFloorYFar - camera->playerGroundY); + floorYDiffNear = CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT * (sFloorYNear - camera->playerGroundY); + floorYDiffFar = (1.0f - CAM_PITCH_FLOOR_CHECK_NEAR_WEIGHT) * (sFloorYFar - camera->playerGroundY); pitchNear = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(floorYDiffNear, nearDist))); pitchFar = CAM_DEG_TO_BINANG(RAD_TO_DEG(Math_FAtan2F(floorYDiffFar, farDist))); @@ -706,12 +842,12 @@ Vec3f Camera_CalcUpFromPitchYawRoll(s16 pitch, s16 yaw, s16 roll) { f32 Camera_ClampLERPScale(Camera* camera, f32 maxLERPScale) { f32 ret; - if (camera->atLERPStepScale < CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_MIN)) { - ret = CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_MIN); + if (camera->atLERPStepScale < CAM_AT_LERP_STEP_SCALE_MIN) { + ret = CAM_AT_LERP_STEP_SCALE_MIN; } else if (camera->atLERPStepScale >= maxLERPScale) { ret = maxLERPScale; } else { - ret = CAM_DATA_SCALED(R_CAM_AT_LERP_STEP_SCALE_FAC) * camera->atLERPStepScale; + ret = CAM_AT_LERP_STEP_SCALE_FAC * camera->atLERPStepScale; } return ret; @@ -722,6 +858,7 @@ void Camera_CopyDataToRegs(Camera* camera, s16 mode) { CameraModeValue* valueP; s32 i; +#if OOT_DEBUG if (PREG(82)) { PRINTF("camera: res: stat (%d/%d/%d)\n", camera->camId, camera->setting, mode); } @@ -735,9 +872,12 @@ void Camera_CopyDataToRegs(Camera* camera, s16 mode) { PRINTF("camera: res: PREG(%02d) = %d\n", valueP->dataType, valueP->val); } } +#endif + camera->animState = 0; } +#if OOT_DEBUG s32 Camera_CopyPREGToModeValues(Camera* camera) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; CameraModeValue* valueP; @@ -752,6 +892,7 @@ s32 Camera_CopyPREGToModeValues(Camera* camera) { } return true; } +#endif void Camera_UpdateInterface(s16 interfaceField) { s16 hudVisibilityMode; @@ -796,11 +937,15 @@ void Camera_UpdateInterface(s16 interfaceField) { Vec3f Camera_BGCheckCorner(Vec3f* linePointA, Vec3f* linePointB, CamColChk* pointAColChk, CamColChk* pointBColChk) { Vec3f closestPoint; + bool result; - if (!func_800427B4(pointAColChk->poly, pointBColChk->poly, linePointA, linePointB, &closestPoint)) { + result = func_800427B4(pointAColChk->poly, pointBColChk->poly, linePointA, linePointB, &closestPoint); +#if OOT_DEBUG + if (!result) { PRINTF(VT_COL(YELLOW, BLACK) "camera: corner check no cross point %x %x\n" VT_RST, pointAColChk, pointBColChk); return pointAColChk->pos; } +#endif return closestPoint; } @@ -916,7 +1061,7 @@ s32 Camera_CalcAtDefault(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, s16 calc if (calcSlopeYAdj) { playerToAtOffsetTarget.y -= OLib_ClampMaxDist( - Camera_CalcSlopeYAdj(&camera->floorNorm, playerPosRot->rot.y, eyeAtDir->yaw, R_CAM_SLOPE_Y_ADJ_AMOUNT), + Camera_CalcSlopeYAdj(&camera->floorNorm, playerPosRot->rot.y, eyeAtDir->yaw, CAM_SLOPE_Y_ADJ_AMOUNT), playerHeight); } @@ -939,7 +1084,9 @@ s32 func_800458D4(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, f32* arg3, s16 f32 eyeAtAngle; PosRot* playerPosRot = &camera->playerPosRot; f32 deltaY; - s32 pad[2]; + Vec3f* at = &camera->at; + f32 temp; + s32 pad; playerToAtOffsetTarget.y = Player_GetHeight(camera->player) + yOffset; playerToAtOffsetTarget.x = 0.0f; @@ -947,30 +1094,30 @@ s32 func_800458D4(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, f32* arg3, s16 if (calcSlopeYAdj) { playerToAtOffsetTarget.y -= - Camera_CalcSlopeYAdj(&camera->floorNorm, playerPosRot->rot.y, eyeAtDir->yaw, R_CAM_SLOPE_Y_ADJ_AMOUNT); + Camera_CalcSlopeYAdj(&camera->floorNorm, playerPosRot->rot.y, eyeAtDir->yaw, CAM_SLOPE_Y_ADJ_AMOUNT); } deltaY = playerPosRot->pos.y - *arg3; - eyeAtAngle = Math_FAtan2F(deltaY, OLib_Vec3fDistXZ(&camera->at, &camera->eye)); + eyeAtAngle = Math_FAtan2F(deltaY, OLib_Vec3fDistXZ(at, &camera->eye)); - if (eyeAtAngle > DEG_TO_RAD(OREG(32))) { + if (eyeAtAngle > DEG_TO_RAD(CAM_GLOBAL_32)) { if (1) {} - phi_f2 = 1.0f - sinf(eyeAtAngle - DEG_TO_RAD(OREG(32))); - } else if (eyeAtAngle < DEG_TO_RAD(OREG(33))) { - phi_f2 = 1.0f - sinf(DEG_TO_RAD(OREG(33)) - eyeAtAngle); + phi_f2 = 1.0f - sinf(eyeAtAngle - DEG_TO_RAD(CAM_GLOBAL_32)); + } else if (eyeAtAngle < DEG_TO_RAD(CAM_GLOBAL_33)) { + phi_f2 = 1.0f - sinf(DEG_TO_RAD(CAM_GLOBAL_33) - eyeAtAngle); } else { phi_f2 = 1.0f; } playerToAtOffsetTarget.y -= deltaY * phi_f2; - Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, CAM_DATA_SCALED(OREG(29)), - CAM_DATA_SCALED(OREG(30)), 0.1f); + Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, CAM_GLOBAL_29, CAM_GLOBAL_30, 0.1f); atTarget.x = playerPosRot->pos.x + camera->playerToAtOffset.x; atTarget.y = playerPosRot->pos.y + camera->playerToAtOffset.y; atTarget.z = playerPosRot->pos.z + camera->playerToAtOffset.z; - Camera_LERPCeilVec3f(&atTarget, &camera->at, camera->atLERPStepScale, camera->atLERPStepScale, 0.2f); + temp = camera->atLERPStepScale; + Camera_LERPCeilVec3f(&atTarget, at, temp, camera->atLERPStepScale, 0.2f); return 1; } @@ -995,7 +1142,7 @@ s32 func_80045B08(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, s16 arg3) { phi_f2 = -Math_CosS(playerPosRot->rot.y - eyeAtDir->yaw); } - playerToAtOffsetTarget.y -= temp_ret * phi_f2 * R_CAM_SLOPE_Y_ADJ_AMOUNT; + playerToAtOffsetTarget.y -= temp_ret * phi_f2 * CAM_SLOPE_Y_ADJ_AMOUNT; Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, camera->yOffsetUpdateRate, camera->xzOffsetUpdateRate, 0.1f); @@ -1028,12 +1175,12 @@ s32 Camera_CalcAtForParallel(Camera* camera, VecGeo* arg1, f32 yOffset, f32* arg if (R_CAM_PARALLEL_LOCKON_CALC_SLOPE_Y_ADJ && calcSlopeYAdj) { playerToAtOffsetTarget.y -= - Camera_CalcSlopeYAdj(&camera->floorNorm, playerPosRot->rot.y, arg1->yaw, R_CAM_SLOPE_Y_ADJ_AMOUNT); + Camera_CalcSlopeYAdj(&camera->floorNorm, playerPosRot->rot.y, arg1->yaw, CAM_SLOPE_Y_ADJ_AMOUNT); } if (camera->playerGroundY == camera->playerPosRot.pos.y || camera->player->actor.gravity > -0.1f || camera->player->stateFlags1 & PLAYER_STATE1_21) { - *arg3 = Camera_LERPCeilF(playerPosRot->pos.y, *arg3, CAM_DATA_SCALED(OREG(43)), 0.1f); + *arg3 = Camera_LERPCeilF(playerPosRot->pos.y, *arg3, CAM_GLOBAL_43, 0.1f); phi_f20 = playerPosRot->pos.y - *arg3; playerToAtOffsetTarget.y -= phi_f20; Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, camera->yOffsetUpdateRate, @@ -1056,19 +1203,18 @@ s32 Camera_CalcAtForParallel(Camera* camera, VecGeo* arg1, f32 yOffset, f32* arg } else { phi_f20 = playerPosRot->pos.y - *arg3; temp_f2 = Math_FAtan2F(phi_f20, OLib_Vec3fDistXZ(at, eye)); - if (DEG_TO_RAD(OREG(32)) < temp_f2) { - phi_f16 = 1 - sinf(temp_f2 - DEG_TO_RAD(OREG(32))); - } else if (temp_f2 < DEG_TO_RAD(OREG(33))) { - phi_f16 = 1 - sinf(DEG_TO_RAD(OREG(33)) - temp_f2); + if (DEG_TO_RAD(CAM_GLOBAL_32) < temp_f2) { + phi_f16 = 1 - sinf(temp_f2 - DEG_TO_RAD(CAM_GLOBAL_32)); + } else if (temp_f2 < DEG_TO_RAD(CAM_GLOBAL_33)) { + phi_f16 = 1 - sinf(DEG_TO_RAD(CAM_GLOBAL_33) - temp_f2); } else { phi_f16 = 1; } playerToAtOffsetTarget.y -= phi_f20 * phi_f16; } - Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, CAM_DATA_SCALED(OREG(29)), - CAM_DATA_SCALED(OREG(30)), 0.1f); - camera->yOffsetUpdateRate = CAM_DATA_SCALED(OREG(29)); - camera->xzOffsetUpdateRate = CAM_DATA_SCALED(OREG(30)); + Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, CAM_GLOBAL_29, CAM_GLOBAL_30, 0.1f); + camera->yOffsetUpdateRate = CAM_GLOBAL_29; + camera->xzOffsetUpdateRate = CAM_GLOBAL_30; } atTarget.x = playerPosRot->pos.x + camera->playerToAtOffset.x; atTarget.y = playerPosRot->pos.y + camera->playerToAtOffset.y; @@ -1103,7 +1249,7 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targetPos, f playerToAtOffsetTarget.z = 0.0f; if (R_CAM_PARALLEL_LOCKON_CALC_SLOPE_Y_ADJ && (flags & CAM_LOCKON_AT_FLAG_CALC_SLOPE_Y_ADJ)) { playerToAtOffsetTarget.y -= - Camera_CalcSlopeYAdj(floorNorm, playerPosRot->rot.y, eyeAtDir->yaw, R_CAM_SLOPE_Y_ADJ_AMOUNT); + Camera_CalcSlopeYAdj(floorNorm, playerPosRot->rot.y, eyeAtDir->yaw, CAM_SLOPE_Y_ADJ_AMOUNT); } // tmpPos1 is player's head @@ -1112,13 +1258,13 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targetPos, f *outPlayerToTargetDir = OLib_Vec3fDiffToVecGeo(&tmpPos1, targetPos); playerToTargetDir = *outPlayerToTargetDir; if (distance < playerToTargetDir.r) { - playerToTargetDir.r = playerToTargetDir.r * CAM_DATA_SCALED(OREG(38)); + playerToTargetDir.r = playerToTargetDir.r * CAM_GLOBAL_38; } else { // ratio of player's height off ground to player's height. temp_f0_2 = OLib_ClampMaxDist((playerPosRot->pos.y - camera->playerGroundY) / playerHeight, 1.0f); - playerToTargetDir.r = (playerToTargetDir.r * CAM_DATA_SCALED(OREG(39))) - - (((CAM_DATA_SCALED(OREG(39)) - CAM_DATA_SCALED(OREG(38))) * playerToTargetDir.r) * - (playerToTargetDir.r / distance)); + playerToTargetDir.r = + (playerToTargetDir.r * CAM_GLOBAL_39) - + ((playerToTargetDir.r * (CAM_GLOBAL_39 - CAM_GLOBAL_38)) * (playerToTargetDir.r / distance)); playerToTargetDir.r -= (playerToTargetDir.r * temp_f0_2) * temp_f0_2; } @@ -1140,7 +1286,7 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targetPos, f if (camera->playerGroundY == camera->playerPosRot.pos.y || camera->player->actor.gravity > -0.1f || camera->player->stateFlags1 & PLAYER_STATE1_21) { - *yPosOffset = Camera_LERPCeilF(playerPosRot->pos.y, *yPosOffset, CAM_DATA_SCALED(OREG(43)), 0.1f); + *yPosOffset = Camera_LERPCeilF(playerPosRot->pos.y, *yPosOffset, CAM_GLOBAL_43, 0.1f); yPosDelta = playerPosRot->pos.y - *yPosOffset; playerToAtOffsetTarget.y -= yPosDelta; Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, camera->yOffsetUpdateRate, @@ -1164,20 +1310,19 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targetPos, f yPosDelta = playerPosRot->pos.y - *yPosOffset; temp_f0_2 = Math_FAtan2F(yPosDelta, OLib_Vec3fDistXZ(at, &camera->eye)); - if (temp_f0_2 > DEG_TO_RAD(OREG(32))) { - phi_f16 = 1.0f - sinf(temp_f0_2 - DEG_TO_RAD(OREG(32))); - } else if (temp_f0_2 < DEG_TO_RAD(OREG(33))) { - phi_f16 = 1.0f - sinf(DEG_TO_RAD(OREG(33)) - temp_f0_2); + if (temp_f0_2 > DEG_TO_RAD(CAM_GLOBAL_32)) { + phi_f16 = 1.0f - sinf(temp_f0_2 - DEG_TO_RAD(CAM_GLOBAL_32)); + } else if (temp_f0_2 < DEG_TO_RAD(CAM_GLOBAL_33)) { + phi_f16 = 1.0f - sinf(DEG_TO_RAD(CAM_GLOBAL_33) - temp_f0_2); } else { phi_f16 = 1.0f; } playerToAtOffsetTarget.y -= (yPosDelta * phi_f16); } - Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, CAM_DATA_SCALED(OREG(29)), - CAM_DATA_SCALED(OREG(30)), 0.1f); - camera->yOffsetUpdateRate = CAM_DATA_SCALED(OREG(29)); - camera->xzOffsetUpdateRate = CAM_DATA_SCALED(OREG(30)); + Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, CAM_GLOBAL_29, CAM_GLOBAL_30, 0.1f); + camera->yOffsetUpdateRate = CAM_GLOBAL_29; + camera->xzOffsetUpdateRate = CAM_GLOBAL_30; } tmpPos1.x = playerPosRot->pos.x + camera->playerToAtOffset.x; @@ -1212,8 +1357,8 @@ s32 Camera_CalcAtForHorse(Camera* camera, VecGeo* eyeAtDir, f32 yOffset, f32* yP playerToAtOffsetTarget.z = 0.0f; if (calcSlopeYAdj) { - playerToAtOffsetTarget.y -= Camera_CalcSlopeYAdj(&camera->floorNorm, camera->playerPosRot.rot.y, eyeAtDir->yaw, - R_CAM_SLOPE_Y_ADJ_AMOUNT); + playerToAtOffsetTarget.y -= + Camera_CalcSlopeYAdj(&camera->floorNorm, camera->playerPosRot.rot.y, eyeAtDir->yaw, CAM_SLOPE_Y_ADJ_AMOUNT); } Camera_LERPCeilVec3f(&playerToAtOffsetTarget, &camera->playerToAtOffset, camera->yOffsetUpdateRate, @@ -1233,17 +1378,17 @@ f32 Camera_LERPClampDist(Camera* camera, f32 dist, f32 min, f32 max) { if (dist < min) { distTarget = min; - rUpdateRateInvTarget = R_CAM_R_UPDATE_RATE_INV; + rUpdateRateInvTarget = CAM_R_UPDATE_RATE_INV; } else if (dist > max) { distTarget = max; - rUpdateRateInvTarget = R_CAM_R_UPDATE_RATE_INV; + rUpdateRateInvTarget = CAM_R_UPDATE_RATE_INV; } else { distTarget = dist; rUpdateRateInvTarget = 1.0f; } - camera->rUpdateRateInv = Camera_LERPCeilF(rUpdateRateInvTarget, camera->rUpdateRateInv, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); + camera->rUpdateRateInv = + Camera_LERPCeilF(rUpdateRateInvTarget, camera->rUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); return Camera_LERPCeilF(distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 0.2f); } @@ -1254,19 +1399,19 @@ f32 Camera_ClampDist(Camera* camera, f32 dist, f32 minDist, f32 maxDist, s16 tim if (dist < minDist) { distTarget = minDist; - rUpdateRateInvTarget = timer != 0 ? R_CAM_R_UPDATE_RATE_INV * 0.5f : R_CAM_R_UPDATE_RATE_INV; + rUpdateRateInvTarget = timer != 0 ? CAM_R_UPDATE_RATE_INV * 0.5f : CAM_R_UPDATE_RATE_INV; } else if (maxDist < dist) { distTarget = maxDist; - rUpdateRateInvTarget = timer != 0 ? R_CAM_R_UPDATE_RATE_INV * 0.5f : R_CAM_R_UPDATE_RATE_INV; + rUpdateRateInvTarget = timer != 0 ? CAM_R_UPDATE_RATE_INV * 0.5f : CAM_R_UPDATE_RATE_INV; } else { distTarget = dist; - rUpdateRateInvTarget = timer != 0 ? R_CAM_R_UPDATE_RATE_INV : 1.0f; + rUpdateRateInvTarget = timer != 0 ? CAM_R_UPDATE_RATE_INV : 1.0f; } - camera->rUpdateRateInv = Camera_LERPCeilF(rUpdateRateInvTarget, camera->rUpdateRateInv, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); + camera->rUpdateRateInv = + Camera_LERPCeilF(rUpdateRateInvTarget, camera->rUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); return Camera_LERPCeilF(distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 0.2f); } @@ -1285,7 +1430,7 @@ s16 Camera_CalcDefaultPitch(Camera* camera, s16 arg1, s16 arg2, s16 arg3) { if (ABS(target) < absCur) { stepScale = (1.0f / camera->pitchUpdateRateInv) * 3.0f; } else { - t = absCur * (1.0f / R_CAM_MAX_PITCH); + t = absCur * (1.0f / CAM_MAX_PITCH); pad = Camera_InterpolateCurve(0.8f, 1.0f - t); stepScale = (1.0f / camera->pitchUpdateRateInv) * pad; } @@ -1305,7 +1450,7 @@ s16 Camera_CalcDefaultYaw(Camera* camera, s16 cur, s16 target, f32 arg3, f32 acc speedT = COLPOLY_GET_NORMAL((s16)(angDelta - 0x7FFF)); } else { angDelta = target - (s16)(cur - 0x7FFF); - speedT = CAM_DATA_SCALED(OREG(48)); + speedT = CAM_GLOBAL_48; } updSpeed = Camera_InterpolateCurve(arg3, speedT); @@ -1348,7 +1493,7 @@ void func_80046E20(Camera* camera, VecGeo* eyeAdjustment, f32 minDist, f32 arg3, temp_f0 = OLib_Vec3fDist(at, &atEyeColChk.pos); *arg4 = temp_f0 > minDist ? 1.0f : temp_f0 / minDist; - anim->swingUpdateRate = CAM_DATA_SCALED(OREG(10)); + anim->swingUpdateRate = CAM_GLOBAL_10; anim->unk_18 = 1; anim->atEyePoly = eyeAtColChk.poly; newEyeAdjustment = OLib_Vec3fDiffToVecGeo(at, &peekAroundPoint); @@ -1384,7 +1529,7 @@ void func_80046E20(Camera* camera, VecGeo* eyeAdjustment, f32 minDist, f32 arg3, case 3: case 6: if (anim->unk_18 != 0) { - anim->swingUpdateRateTimer = OREG(52); + anim->swingUpdateRateTimer = CAM_GLOBAL_52; anim->unk_18 = 0; *eyeNext = *eye; } @@ -1396,16 +1541,16 @@ void func_80046E20(Camera* camera, VecGeo* eyeAdjustment, f32 minDist, f32 arg3, *eye = Camera_Vec3fTranslateByUnitVector(&atEyeColChk.pos, &atEyeColChk.norm, 1.0f); anim->atEyePoly = NULL; - if (temp_f0 < OREG(21)) { + if (temp_f0 < CAM_GLOBAL_21) { sp40.yaw = eyeAdjustment->yaw; sp40.pitch = Math_SinS(atEyeColChk.geoNorm.pitch + 0x3FFF) * 16380.0f; - sp40.r = (OREG(21) - temp_f0) * CAM_DATA_SCALED(OREG(22)); + sp40.r = (CAM_GLOBAL_21 - temp_f0) * CAM_GLOBAL_22; *eye = Camera_AddVecGeoToVec3f(eye, &sp40); } break; default: if (anim->unk_18 != 0) { - anim->swingUpdateRateTimer = OREG(52); + anim->swingUpdateRateTimer = CAM_GLOBAL_52; *eyeNext = *eye; anim->unk_18 = 0; } @@ -1443,10 +1588,9 @@ s32 Camera_Normal1(Camera* camera) { f32 rate = 0.1f; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - (1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = (1.0f + CAM_YOFFSET_NORM - CAM_YOFFSET_NORM * (68.0f / playerHeight)); sp94 = yNormal * CAM_DATA_SCALED(playerHeight); @@ -1462,9 +1606,7 @@ s32 Camera_Normal1(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -1473,8 +1615,8 @@ s32 Camera_Normal1(Camera* camera) { switch (camera->animState) { case 20: - camera->yawUpdateRateInv = OREG(27); - camera->pitchUpdateRateInv = OREG(27); + camera->yawUpdateRateInv = CAM_GLOBAL_27; + camera->pitchUpdateRateInv = CAM_GLOBAL_27; FALLTHROUGH; case 0: case 10: @@ -1489,7 +1631,7 @@ s32 Camera_Normal1(Camera* camera) { rwData->swing.swingUpdateRateTimer = 0; rwData->swingYawTarget = atEyeGeo.yaw; sUpdateCameraDirection = 0; - rwData->startSwingTimer = OREG(50) + OREG(51); + rwData->startSwingTimer = CAM_GLOBAL_50 + CAM_GLOBAL_51; break; default: break; @@ -1503,18 +1645,18 @@ s32 Camera_Normal1(Camera* camera) { } if (camera->xzSpeed > 0.001f) { - rwData->startSwingTimer = OREG(50) + OREG(51); + rwData->startSwingTimer = CAM_GLOBAL_50 + CAM_GLOBAL_51; } else if (rwData->startSwingTimer > 0) { - if (rwData->startSwingTimer > OREG(50)) { + if (rwData->startSwingTimer > CAM_GLOBAL_50) { rwData->swingYawTarget = atEyeGeo.yaw + ((s16)((s16)(camera->playerPosRot.rot.y - 0x7FFF) - atEyeGeo.yaw) / rwData->startSwingTimer); } rwData->startSwingTimer--; } - spA0 = camera->speedRatio * CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ); - sp9C = camera->speedRatio * CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y); - sp98 = rwData->swing.unk_18 != 0 ? CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) : spA0; + spA0 = camera->speedRatio * CAM_UPDATE_RATE_STEP_SCALE_XZ; + sp9C = camera->speedRatio * CAM_UPDATE_RATE_STEP_SCALE_Y; + sp98 = rwData->swing.unk_18 != 0 ? CAM_UPDATE_RATE_STEP_SCALE_XZ : spA0; sp94 = (camera->xzSpeed - rwData->unk_20) * (0.333333f); if (sp94 > 1.0f) { @@ -1531,24 +1673,22 @@ s32 Camera_Normal1(Camera* camera) { Camera_LERPCeilF(rwData->swing.swingUpdateRate + (f32)(rwData->swing.swingUpdateRateTimer * 2), camera->yawUpdateRateInv, sp98, rate); camera->pitchUpdateRateInv = - Camera_LERPCeilF((f32)R_CAM_PITCH_UPDATE_RATE_INV + (f32)(rwData->swing.swingUpdateRateTimer * 2), + Camera_LERPCeilF((f32)CAM_PITCH_UPDATE_RATE_INV + (f32)(rwData->swing.swingUpdateRateTimer * 2), camera->pitchUpdateRateInv, sp9C, rate); rwData->swing.swingUpdateRateTimer--; } else { - camera->yawUpdateRateInv = Camera_LERPCeilF(rwData->swing.swingUpdateRate - - ((OREG(49) * 0.01f) * rwData->swing.swingUpdateRate * sp94), - camera->yawUpdateRateInv, sp98, rate); + camera->yawUpdateRateInv = + Camera_LERPCeilF(rwData->swing.swingUpdateRate - (rwData->swing.swingUpdateRate * CAM_GLOBAL_49 * sp94), + camera->yawUpdateRateInv, sp98, rate); camera->pitchUpdateRateInv = - Camera_LERPCeilF(R_CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp9C, rate); + Camera_LERPCeilF(CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp9C, rate); } - camera->pitchUpdateRateInv = Camera_LERPCeilF(R_CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp9C, rate); - camera->xzOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE), camera->xzOffsetUpdateRate, spA0, rate); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, sp9C, rate); - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->yOffsetUpdateRate, - camera->speedRatio * 0.05f, rate); + camera->pitchUpdateRateInv = Camera_LERPCeilF(CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp9C, rate); + camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_XZ_OFFSET_UPDATE_RATE, camera->xzOffsetUpdateRate, spA0, rate); + camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, sp9C, rate); + camera->fovUpdateRate = + Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->yOffsetUpdateRate, camera->speedRatio * 0.05f, rate); if (roData->interfaceField & NORMAL1_FLAG_0) { t = Camera_GetPitchAdjFromFloorHeightDiffs(camera, atEyeGeo.yaw - 0x7FFF, false); @@ -1680,14 +1820,11 @@ s32 Camera_Normal2(Camera* camera) { f32 yNormal; playerHeight = Player_GetHeight(camera->player); - yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; @@ -1701,9 +1838,7 @@ s32 Camera_Normal2(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -1746,18 +1881,16 @@ s32 Camera_Normal2(Camera* camera) { atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); camera->speedRatio *= 0.5f; - spA4 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio; - spA0 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) * camera->speedRatio; + spA4 = CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio; + spA0 = CAM_UPDATE_RATE_STEP_SCALE_Y * camera->speedRatio; camera->yawUpdateRateInv = Camera_LERPCeilF(roData->unk_0C, camera->yawUpdateRateInv * camera->speedRatio, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); - camera->pitchUpdateRateInv = Camera_LERPCeilF(R_CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, spA0, 0.1f); - camera->xzOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE), camera->xzOffsetUpdateRate, spA4, 0.1f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, spA0, 0.1f); - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->yOffsetUpdateRate, - camera->speedRatio * 0.05f, 0.1f); + CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); + camera->pitchUpdateRateInv = Camera_LERPCeilF(CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, spA0, 0.1f); + camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_XZ_OFFSET_UPDATE_RATE, camera->xzOffsetUpdateRate, spA4, 0.1f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, spA0, 0.1f); + camera->fovUpdateRate = + Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->yOffsetUpdateRate, camera->speedRatio * 0.05f, 0.1f); if (!(roData->interfaceField & NORMAL2_FLAG_7)) { Camera_CalcAtDefault(camera, &atToEyeNextDir, roData->unk_00, roData->interfaceField & NORMAL2_FLAG_0); @@ -1823,7 +1956,7 @@ s32 Camera_Normal2(Camera* camera) { } camera->fov = Camera_LERPCeilF(rwData->unk_1C, camera->fov, camera->fovUpdateRate, 1.0f); - camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA); + camera->roll = Camera_LERPCeilS(0, camera->roll, .5f, 0xA); camera->atLERPStepScale = Camera_ClampLERPScale(camera, roData->unk_18); return 1; } @@ -1850,7 +1983,7 @@ s32 Camera_Normal3(Camera* camera) { f32 playerHeight; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->yOffset = GET_NEXT_RO_DATA(values) * CAM_DATA_SCALED(playerHeight); @@ -1864,9 +1997,7 @@ s32 Camera_Normal3(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sp7C = OLib_Vec3fDiffToVecGeo(at, eye); sp74 = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -1884,10 +2015,9 @@ s32 Camera_Normal3(Camera* camera) { rwData->unk_20 = camera->playerGroundY; rwData->swing.unk_16 = rwData->swing.unk_14 = rwData->swing.unk_18 = 0; rwData->swing.swingUpdateRate = roData->yawUpdateSpeed; - rwData->yawUpdAmt = - (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - sp7C.yaw) * (1.0f / R_CAM_DEFAULT_ANIM_TIME); + rwData->yawUpdAmt = (s16)((s16)(playerPosRot->rot.y - 0x7FFF) - sp7C.yaw) * (1.0f / CAM_DEFAULT_ANIM_TIME); rwData->distTimer = 10; - rwData->yawTimer = R_CAM_DEFAULT_ANIM_TIME; + rwData->yawTimer = CAM_DEFAULT_ANIM_TIME; camera->animState = 1; rwData->swing.swingUpdateRateTimer = 0; } @@ -1896,28 +2026,25 @@ s32 Camera_Normal3(Camera* camera) { rwData->distTimer--; } - sp98 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio; - sp94 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) * camera->speedRatio; + sp98 = CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio; + sp94 = CAM_UPDATE_RATE_STEP_SCALE_Y * camera->speedRatio; if (rwData->swing.swingUpdateRateTimer != 0) { camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpdateSpeed + (rwData->swing.swingUpdateRateTimer * 2), camera->yawUpdateRateInv, sp98, 0.1f); camera->pitchUpdateRateInv = - Camera_LERPCeilF((f32)R_CAM_PITCH_UPDATE_RATE_INV + (rwData->swing.swingUpdateRateTimer * 2), + Camera_LERPCeilF((f32)CAM_PITCH_UPDATE_RATE_INV + (rwData->swing.swingUpdateRateTimer * 2), camera->pitchUpdateRateInv, sp94, 0.1f); - if (1) {} rwData->swing.swingUpdateRateTimer--; } else { camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpdateSpeed, camera->yawUpdateRateInv, sp98, 0.1f); camera->pitchUpdateRateInv = - Camera_LERPCeilF(R_CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp94, 0.1f); + Camera_LERPCeilF(CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, sp94, 0.1f); } - camera->xzOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE), camera->xzOffsetUpdateRate, sp98, 0.1f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, sp94, 0.1f); - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->fovUpdateRate, sp94, 0.1f); + camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_XZ_OFFSET_UPDATE_RATE, camera->xzOffsetUpdateRate, sp98, 0.1f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, sp94, 0.1f); + camera->fovUpdateRate = Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->fovUpdateRate, sp94, 0.1f); t2 = Camera_GetPitchAdjFromFloorHeightDiffs(camera, sp7C.yaw - 0x7FFF, true); sp94 = ((1.0f / roData->unk_10) * 0.5f); @@ -1934,11 +2061,11 @@ s32 Camera_Normal3(Camera* camera) { phi_a0 = roData->pitchTarget - rwData->curPitch; sp84.pitch = Camera_LERPCeilS(phi_a0, sp74.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA); - if (sp84.pitch > R_CAM_MAX_PITCH) { - sp84.pitch = R_CAM_MAX_PITCH; + if (sp84.pitch > CAM_MAX_PITCH) { + sp84.pitch = CAM_MAX_PITCH; } - if (sp84.pitch < R_CAM_MIN_PITCH_1) { - sp84.pitch = R_CAM_MIN_PITCH_1; + if (sp84.pitch < CAM_MIN_PITCH_1) { + sp84.pitch = CAM_MIN_PITCH_1; } phi_a0 = playerPosRot->rot.y - (s16)(sp74.yaw - 0x7FFF); @@ -1957,6 +2084,7 @@ s32 Camera_Normal3(Camera* camera) { sp98 = sp98 + (sp94 * sp90); sp98 = (sp98 * phi_a0) / camera->yawUpdateRateInv; + if (1) {} sp84.yaw = fabsf(sp98) > (150.0f * (1.0f - camera->speedRatio)) ? (s16)(sp74.yaw + sp98) : sp74.yaw; if (rwData->yawTimer > 0) { @@ -2007,10 +2135,9 @@ s32 Camera_Parallel1(Camera* camera) { s32 pad3; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->distTarget = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; @@ -2025,9 +2152,7 @@ s32 Camera_Parallel1(Camera* camera) { roData->unk_1C = GET_NEXT_SCALED_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -2042,7 +2167,7 @@ s32 Camera_Parallel1(Camera* camera) { if (roData->interfaceField & PARALLEL1_FLAG_2) { rwData->animTimer = 20; } else { - rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME; + rwData->animTimer = CAM_DEFAULT_ANIM_TIME; } rwData->unk_00.x = 0.0f; rwData->yTarget = playerPosRot->pos.y - camera->playerPosDelta.y; @@ -2077,18 +2202,16 @@ s32 Camera_Parallel1(Camera* camera) { camera->animState = 1; } - spB8 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio; - spB4 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) * camera->speedRatio; + spB8 = CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio; + spB4 = CAM_UPDATE_RATE_STEP_SCALE_Y * camera->speedRatio; - camera->rUpdateRateInv = Camera_LERPCeilF(R_CAM_R_UPDATE_RATE_INV, camera->rUpdateRateInv, spB8, 0.1f); + camera->rUpdateRateInv = Camera_LERPCeilF(CAM_R_UPDATE_RATE_INV, camera->rUpdateRateInv, spB8, 0.1f); camera->yawUpdateRateInv = Camera_LERPCeilF(roData->unk_08, camera->yawUpdateRateInv, spB8, 0.1f); camera->pitchUpdateRateInv = Camera_LERPCeilF(2.0f, camera->pitchUpdateRateInv, spB4, 0.1f); - camera->xzOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE), camera->xzOffsetUpdateRate, spB8, 0.1f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, spB4, 0.1f); - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->fovUpdateRate, - camera->speedRatio * 0.05f, 0.1f); + camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_XZ_OFFSET_UPDATE_RATE, camera->xzOffsetUpdateRate, spB8, 0.1f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, spB4, 0.1f); + camera->fovUpdateRate = + Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.1f); if (roData->interfaceField & PARALLEL1_FLAG_0) { tangle = Camera_GetPitchAdjFromFloorHeightDiffs(camera, atToEyeDir.yaw - 0x7FFF, true); @@ -2143,12 +2266,12 @@ s32 Camera_Parallel1(Camera* camera) { spA8.pitch = Camera_LERPCeilS(phi_a0, atToEyeNextDir.pitch, 1.0f / camera->pitchUpdateRateInv, 4); - if (spA8.pitch > R_CAM_MAX_PITCH) { - spA8.pitch = R_CAM_MAX_PITCH; + if (spA8.pitch > CAM_MAX_PITCH) { + spA8.pitch = CAM_MAX_PITCH; } - if (spA8.pitch < R_CAM_MIN_PITCH_1) { - spA8.pitch = R_CAM_MIN_PITCH_1; + if (spA8.pitch < CAM_MIN_PITCH_1) { + spA8.pitch = CAM_MIN_PITCH_1; } } *eyeNext = Camera_AddVecGeoToVec3f(at, &spA8); @@ -2222,10 +2345,9 @@ s32 Camera_Jump1(Camera* camera) { f32 playerHeight; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->atYOffset = CAM_DATA_SCALED(GET_NEXT_RO_DATA(values)) * playerHeight * yNormal; roData->distMin = CAM_DATA_SCALED(GET_NEXT_RO_DATA(values)) * playerHeight * yNormal; @@ -2237,9 +2359,7 @@ s32 Camera_Jump1(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); // playerhead never gets used. playerhead = Actor_GetFocus(&camera->player->actor); @@ -2264,27 +2384,24 @@ s32 Camera_Jump1(Camera* camera) { } if (rwData->swing.swingUpdateRateTimer != 0) { - camera->yawUpdateRateInv = - Camera_LERPCeilF(roData->yawUpateRateTarget + rwData->swing.swingUpdateRateTimer, camera->yawUpdateRateInv, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); + camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpateRateTarget + rwData->swing.swingUpdateRateTimer, + camera->yawUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); camera->pitchUpdateRateInv = - Camera_LERPCeilF((f32)R_CAM_PITCH_UPDATE_RATE_INV + rwData->swing.swingUpdateRateTimer, - camera->pitchUpdateRateInv, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); + Camera_LERPCeilF((f32)CAM_PITCH_UPDATE_RATE_INV + rwData->swing.swingUpdateRateTimer, + camera->pitchUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); rwData->swing.swingUpdateRateTimer--; } else { - camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpateRateTarget, camera->yawUpdateRateInv, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); - camera->pitchUpdateRateInv = Camera_LERPCeilF((f32)R_CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); + camera->yawUpdateRateInv = + Camera_LERPCeilF(roData->yawUpateRateTarget, camera->yawUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); + camera->pitchUpdateRateInv = Camera_LERPCeilF((f32)CAM_PITCH_UPDATE_RATE_INV, camera->pitchUpdateRateInv, + CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); } camera->xzOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE), camera->xzOffsetUpdateRate, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); - camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); - camera->fovUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->yOffsetUpdateRate, 0.05f, 0.1f); + Camera_LERPCeilF(CAM_XZ_OFFSET_UPDATE_RATE, camera->xzOffsetUpdateRate, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); + camera->yOffsetUpdateRate = + Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); + camera->fovUpdateRate = Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->yOffsetUpdateRate, 0.05f, 0.1f); func_800458D4(camera, &eyeNextAtOffset, roData->atYOffset, &rwData->unk_1C, false); @@ -2292,8 +2409,8 @@ s32 Camera_Jump1(Camera* camera) { eyeDiffTarget = OLib_Vec3fDiffToVecGeo(at, eye); - eyeDiffGeo.r = Camera_LERPCeilF(eyeDiffTarget.r, eyeAtOffset.r, CAM_DATA_SCALED(OREG(29)), 1.0f); - eyeDiffGeo.pitch = Camera_LERPCeilS(eyeDiffTarget.pitch, eyeAtOffset.pitch, CAM_DATA_SCALED(OREG(29)), 0xA); + eyeDiffGeo.r = Camera_LERPCeilF(eyeDiffTarget.r, eyeAtOffset.r, CAM_GLOBAL_29, 1.0f); + eyeDiffGeo.pitch = Camera_LERPCeilS(eyeDiffTarget.pitch, eyeAtOffset.pitch, CAM_GLOBAL_29, 0xA); if (rwData->swing.unk_18) { eyeDiffGeo.yaw = @@ -2312,17 +2429,17 @@ s32 Camera_Jump1(Camera* camera) { eyeDiffGeo.r = roData->distMax; } - // Clamp the phi rotation at R_CAM_MAX_PITCH AND R_CAM_MIN_PITCH_2 - if (eyeDiffGeo.pitch > R_CAM_MAX_PITCH) { - eyeDiffGeo.pitch = R_CAM_MAX_PITCH; - } else if (eyeDiffGeo.pitch < R_CAM_MIN_PITCH_2) { - eyeDiffGeo.pitch = R_CAM_MIN_PITCH_2; + // Clamp the phi rotation at CAM_MAX_PITCH AND CAM_MIN_PITCH_2 + if (eyeDiffGeo.pitch > CAM_MAX_PITCH) { + eyeDiffGeo.pitch = CAM_MAX_PITCH; + } else if (eyeDiffGeo.pitch < CAM_MIN_PITCH_2) { + eyeDiffGeo.pitch = CAM_MIN_PITCH_2; } newEye = Camera_AddVecGeoToVec3f(at, &eyeDiffGeo); eyeNext->x = newEye.x; eyeNext->z = newEye.z; - eyeNext->y += (newEye.y - eyeNext->y) * CAM_DATA_SCALED(R_CAM_JUMP1_EYE_Y_STEP_SCALE); + eyeNext->y += (newEye.y - eyeNext->y) * CAM_JUMP1_EYE_Y_STEP_SCALE; if ((camera->status == CAM_STAT_ACTIVE) && !(roData->interfaceField & JUMP1_FLAG_4)) { func_80046E20(camera, &eyeDiffGeo, roData->distMin, roData->yawUpateRateTarget, &spA4, &rwData->swing); if (roData->interfaceField & JUMP1_FLAG_2) { @@ -2375,19 +2492,17 @@ s32 Camera_Jump2(Camera* camera) { s16 playerYawRot180; Jump2ReadOnlyData* roData = &camera->paramData.jump2.roData; Jump2ReadWriteData* rwData = &camera->paramData.jump2.rwData; - CameraModeValue* values; + s32 pad; f32 playerHeight; - f32 yNormal; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); - roData->atYOffset = - CAM_DATA_SCALED((camera->playerPosDelta.y > 0.0f ? -10.0f : 10.0f) + GET_NEXT_RO_DATA(values)) * - playerHeight * yNormal; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); + + sp90 = (camera->playerPosDelta.y > 0.0f) ? -10.0f : 10.0f; + roData->atYOffset = CAM_DATA_SCALED(sp90 + GET_NEXT_RO_DATA(values)) * playerHeight * yNormal; roData->minDist = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->maxDist = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->minMaxDistFactor = GET_NEXT_SCALED_RO_DATA(values); @@ -2398,9 +2513,7 @@ s32 Camera_Jump2(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -2424,7 +2537,7 @@ s32 Camera_Jump2(Camera* camera) { } yawDiff = (s16)(playerPosRot->rot.y - 0x7FFF) - atToEyeNextDir.yaw; - rwData->initYawDiff = ((yawDiff / R_CAM_DEFAULT_ANIM_TIME) / 4) * 3; + rwData->initYawDiff = ((yawDiff / CAM_DEFAULT_ANIM_TIME) / 4) * 3; if (roData->interfaceField & JUMP2_FLAG_1) { rwData->yawAdj = 0xA; } else { @@ -2434,21 +2547,20 @@ s32 Camera_Jump2(Camera* camera) { playerPosRot->pos.x -= camera->playerPosDelta.x; playerPosRot->pos.y -= camera->playerPosDelta.y; playerPosRot->pos.z -= camera->playerPosDelta.z; - rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME; + rwData->animTimer = CAM_DEFAULT_ANIM_TIME; camera->animState++; camera->atLERPStepScale = roData->atLERPStepScale; } - sp90 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio; - sp8C = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) * camera->speedRatio; + sp90 = CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio; + sp8C = CAM_UPDATE_RATE_STEP_SCALE_Y * camera->speedRatio; camera->yawUpdateRateInv = Camera_LERPCeilF(roData->yawUpdRateTarget, camera->yawUpdateRateInv, sp90, 0.1f); camera->xzOffsetUpdateRate = Camera_LERPCeilF(roData->xzUpdRateTarget, camera->xzOffsetUpdateRate, sp90, 0.1f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, sp8C, 0.1f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, sp8C, 0.1f); - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->yOffsetUpdateRate, - camera->speedRatio * 0.05f, 0.1f); - camera->rUpdateRateInv = OREG(27); + camera->fovUpdateRate = + Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->yOffsetUpdateRate, camera->speedRatio * 0.05f, 0.1f); + camera->rUpdateRateInv = CAM_GLOBAL_27; Camera_CalcAtDefault(camera, &atToEyeNextDir, roData->atYOffset, false); adjAtToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); @@ -2486,16 +2598,14 @@ s32 Camera_Jump2(Camera* camera) { if ((sp90 != BGCHECK_Y_MIN) && (playerPosRot->pos.y < sp90)) { // top of the climb is within 2.2x of the player's height. camera->pitchUpdateRateInv = - Camera_LERPCeilF(20.0f, camera->pitchUpdateRateInv, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); - camera->rUpdateRateInv = - Camera_LERPCeilF(20.0f, camera->rUpdateRateInv, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); + Camera_LERPCeilF(20.0f, camera->pitchUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); + camera->rUpdateRateInv = Camera_LERPCeilF(20.0f, camera->rUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); adjAtToEyeDir.pitch = Camera_LERPCeilS(0x1F4, atToEyeNextDir.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA); } else if ((playerPosRot->pos.y - rwData->floorY) < playerHeight) { // player is within his height of the ground. camera->pitchUpdateRateInv = - Camera_LERPCeilF(20.0f, camera->pitchUpdateRateInv, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); - camera->rUpdateRateInv = - Camera_LERPCeilF(20.0f, camera->rUpdateRateInv, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y), 0.1f); + Camera_LERPCeilF(20.0f, camera->pitchUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); + camera->rUpdateRateInv = Camera_LERPCeilF(20.0f, camera->rUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.1f); adjAtToEyeDir.pitch = Camera_LERPCeilS(0x1F4, atToEyeNextDir.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA); } else { camera->pitchUpdateRateInv = 100.0f; @@ -2576,12 +2686,12 @@ s32 Camera_Jump3(Camera* camera) { playerhead = Actor_GetFocus(&camera->player->actor); modeSwitch = false; - if (((camera->waterYPos - eye->y) < OREG(44) || (camera->animState == 0))) { + if (((camera->waterYPos - eye->y) < CAM_GLOBAL_44 || (camera->animState == 0))) { if (rwData->mode != CAM_MODE_NORMAL) { rwData->mode = CAM_MODE_NORMAL; modeSwitch = true; } - } else if (((camera->waterYPos - eye->y) > OREG(45)) && (rwData->mode != CAM_MODE_AIM_BOOMERANG)) { + } else if (((camera->waterYPos - eye->y) > CAM_GLOBAL_45) && (rwData->mode != CAM_MODE_AIM_BOOMERANG)) { rwData->mode = CAM_MODE_AIM_BOOMERANG; modeSwitch = true; } @@ -2589,10 +2699,9 @@ s32 Camera_Jump3(Camera* camera) { eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); - if (RELOAD_PARAMS(camera) || modeSwitch || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || modeSwitch || CAM_DEBUG_RELOAD_PARAMS) { values = sCameraSettings[camera->setting].cameraModes[rwData->mode].values; - yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); t2 = CAM_DATA_SCALED(playerHeight) * yNormal; roData->yOffset = GET_NEXT_RO_DATA(values) * t2; roData->distMin = GET_NEXT_RO_DATA(values) * t2; @@ -2606,12 +2715,14 @@ s32 Camera_Jump3(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } +#if OOT_DEBUG if (R_RELOAD_CAM_PARAMS) { prevMode = camera->mode; camera->mode = rwData->mode; Camera_CopyPREGToModeValues(camera); camera->mode = prevMode; } +#endif sCameraInterfaceField = roData->interfaceField; @@ -2637,9 +2748,9 @@ s32 Camera_Jump3(Camera* camera) { spB0 = *eye; - spC4 = CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio; - spC0 = camera->speedRatio * CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y); - spBC = rwData->swing.unk_18 != 0 ? CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) : spC4; + spC4 = CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio; + spC0 = camera->speedRatio * CAM_UPDATE_RATE_STEP_SCALE_Y; + spBC = rwData->swing.unk_18 != 0 ? CAM_UPDATE_RATE_STEP_SCALE_XZ : spC4; if (rwData->swing.swingUpdateRateTimer != 0) { camera->yawUpdateRateInv = @@ -2654,12 +2765,10 @@ s32 Camera_Jump3(Camera* camera) { camera->pitchUpdateRateInv = Camera_LERPCeilF(40.0f, camera->pitchUpdateRateInv, spC0, 0.1f); } - camera->xzOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE), camera->xzOffsetUpdateRate, spC4, 0.1f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, spC0, 0.1f); - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->yOffsetUpdateRate, - camera->speedRatio * 0.05f, 0.1f); + camera->xzOffsetUpdateRate = Camera_LERPCeilF(CAM_XZ_OFFSET_UPDATE_RATE, camera->xzOffsetUpdateRate, spC4, 0.1f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, spC0, 0.1f); + camera->fovUpdateRate = + Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->yOffsetUpdateRate, camera->speedRatio * 0.05f, 0.1f); Camera_CalcAtDefault(camera, &eyeNextAtOffset, roData->yOffset, roData->interfaceField); eyeDiffGeo = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -2693,12 +2802,12 @@ s32 Camera_Jump3(Camera* camera) { eyeDiffGeo.pitch = Camera_CalcDefaultPitch(camera, eyeNextAtOffset.pitch, roData->pitchTarget, 0); } - if (eyeDiffGeo.pitch > R_CAM_MAX_PITCH) { - eyeDiffGeo.pitch = R_CAM_MAX_PITCH; + if (eyeDiffGeo.pitch > CAM_MAX_PITCH) { + eyeDiffGeo.pitch = CAM_MAX_PITCH; } - if (eyeDiffGeo.pitch < R_CAM_MIN_PITCH_1) { - eyeDiffGeo.pitch = R_CAM_MIN_PITCH_1; + if (eyeDiffGeo.pitch < CAM_MIN_PITCH_1) { + eyeDiffGeo.pitch = CAM_MIN_PITCH_1; } *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeDiffGeo); @@ -2782,10 +2891,9 @@ s32 Camera_Battle1(Camera* camera) { skipEyeAtCalc = false; player = camera->player; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->distance = GET_NEXT_RO_DATA(values); @@ -2800,12 +2908,10 @@ s32 Camera_Battle1(Camera* camera) { roData->yOffsetOffGround = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->atLERPScaleOffGround = GET_NEXT_SCALED_RO_DATA(values); rwData->chargeTimer = 40; - rwData->unk_10 = CAM_DATA_SCALED(OREG(12)); + rwData->unk_10 = CAM_GLOBAL_12; } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); distance = roData->distance; sp7C = roData->swingPitchInitial; @@ -2814,12 +2920,12 @@ s32 Camera_Battle1(Camera* camera) { if (camera->player->stateFlags1 & PLAYER_STATE1_12) { // charging sword. - rwData->unk_10 = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(12)) * 0.5f, rwData->unk_10, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); + rwData->unk_10 = + Camera_LERPCeilF(CAM_GLOBAL_12 * (1.0f - 0.5f), rwData->unk_10, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); camera->xzOffsetUpdateRate = - Camera_LERPCeilF(0.2f, camera->xzOffsetUpdateRate, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); + Camera_LERPCeilF(0.2f, camera->xzOffsetUpdateRate, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); camera->yOffsetUpdateRate = - Camera_LERPCeilF(0.2f, camera->yOffsetUpdateRate, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); + Camera_LERPCeilF(0.2f, camera->yOffsetUpdateRate, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); if (rwData->chargeTimer > -20) { rwData->chargeTimer--; } else { @@ -2836,17 +2942,16 @@ s32 Camera_Battle1(Camera* camera) { rwData->chargeTimer++; } else { rwData->chargeTimer = 40; - rwData->unk_10 = Camera_LERPCeilF(CAM_DATA_SCALED(OREG(12)), rwData->unk_10, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); + rwData->unk_10 = Camera_LERPCeilF(CAM_GLOBAL_12, rwData->unk_10, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); camera->xzOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_BATTLE1_XYZ_OFFSET_UPDATE_RATE_TARGET), camera->xzOffsetUpdateRate, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio, 0.1f); + Camera_LERPCeilF(CAM_BATTLE1_XYZ_OFFSET_UPDATE_RATE_TARGET, camera->xzOffsetUpdateRate, + CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio, 0.1f); camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_BATTLE1_XYZ_OFFSET_UPDATE_RATE_TARGET), camera->yOffsetUpdateRate, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) * camera->speedRatio, 0.1f); + Camera_LERPCeilF(CAM_BATTLE1_XYZ_OFFSET_UPDATE_RATE_TARGET, camera->yOffsetUpdateRate, + CAM_UPDATE_RATE_STEP_SCALE_Y * camera->speedRatio, 0.1f); } - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->fovUpdateRate, - camera->speedRatio * 0.05f, 0.1f); + camera->fovUpdateRate = + Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.1f); playerHeight += roData->yOffset; atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); atToEyeNextDir = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -2866,6 +2971,8 @@ s32 Camera_Battle1(Camera* camera) { rwData->roll = 0.0f; rwData->target = camera->target; camera->animState++; + +#if OOT_DEBUG if (rwData->target->id > 0) { PRINTF("camera: battle: target actor name " VT_FGCOL(BLUE) "%d" VT_RST "\n", rwData->target->id); } else { @@ -2874,7 +2981,9 @@ s32 Camera_Battle1(Camera* camera) { Camera_RequestMode(camera, CAM_MODE_Z_PARALLEL); return true; } - rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME + OREG(24); +#endif + + rwData->animTimer = CAM_DEFAULT_ANIM_TIME + CAM_GLOBAL_24; rwData->initialEyeToAtYaw = atToEyeDir.yaw; rwData->initialEyeToAtPitch = atToEyeDir.pitch; rwData->initialEyeToAtDist = atToEyeDir.r; @@ -2918,33 +3027,31 @@ s32 Camera_Battle1(Camera* camera) { playerHead = playerPosRot->pos; playerHead.y += playerHeight; playerToTargetDir = OLib_Vec3fDiffToVecGeo(&playerHead, &camera->targetPosRot.pos); - distRatio = playerToTargetDir.r > distance ? 1 : playerToTargetDir.r / distance; + distRatio = playerToTargetDir.r > distance ? 1.0f : playerToTargetDir.r / distance; targetPos = camera->targetPosRot.pos; atToTargetDir = OLib_Vec3fDiffToVecGeo(at, &targetPos); atToTargetDir.r = distance - ((atToTargetDir.r <= distance ? atToTargetDir.r : distance) * 0.5f); swingAngle = roData->swingYawInitial + ((roData->swingYawFinal - roData->swingYawInitial) * (1.1f - distRatio)); - spF8 = OREG(13) + swingAngle; + spF8 = swingAngle + CAM_GLOBAL_13; - spB4.r = camera->dist = Camera_LERPCeilF(distance, camera->dist, CAM_DATA_SCALED(OREG(11)), 2.0f); + spB4.r = camera->dist = Camera_LERPCeilF(distance, camera->dist, CAM_GLOBAL_11, 2.0f); spB4.yaw = atToEyeNextDir.yaw; tmpAng1 = (s16)(atToTargetDir.yaw - (s16)(atToEyeNextDir.yaw - 0x7FFF)); if (rwData->animTimer != 0) { - if (rwData->animTimer >= OREG(24)) { - sp86 = rwData->animTimer - OREG(24); + if (rwData->animTimer >= CAM_GLOBAL_24) { + sp86 = rwData->animTimer - CAM_GLOBAL_24; playerToTargetDir = OLib_Vec3fDiffToVecGeo(at, eye); playerToTargetDir.yaw = tmpAng2 - 0x7FFF; - var2 = 1.0f / R_CAM_DEFAULT_ANIM_TIME; + var2 = 1.0f / CAM_DEFAULT_ANIM_TIME; var3 = (rwData->initialEyeToAtDist - playerToTargetDir.r) * var2; tmpAng1 = (s16)(rwData->initialEyeToAtYaw - playerToTargetDir.yaw) * var2; tmpAng2 = (s16)(rwData->initialEyeToAtPitch - playerToTargetDir.pitch) * var2; - spB4.r = - Camera_LERPCeilF(playerToTargetDir.r + (var3 * sp86), atToEyeDir.r, CAM_DATA_SCALED(OREG(28)), 1.0f); - spB4.yaw = Camera_LERPCeilS(playerToTargetDir.yaw + (tmpAng1 * sp86), atToEyeDir.yaw, - CAM_DATA_SCALED(OREG(28)), 0xA); - spB4.pitch = Camera_LERPCeilS(playerToTargetDir.pitch + (tmpAng2 * sp86), atToEyeDir.pitch, - CAM_DATA_SCALED(OREG(28)), 0xA); + spB4.r = Camera_LERPCeilF(playerToTargetDir.r + (var3 * sp86), atToEyeDir.r, CAM_GLOBAL_28, 1.0f); + spB4.yaw = Camera_LERPCeilS(playerToTargetDir.yaw + (tmpAng1 * sp86), atToEyeDir.yaw, CAM_GLOBAL_28, 0xA); + spB4.pitch = + Camera_LERPCeilS(playerToTargetDir.pitch + (tmpAng2 * sp86), atToEyeDir.pitch, CAM_GLOBAL_28, 0xA); } else { skipEyeAtCalc = true; } @@ -2959,7 +3066,7 @@ s32 Camera_Battle1(Camera* camera) { spB4.yaw = (s16)((s16)(atToEyeNextDir.yaw - 0x7FFF) + tmpAng2) - 0x7FFF; } else { spFC = 0.05f; - spFC = (1 - camera->speedRatio) * spFC; + spFC = (1.0f - camera->speedRatio) * spFC; tmpAng2 = tmpAng1 >= 0 ? CAM_DEG_TO_BINANG(swingAngle) : -CAM_DEG_TO_BINANG(swingAngle); spB4.yaw = atToEyeNextDir.yaw - (s16)((tmpAng2 - tmpAng1) * spFC); } @@ -2967,7 +3074,8 @@ s32 Camera_Battle1(Camera* camera) { if (!skipEyeAtCalc) { var3 = atToTargetDir.pitch * roData->swingPitchAdj; var2 = F32_LERPIMP(sp7C, sp78, distRatio); - tmpAng1 = CAM_DEG_TO_BINANG(var2) - (s16)(playerToTargetDir.pitch * (0.5f + distRatio * (1.0f - 0.5f))); + tmpAng1 = + CAM_DEG_TO_BINANG(var2) - (s16)(playerToTargetDir.pitch * ((1.0f - 0.5f) + distRatio * (1.0f - 0.5f))); tmpAng1 += (s16)(var3); if (tmpAng1 < -0x2AA8) { @@ -2995,8 +3103,8 @@ s32 Camera_Battle1(Camera* camera) { *eye = *eyeNext; } } - rwData->roll += ((R_CAM_BATTLE1_ROLL_TARGET_BASE * camera->speedRatio * (1.0f - distRatio)) - rwData->roll) * - CAM_DATA_SCALED(R_CAM_BATTLE1_ROLL_STEP_SCALE); + rwData->roll += ((CAM_BATTLE1_ROLL_TARGET_BASE * camera->speedRatio * (1.0f - distRatio)) - rwData->roll) * + CAM_BATTLE1_ROLL_STEP_SCALE; camera->roll = CAM_DEG_TO_BINANG(rwData->roll); camera->fov = Camera_LERPCeilF((player->meleeWeaponState != 0 ? 0.8f : gSaveContext.save.info.playerData.health <= 0x10 ? 0.8f @@ -3031,10 +3139,9 @@ s32 Camera_Battle4(Camera* camera) { f32 playerHeight; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->rTarget = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; @@ -3045,9 +3152,7 @@ s32 Camera_Battle4(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); eyeNextAtOffset = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -3063,16 +3168,14 @@ s32 Camera_Battle4(Camera* camera) { break; } - camera->yawUpdateRateInv = - Camera_LERPCeilF(roData->lerpUpdateRate, camera->yawUpdateRateInv, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio, 0.1f); + camera->yawUpdateRateInv = Camera_LERPCeilF(roData->lerpUpdateRate, camera->yawUpdateRateInv, + CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio, 0.1f); camera->rUpdateRateInv = 1000.0f; camera->pitchUpdateRateInv = 1000.0f; camera->xzOffsetUpdateRate = - Camera_LERPCeilF(0.025f, camera->xzOffsetUpdateRate, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE), camera->yOffsetUpdateRate, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) * camera->speedRatio, 0.1f); + Camera_LERPCeilF(0.025f, camera->xzOffsetUpdateRate, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(CAM_Y_OFFSET_UPDATE_RATE, camera->yOffsetUpdateRate, + CAM_UPDATE_RATE_STEP_SCALE_Y * camera->speedRatio, 0.1f); camera->fovUpdateRate = 0.0001f; Camera_CalcAtDefault(camera, &eyeNextAtOffset, roData->yOffset, true); if (rwData->animTimer != 0) { @@ -3144,10 +3247,9 @@ s32 Camera_KeepOn1(Camera* camera) { return 1; } - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->unk_00 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->unk_04 = GET_NEXT_RO_DATA(values); @@ -3163,9 +3265,7 @@ s32 Camera_KeepOn1(Camera* camera) { roData->unk_28 = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->unk_2C = GET_NEXT_SCALED_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); playerHeight += roData->unk_00; spC0 = OLib_Vec3fDiffToVecGeo(at, eye); @@ -3176,7 +3276,7 @@ s32 Camera_KeepOn1(Camera* camera) { rwData->unk_10 = 0; rwData->unk_04 = 0.0f; rwData->unk_0C = camera->target; - rwData->unk_16 = R_CAM_DEFAULT_ANIM_TIME + OREG(24); + rwData->unk_16 = CAM_DEFAULT_ANIM_TIME + CAM_GLOBAL_24; rwData->unk_12 = spC0.yaw; rwData->unk_14 = spC0.pitch; rwData->unk_00 = spC0.r; @@ -3210,14 +3310,12 @@ s32 Camera_KeepOn1(Camera* camera) { rwData->unk_0C = camera->target; camera->atLERPStepScale = 0.0f; } - camera->xzOffsetUpdateRate = - Camera_LERPCeilF(1.0f, camera->xzOffsetUpdateRate, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ) * camera->speedRatio, 0.1f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(1.0f, camera->yOffsetUpdateRate, - CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_Y) * camera->speedRatio, 0.1f); - camera->fovUpdateRate = Camera_LERPCeilF(CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), camera->fovUpdateRate, - camera->speedRatio * 0.05f, 0.1f); + camera->xzOffsetUpdateRate = Camera_LERPCeilF(1.0f, camera->xzOffsetUpdateRate, + CAM_UPDATE_RATE_STEP_SCALE_XZ * camera->speedRatio, 0.1f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(1.0f, camera->yOffsetUpdateRate, + CAM_UPDATE_RATE_STEP_SCALE_Y * camera->speedRatio, 0.1f); + camera->fovUpdateRate = + Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->fovUpdateRate, camera->speedRatio * 0.05f, 0.1f); goto cont; case CAM_VIEW_TARGET_POS: rwData->unk_0C = NULL; @@ -3247,41 +3345,40 @@ s32 Camera_KeepOn1(Camera* camera) { spD8 = OLib_Vec3fDiffToVecGeo(at, eyeNext); if (spD8.r < roData->unk_04) { sp104 = roData->unk_04; - spE8 = R_CAM_R_UPDATE_RATE_INV; + spE8 = CAM_R_UPDATE_RATE_INV; } else if (roData->unk_08 < spD8.r) { sp104 = roData->unk_08; - spE8 = R_CAM_R_UPDATE_RATE_INV; + spE8 = CAM_R_UPDATE_RATE_INV; } else { sp104 = spD8.r; spE8 = 1.0f; } - camera->rUpdateRateInv = - Camera_LERPCeilF(spE8, camera->rUpdateRateInv, CAM_DATA_SCALED(R_CAM_UPDATE_RATE_STEP_SCALE_XZ), 0.1f); + camera->rUpdateRateInv = Camera_LERPCeilF(spE8, camera->rUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); spD8.r = spE8 = camera->dist = Camera_LERPCeilF(sp104, camera->dist, 1.0f / camera->rUpdateRateInv, 0.2f); sp108 = camera->targetPosRot.pos; spD0 = OLib_Vec3fDiffToVecGeo(at, &sp108); spD0.r = spE8 - ((spD0.r <= spE8 ? spD0.r : spE8) * 0.5f); spEC = roData->unk_0C + ((roData->unk_10 - roData->unk_0C) * (1.1f - sp84)); - spF0 = OREG(13) + spEC; - spD8.r = camera->dist = Camera_LERPCeilF(spE8, camera->dist, CAM_DATA_SCALED(OREG(11)), 2.0f); + spF0 = spEC + CAM_GLOBAL_13; + spD8.r = camera->dist = Camera_LERPCeilF(spE8, camera->dist, CAM_GLOBAL_11, 2.0f); spD8.yaw = spB8.yaw; spE2 = spD0.yaw - (s16)(spB8.yaw - 0x7FFF); if (rwData->unk_16 != 0) { - if (rwData->unk_16 >= OREG(24)) { - sp82 = rwData->unk_16 - OREG(24); + if (rwData->unk_16 >= CAM_GLOBAL_24) { + sp82 = rwData->unk_16 - CAM_GLOBAL_24; spE2 = spC8.yaw; spC8 = OLib_Vec3fDiffToVecGeo(at, eye); spC8.yaw = spE2 - 0x7FFF; - t2 = 1.0f / R_CAM_DEFAULT_ANIM_TIME; + t2 = 1.0f / CAM_DEFAULT_ANIM_TIME; spE8 = (rwData->unk_00 - spC8.r) * t2; spE2 = (s16)(rwData->unk_12 - spC8.yaw) * t2; spE0 = (s16)(rwData->unk_14 - spC8.pitch) * t2; - spD8.r = Camera_LERPCeilF(spC8.r + (spE8 * sp82), spC0.r, CAM_DATA_SCALED(OREG(28)), 1.0f); - spD8.yaw = Camera_LERPCeilS(spC8.yaw + (spE2 * sp82), spC0.yaw, CAM_DATA_SCALED(OREG(28)), 0xA); - spD8.pitch = Camera_LERPCeilS(spC8.pitch + (spE0 * sp82), spC0.pitch, CAM_DATA_SCALED(OREG(28)), 0xA); + spD8.r = Camera_LERPCeilF(spC8.r + (spE8 * sp82), spC0.r, CAM_GLOBAL_28, 1.0f); + spD8.yaw = Camera_LERPCeilS(spC8.yaw + (spE2 * sp82), spC0.yaw, CAM_GLOBAL_28, 0xA); + spD8.pitch = Camera_LERPCeilS(spC8.pitch + (spE0 * sp82), spC0.pitch, CAM_GLOBAL_28, 0xA); } else { sp88 = 1; } @@ -3313,7 +3410,7 @@ s32 Camera_KeepOn1(Camera* camera) { spE2 = 0x3200; } - spD8.pitch = Camera_LERPCeilS(spE2, spB8.pitch, CAM_DATA_SCALED(OREG(12)), 0xA); + spD8.pitch = Camera_LERPCeilS(spE2, spB8.pitch, CAM_GLOBAL_12, 0xA); *eyeNext = Camera_AddVecGeoToVec3f(at, &spD8); sp8C.pos = *eyeNext; if (camera->status == CAM_STAT_ACTIVE) { @@ -3332,7 +3429,7 @@ s32 Camera_KeepOn1(Camera* camera) { *eye = *eyeNext; } sp120 = OLib_Vec3fDistNormalize(eye, at); - *eye = Camera_Vec3fTranslateByUnitVector(eye, &sp120, OREG(1)); + *eye = Camera_Vec3fTranslateByUnitVector(eye, &sp120, CAM_GLOBAL_1); } camera->fov = Camera_LERPCeilF(roData->unk_20, camera->fov, camera->fovUpdateRate, 1.0f); camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA); @@ -3391,10 +3488,9 @@ s32 Camera_KeepOn3(Camera* camera) { camera->stateFlags &= ~CAM_STATE_LOCK_MODE; } camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->minDist = GET_NEXT_RO_DATA(values); @@ -3410,9 +3506,7 @@ s32 Camera_KeepOn3(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); playerHeight += roData->yOffset; atToEyeDir = OLib_Vec3fDiffToVecGeo(at, eye); @@ -3584,7 +3678,7 @@ s32 Camera_KeepOn4(Camera* camera) { playerHeight = Player_GetHeight(camera->player); camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; f32 yNormal = 1.0f + t - (68.0f / playerHeight * t); @@ -3684,12 +3778,12 @@ s32 Camera_KeepOn4(Camera* camera) { roData->unk_00 = playerHeight * -0.3f * yNormal; roData->unk_04 = playerHeight * 1.5f * yNormal; roData->unk_08 = 2.0f; + roData->unk_18 = 45.0f; roData->unk_0C = 20.0f; roData->unk_10 = 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; break; case 11: @@ -3706,9 +3800,7 @@ s32 Camera_KeepOn4(Camera* camera) { } } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sUpdateCameraDirection = 1; sCameraInterfaceField = roData->interfaceField; @@ -3785,7 +3877,9 @@ s32 Camera_KeepOn4(Camera* camera) { spB8.pitch = D_8011D3CC[i] + spA2; D_8015BD70 = Camera_AddVecGeoToVec3f(&D_8015BD50, &spB8); } +#if OOT_DEBUG PRINTF("camera: item: BG&collision check %d time(s)\n", i); +#endif } rwData->unk_04 = (s16)(spB8.pitch - spA8.pitch) / (f32)rwData->unk_10; rwData->unk_00 = (s16)(spB8.yaw - spA8.yaw) / (f32)rwData->unk_10; @@ -3865,7 +3959,7 @@ s32 Camera_KeepOn0(Camera* camera) { camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->fovScale = GET_NEXT_SCALED_RO_DATA(values); @@ -3874,9 +3968,7 @@ s32 Camera_KeepOn0(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); *eyeNext = Camera_Vec3sToVec3f(&bgCamFuncData->pos); @@ -3940,7 +4032,7 @@ s32 Camera_Fixed1(Camera* camera) { f32 playerHeight; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); @@ -3954,9 +4046,7 @@ s32 Camera_Fixed1(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); if (rwData->fov == -1) { rwData->fov = roData->fov * 100.0f; } else if (rwData->fov <= 360) { @@ -4014,10 +4104,9 @@ s32 Camera_Fixed2(Camera* camera) { playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = (GET_NEXT_SCALED_RO_DATA(values) * playerHeight) * yNormal; roData->eyeStepScale = GET_NEXT_SCALED_RO_DATA(values); @@ -4040,9 +4129,7 @@ s32 Camera_Fixed2(Camera* camera) { } } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -4097,7 +4184,7 @@ s32 Camera_Fixed3(Camera* camera) { eyeAtOffset = OLib_Vec3fDiffToVecGeo(eye, at); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->interfaceField = GET_NEXT_RO_DATA(values); @@ -4114,9 +4201,7 @@ s32 Camera_Fixed3(Camera* camera) { } } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); if (camera->animState == 0) { rwData->updDirTimer = 5; @@ -4172,10 +4257,9 @@ s32 Camera_Fixed4(Camera* camera) { playerYOffset = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerYOffset)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerYOffset)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerYOffset * yNormal; roData->speedToEyePos = GET_NEXT_SCALED_RO_DATA(values); @@ -4190,9 +4274,7 @@ s32 Camera_Fixed4(Camera* camera) { rwData->eyeTarget = *eye; } } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; if (camera->animState == 0) { camera->animState++; @@ -4276,7 +4358,11 @@ s32 Camera_Subj3(Camera* camera) { } func_80043ABC(camera); + +#if OOT_DEBUG Camera_CopyPREGToModeValues(camera); +#endif + values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->eyeNextYOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight; roData->eyeDist = GET_NEXT_RO_DATA(values); @@ -4301,7 +4387,7 @@ s32 Camera_Subj3(Camera* camera) { rwData->r = sp7C.r; rwData->yaw = sp7C.yaw; rwData->pitch = sp7C.pitch; - rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME; + rwData->animTimer = CAM_DEFAULT_ANIM_TIME; camera->dist = roData->eyeNextDist; camera->animState++; camera->rUpdateRateInv = 1.0f; @@ -4317,15 +4403,14 @@ s32 Camera_Subj3(Camera* camera) { at->y = F32_LERPIMP(at->y, sp98.y, temp_f0_3); at->z = F32_LERPIMP(at->z, sp98.z, temp_f0_3); - temp_f0_3 = (1.0f / R_CAM_DEFAULT_ANIM_TIME); + temp_f0_3 = (1.0f / CAM_DEFAULT_ANIM_TIME); sp58 = (tGeo.r - sp84.r) * temp_f0_3; sp52 = (s16)(tGeo.yaw - sp84.yaw) * temp_f0_3; sp50 = (s16)(tGeo.pitch - sp84.pitch) * temp_f0_3; - sp7C.r = Camera_LERPCeilF(sp84.r + (sp58 * rwData->animTimer), sp7C.r, CAM_DATA_SCALED(OREG(28)), 1.0f); - sp7C.yaw = Camera_LERPCeilS(sp84.yaw + (sp52 * rwData->animTimer), sp7C.yaw, CAM_DATA_SCALED(OREG(28)), 0xA); - sp7C.pitch = - Camera_LERPCeilS(sp84.pitch + (sp50 * rwData->animTimer), sp7C.pitch, CAM_DATA_SCALED(OREG(28)), 0xA); + sp7C.r = Camera_LERPCeilF(sp84.r + (sp58 * rwData->animTimer), sp7C.r, CAM_GLOBAL_28, 1.0f); + sp7C.yaw = Camera_LERPCeilS(sp84.yaw + (sp52 * rwData->animTimer), sp7C.yaw, CAM_GLOBAL_28, 0xA); + sp7C.pitch = Camera_LERPCeilS(sp84.pitch + (sp50 * rwData->animTimer), sp7C.pitch, CAM_GLOBAL_28, 0xA); *eyeNext = Camera_AddVecGeoToVec3f(at, &sp7C); *eye = *eyeNext; @@ -4389,13 +4474,13 @@ s32 Camera_Subj4(Camera* camera) { Vec3f temp1; Vec3f zoomAtTarget; f32 temp2; - Player* player; + s32 pad1; f32 eyeLerp; PosRot playerPosRot; VecGeo targetOffset; VecGeo atEyeOffset; s16 eyeToAtYaw; - s32 pad[2]; + s32 pad2; f32 temp; Subj4ReadOnlyData* roData = &camera->paramData.subj4.roData; Subj4ReadWriteData* rwData = &camera->paramData.subj4.rwData; @@ -4405,15 +4490,13 @@ s32 Camera_Subj4(Camera* camera) { #define vPlayerDistToFront temp2 #define vZoomTimer temp2 - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); if (camera->play->view.unk_124 == 0) { camera->play->view.unk_124 = camera->camId | 0x50; @@ -4513,7 +4596,8 @@ s32 Camera_Subj4(Camera* camera) { // When camera reaches the peak of offset and starts to move down // && alternating cycles (sfx plays only every 2nd cycle) if ((eyeLerp > rwData->eyeLerp) && !rwData->isSfxOff) { - player = camera->player; + Player* player = camera->player; + rwData->isSfxOff = true; func_800F4010(&player->actor.projectedPos, NA_SE_PL_CRAWL + player->floorSfxOffset, 4.0f); } else if (eyeLerp < rwData->eyeLerp) { @@ -4570,19 +4654,18 @@ s32 Camera_Data4(Camera* camera) { Vec3f* eyeNext = &camera->eyeNext; BgCamFuncData* bgCamFuncData; Vec3f lookAt; - CameraModeValue* values; + s32 pad; Data4ReadWriteData* rwData = &camera->paramData.data4.rwData; Vec3f* eye = &camera->eye; f32 playerHeight; Vec3f* at = &camera->at; - s32 pad; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + + yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->fov = GET_NEXT_RO_DATA(values); roData->interfaceField = GET_NEXT_RO_DATA(values); @@ -4600,9 +4683,7 @@ s32 Camera_Data4(Camera* camera) { *eye = rwData->eyePosRot.pos; } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -4655,10 +4736,9 @@ s32 Camera_Unique1(Camera* camera) { s32 pad2; playerHeight = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->distMin = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; @@ -4669,9 +4749,7 @@ s32 Camera_Unique1(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS != 0) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sUpdateCameraDirection = 1; @@ -4686,7 +4764,7 @@ s32 Camera_Unique1(Camera* camera) { rwData->unk_00 = 0.0f; playerWaistPos = camera->player->bodyPartsPos[PLAYER_BODYPART_WAIST]; unk908PlayerPosOffset = OLib_Vec3fDiffToVecGeo(&playerPosRot->pos, &playerWaistPos); - rwData->timer = R_CAM_DEFAULT_ANIM_TIME; + rwData->timer = CAM_DEFAULT_ANIM_TIME; rwData->yawTargetAdj = ABS((s16)(unk908PlayerPosOffset.yaw - eyeAtOffset.yaw)) < 0x3A98 ? 0 : (((s16)(unk908PlayerPosOffset.yaw - eyeAtOffset.yaw) / rwData->timer) / 4) * 3; @@ -4695,15 +4773,13 @@ s32 Camera_Unique1(Camera* camera) { playerhead = Actor_GetFocus(&camera->player->actor); // unused - camera->yawUpdateRateInv = - Camera_LERPCeilF(100.0f, camera->yawUpdateRateInv, R_CAM_UPDATE_RATE_STEP_SCALE_XZ * 0.01f, 0.1f); + camera->yawUpdateRateInv = Camera_LERPCeilF(100.0f, camera->yawUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); camera->pitchUpdateRateInv = - Camera_LERPCeilF(100.0f, camera->pitchUpdateRateInv, R_CAM_UPDATE_RATE_STEP_SCALE_XZ * 0.01f, 0.1f); + Camera_LERPCeilF(100.0f, camera->pitchUpdateRateInv, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.1f); camera->xzOffsetUpdateRate = - Camera_LERPCeilF(0.005f, camera->xzOffsetUpdateRate, R_CAM_UPDATE_RATE_STEP_SCALE_XZ * 0.01f, 0.01f); - camera->yOffsetUpdateRate = - Camera_LERPCeilF(0.01f, camera->yOffsetUpdateRate, R_CAM_UPDATE_RATE_STEP_SCALE_Y * 0.01f, 0.01f); - camera->fovUpdateRate = Camera_LERPCeilF(R_CAM_FOV_UPDATE_RATE * 0.01f, camera->fovUpdateRate, 0.05f, 0.1f); + Camera_LERPCeilF(0.005f, camera->xzOffsetUpdateRate, CAM_UPDATE_RATE_STEP_SCALE_XZ, 0.01f); + camera->yOffsetUpdateRate = Camera_LERPCeilF(0.01f, camera->yOffsetUpdateRate, CAM_UPDATE_RATE_STEP_SCALE_Y, 0.01f); + camera->fovUpdateRate = Camera_LERPCeilF(CAM_FOV_UPDATE_RATE, camera->fovUpdateRate, 0.05f, 0.1f); Camera_CalcAtDefault(camera, &eyeNextAtOffset, roData->yOffset, true); sp8C = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -4713,11 +4789,11 @@ s32 Camera_Unique1(Camera* camera) { phiTarget = roData->pitchTarget; sp8C.pitch = Camera_LERPCeilS(phiTarget, eyeNextAtOffset.pitch, 1.0f / camera->pitchUpdateRateInv, 0xA); - if (sp8C.pitch > R_CAM_MAX_PITCH) { - sp8C.pitch = R_CAM_MAX_PITCH; + if (sp8C.pitch > CAM_MAX_PITCH) { + sp8C.pitch = CAM_MAX_PITCH; } - if (sp8C.pitch < -R_CAM_MAX_PITCH) { - sp8C.pitch = -R_CAM_MAX_PITCH; + if (sp8C.pitch < -CAM_MAX_PITCH) { + sp8C.pitch = -CAM_MAX_PITCH; } if (rwData->timer != 0) { @@ -4753,10 +4829,9 @@ s32 Camera_Unique2(Camera* camera) { eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->distTarget = GET_NEXT_RO_DATA(values); @@ -4764,9 +4839,7 @@ s32 Camera_Unique2(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -4830,19 +4903,16 @@ s32 Camera_Unique3(Camera* camera) { playerHeight = Player_GetHeight(camera->player); camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerHeight)); roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerHeight * yNormal; roData->fov = GET_NEXT_RO_DATA(values); roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS != 0) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -4942,7 +5012,7 @@ s32 Camera_Unique3(Camera* camera) { */ s32 Camera_Unique0(Camera* camera) { f32 yOffset; - CameraModeValue* values; + s16 fov; Player* player; Vec3f playerPosWithOffset; VecGeo atPlayerOffset; @@ -4953,19 +5023,17 @@ s32 Camera_Unique0(Camera* camera) { Unique0ReadOnlyData* roData = &camera->paramData.uniq0.roData; Unique0ReadWriteData* rwData = &camera->paramData.uniq0.rwData; Vec3f* eye = &camera->eye; - s16 fov; yOffset = Player_GetHeight(camera->player); player = camera->player; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); playerPosWithOffset = playerPosRot->pos; playerPosWithOffset.y += yOffset; @@ -5072,19 +5140,17 @@ s32 Camera_Unique5(Camera* camera) { */ s32 Camera_Unique6(Camera* camera) { Unique6ReadOnlyData* roData = &camera->paramData.uniq6.roData; - CameraModeValue* values; + f32 offset; Vec3f sp2C; PosRot* playerPosRot = &camera->playerPosRot; - f32 offset; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -5119,25 +5185,23 @@ s32 Camera_Unique6(Camera* camera) { s32 Camera_Unique7(Camera* camera) { s32 pad; Unique7ReadOnlyData* roData = &camera->paramData.uniq7.roData; - CameraModeValue* values; + PosRot* playerPosRot = &camera->playerPosRot; VecGeo playerPosEyeOffset; s16 fov; BgCamFuncData* bgCamFuncData; UNUSED Vec3s bgCamRot; Vec3f* at = &camera->at; - PosRot* playerPosRot = &camera->playerPosRot; Vec3f* eye = &camera->eye; Vec3f* eyeNext = &camera->eyeNext; Unique7ReadWriteData* rwData = &camera->paramData.uniq7.rwData; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->fov = GET_NEXT_RO_DATA(values); roData->interfaceField = (s16)GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); @@ -5208,17 +5272,14 @@ s32 Camera_Unique9(Camera* camera) { f32 spB4; PosRot atFocusPosRot; Vec3f eyeLookAtPos; - CameraModeValue* values; - PosRot eyeFocusPosRot; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -5260,7 +5321,7 @@ s32 Camera_Unique9(Camera* camera) { PRINTF("camera: demo: player demo set WAIT\n"); } else { PRINTF("camera: demo: player demo set %d\n", rwData->curKeyFrame->initField); - Player_SetCsAction(camera->play, camera->target, rwData->curKeyFrame->initField); + Player_SetCsAction(camera->play, camera->target, rwData->curKeyFrame->initField & 0xFF); } } } @@ -5415,6 +5476,8 @@ s32 Camera_Unique9(Camera* camera) { } if (focusActor != NULL) { + PosRot eyeFocusPosRot; + if ((eyeFlags & 0xF00) == 0x100) { // head eyeFocusPosRot = Actor_GetFocus(focusActor); @@ -5668,6 +5731,7 @@ s32 Camera_Unique9(Camera* camera) { return true; } +#if OOT_DEBUG void Camera_DebugPrintSplineArray(char* name, s16 length, CutsceneCameraPoint cameraPoints[]) { s32 i; @@ -5684,6 +5748,7 @@ void Camera_DebugPrintSplineArray(char* name, s16 length, CutsceneCameraPoint ca } PRINTF("};\n\n"); } +#endif /** * Copies `src` to `dst`, used in Camera_Demo1 @@ -5717,7 +5782,7 @@ void Camera_RotateAroundPoint(PosRot* at, Vec3f* pos, Vec3f* dst) { s32 Camera_Demo1(Camera* camera) { s32 pad; Demo1ReadOnlyData* roData = &camera->paramData.demo1.roData; - CameraModeValue* values; + f32* cameraFOV = &camera->fov; Vec3f* at = &camera->at; CutsceneCameraPoint* csAtPoints = (CutsceneCameraPoint*)camera->data0; CutsceneCameraPoint* csEyePoints = (CutsceneCameraPoint*)camera->data1; @@ -5727,12 +5792,12 @@ s32 Camera_Demo1(Camera* camera) { Vec3f csAtUpdate; f32 newRoll; Vec3f* eyeNext = &camera->eyeNext; - f32* cameraFOV = &camera->fov; s16* relativeToPlayer = &camera->data2; Demo1ReadWriteData* rwData = &camera->paramData.demo1.rwData; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceField = GET_NEXT_RO_DATA(values); } @@ -5748,10 +5813,12 @@ s32 Camera_Demo1(Camera* camera) { PRINTF(VT_SGR("1") "%06u:" VT_RST " camera: spline demo: start %s \n", camera->play->state.frames, *relativeToPlayer == 0 ? "絶対" : "相対"); +#if OOT_DEBUG if (PREG(93)) { Camera_DebugPrintSplineArray("CENTER", 5, csAtPoints); Camera_DebugPrintSplineArray(" EYE", 5, csEyePoints); } +#endif FALLTHROUGH; case 1: // follow CutsceneCameraPoints. function returns 1 if at the end. @@ -5766,9 +5833,12 @@ s32 Camera_Demo1(Camera* camera) { curPlayerPosRot = Actor_GetWorld(&camera->player->actor); Camera_RotateAroundPoint(&curPlayerPosRot, &csEyeUpdate, eyeNext); Camera_RotateAroundPoint(&curPlayerPosRot, &csAtUpdate, at); - } else { + } +#if OOT_DEBUG + else { PRINTF(VT_COL(RED, WHITE) "camera: spline demo: owner dead\n" VT_RST); } +#endif } else { // simply copy the interpolated values to the eye and at Camera_Vec3fCopy(&csEyeUpdate, eyeNext); @@ -5813,7 +5883,7 @@ s32 Camera_Demo3(Camera* camera) { camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->fov = GET_NEXT_RO_DATA(values); @@ -5821,9 +5891,7 @@ s32 Camera_Demo3(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); eyeAtOffset = OLib_Vec3fDiffToVecGeo(at, eye); @@ -5990,6 +6058,8 @@ s32 Camera_Demo3(Camera* camera) { camera->animState = 4; } + if (1) {} + if (!skipUpdateEye) { eyeOffset.r = Camera_LERPCeilF(eyeOffset.r, eyeAtOffset.r, rwData->unk_0C, 2.0f); eyeOffset.pitch = Camera_LERPCeilS(eyeOffset.pitch, eyeAtOffset.pitch, rwData->unk_0C, 0xA); @@ -6014,6 +6084,7 @@ s32 Camera_Demo4(Camera* camera) { * Sets up a OnePoint attention cutscene */ s32 Camera_Demo5(Camera* camera) { + static s32 sDemo5PrevSfxFrame = -200; f32 eyeTargetDist; f32 sp90; VecGeo playerTargetGeo; @@ -6053,6 +6124,54 @@ s32 Camera_Demo5(Camera* camera) { if (camera->target->category == ACTORCAT_PLAYER) { // camera is targeting a(the) player actor if (eyePlayerGeo.r > 30.0f) { + // target is player, far from eye + static OnePointCsFull D_8011D6AC[] = { + { + // viewFlags & 0x00FF (at): 2, atTarget is view lookAt + atInit + // viewFlags & 0xFF00 (eye): none + // action: 15, copy at, eye, roll, fov to camera + // result: eye remains in the same location, at is View's lookAt + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0002, + 1, + 0, + 60.0f, + 1.0f, + { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, + }, + { + // viewFlags & 0x00FF (at): 3, atTarget is camera's current at + atInit + // viewFlags & 0xFF00 (eye): 3, eyeTarget is the camera's current eye + eyeInit + // action: interpolate eye and at. + // result: eye and at's y interpolate to become +20 from their current location. + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0303, + 19, + 0, + 45.0f, + 1.0f, + { 0.0f, 20.0f, 0.0f }, + { 0.0f, 20.0f, 0.0f }, + }, + { + // viewFlags & 0x00FF (at): 0 none + // viewFlags & 0xFF00 (eye): 0 none + // action: 18, copy this camera to default camera. + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + D_8011D6AC[1].timerInit = camera->timer - 1; D_8011D6AC[1].atTargetInit.z = Rand_ZeroOne() * 10.0f; D_8011D6AC[1].eyeTargetInit.x = Rand_ZeroOne() * 10.0f; @@ -6064,6 +6183,43 @@ s32 Camera_Demo5(Camera* camera) { camera->timer += D_8011D6AC[2].timerInit; } } else { + // target is player close to current eye + static OnePointCsFull D_8011D724[] = { + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x2424, + 1, + 0, + 60.0f, + 1.0f, + { 0.0f, 0.0f, 0.0f }, + { 0.0f, 10.0f, -20.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x2121, + 19, + 0, + 50.0f, + 1.0f, + { 0.0f, -10.0f, 0.0f }, + { 0.0f, 0.0f, 60.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + D_8011D724[1].eyeTargetInit.x = Rand_ZeroOne() * 10.0f; D_8011D724[1].timerInit = camera->timer - 1; ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D724; @@ -6076,6 +6232,53 @@ s32 Camera_Demo5(Camera* camera) { } } else if (playerTargetGeo.r < 30.0f) { // distance between player and target is less than 30 units. + static OnePointCsFull D_8011D79C[] = { + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, true, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0002, + 1, + 0, + 60.0f, + 1.0f, + { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, true, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0303, + 19, + 0, + 45.0f, + 1.0f, + { 0.0f, -20.0f, 0.0f }, + { 0.0f, -10.0f, 5.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, true, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0303, + 9, + 0, + 60.0f, + 1.0f, + { 0.0f, 10.0f, 0.0f }, + { 0.0f, 10.0f, 0.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D79C; ONEPOINT_CS_INFO(camera)->keyFrameCount = ARRAY_COUNT(D_8011D79C); if ((targetScreenPosX <= 20) || (targetScreenPosX >= SCREEN_WIDTH - 20) || (targetScreenPosY <= 40) || @@ -6099,6 +6302,31 @@ s32 Camera_Demo5(Camera* camera) { } else if (eyeTargetDist < 300.0f && eyePlayerGeo.r < 30.0f) { // distance from the camera's current positon and the target is less than 300 units // and the distance fromthe camera's current position to the player is less than 30 units + static OnePointCsFull D_8011D83C[] = { + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_3, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x2141, + 20, + 0, + 45.0f, + 0.2f, + { 0.0f, 0.0f, 10.0f }, + { 0.0f, 0.0f, 10.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + D_8011D83C[0].timerInit = camera->timer; ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D83C; ONEPOINT_CS_INFO(camera)->keyFrameCount = ARRAY_COUNT(D_8011D83C); @@ -6113,6 +6341,33 @@ s32 Camera_Demo5(Camera* camera) { // is less than ~76.9 degrees if ((targetScreenPosX > 20) && (targetScreenPosX < SCREEN_WIDTH - 20) && (targetScreenPosY > 40) && (targetScreenPosY < SCREEN_HEIGHT - 40) && (eyePlayerGeo.r > 30.0f)) { + // The x/y coordinates of the target on screen is between (21, 41) and (300, 200), + // and the player is farther than 30 units of the eye + static OnePointCsFull D_8011D88C[] = { + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0303, + 20, + 0, + 45.0f, + 1.0f, + { 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + D_8011D88C[0].timerInit = camera->timer; ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D88C; ONEPOINT_CS_INFO(camera)->keyFrameCount = ARRAY_COUNT(D_8011D88C); @@ -6122,6 +6377,43 @@ s32 Camera_Demo5(Camera* camera) { camera->timer += D_8011D88C[1].timerInit; } } else { + // same as above, but the target is NOT within the screen area. + static OnePointCsFull D_8011D8DC[] = { + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0404, + 20, + 1, + 50.0f, + 1.0f, + { 0.0f, 5.0f, 10.0f }, + { 0.0f, 10.0f, -80.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_2, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x2121, + 5, + 0, + 60.0f, + 1.0f, + { 0.0f, 5.0f, 0.0f }, + { 5.0f, 5.0f, -200.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + D_8011D8DC[0].atTargetInit.z = eyeTargetDist * 0.6f; D_8011D8DC[0].eyeTargetInit.z = eyeTargetDist + 50.0f; D_8011D8DC[0].eyeTargetInit.x = Rand_ZeroOne() * 10.0f; @@ -6142,6 +6434,53 @@ s32 Camera_Demo5(Camera* camera) { } } else if (camera->target->category == ACTORCAT_DOOR) { // the target is a door. + static OnePointCsFull D_8011D954[] = { + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0xC1C1, + 20, + 0, + 60.0f, + 1.0f, + { 0.0f, 0.0f, 50.0f }, + { 0.0f, 0.0f, 250.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_3, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x05B1, + 5, + 0, + 60.0f, + 0.1f, + { 0.0f, 10.0f, 50.0f }, + { 0.0f, 10.0f, 100.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_2, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x2121, + 5, + 2, + 60.0f, + 1.0f, + { 0.0f, 10.0f, 0.0f }, + { 0.0f, 20.0f, -150.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + D_8011D954[0].timerInit = camera->timer - 5; sp4A = 0; if (!func_800C0D34(camera->play, camera->target, &sp4A)) { @@ -6177,6 +6516,43 @@ s32 Camera_Demo5(Camera* camera) { camera->timer += D_8011D954[2].timerInit + D_8011D954[3].timerInit; } } else { + // otherwise + static OnePointCsFull D_8011D9F4[] = { + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0504, + 20, + 2, + 60.0f, + 1.0f, + { 0.0f, 5.0f, 50.0f }, + { 0.0f, 20.0f, 300.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_2, false, true), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x2121, + 5, + 2, + 60.0f, + 1.0f, + { 0.0f, 10.0f, 0.0f }, + { 0.0f, 20.0f, -150.0f }, + }, + { + ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), + ONEPOINT_CS_INIT_FIELD_NONE, + 0x0000, + 1, + 0, + 60.0f, + 1.0f, + { -1.0f, -1.0f, -1.0f }, + { -1.0f, -1.0f, -1.0f }, + }, + }; + if (playerTargetGeo.r < 200.0f) { D_8011D9F4[0].eyeTargetInit.z = playerTargetGeo.r; D_8011D9F4[0].atTargetInit.z = playerTargetGeo.r * 0.25f; @@ -6254,12 +6630,11 @@ s32 Camera_Demo6(Camera* camera) { Camera* mainCam; Demo6ReadOnlyData* roData = &camera->paramData.demo6.roData; Vec3f* eyeNext = &camera->eyeNext; - CameraModeValue* values; + Demo6ReadWriteData* rwData = &camera->paramData.demo6.rwData; VecGeo eyeOffset; Actor* camFocus; PosRot focusPosRot; s16 stateTimers[4]; - Demo6ReadWriteData* rwData = &camera->paramData.demo6.rwData; mainCam = Play_GetCamera(camera->play, CAM_ID_MAIN); camFocus = camera->target; @@ -6267,14 +6642,13 @@ s32 Camera_Demo6(Camera* camera) { stateTimers[2] = 70; stateTimers[3] = 90; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); switch (camera->animState) { case 0: @@ -6357,12 +6731,11 @@ s32 Camera_Demo9(Camera* camera) { Vec3f newEye; Vec3f newAt; f32 newRoll; - CameraModeValue* values; + s32 pad3; Camera* mainCam; Vec3f* eye = &camera->eye; PosRot* mainCamPlayerPosRot; PosRot focusPosRot; - s32 pad3; Vec3f* eyeNext = &camera->eyeNext; Demo9ReadOnlyData* roData = &camera->paramData.demo9.roData; Vec3f* at = &camera->at; @@ -6371,14 +6744,13 @@ s32 Camera_Demo9(Camera* camera) { mainCam = Play_GetCamera(camera->play, CAM_ID_MAIN); mainCamPlayerPosRot = &mainCam->playerPosRot; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { - values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { + CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; + roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -6494,16 +6866,14 @@ s32 Camera_Special0(Camera* camera) { PosRot* playerPosRot = &camera->playerPosRot; Special0ReadOnlyData* roData = &camera->paramData.spec0.roData; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->lerpAtScale = GET_NEXT_SCALED_RO_DATA(values); roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sCameraInterfaceField = roData->interfaceField; @@ -6604,10 +6974,9 @@ s32 Camera_Special5(Camera* camera) { f32 yOffset; yOffset = Player_GetHeight(camera->player); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; - f32 yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / yOffset)); + f32 yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / yOffset)); roData->yOffset = (GET_NEXT_SCALED_RO_DATA(values) * yOffset) * yNormal; roData->eyeDist = GET_NEXT_RO_DATA(values); @@ -6619,9 +6988,7 @@ s32 Camera_Special5(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); sp64 = OLib_Vec3fDiffToVecGeo(at, eye); sp5C = OLib_Vec3fDiffToVecGeo(at, eyeNext); @@ -6664,13 +7031,59 @@ s32 Camera_Special5(Camera* camera) { } Camera_CalcAtDefault(camera, &sp5C, roData->yOffset, false); - camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, - camera->atLERPStepScale * CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE), 1.0f); + camera->fov = Camera_LERPCeilF(roData->fovTarget, camera->fov, camera->atLERPStepScale * CAM_FOV_UPDATE_RATE, 1.0f); camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA); camera->atLERPStepScale = Camera_ClampLERPScale(camera, roData->atMaxLERPScale); return true; } +typedef enum { + /* 0 */ CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR, // ACTOR_BG_HIDAN_ROCK + /* 1 */ CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER, // ACTOR_BG_HIDAN_FSLIFT + /* 2 */ CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER, // ACTOR_BG_HIDAN_SYOKU + /* 3 */ CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE // ACTOR_BG_JYA_1FLIFT +} CamElevatorPlatform; + +Vec3f sCamElevatorPlatformLowerEyePoints[] = { + { 3050.0f, 700.0f, 0.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR + { 1755.0f, 3415.0f, -380.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER + { -3120.0f, 3160.0f, 245.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER + { 0.0f, -10.0f, 240.0f }, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE +}; + +Vec3f sCamElevatorPlatformUpperEyePoints[] = { + { 3160.0f, 2150.0f, 0.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR + { 1515.0f, 4130.0f, -835.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER + { -3040.0f, 4135.0f, 230.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER + { -50.0f, 600.0f, -75.0f }, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE +}; + +// Trigger player y position to swap eye points +f32 sCamElevatorPlatformTogglePosY[] = { + 1570.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR + 3680.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER + 3700.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER + 395.0f, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE +}; + +f32 sCamElevatorPlatformFovRollParam[] = { + 320.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR + 320.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER + 320.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER + 0.0f, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE +}; + +s16 sCamElevatorPlatformRolls[] = { + -2000, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR + -1000, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER + 0, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER + 0 // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE +}; + +// unused +s32 D_8011DAF4 = 0; +s32 D_8011DAF8 = 0; + /** * Camera's eye is fixed at points specified at lower or upper points depending on the player's position. * Designed around 4 specific elevator platforms, 1 in spirit temple and 3 in fire temple. @@ -6766,15 +7179,13 @@ s32 Camera_Special6(Camera* camera) { Special6ReadWriteData* rwData = &camera->paramData.spec6.rwData; s32 pad; - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); eyeAtOffset = OLib_Vec3fDiffToVecGeo(eye, at); @@ -6877,10 +7288,9 @@ s32 Camera_Special9(Camera* camera) { playerYOffset = Player_GetHeight(camera->player); camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; - yNormal = - 1.0f + CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) - (CAM_DATA_SCALED(R_CAM_YOFFSET_NORM) * (68.0f / playerYOffset)); + yNormal = 1.0f + CAM_YOFFSET_NORM - (CAM_YOFFSET_NORM * (68.0f / playerYOffset)); - if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { + if (RELOAD_PARAMS(camera) || CAM_DEBUG_RELOAD_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; roData->yOffset = GET_NEXT_SCALED_RO_DATA(values) * playerYOffset * yNormal; @@ -6888,9 +7298,7 @@ s32 Camera_Special9(Camera* camera) { roData->interfaceField = GET_NEXT_RO_DATA(values); } - if (R_RELOAD_CAM_PARAMS) { - Camera_CopyPREGToModeValues(camera); - } + CAM_DEBUG_RELOAD_PREG(camera); if (doorParams->doorActor != NULL) { referencePosRot = Actor_GetWorldPosShapeRot(doorParams->doorActor); @@ -7034,12 +7442,14 @@ void Camera_Destroy(Camera* camera) { void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState* play) { Camera* camP; - s32 i; s16 curUID; s16 j; __osMemset(camera, 0, sizeof(Camera)); if (sInitRegs) { + s32 i; + +#if OOT_DEBUG for (i = 0; i < sOREGInitCnt; i++) { OREG(i) = sOREGInit[i]; } @@ -7048,7 +7458,6 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState R_CAM_DATA(i) = sCamDataRegsInit[i]; } -#if OOT_DEBUG DebugCamera_Reset(camera, &D_8015BD80); #endif sInitRegs = false; @@ -7085,14 +7494,13 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState camera->camDir = camera->inputDir; camera->rUpdateRateInv = 10.0f; camera->yawUpdateRateInv = 10.0f; - camera->up.x = 0.0f; camera->up.y = 1.0f; - camera->up.z = 0.0f; + camera->up.z = camera->up.x = 0.0f; camera->fov = 60.0f; - camera->pitchUpdateRateInv = R_CAM_PITCH_UPDATE_RATE_INV; - camera->xzOffsetUpdateRate = CAM_DATA_SCALED(R_CAM_XZ_OFFSET_UPDATE_RATE); - camera->yOffsetUpdateRate = CAM_DATA_SCALED(R_CAM_Y_OFFSET_UPDATE_RATE); - camera->fovUpdateRate = CAM_DATA_SCALED(R_CAM_FOV_UPDATE_RATE); + camera->pitchUpdateRateInv = CAM_PITCH_UPDATE_RATE_INV; + camera->xzOffsetUpdateRate = CAM_XZ_OFFSET_UPDATE_RATE; + camera->yOffsetUpdateRate = CAM_Y_OFFSET_UPDATE_RATE; + camera->fovUpdateRate = CAM_FOV_UPDATE_RATE; sCameraLetterboxSize = 32; sCameraHudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; camera->stateFlags = 0; @@ -7106,10 +7514,14 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState camera->up.y = 1.0f; camera->up.z = camera->up.x = 0.0f; - camera->quakeOffset.x = camera->quakeOffset.y = camera->quakeOffset.z = 0; + camera->quakeOffset.x = 0; + camera->quakeOffset.y = 0; + camera->quakeOffset.z = 0; camera->atLERPStepScale = 1; sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0); +#if OOT_DEBUG sDbgModeIdx = -1; +#endif D_8011D3F0 = 3; PRINTF(VT_FGCOL(BLUE) "camera: initialize --- " VT_RST " UID %d\n", camera->uid); } @@ -7153,9 +7565,7 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player) { Vec3f floorNorm; s32 upXZ; f32 playerToAtOffsetY; - Vec3f* eye = &camera->eye; Vec3f* at = &camera->at; - Vec3f* eyeNext = &camera->eyeNext; playerPosRot = Actor_GetWorldPosShapeRot(&player->actor); playerToAtOffsetY = Player_GetHeight(player); @@ -7176,8 +7586,8 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player) { camera->playerToAtOffset.y = playerToAtOffsetY; camera->playerToAtOffset.z = 0; - *eyeNext = Camera_AddVecGeoToVec3f(at, &eyeNextAtOffset); - *eye = *eyeNext; + camera->eyeNext = Camera_AddVecGeoToVec3f(at, &eyeNextAtOffset); + camera->eye = camera->eyeNext; camera->roll = 0; upXZ = 0; @@ -7189,8 +7599,13 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player) { camera->bgId = bgId; } - camera->bgCamIndexBeforeUnderwater = -1; - camera->waterCamSetting = -1; + { + s32 pad[2]; + + camera->bgCamIndexBeforeUnderwater = -1; + camera->waterCamSetting = -1; + } + camera->stateFlags |= CAM_STATE_CHECK_BG; if (camera == &camera->play->mainCamera) { @@ -7206,7 +7621,9 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player) { camera->nextBgCamIndex = -1; camera->atLERPStepScale = 1.0f; Camera_CopyDataToRegs(camera, camera->mode); +#if OOT_DEBUG Camera_QRegInit(); +#endif PRINTF(VT_FGCOL(BLUE) "camera: personalize ---" VT_RST "\n"); if (camera->camId == CAM_ID_MAIN) { @@ -7219,6 +7636,7 @@ s16 Camera_ChangeStatus(Camera* camera, s16 status) { CameraModeValue* valueP; s32 i; +#if OOT_DEBUG if (PREG(82)) { PRINTF("camera: change camera status: cond %c%c\n", status == CAM_STAT_ACTIVE ? 'o' : 'x', camera->status != CAM_STAT_ACTIVE ? 'o' : 'x'); @@ -7238,10 +7656,13 @@ s16 Camera_ChangeStatus(Camera* camera, s16 status) { } } } +#endif + camera->status = status; return camera->status; } +#if OOT_DEBUG void Camera_PrintSettings(Camera* camera) { char sp58[8]; char sp50[8]; @@ -7318,6 +7739,7 @@ void Camera_PrintSettings(Camera* camera) { DebugCamera_ScreenTextColored(5, 26, DEBUG_CAM_TEXT_GOLD, sp50); } } +#endif s32 Camera_UpdateWater(Camera* camera) { f32 waterY; @@ -7457,7 +7879,11 @@ s32 Camera_UpdateHotRoom(Camera* camera) { return 1; } +#if OOT_DEBUG s32 Camera_DbgChangeMode(Camera* camera) { + static s16 D_8011DAFC[] = { + CAM_SET_NORMAL0, CAM_SET_NORMAL1, CAM_SET_NORMAL2, CAM_SET_DUNGEON0, CAM_SET_DUNGEON1, CAM_SET_DUNGEON2, + }; s32 changeDir = 0; if (!gDebugCamEnabled && camera->play->activeCamId == CAM_ID_MAIN) { @@ -7485,6 +7911,7 @@ s32 Camera_DbgChangeMode(Camera* camera) { } return true; } +#endif void Camera_UpdateDistortion(Camera* camera) { static s16 depthPhase = 0x3F0; @@ -7571,6 +7998,12 @@ void Camera_UpdateDistortion(Camera* camera) { } } +#if OOT_DEBUG +#define ENABLE_DEBUG_CAM_UPDATE R_DEBUG_CAM_UPDATE +#else +#define ENABLE_DEBUG_CAM_UPDATE false +#endif + Vec3s Camera_Update(Camera* camera) { static s32 sOOBTimer = 0; Vec3f viewAt; @@ -7590,12 +8023,12 @@ Vec3s Camera_Update(Camera* camera) { player = camera->play->cameraPtrs[CAM_ID_MAIN]->player; - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: in %x\n", camera); } if (camera->status == CAM_STAT_CUT) { - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: cut out %x\n", camera); } return camera->inputDir; @@ -7607,8 +8040,7 @@ Vec3s Camera_Update(Camera* camera) { curPlayerPosRot = Actor_GetWorldPosShapeRot(&camera->player->actor); camera->xzSpeed = playerXZSpeed = OLib_Vec3fDistXZ(&curPlayerPosRot.pos, &camera->playerPosRot.pos); - camera->speedRatio = - OLib_ClampMaxDist(playerXZSpeed / (func_8002DCE4(camera->player) * CAM_DATA_SCALED(OREG(8))), 1.0f); + camera->speedRatio = OLib_ClampMaxDist(playerXZSpeed / (func_8002DCE4(camera->player) * CAM_GLOBAL_8), 1.0f); camera->playerPosDelta.x = curPlayerPosRot.pos.x - camera->playerPosRot.pos.x; camera->playerPosDelta.y = curPlayerPosRot.pos.y - camera->playerPosRot.pos.y; camera->playerPosDelta.z = curPlayerPosRot.pos.z - camera->playerPosRot.pos.z; @@ -7619,18 +8051,18 @@ Vec3s Camera_Update(Camera* camera) { &camera->player->actor, &pos); if (playerGroundY != BGCHECK_Y_MIN) { // player is above ground. - sOOBTimer = 0; camera->floorNorm.x = COLPOLY_GET_NORMAL(playerFloorPoly->normal.x); camera->floorNorm.y = COLPOLY_GET_NORMAL(playerFloorPoly->normal.y); camera->floorNorm.z = COLPOLY_GET_NORMAL(playerFloorPoly->normal.z); camera->bgId = bgId; camera->playerGroundY = playerGroundY; + sOOBTimer = 0; } else { // player is not above ground. - sOOBTimer++; camera->floorNorm.x = 0.0; camera->floorNorm.y = 1.0f; camera->floorNorm.z = 0.0; + sOOBTimer++; } camera->playerPosRot = curPlayerPosRot; @@ -7666,11 +8098,14 @@ Vec3s Camera_Update(Camera* camera) { } } } + +#if OOT_DEBUG Camera_PrintSettings(camera); Camera_DbgChangeMode(camera); +#endif if (camera->status == CAM_STAT_WAIT) { - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: wait out %x\n", camera); } return camera->inputDir; @@ -7680,7 +8115,7 @@ Vec3s Camera_Update(Camera* camera) { camera->stateFlags &= ~(CAM_STATE_BLOCK_BG | CAM_STATE_LOCK_MODE); camera->stateFlags |= CAM_STATE_CAM_FUNC_FINISH; - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: engine (%d %d %d) %04x \n", camera->setting, camera->mode, sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx, camera->stateFlags); } @@ -7704,31 +8139,32 @@ Vec3s Camera_Update(Camera* camera) { sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_NOTHING_ALT, 0); Camera_UpdateInterface(sCameraInterfaceField); } else if (camera->play->csCtx.state != CS_STATE_IDLE) { - sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NOTHING_ALT, 0); + // clang-format off + sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NOTHING_ALT, 0); \ Camera_UpdateInterface(sCameraInterfaceField); + // clang-format on } else { Camera_UpdateInterface(sCameraInterfaceField); } } - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: shrink_and_bitem %x(%d)\n", sCameraInterfaceField, camera->play->transitionMode); } - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: engine (%s(%d) %s(%d) %s(%d)) ok!\n", &sCameraSettingNames[camera->setting], camera->setting, &sCameraModeNames[camera->mode], camera->mode, &sCameraFunctionNames[sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx], sCameraSettings[camera->setting].cameraModes[camera->mode].funcIdx); } +#if OOT_DEBUG // enable/disable debug cam if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_START)) { gDebugCamEnabled ^= 1; if (gDebugCamEnabled) { -#if OOT_DEBUG DebugCamera_Enable(&D_8015BD80, camera); -#endif } else if (camera->play->csCtx.state != CS_STATE_IDLE) { Cutscene_StopManual(camera->play, &camera->play->csCtx); } @@ -7737,17 +8173,16 @@ Vec3s Camera_Update(Camera* camera) { // Debug cam update if (gDebugCamEnabled) { camera->play->view.fovy = D_8015BD80.fov; -#if OOT_DEBUG DebugCamera_Update(&D_8015BD80, camera); -#endif View_LookAt(&camera->play->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: debug out\n"); } return D_8015BD80.sub.unk_104A; } OREG(0) &= ~8; +#endif if (camera->status == CAM_STAT_UNK3) { return camera->inputDir; @@ -7813,11 +8248,13 @@ Vec3s Camera_Update(Camera* camera) { CAM_BINANG_TO_DEG(camera->camDir.x), camera->camDir.y, CAM_BINANG_TO_DEG(camera->camDir.y)); } +#if OOT_DEBUG if (camera->timer != -1 && CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_DRIGHT)) { camera->timer = 0; } +#endif - if (R_DEBUG_CAM_UPDATE) { + if (ENABLE_DEBUG_CAM_UPDATE) { PRINTF("camera: out (%f %f %f) (%f %f %f)\n", camera->at.x, camera->at.y, camera->at.z, camera->eye.x, camera->eye.y, camera->eye.z); PRINTF("camera: dir (%f %d(%f) %d(%f)) (%f)\n", eyeAtAngle.r, eyeAtAngle.pitch, @@ -8145,6 +8582,7 @@ s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex) { if (!(camera->behaviorFlags & CAM_BEHAVIOR_BG_PROCESSED)) { requestedCamSetting = Camera_GetBgCamSetting(camera, requestedBgCamIndex); camera->behaviorFlags |= CAM_BEHAVIOR_BG_PROCESSED; +#if OOT_DEBUG settingChangeSuccessful = Camera_RequestSettingImpl(camera, requestedCamSetting, CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX | CAM_REQUEST_SETTING_FORCE_CHANGE) >= 0; @@ -8158,6 +8596,16 @@ s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex) { PRINTF(VT_COL(RED, WHITE) "camera: error: illegal camera ID (%d) !! (%d|%d|%d)\n" VT_RST, requestedBgCamIndex, camera->camId, BGCHECK_SCENE, requestedCamSetting); } +#else + if ((Camera_RequestSettingImpl(camera, requestedCamSetting, + CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX | CAM_REQUEST_SETTING_FORCE_CHANGE) >= + 0) || + (sCameraSettings[camera->setting].unk_00 & 0x80000000)) { + camera->bgCamIndex = requestedBgCamIndex; + camera->behaviorFlags |= CAM_BEHAVIOR_BG_SUCCESS; + Camera_CopyDataToRegs(camera, camera->mode); + } +#endif return 0x80000000 | requestedBgCamIndex; } @@ -8165,11 +8613,13 @@ s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex) { } Vec3s Camera_GetInputDir(Camera* camera) { +#if OOT_DEBUG if (gDebugCamEnabled) { return D_8015BD80.sub.unk_104A; - } else { - return camera->inputDir; } +#endif + + return camera->inputDir; } s16 Camera_GetInputDirPitch(Camera* camera) { @@ -8185,11 +8635,13 @@ s16 Camera_GetInputDirYaw(Camera* camera) { } Vec3s Camera_GetCamDir(Camera* camera) { +#if OOT_DEBUG if (gDebugCamEnabled) { return D_8015BD80.sub.unk_104A; - } else { - return camera->camDir; } +#endif + + return camera->camDir; } s16 Camera_GetCamDirPitch(Camera* camera) { @@ -8356,11 +8808,7 @@ s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 a } s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera) { - s32 pad; - - dstCamera->playerToAtOffset.x = 0.0f; - dstCamera->playerToAtOffset.y = 0.0f; - dstCamera->playerToAtOffset.z = 0.0f; + dstCamera->playerToAtOffset.x = dstCamera->playerToAtOffset.y = dstCamera->playerToAtOffset.z = 0.0f; dstCamera->atLERPStepScale = 0.1f; dstCamera->at = srcCamera->at; @@ -8384,7 +8832,11 @@ s32 Camera_Copy(Camera* dstCamera, Camera* srcCamera) { } s32 Camera_IsDebugCamEnabled(void) { +#if OOT_DEBUG return gDebugCamEnabled; +#else + return false; +#endif } Vec3f Camera_GetQuakeOffset(Camera* camera) { @@ -8414,6 +8866,7 @@ void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* d } } +#if OOT_DEBUG s32 Camera_QRegInit(void) { if (!R_RELOAD_CAM_PARAMS) { QREG(2) = 1; @@ -8448,6 +8901,7 @@ s32 Camera_QRegInit(void) { QREG(65) = 50; return true; } +#endif s32 func_8005B198(void) { return D_8011D3AC; diff --git a/src/code/z_camera_data.inc.c b/src/code/z_camera_data.inc.c index 4a4c828e2d..dc319636ae 100644 --- a/src/code/z_camera_data.inc.c +++ b/src/code/z_camera_data.inc.c @@ -26,6 +26,8 @@ typedef struct { /*==================================================================*/ // Data + +#if OOT_DEBUG s16 sOREGInit[] = { 0, // OREG(0) 1, // OREG(1) @@ -83,6 +85,7 @@ s16 sOREGInit[] = { }; s16 sOREGInitCnt = ARRAY_COUNT(sOREGInit); +#endif s16 sCamDataRegsInit[CAM_DATA_MAX] = { -20, // CAM_DATA_Y_OFFSET @@ -116,6 +119,7 @@ s16 sCamDataRegsInit[CAM_DATA_MAX] = { s16 sCamDataRegsInitCount = ARRAY_COUNT(sCamDataRegsInit); +#if OOT_DEBUG char sCameraSettingNames[][12] = { "NONE ", // CAM_SET_NONE "NORMAL0 ", // CAM_SET_NORMAL0 @@ -208,6 +212,7 @@ char sCameraModeNames[][12] = { "PUSHPULL ", // CAM_MODE_PUSH_PULL "BOOKEEPON ", // CAM_MODE_FOLLOW_BOOMERANG }; +#endif /** *===================================================================== @@ -2556,7 +2561,11 @@ s32 (*sCameraFunctions[])(Camera*) = { s32 sInitRegs = 1; s32 gDebugCamEnabled = false; + +#if OOT_DEBUG s32 sDbgModeIdx = -1; +#endif + s16 sNextUID = 0; s32 sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 1); @@ -2579,6 +2588,7 @@ s32 D_8011D3F0 = 0; s32 sDemo5PrevAction12Frame = -16; +#if OOT_DEBUG char sCameraFunctionNames[][8] = { "NONE ", // CAM_FUNC_NONE "NORM0()", // CAM_FUNC_NORM0 @@ -2653,6 +2663,7 @@ char sCameraFunctionNames[][8] = { "SPEC9()", // CAM_FUNC_SPEC9 "", "", "", "", "", }; +#endif VecSph D_8011D658[] = { { 50.0f, 0xEE3A, 0xD558 }, @@ -2668,371 +2679,10 @@ Vec3f D_8011D678[] = { { 0.0f, 3.0f, -3.0 }, }; -/******************************************************* - * OnePoint initalization values for Attention Cutscenes (Demo5) - ********************************************************/ -s32 sDemo5PrevSfxFrame = -200; - -// target is player, far from eye -OnePointCsFull D_8011D6AC[] = { - { - // viewFlags & 0x00FF (at): 2, atTarget is view lookAt + atInit - // viewFlags & 0xFF00 (eye): none - // action: 15, copy at, eye, roll, fov to camera - // result: eye remains in the same location, at is View's lookAt - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0002, - 1, - 0, - 60.0f, - 1.0f, - { 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f }, - }, - { - // viewFlags & 0x00FF (at): 3, atTarget is camera's current at + atInit - // viewFlags & 0xFF00 (eye): 3, eyeTarget is the camera's current eye + eyeInit - // action: interpolate eye and at. - // result: eye and at's y interpolate to become +20 from their current location. - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0303, - 19, - 0, - 45.0f, - 1.0f, - { 0.0f, 20.0f, 0.0f }, - { 0.0f, 20.0f, 0.0f }, - }, - { - // viewFlags & 0x00FF (at): 0 none - // viewFlags & 0xFF00 (eye): 0 none - // action: 18, copy this camera to default camera. - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -// target is player close to current eye -OnePointCsFull D_8011D724[] = { - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x2424, - 1, - 0, - 60.0f, - 1.0f, - { 0.0f, 0.0f, 0.0f }, - { 0.0f, 10.0f, -20.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x2121, - 19, - 0, - 50.0f, - 1.0f, - { 0.0f, -10.0f, 0.0f }, - { 0.0f, 0.0f, 60.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -// target is close to player -OnePointCsFull D_8011D79C[] = { - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, true, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0002, - 1, - 0, - 60.0f, - 1.0f, - { 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, true, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0303, - 19, - 0, - 45.0f, - 1.0f, - { 0.0f, -20.0f, 0.0f }, - { 0.0f, -10.0f, 5.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, true, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0303, - 9, - 0, - 60.0f, - 1.0f, - { 0.0f, 10.0f, 0.0f }, - { 0.0f, 10.0f, 0.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -// target is within 300 units of eye, and player is within 30 units of eye -OnePointCsFull D_8011D83C[] = { - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_3, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x2141, - 20, - 0, - 45.0f, - 0.2f, - { 0.0f, 0.0f, 10.0f }, - { 0.0f, 0.0f, 10.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -// target is within 700 units of eye, angle between player/eye and target/eye is less than -// 76.9 degrees. The x/y coordinates of the target on screen is between (21, 41) and (300, 200), -// and the player is farther than 30 units of the eye -OnePointCsFull D_8011D88C[] = { - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_1, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0303, - 20, - 0, - 45.0f, - 1.0f, - { 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -// same as above, but the target is NOT within the screen area. -OnePointCsFull D_8011D8DC[] = { - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0404, - 20, - 1, - 50.0f, - 1.0f, - { 0.0f, 5.0f, 10.0f }, - { 0.0f, 10.0f, -80.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_2, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x2121, - 5, - 0, - 60.0f, - 1.0f, - { 0.0f, 5.0f, 0.0f }, - { 5.0f, 5.0f, -200.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -// target is a door. -OnePointCsFull D_8011D954[] = { - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0xC1C1, - 20, - 0, - 60.0f, - 1.0f, - { 0.0f, 0.0f, 50.0f }, - { 0.0f, 0.0f, 250.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_3, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x05B1, - 5, - 0, - 60.0f, - 0.1f, - { 0.0f, 10.0f, 50.0f }, - { 0.0f, 10.0f, 100.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_2, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x2121, - 5, - 2, - 60.0f, - 1.0f, - { 0.0f, 10.0f, 0.0f }, - { 0.0f, 20.0f, -150.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -// otherwise -OnePointCsFull D_8011D9F4[] = { - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_15, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0504, - 20, - 2, - 60.0f, - 1.0f, - { 0.0f, 5.0f, 50.0f }, - { 0.0f, 20.0f, 300.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_2, false, true), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x2121, - 5, - 2, - 60.0f, - 1.0f, - { 0.0f, 10.0f, 0.0f }, - { 0.0f, 20.0f, -150.0f }, - }, - { - ONEPOINT_CS_ACTION(ONEPOINT_CS_ACTION_ID_18, false, false), - ONEPOINT_CS_INIT_FIELD_NONE, - 0x0000, - 1, - 0, - 60.0f, - 1.0f, - { -1.0f, -1.0f, -1.0f }, - { -1.0f, -1.0f, -1.0f }, - }, -}; - -typedef enum { - /* 0 */ CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR, // ACTOR_BG_HIDAN_ROCK - /* 1 */ CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER, // ACTOR_BG_HIDAN_FSLIFT - /* 2 */ CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER, // ACTOR_BG_HIDAN_SYOKU - /* 3 */ CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE // ACTOR_BG_JYA_1FLIFT -} CamElevatorPlatform; - -Vec3f sCamElevatorPlatformLowerEyePoints[] = { - { 3050.0f, 700.0f, 0.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR - { 1755.0f, 3415.0f, -380.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER - { -3120.0f, 3160.0f, 245.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER - { 0.0f, -10.0f, 240.0f }, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE -}; - -Vec3f sCamElevatorPlatformUpperEyePoints[] = { - { 3160.0f, 2150.0f, 0.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR - { 1515.0f, 4130.0f, -835.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER - { -3040.0f, 4135.0f, 230.0f }, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER - { -50.0f, 600.0f, -75.0f }, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE -}; - -// Trigger player y position to swap eye points -f32 sCamElevatorPlatformTogglePosY[] = { - 1570.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR - 3680.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER - 3700.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER - 395.0f, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE -}; - -f32 sCamElevatorPlatformFovRollParam[] = { - 320.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR - 320.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER - 320.0f, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER - 0.0f, // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE -}; - -s16 sCamElevatorPlatformRolls[] = { - -2000, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_LOWER_FLOOR - -1000, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_EAST_TOWER - 0, // CAM_ELEVATOR_PLATFORM_FIRE_TEMPLE_WEST_TOWER - 0 // CAM_ELEVATOR_PLATFORM_SPIRIT_TEMPLE_ENTRANCE -}; - -// unused -s32 D_8011DAF4 = 0; -s32 D_8011DAF8 = 0; - -s16 D_8011DAFC[] = { - CAM_SET_NORMAL0, CAM_SET_NORMAL1, CAM_SET_NORMAL2, CAM_SET_DUNGEON0, CAM_SET_DUNGEON1, CAM_SET_DUNGEON2, -}; - PlayState* D_8015BD7C; + +#if OOT_DEBUG DebugCam D_8015BD80; +#endif + CollisionPoly* playerFloorPoly;