diff --git a/asm/MetroidPrime/CStateManager.s b/asm/MetroidPrime/CStateManager.s index 7edcb380..13975c59 100644 --- a/asm/MetroidPrime/CStateManager.s +++ b/asm/MetroidPrime/CStateManager.s @@ -1334,7 +1334,7 @@ lbl_800449E8: /* 800449F8 00041958 7C 7E 1B 79 */ or. r30, r3, r3 /* 800449FC 0004195C 41 82 00 14 */ beq lbl_80044A10 /* 80044A00 00041960 7F A4 EB 78 */ mr r4, r29 -/* 80044A04 00041964 48 10 CE 65 */ bl ShouldSkipCinematic__22CScriptSpecialFunctionFR13CStateManager +/* 80044A04 00041964 48 10 CE 65 */ bl ShouldSkipCinematic__22CScriptSpecialFunctionCFR13CStateManager /* 80044A08 00041968 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 80044A0C 0004196C 40 82 00 0C */ bne lbl_80044A18 lbl_80044A10: diff --git a/asm/MetroidPrime/Player/CGameState.s b/asm/MetroidPrime/Player/CGameState.s index 4774d5c0..a8265168 100644 --- a/asm/MetroidPrime/Player/CGameState.s +++ b/asm/MetroidPrime/Player/CGameState.s @@ -2203,8 +2203,8 @@ lbl_801D54FC: /* 801D5520 001D2480 38 21 00 10 */ addi r1, r1, 0x10 /* 801D5524 001D2484 4E 80 00 20 */ blr -.global "GetCinematicState__14CSystemOptionsFRCQ24rstl19pair" -"GetCinematicState__14CSystemOptionsFRCQ24rstl19pair": +.global "GetCinematicState__14CSystemOptionsCFQ24rstl19pair" +"GetCinematicState__14CSystemOptionsCFQ24rstl19pair": /* 801D5528 001D2488 80 03 00 B0 */ lwz r0, 0xb0(r3) /* 801D552C 001D248C 80 E3 00 B8 */ lwz r7, 0xb8(r3) /* 801D5530 001D2490 54 00 18 38 */ slwi r0, r0, 3 @@ -2422,7 +2422,7 @@ lbl_801D583C: /* 801D584C 001D27AC 90 01 00 1C */ stw r0, 0x1c(r1) /* 801D5850 001D27B0 93 21 00 20 */ stw r25, 0x20(r1) /* 801D5854 001D27B4 90 01 00 24 */ stw r0, 0x24(r1) -/* 801D5858 001D27B8 4B FF FC D1 */ bl "GetCinematicState__14CSystemOptionsFRCQ24rstl19pair" +/* 801D5858 001D27B8 4B FF FC D1 */ bl "GetCinematicState__14CSystemOptionsCFQ24rstl19pair" /* 801D585C 001D27BC 80 01 00 58 */ lwz r0, 0x58(r1) /* 801D5860 001D27C0 7C 74 1B 78 */ mr r20, r3 /* 801D5864 001D27C4 80 A1 00 5C */ lwz r5, 0x5c(r1) @@ -3363,4 +3363,3 @@ lbl_803D1B88: # ROM: 0x3CEB88 .asciz "??(??)" .balign 4 - diff --git a/asm/MetroidPrime/ScriptObjects/CScriptSpecialFunction.s b/asm/MetroidPrime/ScriptObjects/CScriptSpecialFunction.s index 53ae372f..8d1efea8 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptSpecialFunction.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptSpecialFunction.s @@ -2912,8 +2912,8 @@ SkipCinematic__22CScriptSpecialFunctionFR13CStateManager: /* 80151860 0014E7C0 38 21 00 20 */ addi r1, r1, 0x20 /* 80151864 0014E7C4 4E 80 00 20 */ blr -.global ShouldSkipCinematic__22CScriptSpecialFunctionFR13CStateManager -ShouldSkipCinematic__22CScriptSpecialFunctionFR13CStateManager: +.global ShouldSkipCinematic__22CScriptSpecialFunctionCFR13CStateManager +ShouldSkipCinematic__22CScriptSpecialFunctionCFR13CStateManager: /* 80151868 0014E7C8 94 21 FF E0 */ stwu r1, -0x20(r1) /* 8015186C 0014E7CC 7C 08 02 A6 */ mflr r0 /* 80151870 0014E7D0 90 01 00 24 */ stw r0, 0x24(r1) @@ -2927,7 +2927,7 @@ ShouldSkipCinematic__22CScriptSpecialFunctionFR13CStateManager: /* 80151890 0014E7F0 90 01 00 0C */ stw r0, 0xc(r1) /* 80151894 0014E7F4 90 A1 00 10 */ stw r5, 0x10(r1) /* 80151898 0014E7F8 90 01 00 14 */ stw r0, 0x14(r1) -/* 8015189C 0014E7FC 48 08 3C 8D */ bl "GetCinematicState__14CSystemOptionsFRCQ24rstl19pair" +/* 8015189C 0014E7FC 48 08 3C 8D */ bl "GetCinematicState__14CSystemOptionsCFQ24rstl19pair" /* 801518A0 0014E800 80 01 00 24 */ lwz r0, 0x24(r1) /* 801518A4 0014E804 7C 08 03 A6 */ mtlr r0 /* 801518A8 0014E808 38 21 00 20 */ addi r1, r1, 0x20 @@ -3579,7 +3579,7 @@ lbl_801521C4: /* 801521C8 0014F128 40 82 00 2C */ bne lbl_801521F4 /* 801521CC 0014F12C 7F E3 FB 78 */ mr r3, r31 /* 801521D0 0014F130 7F C4 F3 78 */ mr r4, r30 -/* 801521D4 0014F134 4B FF F6 95 */ bl ShouldSkipCinematic__22CScriptSpecialFunctionFR13CStateManager +/* 801521D4 0014F134 4B FF F6 95 */ bl ShouldSkipCinematic__22CScriptSpecialFunctionCFR13CStateManager /* 801521D8 0014F138 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 801521DC 0014F13C 41 82 06 C4 */ beq lbl_801528A0 /* 801521E0 0014F140 A0 1F 00 08 */ lhz r0, 8(r31) diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index 9e2c2d3c..dea89c7c 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -5,8 +5,11 @@ #include "Kyoto/CObjectReference.hpp" #include "Kyoto/CRandom16.hpp" +#include "Kyoto/Math/CVector2f.hpp" #include "Kyoto/Math/CVector2i.hpp" +#include "Kyoto/TOneStatic.hpp" #include "Kyoto/TToken.hpp" + #include "MetroidPrime/CEntityInfo.hpp" #include "MetroidPrime/CObjectList.hpp" #include "MetroidPrime/TGameTypes.hpp" @@ -60,13 +63,19 @@ enum EStateManagerTransition { kSMT_MessageScreen }; +enum EThermalDrawFlag { + kTD_Hot, + kTD_Cold, + kTD_Bypass, +}; + struct SOnScreenTex { CAssetId x0_id; CVector2i x4_origin; CVector2i xc_extent; }; -class CStateManager { +class CStateManager : public TOneStatic< CStateManager > { public: void ResetEscapeSequenceTimer(float); void SendScriptMsg(TUniqueId uid, TEditorId target, EScriptObjectMessage msg, @@ -136,8 +145,7 @@ public: const SOnScreenTex& GetPendingScreenTex() const { return xef4_pendingScreenTex; } void SetShouldQuitGame(bool should) { xf94_25_quitGame = should; } - void SetSkipCinematicSpecialFunction(TUniqueId id) { /*xf38_skipCineSpecialFunc = id;*/ - } + void SetSkipCinematicSpecialFunction(TUniqueId id) { xf38_skipCineSpecialFunc = id; } void SetInSaveUI(bool b) { xf94_28_inSaveUI = b; } bool GetInSaveUI() const { return xf94_28_inSaveUI; } void SetIsFullThreat(bool v) { xf94_30_fullThreat = v; } @@ -177,17 +185,36 @@ private: rstl::vector< CLight > x8e0_dynamicLights; TLockedToken< CTexture > x8f0_shadowTex; + CRandom16 x8fc_random; CRandom16* x900_random; u8 x904_pad[0x5f0]; SOnScreenTex xef4_pendingScreenTex; - - u8 xf08_pad[0x1C]; - + CAssetId xf08_pauseHudMessage; + f32 xf0c_escapeTimer; + f32 xf10_escapeTotalTime; + f32 xf14_curTimeMod900; + TUniqueId xf18_bossId; + f32 xf1c_totalBossEnergy; + uint xf20_bossStringIdx; f32 xf24_thermColdScale1; f32 xf28_thermColdScale2; - u8 pad3[0x68]; + CVector2f xf2c_viewportScale; + EThermalDrawFlag xf34_thermalFlag; + TUniqueId xf38_skipCineSpecialFunc; + rstl::list< TUniqueId > xf3c_activeFlickerBats; + rstl::list< TUniqueId > xf54_activeParasites; + TUniqueId xf6c_playerActorHead; + rstl::single_ptr< CMazeState > xf70_currentMaze; + TUniqueId xf74_lastTrigger; + TUniqueId xf76_lastRelay; + f32 xf78_hudMessageTime; + unkptr xf7c_projectedShadow; + uint xf80_hudMessageFrameCount; + CAssetId xf84_; + CAssetId xf88_; + f32 xf8c_; EStateManagerTransition xf90_deferredTransition; bool xf94_24_readyToRender : 1; bool xf94_25_quitGame : 1; @@ -197,5 +224,6 @@ private: bool xf94_29_cinematicPause : 1; bool xf94_30_fullThreat : 1; }; +CHECK_SIZEOF(CStateManager, 0xf98) #endif diff --git a/include/MetroidPrime/Player/CSystemOptions.hpp b/include/MetroidPrime/Player/CSystemOptions.hpp index 573f6c8a..2e22b9cc 100644 --- a/include/MetroidPrime/Player/CSystemOptions.hpp +++ b/include/MetroidPrime/Player/CSystemOptions.hpp @@ -16,8 +16,8 @@ public: void SetHasFusion(bool v); bool GetHasFusion() const { return xd0_28_fusionSuitActive; } - bool GetCinematicState(CAssetId mlvlId, TEditorId cineId) const; - void SetCinematicState(CAssetId mlvlId, TEditorId cineId, bool state); + bool GetCinematicState(rstl::pair< CAssetId, TEditorId > cineId) const; + void SetCinematicState(rstl::pair< CAssetId, TEditorId > cineId, bool state); private: rstl::reserved_vector< u8, 98 > x0_nesState; diff --git a/include/rstl/pair.hpp b/include/rstl/pair.hpp index dd51533f..4d617fff 100644 --- a/include/rstl/pair.hpp +++ b/include/rstl/pair.hpp @@ -9,11 +9,6 @@ class pair { public: inline pair() {} inline pair(const L& first, const R& second) : first(first), second(second) {} - inline pair(const pair& other) : first(other.first), second(other.second) {} - inline void operator=(const pair& other) { - first = other.first; - second = other.second; - } L first; R second; diff --git a/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp b/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp index 09c95cc1..6b0fc0e6 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp @@ -405,8 +405,9 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId } } else if (msg == kSM_Decrement) { mgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId); - gpGameState->SystemOptions().SetCinematicState(mgr.GetWorld()->GetWorldAssetId(), - GetEditorId(), true); + gpGameState->SystemOptions().SetCinematicState( + rstl::pair< CAssetId, TEditorId >(mgr.GetWorld()->GetWorldAssetId(), GetEditorId()), + true); } break; } @@ -562,14 +563,16 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId } } -bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const { - return gpGameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), - GetEditorId()); +bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& mgr) const { + CAssetId mlvlId = mgr.GetWorld()->GetWorldAssetId(); + TEditorId cineId = GetEditorId(); + return gpGameState->SystemOptions().GetCinematicState( + rstl::pair< CAssetId, TEditorId >(mlvlId, cineId)); } -void CScriptSpecialFunction::SkipCinematic(CStateManager& stateMgr) { - SendScriptMsgs(kSS_Zero, stateMgr, kSM_None); - stateMgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId); +void CScriptSpecialFunction::SkipCinematic(CStateManager& mgr) { + SendScriptMsgs(kSS_Zero, mgr, kSM_None); + mgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId); } void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(*this); } @@ -578,25 +581,26 @@ void CScriptSpecialFunction::RingScramble(CStateManager& mgr) { SendScriptMsgs(kSS_Zero, mgr, kSM_None); x1a8_ringState = kRS_Scramble; x1b8_ringReverse = !x1b8_ringReverse; - float dir = (x1b8_ringReverse ? 1.f : -1.f); - for (rstl::vector< SRingController >::iterator it = x198_ringControllers.begin(); - it != x198_ringControllers.end(); ++it) { - it->x4_rotateSpeed = dir * mgr.GetActiveRandom()->Range(x100_float2, x104_float3); + float dir = x1b8_ringReverse ? 1.f : -1.f; + for (int i = 0; i < x198_ringControllers.size(); ++i) { + x198_ringControllers[i].x4_rotateSpeed = + dir * mgr.GetActiveRandom()->Range(x100_float2, x104_float3); dir = -dir; - it->x8_reachedTarget = false; + x198_ringControllers[i].x8_reachedTarget = false; } } void CScriptSpecialFunction::ThinkSaveStation(float, CStateManager& mgr) { - if (!x1e5_24_doSave || mgr.GetDeferredStateTransition() == kSMT_SaveGame) { + if (!x1e5_24_doSave) { return; } - - x1e5_24_doSave = false; - if (mgr.GetInSaveUI()) { - SendScriptMsgs(kSS_MaxReached, mgr, kSM_None); - } else { - SendScriptMsgs(kSS_Zero, mgr, kSM_None); + if (mgr.GetDeferredStateTransition() != kSMT_SaveGame) { + x1e5_24_doSave = false; + if (mgr.GetInSaveUI()) { + SendScriptMsgs(kSS_MaxReached, mgr, kSM_None); + } else { + SendScriptMsgs(kSS_Zero, mgr, kSM_None); + } } }