Decompile/Document bgCam and actorCsCam (combination of Camera/BgCheck/Play) (#932)

* Document bgCam and actorCsCam

* index

* Small PR suggestions

* small suggestions

* player stateflags

* Fix bss

* Fix BSS

* Fix bss

* Fix bss
This commit is contained in:
engineer124
2022-07-23 15:51:14 -04:00
committed by GitHub
parent 6fc12c3a70
commit 04dd8d7b62
13 changed files with 284 additions and 161 deletions
+85 -5
View File
@@ -38,7 +38,22 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB854.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB880.s")
s32 Camera_IsSwimming(Camera* camera) {
Actor* focalActor = camera->focalActor;
if (focalActor == &GET_PLAYER(camera->play)->actor) {
if (((Player*)focalActor)->stateFlags3 & PLAYER_STATE3_8000) {
// Swimming as Zora
return 999;
} else {
// Swimming as Human or Fierce Deity
return ((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_8000000;
}
} else {
// Camera not focused on player
return 0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB8C8.s")
@@ -84,13 +99,78 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC5C8.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC740.s")
#define CAM_DATA_IS_BG (1 << 12) // if not set, then cam data is for actor cutscenes
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC7A8.s")
/**
* Returns the CameraSettingType of the camera from either the bgCam or the actorCsCam at index `camDataId`
*/
s16 Camera_GetBgCamOrActorCsCamSetting(Camera* camera, u32 camDataId) {
if (camDataId & CAM_DATA_IS_BG) {
return BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, camDataId & ~CAM_DATA_IS_BG, BGCHECK_SCENE);
} else {
return Play_GetActorCsCamSetting(camera->play, camDataId);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC804.s")
/**
* Returns either the bgCam data or the actorCsCam data at index `camDataId`
*/
Vec3s* Camera_GetBgCamOrActorCsCamFuncData(Camera* camera, u32 camDataId) {
if (camDataId & CAM_DATA_IS_BG) {
return BgCheck_GetBgCamFuncDataImpl(&camera->play->colCtx, camDataId & ~CAM_DATA_IS_BG, BGCHECK_SCENE);
} else {
return Play_GetActorCsCamFuncData(camera->play, camDataId);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC874.s")
/**
* Gets the bgCam index for the poly `poly`, returns -1 if
* there is no camera data for that poly.
*/
s32 Camera_GetBgCamIndex(Camera* camera, s32* bgId, CollisionPoly* poly) {
s32 bgCamIndex = SurfaceType_GetBgCamIndex(&camera->play->colCtx, poly, *bgId);
s32 ret;
if (BgCheck_GetBgCamSettingImpl(&camera->play->colCtx, bgCamIndex, *bgId) == CAM_SET_NONE) {
ret = -1;
} else {
ret = bgCamIndex;
}
return ret;
}
/**
* Gets the Camera setting for the water box the player is in.
* Returns -1 if the player is not in a water box, or does not have a swimming state.
* Returns -2 if there is no bgCam index for the water box.
* Returns the camera setting otherwise.
*/
s32 Camera_GetWaterBoxBgCamSetting(Camera* camera, f32* waterY) {
PosRot playerPosShape;
WaterBox* waterBox;
s32 camSetting;
s32 bgId;
Actor_GetWorldPosShapeRot(&playerPosShape, camera->focalActor);
*waterY = playerPosShape.pos.y;
if (!WaterBox_GetSurfaceImpl(camera->play, &camera->play->colCtx, playerPosShape.pos.x, playerPosShape.pos.z,
waterY, &waterBox, &bgId)) {
// player's position is not in a waterbox
*waterY = playerPosShape.pos.y;
return -1;
}
if (!Camera_IsSwimming(camera)) {
return -1;
}
camSetting = WaterBox_GetBgCamSetting(&camera->play->colCtx, waterBox, bgId);
// -2: no bgCam index
return (camSetting == CAM_SET_NONE) ? -2 : camSetting;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC938.s")