1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 15:04:31 +00:00

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 <Dragorn421@users.noreply.github.com>

* Update include/z64camera.h

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

* Better comments

* PR Suggestions

* rm numbers

* Update src/code/z_play.c

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>

Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
engineer124 2022-06-20 20:31:53 -04:00 committed by GitHub
parent 6d52684020
commit d88a23f4a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 105 additions and 60 deletions

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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;

View file

@ -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:

View file

@ -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);

View file

@ -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 {

View file

@ -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) {

View file

@ -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) {

View file

@ -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)) {