From 4d8926d3bd710f7214f52ef4ed09bd8205f3aed0 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Mon, 17 Oct 2022 20:43:21 +0300 Subject: [PATCH] Match and link CScriptCameraBlurKeyframe Former-commit-id: 45aa20e25ebb7958cab68481de08cbda7adedd1a --- asm/MetroidPrime/ScriptLoader.s | 2 +- .../ScriptObjects/CScriptCameraBlurKeyframe.s | 16 ++++---- configure.py | 2 +- include/MetroidPrime/CStateManager.hpp | 4 ++ .../MetroidPrime/Cameras/CCameraBlurPass.hpp | 2 + .../CScriptCameraBlurKeyframe.hpp | 25 ++++++++++++ obj_files.mk | 2 +- .../CScriptCameraBlurKeyframe.cpp | 39 +++++++++++++++++++ 8 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 include/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.hpp create mode 100644 src/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.cpp diff --git a/asm/MetroidPrime/ScriptLoader.s b/asm/MetroidPrime/ScriptLoader.s index 2787f8f8..dd979a71 100644 --- a/asm/MetroidPrime/ScriptLoader.s +++ b/asm/MetroidPrime/ScriptLoader.s @@ -16650,7 +16650,7 @@ lbl_800D4320: /* 800D43C8 000D1328 7F E9 FB 78 */ mr r9, r31 /* 800D43CC 000D132C 38 81 00 0C */ addi r4, r1, 0xc /* 800D43D0 000D1330 38 A1 00 10 */ addi r5, r1, 0x10 -/* 800D43D4 000D1334 48 01 64 CD */ bl "__ct__25CScriptCameraBlurKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoUifUiffb" +/* 800D43D4 000D1334 48 01 64 CD */ bl "__ct__25CScriptCameraBlurKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoQ215CCameraBlurPass9EBlurTypefUlffb" /* 800D43D8 000D1338 7C 7C 1B 78 */ mr r28, r3 lbl_800D43DC: /* 800D43DC 000D133C 38 61 00 10 */ addi r3, r1, 0x10 diff --git a/asm/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.s b/asm/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.s index 6470a24d..ee174122 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803DFCA0 -lbl_803DFCA0: +.global __vt__25CScriptCameraBlurKeyframe +__vt__25CScriptCameraBlurKeyframe: # ROM: 0x3DCCA0 .4byte 0 .4byte 0 @@ -94,9 +94,9 @@ __dt__25CScriptCameraBlurKeyframeFv: /* 800EA854 000E77B4 93 C1 00 08 */ stw r30, 8(r1) /* 800EA858 000E77B8 7C 7E 1B 79 */ or. r30, r3, r3 /* 800EA85C 000E77BC 41 82 00 28 */ beq lbl_800EA884 -/* 800EA860 000E77C0 3C A0 80 3E */ lis r5, lbl_803DFCA0@ha +/* 800EA860 000E77C0 3C A0 80 3E */ lis r5, __vt__25CScriptCameraBlurKeyframe@ha /* 800EA864 000E77C4 38 80 00 00 */ li r4, 0 -/* 800EA868 000E77C8 38 05 FC A0 */ addi r0, r5, lbl_803DFCA0@l +/* 800EA868 000E77C8 38 05 FC A0 */ addi r0, r5, __vt__25CScriptCameraBlurKeyframe@l /* 800EA86C 000E77CC 90 1E 00 00 */ stw r0, 0(r30) /* 800EA870 000E77D0 4B F6 6A 05 */ bl __dt__7CEntityFv /* 800EA874 000E77D4 7F E0 07 35 */ extsh. r0, r31 @@ -112,8 +112,8 @@ lbl_800EA884: /* 800EA898 000E77F8 38 21 00 10 */ addi r1, r1, 0x10 /* 800EA89C 000E77FC 4E 80 00 20 */ blr -.global "__ct__25CScriptCameraBlurKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoUifUiffb" -"__ct__25CScriptCameraBlurKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoUifUiffb": +.global "__ct__25CScriptCameraBlurKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoQ215CCameraBlurPass9EBlurTypefUlffb" +"__ct__25CScriptCameraBlurKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoQ215CCameraBlurPass9EBlurTypefUlffb": /* 800EA8A0 000E7800 94 21 FF C0 */ stwu r1, -0x40(r1) /* 800EA8A4 000E7804 7C 08 02 A6 */ mflr r0 /* 800EA8A8 000E7808 90 01 00 44 */ stw r0, 0x44(r1) @@ -137,9 +137,9 @@ lbl_800EA884: /* 800EA8F0 000E7850 7C 87 23 78 */ mr r7, r4 /* 800EA8F4 000E7854 38 81 00 08 */ addi r4, r1, 8 /* 800EA8F8 000E7858 4B F6 6A 2D */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" -/* 800EA8FC 000E785C 3C 80 80 3E */ lis r4, lbl_803DFCA0@ha +/* 800EA8FC 000E785C 3C 80 80 3E */ lis r4, __vt__25CScriptCameraBlurKeyframe@ha /* 800EA900 000E7860 7F A3 EB 78 */ mr r3, r29 -/* 800EA904 000E7864 38 04 FC A0 */ addi r0, r4, lbl_803DFCA0@l +/* 800EA904 000E7864 38 04 FC A0 */ addi r0, r4, __vt__25CScriptCameraBlurKeyframe@l /* 800EA908 000E7868 90 1D 00 00 */ stw r0, 0(r29) /* 800EA90C 000E786C 93 DD 00 34 */ stw r30, 0x34(r29) /* 800EA910 000E7870 D3 BD 00 38 */ stfs f29, 0x38(r29) diff --git a/configure.py b/configure.py index 74d6d341..22fb33d5 100755 --- a/configure.py +++ b/configure.py @@ -141,7 +141,7 @@ LIBS = [ "MetroidPrime/CMappableObject", "MetroidPrime/Player/CPlayerCameraBob", "MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe", - "MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe", + ["MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe", True], "MetroidPrime/Cameras/CCameraFilter", "MetroidPrime/Player/CMorphBall", "MetroidPrime/ScriptObjects/CScriptDamageableTrigger", diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index c32c08bb..2acf2fc3 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -149,6 +149,10 @@ public: CEnvFxManager* EnvFxManager() { return x880_envFxManager; } const CEnvFxManager* GetEnvFxManager() const { return x880_envFxManager; } CRumbleManager* GetRumbleManager() { return x88c_rumbleManager; } + CCameraFilterPass& CameraFilterPass(int idx) { return xb84_camFilterPasses[idx]; } + const CCameraFilterPass& GetCameraFilterPass(int idx) const { return xb84_camFilterPasses[idx]; } + CCameraBlurPass& CameraBlurPass(int idx) { return xd14_camBlurPasses[idx]; } + const CCameraBlurPass& GetCameraBlurPass(int idx) const { return xd14_camBlurPasses[idx]; } CRandom16* GetActiveRandom() const { return x900_random; } diff --git a/include/MetroidPrime/Cameras/CCameraBlurPass.hpp b/include/MetroidPrime/Cameras/CCameraBlurPass.hpp index f70104df..b79324eb 100644 --- a/include/MetroidPrime/Cameras/CCameraBlurPass.hpp +++ b/include/MetroidPrime/Cameras/CCameraBlurPass.hpp @@ -22,6 +22,8 @@ public: kBT_XRay, }; + void SetBlur(EBlurType type, float amount, float duration, bool usePersistentFb); + void DisableBlur(float duration); static void DrawWideScreen(const CColor& color, const CTexture* tex, float v); private: diff --git a/include/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.hpp b/include/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.hpp new file mode 100644 index 00000000..f3fa52e9 --- /dev/null +++ b/include/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.hpp @@ -0,0 +1,25 @@ +#ifndef _CSCRIPTCAMERABLURKEYFRAME +#define _CSCRIPTCAMERABLURKEYFRAME + +#include "MetroidPrime/CEntity.hpp" + +#include "MetroidPrime/Cameras/CCameraBlurPass.hpp" + +class CScriptCameraBlurKeyframe : public CEntity { + CCameraBlurPass::EBlurType x34_type; + float x38_amount; + u32 x3c_; + float x40_timeIn; + float x44_timeOut; + +public: + CScriptCameraBlurKeyframe(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + CCameraBlurPass::EBlurType type, float amount, u32 unk, float timeIn, + float timeOut, bool active); + ~CScriptCameraBlurKeyframe(); + + void Accept(IVisitor& visitor) override; + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override; +}; + +#endif // _CSCRIPTCAMERABLURKEYFRAME diff --git a/obj_files.mk b/obj_files.mk index 4a694204..d3df1924 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -108,7 +108,7 @@ METROIDPRIME :=\ $(BUILD_DIR)/asm/MetroidPrime/CMappableObject.o\ $(BUILD_DIR)/asm/MetroidPrime/Player/CPlayerCameraBob.o\ $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.o\ - $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.o\ + $(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.o\ $(BUILD_DIR)/asm/MetroidPrime/Cameras/CCameraFilter.o\ $(BUILD_DIR)/asm/MetroidPrime/Player/CMorphBall.o\ $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptDamageableTrigger.o\ diff --git a/src/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.cpp b/src/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.cpp new file mode 100644 index 00000000..13646fbe --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.cpp @@ -0,0 +1,39 @@ +#include "MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.hpp" + +#include "MetroidPrime/CStateManager.hpp" + +CScriptCameraBlurKeyframe::CScriptCameraBlurKeyframe(TUniqueId uid, const rstl::string& name, + const CEntityInfo& info, + CCameraBlurPass::EBlurType type, float amount, + u32 unk, float timeIn, float timeOut, + bool active) +: CEntity(uid, info, active, name) +, x34_type(type) +, x38_amount(amount) +, x3c_(unk) +, x40_timeIn(timeIn) +, x44_timeOut(timeOut) {} + +CScriptCameraBlurKeyframe::~CScriptCameraBlurKeyframe() {} + +void CScriptCameraBlurKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, + CStateManager& stateMgr) { + CEntity::AcceptScriptMsg(msg, objId, stateMgr); + + switch (msg) { + case kSM_Increment: + if (GetActive()) { + stateMgr.CameraBlurPass(3).SetBlur(x34_type, x38_amount, x40_timeIn, false); + } + break; + case kSM_Decrement: + if (GetActive()) { + stateMgr.CameraBlurPass(3).DisableBlur(x44_timeOut); + } + break; + default: + break; + } +} + +void CScriptCameraBlurKeyframe::Accept(IVisitor& visitor) { visitor.Visit(*this); }