From 6cb774232d2a86129266fe0b617410c7a8099916 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Wed, 5 Oct 2022 19:16:14 -0700 Subject: [PATCH] Camera Functions --- include/functions.h | 6 ++-- include/z64player.h | 2 +- include/z64quake.h | 6 ++-- src/code/z_play.c | 52 +++++++++++++++++----------------- src/code/z_quake.c | 6 ++-- tools/disasm/functions.txt | 6 ++-- tools/sizes/code_functions.csv | 6 ++-- 7 files changed, 42 insertions(+), 42 deletions(-) diff --git a/include/functions.h b/include/functions.h index 9c20969d44..bcd669945b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2458,12 +2458,12 @@ Gfx* Play_SetFog(PlayState* this, Gfx* gfx); void Play_Destroy(GameState* thisx); // void func_801663C4(void); // void func_80166644(void); -// void func_801668B4(void); -void func_80166968(PlayState* this, Camera* camera); +// void Play_GetWaterSurface(void); +void Play_UpdateWaterCamera(PlayState* this, Camera* camera); void Play_UpdateTransition(PlayState* this); void Play_Update(PlayState* this); void Play_SetupUpdate(PlayState* this); -// void Play_DrawOverlayElements(void); +// void Play_PostWorldDraw(void); void Play_Draw(PlayState* this); void Play_SetupDraw(PlayState* this); void Play_Main(GameState* thisx); diff --git a/include/z64player.h b/include/z64player.h index 2f101b5588..a90dba4e68 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -426,7 +426,7 @@ typedef struct struct_80122744_arg1 { #define PLAYER_STATE3_2000 (1 << 13) // #define PLAYER_STATE3_4000 (1 << 14) -// +// Swimming Zora #define PLAYER_STATE3_8000 (1 << 15) // #define PLAYER_STATE3_10000 (1 << 16) diff --git a/include/z64quake.h b/include/z64quake.h index a1272941d9..f0bd401fc3 100644 --- a/include/z64quake.h +++ b/include/z64quake.h @@ -47,9 +47,9 @@ s32 Quake_NumActiveQuakes(void); void Quake_Init(void); #define DISTORTION_TYPE_0 (1 << 0) -#define DISTORTION_TYPE_2 (1 << 2) -#define DISTORTION_TYPE_3 (1 << 3) -#define DISTORTION_TYPE_4 (1 << 4) +#define DISTORTION_TYPE_NON_ZORA_SWIMMING (1 << 2) +#define DISTORTION_TYPE_ZORA_SWIMMING (1 << 3) +#define DISTORTION_TYPE_UNDERWATER_ENTRY (1 << 4) #define DISTORTION_TYPE_5 (1 << 5) #define DISTORTION_TYPE_6 (1 << 6) #define DISTORTION_TYPE_7 (1 << 7) diff --git a/src/code/z_play.c b/src/code/z_play.c index 14f445f0ef..71a745b6e7 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -516,45 +516,45 @@ void func_80166644(u8* srcI5, s8* destI8, size_t size) { } } -f32 func_801668B4(PlayState* this, Vec3f* arg1, s32* arg2) { +f32 Play_GetWaterSurface(PlayState* this, Vec3f* pos, s32* lightIndex) { Player* player = GET_PLAYER(this); - f32 sp38 = player->actor.world.pos.y; + f32 waterSurfaceY = player->actor.world.pos.y; WaterBox* waterBox; s32 bgId; - if (!WaterBox_GetSurfaceImpl(this, &this->colCtx, arg1->x, arg1->z, &sp38, &waterBox, &bgId)) { + if (!WaterBox_GetSurfaceImpl(this, &this->colCtx, pos->x, pos->z, &waterSurfaceY, &waterBox, &bgId)) { return BGCHECK_Y_MIN; } - if (sp38 < arg1->y) { + if (waterSurfaceY < pos->y) { return BGCHECK_Y_MIN; } - *arg2 = WaterBox_GetLightSettingIndex(&this->colCtx, waterBox); - return sp38; + *lightIndex = WaterBox_GetLightSettingIndex(&this->colCtx, waterBox); + return waterSurfaceY; } -void func_80166968(PlayState* this, Camera* camera) { +void Play_UpdateWaterCamera(PlayState* this, Camera* camera) { static s16 sQuakeIndex = -1; static s16 sIsCameraUnderwater = false; s32 pad; - s32 sp28; + s32 lightIndex; Player* player = GET_PLAYER(this); sIsCameraUnderwater = camera->stateFlags & CAM_STATE_UNDERWATER; - if (func_801668B4(this, &camera->eye, &sp28) != BGCHECK_Y_MIN) { + if (Play_GetWaterSurface(this, &camera->eye, &lightIndex) != BGCHECK_Y_MIN) { if (!sIsCameraUnderwater) { Camera_SetFlags(camera, CAM_STATE_UNDERWATER); sQuakeIndex = -1; - Distortion_SetType(0x10); + Distortion_SetType(DISTORTION_TYPE_UNDERWATER_ENTRY); Distortion_SetCountdown(80); } func_801A3EC0(0x20); - func_800F6834(this, sp28); + func_800F6834(this, lightIndex); - if ((sQuakeIndex == -1) || (Quake_GetCountdown(sQuakeIndex) == 0xA)) { - s16 quakeIndex = Quake_Add(camera, 5); + if ((sQuakeIndex == -1) || (Quake_GetCountdown(sQuakeIndex) == 10)) { + s16 quakeIndex = Quake_Add(camera, QUAKE_TYPE_5); sQuakeIndex = quakeIndex; if (quakeIndex != 0) { @@ -564,19 +564,19 @@ void func_80166968(PlayState* this, Camera* camera) { } } if (player->stateFlags3 & PLAYER_STATE3_8000) { - Distortion_SetType(8); - Distortion_ClearType(4); + Distortion_SetType(DISTORTION_TYPE_ZORA_SWIMMING); + Distortion_ClearType(DISTORTION_TYPE_NON_ZORA_SWIMMING); } else { - Distortion_SetType(4); - Distortion_ClearType(8); + Distortion_SetType(DISTORTION_TYPE_NON_ZORA_SWIMMING); + Distortion_ClearType(DISTORTION_TYPE_ZORA_SWIMMING); } } else { if (sIsCameraUnderwater) { Camera_ClearFlags(camera, CAM_STATE_UNDERWATER); } - Distortion_ClearType(4); - Distortion_ClearType(0x10); - Distortion_ClearType(8); + Distortion_ClearType(DISTORTION_TYPE_NON_ZORA_SWIMMING); + Distortion_ClearType(DISTORTION_TYPE_UNDERWATER_ENTRY); + Distortion_ClearType(DISTORTION_TYPE_ZORA_SWIMMING); if (sQuakeIndex != 0) { Quake_Remove(sQuakeIndex); } @@ -1050,7 +1050,7 @@ void Play_Update(PlayState* this) { } if (!sp5C) { - func_80166968(this, this->cameraPtrs[this->nextCamera]); + Play_UpdateWaterCamera(this, this->cameraPtrs[this->nextCamera]); Distortion_Update(); } @@ -1097,7 +1097,7 @@ void Play_SetupUpdate(PlayState* this) { } } -void Play_DrawOverlayElements(PlayState* this) { +void Play_PostWorldDraw(PlayState* this) { if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { KaleidoScopeCall_Draw(this); } @@ -1262,7 +1262,7 @@ void Play_Draw(PlayState* this) { TransitionUnk_Draw(&sTrnsnUnk, &sp90); POLY_OPA_DISP = sp90; sp25B = true; - goto Play_Draw_DrawOverlayElements; + goto Play_Draw_PostWorldDraw; } PreRender_SetValues(&this->pauseBgPreRender, D_801FBBCC, D_801FBBCE, gfxCtx->curFrameBuffer, gfxCtx->zbuffer); @@ -1287,7 +1287,7 @@ void Play_Draw(PlayState* this) { gSPDisplayList(sp8C++, D_0E000000.syncSegments); POLY_OPA_DISP = sp8C; sp25B = true; - goto Play_Draw_DrawOverlayElements; + goto Play_Draw_PostWorldDraw; } if (!this->unk_18844) { @@ -1411,8 +1411,8 @@ void Play_Draw(PlayState* this) { this->unk_18B49 = 2; SREG(33) |= 1; } else { - Play_Draw_DrawOverlayElements: - Play_DrawOverlayElements(this); + Play_Draw_PostWorldDraw: + Play_PostWorldDraw(this); } } diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 964935ea1f..49d5c1cde1 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -668,7 +668,7 @@ void Distortion_Update(void) { zScaleFactor = 1.0f; xyScaleFactor = 1.0f; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_4) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_UNDERWATER_ENTRY) { if (sDistortionRequest.state == DISTORTION_SETUP) { countdownMax = sDistortionRequest.countdown; depthPhase = 0x760; @@ -690,7 +690,7 @@ void Distortion_Update(void) { countdownRatio = sDistortionRequest.countdown / (f32)countdownMax; zScaleFactor = xyScaleFactor = countdownRatio; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_3) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_ZORA_SWIMMING) { depthPhase = 0x3F0; screenPlanePhase = 0x156; @@ -745,7 +745,7 @@ void Distortion_Update(void) { } zScaleFactor = -xyScaleFactor; speedScaleFactor = 1.0f; - } else if (sDistortionRequest.type & DISTORTION_TYPE_2) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_NON_ZORA_SWIMMING) { depthPhase = 0x3F0; screenPlanePhase = 0x156; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e124f582e5..e1074e97d6 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2989,12 +2989,12 @@ 0x8016613C:("Play_Destroy",), 0x801663C4:("func_801663C4",), 0x80166644:("func_80166644",), - 0x801668B4:("func_801668B4",), - 0x80166968:("func_80166968",), + 0x801668B4:("Play_GetWaterSurface",), + 0x80166968:("Play_UpdateWaterCamera",), 0x80166B30:("Play_UpdateTransition",), 0x80167814:("Play_Update",), 0x80167DE4:("Play_SetupUpdate",), - 0x80167F0C:("Play_DrawOverlayElements",), + 0x80167F0C:("Play_PostWorldDraw",), 0x80168090:("Play_Draw",), 0x80168DAC:("Play_SetupDraw",), 0x80168F64:("Play_Main",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 3904fde109..42a74e4cce 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2503,12 +2503,12 @@ asm/non_matchings/code/z_play/Play_SetFog.s,Play_SetFog,0x801660B8,0x21 asm/non_matchings/code/z_play/Play_Destroy.s,Play_Destroy,0x8016613C,0xA2 asm/non_matchings/code/z_play/func_801663C4.s,func_801663C4,0x801663C4,0xA0 asm/non_matchings/code/z_play/func_80166644.s,func_80166644,0x80166644,0x9C -asm/non_matchings/code/z_play/func_801668B4.s,func_801668B4,0x801668B4,0x2D -asm/non_matchings/code/z_play/func_80166968.s,func_80166968,0x80166968,0x72 +asm/non_matchings/code/z_play/Play_GetWaterSurface.s,Play_GetWaterSurface,0x801668B4,0x2D +asm/non_matchings/code/z_play/Play_UpdateWaterCamera.s,Play_UpdateWaterCamera,0x80166968,0x72 asm/non_matchings/code/z_play/Play_UpdateTransition.s,Play_UpdateTransition,0x80166B30,0x339 asm/non_matchings/code/z_play/Play_Update.s,Play_Update,0x80167814,0x174 asm/non_matchings/code/z_play/Play_SetupUpdate.s,Play_SetupUpdate,0x80167DE4,0x4A -asm/non_matchings/code/z_play/Play_DrawOverlayElements.s,Play_DrawOverlayElements,0x80167F0C,0x61 +asm/non_matchings/code/z_play/Play_PostWorldDraw.s,Play_PostWorldDraw,0x80167F0C,0x61 asm/non_matchings/code/z_play/Play_Draw.s,Play_Draw,0x80168090,0x347 asm/non_matchings/code/z_play/Play_SetupDraw.s,Play_SetupDraw,0x80168DAC,0x6E asm/non_matchings/code/z_play/Play_Main.s,Play_Main,0x80168F64,0x5A