From d7facf5956b50ad28523908336c01c9c7ab52ea9 Mon Sep 17 00:00:00 2001 From: kipcode66 Date: Mon, 15 Dec 2025 20:00:16 -0500 Subject: [PATCH] Resource (#2939) * matching Do_destroy from resource.cpp * add missing constants from `float.c` * add numeric_limits for double * set TObject::reset for each version in stb.cpp * improve debug matching --- include/JSystem/JGadget/define.h | 10 ++- include/JSystem/JGadget/std-vector.h | 13 ++- .../JSystem/JStudio/JStudio/functionvalue.h | 3 +- include/JSystem/JStudio/JStudio/stb.h | 14 +++ src/JSystem/JMessage/resource.cpp | 9 +- src/JSystem/JStudio/JStudio/ctb.cpp | 2 +- src/JSystem/JStudio/JStudio/functionvalue.cpp | 57 +++++++----- .../JStudio/JStudio/jstudio-control.cpp | 13 ++- src/JSystem/JStudio/JStudio/stb.cpp | 12 ++- .../MSL_C++/MSL_Common/Include/type_traits.h | 90 +++++++++++++++++++ .../MSL/MSL_C/MSL_Common/Include/limits.h | 12 +++ .../MSL/MSL_C/MSL_Common/Src/float.c | 6 ++ 12 files changed, 203 insertions(+), 38 deletions(-) create mode 100644 src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits.h diff --git a/include/JSystem/JGadget/define.h b/include/JSystem/JGadget/define.h index 394a35a3d0..93ba872ad6 100644 --- a/include/JSystem/JGadget/define.h +++ b/include/JSystem/JGadget/define.h @@ -15,14 +15,14 @@ public: JGadget_outMessage(MessageFunc fn, const char* file, int line); ~JGadget_outMessage(); - JGadget_outMessage& operator<<(int param_1) { return *this << (s32)param_1; } + JGadget_outMessage& operator<<(int param_1) { return *this << (signed long)param_1; } JGadget_outMessage& operator<<(u16); JGadget_outMessage& operator<<(unsigned int); JGadget_outMessage& operator<<(u8 param_1) { return *this << (char)param_1; } JGadget_outMessage& operator<<(const char* str); JGadget_outMessage& operator<<(char); - JGadget_outMessage& operator<<(s32); - JGadget_outMessage& operator<<(u32); + JGadget_outMessage& operator<<(signed long); + JGadget_outMessage& operator<<(unsigned long); JGadget_outMessage& operator<<(const void*); private: @@ -45,6 +45,10 @@ private: JGadget_outMessage out(JGadget_outMessage::warning, __FILE__, line); \ out << msg << (arg); +#define JGADGET_WARNMSG3(line, msg, arg1, arg2, arg3) \ + JGadget_outMessage out(JGadget_outMessage::warning, __FILE__, line); \ + out << msg << (arg1) << (arg2) << (arg3); + #define JGADGET_WARNMSG4(line, msg, arg1, arg2, arg3, arg4) \ JGadget_outMessage out(JGadget_outMessage::warning, __FILE__, line); \ out << msg << (arg1) << (arg2) << (arg3) << (arg4); diff --git a/include/JSystem/JGadget/std-vector.h b/include/JSystem/JGadget/std-vector.h index 77b0f8a540..652ea7c3a3 100644 --- a/include/JSystem/JGadget/std-vector.h +++ b/include/JSystem/JGadget/std-vector.h @@ -29,6 +29,9 @@ struct TVector { T* mPtr; }; + typedef T* iterator; + typedef const T* const_iterator; + TVector(Allocator const& allocator) { mAllocator = allocator; pBegin_ = NULL; @@ -111,9 +114,10 @@ struct TVector { return pBegin_ + diff; } - T* begin() const { return pBegin_; } - - T* end() const { return pEnd_; } + iterator begin() { return pBegin_; } + const_iterator begin() const { return pBegin_; } + iterator end() { return pEnd_; } + const_iterator end() const { return pEnd_; } u32 size() const { if (pBegin_ == 0) { @@ -178,6 +182,9 @@ struct TVector_pointer : TVector_pointer_void { TVector_pointer(const TAllocator& allocator) : TVector_pointer_void(allocator) {} ~TVector_pointer() {} + typedef T* iterator; + typedef const T* const_iterator; + const T* begin() const { return (const T*)TVector_pointer_void::begin(); } T* begin() { return (T*)TVector_pointer_void::begin(); } diff --git a/include/JSystem/JStudio/JStudio/functionvalue.h b/include/JSystem/JStudio/JStudio/functionvalue.h index c221c27c68..74f89eb2d7 100644 --- a/include/JSystem/JStudio/JStudio/functionvalue.h +++ b/include/JSystem/JStudio/JStudio/functionvalue.h @@ -33,7 +33,7 @@ public: virtual TFunctionValueAttributeSet getAttributeSet() = 0; virtual void initialize() = 0; virtual void prepare() = 0; - virtual f64 getValue(f64 arg1) = 0; + virtual TValue getValue(f64 arg1) = 0; static ExtrapolateParameter toFunction_outside(int); @@ -180,6 +180,7 @@ public: inline void operator=(const TData& rhs) { f32data = rhs.f32data; } u32 get_unsignedInteger() const { return u32data; } + u32 get_outside() const { return u32data; } f64 get_value() const { return f32data; } union { diff --git a/include/JSystem/JStudio/JStudio/stb.h b/include/JSystem/JStudio/JStudio/stb.h index 72f67c0e19..1b8c3d497d 100644 --- a/include/JSystem/JStudio/JStudio/stb.h +++ b/include/JSystem/JStudio/JStudio/stb.h @@ -43,7 +43,21 @@ public: virtual ~TObject(); void setFlag_operation(u8, int); +#if PLATFORM_SHIELD && !DEBUG + void reset(void const* arg1) { + bSequence_ = 0; + mStatus = STATUS_STILL; + pSequence_next = arg1; + u32Wait_ = 0; + } +#else void reset(void const*); +#endif +#if !DEBUG + void reset() { reset(NULL); } +#else + void reset(); +#endif bool forward(u32); virtual void do_begin(); virtual void do_end(); diff --git a/src/JSystem/JMessage/resource.cpp b/src/JSystem/JMessage/resource.cpp index 2b1ddf7068..0007e370af 100644 --- a/src/JSystem/JMessage/resource.cpp +++ b/src/JSystem/JMessage/resource.cpp @@ -116,12 +116,11 @@ JMessage::TResource* JMessage::TResourceContainer::TCResource::Do_create() { } void JMessage::TResourceContainer::TCResource::Do_destroy(JMessage::TResource* pResource) { - #if DEBUG +#if DEBUG delete pResource; - #else - // Fake Match - extra null comparison when not doing the conversion - delete (void*)pResource; - #endif +#else + operator delete(pResource); +#endif } JMessage::TResourceContainer::TResourceContainer() : encodingType_(0), pfnParseCharacter_(NULL) {} diff --git a/src/JSystem/JStudio/JStudio/ctb.cpp b/src/JSystem/JStudio/JStudio/ctb.cpp index 9d98328def..db86c69e77 100644 --- a/src/JSystem/JStudio/JStudio/ctb.cpp +++ b/src/JSystem/JStudio/JStudio/ctb.cpp @@ -59,7 +59,7 @@ JStudio::ctb::TObject* JStudio::ctb::TControl::getObject_index(u32 param_0) { return 0; } JGadget::TLinkList::iterator aiStack_14 = ocObject_.begin(); - std::advance_fake(aiStack_14, param_0); + std::advance(aiStack_14, param_0); return &*aiStack_14; } diff --git a/src/JSystem/JStudio/JStudio/functionvalue.cpp b/src/JSystem/JStudio/JStudio/functionvalue.cpp index 52e642b711..7ca04c6252 100644 --- a/src/JSystem/JStudio/JStudio/functionvalue.cpp +++ b/src/JSystem/JStudio/JStudio/functionvalue.cpp @@ -7,6 +7,7 @@ #include "JSystem/JGadget/linklist.h" #include "math.h" #include "stdlib.h" +#include "limits.h" namespace JStudio { @@ -261,13 +262,13 @@ f64 TFunctionValue_composite::getValue(f64 arg1) { f64 TFunctionValue_composite::composite_raw(TVector_pointer const& param_1, TData const& param_2, f64 param_3) { u32 index = param_2.get_unsignedInteger(); - u32 size = param_1.size(); - if (index >= size) { + if (index >= param_1.size()) { return 0.0; } - TFunctionValue** local_18 = (TFunctionValue**)param_1.begin(); - std::advance_pointer(local_18, index); - TFunctionValue* piVar4 = *local_18; + TFunctionValue** p = (TFunctionValue**)param_1.begin(); + std::advance(p, index); + JUT_ASSERT(0x247, p!=0); + TFunctionValue* piVar4 = *p; return piVar4->getValue(param_3); } @@ -284,9 +285,9 @@ f64 TFunctionValue_composite::composite_index(TVector_pointer c TFunctionValue** local_148 = (TFunctionValue**)param_1.begin(); TFunctionValue* pFront = *local_148; JUT_ASSERT(599, pFront!=NULL); - f64 dVar4 = pFront->getValue(param_3); - s32 index = floor(dVar4); - u32 uVar2 = param_2.get_unsignedInteger(); + TValue fData = pFront->getValue(param_3); + s32 index = floor(fData); + u32 uVar2 = param_2.get_outside(); switch (uVar2) { case 0: case 3: @@ -360,8 +361,9 @@ f64 TFunctionValue_composite::composite_add(TVector_pointer con f64 dVar4 = param_2.get_value(); TContainerEnumerator_const_TVector aTStack_18(param_1); while (aTStack_18) { - TFunctionValue* const* ppiVar3 = *aTStack_18; - TFunctionValue* piVar3 = *ppiVar3; + TFunctionValue* const* p = *aTStack_18; + JUT_ASSERT(0x2a1, p!=0); + TFunctionValue* piVar3 = *p; dVar4 += piVar3->getValue(param_3); } return dVar4; @@ -382,8 +384,9 @@ f64 TFunctionValue_composite::composite_subtract(TVector_pointergetValue(param_3); while (aTStack_18) { - TFunctionValue* const* ppiVar3 = *aTStack_18; - TFunctionValue* piVar3 = *ppiVar3; + TFunctionValue* const* p = *aTStack_18; + JUT_ASSERT(0x2b5, p!=0); + TFunctionValue* piVar3 = *p; dVar4 -= piVar3->getValue(param_3); } dVar4 -= param_2.f32data; @@ -399,8 +402,9 @@ f64 TFunctionValue_composite::composite_multiply(TVector_pointer aTStack_18(param_1); while (aTStack_18) { - TFunctionValue* const* ppiVar3 = *aTStack_18; - TFunctionValue* piVar3 = *ppiVar3; + TFunctionValue* const* p = *aTStack_18; + JUT_ASSERT(0x2c5, p!=0); + TFunctionValue* piVar3 = *p; dVar4 *= piVar3->getValue(param_3); } return dVar4; @@ -419,18 +423,29 @@ f64 TFunctionValue_composite::composite_divide(TVector_pointer TFunctionValue* const* local_148 = *aTStack_18; TFunctionValue* pFront = *local_148; JUT_ASSERT(724, pFront!=NULL); - f64 dVar4 = pFront->getValue(param_3); + TValue fData = pFront->getValue(param_3); while (aTStack_18) { - TFunctionValue* const* ppiVar3 = *aTStack_18; - TFunctionValue* piVar3 = *ppiVar3; - dVar4 /= piVar3->getValue(param_3); + TFunctionValue* const* p = *aTStack_18; + JUT_ASSERT(0x2d9, p!=0); + TFunctionValue* piVar3 = *p; + fData /= piVar3->getValue(param_3); + JGADGET_ASSERTWARN(0x2db, fData!=TValue(0)); } - dVar4 /= param_2.f32data; - return dVar4; +#if DEBUG + TValue v = param_2.get_value(); + JGADGET_ASSERTWARN(0x2df, fData!=TValue(0)); +#endif + fData /= param_2.f32data; + return fData; } +#if PLATFORM_WII || PLATFORM_SHIELD +#define NUMERIC_LIMIT double +#else +#define NUMERIC_LIMIT float +#endif -TFunctionValue_constant::TFunctionValue_constant() : fValue_(NAN) {} +TFunctionValue_constant::TFunctionValue_constant() : fValue_(std::numeric_limits::signaling_NaN()) {} u32 TFunctionValue_constant::getType() const { return 2; diff --git a/src/JSystem/JStudio/JStudio/jstudio-control.cpp b/src/JSystem/JStudio/JStudio/jstudio-control.cpp index b58fb20f0f..649501b4c9 100644 --- a/src/JSystem/JStudio/JStudio/jstudio-control.cpp +++ b/src/JSystem/JStudio/JStudio/jstudio-control.cpp @@ -81,15 +81,24 @@ void JStudio::TFactory::appendCreateObject(JStudio::TCreateObject* param_0) { } -JStudio::TObject* JStudio::TFactory::create(JStudio::stb::data::TParse_TBlock_object const& param_0) { +JStudio::TObject* JStudio::TFactory::create(JStudio::stb::data::TParse_TBlock_object const& rParse) { JGadget::TContainerEnumerator > aTStack_368(mList); while(aTStack_368) { TCreateObject& piVar1 = *aTStack_368; JStudio::TObject* obj; - if (piVar1.create(&obj, param_0)) { + if (piVar1.create(&obj, rParse)) { return obj; } } +#if DEBUG + u32 type = rParse.get_type(); + char a5c[8]; + stb::data::toString_block(a5c, type); + const char* szID = (const char*)rParse.get_ID(); + JGADGET_ASSERTWARN(0x108, rParse.get_IDSize()>0); + JGADGET_ASSERTWARN(0x109, szID[rParse.get_IDSize()-1]=='\\0'); + JGADGET_WARNMSG3(0x10c, "ID not found\n demo object : ", szID, "\n type : ", a5c); +#endif return NULL; } diff --git a/src/JSystem/JStudio/JStudio/stb.cpp b/src/JSystem/JStudio/JStudio/stb.cpp index 776f6c39f8..6a2f6515c7 100644 --- a/src/JSystem/JStudio/JStudio/stb.cpp +++ b/src/JSystem/JStudio/JStudio/stb.cpp @@ -67,12 +67,20 @@ void TObject::setFlag_operation(u8 op, int val) { } } +#if !PLATFORM_SHIELD || DEBUG void TObject::reset(const void* arg1) { bSequence_ = 0; mStatus = STATUS_STILL; pSequence_next = arg1; u32Wait_ = 0; } +#endif + +#if DEBUG +void TObject::reset() { + reset(NULL); +} +#endif bool TObject::forward(u32 arg1) { bool temp = false; @@ -334,10 +342,10 @@ TObject* TControl::getObject(void const* param_0, u32 param_1) { void TControl::reset() { resetStatus_(); - mObject_control.reset(NULL); + mObject_control.reset(); JGadget::TContainerEnumerator > aTStack_18(mObjectContainer); while (aTStack_18) { - (*aTStack_18).reset(NULL); + (*aTStack_18).reset(); } } diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits.h new file mode 100644 index 0000000000..14c7f35734 --- /dev/null +++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits.h @@ -0,0 +1,90 @@ +#ifndef MSL_TYPE_TRAITS_H_ +#define MSL_TYPE_TRAITS_H_ + +#include + +namespace std { + // helper class + template struct integral_constant { static const T value = v;}; + + typedef integral_constant true_type; + typedef integral_constant false_type; + + template + struct enable_if {}; + + template + struct enable_if { typedef T type; }; + + template struct remove_reference { typedef T type; }; + template struct remove_reference { typedef T type; }; + + template + struct conditional { typedef T type; }; + + template + struct conditional { typedef F type; }; + + template + struct is_array : false_type {}; + + template + struct is_array : std::true_type {}; + + template + struct is_array : std::true_type {}; + + template + struct add_pointer + { + typedef T* type; + }; + template + struct add_pointer + { + typedef T* type; + }; + template + struct add_pointer + { + typedef T* type; + }; + template + struct add_pointer + { + typedef T* type; + }; + template + struct add_pointer + { + typedef T* type; + }; + + template + struct remove_extent { typedef T type; }; + + template + struct remove_extent { typedef T type; }; + + template + struct remove_extent { typedef T type; }; + + template struct remove_cv { typedef T type; }; + template struct remove_cv { typedef T type; }; + template struct remove_cv { typedef T type; }; + template struct remove_cv { typedef T type; }; + + template struct remove_const { typedef T type; }; + template struct remove_const { typedef T type; }; + + template struct remove_volatile { typedef T type; }; + template struct remove_volatile { typedef T type; }; + + template + struct is_same : std::false_type {}; + + template + struct is_same : std::true_type {}; +} + +#endif diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/limits.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/limits.h index b04a57536e..e8f381874e 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/limits.h +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/limits.h @@ -104,8 +104,20 @@ class numeric_limits { public: inline static float min(); inline static float max() { return FLT_MAX; } + inline static float signaling_NaN() { return *(float*)__float_nan; } }; +#if __REVOLUTION_SDK__ +template <> +class numeric_limits { +public: + static const unsigned long long x = 0x7ff0000000000001ULL; + inline static double min(); + inline static double max(); + inline static double signaling_NaN() { return *reinterpret_cast(&x); } +}; +#endif + } // namespace std #endif #endif diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c index 782bc99688..3455dbf930 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c @@ -4,6 +4,12 @@ unsigned long __float_nan[] = {0x7FFFFFFF}; unsigned long __float_huge[] = {0x7F800000}; +#if !__REVOLUTION_SDK__ unsigned long __float_max[] = {0x7F7FFFFF}; unsigned long __float_epsilon[] = {0x34000000}; +#endif + +#if DEBUG +unsigned long long __double_huge[] = {0x7ff0000000000000ULL}; +#endif