diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 6a4be735..d24ff94e 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -1352,7 +1352,7 @@ fn_80056FE8 = .text:0x80056FE8; // type:function size:0x8C fn_80057074 = .text:0x80057074; // type:function size:0x50 fn_800570C4 = .text:0x800570C4; // type:function size:0x24 fn_800570E8 = .text:0x800570E8; // type:function size:0xF0 -LoadRelays__FR12CInputStreamRQ24rstl44vector = .text:0x800571D8; // type:function size:0xF8 scope:global +__ct__Q24rstl42vector<6CRelay,Q24rstl17rmemory_allocator>FR12CInputStreamRCQ24rstl17rmemory_allocator = .text:0x800571D8; // type:function size:0xF8 scope:global __dt__11CDummyWorldFv = .text:0x800572D0; // type:function size:0xDC scope:global fn_800573AC = .text:0x800573AC; // type:function size:0xD0 __ct__11CDummyWorldFUi = .text:0x8005747C; // type:function size:0x138 scope:global diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index e6f1a3ab..e3960a27 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -1352,7 +1352,7 @@ fn_80056FE8 = .text:0x80057064; // type:function size:0x8C scope:global fn_80057074 = .text:0x800570F0; // type:function size:0x50 scope:global fn_800570C4 = .text:0x80057140; // type:function size:0x24 scope:global fn_800570E8 = .text:0x80057164; // type:function size:0xF0 scope:global -LoadRelays__FR12CInputStreamRQ24rstl44vector = .text:0x80057254; // type:function size:0xF8 scope:global +__ct__Q24rstl42vector<6CRelay,Q24rstl17rmemory_allocator>FR12CInputStreamRCQ24rstl17rmemory_allocator = .text:0x80057254; // type:function size:0xF8 scope:global __dt__11CDummyWorldFv = .text:0x8005734C; // type:function size:0xDC scope:global fn_800573AC = .text:0x80057428; // type:function size:0xD0 scope:global __ct__11CDummyWorldFUi = .text:0x800574F8; // type:function size:0x138 scope:global diff --git a/include/Kyoto/Graphics/CModelFlags.hpp b/include/Kyoto/Graphics/CModelFlags.hpp index 74dfc48b..9631ea06 100644 --- a/include/Kyoto/Graphics/CModelFlags.hpp +++ b/include/Kyoto/Graphics/CModelFlags.hpp @@ -40,7 +40,7 @@ public: CModelFlags(const ETrans blendMode, const uchar shadIdx, const EFlags flags, const CColor& col) : x0_blendMode(blendMode), x1_matSetIdx(shadIdx), x2_flags(flags), x4_color(col) {} - CModelFlags(const CModelFlags& flags, uint otherFlags) + CModelFlags(const CModelFlags& flags, const uint otherFlags) : x0_blendMode(flags.x0_blendMode) , x1_matSetIdx(flags.x1_matSetIdx) , x2_flags(otherFlags) diff --git a/include/Kyoto/Streams/CInputStream.hpp b/include/Kyoto/Streams/CInputStream.hpp index 10a9cbe9..7b6d82f6 100644 --- a/include/Kyoto/Streams/CInputStream.hpp +++ b/include/Kyoto/Streams/CInputStream.hpp @@ -34,7 +34,7 @@ public: void Get(void* dest, unsigned long len); template < typename T > - inline T Get(const TType< T >& type = TType< T >()) { + T Get(const TType< T >& type = TType< T >()) { return cinput_stream_helper(TType< T >(), *this); } diff --git a/include/MetroidPrime/CAnimData.hpp b/include/MetroidPrime/CAnimData.hpp index 86cb680d..fbff41f6 100644 --- a/include/MetroidPrime/CAnimData.hpp +++ b/include/MetroidPrime/CAnimData.hpp @@ -53,9 +53,9 @@ public: const TLockedToken< CSkinnedModel >& GetModelData() const { return xd8_modelData; } void SetIsAnimating(bool v) { x220_24_animating = v; } - void SetParticleEffectState(const rstl::string& name, const bool active, CStateManager& mgr); /* { + void SetParticleEffectState(const rstl::string& name, const bool active, CStateManager& mgr) { x120_particleDB.SetParticleEffectState(name, active, mgr); - }*/ + } int GetCharacterIndex() const { return x204_charIdx; } float GetAverageVelocity(int idx) const; diff --git a/include/MetroidPrime/CGameArea.hpp b/include/MetroidPrime/CGameArea.hpp index 8b22ee73..cb2dd92d 100644 --- a/include/MetroidPrime/CGameArea.hpp +++ b/include/MetroidPrime/CGameArea.hpp @@ -302,7 +302,7 @@ class CDummyGameArea final : public IGameArea { friend class CDummyWorld; public: - CDummyGameArea(CInputStream& in, int idx, int mlvlVersion); + CDummyGameArea(CInputStream& in, int idx, uint mlvlVersion); rstl::pair< rstl::auto_ptr< uchar >, int > IGetScriptingMemoryAlways() const override; int IGetAreaSaveId() const override; CAssetId IGetAreaAssetId() const override; diff --git a/include/MetroidPrime/CMapWorld.hpp b/include/MetroidPrime/CMapWorld.hpp index 984e4d99..8c725f68 100644 --- a/include/MetroidPrime/CMapWorld.hpp +++ b/include/MetroidPrime/CMapWorld.hpp @@ -151,7 +151,6 @@ public: bool IsMapAreaInBFSInfoVector(const CMapAreaData* area, const rstl::vector< CMapAreaBFSInfo >& vec) const; void SetWhichMapAreasLoaded(const IWorld& wld, int start, int count); - bool IsMapAreasStreaming(); void MoveMapAreaToList(CMapAreaData* data, EMapAreaList list); int GetCurrentMapAreaDepth(const IWorld& wld, TAreaId aid); rstl::vector< int > GetVisibleAreas(const IWorld& wld, const CMapWorldInfo& mwInfo) const; diff --git a/include/MetroidPrime/CWorld.hpp b/include/MetroidPrime/CWorld.hpp index 05d64adc..2f94f5a9 100644 --- a/include/MetroidPrime/CWorld.hpp +++ b/include/MetroidPrime/CWorld.hpp @@ -123,7 +123,9 @@ public: const CGameArea& GetAreaAlways(const TAreaId id) const { return *x18_areas[id.Value()]; } CGameArea* Area(const TAreaId id) { return &*x18_areas[id.Value()]; } const CGameArea* GetArea(const TAreaId id) const { return &*x18_areas[id.Value()]; } - bool IsAreaValid(const TAreaId id) const { return x18_areas[id.Value()]->IsLoaded(); } + bool IsAreaValid(const TAreaId id) const { + return x18_areas[id.Value()]->IsLoaded(); + } CAssetId GetWorldAssetId() const { return x8_mlvlId; } TAreaId GetCurrentAreaId() const { return x68_curAreaId; } TAreaId GetAreaIdForSaveId(int saveId) const; @@ -149,6 +151,7 @@ public: void SetAreaAttributes(const TAreaId aid, CScriptAreaAttributes* attr) { Area(aid)->SetAreaAttributes(attr); } + private: enum Phase { diff --git a/src/MetroidPrime/CActor.cpp b/src/MetroidPrime/CActor.cpp index d3f5963c..f0dd1120 100644 --- a/src/MetroidPrime/CActor.cpp +++ b/src/MetroidPrime/CActor.cpp @@ -36,9 +36,10 @@ static CMaterialList MakeActorMaterialList(const CMaterialList& in, return ret; } -CActor::CActor(TUniqueId uid, bool active, const rstl::string& name, const CEntityInfo& info, - const CTransform4f& xf, const CModelData& mData, const CMaterialList& list, - const CActorParameters& params, TUniqueId nextDrawNode) +CActor::CActor(const TUniqueId uid, const bool active, const rstl::string& name, + const CEntityInfo& info, const CTransform4f& xf, const CModelData& mData, + const CMaterialList& list, const CActorParameters& params, + const TUniqueId nextDrawNode) : CEntity(uid, info, active, name) , x34_transform(xf) , x64_modelData(mData.IsNull() ? nullptr : rs_new CModelData(mData)) @@ -232,27 +233,23 @@ void CActor::PreRender(CStateManager& mgr, const CFrustumPlanes& planes) { } if (GetCalculateLighting()) { - CAABox bounds = GetModelData()->GetBounds(GetTransform()); + const CAABox bounds = GetModelData()->GetBounds(GetTransform()); if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::kPV_Thermal) { ActorLights()->BuildConstantAmbientLighting(); } else { - if (lightsDirty == true) { - if (GetCurrentAreaId() != kInvalidAreaId) { - TAreaId aid = GetCurrentAreaId(); - if (mgr.GetWorld()->IsAreaValid(aid)) { - const CGameArea* area = mgr.GetWorld()->GetArea(aid); - if (ActorLights()->BuildAreaLightList(mgr, *area, bounds)) { - xe7_28_worldLightingDirty = false; - } - } - } + if (lightsDirty == true && GetCurrentAreaId() != kInvalidAreaId && + mgr.GetWorld()->IsAreaValid(GetCurrentAreaId()) && + ActorLights()->BuildAreaLightList(mgr, *mgr.GetWorld()->GetArea(GetCurrentAreaId()), + bounds)) { + xe7_28_worldLightingDirty = false; } ActorLights()->BuildDynamicLightList(mgr, bounds); } } + CModelData* mData = ModelData(); if (GetModelData()->HasAnimation()) { - AnimationData()->PreRender(); + mData->AnimationData()->PreRender(); } } else { if (GetPreRenderHasMoved()) { @@ -700,81 +697,86 @@ void CActor::SetInFluid(bool in, TUniqueId uid) { } // TODO nonmatching -void CActor::ProcessSoundEvent(int sfxId, float weight, int flags, float fallOff, float maxDist, - uchar minVol, uchar maxVol, const CVector3f& toListener, - const CVector3f& position, int aid, CStateManager& mgr, - bool translateId) { - if (toListener.MagSquared() >= maxDist * maxDist) { - return; - } - ushort id = translateId ? CSfxManager::TranslateSFXID(static_cast< ushort >(sfxId)) - : static_cast< ushort >(sfxId); - - uint musyxFlags = 0x1; // Continuous parameter update - if (flags & 0x8) { - musyxFlags |= 0x8; // Doppler FX - } - - // TODO ctor? - CAudioSys::C3DEmitterParmData parms(maxDist, fallOff, musyxFlags, maxVol, minVol); - parms.x0_pos = position; - parms.xc_dir = CVector3f::Zero(); - parms.x24_sfxId = id; - - bool useAcoustics = (flags & 0x80) == 0; - bool looping = (sfxId & 0x80000000) != 0; - bool nonEmitter = (sfxId & 0x40000000) != 0; - - if (mgr.Random()->Float() > weight) { - return; - } - - if (looping) { - ushort curId = x88_sfxId; - if (!x8c_loopingSfxHandle) { - CSfxHandle handle; - if (nonEmitter) { - handle = CSfxManager::SfxStart(id, 1.f, 0.f, true, CSfxManager::kMedPriority, true, aid); - } else { - handle = CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid); - } - if (handle) { - x88_sfxId = id; - x8c_loopingSfxHandle = handle; - if (xe6_30_enablePitchBend) { - CSfxManager::PitchBend(handle, xc0_pitchBend); - } - } - } else if (curId == id) { - CSfxManager::UpdateEmitter(x8c_loopingSfxHandle, parms.x0_pos, parms.xc_dir, maxVol); - } else if (flags & 0x4) { - CSfxManager::RemoveEmitter(x8c_loopingSfxHandle); - CSfxHandle handle = - CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid); - if (handle) { - x88_sfxId = id; - x8c_loopingSfxHandle = handle; - if (xe6_30_enablePitchBend) { - CSfxManager::PitchBend(handle, xc0_pitchBend); - } - } - } - } else { - CSfxHandle handle; - if (nonEmitter) { - handle = - CSfxManager::SfxStart(id, 1.f, 0.f, useAcoustics, CSfxManager::kMedPriority, false, aid); +void CActor::ProcessSoundEvent(const int sfxId, const float weight, const int flags, + const float fallOff, const float maxDist, const uchar minVol, + const uchar maxVol, const CVector3f& toListener, + const CVector3f& position, const int aid, CStateManager& mgr, + const bool translateId) { + if (toListener.MagSquared() < maxDist * maxDist) { + ushort id; + if (translateId) { + id = CSfxManager::TranslateSFXID(sfxId); } else { - handle = CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, false, aid); - } - if ((sfxId & 0x20000000) != 0 /* continuous update */) { - xd8_nonLoopingSfxHandles[xe4_24_nextNonLoopingSfxHandle] = handle; - xe4_24_nextNonLoopingSfxHandle = - (xe4_24_nextNonLoopingSfxHandle + 1) % xd8_nonLoopingSfxHandles.size(); + id = static_cast(sfxId); } - if (xe6_30_enablePitchBend) { - CSfxManager::PitchBend(handle, xc0_pitchBend); + uint musyxFlags = 0x1; // Continuous parameter update + if (flags & 0x8) { + musyxFlags |= 0x8; // Doppler FX + } + + // TODO ctor? + CAudioSys::C3DEmitterParmData parms(maxDist, fallOff, musyxFlags, maxVol, minVol); + parms.x0_pos = position; + parms.xc_dir = CVector3f::Zero(); + parms.x24_sfxId = id; + + bool useAcoustics = (flags & 0x80) == 0; + bool looping = (sfxId & 0x80000000) != 0; + bool nonEmitter = (sfxId & 0x40000000) != 0; + + if (mgr.Random()->Float() <= weight) { + if (looping) { + ushort curId = x88_sfxId; + if (!x8c_loopingSfxHandle) { + CSfxHandle handle; + if (nonEmitter) { + handle = + CSfxManager::SfxStart(id, 1.f, 0.f, true, CSfxManager::kMedPriority, true, aid); + } else { + handle = + CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid); + } + if (handle) { + x88_sfxId = id; + x8c_loopingSfxHandle = handle; + if (xe6_30_enablePitchBend) { + CSfxManager::PitchBend(handle, xc0_pitchBend); + } + } + } else if (curId == id) { + CSfxManager::UpdateEmitter(x8c_loopingSfxHandle, parms.x0_pos, parms.xc_dir, maxVol); + } else if (flags & 0x4) { + CSfxManager::RemoveEmitter(x8c_loopingSfxHandle); + CSfxHandle handle = + CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, true, aid); + if (handle) { + x88_sfxId = id; + x8c_loopingSfxHandle = handle; + if (xe6_30_enablePitchBend) { + CSfxManager::PitchBend(handle, xc0_pitchBend); + } + } + } + } else { + CSfxHandle handle; + if (nonEmitter) { + handle = CSfxManager::SfxStart(id, 1.f, 0.f, useAcoustics, CSfxManager::kMedPriority, + false, aid); + } else { + handle = + CSfxManager::AddEmitter(parms, useAcoustics, CSfxManager::kMedPriority, false, aid); + } + if ((sfxId & 0x20000000) != 0 /* continuous update */) { + xd8_nonLoopingSfxHandles[xe4_24_nextNonLoopingSfxHandle] = handle; + xe4_24_nextNonLoopingSfxHandle = + (xe4_24_nextNonLoopingSfxHandle + 1) % xd8_nonLoopingSfxHandles.size(); + } + + if (xe6_30_enablePitchBend) { + CSfxManager::PitchBend(handle, xc0_pitchBend); + } + } } } } @@ -814,10 +816,9 @@ void CActor::SetDrawShadow(bool enabled) { xe5_24_shadowEnabled = enabled; } -// TODO nonmatching bool CActor::CanDrawStatic() const { - if (!GetActive() || !HasModelData() || xb4_drawFlags.GetTrans() > 4) { - return false; + if (!GetActive() || !HasModelData() || static_cast< char >(xb4_drawFlags.GetBlendMode()) > 4) { + return false; } if (GetModelData()->IsNull() || GetModelData()->HasAnimation()) { return false; diff --git a/src/MetroidPrime/CGameArea.cpp b/src/MetroidPrime/CGameArea.cpp index ba0c8992..a4143ca7 100644 --- a/src/MetroidPrime/CGameArea.cpp +++ b/src/MetroidPrime/CGameArea.cpp @@ -7,6 +7,7 @@ #define ROUND_UP_32(val) (((val) + 31) & ~31) + rstl::pair< rstl::auto_ptr< uchar >, int > GetScriptingMemoryAlways(const IGameArea& area) { SObjectTag tag('MREA', area.IGetAreaAssetId()); diff --git a/src/MetroidPrime/CWorld.cpp b/src/MetroidPrime/CWorld.cpp index dc8769d9..b3541198 100644 --- a/src/MetroidPrime/CWorld.cpp +++ b/src/MetroidPrime/CWorld.cpp @@ -269,13 +269,13 @@ CDummyWorld::CDummyWorld(CAssetId mlvlId, bool loadMap) class CMemoryRelays { public: - CMemoryRelays(CInputStream& in /*, const int& unk*/); + CMemoryRelays(CInputStream& in, const int& unk); private: rstl::vector< CRelay > x0_relayList; }; -CMemoryRelays::CMemoryRelays(CInputStream& in /*, const int& unk*/) { +CMemoryRelays::CMemoryRelays(CInputStream& in, const int&) { int count = in.Get< int >(); x0_relayList.reserve(count); for (int i = 0; i < count; ++i) { @@ -283,8 +283,10 @@ CMemoryRelays::CMemoryRelays(CInputStream& in /*, const int& unk*/) { } } +void LoadRelays(CInputStream& in, rstl::vector< CRelay >& relays) {} CDummyWorld::~CDummyWorld() {} +#pragma inline_max_size(250) // TOOD nonmatching bool CDummyWorld::ICheckWorldComplete() { switch (x8_phase) { @@ -305,10 +307,7 @@ bool CDummyWorld::ICheckWorldComplete() { r.ReadLong(); } if (version >= 17) { - // TOOD: this class takes some stack argument in r5 - // but I can't figure out what it is - // int unk; - CMemoryRelays relays(r /*, unk*/); + rstl::vector< CRelay > relay(r); } int areaCount = r.Get< int >(); @@ -406,3 +405,5 @@ TAreaId CDummyWorld::IGetAreaId(CAssetId id) const { return TAreaId(-1); #endif } + +rstl::string CDummyWorld::IGetDefaultAudioTrack() const { return rstl::string_l(""); }