summaryrefslogtreecommitdiff
path: root/src/JSystem
diff options
context:
space:
mode:
authorkipcode66 <kipcode66@gmail.com>2025-12-15 20:00:16 -0500
committerGitHub <noreply@github.com>2025-12-15 17:00:16 -0800
commitd7facf5956b50ad28523908336c01c9c7ab52ea9 (patch)
treedaccdf4b8a69ecd701e8d755a571ff00b64b69c6 /src/JSystem
parent4e6dffff5a325365dce234d3b7daba60dc3245c0 (diff)
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
Diffstat (limited to 'src/JSystem')
-rw-r--r--src/JSystem/JMessage/resource.cpp9
-rw-r--r--src/JSystem/JStudio/JStudio/ctb.cpp2
-rw-r--r--src/JSystem/JStudio/JStudio/functionvalue.cpp57
-rw-r--r--src/JSystem/JStudio/JStudio/jstudio-control.cpp13
-rw-r--r--src/JSystem/JStudio/JStudio/stb.cpp12
5 files changed, 62 insertions, 31 deletions
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<TObject, -12>::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<TFunctionValue*> 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<TFunctionValue*> 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<TFunctionValue*> con
f64 dVar4 = param_2.get_value();
TContainerEnumerator_const_TVector<TFunctionValue*> 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_pointer<TFunctionValue*
JUT_ASSERT(688, pFront!=NULL);
f64 dVar4 = pFront->getValue(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<TFunctionValue*
f64 dVar4 = param_2.get_value();
TContainerEnumerator_const_TVector<TFunctionValue*> 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*>
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<NUMERIC_LIMIT>::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<JGadget::TLinkList<TCreateObject, -4> > 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<JGadget::TLinkList<JStudio::stb::TObject, -12> > aTStack_18(mObjectContainer);
while (aTStack_18) {
- (*aTStack_18).reset(NULL);
+ (*aTStack_18).reset();
}
}