From d88a23f4a0dc543327e9712407b486a54cd0d101 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Mon, 20 Jun 2022 20:31:53 -0400 Subject: [PATCH] Document Viewpoints and Scene Cam Types (#1285) * Document bgCamData * More changes and cleanup * More docs * Clarify comments * PR Feedback, rename bgcheck functions * remove fallthrough cleanup (other pr that deals with that) * PR Suggestions * bug report * bgCamDataIndexBeforeUnderwater * PR/Discord Discussions * Missed some * sync function header args * Another suggestion * cleanup * Comments * Indoor BgCamData * Change bgCamData to s16 for now * PR suggestions * the * use "info" * Missed a suggestion * Update and sync docs * More docs * Even more docs * Revert macro * Add comment * Better comments * More cleanup * Better Cam Scene Docs * Small change * Market -> Pivot * "only" * swap * Better comment * Another comment * to * Implement suggestions from discord * Discord Discussion * Revert bgCamFuncData to Vec3s * cleanup * Remaining cleanup * docs cleanup * format * More docs * Improve notes * Cleanup * Change enum * PR Suggestions * Improve comment * Rephrase * Implement discussion from discord * Discord discussion * fixed to locked * Update comments * Few more comments * Update include/z64.h Co-authored-by: Dragorn421 * Update include/z64camera.h Co-authored-by: Dragorn421 * Better comments * PR Suggestions * rm numbers * Update src/code/z_play.c Co-authored-by: Dragorn421 Co-authored-by: Dragorn421 --- include/functions.h | 8 +-- include/regs.h | 1 + include/z64.h | 2 +- include/z64camera.h | 13 ++++ include/z64scene.h | 14 +++- src/code/z_actor.c | 2 +- src/code/z_bgcheck.c | 4 +- src/code/z_construct.c | 2 +- src/code/z_demo.c | 2 +- src/code/z_kankyo.c | 6 +- src/code/z_message_PAL.c | 8 +-- src/code/z_onepointdemo.c | 4 +- src/code/z_play.c | 70 +++++++++++-------- src/code/z_scene.c | 2 +- .../actors/ovl_Demo_Kankyo/z_demo_kankyo.c | 2 +- src/overlays/actors/ovl_En_Elf/z_en_elf.c | 8 ++- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 10 +-- .../actors/ovl_Oceff_Spot/z_oceff_spot.c | 2 +- .../actors/ovl_player_actor/z_player.c | 5 +- 19 files changed, 105 insertions(+), 60 deletions(-) diff --git a/include/functions.h b/include/functions.h index 2b61d165ee..ac80d98fc2 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1475,9 +1475,9 @@ void KaleidoScopeCall_Init(PlayState* play); void KaleidoScopeCall_Destroy(PlayState* play); void KaleidoScopeCall_Update(PlayState* play); void KaleidoScopeCall_Draw(PlayState* play); -void func_800BC490(PlayState* this, s16 point); -s32 func_800BC56C(PlayState* this, s16 arg1); -void func_800BC590(PlayState* this); +void Play_SetViewpoint(PlayState* this, s16 viewpoint); +s32 Play_CheckViewpoint(PlayState* this, s16 viewpoint); +void Play_SetShopBrowsingViewpoint(PlayState* this); Gfx* Play_SetFog(PlayState* this, Gfx* gfx); void Play_Destroy(GameState* thisx); void Play_Init(GameState* thisx); @@ -1504,7 +1504,7 @@ void Play_SaveSceneFlags(PlayState* this); void Play_SetupRespawnPoint(PlayState* this, s32 respawnMode, s32 playerParams); void Play_TriggerVoidOut(PlayState* this); void Play_TriggerRespawn(PlayState* this); -s32 func_800C0CB8(PlayState* this); +s32 Play_CamIsNotFixed(PlayState* this); s32 FrameAdvance_IsEnabled(PlayState* this); s32 func_800C0D34(PlayState* this, Actor* actor, s16* yaw); s32 func_800C0DB4(PlayState* this, Vec3f* pos); diff --git a/include/regs.h b/include/regs.h index 71c28745b6..18e44794c9 100644 --- a/include/regs.h +++ b/include/regs.h @@ -68,6 +68,7 @@ #define R_DBG_CAM_UPDATE PREG(80) #define R_DBG_REG_UPDATE PREG(82) #define R_RELOAD_CAM_PARAMS QREG(0) +#define R_SCENE_CAM_TYPE YREG(15) #define R_C_UP_ICON_X YREG(88) #define R_C_UP_ICON_Y YREG(89) #define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) diff --git a/include/z64.h b/include/z64.h index 160735c816..423c32392e 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1207,7 +1207,7 @@ typedef struct PlayState { /* 0x1241B */ u8 transitionMode; // "fbdemo_wipe_modem" /* 0x1241C */ TransitionFade transitionFade; /* 0x12428 */ char unk_12428[0x3]; - /* 0x1242B */ u8 unk_1242B; + /* 0x1242B */ u8 viewpoint; // toggleable camera setting by shops or player. Is also equal to the bgCamIndex + 1 /* 0x1242C */ SceneTableEntry* loadedScene; /* 0x12430 */ char unk_12430[0xE8]; } PlayState; // size = 0x12518 diff --git a/include/z64camera.h b/include/z64camera.h index b65965c2ba..944709bf95 100644 --- a/include/z64camera.h +++ b/include/z64camera.h @@ -27,6 +27,19 @@ #define PARENT_CAM(cam) ((cam)->play->cameraPtrs[(cam)->parentCamId]) #define CHILD_CAM(cam) ((cam)->play->cameraPtrs[(cam)->childCamId]) +// All scenes using `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT` or `SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT` are expected +// to have their first two bgCamInfo entries be the following: +#define BGCAM_INDEX_TOGGLE_LOCKED 0 +#define BGCAM_INDEX_TOGGLE_PIVOT 1 + +// Viewpoint is only used by `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT` and `SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT` +// Value must be 1 greater than the corresponding bgCamIndex. +#define VIEWPOINT_NONE 0 +// Use a camera prerend setting that locks the camera in place +#define VIEWPOINT_LOCKED (BGCAM_INDEX_TOGGLE_LOCKED + 1) +// Use a camera pivot setting that allows camera rotation (CAM_SET_PIVOT_SHOP_BROWSING for shop specifically) +#define VIEWPOINT_PIVOT (BGCAM_INDEX_TOGGLE_PIVOT + 1) + typedef enum { /* 0x00 */ CAM_SET_NONE, /* 0x01 */ CAM_SET_NORMAL0, diff --git a/include/z64scene.h b/include/z64scene.h index 8260639a67..7bb1348ea3 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -328,7 +328,7 @@ typedef struct { typedef struct { /* 0x00 */ u8 code; - /* 0x01 */ u8 cameraMovement; + /* 0x01 */ u8 sceneCamType; /* 0x04 */ u32 area; } SCmdMiscSettings; @@ -453,6 +453,14 @@ typedef enum { /* 53 */ SDC_MAX } SceneDrawConfig; +// R_SCENE_CAM_TYPE values +#define SCENE_CAM_TYPE_DEFAULT 0 +#define SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT 0x10 // Camera exhibits fixed behaviors and viewpoint changing is handled by shops +#define SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT 0x20 // Camera exhibits fixed behaviors and viewpoint can be toggled with c-up +#define SCENE_CAM_TYPE_FIXED 0x30 // Camera exhibits fixed behaviors (see `Play_CamIsNotFixed` usages for examples) +#define SCENE_CAM_TYPE_FIXED_MARKET 0x40 // Camera exhibits fixed behaviors and delays textboxes by a small amount before they start to appear +#define SCENE_CAM_TYPE_SHOOTING_GALLERY 0x50 // Unreferenced in code, and set only by the main setup of the shooting gallery scene + // Scene commands typedef enum { @@ -561,8 +569,8 @@ typedef enum { #define SCENE_CMD_ALTERNATE_HEADER_LIST(alternateHeaderList) \ { SCENE_CMD_ID_ALTERNATE_HEADER_LIST, 0, CMD_PTR(alternateHeaderList) } -#define SCENE_CMD_MISC_SETTINGS(camMode, worldMapLocation) \ - { SCENE_CMD_ID_MISC_SETTINGS, camMode, CMD_W(worldMapLocation) } +#define SCENE_CMD_MISC_SETTINGS(sceneCamType, worldMapLocation) \ + { SCENE_CMD_ID_MISC_SETTINGS, sceneCamType, CMD_W(worldMapLocation) } #endif diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 3d9798665e..9811758e43 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1008,7 +1008,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) && func_800C0CB8(play)) { + if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && Play_CamIsNotFixed(play)) { Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_HORSE); } } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 6f1b53e0e2..e875ccc3b7 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1511,7 +1511,9 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader // "/*---------------- BGCheck Buffer Memory Size -------------*/\n" osSyncPrintf("/*---------------- BGCheck バッファーメモリサイズ -------------*/\n"); - if (YREG(15) == 0x10 || YREG(15) == 0x20 || YREG(15) == 0x30 || YREG(15) == 0x40) { + if ((R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) || + (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT) || (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED) || + (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_MARKET)) { if (play->sceneNum == SCENE_MALON_STABLE) { // "/* BGCheck LonLon Size %dbyte */\n" osSyncPrintf("/* BGCheck LonLonサイズ %dbyte */\n", 0x3520); diff --git a/src/code/z_construct.c b/src/code/z_construct.c index 17a6477455..1b2e2706af 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -194,7 +194,7 @@ void Message_Init(PlayState* play) { void func_80111070(void) { YREG(8) = 10; YREG(14) = 0; - YREG(15) = 0; + R_SCENE_CAM_TYPE = SCENE_CAM_TYPE_DEFAULT; R_TEXTBOX_TEXWIDTH = 0; R_TEXTBOX_TEXHEIGHT = 0; R_TEXTBOX_WIDTH = 50; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 33cc69b971..82973eb119 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -302,7 +302,7 @@ void func_80064824(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { break; case 14: if (sp3F != 0) { - func_800BC490(play, 1); + Play_SetViewpoint(play, VIEWPOINT_LOCKED); } break; case 15: diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 6ea7970b97..f10cb2aa73 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -2222,7 +2222,7 @@ void Environment_FadeInGameOverLights(PlayState* play) { sGameOverLightsIntensity += 2; } - if (func_800C0CB8(play)) { + if (Play_CamIsNotFixed(play)) { for (i = 0; i < 3; i++) { if (play->envCtx.adjAmbientColor[i] > -255) { play->envCtx.adjAmbientColor[i] -= 12; @@ -2269,7 +2269,7 @@ void Environment_FadeOutGameOverLights(PlayState* play) { sGameOverLightsIntensity, sGameOverLightsIntensity, sGameOverLightsIntensity, 255); } - if (func_800C0CB8(play)) { + if (Play_CamIsNotFixed(play)) { for (i = 0; i < 3; i++) { Math_SmoothStepToS(&play->envCtx.adjAmbientColor[i], 0, 5, 12, 1); Math_SmoothStepToS(&play->envCtx.adjLight1Color[i], 0, 5, 12, 1); @@ -2489,7 +2489,7 @@ void Environment_AdjustLights(PlayState* play, f32 arg1, f32 arg2, f32 arg3, f32 f32 temp; s32 i; - if (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_5 && func_800C0CB8(play)) { + if (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_5 && Play_CamIsNotFixed(play)) { arg1 = CLAMP_MIN(arg1, 0.0f); arg1 = CLAMP_MAX(arg1, 1.0f); diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.c index 14c7cedb24..668fb61200 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.c @@ -1590,7 +1590,7 @@ void Message_OpenText(PlayState* play, u16 textId) { if (msgCtx->msgMode == MSGMODE_NONE) { gSaveContext.unk_13EE = gSaveContext.unk_13EA; } - if (YREG(15) == 0x10) { + if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) { Interface_ChangeAlpha(5); } @@ -3095,11 +3095,11 @@ void Message_Update(PlayState* play) { D_8014B2F4++; var = false; - if (YREG(15) == 0x40) { + if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_MARKET) { if (D_8014B2F4 >= 4) { var = true; } - } else if (YREG(15) != 0 || play->sceneNum == SCENE_HAIRAL_NIWA) { + } else if (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_DEFAULT || play->sceneNum == SCENE_HAIRAL_NIWA) { var = true; } else if (D_8014B2F4 >= 4 || msgCtx->talkActor == NULL) { var = true; @@ -3125,7 +3125,7 @@ void Message_Update(PlayState* play) { var = msgCtx->textBoxType; if (!msgCtx->textBoxPos) { // variable position - if (YREG(15) != 0 || play->sceneNum == SCENE_HAIRAL_NIWA) { + if (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_DEFAULT || play->sceneNum == SCENE_HAIRAL_NIWA) { if (averageY < XREG(92)) { R_TEXTBOX_Y_TARGET = sTextboxMidYPositions[var]; } else { diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 832caf2541..0f61caee18 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -954,7 +954,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act } break; case 9806: subCam->timer = -99; - if (func_800C0CB8(play)) { + if (Play_CamIsNotFixed(play)) { func_800C0808(play, subCamId, player, CAM_SET_TURN_AROUND); subCam->data2 = 0xC; } else { @@ -963,7 +963,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act } break; case 9908: - if (func_800C0CB8(play)) { + if (Play_CamIsNotFixed(play)) { D_801231B4[0].eyeTargetInit.z = D_801231B4[1].eyeTargetInit.z = !LINK_IS_ADULT ? 100.0f : 120.0f; if (player->stateFlags1 & PLAYER_STATE1_27) { diff --git a/src/code/z_play.c b/src/code/z_play.c index 1804cecc36..afe53a0e4e 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -15,33 +15,42 @@ u64 D_801614D0[0xA00]; void Play_SpawnScene(PlayState* this, s32 sceneNum, s32 spawn); -void func_800BC450(PlayState* this) { - Camera_ChangeBgCamIndex(GET_ACTIVE_CAM(this), this->unk_1242B - 1); +void Play_ChangeViewpointBgCamIndex(PlayState* this) { + Camera_ChangeBgCamIndex(GET_ACTIVE_CAM(this), this->viewpoint - 1); } -void func_800BC490(PlayState* this, s16 point) { - ASSERT(point == 1 || point == 2, "point == 1 || point == 2", "../z_play.c", 2160); +void Play_SetViewpoint(PlayState* this, s16 viewpoint) { + ASSERT(viewpoint == VIEWPOINT_LOCKED || viewpoint == VIEWPOINT_PIVOT, "point == 1 || point == 2", "../z_play.c", + 2160); - this->unk_1242B = point; + this->viewpoint = viewpoint; - if ((YREG(15) != 0x10) && (gSaveContext.cutsceneIndex < 0xFFF0)) { - Audio_PlaySoundGeneral((point == 1) ? NA_SE_SY_CAMERA_ZOOM_DOWN : NA_SE_SY_CAMERA_ZOOM_UP, &gSfxDefaultPos, 4, - &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + if ((R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) && (gSaveContext.cutsceneIndex < 0xFFF0)) { + // Play a sfx when the player toggles the camera + Audio_PlaySoundGeneral((viewpoint == VIEWPOINT_LOCKED) ? NA_SE_SY_CAMERA_ZOOM_DOWN : NA_SE_SY_CAMERA_ZOOM_UP, + &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultReverb); } - func_800BC450(this); + Play_ChangeViewpointBgCamIndex(this); } -s32 func_800BC56C(PlayState* this, s16 arg1) { - return (arg1 == this->unk_1242B); +/** + * @return true if the currently set viewpoint is the same as the one provided in the argument + */ +s32 Play_CheckViewpoint(PlayState* this, s16 viewpoint) { + return (viewpoint == this->viewpoint); } -// original name: "Game_play_shop_pr_vr_switch_set" -void func_800BC590(PlayState* this) { +/** + * If the scene is a shop, set the viewpoint that will set the bgCamIndex + * to toggle the camera into a "browsing item selection" setting. + */ +void Play_SetShopBrowsingViewpoint(PlayState* this) { osSyncPrintf("Game_play_shop_pr_vr_switch_set()\n"); - if (YREG(15) == 0x10) { - this->unk_1242B = 2; + if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) { + this->viewpoint = VIEWPOINT_PIVOT; } } @@ -394,12 +403,12 @@ void Play_Init(GameState* thisx) { Camera_ChangeBgCamIndex(&this->mainCamera, playerStartBgCamIndex); } - if (YREG(15) == 32) { - this->unk_1242B = 2; - } else if (YREG(15) == 16) { - this->unk_1242B = 1; + if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT) { + this->viewpoint = VIEWPOINT_PIVOT; + } else if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) { + this->viewpoint = VIEWPOINT_LOCKED; } else { - this->unk_1242B = 0; + this->viewpoint = VIEWPOINT_NONE; } Interface_SetSceneRestrictions(this); @@ -943,7 +952,7 @@ void Play_Update(PlayState* this) { LOG_NUM("1", 1, "../z_play.c", 3677); } - if (this->unk_1242B != 0) { + if (this->viewpoint != VIEWPOINT_NONE) { if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) { if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { // "Changing viewpoint is prohibited due to the kaleidoscope" @@ -951,14 +960,16 @@ void Play_Update(PlayState* this) { } else if (Player_InCsMode(this)) { // "Changing viewpoint is prohibited during the cutscene" osSyncPrintf(VT_FGCOL(CYAN) "デモ中につき視点変更を禁止しております\n" VT_RST); - } else if (YREG(15) == 0x10) { + } else if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } else { - func_800BC490(this, this->unk_1242B ^ 3); + // C-Up toggle for houses, move between pivot camera and fixed camera + // Toggle viewpoint between VIEWPOINT_LOCKED and VIEWPOINT_PIVOT + Play_SetViewpoint(this, this->viewpoint ^ (VIEWPOINT_LOCKED ^ VIEWPOINT_PIVOT)); } } - func_800BC450(this); + Play_ChangeViewpointBgCamIndex(this); } if (1 && HREG(63)) { @@ -1488,7 +1499,7 @@ void Play_InitScene(PlayState* this, s32 spawn) { LightContext_Init(this, &this->lightCtx); TransitionActor_InitContext(&this->state, &this->transiActorCtx); func_80096FD4(this, &this->roomCtx.curRoom); - YREG(15) = 0; + R_SCENE_CAM_TYPE = SCENE_CAM_TYPE_DEFAULT; gSaveContext.worldMapArea = 0; Scene_ExecuteCommands(this, this->sceneSegment); Play_InitEnvironment(this, this->skyboxId); @@ -1807,9 +1818,12 @@ void Play_TriggerRespawn(PlayState* this) { Play_LoadToLastEntrance(this); } -s32 func_800C0CB8(PlayState* this) { - return (this->roomCtx.curRoom.meshHeader->base.type != MESH_HEADER_TYPE_1) && (YREG(15) != 0x20) && - (YREG(15) != 0x30) && (YREG(15) != 0x40) && (this->sceneNum != SCENE_HAIRAL_NIWA); +s32 Play_CamIsNotFixed(PlayState* this) { + // SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT was probably intended to be in this condition, + // but the scene mesh header handles all shop cases regardless + return (this->roomCtx.curRoom.meshHeader->base.type != MESH_HEADER_TYPE_1) && + (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT) && (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED) && + (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_MARKET) && (this->sceneNum != SCENE_HAIRAL_NIWA); } s32 FrameAdvance_IsEnabled(PlayState* this) { diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 7bc15dd23f..1e82f2d5d7 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -447,7 +447,7 @@ void Scene_CommandCutsceneData(PlayState* play, SceneCmd* cmd) { // Camera & World Map Area void Scene_CommandMiscSettings(PlayState* play, SceneCmd* cmd) { - YREG(15) = cmd->miscSettings.cameraMovement; + R_SCENE_CAM_TYPE = cmd->miscSettings.sceneCamType; gSaveContext.worldMapArea = cmd->miscSettings.area; if ((play->sceneNum == SCENE_SHOP1) || (play->sceneNum == SCENE_SYATEKIJYOU)) { diff --git a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c index 00d28aa1c6..c8e9933986 100644 --- a/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c +++ b/src/overlays/actors/ovl_Demo_Kankyo/z_demo_kankyo.c @@ -333,7 +333,7 @@ void DemoKankyo_SetupType(DemoKankyo* this, PlayState* play) { play->csCtx.segment = gAdultWarpInCS; } } - if (func_800C0CB8(play) != 0) { + if (Play_CamIsNotFixed(play)) { gSaveContext.cutsceneTrigger = 1; } DemoKankyo_SetupAction(this, DemoKankyo_DoNothing); diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index ada3c07758..6a3f175fcf 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1083,7 +1083,13 @@ void func_80A0461C(EnElf* this, PlayState* play) { } else { arrowPointedActor = play->actorCtx.targetCtx.arrowPointedActor; - if ((player->stateFlags1 & PLAYER_STATE1_10) || ((YREG(15) & 0x10) && func_800BC56C(play, 2))) { + // `R_SCENE_CAM_TYPE` is not a bit field, but this conditional checks for a specific bit. + // This `& 0x10` check will pass for either `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT`, `SCENE_CAM_TYPE_FIXED`, or + // `SCENE_CAM_TYPE_SHOOTING_GALLERY`. + // However, of these three, only `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT` is used with `VIEWPOINT_PIVOT`, + // so here the bit check is equivalent to checking for `SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT`. + if ((player->stateFlags1 & PLAYER_STATE1_10) || + ((R_SCENE_CAM_TYPE & 0x10) && Play_CheckViewpoint(play, VIEWPOINT_PIVOT))) { temp = 12; this->unk_2C0 = 100; } else if (arrowPointedActor == NULL || arrowPointedActor->category == ACTORCAT_NPC) { diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index 54f8af944a..d7fc9bb700 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -653,7 +653,7 @@ void EnOssan_EndInteraction(PlayState* play, EnOssan* this) { play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~PLAYER_STATE2_29; - func_800BC490(play, 1); + Play_SetViewpoint(play, VIEWPOINT_LOCKED); Interface_ChangeAlpha(50); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; @@ -737,7 +737,7 @@ void EnOssan_State_Idle(EnOssan* this, PlayState* play, Player* player) { // "Start conversation!!" osSyncPrintf(VT_FGCOL(YELLOW) "★★★ 会話開始!! ★★★" VT_RST "\n"); player->stateFlags2 |= PLAYER_STATE2_29; - func_800BC590(play); + Play_SetShopBrowsingViewpoint(play); EnOssan_SetStateStartShopping(play, this, false); } else if (this->actor.xzDistToPlayer < 100.0f) { func_8002F2CC(&this->actor, play, 100); @@ -1322,7 +1322,7 @@ void EnOssan_GiveItemWithFanfare(PlayState* play, EnOssan* this) { play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; play->msgCtx.stateTimer = 4; player->stateFlags2 &= ~PLAYER_STATE2_29; - func_800BC490(play, 1); + Play_SetViewpoint(play, VIEWPOINT_LOCKED); Interface_ChangeAlpha(50); this->drawCursor = 0; EnOssan_UpdateCameraDirection(this, play, 0.0f); @@ -1696,7 +1696,7 @@ void EnOssan_State_ContinueShoppingPrompt(EnOssan* this, PlayState* play, Player osSyncPrintf(VT_FGCOL(YELLOW) "★★★ 続けるよ!! ★★★" VT_RST "\n"); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= PLAYER_STATE2_29; - func_800BC490(play, 2); + Play_SetViewpoint(play, VIEWPOINT_PIVOT); Message_StartTextbox(play, this->actor.textId, &this->actor); EnOssan_SetStateStartShopping(play, this, true); func_8002F298(&this->actor, play, 100.0f, -1); @@ -1715,7 +1715,7 @@ void EnOssan_State_ContinueShoppingPrompt(EnOssan* this, PlayState* play, Player selectedItem->updateStockedItemFunc(play, selectedItem); player->actor.shape.rot.y += 0x8000; player->stateFlags2 |= PLAYER_STATE2_29; - func_800BC490(play, 2); + Play_SetViewpoint(play, VIEWPOINT_PIVOT); Message_StartTextbox(play, this->actor.textId, &this->actor); EnOssan_SetStateStartShopping(play, this, true); func_8002F298(&this->actor, play, 100.0f, -1); diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index afae0b1102..09ed4dbec6 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -53,7 +53,7 @@ void OceffSpot_Init(Actor* thisx, PlayState* play) { Lights_PointNoGlowSetInfo(&this->lightInfo2, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); this->lightNode2 = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo2); - if (YREG(15)) { + if (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_DEFAULT) { this->actor.scale.y = 2.4f; } else { this->actor.scale.y = 0.3f; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 781b9bc3eb..43e63c392f 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -2830,7 +2830,7 @@ void func_80835DE4(PlayState* play, Player* this, PlayerFunc674 func, s32 flags) } void func_80835E44(PlayState* play, s16 camSetting) { - if (!func_800C0CB8(play)) { + if (!Play_CamIsNotFixed(play)) { if (camSetting == CAM_SET_SCENE_TRANSITION) { Interface_ChangeAlpha(2); } @@ -5144,7 +5144,8 @@ s32 func_8083B998(Player* this, PlayState* play) { (this->unk_664->naviEnemyId != NAVI_ENEMY_NONE))) { this->stateFlags2 |= PLAYER_STATE2_21; } else if ((this->naviTextId == 0) && !func_8008E9C4(this) && CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && - (YREG(15) != 0x10) && (YREG(15) != 0x20) && !func_8083B8F4(this, play)) { + (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) && + (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_FIXED_TOGGLE_VIEWPOINT) && !func_8083B8F4(this, play)) { func_80078884(NA_SE_SY_ERROR); }