More jstudio work (#2048)

This commit is contained in:
hatal175
2024-01-26 00:50:55 +02:00
committed by GitHub
parent 4640b758c9
commit 1ea10fcc63
80 changed files with 834 additions and 2229 deletions
+40 -11
View File
@@ -256,28 +256,57 @@ struct TLinkList_factory : public TLinkList<T, I> {
}
};
template <typename T, int I>
template <typename T>
struct TEnumerator {
inline TEnumerator(typename TLinkList<T, I>::const_iterator _current,
typename TLinkList<T, I>::const_iterator _end)
inline TEnumerator(T _current, T _end)
: current(_current), end(_end) {}
bool isEnd() const { return current.node == end.node; }
bool isEnd() const { return current != end; }
operator bool() const { return isEnd(); }
T& operator*() {
T& rv = (T&)*current;
T operator*() {
T rv = current;
++current;
return rv;
}
TLinkList<T, I>::const_iterator current;
TLinkList<T, I>::const_iterator end;
T current;
T end;
};
// TEnumerator2 should be the same but there are two issues:
// 1. How to derive the iterator return type for operator* (the debug makes it seem like operator* is called
// so the return value should be what the iterator points to)
// 2. Calling the * operator seems to make functions using TEnumerator<T*> not work. See
// JStudio::TAdaptor::adaptor_setVariableValue_n
// Perhaps template specialization?
template <typename Iterator, typename T>
struct TEnumerator2 {
inline TEnumerator2(Iterator _current, Iterator _end)
: current(_current), end(_end) {}
bool isEnd() const { return current != end; }
operator bool() const { return isEnd(); }
T& operator*() {
T& rv = *current;
++current;
return rv;
}
Iterator current;
Iterator end;
};
template <typename T, int I>
struct TContainerEnumerator_const : public TEnumerator<T, I> {
inline TContainerEnumerator_const(const T* param_0)
: TEnumerator<T, I>(param_0->begin(), param_0->end()) {}
struct TContainerEnumerator : public TEnumerator2<TLinkList<T, I>::iterator, T> {
inline TContainerEnumerator(TLinkList<T, I>* param_0)
: TEnumerator2<TLinkList<T, I>::iterator, T>(param_0->begin(), param_0->end()) {}
};
template <typename T, int I>
struct TContainerEnumerator_const : public TEnumerator2<TLinkList<T, I>::const_iterator, const T> {
inline TContainerEnumerator_const(const TLinkList<T, I>* param_0)
: TEnumerator2<TLinkList<T, I>::const_iterator, const T>(param_0->begin(), param_0->end()) {}
};
}; // namespace JGadget
+31
View File
@@ -19,6 +19,28 @@ struct TVec3 {
}
};
template <>
struct TVec3<double> {
double x, y, z;
void set(double x_, double y_, double z_) {
x = x_;
y = y_;
z = z_;
}
inline TVec3<double>& operator*=(double b) {
scale(b);
return *this;
}
void scale(double b) {
x *= b;
y *= b;
z *= b;
}
};
template <>
struct TVec3<s16> {
s16 x, y, z;
@@ -422,6 +444,15 @@ struct TUtil {
}
};
template<>
struct TUtil<double> {
static inline double epsilon() { return 32.0f * FLT_EPSILON; }
static inline double one() { return 1.0; }
static inline double atan2(double x, double y) { return atan2(x, y); }
static inline double asin(double x) { return asin(x); }
static inline double halfPI() { return 1.5707963267948966; }
};
// clang-format on
} // namespace JGeometry
+4 -1
View File
@@ -14,6 +14,8 @@ struct TObject : public object::TObject_ID {
JUT_ASSERT(82, pData_!=0);
}
/* 80280F18 */ virtual ~TObject() = 0;
virtual int getScheme() const = 0;
const void* getData() const { return pData_; }
/* 0x08 vtable */
/* 0x0C */ JGadget::TLinkListNode ocObject_;
@@ -111,7 +113,7 @@ struct TObject_TxyzRy : public TObject {
/* 80280F60 */ TObject_TxyzRy(JStudio::ctb::data::TParse_TBlock const&);
/* 80281554 */ virtual ~TObject_TxyzRy();
/* 80280FBC */ virtual bool getScheme() const;
/* 80280FBC */ virtual int getScheme() const;
};
struct TFactory {
@@ -133,6 +135,7 @@ struct TControl {
/* 80281230 */ JStudio::ctb::TObject* getObject_index(u32);
TFactory* getFactory() { return pFactory_; }
void setFactory(TFactory* factory) { pFactory_ = factory; }
/* 0x4 */ TFactory* pFactory_;
/* 0x8 */ JGadget::TLinkList<TObject, -12> mList;
+1
View File
@@ -68,6 +68,7 @@ public:
/* 802848D4 */ TObject* getObject_index(u32);
TFactory* getFactory() const { return pFactory; }
void setFactory(TFactory* factory) { pFactory = factory; }
private:
/* 0x4 */ TFactory* pFactory;
@@ -8,9 +8,11 @@
#include "dolphin/mtx/vec.h"
namespace JStudio {
struct TObject;
struct TCreateObject {
TCreateObject() {}
/* 80285488 */ virtual ~TCreateObject() = 0;
virtual bool create(TObject**, JStudio::stb::data::TParse_TBlock_object const&) = 0;
/* 0x4 */ JGadget::TLinkListNode mNode;
}; // Size: 0xC
@@ -19,7 +21,7 @@ struct TFactory : public stb::TFactory {
TFactory() {}
/* 802854D0 */ virtual ~TFactory();
/* 802855AC */ virtual void create(JStudio::stb::data::TParse_TBlock_object const&);
/* 802855AC */ virtual TObject* create(JStudio::stb::data::TParse_TBlock_object const&);
/* 80285560 */ void appendCreateObject(JStudio::TCreateObject*);
@@ -36,10 +38,10 @@ public:
/* 80285114 */ TControl();
/* 802851AC */ virtual ~TControl();
/* 80285228 */ void setFactory(JStudio::TFactory*);
/* 80285250 */ void transformOnSet_setOrigin_TxyzRy(Vec const&, f32);
/* 802852D0 */ void transformOnGet_setOrigin_TxyzRy(Vec const&, f32);
/* 80285368 */ void transform_setOrigin_ctb(JStudio::ctb::TObject const&);
/* 8028543C */ void transform_setOrigin_ctb_index(u32);
/* 80285250 */ int transformOnSet_setOrigin_TxyzRy(Vec const&, f32);
/* 802852D0 */ int transformOnGet_setOrigin_TxyzRy(Vec const&, f32);
/* 80285368 */ int transform_setOrigin_ctb(JStudio::ctb::TObject const&);
/* 8028543C */ bool transform_setOrigin_ctb_index(u32);
void stb_destroyObject_all() { stb::TControl::destroyObject_all(); }
void fvb_destroyObject_all() { fvb_Control.destroyObject_all(); }
@@ -68,7 +70,36 @@ public:
transform_setOrigin_TxyzRy(xyz, rotY);
}
void setSecondPerFrame(double param_0) { mSecondPerFrame = param_0; }
void setSecondPerFrame(f64 param_0) { mSecondPerFrame = param_0; }
f64 getSecondPerFrame() const { return mSecondPerFrame; }
ctb::TObject* ctb_getObject_index(u32 index) {
return ctb_Control.getObject_index(index);
}
fvb::TObject* fvb_getObject(const void* param_1, u32 param_2) {
return fvb_Control.getObject(param_1, param_2);
}
fvb::TObject* fvb_getObject_index(u32 index) {
return fvb_Control.getObject_index(index);
}
TFunctionValue* getFunctionValue(const void* param_1, u32 param_2) {
fvb::TObject* obj = fvb_getObject(param_1, param_2);
if (obj == NULL) {
return NULL;
}
return obj->referFunctionValue();
}
TFunctionValue* getFunctionValue_index(u32 index) {
fvb::TObject* obj = fvb_getObject_index(index);
if (obj == NULL) {
return NULL;
}
return obj->referFunctionValue();
}
/* 0x58 */ f64 mSecondPerFrame;
/* 0x60 */ fvb::TControl fvb_Control;
@@ -78,19 +109,21 @@ public:
/* 0x8C */ Vec field_0x8c;
/* 0x98 */ Vec field_0x98;
/* 0xA4 */ f32 mTransformOnSet_RotationY;
/* 0xA8 */ u8 field_0xa8[4];
/* 0xA8 */ f32 field_0xa8;
/* 0xAC */ Mtx mTransformOnSet_Matrix;
/* 0xDC */ Mtx mTransformOnGet_Matrix;
};
struct TParse : public stb::TParse {
/* 8028566C */ TParse(JStudio::TControl*);
/* 80285844 */ void parseBlock_block_fvb_(JStudio::stb::data::TParse_TBlock const&, u32);
/* 802858F0 */ void parseBlock_block_ctb_(JStudio::stb::data::TParse_TBlock const&, u32);
/* 80285844 */ bool parseBlock_block_fvb_(JStudio::stb::data::TParse_TBlock const&, u32);
/* 802858F0 */ bool parseBlock_block_ctb_(JStudio::stb::data::TParse_TBlock const&, u32);
/* 802856A8 */ virtual ~TParse();
/* 80285708 */ virtual void parseHeader(JStudio::stb::data::TParse_THeader const&, u32);
/* 802857E4 */ virtual void parseBlock_block(JStudio::stb::data::TParse_TBlock const&, u32);
/* 80285708 */ virtual bool parseHeader(JStudio::stb::data::TParse_THeader const&, u32);
/* 802857E4 */ virtual bool parseBlock_block(JStudio::stb::data::TParse_TBlock const&, u32);
TControl* getControl() { return (TControl*)stb::TParse::getControl(); }
};
}; // namespace JStudio
@@ -2,12 +2,59 @@
#define JSTUDIO_MATH_H
#include "dolphin/mtx.h"
#include "math.h"
namespace JStudio {
namespace math {
/* 802859DC */ void getRotation_xyz(MtxP, f32, f32, f32);
/* 80285B44 */ void getTransformation_SRxyzT(MtxP, Vec const&, Vec const&, Vec const&);
/* 80285BCC */ void getFromTransformation_SRxyzT(Vec*, Vec*, Vec*, CMtxP);
inline void getRotation_y(Mtx param_0, f32 param_1) {
MTXRotRad(param_0, 0x79, DEG_TO_RAD(param_1));
}
inline void getTransformation_RyT(Mtx param_0, const Vec& param_1, f32 param_2) {
Mtx amStack_40;
getRotation_y(amStack_40, param_2);
MTXTransApply(amStack_40, param_0, param_1.x, param_1.y, param_1.z);
}
inline void rotate_y(Mtx param_0, Mtx param_1, f32 param_2) {
Mtx afStack_38;
getRotation_y(afStack_38, param_2);
MTXConcat(afStack_38, param_1, param_0);
}
inline void rotate_xyz(Mtx param_0, Mtx param_1, f32 param_2, f32 param_3, f32 param_4) {
Mtx amStack_30;
getRotation_xyz(amStack_30, param_2, param_3, param_4);
MTXConcat(amStack_30, param_0, param_1);
}
inline void rotate_xyz(Mtx param_0, Mtx param_1, const Vec& param_2) {
rotate_xyz(param_0, param_1, param_2.x, param_2.y, param_2.z);
}
inline f32 getFromTransformation_Sn(CMtxP param_1, u32 param_2) {
Vec local_18;
local_18.x = param_1[0][param_2];
local_18.y = param_1[1][param_2];
local_18.z = param_1[2][param_2];
return VECMag(&local_18);
}
inline void getFromTransformation_S(CMtxP param_1, Vec* param_2) {
param_2->x = getFromTransformation_Sn(param_1, 0);
param_2->y = getFromTransformation_Sn(param_1, 1);
param_2->z = getFromTransformation_Sn(param_1, 2);
}
inline void getFromTransformation_T(CMtxP param_1, Vec* param_2) {
param_2->x = param_1[0][3];
param_2->y = param_1[1][3];
param_2->z = param_1[2][3];
}
};
}; // namespace JStudio
@@ -3,12 +3,18 @@
#include "JSystem/JStudio/JStudio/ctb.h"
#include "JSystem/JStudio/JStudio/jstudio-control.h"
#include "limits.h"
typedef struct _GXColor GXColor;
namespace JStudio {
namespace data {
enum TEOperationData {
UNK_0x1 = 0x1,
UNK_0x2 = 0x2,
UNK_0x3 = 0x3,
UNK_0x10 = 0x10,
UNK_0x12 = 0x12,
UNK_0x19 = 0x19,
};
};
@@ -16,6 +22,7 @@ namespace data {
struct TAdaptor;
struct TVariableValue {
struct TOutput {
virtual void operator()(f32, JStudio::TAdaptor*) const = 0;
/* 80285E0C */ ~TOutput();
};
@@ -25,20 +32,69 @@ struct TVariableValue {
};
/* 80285E54 */ void update(f64, JStudio::TAdaptor*);
/* 80285EB8 */ void update_immediate_(JStudio::TVariableValue*, f64);
/* 80285ECC */ void update_time_(JStudio::TVariableValue*, f64);
/* 80285F08 */ void update_functionValue_(JStudio::TVariableValue*, f64);
/* 80285EB8 */ static void update_immediate_(JStudio::TVariableValue*, f64);
/* 80285ECC */ static void update_time_(JStudio::TVariableValue*, f64);
/* 80285F08 */ static void update_functionValue_(JStudio::TVariableValue*, f64);
/* 8028B568 */ TVariableValue();
void setValue_immediate(f32 value) {
field_0x8 = &update_immediate_;
field_0x4 = 0;
field_0xc.val = value;
}
void setValue_none() {
field_0x8 = NULL;
}
void setValue_time(f32 value) {
field_0x8 = &update_time_;
field_0x4 = 0;
field_0xc.val = value;
}
void setValue_functionValue(TFunctionValue* value) {
field_0x8 = &update_functionValue_;
field_0x4 = 0;
field_0xc.fv = value;
}
f32 getValue() const { return mValue; }
template<typename T>
T getValue_clamp() const {
f32 val = mValue;
if (val <= std::numeric_limits<T>::min()) {
return std::numeric_limits<T>::min();
} else if (val >= std::numeric_limits<T>::max()) {
return std::numeric_limits<T>::max();
}
return val;
}
u8 getValue_uint8() const { return getValue_clamp<u8>(); }
void forward(u32 param_0) {
if (std::numeric_limits<u32>::max() - field_0x4 <= param_0) {
field_0x4 = std::numeric_limits<u32>::max();
} else {
field_0x4 += param_0;
}
}
static u8 soOutput_none_[4 + 4 /* padding */];
/* 0x00 */ f32 mValue;
/* 0x04 */ u32 field_0x4;
/* 0x08 */ void (*field_0x8)(TVariableValue*, double);
/* 0x0C */ TFunctionValue* field_0xc;
/* 0x0C */ union {
TFunctionValue* fv;
f32 val;
} field_0xc;
/* 0x10 */ TOutput* pOutput_;
}; // Size: 0x14
typedef void (TObject::*paragraphFunc)(u32, void const*, u32);
class TObject : public stb::TObject {
public:
/* 80286864 */ TObject(JStudio::stb::data::TParse_TBlock_object const&, JStudio::TAdaptor*);
@@ -51,6 +107,9 @@ public:
/* 8028680C */ virtual void do_wait(u32);
/* 8028682C */ virtual void do_data(void const*, u32, void const*, u32);
TAdaptor* getAdaptor() { return mpAdaptor; }
TControl* getControl() { return (TControl*)stb::TObject::getControl(); }
void prepareAdaptor() {
if (mpAdaptor != NULL) {
// mpAdaptor->adaptor_setObject_(this);
@@ -75,8 +134,11 @@ public:
};
struct TAdaptor {
struct TSetVariableValue_immediate {};
struct TSetVariableValue_immediate {
u32 field_0x0;
f32 field_0x4;
};
typedef void (*setVarFunc)(JStudio::TAdaptor*, JStudio::TControl*, u32, void const*, u32);
/* 80285FD0 */ virtual ~TAdaptor() = 0;
/* 80286018 */ virtual void adaptor_do_prepare();
/* 8028601C */ virtual void adaptor_do_begin();
@@ -96,21 +158,33 @@ struct TAdaptor {
/* 802862AC */ void adaptor_setVariableValue_GXColor(u32 const*, GXColor const&);
/* 8028638C */ void adaptor_getVariableValue_GXColor(GXColor*, u32 const*) const;
/* 802864D8 */ void adaptor_updateVariableValue(JStudio::TControl*, u32);
/* 8028656C */ void adaptor_setVariableValue_VOID_(JStudio::TAdaptor*, JStudio::TControl*, u32,
/* 8028656C */ static void adaptor_setVariableValue_VOID_(JStudio::TAdaptor*, JStudio::TControl*, u32,
void const*, u32);
/* 80286584 */ void adaptor_setVariableValue_IMMEDIATE_(JStudio::TAdaptor*, JStudio::TControl*,
/* 80286584 */ static void adaptor_setVariableValue_IMMEDIATE_(JStudio::TAdaptor*, JStudio::TControl*,
u32, void const*, u32);
/* 802865B0 */ void adaptor_setVariableValue_TIME_(JStudio::TAdaptor*, JStudio::TControl*, u32,
/* 802865B0 */ static void adaptor_setVariableValue_TIME_(JStudio::TAdaptor*, JStudio::TControl*, u32,
void const*, u32);
/* 802865DC */ void adaptor_setVariableValue_FVR_NAME_(JStudio::TAdaptor*, JStudio::TControl*,
/* 802865DC */ static void adaptor_setVariableValue_FVR_NAME_(JStudio::TAdaptor*, JStudio::TControl*,
u32, void const*, u32);
/* 80286648 */ void adaptor_setVariableValue_FVR_INDEX_(JStudio::TAdaptor*, JStudio::TControl*,
/* 80286648 */ static void adaptor_setVariableValue_FVR_INDEX_(JStudio::TAdaptor*, JStudio::TControl*,
u32, void const*, u32);
void adaptor_setObject_(const TObject* pObject) {
pObject_ = pObject;
}
TVariableValue* adaptor_referVariableValue(u32 param_0) {
return &pValue_[param_0];
}
void adaptor_setVariableValue_immediate(u32 param_0, f32 param_1) {
adaptor_referVariableValue(param_0)->setValue_immediate(param_1);
}
const TVariableValue* adaptor_getVariableValue(u32 param_0) const {
return &pValue_[param_0];
}
/* 0x4 */ const TObject* pObject_;
/* 0x8 */ TVariableValue* pValue_;
/* 0xC */ u32 u;
@@ -21,6 +21,7 @@ public:
u16 get_byteOrder() const { return get()->byte_order; }
u16 get_version() const { return get()->version; }
u32 get_blockNumber() const { return get()->block_number; }
const THeader::Target& get_target() const { return get()->target; }
};
class TParse_TBlock : public TParseData_aligned<4> {
@@ -32,6 +33,7 @@ public:
u32 get_size() const { return get()->size; }
u32 get_type() const { return get()->type; }
const void* getContent() const { return ((char*)getRaw()) + 8;}
};
class TParse_TSequence : public TParseData_aligned<4> {
+4 -2
View File
@@ -7,6 +7,7 @@
#include "global.h"
namespace JStudio {
struct TObject;
namespace stb {
class TControl;
@@ -43,7 +44,7 @@ public:
/* 80288B78 */ void setFlag_operation(u8, int);
/* 80288BD0 */ void reset(void const*);
/* 80288BE8 */ int forward(u32);
/* 80288BE8 */ u8 forward(u32);
/* 80288E18 */ virtual void do_begin();
/* 80288E1C */ virtual void do_end();
/* 80288E20 */ virtual void do_paragraph(u32, void const*, u32);
@@ -110,7 +111,7 @@ public:
TFactory() {}
/* 802895B4 */ virtual ~TFactory();
/* 802895FC */ virtual TObject* create(data::TParse_TBlock_object const&);
/* 802895FC */ virtual JStudio::TObject* create(data::TParse_TBlock_object const&);
/* 80289604 */ virtual void destroy(TObject*);
};
@@ -138,6 +139,7 @@ public:
void resetStatus_() { setStatus_(0); }
bool isSuspended() const { return _54 > 0; }
TFactory* getFactory() const { return pFactory; }
void setFactory(TFactory* factory) { pFactory = factory; }
TObject_control& referObject_control() { return mObject_control; }
int getSuspend() const { return _54; }
void setSuspend(s32 suspend) { mObject_control.setSuspend(suspend); }
@@ -15,7 +15,7 @@ struct TCreateObject : public JStudio::TCreateObject {
}
/* 8028D550 */ virtual ~TCreateObject();
/* 8028D5B0 */ virtual void create(JStudio::TObject**,
/* 8028D5B0 */ virtual bool create(JStudio::TObject**,
JStudio::stb::data::TParse_TBlock_object const&);
/* 8028D624 */ void createObject_JAI_SOUND_(JStudio::stb::data::TParse_TBlock_object const&,
JStudio_JAudio2::TCreateObject*);
@@ -14,7 +14,7 @@ struct TCreateObject : public JStudio::TCreateObject {
}
/* 8028E3A0 */ virtual ~TCreateObject();
/* 8028E400 */ virtual void create(JStudio::TObject**,
/* 8028E400 */ virtual bool create(JStudio::TObject**,
JStudio::stb::data::TParse_TBlock_object const&);
/* 8028E474 */ virtual void emitter_create(u32);
/* 8028E4E4 */ virtual void emitter_destroy(JPABaseEmitter*);
@@ -16,7 +16,7 @@ struct TCreateObject : public JStudio::TCreateObject {
}
/* 80289B00 */ virtual ~TCreateObject();
/* 80289B60 */ virtual void create(JStudio::TObject**,
/* 80289B60 */ virtual bool create(JStudio::TObject**,
JStudio::stb::data::TParse_TBlock_object const&);
/* 0x0C */ const JStage::TSystem* pJSGSystem_;
+45 -1
View File
@@ -3,6 +3,7 @@
#include "dolphin/mtx.h"
#include "JSystem/JMath/JMath.h"
#include "JSystem/JGeometry.h"
namespace JGeometry {
@@ -18,12 +19,55 @@ struct SMatrix34C<f32> {
void identity() { MTXIdentity(data); }
typedef f32 ArrType[4];
void set(const ArrType* src) { JMath::gekko_ps_copy12((f32*)data, (f32*)src); }
void set(const ArrType* src) {
}
operator ArrType*() { return data; }
operator const ArrType*() const { return data; }
};
template <typename T>
struct SMatrix33C {
T data[3][3];
inline T& ref(int i, int j) {
return data[i][j];
}
inline T at(int i, int j) {
return data[i][j];
}
inline void set(T param_1, T param_2, T param_3, T param_4, T param_5,
T param_6, T param_7, T param_8, T param_9) {
ref(0,0) = param_1;
ref(0,1) = param_2;
ref(0,2) = param_3;
ref(1,0) = param_4;
ref(1,1) = param_5;
ref(1,2) = param_6;
ref(2,0) = param_7;
ref(2,1) = param_8;
ref(2,2) = param_9;
}
inline void getEulerXYZ(TVec3<T>* param_1) {
if (at(2, 0) - TUtil<T>::one() >= TUtil<T>::epsilon()) {
param_1->set(TUtil<T>::atan2(at(0,1), at(1,1)), -TUtil<T>::halfPI(), 0.0);
} else {
if (at(2, 0) - TUtil<T>::one() >= TUtil<T>::one() + TUtil<T>::epsilon()) {
param_1->set(TUtil<T>::atan2(at(0, 1), at(1, 1)), TUtil<T>::halfPI(),
0.0);
} else {
param_1->x = TUtil<T>::atan2(at(2, 1), at(2, 2));
param_1->z = TUtil<T>::atan2(at(0, 1), at(0, 0));
param_1->y = TUtil<T>::asin(at(2, 0));
}
}
}
};
template <typename T>
struct TMatrix34 : public T {};
+1 -1
View File
@@ -246,7 +246,7 @@ public:
jstudio_tCreateObject_message() {}
virtual ~jstudio_tCreateObject_message();
virtual void create(JStudio::TObject**, const JStudio::stb::data::TParse_TBlock_object&);
virtual bool create(JStudio::TObject**, const JStudio::stb::data::TParse_TBlock_object&);
};
class jstudio_tAdaptor_message : public JStudio::TAdaptor_message {