From 920b8b3e561118fd7df795e29766937d74e8eab8 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 22 Oct 2022 20:02:37 -0700 Subject: [PATCH] Add CScannableObjectInfo (this thing is a confusing mess) Former-commit-id: 8fad20812505d3a652c3010835599807e33909ad --- asm/MetroidPrime/CPauseScreen.s | 2 +- .../Factories/CScannableObjectInfo.s | 5 ++- asm/MetroidPrime/Player/CScanDisplay.s | 2 +- configure.py | 2 +- include/Kyoto/Streams/CInputStream.hpp | 2 ++ .../Factories/CScannableObjectInfo.hpp | 35 +++++++++++++++++++ .../Factories/CScannableObjectInfo.cpp | 24 +++++++++++++ src/MetroidPrime/HUD/CHUDMemoParms.cpp | 4 +-- 8 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 include/MetroidPrime/Factories/CScannableObjectInfo.hpp create mode 100644 src/MetroidPrime/Factories/CScannableObjectInfo.cpp diff --git a/asm/MetroidPrime/CPauseScreen.s b/asm/MetroidPrime/CPauseScreen.s index 43980728..8e62bc9a 100644 --- a/asm/MetroidPrime/CPauseScreen.s +++ b/asm/MetroidPrime/CPauseScreen.s @@ -1747,7 +1747,7 @@ lbl_8007206C: /* 80072088 0006EFE8 3B 3F 00 F4 */ addi r25, r31, 0xf4 lbl_8007208C: /* 8007208C 0006EFEC 7F 43 D3 78 */ mr r3, r26 -/* 80072090 0006EFF0 48 0F 7E E1 */ bl GetImagePaneName__16CPauseScreenBaseFUi +/* 80072090 0006EFF0 48 0F 7E E1 */ bl GetImagePaneName__20CScannableObjectInfoFUi /* 80072094 0006EFF4 7C 64 1B 78 */ mr r4, r3 /* 80072098 0006EFF8 80 7F 00 08 */ lwz r3, 8(r31) /* 8007209C 0006EFFC 48 25 00 B9 */ bl FindWidget__9CGuiFrameCFPCc diff --git a/asm/MetroidPrime/Factories/CScannableObjectInfo.s b/asm/MetroidPrime/Factories/CScannableObjectInfo.s index cde9b9e6..28b08788 100644 --- a/asm/MetroidPrime/Factories/CScannableObjectInfo.s +++ b/asm/MetroidPrime/Factories/CScannableObjectInfo.s @@ -476,8 +476,8 @@ lbl_80169F44: /* 80169F68 00166EC8 38 21 00 10 */ addi r1, r1, 0x10 /* 80169F6C 00166ECC 4E 80 00 20 */ blr -.global GetImagePaneName__16CPauseScreenBaseFUi -GetImagePaneName__16CPauseScreenBaseFUi: +.global GetImagePaneName__20CScannableObjectInfoFUi +GetImagePaneName__20CScannableObjectInfoFUi: /* 80169F70 00166ED0 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80169F74 00166ED4 7C 08 02 A6 */ mflr r0 /* 80169F78 00166ED8 3C 80 80 3D */ lis r4, lbl_803D0440@ha @@ -669,4 +669,3 @@ lbl_803D04C7: .asciz "??(??)" .byte 0x25 .4byte 0x73257300 - diff --git a/asm/MetroidPrime/Player/CScanDisplay.s b/asm/MetroidPrime/Player/CScanDisplay.s index 6dddce37..7bdd30bd 100644 --- a/asm/MetroidPrime/Player/CScanDisplay.s +++ b/asm/MetroidPrime/Player/CScanDisplay.s @@ -1719,7 +1719,7 @@ StartScan__12CScanDisplayF9TUniqueIdRC20CScannableObjectInfoP12CGuiTextPaneP10CG /* 801741C0 00171120 3B FE 01 74 */ addi r31, r30, 0x174 lbl_801741C4: /* 801741C4 00171124 7F 83 E3 78 */ mr r3, r28 -/* 801741C8 00171128 4B FF 5D A9 */ bl GetImagePaneName__16CPauseScreenBaseFUi +/* 801741C8 00171128 4B FF 5D A9 */ bl GetImagePaneName__20CScannableObjectInfoFUi /* 801741CC 0017112C 7C 64 1B 78 */ mr r4, r3 /* 801741D0 00171130 38 61 00 3C */ addi r3, r1, 0x3c /* 801741D4 00171134 38 C1 00 0C */ addi r6, r1, 0xc diff --git a/configure.py b/configure.py index 2332ce0f..e32987a4 100755 --- a/configure.py +++ b/configure.py @@ -230,7 +230,7 @@ LIBS = [ ["MetroidPrime/ScriptObjects/CScriptPointOfInterest", True], "MetroidPrime/Enemies/CDrone", "MetroidPrime/CMapWorldInfo", - "MetroidPrime/Factories/CScannableObjectInfo", + ["MetroidPrime/Factories/CScannableObjectInfo", False], "MetroidPrime/Enemies/CMetroid", "MetroidPrime/Player/CScanDisplay", ["MetroidPrime/ScriptObjects/CScriptSteam", False], diff --git a/include/Kyoto/Streams/CInputStream.hpp b/include/Kyoto/Streams/CInputStream.hpp index 719e2007..ef84ab15 100644 --- a/include/Kyoto/Streams/CInputStream.hpp +++ b/include/Kyoto/Streams/CInputStream.hpp @@ -40,6 +40,8 @@ public: // why? int ReadInt32() { return static_cast< uint >(Get(TType< int >())); } + uint GetBlockOffset() const { return x4_blockOffset; } + private: bool GrabAnotherBlock(); bool InternalReadNext(); diff --git a/include/MetroidPrime/Factories/CScannableObjectInfo.hpp b/include/MetroidPrime/Factories/CScannableObjectInfo.hpp new file mode 100644 index 00000000..80f7b052 --- /dev/null +++ b/include/MetroidPrime/Factories/CScannableObjectInfo.hpp @@ -0,0 +1,35 @@ +#ifndef _CSCANNABLEOBJECTINFO +#define _CSCANNABLEOBJECTINFO + +#include "types.h" + +#include "Kyoto/Math/CVector2i.hpp" +#include "Kyoto/SObjectTag.hpp" + +#include "rstl/reserved_vector.hpp" +#include "rstl/string.hpp" + +class CInputStream; +class CScannableObjectInfo { +public: + static const char* GetImagePaneName(uint pane); + CScannableObjectInfo(CInputStream& in, uint version); + +private: + struct SBucket { + CAssetId x0_texture; + float x4_appearanceRange; + uint x8_imagePos; + CVector2i xc_size; + float x14_interval; + float x18_fadeDuration; + }; + CAssetId x0_scannableObjectId; + CAssetId x4_stringId; + float x8_totalDownloadTime; + uint xc_category; + bool x10_important; + rstl::reserved_vector< SBucket, 4 > x14_buckets; +}; + +#endif // _CSCANNABLEOBJECTINFO diff --git a/src/MetroidPrime/Factories/CScannableObjectInfo.cpp b/src/MetroidPrime/Factories/CScannableObjectInfo.cpp new file mode 100644 index 00000000..fe0301ba --- /dev/null +++ b/src/MetroidPrime/Factories/CScannableObjectInfo.cpp @@ -0,0 +1,24 @@ +#include "MetroidPrime/Factories/CScannableObjectInfo.hpp" +#include "Kyoto/CFactoryMgr.hpp" + +#include "Kyoto/Basics/CBasics.hpp" +#include "Kyoto/Streams/CInputStream.hpp" + +const char* PaneSufixes[] = {"0", "1", "2", "3", "01", "12", "23", "012", "123", "0123", + "4", "5", "6", "7", "45", "56", "67", "456", "567", "4567"}; +const char* CScannableObjectInfo::GetImagePaneName(uint pane) { + + return CBasics::Stringize("%s%s", "image_pane", PaneSufixes[pane]); +} + +CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, uint version) {} + +template <> +inline CFactoryFnReturn::CFactoryFnReturn(CScannableObjectInfo* ptr) +: obj(TToken< CScannableObjectInfo >::GetIObjObjectFor(rstl::auto_ptr< CScannableObjectInfo >(ptr)) + .release()) {} + +CFactoryFnReturn FScannableObjectInfoFactory(const SObjectTag& tag, CInputStream& in, + const CVParamTransfer& xfer) { + return new CScannableObjectInfo(in, in.GetBlockOffset()); +} diff --git a/src/MetroidPrime/HUD/CHUDMemoParms.cpp b/src/MetroidPrime/HUD/CHUDMemoParms.cpp index 750c952c..ddee8ca0 100644 --- a/src/MetroidPrime/HUD/CHUDMemoParms.cpp +++ b/src/MetroidPrime/HUD/CHUDMemoParms.cpp @@ -2,7 +2,7 @@ #include "Kyoto/Streams/CInputStream.hpp" CHUDMemoParms::CHUDMemoParms(CInputStream& in) -: mDispTime(in.Get(TType< float >())) -, mClearMemoWindow(in.ReadBool()) +: mDispTime(in.Get< float >()) +, mClearMemoWindow(in.Get< bool >()) , mFadeOutOnly(false) , mHintMemo(false) {}