diff --git a/asm/MetroidPrime/CMFGame.s b/asm/MetroidPrime/CMFGame.s index f55cb4ad..cbfbd98b 100644 --- a/asm/MetroidPrime/CMFGame.s +++ b/asm/MetroidPrime/CMFGame.s @@ -740,7 +740,7 @@ lbl_80024258: /* 800242C0 00021220 38 E0 00 00 */ li r7, 0 /* 800242C4 00021224 C0 42 83 04 */ lfs f2, lbl_805AA024@sda21(r2) /* 800242C8 00021228 C0 62 83 08 */ lfs f3, lbl_805AA028@sda21(r2) -/* 800242CC 0002122C 48 1E 53 25 */ bl EnableTransition__18CWorldTransManagerFviibbfff +/* 800242CC 0002122C 48 1E 53 25 */ bl EnableTransition__18CWorldTransManagerFiiibfff lbl_800242D0: /* 800242D0 00021230 80 6D A0 80 */ lwz r3, gpGameState@sda21(r13) /* 800242D4 00021234 48 1A F6 FD */ bl CurrentWorldAssetId__10CGameStateCFv @@ -777,7 +777,7 @@ lbl_800242D0: /* 80024350 000212B0 C0 22 83 00 */ lfs f1, lbl_805AA020@sda21(r2) /* 80024354 000212B4 C0 42 83 04 */ lfs f2, lbl_805AA024@sda21(r2) /* 80024358 000212B8 C0 62 83 08 */ lfs f3, lbl_805AA028@sda21(r2) -/* 8002435C 000212BC 48 1E 52 95 */ bl EnableTransition__18CWorldTransManagerFviibbfff +/* 8002435C 000212BC 48 1E 52 95 */ bl EnableTransition__18CWorldTransManagerFiiibfff lbl_80024360: /* 80024360 000212C0 88 1F 00 2C */ lbz r0, 0x2c(r31) /* 80024364 000212C4 38 60 00 01 */ li r3, 1 diff --git a/asm/MetroidPrime/CWorldTransManager.s b/asm/MetroidPrime/CWorldTransManager.s index 63d53015..2e209d09 100644 --- a/asm/MetroidPrime/CWorldTransManager.s +++ b/asm/MetroidPrime/CWorldTransManager.s @@ -629,8 +629,8 @@ lbl_802095D4: /* 802095E8 00206548 38 21 00 40 */ addi r1, r1, 0x40 /* 802095EC 0020654C 4E 80 00 20 */ blr -.global EnableTransition__18CWorldTransManagerFviibbfff -EnableTransition__18CWorldTransManagerFviibbfff: +.global EnableTransition__18CWorldTransManagerFiiibfff +EnableTransition__18CWorldTransManagerFiiibfff: /* 802095F0 00206550 94 21 FF 80 */ stwu r1, -0x80(r1) /* 802095F4 00206554 7C 08 02 A6 */ mflr r0 /* 802095F8 00206558 90 01 00 84 */ stw r0, 0x84(r1) @@ -874,15 +874,15 @@ lbl_80209948: /* 8020995C 002068BC 38 21 00 20 */ addi r1, r1, 0x20 /* 80209960 002068C0 4E 80 00 20 */ blr -.global sub_80209964 -sub_80209964: +.global SetSfx__18CWorldTransManagerFUsUcUc +SetSfx__18CWorldTransManagerFUsUcUc: /* 80209964 002068C4 B0 83 00 24 */ sth r4, 0x24(r3) /* 80209968 002068C8 98 A3 00 2C */ stb r5, 0x2c(r3) /* 8020996C 002068CC 98 C3 00 2D */ stb r6, 0x2d(r3) /* 80209970 002068D0 4E 80 00 20 */ blr -.global sub_80209974 -sub_80209974: +.global SfxStop__18CWorldTransManagerFv +SfxStop__18CWorldTransManagerFv: /* 80209974 002068D4 94 21 FF E0 */ stwu r1, -0x20(r1) /* 80209978 002068D8 7C 08 02 A6 */ mflr r0 /* 8020997C 002068DC 90 01 00 24 */ stw r0, 0x24(r1) @@ -904,8 +904,8 @@ lbl_802099AC: /* 802099B8 00206918 38 21 00 20 */ addi r1, r1, 0x20 /* 802099BC 0020691C 4E 80 00 20 */ blr -.global sub_802099c0 -sub_802099c0: +.global SfxStart__18CWorldTransManagerFv +SfxStart__18CWorldTransManagerFv: /* 802099C0 00206920 94 21 FF E0 */ stwu r1, -0x20(r1) /* 802099C4 00206924 7C 08 02 A6 */ mflr r0 /* 802099C8 00206928 90 01 00 24 */ stw r0, 0x24(r1) diff --git a/asm/MetroidPrime/ScriptLoader.s b/asm/MetroidPrime/ScriptLoader.s index 6832f933..80bee355 100644 --- a/asm/MetroidPrime/ScriptLoader.s +++ b/asm/MetroidPrime/ScriptLoader.s @@ -8713,7 +8713,7 @@ lbl_800CCF34: /* 800CCFA4 000C9F04 38 A1 00 80 */ addi r5, r1, 0x80 /* 800CCFA8 000C9F08 92 C1 00 14 */ stw r22, 0x14(r1) /* 800CCFAC 000C9F0C 93 E1 00 18 */ stw r31, 0x18(r1) -/* 800CCFB0 000C9F10 48 10 9C 15 */ bl "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUiUiRC9CVector3fUiRC9CVector3fUiRC9CVector3fb" +/* 800CCFB0 000C9F10 48 10 9C 15 */ bl "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUsUcUcUiUibfff" /* 800CCFB4 000C9F14 7C 6E 1B 78 */ mr r14, r3 lbl_800CCFB8: /* 800CCFB8 000C9F18 38 61 00 80 */ addi r3, r1, 0x80 @@ -8758,7 +8758,7 @@ lbl_800CCFC8: /* 800CD050 000C9FB0 93 41 00 28 */ stw r26, 0x28(r1) /* 800CD054 000C9FB4 93 21 00 2C */ stw r25, 0x2c(r1) /* 800CD058 000C9FB8 93 01 00 30 */ stw r24, 0x30(r1) -/* 800CD05C 000C9FBC 48 10 9C E5 */ bl "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" +/* 800CD05C 000C9FBC 48 10 9C E5 */ bl "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUiUiUiRC9CVector3fUiRC9CVector3fUiRC9CVector3fbUsUcUc" /* 800CD060 000C9FC0 7C 70 1B 78 */ mr r16, r3 lbl_800CD064: /* 800CD064 000C9FC4 38 61 00 80 */ addi r3, r1, 0x80 diff --git a/asm/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.s b/asm/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.s index 3464c08f..057e22c3 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803E58A0 -lbl_803E58A0: +.global __vt__22CScriptWorldTeleporter +__vt__22CScriptWorldTeleporter: # ROM: 0x3E28A0 .4byte 0 .4byte 0 @@ -17,8 +17,8 @@ lbl_803E58A0: .section .text, "ax" -.global StartTransition__22CScriptWorldTeleporterFv -StartTransition__22CScriptWorldTeleporterFv: +.global StartTransition__22CScriptWorldTeleporterFR13CStateManager +StartTransition__22CScriptWorldTeleporterFR13CStateManager: /* 801D689C 001D37FC 94 21 FF D0 */ stwu r1, -0x30(r1) /* 801D68A0 001D3800 7C 08 02 A6 */ mflr r0 /* 801D68A4 001D3804 90 01 00 34 */ stw r0, 0x34(r1) @@ -75,7 +75,7 @@ lbl_801D6950: /* 801D696C 001D38CC C0 3F 00 44 */ lfs f1, 0x44(r31) /* 801D6970 001D38D0 C0 5F 00 48 */ lfs f2, 0x48(r31) /* 801D6974 001D38D4 C0 7F 00 4C */ lfs f3, 0x4c(r31) -/* 801D6978 001D38D8 48 03 2C 79 */ bl EnableTransition__18CWorldTransManagerFviibbfff +/* 801D6978 001D38D8 48 03 2C 79 */ bl EnableTransition__18CWorldTransManagerFiiibfff /* 801D697C 001D38DC 88 1F 00 40 */ lbz r0, 0x40(r31) /* 801D6980 001D38E0 38 60 00 01 */ li r3, 1 /* 801D6984 001D38E4 50 60 36 72 */ rlwimi r0, r3, 6, 0x19, 0x19 @@ -135,7 +135,7 @@ lbl_801D6A00: /* 801D6A40 001D39A0 40 82 00 4C */ bne lbl_801D6A8C /* 801D6A44 001D39A4 7F 83 E3 78 */ mr r3, r28 /* 801D6A48 001D39A8 7F E4 FB 78 */ mr r4, r31 -/* 801D6A4C 001D39AC 4B FF FE 51 */ bl StartTransition__22CScriptWorldTeleporterFv +/* 801D6A4C 001D39AC 4B FF FE 51 */ bl StartTransition__22CScriptWorldTeleporterFR13CStateManager /* 801D6A50 001D39B0 80 6D A0 80 */ lwz r3, gpGameState@sda21(r13) /* 801D6A54 001D39B4 80 9C 00 34 */ lwz r4, 0x34(r28) /* 801D6A58 001D39B8 4B FF CE ED */ bl SetCurrentWorldId__10CGameStateFUi @@ -164,14 +164,14 @@ lbl_801D6A8C: /* 801D6AB0 001D3A10 48 00 00 4C */ b lbl_801D6AFC lbl_801D6AB4: /* 801D6AB4 001D3A14 7F E4 FB 78 */ mr r4, r31 -/* 801D6AB8 001D3A18 4B FF FD E5 */ bl StartTransition__22CScriptWorldTeleporterFv +/* 801D6AB8 001D3A18 4B FF FD E5 */ bl StartTransition__22CScriptWorldTeleporterFR13CStateManager /* 801D6ABC 001D3A1C A0 9C 00 88 */ lhz r4, 0x88(r28) /* 801D6AC0 001D3A20 7F 63 DB 78 */ mr r3, r27 /* 801D6AC4 001D3A24 88 BC 00 8A */ lbz r5, 0x8a(r28) /* 801D6AC8 001D3A28 88 DC 00 8B */ lbz r6, 0x8b(r28) -/* 801D6ACC 001D3A2C 48 03 2E 99 */ bl sub_80209964 +/* 801D6ACC 001D3A2C 48 03 2E 99 */ bl SetSfx__18CWorldTransManagerFUsUcUc /* 801D6AD0 001D3A30 7F 63 DB 78 */ mr r3, r27 -/* 801D6AD4 001D3A34 48 03 2E ED */ bl sub_802099c0 +/* 801D6AD4 001D3A34 48 03 2E ED */ bl SfxStart__18CWorldTransManagerFv /* 801D6AD8 001D3A38 48 00 00 24 */ b lbl_801D6AFC lbl_801D6ADC: /* 801D6ADC 001D3A3C 88 1C 00 40 */ lbz r0, 0x40(r28) @@ -181,7 +181,7 @@ lbl_801D6ADC: /* 801D6AEC 001D3A4C 98 1C 00 40 */ stb r0, 0x40(r28) /* 801D6AF0 001D3A50 48 03 49 99 */ bl DisableTransition__18CWorldTransManagerFv /* 801D6AF4 001D3A54 7F 63 DB 78 */ mr r3, r27 -/* 801D6AF8 001D3A58 48 03 2E 7D */ bl sub_80209974 +/* 801D6AF8 001D3A58 48 03 2E 7D */ bl SfxStop__18CWorldTransManagerFv lbl_801D6AFC: /* 801D6AFC 001D3A5C A0 1E 00 00 */ lhz r0, 0(r30) /* 801D6B00 001D3A60 7F 83 E3 78 */ mr r3, r28 @@ -223,9 +223,9 @@ __dt__22CScriptWorldTeleporterFv: /* 801D6B78 001D3AD8 93 C1 00 08 */ stw r30, 8(r1) /* 801D6B7C 001D3ADC 7C 7E 1B 79 */ or. r30, r3, r3 /* 801D6B80 001D3AE0 41 82 00 28 */ beq lbl_801D6BA8 -/* 801D6B84 001D3AE4 3C A0 80 3E */ lis r5, lbl_803E58A0@ha +/* 801D6B84 001D3AE4 3C A0 80 3E */ lis r5, __vt__22CScriptWorldTeleporter@ha /* 801D6B88 001D3AE8 38 80 00 00 */ li r4, 0 -/* 801D6B8C 001D3AEC 38 05 58 A0 */ addi r0, r5, lbl_803E58A0@l +/* 801D6B8C 001D3AEC 38 05 58 A0 */ addi r0, r5, __vt__22CScriptWorldTeleporter@l /* 801D6B90 001D3AF0 90 1E 00 00 */ stw r0, 0(r30) /* 801D6B94 001D3AF4 4B E7 A6 E1 */ bl __dt__7CEntityFv /* 801D6B98 001D3AF8 7F E0 07 35 */ extsh. r0, r31 @@ -241,8 +241,8 @@ lbl_801D6BA8: /* 801D6BBC 001D3B1C 38 21 00 10 */ addi r1, r1, 0x10 /* 801D6BC0 001D3B20 4E 80 00 20 */ blr -.global "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUiUiRC9CVector3fUiRC9CVector3fUiRC9CVector3fb" -"__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUiUiRC9CVector3fUiRC9CVector3fUiRC9CVector3fb": +.global "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUsUcUcUiUibfff" +"__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUsUcUcUiUibfff": /* 801D6BC4 001D3B24 94 21 FF 90 */ stwu r1, -0x70(r1) /* 801D6BC8 001D3B28 7C 08 02 A6 */ mflr r0 /* 801D6BCC 001D3B2C 90 01 00 74 */ stw r0, 0x74(r1) @@ -273,9 +273,9 @@ lbl_801D6BA8: /* 801D6C30 001D3B90 7D 5A 53 78 */ mr r26, r10 /* 801D6C34 001D3B94 38 81 00 08 */ addi r4, r1, 8 /* 801D6C38 001D3B98 4B E7 A6 ED */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" -/* 801D6C3C 001D3B9C 3C 80 80 3E */ lis r4, lbl_803E58A0@ha +/* 801D6C3C 001D3B9C 3C 80 80 3E */ lis r4, __vt__22CScriptWorldTeleporter@ha /* 801D6C40 001D3BA0 3C 60 80 5A */ lis r3, sZeroVector__9CVector3f@ha -/* 801D6C44 001D3BA4 38 04 58 A0 */ addi r0, r4, lbl_803E58A0@l +/* 801D6C44 001D3BA4 38 04 58 A0 */ addi r0, r4, __vt__22CScriptWorldTeleporter@l /* 801D6C48 001D3BA8 38 A0 00 02 */ li r5, 2 /* 801D6C4C 001D3BAC 90 17 00 00 */ stw r0, 0(r23) /* 801D6C50 001D3BB0 38 C0 00 00 */ li r6, 0 @@ -339,8 +339,8 @@ lbl_801D6BA8: /* 801D6D38 001D3C98 38 21 00 70 */ addi r1, r1, 0x70 /* 801D6D3C 001D3C9C 4E 80 00 20 */ blr -.global "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" -"__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>": +.global "__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUiUiUiRC9CVector3fUiRC9CVector3fUiRC9CVector3fbUsUcUc" +"__ct__22CScriptWorldTeleporterF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfobUiUiUiUiUiRC9CVector3fUiRC9CVector3fUiRC9CVector3fbUsUcUc": /* 801D6D40 001D3CA0 94 21 FF B0 */ stwu r1, -0x50(r1) /* 801D6D44 001D3CA4 7C 08 02 A6 */ mflr r0 /* 801D6D48 001D3CA8 90 01 00 54 */ stw r0, 0x54(r1) @@ -368,9 +368,9 @@ lbl_801D6BA8: /* 801D6DA0 001D3D00 7C 87 23 78 */ mr r7, r4 /* 801D6DA4 001D3D04 38 81 00 08 */ addi r4, r1, 8 /* 801D6DA8 001D3D08 4B E7 A5 7D */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" -/* 801D6DAC 001D3D0C 3C 60 80 3E */ lis r3, lbl_803E58A0@ha +/* 801D6DAC 001D3D0C 3C 60 80 3E */ lis r3, __vt__22CScriptWorldTeleporter@ha /* 801D6DB0 001D3D10 38 00 00 01 */ li r0, 1 -/* 801D6DB4 001D3D14 38 63 58 A0 */ addi r3, r3, lbl_803E58A0@l +/* 801D6DB4 001D3D14 38 63 58 A0 */ addi r3, r3, __vt__22CScriptWorldTeleporter@l /* 801D6DB8 001D3D18 38 80 00 00 */ li r4, 0 /* 801D6DBC 001D3D1C 90 78 00 00 */ stw r3, 0(r24) /* 801D6DC0 001D3D20 7E A3 AB 78 */ mr r3, r21 @@ -445,9 +445,9 @@ lbl_801D6BA8: /* 801D6EC8 001D3E28 7C 87 23 78 */ mr r7, r4 /* 801D6ECC 001D3E2C 38 81 00 08 */ addi r4, r1, 8 /* 801D6ED0 001D3E30 4B E7 A4 55 */ bl "__ct__7CEntityF9TUniqueIdRC11CEntityInfobRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" -/* 801D6ED4 001D3E34 3C 80 80 3E */ lis r4, lbl_803E58A0@ha +/* 801D6ED4 001D3E34 3C 80 80 3E */ lis r4, __vt__22CScriptWorldTeleporter@ha /* 801D6ED8 001D3E38 3C 60 80 5A */ lis r3, sZeroVector__9CVector3f@ha -/* 801D6EDC 001D3E3C 38 04 58 A0 */ addi r0, r4, lbl_803E58A0@l +/* 801D6EDC 001D3E3C 38 04 58 A0 */ addi r0, r4, __vt__22CScriptWorldTeleporter@l /* 801D6EE0 001D3E40 38 E0 00 00 */ li r7, 0 /* 801D6EE4 001D3E44 90 1D 00 00 */ stw r0, 0(r29) /* 801D6EE8 001D3E48 38 A0 FF FF */ li r5, -1 diff --git a/configure.py b/configure.py index 7f6cc3e9..aebf9f24 100755 --- a/configure.py +++ b/configure.py @@ -285,7 +285,7 @@ LIBS = [ ["MetroidPrime/CHealthInfo", True], "MetroidPrime/Player/CGameState", ["MetroidPrime/ScriptObjects/CScriptVisorFlare", False], - "MetroidPrime/ScriptObjects/CScriptWorldTeleporter", + ["MetroidPrime/ScriptObjects/CScriptWorldTeleporter", False], "MetroidPrime/ScriptObjects/CScriptVisorGoo", "MetroidPrime/Enemies/CJellyZap", ["MetroidPrime/ScriptObjects/CScriptControllerAction", False], diff --git a/include/Kyoto/CResLoader.hpp b/include/Kyoto/CResLoader.hpp index 12bc49ef..cd4bbc8b 100644 --- a/include/Kyoto/CResLoader.hpp +++ b/include/Kyoto/CResLoader.hpp @@ -26,6 +26,7 @@ public: void AsyncIdlePakLoading(); bool AreAllPaksLoaded() const; CInputStream* LoadNewResourceSync(const SObjectTag& tag, char* extBuf); + FourCC GetResourceTypeById(CAssetId) const; private: rstl::list< unkptr > x0_aramList; diff --git a/include/MetroidPrime/CAnimationParameters.hpp b/include/MetroidPrime/CAnimationParameters.hpp index 1ed9af39..31696ab8 100644 --- a/include/MetroidPrime/CAnimationParameters.hpp +++ b/include/MetroidPrime/CAnimationParameters.hpp @@ -15,6 +15,10 @@ public: CAnimationParameters(CInputStream& in) : x0_ancs(in.ReadLong()), x4_charIdx(in.ReadLong()), x8_defaultAnim(in.ReadLong()) {} + + CAssetId GetACSFile() const { return x0_ancs; } + uint GetCharacter() const { return x4_charIdx; } + uint GetInitialAnimation() const { return x8_defaultAnim; } }; diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index 41baa5f4..d86ef68a 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -157,6 +157,8 @@ public: CRumbleManager* GetRumbleManager() { return x88c_rumbleManager; } CFluidPlaneManager* FluidPlaneManager() { return x87c_fluidPlaneManager; } const CFluidPlaneManager* GetFluidPlaneManager() const { return x87c_fluidPlaneManager; } + CWorldTransManager* WorldTransManager() { return x8c4_worldTransManager.GetPtr(); } + const CWorldTransManager* GetWorldTransManager() const { return x8c4_worldTransManager.GetPtr(); } CRandom16* Random() const { return x900_random; } diff --git a/include/MetroidPrime/CWorld.hpp b/include/MetroidPrime/CWorld.hpp index 02f64d34..cae7fae0 100644 --- a/include/MetroidPrime/CWorld.hpp +++ b/include/MetroidPrime/CWorld.hpp @@ -74,6 +74,8 @@ public: rstl::string IGetDefaultAudioTrack() const override; int IGetAreaCount() const override; + void SetLoadPauseState(bool); + const CGameArea& GetAreaAlways(TAreaId id) const { return *x18_areas[id.Value()]; } CGameArea* Area(TAreaId id) { return x18_areas[id.Value()].get(); } const CGameArea* GetArea(TAreaId id) const { return x18_areas[id.Value()].get(); } diff --git a/include/MetroidPrime/Player/CGameState.hpp b/include/MetroidPrime/Player/CGameState.hpp index 9c778414..4e1101f6 100644 --- a/include/MetroidPrime/Player/CGameState.hpp +++ b/include/MetroidPrime/Player/CGameState.hpp @@ -24,10 +24,14 @@ public: void PutTo(COutputStream& out) const; void WriteSystemOptions(COutputStream& out); + void SetCurrentWorldId(CAssetId); + rstl::rc_ptr< CPlayerState >& PlayerState(); - CAssetId CurrentWorldAssetId(); + CAssetId CurrentWorldAssetId() const; void WriteBackupBuf(); + CWorldState& CurrentWorldState(); + void ImportPersistentOptions(const CSystemOptions&); void ExportPersistentOptions(CSystemOptions&); diff --git a/include/MetroidPrime/Player/CWorldState.hpp b/include/MetroidPrime/Player/CWorldState.hpp index 49a28301..210b168f 100644 --- a/include/MetroidPrime/Player/CWorldState.hpp +++ b/include/MetroidPrime/Player/CWorldState.hpp @@ -1,10 +1,12 @@ #ifndef _CWORLDSTATE #define _CWORLDSTATE -#include "types.h" +#include "Kyoto/SObjectTag.hpp" class CWorldState { public: + void SetDesiredAreaAssetId(CAssetId id); + private: uchar pad[0x18]; }; diff --git a/include/MetroidPrime/Player/CWorldTransManager.hpp b/include/MetroidPrime/Player/CWorldTransManager.hpp index f14f18a0..13c1b47f 100644 --- a/include/MetroidPrime/Player/CWorldTransManager.hpp +++ b/include/MetroidPrime/Player/CWorldTransManager.hpp @@ -3,10 +3,21 @@ #include "types.h" +class CAnimRes; +class CVector3f; + class CWorldTransManager { public: enum ETransType { kTT_Disabled, kTT_Enabled, kTT_Text }; + void SetSfx(ushort, uchar, uchar); + void SfxStart(); + void SfxStop(); + + void EnableTransition(const CAnimRes&, unsigned int, const CVector3f&, unsigned int, const CVector3f&, bool); + void EnableTransition(int fontId, int stringId, int stringIdx, bool fadeWhite, float chFadeTime, float chFadeRate, float textStartTime); + void DisableTransition(); + ETransType GetTransType() const { return x30_transType; } private: diff --git a/include/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.hpp b/include/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.hpp new file mode 100644 index 00000000..4cd6c4a1 --- /dev/null +++ b/include/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.hpp @@ -0,0 +1,58 @@ +#ifndef _CSCRIPTWORLDTELEPORTER +#define _CSCRIPTWORLDTELEPORTER + +#include "MetroidPrime/CEntity.hpp" + +#include "MetroidPrime/CAnimationParameters.hpp" + +#include "Kyoto/Math/CVector3f.hpp" + +class CScriptWorldTeleporter : public CEntity { +public: + CScriptWorldTeleporter(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + bool active, CAssetId worldId, CAssetId areaId); + CScriptWorldTeleporter(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + bool active, CAssetId worldId, CAssetId areaId, CAssetId playerAncs, + uint charIdx, uint defaultAnim, const CVector3f& playerScale, + CAssetId platformModel, const CVector3f& platformScale, + CAssetId backgroundModel, const CVector3f& backgroundScale, + bool upElevator, ushort soundId, uchar volume, uchar panning); + CScriptWorldTeleporter(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + bool active, CAssetId worldId, CAssetId areaId, ushort soundId, + uchar volume, uchar panning, CAssetId fontId, CAssetId stringId, + bool fadeWhite, float charFadeIn, float charsPerSecond, float showDelay); + ~CScriptWorldTeleporter(); + + void Accept(IVisitor&) override; + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; + void StartTransition(CStateManager&); + + bool GetFadeWhite() const { return x40_27_fadeWhite; } + +private: + enum ETeleporterType { kTT_NoTransition, kTT_Elevator, kTT_Text }; + + CAssetId x34_worldId; + CAssetId x38_areaId; + ETeleporterType x3c_type; // = ETeleporterType::NoTransition; + bool x40_24_upElevator : 1; // = false; + bool x40_25_inTransition : 1; // = false; + bool x40_26_ : 1; + bool x40_27_fadeWhite : 1; // = false; + float x44_charFadeIn; // = 0.1f; + float x48_charsPerSecond; // = 8.0f; + float x4c_showDelay; // = 0.0f; + CAnimationParameters x50_playerAnim; + CVector3f x5c_playerScale; + CAssetId x68_platformModel; + CVector3f x6c_platformScale; + CAssetId x78_backgroundModel; + CVector3f x7c_backgroundScale; + ushort x88_soundId; // = -1; + uchar x8a_volume; // = 0; + uchar x8b_panning; // = 0; + CAssetId x8c_fontId; + CAssetId x90_stringId; +}; + +#endif // _CSCRIPTWORLDTELEPORTER diff --git a/src/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.cpp b/src/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.cpp new file mode 100644 index 00000000..9b5f2741 --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptWorldTeleporter.cpp @@ -0,0 +1,163 @@ +#include "MetroidPrime/ScriptObjects/CScriptWorldTeleporter.hpp" + +#include "MetroidPrime/CAnimRes.hpp" +#include "MetroidPrime/CMain.hpp" +#include "MetroidPrime/CMainFlow.hpp" +#include "MetroidPrime/CStateManager.hpp" +#include "MetroidPrime/CWorld.hpp" +#include "MetroidPrime/Player/CGameState.hpp" +#include "MetroidPrime/Player/CWorldTransManager.hpp" + +#include "Kyoto/Audio/CSfxManager.hpp" +#include "Kyoto/CResFactory.hpp" + +CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const rstl::string& name, + const CEntityInfo& info, bool active, + CAssetId worldId, CAssetId areaId) +: CEntity(uid, info, active, name) +, x34_worldId(worldId) +, x38_areaId(areaId) +, x3c_type(kTT_NoTransition) +, x40_24_upElevator(false) +, x40_25_inTransition(false) +, x40_27_fadeWhite(false) +, x44_charFadeIn(0.1f) +, x48_charsPerSecond(8.0f) +, x4c_showDelay(0.0f) +, x50_playerAnim(kInvalidAssetId, -1, 0) +, x5c_playerScale(CVector3f::Zero()) +, x68_platformModel(kInvalidAssetId) +, x6c_platformScale(CVector3f::Zero()) +, x78_backgroundModel(kInvalidAssetId) +, x7c_backgroundScale(CVector3f::Zero()) +, x88_soundId(CSfxManager::kInternalInvalidSfxId) +, x8a_volume(0) +, x8b_panning(0) +{} + +CScriptWorldTeleporter::CScriptWorldTeleporter( + TUniqueId uid, const rstl::string& name, const CEntityInfo& info, bool active, CAssetId worldId, + CAssetId areaId, CAssetId playerAncs, uint charIdx, uint defaultAnim, + const CVector3f& playerScale, CAssetId platformModel, const CVector3f& platformScale, + CAssetId backgroundModel, const CVector3f& backgroundScale, bool upElevator, ushort soundId, + uchar volume, uchar panning) +: CEntity(uid, info, active, name) +, x34_worldId(worldId) +, x38_areaId(areaId) +, x3c_type(kTT_Elevator) +, x40_24_upElevator(upElevator) +, x40_25_inTransition(false) +, x40_27_fadeWhite(false) +, x44_charFadeIn(0.1f) +, x48_charsPerSecond(8.0f) +, x4c_showDelay(0.0f) +, x50_playerAnim(playerAncs, charIdx, defaultAnim) +, x5c_playerScale(playerScale) +, x68_platformModel(platformModel) +, x6c_platformScale(platformScale) +, x78_backgroundModel(backgroundModel) +, x7c_backgroundScale(backgroundScale) +, x88_soundId(CSfxManager::TranslateSFXID(soundId)) +, x8a_volume(volume) +, x8b_panning(panning) {} + +CScriptWorldTeleporter::CScriptWorldTeleporter(TUniqueId uid, const rstl::string& name, + const CEntityInfo& info, bool active, + CAssetId worldId, CAssetId areaId, ushort soundId, + uchar volume, uchar panning, CAssetId fontId, + CAssetId stringId, bool fadeWhite, float charFadeIn, + float charsPerSecond, float showDelay) +: CEntity(uid, info, active, name) +, x34_worldId(worldId) +, x38_areaId(areaId) +, x3c_type(kTT_Text) +, x40_24_upElevator(false) +, x40_25_inTransition(false) +, x40_27_fadeWhite(fadeWhite) +, x44_charFadeIn(charFadeIn) +, x48_charsPerSecond(charsPerSecond) +, x4c_showDelay(showDelay) +, x50_playerAnim(kInvalidAssetId, -1, 0) +, x5c_playerScale(CVector3f::Zero()) +, x68_platformModel(kInvalidAssetId) +, x6c_platformScale(CVector3f::Zero()) +, x78_backgroundModel(kInvalidAssetId) +, x7c_backgroundScale(CVector3f::Zero()) +, x88_soundId(CSfxManager::TranslateSFXID(soundId)) +, x8a_volume(volume) +, x8b_panning(panning) +, x8c_fontId(fontId) +, x90_stringId(stringId) {} + +CScriptWorldTeleporter::~CScriptWorldTeleporter() {} + +void CScriptWorldTeleporter::Accept(IVisitor& visitor) { visitor.Visit(*this); } + +void CScriptWorldTeleporter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, + CStateManager& mgr) { + if (GetActive()) { + CWorldTransManager* transMgr = mgr.WorldTransManager(); + switch (msg) { + case kSM_SetToZero: { + CWorld* world = mgr.World(); + world->SetLoadPauseState(true); + CAssetId currentWorld = gpGameState->CurrentWorldAssetId(); + gpGameState->SetCurrentWorldId(x34_worldId); + + if (gpResourceFactory->GetResLoader().GetResourceTypeById(x34_worldId) == 'MLVL') { + StartTransition(mgr); + gpGameState->SetCurrentWorldId(x34_worldId); + gpGameState->CurrentWorldState().SetDesiredAreaAssetId(x38_areaId); + gpMain->SetRestartMode(CMain::kRM_None); + mgr.QuitGame(); + } else { + x40_25_inTransition = false; + transMgr->DisableTransition(); + gpGameState->SetCurrentWorldId(currentWorld); + } + break; + } + case kSM_Play: + StartTransition(mgr); + transMgr->SetSfx(x88_soundId, x8a_volume, x8b_panning); + transMgr->SfxStart(); + break; + + case kSM_Stop: + x40_25_inTransition = false; + transMgr->DisableTransition(); + transMgr->SfxStop(); + break; + + default: + break; + } + } + CEntity::AcceptScriptMsg(msg, uid, mgr); +} + +void CScriptWorldTeleporter::StartTransition(CStateManager& mgr) { + if (x40_25_inTransition) { + return; + } + + CWorldTransManager* transMgr = mgr.WorldTransManager(); + + if (x3c_type == kTT_Elevator && x50_playerAnim.GetACSFile() != kInvalidAssetId && + x50_playerAnim.GetCharacter() != u32(-1)) { + transMgr->EnableTransition(CAnimRes(x50_playerAnim.GetACSFile(), x50_playerAnim.GetCharacter(), + x5c_playerScale, x50_playerAnim.GetInitialAnimation(), + true), + x68_platformModel, x6c_platformScale, x78_backgroundModel, + x7c_backgroundScale, x40_24_upElevator); + x40_25_inTransition = true; + + } else if (x3c_type == kTT_Text) { + transMgr->EnableTransition(x8c_fontId, x90_stringId, 0, GetFadeWhite(), x44_charFadeIn, + x48_charsPerSecond, x4c_showDelay); + x40_25_inTransition = true; + + } else { + transMgr->DisableTransition(); + } +}