From 8af356062b38d6283a9c571ea4fdbb8aaba477fc Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Fri, 21 Oct 2022 17:51:59 +0300 Subject: [PATCH] Match and link CScriptPointOfInterest Former-commit-id: e1d392927cff8abdebfdf961e8135e9bafdd8e59 --- asm/MetroidPrime/ScriptLoader.s | 2 +- .../ScriptObjects/CScriptPointOfInterest.s | 16 +++---- configure.py | 2 +- include/MetroidPrime/CActorParameters.hpp | 1 + .../ScriptObjects/CScriptPointOfInterest.hpp | 26 ++++++++++ obj_files.mk | 2 +- .../ScriptObjects/CScriptPointOfInterest.cpp | 47 +++++++++++++++++++ tools/metaforce_renames.sh | 3 ++ 8 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 include/MetroidPrime/ScriptObjects/CScriptPointOfInterest.hpp create mode 100644 src/MetroidPrime/ScriptObjects/CScriptPointOfInterest.cpp diff --git a/asm/MetroidPrime/ScriptLoader.s b/asm/MetroidPrime/ScriptLoader.s index abf03294..7f23766b 100644 --- a/asm/MetroidPrime/ScriptLoader.s +++ b/asm/MetroidPrime/ScriptLoader.s @@ -20536,7 +20536,7 @@ lbl_800D7C9C: /* 800D7D1C 000D4C7C 38 A1 00 18 */ addi r5, r1, 0x18 /* 800D7D20 000D4C80 38 E1 00 28 */ addi r7, r1, 0x28 /* 800D7D24 000D4C84 39 21 00 14 */ addi r9, r1, 0x14 -/* 800D7D28 000D4C88 48 08 70 0D */ bl "__ct__22CScriptPointOfInterestF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC20CScannableParameters" +/* 800D7D28 000D4C88 48 08 70 0D */ bl "__ct__22CScriptPointOfInterestF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC20CScannableParametersf" /* 800D7D2C 000D4C8C 7C 7E 1B 78 */ mr r30, r3 lbl_800D7D30: /* 800D7D30 000D4C90 38 61 00 18 */ addi r3, r1, 0x18 diff --git a/asm/MetroidPrime/ScriptObjects/CScriptPointOfInterest.s b/asm/MetroidPrime/ScriptObjects/CScriptPointOfInterest.s index 48e8b624..9d8bddbb 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptPointOfInterest.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptPointOfInterest.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803E3638 -lbl_803E3638: +.global __vt__22CScriptPointOfInterest +__vt__22CScriptPointOfInterest: # ROM: 0x3E0638 .4byte 0 .4byte 0 @@ -209,9 +209,9 @@ __dt__22CScriptPointOfInterestFv: /* 8015ECE8 0015BC48 93 C1 00 08 */ stw r30, 8(r1) /* 8015ECEC 0015BC4C 7C 7E 1B 79 */ or. r30, r3, r3 /* 8015ECF0 0015BC50 41 82 00 28 */ beq lbl_8015ED18 -/* 8015ECF4 0015BC54 3C A0 80 3E */ lis r5, lbl_803E3638@ha +/* 8015ECF4 0015BC54 3C A0 80 3E */ lis r5, __vt__22CScriptPointOfInterest@ha /* 8015ECF8 0015BC58 38 80 00 00 */ li r4, 0 -/* 8015ECFC 0015BC5C 38 05 36 38 */ addi r0, r5, lbl_803E3638@l +/* 8015ECFC 0015BC5C 38 05 36 38 */ addi r0, r5, __vt__22CScriptPointOfInterest@l /* 8015ED00 0015BC60 90 1E 00 00 */ stw r0, 0(r30) /* 8015ED04 0015BC64 4B EF 69 ED */ bl __dt__6CActorFv /* 8015ED08 0015BC68 7F E0 07 35 */ extsh. r0, r31 @@ -227,8 +227,8 @@ lbl_8015ED18: /* 8015ED2C 0015BC8C 38 21 00 10 */ addi r1, r1, 0x10 /* 8015ED30 0015BC90 4E 80 00 20 */ blr -.global "__ct__22CScriptPointOfInterestF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC20CScannableParameters" -"__ct__22CScriptPointOfInterestF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC20CScannableParameters": +.global "__ct__22CScriptPointOfInterestF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC20CScannableParametersf" +"__ct__22CScriptPointOfInterestF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC20CScannableParametersf": /* 8015ED34 0015BC94 94 21 FE 90 */ stwu r1, -0x170(r1) /* 8015ED38 0015BC98 7C 08 02 A6 */ mflr r0 /* 8015ED3C 0015BC9C 90 01 01 74 */ stw r0, 0x174(r1) @@ -289,9 +289,9 @@ lbl_8015ED18: /* 8015EE18 0015BD78 38 61 00 F0 */ addi r3, r1, 0xf0 /* 8015EE1C 0015BD7C 38 80 FF FF */ li r4, -1 /* 8015EE20 0015BD80 4B FB 7C 2D */ bl __dt__10CModelDataFv -/* 8015EE24 0015BD84 3C 80 80 3E */ lis r4, lbl_803E3638@ha +/* 8015EE24 0015BD84 3C 80 80 3E */ lis r4, __vt__22CScriptPointOfInterest@ha /* 8015EE28 0015BD88 7F E3 FB 78 */ mr r3, r31 -/* 8015EE2C 0015BD8C 38 04 36 38 */ addi r0, r4, lbl_803E3638@l +/* 8015EE2C 0015BD8C 38 04 36 38 */ addi r0, r4, __vt__22CScriptPointOfInterest@l /* 8015EE30 0015BD90 90 1F 00 00 */ stw r0, 0(r31) /* 8015EE34 0015BD94 D3 FF 00 E8 */ stfs f31, 0xe8(r31) /* 8015EE38 0015BD98 CB E1 01 68 */ lfd f31, 0x168(r1) diff --git a/configure.py b/configure.py index f3d091b5..f9b03f92 100755 --- a/configure.py +++ b/configure.py @@ -227,7 +227,7 @@ LIBS = [ "MetroidPrime/Enemies/CRipper", "MetroidPrime/Cameras/CCameraShakeData", "MetroidPrime/ScriptObjects/CScriptPickupGenerator", - "MetroidPrime/ScriptObjects/CScriptPointOfInterest", + ["MetroidPrime/ScriptObjects/CScriptPointOfInterest", True], "MetroidPrime/Enemies/CDrone", "MetroidPrime/CMapWorldInfo", "MetroidPrime/Factories/CScannableObjectInfo", diff --git a/include/MetroidPrime/CActorParameters.hpp b/include/MetroidPrime/CActorParameters.hpp index 676fa990..7b43c095 100644 --- a/include/MetroidPrime/CActorParameters.hpp +++ b/include/MetroidPrime/CActorParameters.hpp @@ -102,6 +102,7 @@ public: // CActorParameters() { // // TODO // } + CActorParameters Scannable(const CScannableParameters& sParms) const; const CLightParameters& GetLighting() const { return x0_lightParams; } const CScannableParameters& GetScannable() const { return x40_scanParams; } diff --git a/include/MetroidPrime/ScriptObjects/CScriptPointOfInterest.hpp b/include/MetroidPrime/ScriptObjects/CScriptPointOfInterest.hpp new file mode 100644 index 00000000..979791ff --- /dev/null +++ b/include/MetroidPrime/ScriptObjects/CScriptPointOfInterest.hpp @@ -0,0 +1,26 @@ +#ifndef _CSCRIPTPOINTOFINTEREST +#define _CSCRIPTPOINTOFINTEREST + +#include "MetroidPrime/CActor.hpp" + +class CScannableParameters; + +class CScriptPointOfInterest : public CActor { +private: + float xe8_pointSize; + +public: + CScriptPointOfInterest(TUniqueId, const rstl::string&, const CEntityInfo&, const CTransform4f&, bool, + const CScannableParameters&, float); + ~CScriptPointOfInterest(); + + void Accept(IVisitor& visitor) override; + void Think(float, CStateManager&) override; + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; + void AddToRenderer(const CFrustumPlanes&, const CStateManager&) const override; + void Render(const CStateManager&) const override; + void CalculateRenderBounds() override; + rstl::optional_object GetTouchBounds() const override; +}; + +#endif // _CSCRIPTPOINTOFINTEREST diff --git a/obj_files.mk b/obj_files.mk index 4737b611..d5db3146 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -192,7 +192,7 @@ METROIDPRIME :=\ $(BUILD_DIR)/asm/MetroidPrime/Enemies/CRipper.o\ $(BUILD_DIR)/asm/MetroidPrime/Cameras/CCameraShakeData.o\ $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptPickupGenerator.o\ - $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptPointOfInterest.o\ + $(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptPointOfInterest.o\ $(BUILD_DIR)/asm/MetroidPrime/Enemies/CDrone.o\ $(BUILD_DIR)/asm/MetroidPrime/CMapWorldInfo.o\ $(BUILD_DIR)/asm/MetroidPrime/Factories/CScannableObjectInfo.o\ diff --git a/src/MetroidPrime/ScriptObjects/CScriptPointOfInterest.cpp b/src/MetroidPrime/ScriptObjects/CScriptPointOfInterest.cpp new file mode 100644 index 00000000..1671b7b0 --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptPointOfInterest.cpp @@ -0,0 +1,47 @@ +#include "MetroidPrime/ScriptObjects/CScriptPointOfInterest.hpp" + +#include "MetroidPrime/CActorParameters.hpp" +#include "MetroidPrime/Player/CPlayerState.hpp" + +#include "Kyoto/Math/CAABox.hpp" + +CScriptPointOfInterest::CScriptPointOfInterest(TUniqueId uid, const rstl::string& name, + const CEntityInfo& info, const CTransform4f& xf, + bool active, const CScannableParameters& parms, + float f1) +: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(kMT_Orbit), + CActorParameters::None().Scannable(parms), kInvalidUniqueId) +, xe8_pointSize(f1) {} + +CScriptPointOfInterest::~CScriptPointOfInterest() {} + +void CScriptPointOfInterest::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, + CStateManager& mgr) { + CActor::AcceptScriptMsg(msg, uid, mgr); +} + +rstl::optional_object< CAABox > CScriptPointOfInterest::GetTouchBounds() const { + return CAABox(x34_transform.GetTranslation(), x34_transform.GetTranslation()); +} + +void CScriptPointOfInterest::Render(const CStateManager&) const {} + +void CScriptPointOfInterest::AddToRenderer(const CFrustumPlanes&, const CStateManager&) const {} + +void CScriptPointOfInterest::Accept(IVisitor& visitor) { visitor.Visit(*this); } + +void CScriptPointOfInterest::Think(float dt, CStateManager& mgr) { + xe7_31_targetable = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::kPV_Scan; + CEntity::Think(dt, mgr); +} + +void CScriptPointOfInterest::CalculateRenderBounds() { + if (xe8_pointSize == 0.f) { + CActor::CalculateRenderBounds(); + } else { + CVector3f origin = x34_transform.GetTranslation(); + x9c_renderBounds = CAABox( + origin - CVector3f(xe8_pointSize, xe8_pointSize, xe8_pointSize), + origin + CVector3f(xe8_pointSize, xe8_pointSize, xe8_pointSize)); + } +} diff --git a/tools/metaforce_renames.sh b/tools/metaforce_renames.sh index 226162a4..e047c892 100644 --- a/tools/metaforce_renames.sh +++ b/tools/metaforce_renames.sh @@ -4,10 +4,13 @@ set -e path=$1 sed -i "s/std::string_view/const rstl::string\&/g" "$path" +sed -i "s/std::optional/rstl::optional_object/g" "$path" sed -i "s/zeus::CTransform/CTransform4f/g" "$path" sed -i "s/zeus::skZero2f/CVector2f(0.f, 0.f)/g" "$path" sed -i "s/zeus::skZero3f/CVector3f::Zero()/g" "$path" sed -i "s/zeus::skPurple/CColor::Purple()/g" "$path" sed -i "s/zeus::skWhite/CColor::White()/g" "$path" +sed -i "s/zeus::CFrustum/CFrustumPlanes/g" "$path" sed -i "s/zeus:://g" "$path" +sed -i "s/DEFINE_ENTITY//g" "$path" sed -i "s/visitor.Visit(this)/visitor.Visit(*this)/g" "$path"