From 81a3c3da32033c22fa59f0b3065a302eaac02a04 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 19 Nov 2023 12:17:32 +1100 Subject: [PATCH] More Camera Flags (#1453) * Generic Camera Flags * New flag names * Add flags to functions * Finish flag docs * More docs * More cleanup * More clarity * Better shrinkwindow flag docs * Improve name * CAM_INTERFACE_FLAGS * Better approach to edge cases * Change ordering for consistency * Oops * Add masks to macro * PR/Discord discussions * cleanup comment * Oops * PR Suggestions * More PR Feedback * More PR Suggestions * More Camera Flags * PR Suggestions * More flag style change * Small cleanup * More flag docs * Another flag * Fix flags * sync names with other PRs * more fixes * fix comments * update with hud visibility mode docs * missed one * fix comments * Roman PR Suggestions * interfaceField * small fix * letterbox cleanup * cleanup * fix macro arg * fix func declaration * many more docs * better docs? * missed some * oops, revert * add flags to name * cleanup * flag * double signal * simplify cam func name * more suggestions * PR Suggestion --- docs/tutorial/other_functions.md | 10 +- include/functions.h | 10 +- include/z64camera.h | 44 +- src/code/z_actor.c | 4 +- src/code/z_camera.c | 636 ++++++++++-------- src/code/z_demo.c | 10 +- src/code/z_kankyo.c | 2 +- src/code/z_onepointdemo.c | 58 +- src/code/z_play.c | 23 +- src/code/z_player_lib.c | 2 +- .../ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c | 12 +- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 2 +- .../ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c | 4 +- .../ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c | 8 +- .../ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c | 4 +- .../ovl_Bg_Jya_1flift/z_bg_jya_1flift.c | 4 +- .../actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c | 6 +- .../ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c | 2 +- .../z_bg_mori_rakkatenjo.c | 4 +- .../actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c | 4 +- .../actors/ovl_En_Bigokuta/z_en_bigokuta.c | 8 +- .../ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c | 2 +- .../actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c | 2 +- .../actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c | 2 +- src/overlays/actors/ovl_En_Du/z_en_du.c | 2 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 4 +- src/overlays/actors/ovl_En_Go2/z_en_go2.c | 10 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 4 +- src/overlays/actors/ovl_En_Jj/z_en_jj.c | 2 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 6 +- .../actors/ovl_En_Kakasi3/z_en_kakasi3.c | 4 +- src/overlays/actors/ovl_En_Ru2/z_en_ru2.c | 4 +- src/overlays/actors/ovl_En_Zl3/z_en_zl3.c | 4 +- src/overlays/actors/ovl_En_Zl4/z_en_zl4.c | 6 +- src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c | 12 +- .../ovl_Object_Kankyo/z_object_kankyo.c | 4 +- .../actors/ovl_player_actor/z_player.c | 67 +- 37 files changed, 531 insertions(+), 461 deletions(-) diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index ec886e175f..9c1916ee60 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -380,7 +380,7 @@ void func_80A87CEC(EnJj *this, PlayState *play) { play->csCtx.script = &D_80A88164; gSaveContext.cutsceneTrigger = (u8)1U; func_8003EBF8(play, &play->colCtx.dyna, (s32) temp_v1->bgId); - func_8005B1A4(play->cameraPtrs[play->activeCamId]); + Camera_SetFinishedFlag(play->cameraPtrs[play->activeCamId]); gSaveContext.unkEDA = (u16) (gSaveContext.unkEDA | 0x400); Sfx_PlaySfxCentered((u16)0x4802U); } @@ -396,7 +396,7 @@ Easy things to sort out: - `play->cameraPtrs[play->activeCamId]` has a macro: it is `GET_ACTIVE_CAM(play)`, so this line can be written as ```C -func_8005B1A4(GET_ACTIVE_CAM(play)); +Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); ``` - `gSaveContext.unkEDA` we have dealt with before: it is `gSaveContext.save.info.eventChkInf[3]`. This is a flag-setting function; it can be written more compactly as @@ -418,13 +418,13 @@ void func_80A87CEC(EnJj *this, PlayState *play) { play->csCtx.script = &D_80A88164; gSaveContext.cutsceneTrigger = 1; func_8003EBF8(play, &play->colCtx.dyna, child->bgId); - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); gSaveContext.save.info.eventChkInf[3] |= 0x400; Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME); } ``` -matches, but generates a complier warning for `func_8005B1A4`, which it can't find. To fix this, add it to `functions.h`, in as near as possible the correct position in numerical order. Some detective work with VSCode's Search shows that this function lives in `z_camera.c`, and its prototype is `s16 func_8005B1A4(Camera* camera)`, so add this line to `functions.h` at the bottom of the camera functions part. +matches, but generates a complier warning for `Camera_SetFinishedFlag`, which it can't find. To fix this, add it to `functions.h`, in as near as possible the correct position in numerical order. Some detective work with VSCode's Search shows that this function lives in `z_camera.c`, and its prototype is `s16 Camera_SetFinishedFlag(Camera* camera)`, so add this line to `functions.h` at the bottom of the camera functions part. Lastly, we prefer to limit use of early `return`s, and use `else`s instead if possible. That applies here: the function can be rewritten as ```C @@ -437,7 +437,7 @@ void func_80A87CEC(EnJj* this, PlayState* play) { play->csCtx.script = &D_80A88164; gSaveContext.cutsceneTrigger = 1; func_8003EBF8(play, &play->colCtx.dyna, child->bgId); - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); gSaveContext.save.info.eventChkInf[3] |= 0x400; Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME); } diff --git a/include/functions.h b/include/functions.h index 771b666020..011d0d0c2e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -634,10 +634,10 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player); s16 Camera_ChangeStatus(Camera* camera, s16 status); Vec3s Camera_Update(Camera* camera); void Camera_Finish(Camera* camera); -s32 Camera_ChangeMode(Camera* camera, s16 mode); +s32 Camera_RequestMode(Camera* camera, s16 mode); s32 Camera_CheckValidMode(Camera* camera, s16 mode); -s32 Camera_ChangeSetting(Camera* camera, s16 setting); -s32 Camera_ChangeBgCamIndex(Camera* camera, s32 bgCamIndex); +s32 Camera_RequestSetting(Camera* camera, s16 setting); +s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex); s16 Camera_GetInputDirYaw(Camera* camera); Vec3s* Camera_GetCamDir(Vec3s* dst, Camera* camera); s16 Camera_GetCamDirPitch(Camera* camera); @@ -657,7 +657,7 @@ Vec3f* Camera_GetQuakeOffset(Vec3f* quakeOffset, Camera* camera); void Camera_SetCameraData(Camera* camera, s16 setDataFlags, void* data0, void* data1, s16 data2, s16 data3, UNK_TYPE arg6); s32 func_8005B198(void); -s16 func_8005B1A4(Camera* camera); +s16 Camera_SetFinishedFlag(Camera* camera); DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* table); void Collider_DrawRedPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC); @@ -1271,7 +1271,7 @@ s32 Play_SetCameraFov(PlayState* this, s16 camId, f32 fov); s32 Play_SetCameraRoll(PlayState* this, s16 camId, s16 roll); void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId); s32 Play_InitCameraDataUsingPlayer(PlayState* this, s16 camId, Player* player, s16 setting); -s32 Play_ChangeCameraSetting(PlayState* this, s16 camId, s16 setting); +s32 Play_RequestCameraSetting(PlayState* this, s16 camId, s16 setting); void Play_ReturnToMainCam(PlayState* this, s16 camId, s16 duration); void Play_SaveSceneFlags(PlayState* this); void Play_SetupRespawnPoint(PlayState* this, s32 respawnMode, s32 playerParams); diff --git a/include/z64camera.h b/include/z64camera.h index f6c4589180..81584c1b68 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -84,33 +84,33 @@ #define CAM_INTERFACE_FIELD(letterboxFlag, hudVisibilityMode, funcFlags) \ (((letterboxFlag) & CAM_LETTERBOX_MASK) | CAM_HUD_VISIBILITY(hudVisibilityMode) | ((funcFlags) & 0xFF)) -// Camera behaviorFlags. Flags specifically for settings, modes, and bgCam -// Used to store current state, only CAM_BEHAVIOR_SETTING_1 and CAM_BEHAVIOR_BG_2 are read from and used in logic +// Camera behaviorFlags. Flags specifically for settings, modes, and bgCam. Reset every frame. +// Used to store current state, only CAM_BEHAVIOR_SETTING_CHECK_PRIORITY and CAM_BEHAVIOR_BG_PROCESSED are read from and used in logic // Setting (0x1, 0x10) -#define CAM_BEHAVIOR_SETTING_1 (1 << 0) -#define CAM_BEHAVIOR_SETTING_2 (1 << 4) +#define CAM_BEHAVIOR_SETTING_CHECK_PRIORITY (1 << 0) +#define CAM_BEHAVIOR_SETTING_VALID (1 << 4) // Set when a valid camera setting is requested // Mode (0x2, 0x20) -#define CAM_BEHAVIOR_MODE_1 (1 << 1) -#define CAM_BEHAVIOR_MODE_2 (1 << 5) +#define CAM_BEHAVIOR_MODE_SUCCESS (1 << 1) // Set when the camera mode is the requested mode +#define CAM_BEHAVIOR_MODE_VALID (1 << 5) // Set when a valid camera mode is requested // bgCam (0x4, 0x40) -#define CAM_BEHAVIOR_BG_1 (1 << 2) -#define CAM_BEHAVIOR_BG_2 (1 << 6) +#define CAM_BEHAVIOR_BG_SUCCESS (1 << 2) +#define CAM_BEHAVIOR_BG_PROCESSED (1 << 6) // Camera stateFlags. Variety of generic flags -#define CAM_STATE_0 (1 << 0) // Must be set for the camera to change settings based on the bg surface -#define CAM_STATE_1 (1 << 1) // Must be set for Camera_UpdateWater to run -#define CAM_STATE_2 (1 << 2) -#define CAM_STATE_3 (1 << 3) // Customizable flag for different functions -#define CAM_STATE_4 (1 << 4) -#define CAM_STATE_5 (1 << 5) -#define CAM_STATE_6 (1 << 6) -#define CAM_STATE_7 (1 << 7) // Set in play, unused -#define CAM_STATE_8 (1 << 8) // Camera (eye) is underwater -#define CAM_STATE_9 (1 << 9) -#define CAM_STATE_10 (1 << 10) // Prevents the camera from changing settings based on the bg surface -#define CAM_STATE_12 (1 << 12) // Set in Camera_Demo7, but Camera_Demo7 is never called -#define CAM_STATE_14 (1 << 14) // isInitialized. Turned on in Camera Init, never used or changed -#define CAM_STATE_15 ((s16)(1 << 15)) +#define CAM_STATE_CHECK_BG_ALT (1 << 0) // Must be set for the camera to change settings based on the bg surface +#define CAM_STATE_CHECK_WATER (1 << 1) // Must be set for Camera_UpdateWater to run +#define CAM_STATE_CHECK_BG (1 << 2) // Must be set for the camera to change settings based on the bg surface +#define CAM_STATE_EXTERNAL_FINISHED (1 << 3) // Signal from the external systems to camera that the current cam-update function is no longer needed +#define CAM_STATE_CAM_FUNC_FINISH (1 << 4) // Signal from camera to player that the cam-update function is finished its primary purpose +#define CAM_STATE_LOCK_MODE (1 << 5) // Prevents camera from changing mode, unless overriden by `forceModeChange` passed to `Camera_RequestModeImpl` +#define CAM_STATE_DISTORTION (1 << 6) // Set when camera distortion is on +#define CAM_STATE_PLAY_INIT (1 << 7) // Set in Play_Init, never used or changed +#define CAM_STATE_CAMERA_IN_WATER (1 << 8) // Camera (eye) is underwater +#define CAM_STATE_PLAYER_IN_WATER (1 << 9) // Player is swimming in water +#define CAM_STATE_BLOCK_BG (1 << 10) // Prevents the camera from changing settings based on the bg surface for 1 frame +#define CAM_STATE_DEMO7 (1 << 12) // Set in Camera_Demo7, but this function is never called +#define CAM_STATE_CAM_INIT (1 << 14) // Set in Camera_Init, never used or changed +#define CAM_STATE_PLAYER_DIVING ((s16)(1 << 15)) // Diving from the surface of the water down // Camera viewFlags. Set params related to view #define CAM_VIEW_AT (1 << 0) // camera->at diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 091b5d109f..bbbb22c360 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1039,7 +1039,7 @@ void func_8002DE04(PlayState* play, Actor* actorA, Actor* actorB) { void func_8002DE74(PlayState* play, Player* player) { if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && Play_CamIsNotFixed(play)) { - Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_HORSE); + Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_HORSE); } } @@ -2985,7 +2985,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { if ((player != NULL) && (actor == player->unk_664)) { func_8008EDF0(player); - Camera_ChangeMode(Play_GetCamera(play, Play_GetActiveCamId(play)), 0); + Camera_RequestMode(Play_GetCamera(play, Play_GetActiveCamId(play)), CAM_MODE_NORMAL); } if (actor == actorCtx->targetCtx.arrowPointedActor) { diff --git a/src/code/z_camera.c b/src/code/z_camera.c index ef2964d451..10283f4b71 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -4,8 +4,8 @@ #include "terminal.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" -s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags); -s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags); +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); @@ -31,6 +31,13 @@ s32 Camera_UpdateWater(Camera* camera); #define DISTORTION_UNDERWATER_STRONG (1 << 3) #define DISTORTION_UNDERWATER_FISHING (1 << 4) +#define CAM_REQUEST_SETTING_FORCE_CHANGE (1 << 0) +// If set, then any other setting requests on the same frame will skip a priority check +// and overwrite the request +#define CAM_REQUEST_SETTING_IGNORE_PRIORITY (1 << 1) +#define CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX (1 << 2) +#define CAM_REQUEST_SETTING_RESTORE_PREV_BG_CAM_INDEX (1 << 3) + #include "z_camera_data.inc.c" /*===============================================================*/ @@ -517,7 +524,7 @@ s32 Camera_GetWaterBoxBgCamIndex(Camera* camera, f32* waterY) { if (!WaterBox_GetSurface1(camera->play, &camera->play->colCtx, playerPosRot.pos.x, playerPosRot.pos.z, waterY, &waterBox)) { - // player's position is not in a water box. + // player's position is not within the x/z boundaries of a water box. *waterY = BGCHECK_Y_MIN; return -1; } @@ -557,8 +564,8 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* lightIndex) { return BGCHECK_Y_MIN; } - if (waterY < chkPos->y) { - // the water's y position is below the check position + if (chkPos->y > waterY) { + // the check position is above the water's y position // meaning the position is NOT in the water. return BGCHECK_Y_MIN; } @@ -2122,7 +2129,7 @@ s32 Camera_Parallel1(Camera* camera) { } if (rwData->animTimer != 0) { - camera->stateFlags |= CAM_STATE_5; + camera->stateFlags |= CAM_STATE_LOCK_MODE; tangle = (((rwData->animTimer + 1) * rwData->animTimer) >> 1); spA8.yaw = atToEyeDir.yaw + (((s16)(rwData->yawTarget - atToEyeDir.yaw) / tangle) * rwData->animTimer); spA8.pitch = atToEyeDir.pitch; @@ -2188,10 +2195,10 @@ s32 Camera_Parallel3(Camera* camera) { sCameraInterfaceField = interfaceField; if (interfaceField & PARALLEL3_FLAG_0) { - camera->stateFlags |= CAM_STATE_10; + camera->stateFlags |= CAM_STATE_BLOCK_BG; } if (interfaceField & PARALLEL3_FLAG_1) { - camera->stateFlags |= CAM_STATE_4; + camera->stateFlags |= CAM_STATE_CAM_FUNC_FINISH; } //! @bug doesn't return } @@ -2861,7 +2868,7 @@ s32 Camera_Battle1(Camera* camera) { VT_COL(YELLOW, BLACK) "camera: warning: battle: target is not valid, change parallel\n" VT_RST); } camera->target = NULL; - Camera_ChangeMode(camera, CAM_MODE_Z_PARALLEL); + Camera_RequestMode(camera, CAM_MODE_Z_PARALLEL); return true; } @@ -2877,7 +2884,7 @@ s32 Camera_Battle1(Camera* camera) { } else { osSyncPrintf("camera: battle: target actor name " VT_COL(RED, WHITE) "%d" VT_RST "\n", rwData->target->id); camera->target = NULL; - Camera_ChangeMode(camera, CAM_MODE_Z_PARALLEL); + Camera_RequestMode(camera, CAM_MODE_Z_PARALLEL); return true; } rwData->animTimer = R_CAM_DEFAULT_ANIM_TIME + OREG(24); @@ -3147,7 +3154,7 @@ s32 Camera_KeepOn1(Camera* camera) { VT_COL(YELLOW, BLACK) "camera: warning: keepon: target is not valid, change parallel\n" VT_RST); } camera->target = NULL; - Camera_ChangeMode(camera, CAM_MODE_Z_PARALLEL); + Camera_RequestMode(camera, CAM_MODE_Z_PARALLEL); return 1; } @@ -3386,18 +3393,18 @@ s32 Camera_KeepOn3(Camera* camera) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: warning: talk: target is not valid, change parallel\n" VT_RST); } camera->target = NULL; - Camera_ChangeMode(camera, CAM_MODE_Z_PARALLEL); + Camera_RequestMode(camera, CAM_MODE_Z_PARALLEL); return 1; } if (RELOAD_PARAMS(camera)) { if (camera->play->view.unk_124 == 0) { - camera->stateFlags |= CAM_STATE_5; + camera->stateFlags |= CAM_STATE_LOCK_MODE; camera->play->view.unk_124 = camera->camId | 0x50; return 1; } - camera->stateFlags &= ~CAM_STATE_5; + camera->stateFlags &= ~CAM_STATE_LOCK_MODE; } - camera->stateFlags &= ~CAM_STATE_4; + camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; f32 yNormal = @@ -3493,7 +3500,7 @@ s32 Camera_KeepOn3(Camera* camera) { } } osSyncPrintf("camera: talk: BG&collision check %d time(s)\n", i); - camera->stateFlags &= ~(CAM_STATE_2 | CAM_STATE_3); + camera->stateFlags &= ~(CAM_STATE_CHECK_BG | CAM_STATE_EXTERNAL_FINISHED); pad = ((rwData->animTimer + 1) * rwData->animTimer) >> 1; rwData->eyeToAtTargetYaw = (f32)(s16)(atToEyeAdj.yaw - atToEyeNextDir.yaw) / pad; rwData->eyeToAtTargetPitch = (f32)(s16)(atToEyeAdj.pitch - atToEyeNextDir.pitch) / pad; @@ -3518,10 +3525,10 @@ s32 Camera_KeepOn3(Camera* camera) { Camera_BGCheck(camera, at, eye); rwData->animTimer--; } else { - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); + camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG); } - if (camera->stateFlags & CAM_STATE_3) { + if (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED) { sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); func_80043B60(camera); camera->atLERPStepScale = 0.0f; @@ -3534,8 +3541,8 @@ s32 Camera_KeepOn3(Camera* camera) { CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) { - camera->stateFlags |= CAM_STATE_2; - camera->stateFlags &= ~CAM_STATE_3; + camera->stateFlags |= CAM_STATE_CHECK_BG; + camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; } } return 1; @@ -3571,27 +3578,27 @@ s32 Camera_KeepOn4(Camera* camera) { if (RELOAD_PARAMS(camera)) { if (camera->play->view.unk_124 == 0) { - camera->stateFlags |= CAM_STATE_5; - camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); + camera->stateFlags |= CAM_STATE_LOCK_MODE; + camera->stateFlags &= ~(CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); camera->play->view.unk_124 = camera->camId | 0x50; return 1; } rwData->unk_14 = *temp_s0; - camera->stateFlags &= ~CAM_STATE_5; + camera->stateFlags &= ~CAM_STATE_LOCK_MODE; } if (rwData->unk_14 != *temp_s0) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: item: item type changed %d -> %d\n" VT_RST, rwData->unk_14, *temp_s0); camera->animState = 20; - camera->stateFlags |= CAM_STATE_5; - camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); + camera->stateFlags |= CAM_STATE_LOCK_MODE; + camera->stateFlags &= ~(CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); camera->play->view.unk_124 = camera->camId | 0x50; return 1; } playerHeight = Player_GetHeight(camera->player); - camera->stateFlags &= ~CAM_STATE_4; + camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; f32 yNormal = 1.0f + t - (68.0f / playerHeight * t); @@ -3738,7 +3745,7 @@ s32 Camera_KeepOn4(Camera* camera) { spCC[sp9C] = &camera->player->actor; sp9C++; func_80043ABC(camera); - camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); + camera->stateFlags &= ~(CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); rwData->unk_10 = roData->unk_1E; rwData->unk_08 = playerPosRot->pos.y - camera->playerPosDelta.y; if (roData->interfaceField & KEEPON4_FLAG_1) { @@ -3821,27 +3828,27 @@ s32 Camera_KeepOn4(Camera* camera) { camera->dist = Camera_LERPCeilF(roData->unk_04, camera->dist, 0.25f, 2.0f); spB8.r = camera->dist; if (rwData->unk_10 != 0) { - camera->stateFlags |= CAM_STATE_5; + camera->stateFlags |= CAM_STATE_LOCK_MODE; rwData->unk_0C += (s16)rwData->unk_00; rwData->unk_0E += (s16)rwData->unk_04; rwData->unk_10--; } else if (roData->interfaceField & KEEPON4_FLAG_4) { - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); - camera->stateFlags |= (CAM_STATE_1 | CAM_STATE_2); - camera->stateFlags &= ~CAM_STATE_3; + camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG); + camera->stateFlags |= (CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); + camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; if (camera->timer > 0) { camera->timer--; } } else { - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); - if ((camera->stateFlags & CAM_STATE_3) || (roData->interfaceField & KEEPON4_FLAG_7)) { + camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG); + if ((camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED) || (roData->interfaceField & KEEPON4_FLAG_7)) { sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); - camera->stateFlags |= (CAM_STATE_1 | CAM_STATE_2); - camera->stateFlags &= ~CAM_STATE_3; + camera->stateFlags |= (CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); + camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; if (camera->prevBgCamIndex < 0) { - Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); + Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY); } else { - Camera_ChangeBgCamIndex(camera, camera->prevBgCamIndex); + Camera_RequestBgCam(camera, camera->prevBgCamIndex); camera->prevBgCamIndex = -1; } } @@ -3871,7 +3878,7 @@ s32 Camera_KeepOn0(Camera* camera) { UNUSED Vec3s bgCamRot; s16 fov; - camera->stateFlags &= ~CAM_STATE_4; + camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; @@ -3903,7 +3910,7 @@ s32 Camera_KeepOn0(Camera* camera) { VT_COL(YELLOW, BLACK) "camera: warning: talk: target is not valid, change normal camera\n" VT_RST); } camera->target = NULL; - Camera_ChangeMode(camera, CAM_MODE_NORMAL); + Camera_RequestMode(camera, CAM_MODE_NORMAL); return true; } @@ -3928,7 +3935,7 @@ s32 Camera_KeepOn0(Camera* camera) { Camera_AddVecGeoToVec3f(at, eye, &eyeAtOffset); rwData->animTimer--; } else { - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); + camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG); } camera->fov = Camera_LERPCeilF(rwData->fovTarget, camera->fov, 0.5f, 10.0f); return true; @@ -4789,7 +4796,7 @@ s32 Camera_Unique2(Camera* camera) { func_80043B60(camera); rwData->unk_00 = 200.0f; if (roData->interfaceField & UNIQUE2_FLAG_4) { - camera->stateFlags &= ~CAM_STATE_2; + camera->stateFlags &= ~CAM_STATE_CHECK_BG; } } @@ -4838,7 +4845,7 @@ s32 Camera_Unique3(Camera* camera) { PosRot* cameraPlayerPosRot = &camera->playerPosRot; playerHeight = Player_GetHeight(camera->player); - camera->stateFlags &= ~CAM_STATE_4; + camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; @@ -4859,7 +4866,7 @@ s32 Camera_Unique3(Camera* camera) { switch (camera->animState) { case 0: func_80043B60(camera); - camera->stateFlags &= ~(CAM_STATE_2 | CAM_STATE_3); + camera->stateFlags &= ~(CAM_STATE_CHECK_BG | CAM_STATE_EXTERNAL_FINISHED); rwData->initialFov = camera->fov; rwData->initialDist = OLib_Vec3fDist(at, &camera->eye); camera->animState++; @@ -4892,8 +4899,8 @@ s32 Camera_Unique3(Camera* camera) { camera->animState++; FALLTHROUGH; case 3: - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); - if (camera->stateFlags & CAM_STATE_3) { + camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG); + if (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED) { camera->animState++; } else { break; @@ -4901,9 +4908,9 @@ s32 Camera_Unique3(Camera* camera) { FALLTHROUGH; case 4: if (roData->interfaceField & UNIQUE3_FLAG_1) { - camera->stateFlags |= CAM_STATE_2; - camera->stateFlags &= ~CAM_STATE_3; - Camera_ChangeSettingFlags(camera, CAM_SET_PIVOT_IN_FRONT, 2); + camera->stateFlags |= CAM_STATE_CHECK_BG; + camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; + Camera_RequestSettingImpl(camera, CAM_SET_PIVOT_IN_FRONT, CAM_REQUEST_SETTING_IGNORE_PRIORITY); break; } doorParams->timer3 = 5; @@ -4932,10 +4939,10 @@ s32 Camera_Unique3(Camera* camera) { camera->animState++; FALLTHROUGH; default: - camera->stateFlags |= CAM_STATE_2; - camera->stateFlags &= ~CAM_STATE_3; + camera->stateFlags |= CAM_STATE_CHECK_BG; + camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; camera->fov = roData->fov; - Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); + Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY); camera->atLERPStepScale = 0.0f; camera->playerToAtOffset.x = camera->at.x - cameraPlayerPosRot->pos.x; camera->playerToAtOffset.y = camera->at.y - cameraPlayerPosRot->pos.y; @@ -4984,7 +4991,7 @@ s32 Camera_Unique0(Camera* camera) { if (camera->animState == 0) { func_80043B60(camera); - camera->stateFlags &= ~CAM_STATE_2; + camera->stateFlags &= ~CAM_STATE_CHECK_BG; bgCamFuncData = (BgCamFuncData*)Camera_GetBgCamFuncData(camera); Camera_Vec3sToVec3f(&rwData->eyeAndDirection.point, &bgCamFuncData->pos); @@ -5031,8 +5038,8 @@ s32 Camera_Unique0(Camera* camera) { camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y; camera->playerToAtOffset.z = camera->at.z - playerPosRot->pos.z; camera->atLERPStepScale = 0.0f; - camera->stateFlags |= CAM_STATE_2; - Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); + camera->stateFlags |= CAM_STATE_CHECK_BG; + Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY); } } else { if (rwData->animTimer > 0) { @@ -5058,8 +5065,8 @@ s32 Camera_Unique0(Camera* camera) { camera->playerToAtOffset.y = camera->at.y - playerPosRot->pos.y; camera->playerToAtOffset.z = camera->at.z - playerPosRot->pos.z; camera->atLERPStepScale = 0.0f; - Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); - camera->stateFlags |= CAM_STATE_2; + Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY); + camera->stateFlags |= CAM_STATE_CHECK_BG; } } return true; @@ -5183,7 +5190,7 @@ s32 Camera_Unique7(Camera* camera) { rwData->unk_00.x = Camera_LERPFloorS(playerPosEyeOffset.yaw, rwData->unk_00.x, 0.4f, 0x7D0); playerPosEyeOffset.pitch = -bgCamFuncData->rot.x * Math_CosS(playerPosEyeOffset.yaw - bgCamFuncData->rot.y); Camera_AddVecGeoToVec3f(at, eye, &playerPosEyeOffset); - camera->stateFlags |= CAM_STATE_10; + camera->stateFlags |= CAM_STATE_BLOCK_BG; return true; } @@ -5478,16 +5485,16 @@ s32 Camera_Unique9(Camera* camera) { *eyeNext = rwData->eyeTarget; camera->fov = rwData->fovTarget; camera->roll = rwData->rollTarget; - camera->stateFlags |= CAM_STATE_10; + camera->stateFlags |= CAM_STATE_BLOCK_BG; break; case ONEPOINT_CS_ACTION_ID_21: // same as 15, but with unk_38 ? if (rwData->unk_38 == 0) { rwData->unk_38 = 1; - } else if (camera->stateFlags & CAM_STATE_3) { + } else if (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED) { rwData->unk_38 = 0; - camera->stateFlags &= ~CAM_STATE_3; + camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; } *at = rwData->atTarget; *eyeNext = rwData->eyeTarget; @@ -5496,10 +5503,10 @@ s32 Camera_Unique9(Camera* camera) { break; case ONEPOINT_CS_ACTION_ID_16: - // same as 21, but don't unset CAM_STATE_3 on stateFlags + // same as 21, but don't unset CAM_STATE_EXTERNAL_FINISHED on stateFlags if (rwData->unk_38 == 0) { rwData->unk_38 = 1; - } else if (camera->stateFlags & CAM_STATE_3) { + } else if (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED) { rwData->unk_38 = 0; } @@ -5626,7 +5633,7 @@ s32 Camera_Unique9(Camera* camera) { // Change the parent camera (or default)'s mode to normal s32 camId = camera->parentCamId <= CAM_ID_NONE ? CAM_ID_MAIN : camera->parentCamId; - Camera_ChangeModeFlags(camera->play->cameraPtrs[camId], CAM_MODE_NORMAL, 1); + Camera_RequestModeImpl(camera->play->cameraPtrs[camId], CAM_MODE_NORMAL, true); } FALLTHROUGH; case ONEPOINT_CS_ACTION_ID_18: { @@ -5821,7 +5828,7 @@ s32 Camera_Demo3(Camera* camera) { Demo3ReadWriteData* rwData = &camera->paramData.demo3.rwData; s32 pad2; - camera->stateFlags &= ~CAM_STATE_4; + camera->stateFlags &= ~CAM_STATE_CAM_FUNC_FINISH; if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; @@ -5841,7 +5848,7 @@ s32 Camera_Demo3(Camera* camera) { switch (camera->animState) { case 0: - camera->stateFlags &= ~(CAM_STATE_2 | CAM_STATE_3); + camera->stateFlags &= ~(CAM_STATE_CHECK_BG | CAM_STATE_EXTERNAL_FINISHED); func_80043B60(camera); camera->fov = roData->fov; camera->roll = rwData->animFrame = 0; @@ -5938,8 +5945,8 @@ s32 Camera_Demo3(Camera* camera) { rwData->unk_0C += (4.0f / 45.0f); break; case 30: - camera->stateFlags |= CAM_STATE_10; - if (camera->stateFlags & CAM_STATE_3) { + camera->stateFlags |= CAM_STATE_BLOCK_BG; + if (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED) { camera->animState = 4; } FALLTHROUGH; @@ -5963,17 +5970,17 @@ s32 Camera_Demo3(Camera* camera) { CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CRIGHT) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_R) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z)) && - (camera->stateFlags & CAM_STATE_3))) { + (camera->stateFlags & CAM_STATE_EXTERNAL_FINISHED))) { goto skipeyeUpdate; } FALLTHROUGH; default: - camera->stateFlags |= (CAM_STATE_2 | CAM_STATE_4); - camera->stateFlags &= ~CAM_STATE_3; + camera->stateFlags |= (CAM_STATE_CHECK_BG | CAM_STATE_CAM_FUNC_FINISH); + camera->stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; if (camera->prevBgCamIndex < 0) { - Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); + Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY); } else { - Camera_ChangeBgCamIndex(camera, camera->prevBgCamIndex); + Camera_RequestBgCam(camera, camera->prevBgCamIndex); camera->prevBgCamIndex = -1; } sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); @@ -6248,7 +6255,8 @@ s32 Camera_Demo5(Camera* camera) { } sDemo5PrevAction12Frame = camera->play->state.frames; - Camera_ChangeSettingFlags(camera, CAM_SET_CS_C, (4 | 1)); + Camera_RequestSettingImpl(camera, CAM_SET_CS_C, + CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX | CAM_REQUEST_SETTING_FORCE_CHANGE); Camera_Unique9(camera); @@ -6340,8 +6348,8 @@ s32 Camera_Demo6(Camera* camera) { s32 Camera_Demo7(Camera* camera) { if (camera->animState == 0) { - camera->stateFlags &= ~CAM_STATE_2; - camera->stateFlags |= CAM_STATE_12; + camera->stateFlags &= ~CAM_STATE_CHECK_BG; + camera->stateFlags |= CAM_STATE_DEMO7; camera->animState++; } //! @bug doesn't return @@ -6885,7 +6893,7 @@ s32 Camera_Special9(Camera* camera) { BgCamFuncData* bgCamFuncData; playerYOffset = Player_GetHeight(camera->player); - camera->stateFlags &= ~CAM_STATE_4; + 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)); @@ -6917,7 +6925,7 @@ s32 Camera_Special9(Camera* camera) { if (1) {} case 0: - camera->stateFlags &= ~(CAM_STATE_1 | CAM_STATE_2); + camera->stateFlags &= ~(CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); camera->animState++; //! @bug The angle passed to ABS should be cast to s16. @@ -6992,7 +7000,7 @@ s32 Camera_Special9(Camera* camera) { camera->animState++; FALLTHROUGH; default: - camera->stateFlags |= (CAM_STATE_4 | CAM_STATE_10); + camera->stateFlags |= (CAM_STATE_CAM_FUNC_FINISH | CAM_STATE_BLOCK_BG); sCameraInterfaceField = CAM_INTERFACE_FIELD(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0); if (camera->xzSpeed > 0.001f || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || @@ -7005,8 +7013,8 @@ s32 Camera_Special9(Camera* camera) { CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_Z) || (roData->interfaceField & SPECIAL9_FLAG_3)) { - Camera_ChangeSettingFlags(camera, camera->prevSetting, 2); - camera->stateFlags |= (CAM_STATE_1 | CAM_STATE_2); + Camera_RequestSettingImpl(camera, camera->prevSetting, CAM_REQUEST_SETTING_IGNORE_PRIORITY); + camera->stateFlags |= (CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG); } break; } @@ -7107,7 +7115,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState camera->bgId = BGCHECK_SCENE; camera->csId = 0x7FFF; camera->timer = -1; - camera->stateFlags |= CAM_STATE_14; + camera->stateFlags |= CAM_STATE_CAM_INIT; camera->up.y = 1.0f; camera->up.z = camera->up.x = 0.0f; @@ -7122,7 +7130,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState void func_80057FC4(Camera* camera) { if (camera != &camera->play->mainCamera) { camera->prevSetting = camera->setting = CAM_SET_FREE0; - camera->stateFlags &= ~CAM_STATE_2; + camera->stateFlags &= ~CAM_STATE_CHECK_BG; } else if (camera->play->roomCtx.curRoom.roomShape->base.type != ROOM_SHAPE_TYPE_IMAGE) { switch (camera->play->roomCtx.curRoom.behaviorType1) { case ROOM_BEHAVIOR_TYPE1_1: @@ -7138,13 +7146,13 @@ void func_80057FC4(Camera* camera) { osSyncPrintf("camera: room type: default set etc (%d)\n", camera->play->roomCtx.curRoom.behaviorType1); Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10); camera->prevSetting = camera->setting = CAM_SET_NORMAL0; - camera->stateFlags |= CAM_STATE_2; + camera->stateFlags |= CAM_STATE_CHECK_BG; break; } } else { osSyncPrintf("camera: room type: prerender\n"); camera->prevSetting = camera->setting = CAM_SET_FREE0; - camera->stateFlags &= ~CAM_STATE_2; + camera->stateFlags &= ~CAM_STATE_CHECK_BG; } } @@ -7196,7 +7204,7 @@ void Camera_InitDataUsingPlayer(Camera* camera, Player* player) { camera->bgCamIndexBeforeUnderwater = -1; camera->waterCamSetting = -1; - camera->stateFlags |= CAM_STATE_2; + camera->stateFlags |= CAM_STATE_CHECK_BG; if (camera == &camera->play->mainCamera) { sCameraInterfaceField = @@ -7334,24 +7342,29 @@ s32 Camera_UpdateWater(Camera* camera) { Player* player = camera->player; s16 prevBgId; - if (!(camera->stateFlags & CAM_STATE_1) || sCameraSettings[camera->setting].unk_00 & 0x40000000) { + if (!(camera->stateFlags & CAM_STATE_CHECK_WATER) || sCameraSettings[camera->setting].unk_00 & 0x40000000) { return 0; } - if (camera->stateFlags & CAM_STATE_9) { + // Process player diving in water + if (camera->stateFlags & CAM_STATE_PLAYER_IN_WATER) { if (player->stateFlags2 & PLAYER_STATE2_11) { - Camera_ChangeSettingFlags(camera, CAM_SET_PIVOT_WATER_SURFACE, 6); - camera->stateFlags |= CAM_STATE_15; - } else if (camera->stateFlags & CAM_STATE_15) { - Camera_ChangeSettingFlags(camera, *waterCamSetting, 6); - camera->stateFlags &= ~CAM_STATE_15; + Camera_RequestSettingImpl(camera, CAM_SET_PIVOT_WATER_SURFACE, + CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX | CAM_REQUEST_SETTING_IGNORE_PRIORITY); + camera->stateFlags |= CAM_STATE_PLAYER_DIVING; + } else if (camera->stateFlags & CAM_STATE_PLAYER_DIVING) { + Camera_RequestSettingImpl(camera, *waterCamSetting, + CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX | CAM_REQUEST_SETTING_IGNORE_PRIORITY); + camera->stateFlags &= ~CAM_STATE_PLAYER_DIVING; } } - if (!(camera->stateFlags & CAM_STATE_15)) { + + // Process player swimming in water + if (!(camera->stateFlags & CAM_STATE_PLAYER_DIVING)) { if (waterBgCamIndex = Camera_GetWaterBoxBgCamIndex(camera, &waterY), waterBgCamIndex == -2) { - // No camera data index - if (!(camera->stateFlags & CAM_STATE_9)) { - camera->stateFlags |= CAM_STATE_9; + // In a water box that has no bgCamIndex + if (!(camera->stateFlags & CAM_STATE_PLAYER_IN_WATER)) { + camera->stateFlags |= CAM_STATE_PLAYER_IN_WATER; camera->waterYPos = waterY; camera->bgCamIndexBeforeUnderwater = camera->bgCamIndex; *waterQuakeIndex = -1; @@ -7359,15 +7372,15 @@ s32 Camera_UpdateWater(Camera* camera) { if (camera->playerGroundY != camera->playerPosRot.pos.y) { prevBgId = camera->bgId; camera->bgId = BGCHECK_SCENE; - Camera_ChangeSettingFlags(camera, CAM_SET_NORMAL3, 2); + Camera_RequestSettingImpl(camera, CAM_SET_NORMAL3, CAM_REQUEST_SETTING_IGNORE_PRIORITY); *waterCamSetting = camera->setting; camera->bgId = prevBgId; camera->bgCamIndex = -2; } } else if (waterBgCamIndex != -1) { - // player is in a water box - if (!(camera->stateFlags & CAM_STATE_9)) { - camera->stateFlags |= CAM_STATE_9; + // In a water box with a bgCamIndex + if (!(camera->stateFlags & CAM_STATE_PLAYER_IN_WATER)) { + camera->stateFlags |= CAM_STATE_PLAYER_IN_WATER; camera->waterYPos = waterY; camera->bgCamIndexBeforeUnderwater = camera->bgCamIndex; *waterQuakeIndex = -1; @@ -7375,30 +7388,31 @@ s32 Camera_UpdateWater(Camera* camera) { if (camera->playerGroundY != camera->playerPosRot.pos.y) { prevBgId = camera->bgId; camera->bgId = BGCHECK_SCENE; - Camera_ChangeBgCamIndex(camera, waterBgCamIndex); + Camera_RequestBgCam(camera, waterBgCamIndex); *waterCamSetting = camera->setting; camera->bgId = prevBgId; } - } else if (camera->stateFlags & CAM_STATE_9) { - // player is out of a water box. + } else if (camera->stateFlags & CAM_STATE_PLAYER_IN_WATER) { + // player is leaving a water box. osSyncPrintf("camera: water: off\n"); - camera->stateFlags &= ~CAM_STATE_9; + camera->stateFlags &= ~CAM_STATE_PLAYER_IN_WATER; prevBgId = camera->bgId; camera->bgId = BGCHECK_SCENE; if (camera->bgCamIndexBeforeUnderwater < 0) { func_80057FC4(camera); camera->bgCamIndex = -1; } else { - Camera_ChangeBgCamIndex(camera, camera->bgCamIndexBeforeUnderwater); + Camera_RequestBgCam(camera, camera->bgCamIndexBeforeUnderwater); } camera->bgId = prevBgId; } } + // Process camera in water if (waterY = Camera_GetWaterSurface(camera, &camera->eye, &waterLightsIndex), waterY != BGCHECK_Y_MIN) { camera->waterYPos = waterY; - if (!(camera->stateFlags & CAM_STATE_8)) { - camera->stateFlags |= CAM_STATE_8; + if (!(camera->stateFlags & CAM_STATE_CAMERA_IN_WATER)) { + camera->stateFlags |= CAM_STATE_CAMERA_IN_WATER; osSyncPrintf("kankyo changed water, sound on\n"); Environment_EnableUnderwaterLights(camera->play, waterLightsIndex); camera->waterDistortionTimer = 80; @@ -7432,8 +7446,8 @@ s32 Camera_UpdateWater(Camera* camera) { camera->distortionFlags |= DISTORTION_UNDERWATER_WEAK; } } else { - if (camera->stateFlags & CAM_STATE_8) { - camera->stateFlags &= ~CAM_STATE_8; + if (camera->stateFlags & CAM_STATE_CAMERA_IN_WATER) { + camera->stateFlags &= ~CAM_STATE_CAMERA_IN_WATER; osSyncPrintf("kankyo changed water off, sound off\n"); Environment_DisableUnderwaterLights(camera->play); if (*waterQuakeIndex != 0) { @@ -7477,7 +7491,7 @@ s32 Camera_DbgChangeMode(Camera* camera) { } if (changeDir != 0) { sDbgModeIdx = (sDbgModeIdx + changeDir) % 6; - if (Camera_ChangeSetting(camera, D_8011DAFC[sDbgModeIdx]) > 0) { + if (Camera_RequestSetting(camera, D_8011DAFC[sDbgModeIdx]) > 0) { osSyncPrintf("camera: force change SET to %s!\n", sCameraSettingNames[D_8011DAFC[sDbgModeIdx]]); } } @@ -7562,11 +7576,11 @@ void Camera_UpdateDistortion(Camera* camera) { Math_CosS(depthPhase) * (zScale * scaleFactor) + 1.0f); View_SetDistortionSpeed(&camera->play->view, speed * speedFactor); - camera->stateFlags |= CAM_STATE_6; + camera->stateFlags |= CAM_STATE_DISTORTION; - } else if (camera->stateFlags & CAM_STATE_6) { + } else if (camera->stateFlags & CAM_STATE_DISTORTION) { View_ClearDistortion(&camera->play->view); - camera->stateFlags &= ~CAM_STATE_6; + camera->stateFlags &= ~CAM_STATE_DISTORTION; } } @@ -7640,14 +7654,14 @@ Vec3s Camera_Update(Camera* camera) { Camera_UpdateHotRoom(camera); } - if (!(camera->stateFlags & CAM_STATE_2)) { + if (!(camera->stateFlags & CAM_STATE_CHECK_BG)) { camera->nextBgCamIndex = -1; } - if ((camera->stateFlags & CAM_STATE_0) && (camera->stateFlags & CAM_STATE_2) && - !(camera->stateFlags & CAM_STATE_10) && - (!(camera->stateFlags & CAM_STATE_9) || (player->currentBoots == PLAYER_BOOTS_IRON)) && - !(camera->stateFlags & CAM_STATE_15) && (playerGroundY != BGCHECK_Y_MIN)) { + if ((camera->stateFlags & CAM_STATE_CHECK_BG_ALT) && (camera->stateFlags & CAM_STATE_CHECK_BG) && + !(camera->stateFlags & CAM_STATE_BLOCK_BG) && + (!(camera->stateFlags & CAM_STATE_PLAYER_IN_WATER) || (player->currentBoots == PLAYER_BOOTS_IRON)) && + !(camera->stateFlags & CAM_STATE_PLAYER_DIVING) && (playerGroundY != BGCHECK_Y_MIN)) { bgCamIndex = Camera_GetBgCamIndex(camera, &bgId, playerFloorPoly); if (bgCamIndex != -1) { camera->nextBgId = bgId; @@ -7657,10 +7671,10 @@ Vec3s Camera_Update(Camera* camera) { } } - if (camera->nextBgCamIndex != -1 && (fabsf(curPlayerPosRot.pos.y - playerGroundY) < 2.0f) && - (!(camera->stateFlags & CAM_STATE_9) || (player->currentBoots == PLAYER_BOOTS_IRON))) { + if ((camera->nextBgCamIndex != -1) && (fabsf(curPlayerPosRot.pos.y - playerGroundY) < 2.0f) && + (!(camera->stateFlags & CAM_STATE_PLAYER_IN_WATER) || (player->currentBoots == PLAYER_BOOTS_IRON))) { camera->bgId = camera->nextBgId; - Camera_ChangeBgCamIndex(camera, camera->nextBgCamIndex); + Camera_RequestBgCam(camera, camera->nextBgCamIndex); camera->nextBgCamIndex = -1; } } @@ -7676,8 +7690,8 @@ Vec3s Camera_Update(Camera* camera) { } camera->behaviorFlags = 0; - camera->stateFlags &= ~(CAM_STATE_10 | CAM_STATE_5); - camera->stateFlags |= CAM_STATE_4; + camera->stateFlags &= ~(CAM_STATE_BLOCK_BG | CAM_STATE_LOCK_MODE); + camera->stateFlags |= CAM_STATE_CAM_FUNC_FINISH; if (R_DEBUG_CAM_UPDATE) { osSyncPrintf("camera: engine (%d %d %d) %04x \n", camera->setting, camera->mode, @@ -7846,7 +7860,7 @@ void Camera_Finish(Camera* camera) { osSyncPrintf("camera: player demo end!!\n"); } - mainCam->stateFlags |= CAM_STATE_3; + mainCam->stateFlags |= CAM_STATE_EXTERNAL_FINISHED; } if (CHILD_CAM(camera)->parentCamId == camera->camId) { @@ -7869,140 +7883,181 @@ void Camera_Finish(Camera* camera) { } } -s32 func_8005A02C(Camera* camera) { - camera->stateFlags |= (CAM_STATE_2 | CAM_STATE_3); - camera->stateFlags &= ~(CAM_STATE_3 | CAM_STATE_12); +s32 Camera_SetNewModeStateFlags(Camera* camera) { + camera->stateFlags |= (CAM_STATE_CHECK_BG | CAM_STATE_EXTERNAL_FINISHED); + camera->stateFlags &= ~(CAM_STATE_EXTERNAL_FINISHED | CAM_STATE_DEMO7); return true; } -s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags) { - static s32 modeChangeFlags = 0; +#define CAM_REQUEST_MODE_FORCE_NO_SFX (1 << 0) +#define CAM_REQUEST_MODE_SFX_ATTENTION (1 << 1) +#define CAM_REQUEST_MODE_Z_TARGET_UNFRIENDLY (1 << 2) +#define CAM_REQUEST_MODE_Z_TARGET_FRIENDLY (1 << 3) +#define CAM_REQUEST_MODE_SKIP_ANIM_NORMAL_PARALLEL (1 << 4) // never set to +#define CAM_REQUEST_MODE_SKIP_ANIM_FIRST_PERSON (1 << 5) + +s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange) { + static s32 sModeRequestFlags = 0; if (QREG(89)) { - osSyncPrintf("+=+(%d)+=+ recive request -> %s\n", camera->play->state.frames, sCameraModeNames[mode]); + osSyncPrintf("+=+(%d)+=+ recive request -> %s\n", camera->play->state.frames, sCameraModeNames[requestedMode]); } - if ((camera->stateFlags & CAM_STATE_5) && (flags == 0)) { - camera->behaviorFlags |= CAM_BEHAVIOR_MODE_2; + if ((camera->stateFlags & CAM_STATE_LOCK_MODE) && !forceModeChange) { + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; return -1; } - if (!((sCameraSettings[camera->setting].unk_00 & 0x3FFFFFFF) & (1 << mode))) { - if (mode == CAM_MODE_FIRST_PERSON) { + if (!((sCameraSettings[camera->setting].unk_00 & 0x3FFFFFFF) & (1 << requestedMode))) { + if (requestedMode == CAM_MODE_FIRST_PERSON) { osSyncPrintf("camera: error sound\n"); Sfx_PlaySfxCentered(NA_SE_SY_ERROR); } if (camera->mode != CAM_MODE_NORMAL) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: change camera mode: force NORMAL: %s %s refused\n" VT_RST, - sCameraSettingNames[camera->setting], sCameraModeNames[mode]); + sCameraSettingNames[camera->setting], sCameraModeNames[requestedMode]); camera->mode = CAM_MODE_NORMAL; Camera_CopyDataToRegs(camera, camera->mode); - func_8005A02C(camera); - return 0xC0000000 | mode; - } else { - camera->behaviorFlags |= CAM_BEHAVIOR_MODE_2; - camera->behaviorFlags |= CAM_BEHAVIOR_MODE_1; - return 0; - } - } else { - if (mode == camera->mode && flags == 0) { - camera->behaviorFlags |= CAM_BEHAVIOR_MODE_2; - camera->behaviorFlags |= CAM_BEHAVIOR_MODE_1; - return -1; - } - camera->behaviorFlags |= CAM_BEHAVIOR_MODE_2; - camera->behaviorFlags |= CAM_BEHAVIOR_MODE_1; - Camera_CopyDataToRegs(camera, mode); - modeChangeFlags = 0; - switch (mode) { - case CAM_MODE_FIRST_PERSON: - modeChangeFlags = 0x20; - break; - case CAM_MODE_Z_TARGET_UNFRIENDLY: - modeChangeFlags = 4; - break; - case CAM_MODE_Z_TARGET_FRIENDLY: - if (camera->target != NULL && camera->target->id != ACTOR_EN_BOOM) { - modeChangeFlags = 8; - } - break; - case CAM_MODE_Z_PARALLEL: - case CAM_MODE_TALK: - case CAM_MODE_Z_AIM: - case CAM_MODE_Z_LEDGE_HANG: - case CAM_MODE_PUSH_PULL: - modeChangeFlags = 2; - break; + Camera_SetNewModeStateFlags(camera); + return 0xC0000000 | requestedMode; } - switch (camera->mode) { - case CAM_MODE_FIRST_PERSON: - if (modeChangeFlags & 0x20) { - camera->animState = 10; - } - break; - case CAM_MODE_Z_PARALLEL: - if (modeChangeFlags & 0x10) { - camera->animState = 10; - } - modeChangeFlags |= 1; - break; - case CAM_MODE_CHARGE: - modeChangeFlags |= 1; - break; - case CAM_MODE_Z_TARGET_FRIENDLY: - if (modeChangeFlags & 8) { - camera->animState = 10; - } - modeChangeFlags |= 1; - break; - case CAM_MODE_Z_TARGET_UNFRIENDLY: - if (modeChangeFlags & 4) { - camera->animState = 10; - } - modeChangeFlags |= 1; - break; - case CAM_MODE_Z_AIM: - case CAM_MODE_Z_LEDGE_HANG: - case CAM_MODE_PUSH_PULL: - modeChangeFlags |= 1; - break; - case CAM_MODE_NORMAL: - if (modeChangeFlags & 0x10) { - camera->animState = 10; - } - break; - } - modeChangeFlags &= ~0x10; - if (camera->status == CAM_STAT_ACTIVE) { - switch (modeChangeFlags) { - case 1: - Sfx_PlaySfxCentered(0); - break; - case 2: - if (camera->play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) { - Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_URGENCY); - } else { - Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_ON); - } - break; - case 4: - Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_URGENCY); - break; - case 8: - Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_ON); - break; - } - } - func_8005A02C(camera); - camera->mode = mode; - return 0x80000000 | mode; + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_SUCCESS; + return CAM_MODE_NORMAL; } + + if ((requestedMode == camera->mode) && !forceModeChange) { + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_SUCCESS; + return -1; + } + + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_VALID; + camera->behaviorFlags |= CAM_BEHAVIOR_MODE_SUCCESS; + + Camera_CopyDataToRegs(camera, requestedMode); + + sModeRequestFlags = 0; + + // requested camMode + switch (requestedMode) { + case CAM_MODE_FIRST_PERSON: + sModeRequestFlags = CAM_REQUEST_MODE_SKIP_ANIM_FIRST_PERSON; + break; + + case CAM_MODE_Z_TARGET_UNFRIENDLY: + sModeRequestFlags = CAM_REQUEST_MODE_Z_TARGET_UNFRIENDLY; + break; + + case CAM_MODE_Z_TARGET_FRIENDLY: + if ((camera->target != NULL) && (camera->target->id != ACTOR_EN_BOOM)) { + sModeRequestFlags = CAM_REQUEST_MODE_Z_TARGET_FRIENDLY; + } + break; + + case CAM_MODE_Z_PARALLEL: + case CAM_MODE_TALK: + case CAM_MODE_Z_AIM: + case CAM_MODE_Z_LEDGE_HANG: + case CAM_MODE_PUSH_PULL: + sModeRequestFlags = CAM_REQUEST_MODE_SFX_ATTENTION; + break; + + default: + break; + } + + // If the requested mode is already the same as the current mode, + // then many modes will reset their animState to 10. + switch (camera->mode) { + case CAM_MODE_FIRST_PERSON: + if (sModeRequestFlags & CAM_REQUEST_MODE_SKIP_ANIM_FIRST_PERSON) { + camera->animState = 10; + } + break; + + case CAM_MODE_Z_PARALLEL: + if (sModeRequestFlags & CAM_REQUEST_MODE_SKIP_ANIM_NORMAL_PARALLEL) { + camera->animState = 10; + } + sModeRequestFlags |= CAM_REQUEST_MODE_FORCE_NO_SFX; + break; + + case CAM_MODE_CHARGE: + sModeRequestFlags |= CAM_REQUEST_MODE_FORCE_NO_SFX; + break; + + case CAM_MODE_Z_TARGET_FRIENDLY: + if (sModeRequestFlags & CAM_REQUEST_MODE_Z_TARGET_FRIENDLY) { + camera->animState = 10; + } + sModeRequestFlags |= CAM_REQUEST_MODE_FORCE_NO_SFX; + break; + + case CAM_MODE_Z_TARGET_UNFRIENDLY: + if (sModeRequestFlags & CAM_REQUEST_MODE_Z_TARGET_UNFRIENDLY) { + camera->animState = 10; + } + sModeRequestFlags |= CAM_REQUEST_MODE_FORCE_NO_SFX; + break; + + case CAM_MODE_Z_AIM: + case CAM_MODE_Z_LEDGE_HANG: + case CAM_MODE_PUSH_PULL: + sModeRequestFlags |= CAM_REQUEST_MODE_FORCE_NO_SFX; + break; + + case CAM_MODE_NORMAL: + if (sModeRequestFlags & CAM_REQUEST_MODE_SKIP_ANIM_NORMAL_PARALLEL) { + camera->animState = 10; + } + break; + + default: + break; + } + + sModeRequestFlags &= ~CAM_REQUEST_MODE_SKIP_ANIM_NORMAL_PARALLEL; + + // Choose a sound effect to play. + // Having `CAM_REQUEST_MODE_FORCE_NO_SFX` set often means `default` is taken from two bits being set + if (camera->status == CAM_STAT_ACTIVE) { + switch (sModeRequestFlags) { + case CAM_REQUEST_MODE_FORCE_NO_SFX: + Sfx_PlaySfxCentered(NA_SE_NONE); + break; + + case CAM_REQUEST_MODE_SFX_ATTENTION: + if (camera->play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) { + Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_URGENCY); + } else { + Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_ON); + } + break; + + case CAM_REQUEST_MODE_Z_TARGET_UNFRIENDLY: + Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_URGENCY); + break; + + case CAM_REQUEST_MODE_Z_TARGET_FRIENDLY: + Sfx_PlaySfxCentered(NA_SE_SY_ATTENTION_ON); + break; + + default: + break; + } + } + + Camera_SetNewModeStateFlags(camera); + camera->mode = requestedMode; + + return requestedMode | 0x80000000; } -s32 Camera_ChangeMode(Camera* camera, s16 mode) { - return Camera_ChangeModeFlags(camera, mode, 0); +s32 Camera_RequestMode(Camera* camera, s16 mode) { + return Camera_RequestModeImpl(camera, mode, false); } s32 Camera_CheckValidMode(Camera* camera, s16 mode) { @@ -8019,97 +8074,105 @@ s32 Camera_CheckValidMode(Camera* camera, s16 mode) { } } -s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags) { - if (camera->behaviorFlags & CAM_BEHAVIOR_SETTING_1) { - if ((u32)((u32)(sCameraSettings[camera->setting].unk_00 & 0xF000000) >> 0x18) >= - (u32)((u32)(sCameraSettings[setting].unk_00 & 0xF000000) >> 0x18)) { - camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_2; +s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags) { + if (camera->behaviorFlags & CAM_BEHAVIOR_SETTING_CHECK_PRIORITY) { + // If a second setting is requested this frame, determine if the setting overwrites the + // current setting through priority + if (((sCameraSettings[camera->setting].unk_00 & 0xF000000) >> 0x18) >= + ((sCameraSettings[requestedSetting].unk_00 & 0xF000000) >> 0x18)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_VALID; return -2; } } - if (((setting == CAM_SET_MEADOW_BIRDS_EYE) || (setting == CAM_SET_MEADOW_UNUSED)) && LINK_IS_ADULT && - (camera->play->sceneId == SCENE_SACRED_FOREST_MEADOW)) { - camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_2; + + if (((requestedSetting == CAM_SET_MEADOW_BIRDS_EYE) || (requestedSetting == CAM_SET_MEADOW_UNUSED)) && + LINK_IS_ADULT && (camera->play->sceneId == SCENE_SACRED_FOREST_MEADOW)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_VALID; return -5; } - if (setting == CAM_SET_NONE || setting >= CAM_SET_MAX) { - osSyncPrintf(VT_COL(RED, WHITE) "camera: error: illegal camera set (%d) !!!!\n" VT_RST, setting); + if ((requestedSetting == CAM_SET_NONE) || (requestedSetting >= CAM_SET_MAX)) { + osSyncPrintf(VT_COL(RED, WHITE) "camera: error: illegal camera set (%d) !!!!\n" VT_RST, requestedSetting); return -99; } - if ((setting == camera->setting) && !(flags & 1)) { - camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_2; - if (!(flags & 2)) { - camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_1; + if ((requestedSetting == camera->setting) && !(flags & CAM_REQUEST_SETTING_FORCE_CHANGE)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_VALID; + if (!(flags & CAM_REQUEST_SETTING_IGNORE_PRIORITY)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_CHECK_PRIORITY; } return -1; } - camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_2; - if (!(flags & 2)) { - camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_1; + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_VALID; + + if (!(flags & CAM_REQUEST_SETTING_IGNORE_PRIORITY)) { + camera->behaviorFlags |= CAM_BEHAVIOR_SETTING_CHECK_PRIORITY; } - camera->stateFlags |= (CAM_STATE_2 | CAM_STATE_3); - camera->stateFlags &= ~(CAM_STATE_3 | CAM_STATE_12); + camera->stateFlags |= (CAM_STATE_CHECK_BG | CAM_STATE_EXTERNAL_FINISHED); + camera->stateFlags &= ~(CAM_STATE_EXTERNAL_FINISHED | CAM_STATE_DEMO7); if (!(sCameraSettings[camera->setting].unk_00 & 0x40000000)) { camera->prevSetting = camera->setting; } - if (flags & 8) { + if (flags & CAM_REQUEST_SETTING_RESTORE_PREV_BG_CAM_INDEX) { if (1) {} camera->bgCamIndex = camera->prevBgCamIndex; camera->prevBgCamIndex = -1; - } else if (!(flags & 4)) { + } else if (!(flags & CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX)) { if (!(sCameraSettings[camera->setting].unk_00 & 0x40000000)) { camera->prevBgCamIndex = camera->bgCamIndex; } camera->bgCamIndex = -1; } - camera->setting = setting; + camera->setting = requestedSetting; - if (Camera_ChangeModeFlags(camera, camera->mode, 1) >= 0) { + if (Camera_RequestModeImpl(camera, camera->mode, true) >= 0) { Camera_CopyDataToRegs(camera, camera->mode); } osSyncPrintf(VT_SGR("1") "%06u:" VT_RST " camera: change camera[%d] set %s\n", camera->play->state.frames, camera->camId, sCameraSettingNames[camera->setting]); - return setting; + return requestedSetting; } -s32 Camera_ChangeSetting(Camera* camera, s16 setting) { - return Camera_ChangeSettingFlags(camera, setting, 0); +s32 Camera_RequestSetting(Camera* camera, s16 setting) { + return Camera_RequestSettingImpl(camera, setting, 0); } -s32 Camera_ChangeBgCamIndex(Camera* camera, s32 bgCamIndex) { - s16 newCameraSetting; +s32 Camera_RequestBgCam(Camera* camera, s32 requestedBgCamIndex) { + s16 requestedCamSetting; s16 settingChangeSuccessful; - if (bgCamIndex == -1 || bgCamIndex == camera->bgCamIndex) { - camera->behaviorFlags |= CAM_BEHAVIOR_BG_2; + if ((requestedBgCamIndex == -1) || (requestedBgCamIndex == camera->bgCamIndex)) { + camera->behaviorFlags |= CAM_BEHAVIOR_BG_PROCESSED; return -1; } - if (!(camera->behaviorFlags & CAM_BEHAVIOR_BG_2)) { - newCameraSetting = Camera_GetBgCamSetting(camera, bgCamIndex); - camera->behaviorFlags |= CAM_BEHAVIOR_BG_2; - settingChangeSuccessful = Camera_ChangeSettingFlags(camera, newCameraSetting, 5) >= 0; - if (settingChangeSuccessful || sCameraSettings[camera->setting].unk_00 & 0x80000000) { - camera->bgCamIndex = bgCamIndex; - camera->behaviorFlags |= CAM_BEHAVIOR_BG_1; + if (!(camera->behaviorFlags & CAM_BEHAVIOR_BG_PROCESSED)) { + requestedCamSetting = Camera_GetBgCamSetting(camera, requestedBgCamIndex); + camera->behaviorFlags |= CAM_BEHAVIOR_BG_PROCESSED; + settingChangeSuccessful = Camera_RequestSettingImpl(camera, requestedCamSetting, + CAM_REQUEST_SETTING_PRESERVE_BG_CAM_INDEX | + CAM_REQUEST_SETTING_FORCE_CHANGE) >= 0; + if ((settingChangeSuccessful != CAM_SET_NONE) || (sCameraSettings[camera->setting].unk_00 & 0x80000000)) { + camera->bgCamIndex = requestedBgCamIndex; + camera->behaviorFlags |= CAM_BEHAVIOR_BG_SUCCESS; Camera_CopyDataToRegs(camera, camera->mode); } else if (settingChangeSuccessful < -1) { - //! @bug: This is likely checking the wrong value. The actual return of Camera_ChangeSettingFlags or - // bgCamIndex would make more sense. - osSyncPrintf(VT_COL(RED, WHITE) "camera: error: illegal camera ID (%d) !! (%d|%d|%d)\n" VT_RST, bgCamIndex, - camera->camId, BGCHECK_SCENE, newCameraSetting); + //! @bug: `settingChangeSuccessful` is a bool and is likely checking the wrong value. This can never pass. + // The actual return of Camera_RequestSettingImpl or bgCamIndex would make more sense. + osSyncPrintf(VT_COL(RED, WHITE) "camera: error: illegal camera ID (%d) !! (%d|%d|%d)\n" VT_RST, + requestedBgCamIndex, camera->camId, BGCHECK_SCENE, requestedCamSetting); } - return 0x80000000 | bgCamIndex; + return 0x80000000 | requestedBgCamIndex; } + + //! @note: no return here, but return is unused } Vec3s* Camera_GetInputDir(Vec3s* dst, Camera* camera) { @@ -8292,16 +8355,16 @@ s32 Camera_ChangeDoorCam(Camera* camera, Actor* doorActor, s16 bgCamIndex, f32 a } if (bgCamIndex == -1) { - Camera_ChangeSetting(camera, CAM_SET_DOORC); + Camera_RequestSetting(camera, CAM_SET_DOORC); osSyncPrintf(".... change default door camera (set %d)\n", CAM_SET_DOORC); } else { s32 setting = Camera_GetBgCamSetting(camera, bgCamIndex); - camera->behaviorFlags |= CAM_BEHAVIOR_BG_2; + camera->behaviorFlags |= CAM_BEHAVIOR_BG_PROCESSED; - if (Camera_ChangeSetting(camera, setting) >= 0) { + if (Camera_RequestSetting(camera, setting) >= 0) { camera->bgCamIndex = bgCamIndex; - camera->behaviorFlags |= CAM_BEHAVIOR_BG_1; + camera->behaviorFlags |= CAM_BEHAVIOR_BG_SUCCESS; } osSyncPrintf("....change door camera ID %d (set %d)\n", camera->bgCamIndex, camera->setting); @@ -8410,11 +8473,16 @@ s32 func_8005B198(void) { return D_8011D3AC; } -s16 func_8005B1A4(Camera* camera) { - camera->stateFlags |= CAM_STATE_3; +/** + * Signal to the camera update function through stateFlags that something external has + * finished and is ready for the next camera setting/function + * Different camera update functions will respond differently to this flag being set. + */ +s16 Camera_SetFinishedFlag(Camera* camera) { + camera->stateFlags |= CAM_STATE_EXTERNAL_FINISHED; if ((camera->camId == CAM_ID_MAIN) && (camera->play->activeCamId != CAM_ID_MAIN)) { - GET_ACTIVE_CAM(camera->play)->stateFlags |= CAM_STATE_3; + GET_ACTIVE_CAM(camera->play)->stateFlags |= CAM_STATE_EXTERNAL_FINISHED; return camera->play->activeCamId; } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 4a85639cf1..67a45676c0 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1530,7 +1530,7 @@ s32 CutsceneCmd_UpdateCamEyeSpline(PlayState* play, CutsceneContext* csCtx, u8* csCtx->camEyeSplinePointsAppliedFrame = cmd->startFrame; if (gUseCutsceneCam) { - Play_ChangeCameraSetting(play, csCtx->subCamId, CAM_SET_CS_0); + Play_RequestCameraSetting(play, csCtx->subCamId, CAM_SET_CS_0); Play_ChangeCameraStatus(play, sReturnToCamId, CAM_STAT_WAIT); Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); Camera_ResetAnim(Play_GetCamera(play, csCtx->subCamId)); @@ -1569,7 +1569,7 @@ s32 CutsceneCmd_UpdateCamAtSpline(PlayState* play, CutsceneContext* csCtx, u8* s gCamAtSplinePointsAppliedFrame = cmd->startFrame; if (gUseCutsceneCam) { - Play_ChangeCameraSetting(play, csCtx->subCamId, CAM_SET_CS_0); + Play_RequestCameraSetting(play, csCtx->subCamId, CAM_SET_CS_0); Play_ChangeCameraStatus(play, sReturnToCamId, CAM_STAT_WAIT); Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); Camera_ResetAnim(Play_GetCamera(play, csCtx->subCamId)); @@ -1616,7 +1616,7 @@ s32 CutsceneCmd_SetCamEye(PlayState* play, CutsceneContext* csCtx, u8* script, u Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STAT_WAIT); Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); - Play_ChangeCameraSetting(play, csCtx->subCamId, CAM_SET_FREE0); + Play_RequestCameraSetting(play, csCtx->subCamId, CAM_SET_FREE0); roll = csCtx->camAtPoints->cameraRoll * 1.40625f; Camera_SetViewParam(subCam, CAM_VIEW_ROLL, &roll); @@ -1664,7 +1664,7 @@ s32 CutsceneCmd_SetCamAt(PlayState* play, CutsceneContext* csCtx, u8* script, u8 Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STAT_WAIT); Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); - Play_ChangeCameraSetting(play, csCtx->subCamId, CAM_SET_FREE0); + Play_RequestCameraSetting(play, csCtx->subCamId, CAM_SET_FREE0); at.x = csCtx->camAtPoints->pos.x; at.y = csCtx->camAtPoints->pos.y; @@ -2254,7 +2254,7 @@ void CutsceneHandler_StopScript(PlayState* play, CutsceneContext* csCtx) { Play_ChangeCameraStatus(play, sReturnToCamId, CAM_STAT_ACTIVE); Play_ClearCamera(play, csCtx->subCamId); - func_8005B1A4(play->cameraPtrs[sReturnToCamId]); + Camera_SetFinishedFlag(play->cameraPtrs[sReturnToCamId]); } Audio_SetCutsceneFlag(0); diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 6fffcaf973..996a334d79 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1703,7 +1703,7 @@ void Environment_DrawRain(PlayState* play, View* view, GraphicsContext* gfxCtx) Vec3f windDirection = { 0.0f, 0.0f, 0.0f }; Player* player = GET_PLAYER(play); - if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_8) && + if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_CAMERA_IN_WATER) && (play->envCtx.precipitation[PRECIP_SNOW_CUR] == 0)) { OPEN_DISPS(gfxCtx, "../z_kankyo.c", 2799); diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 65c5b5d69f..3a6586ecc8 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -318,7 +318,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act spD0.pitch = 0x3E8; OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); subCam->roll = 0; @@ -344,22 +344,22 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 1010: - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &childCam->at, &childCam->eye); Play_SetCameraFov(play, subCamId, childCam->fov); Play_SetCameraRoll(play, subCamId, childCam->roll); break; case 9601: // Leaving a crawlspace forwards - Play_ChangeCameraSetting(play, subCamId, CAM_SET_CS_3); - Play_ChangeCameraSetting(play, CAM_ID_MAIN, mainCam->prevSetting); + Play_RequestCameraSetting(play, subCamId, CAM_SET_CS_3); + Play_RequestCameraSetting(play, CAM_ID_MAIN, mainCam->prevSetting); OnePointCutscene_SetCsCamPoints(subCam, sCrawlspaceActionParam | 0x1000, sCrawlspaceTimer, sCrawlspaceAtPoints, sCrawlspaceForwardsEyePoints); break; case 9602: // Leaving a crawlspace backwards - Play_ChangeCameraSetting(play, subCamId, CAM_SET_CS_3); - Play_ChangeCameraSetting(play, CAM_ID_MAIN, mainCam->prevSetting); + Play_RequestCameraSetting(play, subCamId, CAM_SET_CS_3); + Play_RequestCameraSetting(play, CAM_ID_MAIN, mainCam->prevSetting); OnePointCutscene_SetCsCamPoints(subCam, sCrawlspaceActionParam | 0x1000, sCrawlspaceTimer, sCrawlspaceAtPoints, sCrawlspaceBackwardsEyePoints); break; @@ -378,7 +378,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act spB4.x = -1979.0f; spB4.y = 703.0f; spB4.z = -269.0f; - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 6; subCam->fov = 75.0f; @@ -486,7 +486,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3050: - Play_ChangeCameraSetting(play, subCamId, CAM_SET_CS_3); + Play_RequestCameraSetting(play, subCamId, CAM_SET_CS_3); Player_SetCsActionWithHaltedActors(play, &player->actor, PLAYER_CSACTION_5); OnePointCutscene_SetCsCamPoints(subCam, D_80120304 | 0x2000, D_80120300, D_8012013C, D_8012021C); Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME); @@ -514,7 +514,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act case 3120: csInfo->keyFrames = D_80121954[-(timer + 101)]; subCam->timer = 100; - subCam->stateFlags |= CAM_STATE_1; + subCam->stateFlags |= CAM_STATE_CHECK_WATER; csInfo->keyFrameCount = ARRAY_COUNT(D_80121954[0]); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); @@ -527,7 +527,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C); - subCam->stateFlags |= CAM_STATE_1; + subCam->stateFlags |= CAM_STATE_CHECK_WATER; break; case 3140: @@ -548,7 +548,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act spB4.x = 1729.0f; spB4.y = 995.0f; spB4.z = -1405.0f; - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0x50; subCam->fov = 55.0f; @@ -564,7 +564,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act Actor_GetWorld(&spA0, &player->actor); spD0.yaw = OnePointCutscene_Vec3fYaw(&spC0, &spA0.pos) - 0x7D0; OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); Play_CopyCamera(play, CAM_ID_MAIN, subCamId); subCam->roll = -1; @@ -579,7 +579,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act spD0.yaw = spA0.rot.y; spD0.r = 150.0f; OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->fov = 55.0f; @@ -594,7 +594,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act spD0.yaw = spA0.rot.y; spD0.pitch = -0xAF0; OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->fov = 60.0f; @@ -602,8 +602,8 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3190: - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FOREST_DEFEAT_POE); - Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FOREST_DEFEAT_POE); + Camera_RequestMode(mainCam, CAM_MODE_NORMAL); Player_SetCsAction(play, actor, PLAYER_CSACTION_12); break; @@ -614,7 +614,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act spB4.x = 80.0f; spB4.y = 445.0f; spB4.z = -1425.0f; - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0x1E; subCam->fov = 75.0f; @@ -644,7 +644,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act spD0.yaw = spA0.rot.y + 0x7FFF; spD0.r = 300.0f; OnePointCutscene_AddVecGeoToVec3f(&spB4, &spC0, &spD0); - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); Play_SetCameraAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->fov = 45.0f; @@ -679,7 +679,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 6001: - Play_ChangeCameraSetting(play, subCamId, CAM_SET_CS_3); + Play_RequestCameraSetting(play, subCamId, CAM_SET_CS_3); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); Actor_GetWorld(&spA0, actor); if (spA0.pos.z > -750.0f) { @@ -695,7 +695,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3400: - Play_ChangeCameraSetting(play, subCamId, CAM_SET_CS_3); + Play_RequestCameraSetting(play, subCamId, CAM_SET_CS_3); Player_SetCsAction(play, &player->actor, PLAYER_CSACTION_8); OnePointCutscene_SetCsCamPoints(subCam, D_8012069C | 0x2000, D_80120698, D_801204D4, D_801205B4); OnePointCutscene_Vec3sToVec3f(&mainCam->eye, &D_801205B4[D_80120694 - 2].pos); @@ -718,7 +718,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act break; case 3310: - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FIRE_STAIRCASE); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FIRE_STAIRCASE); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); Play_CopyCamera(play, subCamId, CAM_ID_MAIN); @@ -884,7 +884,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act csInfo->keyFrameCount = ARRAY_COUNT(D_801227B4); Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C); - Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); + Camera_RequestMode(mainCam, CAM_MODE_NORMAL); break; case 4150: @@ -892,7 +892,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act csInfo->keyFrameCount = ARRAY_COUNT(D_801228A4); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); - Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); + Camera_RequestMode(mainCam, CAM_MODE_NORMAL); Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C); break; @@ -901,7 +901,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act csInfo->keyFrameCount = ARRAY_COUNT(D_8012296C); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); - Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); + Camera_RequestMode(mainCam, CAM_MODE_NORMAL); Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C); break; @@ -910,7 +910,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act csInfo->keyFrameCount = ARRAY_COUNT(D_80122A0C); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); - Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); + Camera_RequestMode(mainCam, CAM_MODE_NORMAL); Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C); break; @@ -919,7 +919,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act csInfo->keyFrameCount = ARRAY_COUNT(D_80122A5C); Player_SetCsAction(play, &player->actor, PLAYER_CSACTION_8); - Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); + Camera_RequestMode(mainCam, CAM_MODE_NORMAL); Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C); break; @@ -928,7 +928,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act csInfo->keyFrameCount = ARRAY_COUNT(D_80122B9C); Player_SetCsAction(play, &player->actor, PLAYER_CSACTION_8); - Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); + Camera_RequestMode(mainCam, CAM_MODE_NORMAL); Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C); break; @@ -1041,7 +1041,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act subCam->data2 = 0xC; } else { Play_CopyCamera(play, subCamId, CAM_ID_MAIN); - Play_ChangeCameraSetting(play, subCamId, CAM_SET_FREE2); + Play_RequestCameraSetting(play, subCamId, CAM_SET_FREE2); } break; @@ -1358,7 +1358,7 @@ s32 OnePointCutscene_Attention(PlayState* play, Actor* actor) { parentCam = play->cameraPtrs[CAM_ID_MAIN]; if (parentCam->mode == CAM_MODE_FOLLOW_BOOMERANG) { osSyncPrintf(VT_COL(YELLOW, BLACK) "actor attention demo camera: change mode BOOKEEPON -> NORMAL\n" VT_RST); - Camera_ChangeMode(parentCam, CAM_MODE_NORMAL); + Camera_RequestMode(parentCam, CAM_MODE_NORMAL); } // Finds the camera of the first actor attention demo with a lower category actor, or the first non-attention demo diff --git a/src/code/z_play.c b/src/code/z_play.c index b71a60564b..101be010db 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -25,8 +25,8 @@ void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn); } \ } while (0) -void Play_ChangeViewpointBgCamIndex(PlayState* this) { - Camera_ChangeBgCamIndex(GET_ACTIVE_CAM(this), this->viewpoint - 1); +void Play_RequestViewpointBgCam(PlayState* this) { + Camera_RequestBgCam(GET_ACTIVE_CAM(this), this->viewpoint - 1); } void Play_SetViewpoint(PlayState* this, s16 viewpoint) { @@ -42,7 +42,7 @@ void Play_SetViewpoint(PlayState* this, s16 viewpoint) { &gSfxDefaultReverb); } - Play_ChangeViewpointBgCamIndex(this); + Play_RequestViewpointBgCam(this); } /** @@ -255,8 +255,9 @@ void Play_Init(GameState* thisx) { this->cameraPtrs[CAM_ID_MAIN] = &this->mainCamera; this->cameraPtrs[CAM_ID_MAIN]->uid = 0; this->activeCamId = CAM_ID_MAIN; - Camera_OverwriteStateFlags(&this->mainCamera, CAM_STATE_0 | CAM_STATE_1 | CAM_STATE_2 | CAM_STATE_3 | CAM_STATE_4 | - CAM_STATE_5 | CAM_STATE_6 | CAM_STATE_7); + Camera_OverwriteStateFlags(&this->mainCamera, CAM_STATE_CHECK_BG_ALT | CAM_STATE_CHECK_WATER | CAM_STATE_CHECK_BG | + CAM_STATE_EXTERNAL_FINISHED | CAM_STATE_CAM_FUNC_FINISH | + CAM_STATE_LOCK_MODE | CAM_STATE_DISTORTION | CAM_STATE_PLAY_INIT); Sram_Init(this, &this->sramCtx); Regs_InitData(this); Message_Init(this); @@ -412,12 +413,12 @@ void Play_Init(GameState* thisx) { player = GET_PLAYER(this); Camera_InitDataUsingPlayer(&this->mainCamera, player); - Camera_ChangeMode(&this->mainCamera, CAM_MODE_NORMAL); + Camera_RequestMode(&this->mainCamera, CAM_MODE_NORMAL); playerStartBgCamIndex = player->actor.params & 0xFF; if (playerStartBgCamIndex != 0xFF) { osSyncPrintf("player has start camera ID (" VT_FGCOL(BLUE) "%d" VT_RST ")\n", playerStartBgCamIndex); - Camera_ChangeBgCamIndex(&this->mainCamera, playerStartBgCamIndex); + Camera_RequestBgCam(&this->mainCamera, playerStartBgCamIndex); } if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT) { @@ -943,7 +944,7 @@ void Play_Update(PlayState* this) { } } - Play_ChangeViewpointBgCamIndex(this); + Play_RequestViewpointBgCam(this); } PLAY_LOG(3708); @@ -1643,11 +1644,11 @@ s32 Play_InitCameraDataUsingPlayer(PlayState* this, s16 camId, Player* player, s camera = this->cameraPtrs[camIdx]; Camera_InitDataUsingPlayer(camera, player); - return Camera_ChangeSetting(camera, setting); + return Camera_RequestSetting(camera, setting); } -s32 Play_ChangeCameraSetting(PlayState* this, s16 camId, s16 setting) { - return Camera_ChangeSetting(Play_GetCamera(this, camId), setting); +s32 Play_RequestCameraSetting(PlayState* this, s16 camId, s16 setting) { + return Camera_RequestSetting(Play_GetCamera(this, camId), setting); } /** diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 6c12331d56..c694221d88 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -626,7 +626,7 @@ void func_8008EEAC(PlayState* play, Actor* actor) { this->unk_684 = actor; this->stateFlags1 |= PLAYER_STATE1_16; Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, actor); - Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_TARGET_FRIENDLY); + Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_TARGET_FRIENDLY); } s32 func_8008EF30(PlayState* play) { diff --git a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c index b7e09c1b8e..11f5fd85fd 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c +++ b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.c @@ -241,7 +241,7 @@ void func_8086C29C(BgBdanObjects* this, PlayState* play) { BgBdanObjects_SetContactRu1(this, 4); this->timer = 10; this->actionFunc = func_8086C55C; - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); } } @@ -354,12 +354,12 @@ void func_8086C874(BgBdanObjects* this, PlayState* play) { if (this->switchFlag == 0) { if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { this->cameraSetting = play->cameraPtrs[CAM_ID_MAIN]->setting; - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_NORMAL2); - Camera_UnsetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_2); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_NORMAL2); + Camera_UnsetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_CHECK_BG); this->switchFlag = 10; } } else { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_NORMAL2); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_NORMAL2); if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->switchFlag != 0) { this->switchFlag--; @@ -367,8 +367,8 @@ void func_8086C874(BgBdanObjects* this, PlayState* play) { } if (this->switchFlag == 0) { if (1) {} - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], this->cameraSetting); - Camera_SetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_2); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], this->cameraSetting); + Camera_SetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_CHECK_BG); } } this->dyna.actor.world.pos.y = diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index e180a135cd..8995016e17 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -501,7 +501,7 @@ void BgDyYoseizo_SayFarewell_NoReward(BgDyYoseizo* this, PlayState* play) { Message_CloseTextbox(play); this->mouthState = 0; this->actionFunc = BgDyYoseizo_SetupSpinShrink; - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); } BgDyYoseizo_Bob(this, play); diff --git a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c index ea606ec2ab..0f87eabf8a 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Fslift/z_bg_hidan_fslift.c @@ -129,10 +129,10 @@ void BgHidanFslift_Update(Actor* thisx, PlayState* play) { if (this->unk_16A == 0) { this->unk_16A = 3; } - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); } else if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->unk_16A != 0) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } this->unk_16A = 0; } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c index 0d06eadff4..9ea5b85636 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c @@ -264,10 +264,10 @@ void func_8088B79C(BgHidanRock* this, PlayState* play) { if (this->unk_169 == 0) { this->unk_169 = 3; } - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); } else if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->unk_169 != 0) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } this->unk_169 = 0; } @@ -317,10 +317,10 @@ void func_8088B990(BgHidanRock* this, PlayState* play) { if (this->unk_169 == 0) { this->unk_169 = 3; } - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); } else if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->unk_169 != 0) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } this->unk_169 = 0; } diff --git a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c index 2992773fae..e69cca84aa 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Syoku/z_bg_hidan_syoku.c @@ -112,10 +112,10 @@ void BgHidanSyoku_Update(Actor* thisx, PlayState* play) { if (this->unk_168 == 0) { this->unk_168 = 3; } - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); } else if (!DynaPolyActor_IsPlayerOnTop(&this->dyna)) { if (this->unk_168 != 0) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } this->unk_168 = 0; } diff --git a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c index 32fc953c7a..b56effd8c9 100644 --- a/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c +++ b/src/overlays/actors/ovl_Bg_Jya_1flift/z_bg_jya_1flift.c @@ -189,9 +189,9 @@ void BgJya1flift_Update(Actor* thisx, PlayState* play2) { tempIsRiding = DynaPolyActor_IsPlayerOnTop(&this->dyna) ? true : false; if ((this->actionFunc == BgJya1flift_Move) || (this->actionFunc == BgJya1flift_DelayMove)) { if (tempIsRiding) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_ELEVATOR_PLATFORM); } else if (!tempIsRiding && this->isLinkRiding) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } } this->isLinkRiding = tempIsRiding; diff --git a/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c b/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c index ec5af7b350..a6aa9612fa 100644 --- a/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c +++ b/src/overlays/actors/ovl_Bg_Jya_Lift/z_bg_jya_lift.c @@ -113,7 +113,7 @@ void BgJyaLift_Move(BgJyaLift* this, PlayState* play) { tempVelocity = (this->dyna.actor.velocity.y < 0.2f) ? 0.2f : this->dyna.actor.velocity.y; distFromBottom = Math_SmoothStepToF(&this->dyna.actor.world.pos.y, 973.0f, 0.1f, tempVelocity, 0.2f); if ((this->dyna.actor.world.pos.y < 1440.0f) && (1440.0f <= this->dyna.actor.prevPos.y)) { - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); } if (fabsf(distFromBottom) < 0.001f) { BgJyaLift_SetFinalPosY(this); @@ -136,11 +136,11 @@ void BgJyaLift_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); } if ((this->dyna.interactFlags & DYNA_INTERACT_PLAYER_ABOVE) && !(this->unk_16B & DYNA_INTERACT_PLAYER_ABOVE)) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DIRECTED_YAW); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DIRECTED_YAW); } else if (!(this->dyna.interactFlags & DYNA_INTERACT_PLAYER_ABOVE) && (this->unk_16B & DYNA_INTERACT_PLAYER_ABOVE) && (play->cameraPtrs[CAM_ID_MAIN]->setting == CAM_SET_DIRECTED_YAW)) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } this->unk_16B = this->dyna.interactFlags; diff --git a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c index 609ff25a9b..573376faf5 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c +++ b/src/overlays/actors/ovl_Bg_Mori_Hineri/z_bg_mori_hineri.c @@ -169,7 +169,7 @@ void func_808A3C8C(BgMoriHineri* this, PlayState* play) { f0 = 1100.0f - (player->actor.world.pos.z - this->dyna.actor.world.pos.z); this->dyna.actor.shape.rot.z = CLAMP(f0, 0.0f, 1000.0f) * 16.384f; - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON1); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON1); if (this->dyna.actor.params != 0) { this->dyna.actor.shape.rot.z = -this->dyna.actor.shape.rot.z; } diff --git a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c index b76181daca..4d2a706fe4 100644 --- a/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c +++ b/src/overlays/actors/ovl_Bg_Mori_Rakkatenjo/z_bg_mori_rakkatenjo.c @@ -210,11 +210,11 @@ void BgMoriRakkatenjo_Update(Actor* thisx, PlayState* play) { osSyncPrintf("camera changed (mori rakka tenjyo) ... \n"); sCamSetting = play->cameraPtrs[CAM_ID_MAIN]->setting; Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], 1, &this->dyna.actor, NULL, 0, 0, 0); - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_FOREST_BIRDS_EYE); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_FOREST_BIRDS_EYE); } } else if (sCamSetting != CAM_SET_NONE) { osSyncPrintf("camera changed (previous) ... \n"); - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON1); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON1); sCamSetting = CAM_SET_NONE; } } diff --git a/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c b/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c index 10dfbeca03..10caf7c29f 100644 --- a/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c +++ b/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c @@ -61,9 +61,9 @@ void BgSstFloor_Update(Actor* thisx, PlayState* play) { if (1) {} if (DynaPolyActor_IsPlayerAbove(&this->dyna) && (this->dyna.actor.yDistToPlayer < 1000.0f)) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BOSS_BONGO); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BOSS_BONGO); } else { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); } if (DynaPolyActor_IsPlayerOnTop(&this->dyna) && (player->fallDistance > 1000.0f)) { diff --git a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c index 19e521a872..f3ac29088e 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -640,8 +640,8 @@ void func_809BE26C(EnBigokuta* this, PlayState* play) { } if (this->unk_198 == 0 && Math_StepToF(&this->actor.scale.y, 0.0f, 0.001f)) { Flags_SetClear(play, this->actor.room); - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); - Camera_SetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_2); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); + Camera_SetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_CHECK_BG); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_OCTAROCK_BUBLE); Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); Actor_Kill(&this->actor); @@ -777,8 +777,8 @@ void EnBigokuta_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); func_809BD2E4(this); func_809BE568(this); - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BIG_OCTO); - Camera_UnsetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_2); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BIG_OCTO); + Camera_UnsetStateFlag(play->cameraPtrs[CAM_ID_MAIN], CAM_STATE_CHECK_BG); if (this->cylinder[0].base.atFlags & AT_ON) { if (this->actionFunc != func_809BE058) { diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c index b222a86692..6cbbd90c56 100644 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c +++ b/src/overlays/actors/ovl_En_Bom_Bowl_Man/z_en_bom_bowl_man.c @@ -449,7 +449,7 @@ void EnBomBowlMan_BeginPlayGame(EnBomBowlMan* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == this->dialogState) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); this->startedPlaying = true; if (BREG(2)) { diff --git a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c index bde6fb5733..54f9a8491f 100644 --- a/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c +++ b/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c @@ -251,7 +251,7 @@ void EnDntJiji_Talk(EnDntJiji* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x1388, 0); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); Message_CloseTextbox(play); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_7); this->actor.parent = NULL; diff --git a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c index 93170b1d83..19be858d96 100644 --- a/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c +++ b/src/overlays/actors/ovl_En_Dnt_Nomal/z_en_dnt_nomal.c @@ -337,7 +337,7 @@ void EnDntNomal_TargetTalk(EnDntNomal* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) { Message_CloseTextbox(play); - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); GET_ACTIVE_CAM(play)->csId = 0; Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_8); this->actionFunc = EnDntNomal_SetupTargetGivePrize; diff --git a/src/overlays/actors/ovl_En_Du/z_en_du.c b/src/overlays/actors/ovl_En_Du/z_en_du.c index 8c80e10a05..ddb77031b9 100644 --- a/src/overlays/actors/ovl_En_Du/z_en_du.c +++ b/src/overlays/actors/ovl_En_Du/z_en_du.c @@ -384,7 +384,7 @@ void func_809FE6CC(EnDu* this, PlayState* play) { void func_809FE740(EnDu* this, PlayState* play) { if (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) { - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); this->unk_1E2 = 0x5A; EnDu_SetupAction(this, func_809FE798); } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 756a61a482..3f8cfc0d8e 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -429,13 +429,13 @@ s32 EnGo_IsCameraModified(EnGo* this, PlayState* play) { xyzDistSq = (this->actor.scale.x / 0.01f) * SQ(100.0f); if ((this->actor.params & 0xF0) == 0x90) { - Camera_ChangeSetting(mainCam, CAM_SET_DIRECTED_YAW); + Camera_RequestSetting(mainCam, CAM_SET_DIRECTED_YAW); xyzDistSq *= 4.8f; } if (fabsf(this->actor.xyzDistToPlayerSq) > xyzDistSq) { if (mainCam->setting == CAM_SET_DIRECTED_YAW) { - Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); + Camera_RequestSetting(mainCam, CAM_SET_NORMAL0); } return 0; } else { diff --git a/src/overlays/actors/ovl_En_Go2/z_en_go2.c b/src/overlays/actors/ovl_En_Go2/z_en_go2.c index 025b47e322..3fd71314db 100644 --- a/src/overlays/actors/ovl_En_Go2/z_en_go2.c +++ b/src/overlays/actors/ovl_En_Go2/z_en_go2.c @@ -1163,11 +1163,11 @@ s32 EnGo2_IsCameraModified(EnGo2* this, PlayState* play) { if ((this->actor.params & 0x1F) == GORON_DMT_BIGGORON) { if (EnGo2_IsWakingUp(this)) { - Camera_ChangeSetting(mainCam, CAM_SET_DIRECTED_YAW); - Camera_UnsetStateFlag(mainCam, CAM_STATE_2); + Camera_RequestSetting(mainCam, CAM_SET_DIRECTED_YAW); + Camera_UnsetStateFlag(mainCam, CAM_STATE_CHECK_BG); } else if (!EnGo2_IsWakingUp(this) && (mainCam->setting == CAM_SET_DIRECTED_YAW)) { - Camera_ChangeSetting(mainCam, CAM_SET_DUNGEON1); - Camera_SetStateFlag(mainCam, CAM_STATE_2); + Camera_RequestSetting(mainCam, CAM_SET_DUNGEON1); + Camera_SetStateFlag(mainCam, CAM_STATE_CHECK_BG); } } @@ -1839,7 +1839,7 @@ void EnGo2_BiggoronEyedrops(EnGo2* this, PlayState* play) { case 1: if (DECR(this->animTimer)) { if (this->animTimer == 60 || this->animTimer == 120) { - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); func_800F4524(&gSfxDefaultPos, NA_SE_EV_GORON_WATER_DROP, 60); } } else { diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 093348198c..cec62e8357 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -1747,7 +1747,7 @@ void EnHorse_Inactive(EnHorse* this, PlayState* play2) { // Focus the camera on Epona Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], 4, NULL, NULL, 0x51, 0, 0); } } @@ -1821,7 +1821,7 @@ void EnHorse_Idle(EnHorse* this, PlayState* play) { this->followTimer = 0; EnHorse_SetFollowAnimation(this, play); Camera_SetViewParam(play->cameraPtrs[CAM_ID_MAIN], CAM_VIEW_TARGET, &this->actor); - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_TURN_AROUND); Camera_SetCameraData(play->cameraPtrs[CAM_ID_MAIN], 4, NULL, NULL, 0x51, 0, 0); } } else { diff --git a/src/overlays/actors/ovl_En_Jj/z_en_jj.c b/src/overlays/actors/ovl_En_Jj/z_en_jj.c index 383dd7fa5d..5411cab0db 100644 --- a/src/overlays/actors/ovl_En_Jj/z_en_jj.c +++ b/src/overlays/actors/ovl_En_Jj/z_en_jj.c @@ -218,7 +218,7 @@ void EnJj_BeginCutscene(EnJj* this, PlayState* play) { play->csCtx.script = D_80A88164; gSaveContext.cutsceneTrigger = 1; DynaPoly_DisableCollision(play, &play->colCtx.dyna, bodyCollisionActor->bgId); - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); SET_EVENTCHKINF(EVENTCHKINF_3A); Sfx_PlaySfxCentered(NA_SE_SY_CORRECT_CHIME); } diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 9b4e6a50f1..9a4c646b8f 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -264,7 +264,7 @@ void func_80A8F9C8(EnKakasi* this, PlayState* play) { if (this->unk_196 == Message_GetState(&play->msgCtx) && Message_ShouldAdvance(play)) { if (this->subCamId != CAM_ID_NONE) { - func_8005B1A4(play->cameraPtrs[this->subCamId]); + Camera_SetFinishedFlag(play->cameraPtrs[this->subCamId]); } this->subCamId = OnePointCutscene_Init(play, 2270, -99, &this->actor, CAM_ID_MAIN); play->msgCtx.msgMode = MSGMODE_PAUSED; @@ -296,7 +296,7 @@ void func_80A8FAA4(EnKakasi* this, PlayState* play) { OnePointCutscene_EndCutscene(play, this->subCamId); this->subCamId = CAM_ID_NONE; this->subCamId = OnePointCutscene_Init(play, 2260, -99, &this->actor, CAM_ID_MAIN); - func_8005B1A4(play->cameraPtrs[this->subCamId]); + Camera_SetFinishedFlag(play->cameraPtrs[this->subCamId]); } } @@ -305,7 +305,7 @@ void func_80A8FBB8(EnKakasi* this, PlayState* play) { SkelAnime_Update(&this->skelanime); if (this->unk_196 == Message_GetState(&play->msgCtx) && Message_ShouldAdvance(play)) { - func_8005B1A4(play->cameraPtrs[this->subCamId]); + Camera_SetFinishedFlag(play->cameraPtrs[this->subCamId]); Message_CloseTextbox(play); Player_SetCsActionWithHaltedActors(play, NULL, PLAYER_CSACTION_7); this->actionFunc = func_80A8F660; diff --git a/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c b/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c index fc566a094e..182a6d6298 100644 --- a/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c +++ b/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c @@ -286,7 +286,7 @@ void func_80A91620(EnKakasi3* this, PlayState* play) { this->subCamId = CAM_ID_NONE; } if (this->subCamId != CAM_ID_NONE) { - func_8005B1A4(play->cameraPtrs[this->subCamId]); + Camera_SetFinishedFlag(play->cameraPtrs[this->subCamId]); } this->actionFunc = func_80A911F0; return; @@ -394,7 +394,7 @@ void func_80A91A90(EnKakasi3* this, PlayState* play) { this->subCamId = CAM_ID_NONE; } if (this->subCamId != CAM_ID_NONE) { - func_8005B1A4(play->cameraPtrs[this->subCamId]); + Camera_SetFinishedFlag(play->cameraPtrs[this->subCamId]); } Message_CloseTextbox(play); play->msgCtx.ocarinaMode = OCARINA_MODE_04; diff --git a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c index 7116afda90..283b51c8c1 100644 --- a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c +++ b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c @@ -677,7 +677,7 @@ void func_80AF39DC(EnRu2* this, PlayState* play) { player = GET_PLAYER(play); // "uorya-!" (screeming sound) osSyncPrintf("うおりゃー! \n"); - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); player->actor.world.pos.x = 820.0f; player->actor.world.pos.y = 0.0f; player->actor.world.pos.z = 180.0f; @@ -688,7 +688,7 @@ void func_80AF39DC(EnRu2* this, PlayState* play) { this->unk_2C3 = dialogState; if (Message_GetState(msgCtx) == TEXT_STATE_CLOSING) { this->action = 18; - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); } } diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 74c5aaced5..35ff4b9c4d 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -2088,7 +2088,7 @@ void func_80B582C8(EnZl3* this, PlayState* play) { *unk_3CC += 1.0f; func_80B57858(play); } else if (*unk_3CC == kREG(17) + 40.0f) { - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); *unk_3CC += 1.0f; } else if (*unk_3CC >= ((kREG(17) + 40.0f) + 1.0f)) { this->action = 32; @@ -2153,7 +2153,7 @@ void func_80B58624(EnZl3* this, PlayState* play) { } else { if (*unk_3CC >= kREG(20) + 30.0f) { this->action = 28; - func_8005B1A4(GET_ACTIVE_CAM(play)); + Camera_SetFinishedFlag(GET_ACTIVE_CAM(play)); func_80B54E14(this, &gZelda2Anime2Anim_009FBC, 0, -12.0f, 0); *unk_3CC = 0.0f; } else { diff --git a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c index d68c4f89cc..66a4a41431 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -181,7 +181,7 @@ static AnimationInfo sAnimationInfo[] = { void EnZl4_SetActiveCamDir(PlayState* play, s16 index) { Camera* activeCam = GET_ACTIVE_CAM(play); - Camera_ChangeSetting(activeCam, CAM_SET_FREE0); + Camera_RequestSetting(activeCam, CAM_SET_FREE0); activeCam->at = sCamDirections[index].at; activeCam->eye = activeCam->eyeNext = sCamDirections[index].eye; activeCam->roll = sCamDirections[index].roll; @@ -192,7 +192,7 @@ void EnZl4_SetActiveCamMove(PlayState* play, s16 index) { Camera* activeCam = GET_ACTIVE_CAM(play); Player* player = GET_PLAYER(play); - Camera_ChangeSetting(activeCam, CAM_SET_CS_0); + Camera_RequestSetting(activeCam, CAM_SET_CS_0); Camera_ResetAnim(activeCam); Camera_SetCSParams(activeCam, sCamMove[index].atPoints, sCamMove[index].eyePoints, player, sCamMove[index].relativeToPlayer); @@ -1111,7 +1111,7 @@ s32 EnZl4_CsMakePlan(EnZl4* this, PlayState* play) { if (!((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play))) { break; } else { - Camera_ChangeSetting(GET_ACTIVE_CAM(play), CAM_SET_NORMAL0); + Camera_RequestSetting(GET_ACTIVE_CAM(play), CAM_SET_NORMAL0); this->talkState = 7; play->talkWithPlayer(play, &this->actor); Actor_OfferGetItem(&this->actor, play, GI_ZELDAS_LETTER, fabsf(this->actor.xzDistToPlayer) + 1.0f, diff --git a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c index 2c60dcb95e..4eea2768ef 100644 --- a/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c +++ b/src/overlays/actors/ovl_Obj_Bean/z_obj_bean.c @@ -753,9 +753,9 @@ void ObjBean_WaitForPlayer(ObjBean* this, PlayState* play) { if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { ObjBean_SetupFly(this); if (play->sceneId == SCENE_LOST_WOODS) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_LOST_WOODS); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_LOST_WOODS); } else { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_GENERIC); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_GENERIC); } } ObjBean_UpdatePosition(this); @@ -781,7 +781,7 @@ void ObjBean_Fly(ObjBean* this, PlayState* play) { mainCam = play->cameraPtrs[CAM_ID_MAIN]; if ((mainCam->setting == CAM_SET_BEAN_LOST_WOODS) || (mainCam->setting == CAM_SET_BEAN_GENERIC)) { - Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); + Camera_RequestSetting(mainCam, CAM_SET_NORMAL0); } } else if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) { @@ -789,15 +789,15 @@ void ObjBean_Fly(ObjBean* this, PlayState* play) { func_8002F974(&this->dyna.actor, NA_SE_PL_PLANT_MOVE - SFX_FLAG); if (play->sceneId == SCENE_LOST_WOODS) { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_LOST_WOODS); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_LOST_WOODS); } else { - Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_GENERIC); + Camera_RequestSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_BEAN_GENERIC); } } else if (this->stateFlags & BEAN_STATE_PLAYER_ON_TOP) { mainCam = play->cameraPtrs[CAM_ID_MAIN]; if ((mainCam->setting == CAM_SET_BEAN_LOST_WOODS) || (mainCam->setting == CAM_SET_BEAN_GENERIC)) { - Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); + Camera_RequestSetting(mainCam, CAM_SET_NORMAL0); } } diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 24cf975e70..315868f7bf 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -501,7 +501,7 @@ void ObjectKankyo_DrawFairies(Actor* thisx, PlayState* play2) { Vec3f vec2 = { 0.0f, 0.0f, 0.0f }; s16 i; - if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_8)) { + if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_CAMERA_IN_WATER)) { OPEN_DISPS(play->state.gfxCtx, "../z_object_kankyo.c", 807); POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, SETUPDL_20); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gSun1Tex)); @@ -596,7 +596,7 @@ void ObjectKankyo_DrawSnow(Actor* thisx, PlayState* play2) { s32 pad; s32 pad2; - if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_8)) { + if (!(play->cameraPtrs[CAM_ID_MAIN]->stateFlags & CAM_STATE_CAMERA_IN_WATER)) { OPEN_DISPS(play->state.gfxCtx, "../z_object_kankyo.c", 958); if (play->envCtx.precipitation[PRECIP_SNOW_CUR] < play->envCtx.precipitation[PRECIP_SNOW_MAX]) { if (play->state.frames % 16 == 0) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 5c9ce6a2c4..9740e56601 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -1694,7 +1694,7 @@ void func_80832440(PlayState* play, Player* this) { this->unk_6AD = 0; func_80832340(play, this); - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); this->stateFlags1 &= ~(PLAYER_STATE1_13 | PLAYER_STATE1_14 | PLAYER_STATE1_20 | PLAYER_STATE1_21); this->stateFlags2 &= ~(PLAYER_STATE2_4 | PLAYER_STATE2_7 | PLAYER_STATE2_CRAWLING); @@ -3184,7 +3184,7 @@ void func_80835E44(PlayState* play, s16 camSetting) { Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_NOTHING_ALT); } } else { - Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), camSetting); + Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), camSetting); } } @@ -4588,7 +4588,7 @@ void func_80838F5C(PlayState* play, Player* this) { this->stateFlags1 |= PLAYER_STATE1_29 | PLAYER_STATE1_31; - Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_FREE0); + Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_FREE0); } s32 func_80838FB8(PlayState* play, Player* this) { @@ -5368,23 +5368,23 @@ void func_8083AA10(Player* this, PlayState* play) { } s32 func_8083AD4C(PlayState* play, Player* this) { - s32 cameraMode; + s32 camMode; if (this->unk_6AD == 2) { if (func_8002DD6C(this)) { if (LINK_IS_ADULT) { - cameraMode = CAM_MODE_AIM_ADULT; + camMode = CAM_MODE_AIM_ADULT; } else { - cameraMode = CAM_MODE_AIM_CHILD; + camMode = CAM_MODE_AIM_CHILD; } } else { - cameraMode = CAM_MODE_AIM_BOOMERANG; + camMode = CAM_MODE_AIM_BOOMERANG; } } else { - cameraMode = CAM_MODE_FIRST_PERSON; + camMode = CAM_MODE_FIRST_PERSON; } - return Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), cameraMode); + return Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), camMode); } /** @@ -5615,7 +5615,7 @@ s32 Player_ActionChange_13(Player* this, PlayState* play) { Camera_SetViewParam(Play_GetCamera(play, CAM_ID_MAIN), CAM_VIEW_TARGET, this->unk_6A8); } } - } else if (func_8083AD4C(play, this)) { + } else if (func_8083AD4C(play, this) != CAM_MODE_NORMAL) { if (!(this->stateFlags1 & PLAYER_STATE1_23)) { Player_SetupAction(play, this, Player_Action_8084B1D8, 1); this->av2.actionVar2 = 13; @@ -6770,7 +6770,7 @@ s32 Player_ActionChange_2(Player* this, PlayState* play) { ANIM_FLAG_PLAYER_2 | ANIM_FLAG_PLAYER_SETMOVE | ANIM_FLAG_PLAYER_7); chest->unk_1F4 = 1; - Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SLOW_CHEST_CS); + Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SLOW_CHEST_CS); } else { Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_box_kick); chest->unk_1F4 = -1; @@ -8256,7 +8256,7 @@ void Player_Action_8084279C(Player* this, PlayState* play) { } this->actor.flags &= ~ACTOR_FLAG_8; - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); } } @@ -9515,10 +9515,11 @@ void Player_Action_80845CA4(Player* this, PlayState* play) { temp = func_80845BA0(play, this, &sp34, sp30); - if ((this->av2.actionVar2 == 0) || ((temp == 0) && (this->speedXZ == 0.0f) && - (Play_GetCamera(play, CAM_ID_MAIN)->stateFlags & CAM_STATE_4))) { + if ((this->av2.actionVar2 == 0) || + ((temp == 0) && (this->speedXZ == 0.0f) && + (Play_GetCamera(play, CAM_ID_MAIN)->stateFlags & CAM_STATE_CAM_FUNC_FINISH))) { - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); func_80845C68(play, gSaveContext.respawn[RESPAWN_MODE_DOWN].data); if (!Player_ActionChange_4(this, play)) { @@ -9552,7 +9553,7 @@ void Player_Action_80845EF8(Player* this, PlayState* play) { if (play->roomCtx.prevRoom.num >= 0) { func_80097534(play, &play->roomCtx); } - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); Play_SetupRespawnPoint(play, RESPAWN_MODE_DOWN, 0xDFF); } return; @@ -10592,7 +10593,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { seqMode = SEQ_MODE_DEFAULT; if (this->csAction != PLAYER_CSACTION_NONE) { - Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_NORMAL); + Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_NORMAL); } else if (!(this->stateFlags1 & PLAYER_STATE1_20)) { if ((this->actor.parent != NULL) && (this->stateFlags3 & PLAYER_STATE3_7)) { camMode = CAM_MODE_HOOKSHOT_FLY; @@ -10653,7 +10654,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { } } - Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), camMode); + Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), camMode); } else { // First person mode seqMode = SEQ_MODE_STILL; @@ -11701,7 +11702,7 @@ void Player_Action_8084B1D8(Player* this, PlayState* play) { } if ((this->csAction != PLAYER_CSACTION_NONE) || (this->unk_6AD == 0) || (this->unk_6AD >= 4) || - func_80833B54(this) || (this->unk_664 != NULL) || !func_8083AD4C(play, this) || + func_80833B54(this) || (this->unk_664 != NULL) || (func_8083AD4C(play, this) == CAM_MODE_NORMAL) || (((this->unk_6AD == 2) && (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_R) || func_80833B2C(this) || (!func_8002DD78(this) && !func_808334B4(this)))) || ((this->unk_6AD == 1) && @@ -11767,7 +11768,7 @@ void Player_Action_8084B530(Player* this, PlayState* play) { this->stateFlags2 &= ~PLAYER_STATE2_13; } - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); if (!func_8084B4D4(play, this) && !func_8084B3CC(play, this) && !Player_StartCsAction(play, this)) { if ((this->targetActor != this->interactRangeActor) || !Player_ActionChange_2(this, play)) { @@ -12553,7 +12554,7 @@ void Player_Action_8084CC98(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_20) { - if (!func_8083AD4C(play, this) || CHECK_BTN_ANY(sControlInput->press.button, BTN_A) || + if ((func_8083AD4C(play, this) == CAM_MODE_NORMAL) || CHECK_BTN_ANY(sControlInput->press.button, BTN_A) || func_80833BCC(this)) { this->unk_6AD = 0; this->stateFlags1 &= ~PLAYER_STATE1_20; @@ -12613,7 +12614,7 @@ void Player_Action_8084D3E4(Player* this, PlayState* play) { gSaveContext.save.info.horseData.angle = rideActor->actor.shape.rot.y; } } else { - Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_NORMAL0); + Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_NORMAL0); if (this->mountSide < 0) { D_808549C4[0].data = ANIMSFX_DATA(ANIMSFX_TYPE_5, 40); @@ -12864,7 +12865,7 @@ void func_8084DF6C(PlayState* play, Player* this) { this->unk_862 = 0; this->stateFlags1 &= ~(PLAYER_STATE1_10 | PLAYER_STATE1_11); this->getItemId = GI_NONE; - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); } void func_8084DFAC(PlayState* play, Player* this) { @@ -12992,7 +12993,7 @@ void Player_Action_8084E3C4(Player* this, PlayState* play) { } if (play->msgCtx.ocarinaMode == OCARINA_MODE_04) { - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); if ((this->targetActor != NULL) && (this->targetActor == this->unk_6A8)) { func_80853148(play, this->targetActor); @@ -13015,7 +13016,7 @@ void Player_Action_8084E3C4(Player* this, PlayState* play) { this->stateFlags1 &= ~PLAYER_STATE1_29; Player_TryCsAction(play, NULL, PLAYER_CSACTION_8); - play->mainCamera.stateFlags &= ~CAM_STATE_3; + play->mainCamera.stateFlags &= ~CAM_STATE_EXTERNAL_FINISHED; this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; this->stateFlags2 |= PLAYER_STATE2_27; @@ -13203,7 +13204,7 @@ void Player_Action_8084EAC0(Player* this, PlayState* play) { } func_8083C0E8(this, play); - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); } else if (this->av2.actionVar2 == 1) { if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { Player_AnimChangeOnceMorphAdjusted(play, this, &gPlayerAnim_link_bottle_drink_demo_end); @@ -13240,7 +13241,7 @@ void Player_Action_8084ECA4(Player* this, PlayState* play) { this->av2.actionVar2 = 1; } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->av1.actionVar1 = 0; - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); } } else { func_8083C0E8(this, play); @@ -13293,7 +13294,7 @@ static Vec3f D_80854A1C = { 0.0f, 0.0f, 5.0f }; void Player_Action_8084EED8(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_8083C0E8(this, play); - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); return; } @@ -13323,7 +13324,7 @@ void Player_Action_8084EFC0(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_8083C0E8(this, play); - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); return; } @@ -13387,7 +13388,7 @@ void Player_Action_8084F104(Player* this, PlayState* play) { func_8083C0E8(this, play); } - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); } } } else if (this->av2.actionVar2 >= 0) { @@ -13635,7 +13636,7 @@ s32 func_8084FCAC(Player* this, PlayState* play) { D_808535D0 ^= 1; if (D_808535D0) { - Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_AIM); + Camera_RequestMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_Z_AIM); } } @@ -13888,7 +13889,7 @@ void Player_Action_8085063C(Player* this, PlayState* play) { } func_80853080(this, play); - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); } } @@ -13954,7 +13955,7 @@ void Player_Action_808507F4(Player* this, PlayState* play) { if (this->av1.actionVar1 < 0) { if ((this->itemAction == PLAYER_IA_NAYRUS_LOVE) || (gSaveContext.magicState == MAGIC_STATE_IDLE)) { func_80839FFC(this, play); - func_8005B1A4(Play_GetCamera(play, CAM_ID_MAIN)); + Camera_SetFinishedFlag(Play_GetCamera(play, CAM_ID_MAIN)); } } else { if (this->av2.actionVar2 == 0) {