From 43e6f98e65081f3d78b7e4e3a29a017de49e052d Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Thu, 3 Nov 2022 14:48:51 +0200 Subject: [PATCH] Match and link CScriptCameraFilterKeyframe Former-commit-id: 9e400ca7cd2b0188d2ec03156227692d61a6a636 --- asm/MetroidPrime/ScriptLoader.s | 2 +- .../CScriptCameraFilterKeyframe.s | 16 +++---- configure.py | 2 +- .../CScriptCameraFilterKeyframe.hpp | 33 +++++++++++++ obj_files.mk | 2 +- .../CScriptCameraFilterKeyframe.cpp | 48 +++++++++++++++++++ 6 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 include/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.hpp create mode 100644 src/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.cpp diff --git a/asm/MetroidPrime/ScriptLoader.s b/asm/MetroidPrime/ScriptLoader.s index 318da770..5af92af1 100644 --- a/asm/MetroidPrime/ScriptLoader.s +++ b/asm/MetroidPrime/ScriptLoader.s @@ -16749,7 +16749,7 @@ lbl_800D4444: /* 800D453C 000D149C 7E EA BB 78 */ mr r10, r23 /* 800D4540 000D14A0 38 81 00 14 */ addi r4, r1, 0x14 /* 800D4544 000D14A4 38 A1 00 1C */ addi r5, r1, 0x1c -/* 800D4548 000D14A8 48 01 61 45 */ bl "__ct__27CScriptCameraFilterKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoUiUiUiUiffffffUib" +/* 800D4548 000D14A8 48 01 61 45 */ bl "__ct__27CScriptCameraFilterKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoQ217CCameraFilterPass11EFilterTypeQ217CCameraFilterPass12EFilterShapeQ213CStateManager18ECameraFilterStageUiffffffUib" /* 800D454C 000D14AC 7C 7B 1B 78 */ mr r27, r3 lbl_800D4550: /* 800D4550 000D14B0 38 61 00 1C */ addi r3, r1, 0x1c diff --git a/asm/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.s b/asm/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.s index 7b2cba76..b7d47dea 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803DFC80 -lbl_803DFC80: +.global __vt__27CScriptCameraFilterKeyframe +__vt__27CScriptCameraFilterKeyframe: # ROM: 0x3DCC80 .4byte 0 .4byte 0 @@ -128,9 +128,9 @@ __dt__27CScriptCameraFilterKeyframeFv: /* 800EA640 000E75A0 93 C1 00 08 */ stw r30, 8(r1) /* 800EA644 000E75A4 7C 7E 1B 79 */ or. r30, r3, r3 /* 800EA648 000E75A8 41 82 00 28 */ beq lbl_800EA670 -/* 800EA64C 000E75AC 3C A0 80 3E */ lis r5, lbl_803DFC80@ha +/* 800EA64C 000E75AC 3C A0 80 3E */ lis r5, __vt__27CScriptCameraFilterKeyframe@ha /* 800EA650 000E75B0 38 80 00 00 */ li r4, 0 -/* 800EA654 000E75B4 38 05 FC 80 */ addi r0, r5, lbl_803DFC80@l +/* 800EA654 000E75B4 38 05 FC 80 */ addi r0, r5, __vt__27CScriptCameraFilterKeyframe@l /* 800EA658 000E75B8 90 1E 00 00 */ stw r0, 0(r30) /* 800EA65C 000E75BC 4B F6 6C 19 */ bl __dt__7CEntityFv /* 800EA660 000E75C0 7F E0 07 35 */ extsh. r0, r31 @@ -146,8 +146,8 @@ lbl_800EA670: /* 800EA684 000E75E4 38 21 00 10 */ addi r1, r1, 0x10 /* 800EA688 000E75E8 4E 80 00 20 */ blr -.global "__ct__27CScriptCameraFilterKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoUiUiUiUiffffffUib" -"__ct__27CScriptCameraFilterKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoUiUiUiUiffffffUib": +.global "__ct__27CScriptCameraFilterKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoQ217CCameraFilterPass11EFilterTypeQ217CCameraFilterPass12EFilterShapeQ213CStateManager18ECameraFilterStageUiffffffUib" +"__ct__27CScriptCameraFilterKeyframeF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoQ217CCameraFilterPass11EFilterTypeQ217CCameraFilterPass12EFilterShapeQ213CStateManager18ECameraFilterStageUiffffffUib": /* 800EA68C 000E75EC 94 21 FF A0 */ stwu r1, -0x60(r1) /* 800EA690 000E75F0 7C 08 02 A6 */ mflr r0 /* 800EA694 000E75F4 90 01 00 64 */ stw r0, 0x64(r1) @@ -175,9 +175,9 @@ lbl_800EA670: /* 800EA6EC 000E764C 7D 67 5B 78 */ mr r7, r11 /* 800EA6F0 000E7650 38 81 00 08 */ addi r4, r1, 8 /* 800EA6F4 000E7654 4B F6 6C 31 */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" -/* 800EA6F8 000E7658 3C 60 80 3E */ lis r3, lbl_803DFC80@ha +/* 800EA6F8 000E7658 3C 60 80 3E */ lis r3, __vt__27CScriptCameraFilterKeyframe@ha /* 800EA6FC 000E765C FC 20 D0 90 */ fmr f1, f26 -/* 800EA700 000E7660 38 03 FC 80 */ addi r0, r3, lbl_803DFC80@l +/* 800EA700 000E7660 38 03 FC 80 */ addi r0, r3, __vt__27CScriptCameraFilterKeyframe@l /* 800EA704 000E7664 FC 40 D8 90 */ fmr f2, f27 /* 800EA708 000E7668 90 1A 00 00 */ stw r0, 0(r26) /* 800EA70C 000E766C FC 60 E0 90 */ fmr f3, f28 diff --git a/configure.py b/configure.py index fe99011d..415401df 100755 --- a/configure.py +++ b/configure.py @@ -142,7 +142,7 @@ LIBS = [ ["MetroidPrime/ScriptObjects/CScriptHUDMemo", True], "MetroidPrime/CMappableObject", "MetroidPrime/Player/CPlayerCameraBob", - "MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe", + ["MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe", True], ["MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe", True], ["MetroidPrime/Cameras/CCameraFilter", False], "MetroidPrime/Player/CMorphBall", diff --git a/include/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.hpp b/include/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.hpp new file mode 100644 index 00000000..616401e8 --- /dev/null +++ b/include/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.hpp @@ -0,0 +1,33 @@ +#ifndef _CSCRIPTCAMERAFILTERKEYFRAME +#define _CSCRIPTCAMERAFILTERKEYFRAME + +#include "MetroidPrime/CEntity.hpp" + +#include "MetroidPrime/Cameras/CCameraFilterPass.hpp" +#include "MetroidPrime/CStateManager.hpp" + +#include "Kyoto/Graphics/CColor.hpp" + +class CScriptCameraFilterKeyframe : public CEntity { + CCameraFilterPass::EFilterType x34_type; + CCameraFilterPass::EFilterShape x38_shape; + CStateManager::ECameraFilterStage x3c_filterIdx; + uint x40_; + CColor x44_color; + float x48_timeIn; + float x4c_timeOut; + CAssetId x50_txtr; + +public: + CScriptCameraFilterKeyframe(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + CCameraFilterPass::EFilterType type, + CCameraFilterPass::EFilterShape shape, CStateManager::ECameraFilterStage filterIdx, uint unk, + float colorR, float colorG, float colorB, float colorA, float timeIn, + float timeOut, CAssetId txtr, bool active); + ~CScriptCameraFilterKeyframe(); + + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override; + void Accept(IVisitor& visitor) override; +}; + +#endif // _CSCRIPTCAMERAFILTERKEYFRAME diff --git a/obj_files.mk b/obj_files.mk index 10f08f1b..a7e809de 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -107,7 +107,7 @@ METROIDPRIME :=\ $(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptHUDMemo.o\ $(BUILD_DIR)/asm/MetroidPrime/CMappableObject.o\ $(BUILD_DIR)/asm/MetroidPrime/Player/CPlayerCameraBob.o\ - $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.o\ + $(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.o\ $(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptCameraBlurKeyframe.o\ $(BUILD_DIR)/asm/MetroidPrime/Cameras/CCameraFilter.o\ $(BUILD_DIR)/asm/MetroidPrime/Player/CMorphBall.o\ diff --git a/src/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.cpp b/src/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.cpp new file mode 100644 index 00000000..be5242e7 --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.cpp @@ -0,0 +1,48 @@ +#include "MetroidPrime/ScriptObjects/CScriptCameraFilterKeyframe.hpp" + +#include "MetroidPrime/CStateManager.hpp" + +CScriptCameraFilterKeyframe::CScriptCameraFilterKeyframe( + TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + CCameraFilterPass::EFilterType type, CCameraFilterPass::EFilterShape shape, + CStateManager::ECameraFilterStage filterIdx, uint unk, float colorR, float colorG, float colorB, + float colorA, float timeIn, float timeOut, CAssetId txtr, bool active) +: CEntity(uid, info, active, name) +, x34_type(type) +, x38_shape(shape) +, x3c_filterIdx(filterIdx) +, x40_(unk) +, x44_color(colorR, colorG, colorB, colorA) +, x48_timeIn(timeIn) +, x4c_timeOut(timeOut) +, x50_txtr(txtr) {} + +CScriptCameraFilterKeyframe::~CScriptCameraFilterKeyframe() {} + +void CScriptCameraFilterKeyframe::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, + CStateManager& stateMgr) { + switch (msg) { + case kSM_Increment: + if (GetActive()) { + stateMgr.CameraFilterPass(x3c_filterIdx) + .SetFilter(x34_type, x38_shape, x48_timeIn, x44_color, x50_txtr); + } + break; + case kSM_Decrement: + if (GetActive()) { + stateMgr.CameraFilterPass(x3c_filterIdx).DisableFilter(x4c_timeOut); + } + break; + case kSM_Deactivate: + if (GetActive()) { + stateMgr.CameraFilterPass(x3c_filterIdx).DisableFilter(0.f); + } + break; + default: + break; + } + + CEntity::AcceptScriptMsg(msg, objId, stateMgr); +} + +void CScriptCameraFilterKeyframe::Accept(IVisitor& visitor) { visitor.Visit(*this); }