diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 35238c68..2b1e9a4e 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -2054,7 +2054,7 @@ GetItemCapacity__12CPlayerStateCFQ212CPlayerState9EItemType = .text:0x80091AF4; GetItemAmount__12CPlayerStateCFQ212CPlayerState9EItemType = .text:0x80091B1C; // type:function size:0x78 scope:global DecrPickUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091B94; // type:function size:0x5C scope:global IncrPickUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091BF0; // type:function size:0x110 scope:global -ResetAndIncrPickUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091D00; // type:function size:0x30 scope:global +SetPickup__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091D00; // type:function size:0x30 scope:global CalculateHealth__12CPlayerStateFv = .text:0x80091D30; // type:function size:0x38 scope:global InitializePowerUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091D68; // type:function size:0x124 scope:global SetPowerUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091E8C; // type:function size:0x30 scope:global @@ -11477,9 +11477,9 @@ fn_80296D30 = .text:0x80296D30; // type:function size:0x7C fn_80296DAC = .text:0x80296DAC; // type:function size:0x78 Reset__Q27CPlayer12CInputFilterFv = .text:0x80296E24; // type:function size:0x148 scope:global Passes__Q27CPlayer12CInputFilterFv = .text:0x80296F6C; // type:function size:0x480 scope:global -_getElementBoundsCheck>__FRCQ24rstl18reserved_vectori = .text:0x802973EC; // type:function size:0x3C scope:global -_getElementBoundsCheck>__FRCQ24rstl27reserved_vector<9CVector2f>i = .text:0x80297428; // type:function size:0x44 scope:global -_getElementBoundsCheck>__FRCQ24rstl27reserved_vector<9CVector3f>i = .text:0x8029746C; // type:function size:0x4C scope:global +_getElementBoundsCheck__FRCQ24rstl21reserved_vectori = .text:0x802973EC; // type:function size:0x3C scope:global +_getElementBoundsCheck<9CVector2f,20>__FRCQ24rstl30reserved_vector<9CVector2f,20>i = .text:0x80297428; // type:function size:0x44 scope:global +_getElementBoundsCheck<9CVector3f,20>__FRCQ24rstl30reserved_vector<9CVector3f,20>i = .text:0x8029746C; // type:function size:0x4C scope:global AddSample__Q27CPlayer12CInputFilterFiRC9CVector3fRC9CVector3fRC9CVector2f = .text:0x802974B8; // type:function size:0x514 scope:global __ct__Q27CPlayer12CInputFilterFv = .text:0x802979CC; // type:function size:0x18 scope:global GetIsContinueDraw__10CSlideShowFv = .text:0x802979E4; // type:function size:0x8 scope:global diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index 6d854428..6755edf9 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -2054,7 +2054,7 @@ GetItemCapacity__12CPlayerStateCFQ212CPlayerState9EItemType = .text:0x80091B70; GetItemAmount__12CPlayerStateCFQ212CPlayerState9EItemType = .text:0x80091B98; // type:function size:0x78 scope:global DecrPickUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091C10; // type:function size:0x5C scope:global IncrPickUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091C6C; // type:function size:0x110 scope:global -ResetAndIncrPickUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091D7C; // type:function size:0x30 scope:global +SetPickup__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091D7C; // type:function size:0x30 scope:global CalculateHealth__12CPlayerStateFv = .text:0x80091DAC; // type:function size:0x38 scope:global InitializePowerUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091DE4; // type:function size:0x124 scope:global SetPowerUp__12CPlayerStateFQ212CPlayerState9EItemTypei = .text:0x80091F08; // type:function size:0x30 scope:global @@ -11490,9 +11490,9 @@ fn_80296D30 = .text:0x80296DDC; // type:function size:0x7C scope:global fn_80296DAC = .text:0x80296E58; // type:function size:0x78 scope:global Reset__Q27CPlayer12CInputFilterFv = .text:0x80296ED0; // type:function size:0x148 scope:global Passes__Q27CPlayer12CInputFilterFv = .text:0x80297018; // type:function size:0x480 scope:global -_getElementBoundsCheck>__FRCQ24rstl18reserved_vectori = .text:0x80297498; // type:function size:0x3C scope:global -_getElementBoundsCheck>__FRCQ24rstl27reserved_vector<9CVector2f>i = .text:0x802974D4; // type:function size:0x44 scope:global -_getElementBoundsCheck>__FRCQ24rstl27reserved_vector<9CVector3f>i = .text:0x80297518; // type:function size:0x4C scope:global +_getElementBoundsCheck__FRCQ24rstl21reserved_vectori = .text:0x80297498; // type:function size:0x3C scope:global +_getElementBoundsCheck<9CVector2f,20>__FRCQ24rstl30reserved_vector<9CVector2f,20>i = .text:0x802974D4; // type:function size:0x44 scope:global +_getElementBoundsCheck<9CVector2f,20>__FRCQ24rstl30reserved_vector<9CVector2f,20>i = .text:0x80297518; // type:function size:0x4C scope:global AddSample__Q27CPlayer12CInputFilterFiRC9CVector3fRC9CVector3fRC9CVector2f = .text:0x80297564; // type:function size:0x514 scope:global __ct__Q27CPlayer12CInputFilterFv = .text:0x80297A78; // type:function size:0x18 scope:global GetIsContinueDraw__10CSlideShowFv = .text:0x80297A90; // type:function size:0x8 scope:global diff --git a/include/Kyoto/Audio/CAudioGroupSet.hpp b/include/Kyoto/Audio/CAudioGroupSet.hpp index 027de82e..2063137b 100644 --- a/include/Kyoto/Audio/CAudioGroupSet.hpp +++ b/include/Kyoto/Audio/CAudioGroupSet.hpp @@ -16,6 +16,7 @@ public: CAudioGrpSetLoc(const rstl::auto_ptr< uchar >& data, int length); const rstl::string& GetBaseDirName() const { return x10_baseDirName; } const rstl::string& GetGroupSetName() const { return x20_groupSetName; } + void FreeSampleBuffer(); uint AramUsage() const; const void* GetPool() const; const void* GetProject() const; @@ -45,7 +46,7 @@ public: private: rstl::string x0_baseDir; rstl::string x10_groupSetName; - rstl::optional_object< TLockedToken< CAudioGrpSetLoc > > x10_groupSetTok; + rstl::optional_object< TLockedToken< CAudioGrpSetLoc > > x20_groupSetTok; }; #endif // _CAUDIOGROUPSET diff --git a/include/MetroidPrime/Player/CPlayer.hpp b/include/MetroidPrime/Player/CPlayer.hpp index 38633c90..c867c94c 100644 --- a/include/MetroidPrime/Player/CPlayer.hpp +++ b/include/MetroidPrime/Player/CPlayer.hpp @@ -1,6 +1,7 @@ #ifndef _CPLAYER #define _CPLAYER +#include "rstl/reserved_vector.hpp" #include "types.h" #include "MetroidPrime/CAnimRes.hpp" @@ -72,6 +73,19 @@ class CPlayer : public CPhysicsActor { bool AffectsThermal() const { return x28_affectsThermal; } }; + class CInputFilter { + public: + CInputFilter(); + void AddSample(int, const CVector3f&, const CVector3f&, const CVector2f&); + bool Passes(); + void Reset(); + private: + rstl::reserved_vector x0_; + rstl::reserved_vector x54_; + rstl::reserved_vector x148_; + rstl::reserved_vector x23c_; + }; + public: enum EPlayerOrbitState { kOS_NoOrbit, diff --git a/src/Kyoto/Audio/DolphinCAudioGroupSet.cpp b/src/Kyoto/Audio/DolphinCAudioGroupSet.cpp index 0a46de8b..6232b4ec 100644 --- a/src/Kyoto/Audio/DolphinCAudioGroupSet.cpp +++ b/src/Kyoto/Audio/DolphinCAudioGroupSet.cpp @@ -4,17 +4,20 @@ #include "Kyoto/Streams/CMemoryInStream.hpp" #include "Kyoto/CFactoryMgr.hpp" +#include "rstl/auto_ptr.hpp" CAudioGroupSet::CAudioGroupSet(const TLockedToken< CAudioGrpSetLoc >& group) : x0_baseDir(group->GetBaseDirName()) , x10_groupSetName(group->GetGroupSetName()) -, x10_groupSetTok(group) {} +, x20_groupSetTok(group) {} CAudioGroupSet::~CAudioGroupSet() {} void CAudioGroupSet::Reload() {} -void CAudioGroupSet::FreeSampleBuffer() {} +void CAudioGroupSet::FreeSampleBuffer() { + x20_groupSetTok.data()->FreeSampleBuffer(); +} CAudioGrpSetLoc::CAudioGrpSetLoc(const rstl::auto_ptr< uchar >& data, int length) : x0_data(data.get()), x30_(0), x34_(0), x38_(0), x3c_(0), x40_(0) { @@ -28,6 +31,11 @@ CAudioGrpSetLoc::CAudioGrpSetLoc(const rstl::auto_ptr< uchar >& data, int length CAudioSys::GetVerbose(); } +void CAudioGrpSetLoc::FreeSampleBuffer() { + x0_data = nullptr; + x40_ = 0; +} + template <> CFactoryFnReturn::CFactoryFnReturn(CAudioGrpSetLoc* ptr) : obj(TToken< CAudioGrpSetLoc >::GetIObjObjectFor(rstl::auto_ptr< CAudioGrpSetLoc >(ptr)) diff --git a/src/MetroidPrime/Player/CPlayerInputFilter.cpp b/src/MetroidPrime/Player/CPlayerInputFilter.cpp new file mode 100644 index 00000000..f753a51a --- /dev/null +++ b/src/MetroidPrime/Player/CPlayerInputFilter.cpp @@ -0,0 +1,64 @@ +#include "Kyoto/Math/CVector3f.hpp" +#include "MetroidPrime/Player/CPlayer.hpp" +#include "dolphin/hw_regs.h" +#include "rstl/optional_object.hpp" +#include "rstl/reserved_vector.hpp" + +CPlayer::CInputFilter::CInputFilter() {} + +void CPlayer::CInputFilter::AddSample(int a, const CVector3f& b, const CVector3f& c, + const CVector2f& d) { + x0_.push_back(a); + x54_.push_back(b); + x148_.push_back(c); + x23c_.push_back(d); +} + +template < typename T, int N > +rstl::optional_object< T > _getElementBoundsCheck(const rstl::reserved_vector< T, N >& v, int idx); + +template <> +rstl::optional_object< CVector3f > +_getElementBoundsCheck(const rstl::reserved_vector< CVector3f, 20 >& v, int idx) { + if (idx >= v.size()) { + return rstl::optional_object_null(); + } + + return v[idx]; +} +template <> +rstl::optional_object< CVector2f > +_getElementBoundsCheck(const rstl::reserved_vector< CVector2f, 20 >& v, int idx) { + if (idx >= v.size()) { + return rstl::optional_object_null(); + } + + return v[idx]; +} + +template <> +rstl::optional_object< int > _getElementBoundsCheck(const rstl::reserved_vector< int, 20 >& v, + int idx) { + if (idx >= v.size()) { + return rstl::optional_object_null(); + } + + return v[idx]; +} + +bool CPlayer::CInputFilter::Passes() { + if (x0_.size() != 14) { + return false; + } + CVector3f min1, max1; + min1 = *_getElementBoundsCheck(x148_, 0); + max1 = *_getElementBoundsCheck(x148_, 0); + CAABox box1(min1, max1); + CAABox box(*_getElementBoundsCheck(x148_, 0), *_getElementBoundsCheck(x148_, 0)); +} +void CPlayer::CInputFilter::Reset() { + x0_.clear(); + x54_.clear(); + x148_.clear(); + x23c_.clear(); +}