From ec14321dcfa8ad1fe866b4228e5db166f7569502 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 11 Jan 2023 18:43:43 -0800 Subject: [PATCH] Match and link CPASParmInfo Former-commit-id: a04a2267f4b7b06de2568f055a540afbc4f0191e --- asm/Kyoto/Animation/CPASParmInfo.s | 36 -------------------- asm/Kyoto/Animation/CPrimitive.s | 35 +++++++++++++++++++ configure.py | 2 +- include/Kyoto/Animation/CPASAnimParm.hpp | 2 ++ include/Kyoto/Animation/CPASAnimState.hpp | 22 ++---------- include/Kyoto/Animation/CPASParmInfo.hpp | 26 ++++++++++++++ include/Kyoto/Animation/CPrimitive.hpp | 2 ++ include/rstl/string.hpp | 2 ++ src/Kyoto/Animation/CPASParmInfo.cpp | 41 +++++++++++++++++++++++ src/Kyoto/Animation/CPrimitive.cpp | 9 +++-- 10 files changed, 118 insertions(+), 59 deletions(-) create mode 100644 include/Kyoto/Animation/CPASParmInfo.hpp create mode 100644 src/Kyoto/Animation/CPASParmInfo.cpp diff --git a/asm/Kyoto/Animation/CPASParmInfo.s b/asm/Kyoto/Animation/CPASParmInfo.s index 3c264075..6858a04b 100644 --- a/asm/Kyoto/Animation/CPASParmInfo.s +++ b/asm/Kyoto/Animation/CPASParmInfo.s @@ -98,41 +98,6 @@ lbl_802E5888: /* 802E58A0 002E2800 38 21 00 30 */ addi r1, r1, 0x30 /* 802E58A4 002E2804 4E 80 00 20 */ blr -.global PutTo__10CPrimitiveCFR13COutputStream -PutTo__10CPrimitiveCFR13COutputStream: -/* 802E58A8 002E2808 94 21 FF E0 */ stwu r1, -0x20(r1) -/* 802E58AC 002E280C 7C 08 02 A6 */ mflr r0 -/* 802E58B0 002E2810 90 01 00 24 */ stw r0, 0x24(r1) -/* 802E58B4 002E2814 93 E1 00 1C */ stw r31, 0x1c(r1) -/* 802E58B8 002E2818 7C 9F 23 78 */ mr r31, r4 -/* 802E58BC 002E281C 93 C1 00 18 */ stw r30, 0x18(r1) -/* 802E58C0 002E2820 7C 7E 1B 78 */ mr r30, r3 -/* 802E58C4 002E2824 80 03 00 00 */ lwz r0, 0(r3) -/* 802E58C8 002E2828 7F E3 FB 78 */ mr r3, r31 -/* 802E58CC 002E282C 90 01 00 0C */ stw r0, 0xc(r1) -/* 802E58D0 002E2830 48 05 9B E9 */ bl FlushShiftRegister__13COutputStreamFv -/* 802E58D4 002E2834 7F E3 FB 78 */ mr r3, r31 -/* 802E58D8 002E2838 38 81 00 0C */ addi r4, r1, 0xc -/* 802E58DC 002E283C 38 A0 00 04 */ li r5, 4 -/* 802E58E0 002E2840 48 05 9C C9 */ bl DoPut__13COutputStreamFPCvUl -/* 802E58E4 002E2844 80 1E 00 04 */ lwz r0, 4(r30) -/* 802E58E8 002E2848 7F E3 FB 78 */ mr r3, r31 -/* 802E58EC 002E284C 90 01 00 08 */ stw r0, 8(r1) -/* 802E58F0 002E2850 48 05 9B C9 */ bl FlushShiftRegister__13COutputStreamFv -/* 802E58F4 002E2854 7F E3 FB 78 */ mr r3, r31 -/* 802E58F8 002E2858 38 81 00 08 */ addi r4, r1, 8 -/* 802E58FC 002E285C 38 A0 00 04 */ li r5, 4 -/* 802E5900 002E2860 48 05 9C A9 */ bl DoPut__13COutputStreamFPCvUl -/* 802E5904 002E2864 7F E4 FB 78 */ mr r4, r31 -/* 802E5908 002E2868 38 7E 00 08 */ addi r3, r30, 8 -/* 802E590C 002E286C 48 05 83 A9 */ bl "PutTo__Q24rstl66basic_string,Q24rstl17rmemory_allocator>CFR13COutputStream" -/* 802E5910 002E2870 80 01 00 24 */ lwz r0, 0x24(r1) -/* 802E5914 002E2874 83 E1 00 1C */ lwz r31, 0x1c(r1) -/* 802E5918 002E2878 83 C1 00 18 */ lwz r30, 0x18(r1) -/* 802E591C 002E287C 7C 08 03 A6 */ mtlr r0 -/* 802E5920 002E2880 38 21 00 20 */ addi r1, r1, 0x20 -/* 802E5924 002E2884 4E 80 00 20 */ blr - .section .sdata2, "a" .balign 8 .global lbl_805AE300 @@ -140,4 +105,3 @@ lbl_805AE300: # ROM: 0x3FABA0 .4byte 0 .4byte 0 - diff --git a/asm/Kyoto/Animation/CPrimitive.s b/asm/Kyoto/Animation/CPrimitive.s index 71bae03d..c3197216 100644 --- a/asm/Kyoto/Animation/CPrimitive.s +++ b/asm/Kyoto/Animation/CPrimitive.s @@ -2,6 +2,41 @@ .section .text, "ax" +.global PutTo__10CPrimitiveCFR13COutputStream +PutTo__10CPrimitiveCFR13COutputStream: +/* 802E58A8 002E2808 94 21 FF E0 */ stwu r1, -0x20(r1) +/* 802E58AC 002E280C 7C 08 02 A6 */ mflr r0 +/* 802E58B0 002E2810 90 01 00 24 */ stw r0, 0x24(r1) +/* 802E58B4 002E2814 93 E1 00 1C */ stw r31, 0x1c(r1) +/* 802E58B8 002E2818 7C 9F 23 78 */ mr r31, r4 +/* 802E58BC 002E281C 93 C1 00 18 */ stw r30, 0x18(r1) +/* 802E58C0 002E2820 7C 7E 1B 78 */ mr r30, r3 +/* 802E58C4 002E2824 80 03 00 00 */ lwz r0, 0(r3) +/* 802E58C8 002E2828 7F E3 FB 78 */ mr r3, r31 +/* 802E58CC 002E282C 90 01 00 0C */ stw r0, 0xc(r1) +/* 802E58D0 002E2830 48 05 9B E9 */ bl FlushShiftRegister__13COutputStreamFv +/* 802E58D4 002E2834 7F E3 FB 78 */ mr r3, r31 +/* 802E58D8 002E2838 38 81 00 0C */ addi r4, r1, 0xc +/* 802E58DC 002E283C 38 A0 00 04 */ li r5, 4 +/* 802E58E0 002E2840 48 05 9C C9 */ bl DoPut__13COutputStreamFPCvUl +/* 802E58E4 002E2844 80 1E 00 04 */ lwz r0, 4(r30) +/* 802E58E8 002E2848 7F E3 FB 78 */ mr r3, r31 +/* 802E58EC 002E284C 90 01 00 08 */ stw r0, 8(r1) +/* 802E58F0 002E2850 48 05 9B C9 */ bl FlushShiftRegister__13COutputStreamFv +/* 802E58F4 002E2854 7F E3 FB 78 */ mr r3, r31 +/* 802E58F8 002E2858 38 81 00 08 */ addi r4, r1, 8 +/* 802E58FC 002E285C 38 A0 00 04 */ li r5, 4 +/* 802E5900 002E2860 48 05 9C A9 */ bl DoPut__13COutputStreamFPCvUl +/* 802E5904 002E2864 7F E4 FB 78 */ mr r4, r31 +/* 802E5908 002E2868 38 7E 00 08 */ addi r3, r30, 8 +/* 802E590C 002E286C 48 05 83 A9 */ bl "PutTo__Q24rstl66basic_string,Q24rstl17rmemory_allocator>CFR13COutputStream" +/* 802E5910 002E2870 80 01 00 24 */ lwz r0, 0x24(r1) +/* 802E5914 002E2874 83 E1 00 1C */ lwz r31, 0x1c(r1) +/* 802E5918 002E2878 83 C1 00 18 */ lwz r30, 0x18(r1) +/* 802E591C 002E287C 7C 08 03 A6 */ mtlr r0 +/* 802E5920 002E2880 38 21 00 20 */ addi r1, r1, 0x20 +/* 802E5924 002E2884 4E 80 00 20 */ blr + .global __ct__10CPrimitiveFR12CInputStream __ct__10CPrimitiveFR12CInputStream: /* 802E5928 002E2888 94 21 FF E0 */ stwu r1, -0x20(r1) diff --git a/configure.py b/configure.py index 2679b011..1ef578da 100755 --- a/configure.py +++ b/configure.py @@ -496,7 +496,7 @@ LIBS = [ ["Kyoto/Animation/CPASAnimParm", True], "Kyoto/Animation/CPASAnimState", "Kyoto/Animation/CPASDatabase", - "Kyoto/Animation/CPASParmInfo", + ["Kyoto/Animation/CPASParmInfo", True], ["Kyoto/Animation/CPrimitive", True], "Kyoto/Animation/CSequenceHelper", ["Kyoto/Animation/CTransition", True], diff --git a/include/Kyoto/Animation/CPASAnimParm.hpp b/include/Kyoto/Animation/CPASAnimParm.hpp index 8f6f3893..dc27bf2b 100644 --- a/include/Kyoto/Animation/CPASAnimParm.hpp +++ b/include/Kyoto/Animation/CPASAnimParm.hpp @@ -36,6 +36,8 @@ public: bool GetBoolValue() const; int GetEnumValue() const; + UParmValue GetParameter() { return x0_value; } + private: UParmValue x0_value; EParmType x4_type; diff --git a/include/Kyoto/Animation/CPASAnimState.hpp b/include/Kyoto/Animation/CPASAnimState.hpp index c3fa6d14..beb30458 100644 --- a/include/Kyoto/Animation/CPASAnimState.hpp +++ b/include/Kyoto/Animation/CPASAnimState.hpp @@ -3,29 +3,13 @@ #include "types.h" -#include "Kyoto/Animation/CharacterCommon.hpp" #include "Kyoto/Animation/CPASAnimParm.hpp" +#include "Kyoto/Animation/CPASParmInfo.hpp" +#include "Kyoto/Animation/CharacterCommon.hpp" #include "rstl/reserved_vector.hpp" #include "rstl/vector.hpp" -class CPASParmInfo { -public: - enum EWeightFunction { - kWF_ExactMatch, - kWF_PercentError, - kWF_AngularPercent, - kWF_NoWeight, - }; - -private: - CPASAnimParm::EParmType x0_type; - EWeightFunction x4_weightFunction; - float x8_weight; - CPASAnimParm::UParmValue xc_min; - CPASAnimParm::UParmValue x10_max; -}; - class CPASAnimInfo { private: uint x0_id; @@ -37,7 +21,7 @@ public: CPASAnimParm GetAnimParmData(int, unsigned int) const; pas::EAnimationState GetStateId() const { return x0_id; } - bool HasAnims() const { return static_cast(x14_anims.size()) != 0; } + bool HasAnims() const { return static_cast< uint >(x14_anims.size()) != 0; } private: pas::EAnimationState x0_id; diff --git a/include/Kyoto/Animation/CPASParmInfo.hpp b/include/Kyoto/Animation/CPASParmInfo.hpp new file mode 100644 index 00000000..3ace209a --- /dev/null +++ b/include/Kyoto/Animation/CPASParmInfo.hpp @@ -0,0 +1,26 @@ +#ifndef _CPASPARMINFO +#define _CPASPARMINFO + +#include "Kyoto/Animation/CPASAnimParm.hpp" + +class CInputStream; +class CPASParmInfo { +public: + enum EWeightFunction { + kWF_Invalid = -1, + kWF_ExactMatch, + kWF_PercentError, + kWF_AngularPercent, + kWF_NoWeight, + }; + + CPASParmInfo(CInputStream& in); +private: + CPASAnimParm::EParmType x0_type; + EWeightFunction x4_weightFunction; + float x8_weight; + CPASAnimParm::UParmValue xc_min; + CPASAnimParm::UParmValue x10_max; +}; + +#endif // _CPASPARMINFO diff --git a/include/Kyoto/Animation/CPrimitive.hpp b/include/Kyoto/Animation/CPrimitive.hpp index 6d66b011..5a840208 100644 --- a/include/Kyoto/Animation/CPrimitive.hpp +++ b/include/Kyoto/Animation/CPrimitive.hpp @@ -6,9 +6,11 @@ #include "rstl/string.hpp" class CInputStream; +class COutputStream; class CPrimitive { public: CPrimitive(CInputStream& in); + void PutTo(COutputStream& out) const; CAssetId GetAnimResId() const { return x0_animId; } private: diff --git a/include/rstl/string.hpp b/include/rstl/string.hpp index 50ff7dfc..709534b1 100644 --- a/include/rstl/string.hpp +++ b/include/rstl/string.hpp @@ -6,6 +6,7 @@ #include "rstl/rmemory_allocator.hpp" class CInputStream; +class COutputStream; namespace rstl { template < typename _CharTp > @@ -112,6 +113,7 @@ public: bool operator<(const basic_string& other) const; const char* data() const { return x0_ptr; } + void PutTo(COutputStream& out) const; }; template < typename _CharTp, typename Traits, typename Alloc > diff --git a/src/Kyoto/Animation/CPASParmInfo.cpp b/src/Kyoto/Animation/CPASParmInfo.cpp new file mode 100644 index 00000000..62654a2d --- /dev/null +++ b/src/Kyoto/Animation/CPASParmInfo.cpp @@ -0,0 +1,41 @@ +#include "Kyoto/Animation/CPASParmInfo.hpp" + +#include "Kyoto/Streams/CInputStream.hpp" + +CPASParmInfo::CPASParmInfo(CInputStream& in) +: x0_type(CPASAnimParm::kPT_None) +, x4_weightFunction(kWF_Invalid) +, x8_weight(0.f) +, xc_min(CPASAnimParm::FromInt32(0).GetParameter()) +, x10_max(CPASAnimParm::FromInt32(0).GetParameter()) { + + CPASAnimParm::EParmType type = CPASAnimParm::EParmType(in.ReadInt32()); + x0_type = type; + x4_weightFunction = EWeightFunction(in.ReadInt32()); + x8_weight = in.ReadFloat(); + + switch (type) { + case CPASAnimParm::kPT_Int32: + xc_min.m_int = in.ReadInt32(); + x10_max.m_int = in.ReadInt32(); + break; + case CPASAnimParm::kPT_UInt32: + xc_min.m_uint = in.ReadLong(); + x10_max.m_uint = in.ReadLong(); + break; + case CPASAnimParm::kPT_Float: + xc_min.m_float = in.ReadFloat(); + x10_max.m_float = in.ReadFloat(); + break; + case CPASAnimParm::kPT_Bool: + xc_min.m_bool = in.ReadBool(); + x10_max.m_bool = in.ReadBool(); + break; + case CPASAnimParm::kPT_Enum: + xc_min.m_int = in.ReadInt32(); + x10_max.m_int = in.ReadInt32(); + break; + default: + break; + } +} diff --git a/src/Kyoto/Animation/CPrimitive.cpp b/src/Kyoto/Animation/CPrimitive.cpp index de199caf..485924ee 100644 --- a/src/Kyoto/Animation/CPrimitive.cpp +++ b/src/Kyoto/Animation/CPrimitive.cpp @@ -1,10 +1,13 @@ #include "Kyoto/Animation/CPrimitive.hpp" #include "Kyoto/Streams/CInputStream.hpp" +#include "Kyoto/Streams/COutputStream.hpp" CPrimitive::CPrimitive(CInputStream& in) -: x0_animId(in.Get()) -, x4_animIdx(in.Get()) -, x8_animName(in) { +: x0_animId(in.Get< CAssetId >()), x4_animIdx(in.Get< int >()), x8_animName(in) {} +void CPrimitive::PutTo(COutputStream& out) const { + out.Put(x0_animId); + out.Put(x4_animIdx); + out.Put(x8_animName); }