From 1a13f7e4ee893f40bda09e18b0a2ac6a1dc43d8e Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 10 Dec 2019 20:51:33 -0800 Subject: [PATCH] Update submodules, initial CTextureCache --- DataSpec/DNAMP1/SFX/Misc.h | 2 +- DataSpec/DNAMP1/SFX/MiscSamus.h | 2 +- DataSpec/DNAMP1/SFX/UI.h | 2 +- DataSpec/DNAMP1/SFX/Weapons.h | 2 +- DataSpec/DNAMP1/SFX/ZZZ.h | 2 +- Editor/ViewManager.cpp | 51 +++++------ Editor/main.cpp | 2 + Runtime/CGameState.cpp | 2 +- Runtime/CGameState.hpp | 3 +- Runtime/CMakeLists.txt | 1 + Runtime/CStateManager.cpp | 2 +- Runtime/CTextureCache.cpp | 28 +++++- Runtime/CTextureCache.hpp | 51 +++++++++-- Runtime/GameGlobalObjects.cpp | 1 + Runtime/GameGlobalObjects.hpp | 1 + Runtime/Graphics/CTexture.hpp | 6 +- Runtime/Graphics/CTextureBoo.cpp | 1 + Runtime/MP1/MP1.cpp | 142 +++++++++++++++++-------------- Runtime/MP1/MP1.hpp | 6 ++ Runtime/MP1/World/CJellyZap.cpp | 20 ++++- 20 files changed, 213 insertions(+), 114 deletions(-) diff --git a/DataSpec/DNAMP1/SFX/Misc.h b/DataSpec/DNAMP1/SFX/Misc.h index 7c3dc9fb3..67c59bdfb 100644 --- a/DataSpec/DNAMP1/SFX/Misc.h +++ b/DataSpec/DNAMP1/SFX/Misc.h @@ -6,7 +6,7 @@ */ -#define GRPgroup0027 39 +#define GRPmisc 39 #define SFXdor_x_close_00 1128 diff --git a/DataSpec/DNAMP1/SFX/MiscSamus.h b/DataSpec/DNAMP1/SFX/MiscSamus.h index f0aa51439..5ec47e9ec 100644 --- a/DataSpec/DNAMP1/SFX/MiscSamus.h +++ b/DataSpec/DNAMP1/SFX/MiscSamus.h @@ -6,7 +6,7 @@ */ -#define GRPgroup0029 41 +#define GRPmiscSamus 41 #define SFXsam_wlkstone_00 1465 diff --git a/DataSpec/DNAMP1/SFX/UI.h b/DataSpec/DNAMP1/SFX/UI.h index 0a7e9538c..10506086d 100644 --- a/DataSpec/DNAMP1/SFX/UI.h +++ b/DataSpec/DNAMP1/SFX/UI.h @@ -6,7 +6,7 @@ */ -#define GRPgroup0028 40 +#define GRPui 40 #define SFXui_map_rotate 1375 diff --git a/DataSpec/DNAMP1/SFX/Weapons.h b/DataSpec/DNAMP1/SFX/Weapons.h index be498bd91..ec2b55f35 100644 --- a/DataSpec/DNAMP1/SFX/Weapons.h +++ b/DataSpec/DNAMP1/SFX/Weapons.h @@ -6,7 +6,7 @@ */ -#define GRPgroup002B 43 +#define GRPweapons 43 #define SFXwpn_bomb_drop 1756 diff --git a/DataSpec/DNAMP1/SFX/ZZZ.h b/DataSpec/DNAMP1/SFX/ZZZ.h index b4c1ec23f..b57352b53 100644 --- a/DataSpec/DNAMP1/SFX/ZZZ.h +++ b/DataSpec/DNAMP1/SFX/ZZZ.h @@ -6,7 +6,7 @@ */ -#define GRPgroup0041 65 +#define GRPzzz 65 #define SFXsfx0C16 3094 diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index e5c4a8ede..883386b28 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -1,5 +1,4 @@ #include "ViewManager.hpp" -#include "specter/Control.hpp" #include "specter/Space.hpp" #include "specter/Menu.hpp" #include "SplashScreen.hpp" @@ -7,16 +6,12 @@ #include "ResourceBrowser.hpp" #include "icons/icons.hpp" #include "badging/Badging.hpp" -#include "Runtime/Particle/CGenDescription.hpp" -#include "Runtime/Particle/CElectricDescription.hpp" -#include "Runtime/Particle/CSwooshDescription.hpp" #include "Runtime/Graphics/CModel.hpp" #include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Character/CSkinRules.hpp" #include "Graphics/CMetroidModelInstance.hpp" #include "World/CWorldTransManager.hpp" #include "Graphics/Shaders/CColoredQuadFilter.hpp" -#include "Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Audio/CStreamAudioManager.hpp" #include "Runtime/CStateManager.hpp" #include "Runtime/World/CPlayer.hpp" @@ -71,27 +66,34 @@ void ViewManager::TestGameView::think() { const hecl::CVar* playerInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.playerInfo"); const hecl::CVar* worldInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.worldInfo"); const hecl::CVar* areaInfo = hecl::CVarManager::instance()->findCVar("debugOverlay.areaInfo"); + const hecl::CVar* showInGameTime = hecl::CVarManager::instance()->findCVar("debugOverlay.showInGameTime"); if (showFrameIdx && showFrameIdx->toBoolean()) overlayText += fmt::format(fmt("Frame: {}\n"), g_StateManager->GetUpdateFrameIndex()); + if (showInGameTime && showInGameTime->toBoolean()) { + double igt = g_GameState->GetTotalPlayTime(); + u32 ms = u64(igt * 1000) % 1000; + auto pt = std::div(igt, 3600); + overlayText += fmt::format(fmt("PlayTime: {:02d}:{:02d}:{:02d}.{:03d}\n"), pt.quot, pt.rem / 60, pt.rem % 60, + ms); + } if (g_StateManager->Player() && playerInfo && playerInfo->toBoolean()) { const CPlayer& pl = g_StateManager->GetPlayer(); const zeus::CQuaternion plQ = zeus::CQuaternion(pl.GetTransform().getRotation().buildMatrix3f()); const zeus::CTransform camXf = g_StateManager->GetCameraManager()->GetCurrentCameraTransform(*g_StateManager); const zeus::CQuaternion camQ = zeus::CQuaternion(camXf.getRotation().buildMatrix3f()); - overlayText += fmt::format(fmt( - "Player Position: x {}, y {}, z {}\n" - " Roll: {}, Pitch: {}, Yaw: {}\n" - " Momentum: x {}, y: {}, z: {}\n" - " Velocity: x {}, y: {}, z: {}\n" - "Camera Position: x {}, y {}, z {}\n" - " Roll: {}, Pitch: {}, Yaw: {}\n"), - pl.GetTranslation().x(), pl.GetTranslation().y(), pl.GetTranslation().z(), - zeus::radToDeg(plQ.roll()), zeus::radToDeg(plQ.pitch()), zeus::radToDeg(plQ.yaw()), - pl.GetMomentum().x(), pl.GetMomentum().y(), pl.GetMomentum().z(), - pl.GetVelocity().x(), pl.GetVelocity().y(), pl.GetVelocity().z(), - camXf.origin.x(), camXf.origin.y(), camXf.origin.z(), - zeus::radToDeg(camQ.roll()), zeus::radToDeg(camQ.pitch()), zeus::radToDeg(camQ.yaw())); + overlayText += + fmt::format(fmt("Player Position: x {}, y {}, z {}\n" + " Roll: {}, Pitch: {}, Yaw: {}\n" + " Momentum: x {}, y: {}, z: {}\n" + " Velocity: x {}, y: {}, z: {}\n" + "Camera Position: x {}, y {}, z {}\n" + " Roll: {}, Pitch: {}, Yaw: {}\n"), + pl.GetTranslation().x(), pl.GetTranslation().y(), pl.GetTranslation().z(), + zeus::radToDeg(plQ.roll()), zeus::radToDeg(plQ.pitch()), zeus::radToDeg(plQ.yaw()), + pl.GetMomentum().x(), pl.GetMomentum().y(), pl.GetMomentum().z(), pl.GetVelocity().x(), + pl.GetVelocity().y(), pl.GetVelocity().z(), camXf.origin.x(), camXf.origin.y(), camXf.origin.z(), + zeus::radToDeg(camQ.roll()), zeus::radToDeg(camQ.pitch()), zeus::radToDeg(camQ.yaw())); } if (worldInfo && worldInfo->toBoolean()) { TLockedToken tbl = @@ -114,11 +116,10 @@ void ViewManager::TestGameView::think() { } else layerBits += "0"; } - overlayText += fmt::format(fmt( - "Area AssetId: 0x{}, Total Objects: {}\n" - "Active Layer bits: {}\n"), - g_StateManager->GetWorld()->GetArea(aId)->GetAreaAssetId(), - g_StateManager->GetAllObjectList().size(), layerBits); + overlayText += fmt::format(fmt("Area AssetId: 0x{}, Total Objects: {}\n" + "Active Layer bits: {}\n"), + g_StateManager->GetWorld()->GetArea(aId)->GetAreaAssetId(), + g_StateManager->GetAllObjectList().size(), layerBits); } if (!overlayText.empty()) @@ -297,8 +298,8 @@ void ViewManager::init(boo::IApplication* app) { if (m_deferedProject.empty()) { /* Default behavior - search upwards for packaged project containing the program */ - if (hecl::ProjectRootPath root = hecl::SearchForProject(ExeDir)) { - hecl::SystemString rootPath(root.getAbsolutePath()); + if (hecl::ProjectRootPath projRoot = hecl::SearchForProject(ExeDir)) { + hecl::SystemString rootPath(projRoot.getAbsolutePath()); hecl::Sstat theStat; if (!hecl::Stat((rootPath + _SYS_STR("/out/files/Metroid1.upak")).c_str(), &theStat) && S_ISREG(theStat.st_mode)) m_deferedProject = rootPath + _SYS_STR("/out"); diff --git a/Editor/main.cpp b/Editor/main.cpp index f423d181b..1aa3eefbf 100644 --- a/Editor/main.cpp +++ b/Editor/main.cpp @@ -125,6 +125,8 @@ struct Application : boo::IApplicationCallback { false, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly); m_cvarManager.findOrMakeCVar("debugOverlay.showFrameCounter"sv, "Displays the current frame index"sv, false, hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly); + m_cvarManager.findOrMakeCVar("debugOverlay.showInGameTime"sv, "Displays the current in game time"sv, false, + hecl::CVar::EFlags::Game | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ReadOnly); } }; diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index 8ad5a942e..21ed49ffc 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -235,7 +235,7 @@ void CGameState::SetCurrentWorldId(CAssetId id) { MP1::CMain::EnsureWorldPakReady(x84_mlvlId); } -void CGameState::SetTotalPlayTime(float time) { xa0_playTime = zeus::clamp(0.0, time, 359999.0); } +void CGameState::SetTotalPlayTime(double time) { xa0_playTime = zeus::clamp(0.0, time, 359999.0); } CWorldState& CGameState::StateForWorld(CAssetId mlvlId) { auto it = x88_worldStates.begin(); diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 0c422a7c6..5790af0d9 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -95,7 +95,8 @@ public: void SetCurrentWorldId(CAssetId id); std::shared_ptr GetPlayerState() const { return x98_playerState; } std::shared_ptr GetWorldTransitionManager() const { return x9c_transManager; } - void SetTotalPlayTime(float time); + void SetTotalPlayTime(double time); + double GetTotalPlayTime() const { return xa0_playTime; } CPersistentOptions& SystemOptions() { return xa8_systemOptions; } CGameOptions& GameOptions() { return x17c_gameOptions; } CHintOptions& HintOptions() { return x1f8_hintOptions; } diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index d19764525..5ce5f49ad 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -117,6 +117,7 @@ set(RUNTIME_SOURCES_B MkCastTo.py TCastTo.hpp TCastTo.cpp GCNTypes.hpp + CTextureCache.hpp CTextureCache.cpp ${PLAT_SRCS}) function(add_runtime_common_library name) diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 3b6611727..7b4d6ac25 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -1859,7 +1859,7 @@ void CStateManager::Update(float dt) { if (x904_gameState == EGameState::Running) { if (!TCastToPtr(x870_cameraManager->GetCurrentCamera(*this))) { - g_GameState->SetTotalPlayTime(g_GameState->xa0_playTime + dt); + g_GameState->SetTotalPlayTime(g_GameState->GetTotalPlayTime() + dt); UpdateHintState(dt); } diff --git a/Runtime/CTextureCache.cpp b/Runtime/CTextureCache.cpp index 54b38e482..85f32da0f 100644 --- a/Runtime/CTextureCache.cpp +++ b/Runtime/CTextureCache.cpp @@ -1,5 +1,25 @@ -// -// Created by antidote on 12/3/19. -// +#include "Runtime/CTextureCache.hpp" +#include "Runtime/CToken.hpp" -#include "CTextureCache.hpp" +namespace urde { +CTextureCache::CTextureCache(CInputStream& in) { + u32 textureCount = in.readUint32Big(); + for (u32 i = 0; i < textureCount; ++i) { + CAssetId uid(in); + if (m_textureInfo.find(uid) == m_textureInfo.end()) + m_textureInfo.emplace(uid, CTextureInfo(in)); + } +} + +const CTextureInfo* CTextureCache::GetTextureInfo(CAssetId id) const { + auto it = m_textureInfo.find(id); + if (it == m_textureInfo.end()) + return nullptr; + return &it->second; +} + +CFactoryFnReturn FTextureCacheFactory(const SObjectTag& tag, CInputStream& in, + const CVParamTransfer& vparms, CObjectReference* selfRef) { + return TToken::GetIObjObjectFor(std::make_unique(in)); +} +} \ No newline at end of file diff --git a/Runtime/CTextureCache.hpp b/Runtime/CTextureCache.hpp index 34ee76414..70364d691 100644 --- a/Runtime/CTextureCache.hpp +++ b/Runtime/CTextureCache.hpp @@ -1,10 +1,47 @@ -// -// Created by antidote on 12/3/19. -// +#pragma once +#include "Runtime/RetroTypes.hpp" +#include "Runtime/Graphics/CTexture.hpp" +namespace urde { +class CPaletteInfo { + u32 m_format; + u32 m_elementCount; + u64 m_dolphinHash; -#ifndef URDE_CTEXTURECACHE_HPP -#define URDE_CTEXTURECACHE_HPP +public: + CPaletteInfo(CInputStream& in) + : m_format(in.readUint32Big()), m_elementCount(in.readUint32Big()), m_dolphinHash(in.readUint64Big()) {} +}; +class CTextureInfo { + ETexelFormat m_format; + u32 m_mipCount; + u16 m_width; + u16 m_height; + u64 m_dolphinHash; + std::optional m_paletteInfo; -class CTextureCache {}; +public: + CTextureInfo(CInputStream& in) + : m_format(ETexelFormat(in.readUint32Big())) + , m_mipCount(in.readUint32Big()) + , m_width(in.readUint16Big()) + , m_height(in.readUint16Big()) + , m_dolphinHash(in.readUint64Big()) { + bool hasPal = in.readBool(); + if (hasPal) + m_paletteInfo.emplace(in); + } +}; +class CTextureCache { +public: + std::map m_textureInfo; -#endif // URDE_CTEXTURECACHE_HPP +public: + CTextureCache(CInputStream& in); + + + const CTextureInfo* GetTextureInfo(CAssetId id) const; +}; + +CFactoryFnReturn FTextureCacheFactory(const urde::SObjectTag& tag, CInputStream& in, + const urde::CVParamTransfer& vparms, CObjectReference* selfRef); +} \ No newline at end of file diff --git a/Runtime/GameGlobalObjects.cpp b/Runtime/GameGlobalObjects.cpp index da785f78f..a9e78105c 100644 --- a/Runtime/GameGlobalObjects.cpp +++ b/Runtime/GameGlobalObjects.cpp @@ -15,6 +15,7 @@ class CGameState* g_GameState = nullptr; class CInGameTweakManagerBase* g_TweakManager = nullptr; class CBooRenderer* g_Renderer = nullptr; class CStringTable* g_MainStringTable = nullptr; +class CTextureCache* g_TextureCache = nullptr; class CInputGenerator* g_InputGenerator = nullptr; class CStateManager* g_StateManager = nullptr; diff --git a/Runtime/GameGlobalObjects.hpp b/Runtime/GameGlobalObjects.hpp index 3093aaeac..9f940c0bf 100644 --- a/Runtime/GameGlobalObjects.hpp +++ b/Runtime/GameGlobalObjects.hpp @@ -48,6 +48,7 @@ extern class CGameState* g_GameState; extern class CInGameTweakManagerBase* g_TweakManager; extern class CBooRenderer* g_Renderer; extern class CStringTable* g_MainStringTable; +extern class CTextureCache* g_TextureCache; extern class CInputGenerator* g_InputGenerator; extern class CStateManager* g_StateManager; diff --git a/Runtime/Graphics/CTexture.hpp b/Runtime/Graphics/CTexture.hpp index 9e79bf6b0..fc0569cc6 100644 --- a/Runtime/Graphics/CTexture.hpp +++ b/Runtime/Graphics/CTexture.hpp @@ -13,6 +13,7 @@ namespace urde { class CVParamTransfer; +class CTextureInfo; class CTexture { public: @@ -35,7 +36,7 @@ private: boo::ObjToken m_paletteTex; std::unique_ptr m_otex; EFontType m_ftype = EFontType::None; - std::string m_dolphinName; + const CTextureInfo* m_textureInfo; size_t ComputeMippedTexelCount() const; size_t ComputeMippedBlockCountDXT1() const; @@ -73,8 +74,7 @@ public: std::unique_ptr BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr& paletteOut) const; const boo::ObjToken& GetFontTexture(EFontType tp); - std::string_view GetDolphinName() const { return m_dolphinName; } - bool HasDolphinName() const { return !m_dolphinName.empty(); } + const CTextureInfo* GetTextureInfo() const { return m_textureInfo; } }; CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, std::unique_ptr&& in, u32 len, diff --git a/Runtime/Graphics/CTextureBoo.cpp b/Runtime/Graphics/CTextureBoo.cpp index ae3f13fb4..3ba2646ac 100644 --- a/Runtime/Graphics/CTextureBoo.cpp +++ b/Runtime/Graphics/CTextureBoo.cpp @@ -2,6 +2,7 @@ #include "CSimplePool.hpp" #include "CToken.hpp" #include "Graphics/CGraphics.hpp" +#include "Runtime/CTextureCache.hpp" namespace urde { static logvisor::Module Log("urde::CTextureBoo"); diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 21c41fe5d..3491e9d00 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -1,64 +1,69 @@ -#include "MP1.hpp" -#include "Graphics/Shaders/CModelShaders.hpp" -#include "Graphics/Shaders/CThermalColdFilter.hpp" -#include "Graphics/Shaders/CThermalHotFilter.hpp" -#include "Graphics/Shaders/CSpaceWarpFilter.hpp" -#include "Graphics/Shaders/CColoredQuadFilter.hpp" -#include "Graphics/Shaders/CColoredStripShader.hpp" -#include "Graphics/Shaders/CTexturedQuadFilter.hpp" -#include "Graphics/Shaders/CCameraBlurFilter.hpp" -#include "Graphics/Shaders/CXRayBlurFilter.hpp" -#include "Graphics/Shaders/CTextSupportShader.hpp" -#include "Graphics/Shaders/CEnergyBarShader.hpp" -#include "Graphics/Shaders/CRadarPaintShader.hpp" -#include "Graphics/Shaders/CMapSurfaceShader.hpp" -#include "Graphics/Shaders/CPhazonSuitFilter.hpp" -#include "Graphics/Shaders/CScanLinesFilter.hpp" -#include "Graphics/Shaders/CRandomStaticFilter.hpp" -#include "Graphics/Shaders/CFluidPlaneShader.hpp" -#include "Graphics/Shaders/CAABoxShader.hpp" -#include "Graphics/Shaders/CWorldShadowShader.hpp" -#include "Graphics/Shaders/CParticleSwooshShaders.hpp" -#include "Graphics/Shaders/CEnvFxShaders.hpp" -#include "NESEmulator/CNESShader.hpp" -#include "Audio/CStreamAudioManager.hpp" -#include "CGBASupport.hpp" +#include "Runtime/MP1/MP1.hpp" -#include "CGameHintInfo.hpp" -#include "Particle/CParticleDataFactory.hpp" -#include "Particle/CGenDescription.hpp" -#include "Particle/CElectricDescription.hpp" -#include "Particle/CSwooshDescription.hpp" -#include "Particle/CParticleElectricDataFactory.hpp" -#include "Particle/CParticleSwooshDataFactory.hpp" -#include "Particle/CWeaponDescription.hpp" -#include "Particle/CProjectileWeaponDataFactory.hpp" -#include "Particle/CDecalDataFactory.hpp" -#include "GuiSys/CGuiFrame.hpp" -#include "GuiSys/CRasterFont.hpp" -#include "GuiSys/CStringTable.hpp" -#include "Graphics/CModel.hpp" -#include "Graphics/CTexture.hpp" -#include "Character/CCharLayoutInfo.hpp" -#include "Character/CSkinRules.hpp" -#include "Character/CAnimCharacterSet.hpp" -#include "Character/CAllFormatsAnimSource.hpp" -#include "Character/CAnimPOIData.hpp" -#include "Collision/CCollidableOBBTreeGroup.hpp" -#include "Collision/CCollisionResponseData.hpp" -#include "CSaveWorld.hpp" -#include "AutoMapper/CMapWorld.hpp" -#include "AutoMapper/CMapArea.hpp" -#include "AutoMapper/CMapUniverse.hpp" -#include "World/CStateMachine.hpp" -#include "CScannableObjectInfo.hpp" -#include "Audio/CAudioGroupSet.hpp" -#include "Audio/CSfxManager.hpp" -#include "Audio/CMidiManager.hpp" -#include "CDependencyGroup.hpp" -#include "CStateManager.hpp" -#include "World/CPlayer.hpp" -#include "CStopwatch.hpp" +#include "Runtime/Graphics/Shaders/CModelShaders.hpp" +#include "Runtime/Graphics/Shaders/CThermalColdFilter.hpp" +#include "Runtime/Graphics/Shaders/CThermalHotFilter.hpp" +#include "Runtime/Graphics/Shaders/CSpaceWarpFilter.hpp" +#include "Runtime/Graphics/Shaders/CColoredQuadFilter.hpp" +#include "Runtime/Graphics/Shaders/CColoredStripShader.hpp" +#include "Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp" +#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp" +#include "Runtime/Graphics/Shaders/CXRayBlurFilter.hpp" +#include "Runtime/Graphics/Shaders/CTextSupportShader.hpp" +#include "Runtime/Graphics/Shaders/CEnergyBarShader.hpp" +#include "Runtime/Graphics/Shaders/CRadarPaintShader.hpp" +#include "Runtime/Graphics/Shaders/CMapSurfaceShader.hpp" +#include "Runtime/Graphics/Shaders/CPhazonSuitFilter.hpp" +#include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp" +#include "Runtime/Graphics/Shaders/CRandomStaticFilter.hpp" +#include "Runtime/Graphics/Shaders/CFluidPlaneShader.hpp" +#include "Runtime/Graphics/Shaders/CAABoxShader.hpp" +#include "Runtime/Graphics/Shaders/CWorldShadowShader.hpp" +#include "Runtime/Graphics/Shaders/CParticleSwooshShaders.hpp" +#include "Runtime/Graphics/Shaders/CEnvFxShaders.hpp" +#include "NESEmulator/CNESShader.hpp" +#include "Runtime/Audio/CStreamAudioManager.hpp" +#include "Runtime/MP1/CGBASupport.hpp" + +#include "Runtime/CGameHintInfo.hpp" +#include "Runtime/Particle/CParticleDataFactory.hpp" +#include "Runtime/Particle/CParticleElectricDataFactory.hpp" +#include "Runtime/Particle/CParticleSwooshDataFactory.hpp" +#include "Runtime/Particle/CWeaponDescription.hpp" +#include "Runtime/Particle/CProjectileWeaponDataFactory.hpp" +#include "Runtime/Particle/CDecalDataFactory.hpp" +#include "Runtime/GuiSys/CGuiFrame.hpp" +#include "Runtime/GuiSys/CRasterFont.hpp" +#include "Runtime/GuiSys/CStringTable.hpp" +#include "Runtime/Graphics/CModel.hpp" +#include "Runtime/Graphics/CTexture.hpp" +#include "Runtime/Character/CCharLayoutInfo.hpp" +#include "Runtime/Character/CSkinRules.hpp" +#include "Runtime/Character/CAnimCharacterSet.hpp" +#include "Runtime/Character/CAllFormatsAnimSource.hpp" +#include "Runtime/Character/CAnimPOIData.hpp" +#include "Runtime/Collision/CCollidableOBBTreeGroup.hpp" +#include "Runtime/Collision/CCollisionResponseData.hpp" +#include "Runtime/CTextureCache.hpp" +#include "Runtime/CSaveWorld.hpp" +#include "Runtime/AutoMapper/CMapWorld.hpp" +#include "Runtime/AutoMapper/CMapArea.hpp" +#include "Runtime/AutoMapper/CMapUniverse.hpp" +#include "Runtime/World/CStateMachine.hpp" +#include "Runtime/CScannableObjectInfo.hpp" +#include "Runtime/Audio/CAudioGroupSet.hpp" +#include "Runtime/Audio/CSfxManager.hpp" +#include "Runtime/Audio/CMidiManager.hpp" +#include "Runtime/CDependencyGroup.hpp" +#include "Runtime/CStateManager.hpp" +#include "Runtime/World/CPlayer.hpp" +#include "Runtime/CStopwatch.hpp" + +#include +#include +#include +#include +#include #include namespace hecl { @@ -126,8 +131,11 @@ struct AudioGroupInfo { u32 id; }; -static const AudioGroupInfo StaticAudioGroups[] = { - {"Misc_AGSC", 39}, {"MiscSamus_AGSC", 41}, {"UI_AGSC", 40}, {"Weapons_AGSC", 43}, {"ZZZ_AGSC", 65}}; +static const AudioGroupInfo StaticAudioGroups[] = {{"Misc_AGSC", GRPmisc}, + {"MiscSamus_AGSC", GRPmiscSamus}, + {"UI_AGSC", GRPui}, + {"Weapons_AGSC", GRPweapons}, + {"ZZZ_AGSC", GRPzzz}}; bool CGameArchitectureSupport::LoadAudio() { if (x88_audioLoadStatus == EAudioLoadStatus::Loaded) @@ -270,7 +278,6 @@ void CGameGlobalObjects::AddPaksAndFactories() { loader->AddPakFileAsync("SamGunFx", true, false); loader->AddPakFileAsync("MidiData", false, false); loader->AddPakFileAsync("GGuiSys", false, false); - loader->AddPakFileAsync("!original_ids", false, false); loader->WaitForPakFileLoadingComplete(); } @@ -304,6 +311,7 @@ void CGameGlobalObjects::AddPaksAndFactories() { fmgr->AddFactory(FOURCC('MAPU'), FFactoryFunc(FMapUniverseFactory)); fmgr->AddFactory(FOURCC('AFSM'), FFactoryFunc(FAiFiniteStateMachineFactory)); fmgr->AddFactory(FOURCC('PATH'), FMemFactoryFunc(FPathFindAreaFactory)); + fmgr->AddFactory(FOURCC('TMET'), FFactoryFunc(FTextureCacheFactory)); } } @@ -338,12 +346,20 @@ void CMain::AddOverridePaks() { if (!loader) return; + /* Inversely load each pak starting at 999, to ensure proper priority order + * the higher the number the higer the priority, e.g: Override0 has less priority than Override1 etc. + */ for (size_t i = 999; i > 0; --i) { std::string path = fmt::format(fmt("Override{}"), i); if (CDvdFile::FileExists((path + ".upak").c_str())) loader->AddPakFileAsync(path, false, false, true); } + /* Make sure all Override paks are ready before attempting to load URDE.upak */ + loader->WaitForPakFileLoadingComplete(); + /* Attempt to load URDE.upak + * NOTE(phil): Should we fatal here if it's not found? + */ if (CDvdFile::FileExists("URDE.upak")) loader->AddPakFile("URDE", false, false, true); } diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index 939c090ff..bfcb8b5d0 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -61,11 +61,16 @@ class CGameGlobalObjects { TLockedToken x13c_mainStringTable; CInGameTweakManager x150_tweakManager; std::unique_ptr m_renderer; + TLockedToken m_textureCache; void LoadStringTable() { x13c_mainStringTable = g_SimplePool->GetObj("STRG_Main"); g_MainStringTable = x13c_mainStringTable.GetObj(); } + void LoadTextureCache() { + m_textureCache = g_SimplePool->GetObj("TextureCache"sv); + g_TextureCache = m_textureCache.GetObj(); + } void AddPaksAndFactories(); static IRenderer* AllocateRenderer(IObjectStore& store, IFactory& resFactory) { g_Renderer = new CBooRenderer(store, resFactory); @@ -96,6 +101,7 @@ public: void PostInitialize() { AddPaksAndFactories(); + LoadTextureCache(); LoadStringTable(); m_renderer.reset(AllocateRenderer(*xcc_simplePool, *x4_resFactory)); CEnvFxManager::Initialize(); diff --git a/Runtime/MP1/World/CJellyZap.cpp b/Runtime/MP1/World/CJellyZap.cpp index 092b4d5b8..449a23556 100644 --- a/Runtime/MP1/World/CJellyZap.cpp +++ b/Runtime/MP1/World/CJellyZap.cpp @@ -50,7 +50,7 @@ void CJellyZap::Think(float dt, CStateManager& mgr) { if (!GetActive()) return; if (x5b8_24_) - x450_bodyController->FaceDirection(GetTranslation() - mgr.GetPlayer().GetTranslation(), dt); + x450_bodyController->FaceDirection(mgr.GetPlayer().GetTranslation() - GetTranslation(), dt); float fv = (x5b8_25_ && x450_bodyController->GetPercentageFrozen() == 0.f ? x50c_baseDamageMag + (dt / 0.3f) : x50c_baseDamageMag - (dt / 0.75f)); @@ -96,9 +96,21 @@ void CJellyZap::Suck(CStateManager& mgr, EStateMsg msg, float arg) { x32c_animState = EAnimState::Ready; RemoveAllAttractors(mgr); } else if (msg == EStateMsg::Update) { - + TryCommand(mgr, pas::EAnimationState::LoopReaction, &CPatterned::TryLoopReaction, 0); + x450_bodyController->GetCommandMgr().SetTargetVector( + (mgr.GetPlayer().GetTranslation() + zeus::CVector3f(0.f, 0.f, 1.f)) - GetTranslation()); + zeus::CVector3f diff = (mgr.GetPlayer().GetTranslation() - GetTranslation()); + float f1 = diff.magnitude(); + float f3 = 5.f; + float f2 = x58c_; + if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed) + f2 = x594_; + else if (mgr.GetPlayerState()->GetCurrentSuitRaw() == CPlayerState::EPlayerSuit::Gravity) + f2 = x590_; + float f4 = f3 * f2; + float f5 = 1.f / f1; + } else if (msg == EStateMsg::Deactivate) { - } } @@ -110,7 +122,7 @@ void CJellyZap::Active(CStateManager& mgr, EStateMsg msg, float arg) { x330_stateMachineState.SetDelay(x3d0_playerLeashTime); } else if (msg == EStateMsg::Update) { zeus::CVector3f targetVector = - GetTranslation() - (zeus::CVector3f(0.f, 0.f, 1.f) + mgr.GetPlayer().GetTranslation()); + GetTranslation() - (zeus::CVector3f(0.f, 0.f, 1.f) + mgr.GetPlayer().GetTranslation()); x450_bodyController->GetCommandMgr().SetTargetVector(targetVector); if (x5b8_26_) { zeus::CVector3f moveToImpulse =