From 0ad2519985da7988109b477e25de48f6fd71fe24 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Mon, 17 Oct 2022 14:47:47 +0300 Subject: [PATCH] Match and link CPreFrontEnd Former-commit-id: 2cd913399f160296ebed7bc15a16fadae9aed882 --- asm/MetroidPrime/CPreFrontEnd.s | 18 ++++---- configure.py | 2 +- include/MetroidPrime/CMain.hpp | 1 + include/MetroidPrime/CPreFrontEnd.hpp | 18 ++++++++ obj_files.mk | 2 +- src/MetroidPrime/CPreFrontEnd.cpp | 43 +++++++++++++++++++ src/MetroidPrime/Enemies/SPositionHistory.cpp | 2 +- 7 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 include/MetroidPrime/CPreFrontEnd.hpp create mode 100644 src/MetroidPrime/CPreFrontEnd.cpp diff --git a/asm/MetroidPrime/CPreFrontEnd.s b/asm/MetroidPrime/CPreFrontEnd.s index 99e9bd9e..2c0d1de3 100644 --- a/asm/MetroidPrime/CPreFrontEnd.s +++ b/asm/MetroidPrime/CPreFrontEnd.s @@ -3,13 +3,13 @@ .section .data .balign 8 -.global lbl_803EC010 -lbl_803EC010: +.global __vt__12CPreFrontEnd +__vt__12CPreFrontEnd: # ROM: 0x3E9010 .4byte 0 .4byte 0 .4byte __dt__12CPreFrontEndFv - .4byte OnIOWinMessage__12CPreFrontEndFRC20CArchitectureMessage + .4byte OnMessage__12CPreFrontEndFRC20CArchitectureMessageR18CArchitectureQueue .4byte GetIsContinueDraw__6CIOWinCFv .4byte Draw__12CPreFrontEndCFv .4byte PreDraw__6CIOWinCFv @@ -27,9 +27,9 @@ __dt__12CPreFrontEndFv: /* 8029E4B8 0029B418 93 C1 00 08 */ stw r30, 8(r1) /* 8029E4BC 0029B41C 7C 7E 1B 79 */ or. r30, r3, r3 /* 8029E4C0 0029B420 41 82 00 28 */ beq lbl_8029E4E8 -/* 8029E4C4 0029B424 3C A0 80 3F */ lis r5, lbl_803EC010@ha +/* 8029E4C4 0029B424 3C A0 80 3F */ lis r5, __vt__12CPreFrontEnd@ha /* 8029E4C8 0029B428 38 80 00 00 */ li r4, 0 -/* 8029E4CC 0029B42C 38 05 C0 10 */ addi r0, r5, lbl_803EC010@l +/* 8029E4CC 0029B42C 38 05 C0 10 */ addi r0, r5, __vt__12CPreFrontEnd@l /* 8029E4D0 0029B430 90 1E 00 00 */ stw r0, 0(r30) /* 8029E4D4 0029B434 4B DB 46 D1 */ bl __dt__6CIOWinFv /* 8029E4D8 0029B438 7F E0 07 35 */ extsh. r0, r31 @@ -57,8 +57,8 @@ Draw__12CPreFrontEndCFv: /* 8029E520 0029B480 38 21 00 10 */ addi r1, r1, 0x10 /* 8029E524 0029B484 4E 80 00 20 */ blr -.global OnIOWinMessage__12CPreFrontEndFRC20CArchitectureMessage -OnIOWinMessage__12CPreFrontEndFRC20CArchitectureMessage: +.global OnMessage__12CPreFrontEndFRC20CArchitectureMessageR18CArchitectureQueue +OnMessage__12CPreFrontEndFRC20CArchitectureMessageR18CArchitectureQueue: /* 8029E528 0029B488 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8029E52C 0029B48C 7C 08 02 A6 */ mflr r0 /* 8029E530 0029B490 90 01 00 14 */ stw r0, 0x14(r1) @@ -127,9 +127,9 @@ __ct__12CPreFrontEndFv: /* 8029E60C 0029B56C 4B DB 46 01 */ bl "__ct__6CIOWinFRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>" /* 8029E610 0029B570 38 61 00 08 */ addi r3, r1, 8 /* 8029E614 0029B574 48 09 F4 CD */ bl "internal_dereference__Q24rstl66basic_string,Q24rstl17rmemory_allocator>Fv" -/* 8029E618 0029B578 3C 60 80 3F */ lis r3, lbl_803EC010@ha +/* 8029E618 0029B578 3C 60 80 3F */ lis r3, __vt__12CPreFrontEnd@ha /* 8029E61C 0029B57C 38 00 00 00 */ li r0, 0 -/* 8029E620 0029B580 38 83 C0 10 */ addi r4, r3, lbl_803EC010@l +/* 8029E620 0029B580 38 83 C0 10 */ addi r4, r3, __vt__12CPreFrontEnd@l /* 8029E624 0029B584 7F E3 FB 78 */ mr r3, r31 /* 8029E628 0029B588 90 9F 00 00 */ stw r4, 0(r31) /* 8029E62C 0029B58C 98 1F 00 14 */ stb r0, 0x14(r31) diff --git a/configure.py b/configure.py index 90dbf854..6fa7ccd5 100755 --- a/configure.py +++ b/configure.py @@ -383,7 +383,7 @@ LIBS = [ ["MetroidPrime/Tweaks/CTweakSlideShow", True], "MetroidPrime/CArtifactDoll", "MetroidPrime/CProjectedShadow", - "MetroidPrime/CPreFrontEnd", + ["MetroidPrime/CPreFrontEnd", True], "MetroidPrime/CGameCubeDoll", "MetroidPrime/ScriptObjects/CScriptProjectedShadow", "MetroidPrime/ScriptObjects/CEnergyBall", diff --git a/include/MetroidPrime/CMain.hpp b/include/MetroidPrime/CMain.hpp index 2b8851a9..63f183d0 100644 --- a/include/MetroidPrime/CMain.hpp +++ b/include/MetroidPrime/CMain.hpp @@ -60,6 +60,7 @@ public: CMain(); ~CMain(); + bool LoadAudio(); void UpdateStreamedAudio(); void RegisterResourceTweaks(); void ResetGameState(); diff --git a/include/MetroidPrime/CPreFrontEnd.hpp b/include/MetroidPrime/CPreFrontEnd.hpp new file mode 100644 index 00000000..289cb746 --- /dev/null +++ b/include/MetroidPrime/CPreFrontEnd.hpp @@ -0,0 +1,18 @@ +#ifndef _CPREFRONTEND +#define _CPREFRONTEND + +#include "MetroidPrime/CIOWin.hpp" + +class CPreFrontEnd : public CIOWin { +public: + CPreFrontEnd(); + ~CPreFrontEnd(); + + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&); + void Draw() const; + +private: + bool x14_resourceTweaksRegistered; +}; + +#endif // _CPREFRONTEND diff --git a/obj_files.mk b/obj_files.mk index 8ecd75f9..df807f7d 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -350,7 +350,7 @@ METROIDPRIME :=\ $(BUILD_DIR)/src/MetroidPrime/Tweaks/CTweakSlideShow.o\ $(BUILD_DIR)/asm/MetroidPrime/CArtifactDoll.o\ $(BUILD_DIR)/asm/MetroidPrime/CProjectedShadow.o\ - $(BUILD_DIR)/asm/MetroidPrime/CPreFrontEnd.o\ + $(BUILD_DIR)/src/MetroidPrime/CPreFrontEnd.o\ $(BUILD_DIR)/asm/MetroidPrime/CGameCubeDoll.o\ $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptProjectedShadow.o\ $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CEnergyBall.o\ diff --git a/src/MetroidPrime/CPreFrontEnd.cpp b/src/MetroidPrime/CPreFrontEnd.cpp new file mode 100644 index 00000000..2dd8d866 --- /dev/null +++ b/src/MetroidPrime/CPreFrontEnd.cpp @@ -0,0 +1,43 @@ +#include "MetroidPrime/CPreFrontEnd.hpp" + +#include "MetroidPrime/CMain.hpp" +#include "MetroidPrime/CMemoryCard.hpp" + +#include "Kyoto/CResFactory.hpp" +#include "Kyoto/Graphics/CGraphics.hpp" + +CPreFrontEnd::CPreFrontEnd() +: CIOWin(rstl::string_l("Pre front-end window")), x14_resourceTweaksRegistered(false) {} + +CIOWin::EMessageReturn CPreFrontEnd::OnMessage(const CArchitectureMessage& msg, + CArchitectureQueue&) { + if (msg.GetType() == kAM_TimerTick) { + if (!gpResourceFactory->GetResLoader().AreAllPaksLoaded()) + return kMR_Exit; + + if (!x14_resourceTweaksRegistered) { + gpMain->RegisterResourceTweaks(); + x14_resourceTweaksRegistered = true; + } + + gpResourceFactory->AsyncIdle(1000000); + + gpMain->MemoryCardInitializePump(); + if (!gpMemoryCard) + return kMR_Exit; + + if (!gpMain->LoadAudio()) + return kMR_Exit; + + return kMR_RemoveIOWinAndExit; + + } else { + return kMR_Normal; + } +} + +void CPreFrontEnd::Draw() const { + CGraphics::SetIsBeginSceneClearFb(true); +} + +CPreFrontEnd::~CPreFrontEnd() {} diff --git a/src/MetroidPrime/Enemies/SPositionHistory.cpp b/src/MetroidPrime/Enemies/SPositionHistory.cpp index 3597e21b..8bce2f75 100644 --- a/src/MetroidPrime/Enemies/SPositionHistory.cpp +++ b/src/MetroidPrime/Enemies/SPositionHistory.cpp @@ -6,7 +6,7 @@ void SPositionHistory::AddValue(const CVector3f& pos) { if (x4_values.size() >= 16) { return; } - if (x4_values.size() == 0) { + if (x4_values.empty()) { x4_values.push_back(pos); return; }