summaryrefslogtreecommitdiff
path: root/include/JSystem/JStudio
diff options
context:
space:
mode:
authornotyourav <65437533+notyourav@users.noreply.github.com>2021-11-26 06:50:22 -0800
committerGitHub <noreply@github.com>2021-11-26 15:50:22 +0100
commitc4ef30bc95d3e69eb84cb5efa76598bb6e900662 (patch)
treeac0cfa4dd5179c8ada61a511fe859b83c363008d /include/JSystem/JStudio
parent74ed2da8bc93804373cddf64c0c878603150b699 (diff)
Port JStudio work to new branch (#160)
* build fix * stb * functionvalue * fvb * jstudio cleanup * d
Diffstat (limited to 'include/JSystem/JStudio')
-rw-r--r--include/JSystem/JStudio/JStudio/functionvalue.h386
-rw-r--r--include/JSystem/JStudio/JStudio/fvb-data-parse.h48
-rw-r--r--include/JSystem/JStudio/JStudio/fvb-data.h59
-rw-r--r--include/JSystem/JStudio/JStudio/fvb.h155
-rw-r--r--include/JSystem/JStudio/JStudio/object-id.h23
-rw-r--r--include/JSystem/JStudio/JStudio/stb-data-parse.h106
-rw-r--r--include/JSystem/JStudio/JStudio/stb-data.h63
-rw-r--r--include/JSystem/JStudio/JStudio/stb.h150
8 files changed, 985 insertions, 5 deletions
diff --git a/include/JSystem/JStudio/JStudio/functionvalue.h b/include/JSystem/JStudio/JStudio/functionvalue.h
index 4c5b74e232..35d849e27c 100644
--- a/include/JSystem/JStudio/JStudio/functionvalue.h
+++ b/include/JSystem/JStudio/JStudio/functionvalue.h
@@ -1,6 +1,392 @@
#ifndef FUNCTIONVALUE_H
#define FUNCTIONVALUE_H
+#include "JSystem/JGadget/search.h"
+#include "JSystem/JGadget/vector.h"
#include "dolphin/types.h"
+extern u8 lit_652[];
+
+namespace JStudio {
+
+typedef f64 (*ExtrapolateParameter)(f64, f64);
+
+class TFunctionValue;
+class TFunctionValueAttributeSet;
+
+class TFunctionValueAttribute_refer;
+class TFunctionValueAttribute_range;
+class TFunctionValueAttribute_interpolate;
+
+class TFunctionValue {
+public:
+ enum TEProgress { PROG_INIT };
+ enum TEAdjust { ADJ_INIT };
+ enum TEOutside { OUT_INIT };
+ enum TEInterpolate {};
+
+ /* 80281690 */ TFunctionValue();
+ /* 802816A0 */ virtual ~TFunctionValue() = 0;
+
+ virtual u32 getType() const = 0;
+ virtual TFunctionValueAttributeSet getAttributeSet() = 0;
+ virtual void initialize() = 0;
+ virtual void prepare() = 0;
+ virtual f64 getValue(f64 arg1) = 0;
+
+ /* 80281648 */ static ExtrapolateParameter toFunction_outside(int);
+
+ static ExtrapolateParameter toFunction(TFunctionValue::TEOutside outside) {
+ return toFunction_outside(outside);
+ }
+};
+
+class TFunctionValueAttributeSet_const {
+public:
+ TFunctionValueAttributeSet_const(TFunctionValueAttribute_refer* refer,
+ TFunctionValueAttribute_range* range,
+ TFunctionValueAttribute_interpolate* interp)
+ : refer_(refer), range_(range), interp_(interp) {}
+
+ TFunctionValueAttribute_refer* refer_get() const { return refer_; }
+ TFunctionValueAttribute_range* range_get() const { return range_; }
+ TFunctionValueAttribute_interpolate* interpolate_get() const { return interp_; }
+
+private:
+ /* 0x00 */ TFunctionValueAttribute_refer* refer_;
+ /* 0x04 */ TFunctionValueAttribute_range* range_;
+ /* 0x08 */ TFunctionValueAttribute_interpolate* interp_;
+};
+
+class TFunctionValueAttributeSet : public TFunctionValueAttributeSet_const {
+public:
+ TFunctionValueAttributeSet(TFunctionValueAttribute_refer* refer,
+ TFunctionValueAttribute_range* range,
+ TFunctionValueAttribute_interpolate* interp)
+ : TFunctionValueAttributeSet_const(refer, range, interp) {}
+
+ TFunctionValueAttribute_refer* refer_get() const {
+ return static_cast<const TFunctionValueAttributeSet_const*>(this)->refer_get();
+ }
+ TFunctionValueAttribute_range* range_get() const {
+ return static_cast<const TFunctionValueAttributeSet_const*>(this)->range_get();
+ }
+ TFunctionValueAttribute_interpolate* interpolate_get() const {
+ return static_cast<const TFunctionValueAttributeSet_const*>(this)->interpolate_get();
+ }
+};
+
+class TFunctionValueAttribute_refer : public JGadget::TVector_pointer<TFunctionValue*> {
+public:
+ // TFunctionValueAttribute_refer() :
+ // JGadget::TVector_pointer<TFunctionValue*>(JGadget::TAllocator<void*>()) {}
+ ~TFunctionValueAttribute_refer() {}
+
+ /* 802816E8 */ void refer_initialize();
+
+ const TFunctionValueAttribute_refer* refer_getContainer() const { return this; }
+ JGadget::TVector_pointer<TFunctionValue*>& refer_referContainer() { return *this; }
+ bool refer_isReferring(const TFunctionValue* p) const { return false; } // todo
+};
+
+class TFunctionValueAttribute_range {
+public:
+ /* 80281D18 */ TFunctionValueAttribute_range();
+
+ /* 80281918 */ void range_initialize();
+ /* 8028194C */ void range_prepare();
+ /* 802819F4 */ void range_set(f64, f64);
+ /* 80281A08 */ f64 range_getParameter(f64, f64, f64) const;
+
+ TFunctionValue::TEProgress range_getProgress() const {
+ return (TFunctionValue::TEProgress)mProgress;
+ }
+ void range_setProgress(TFunctionValue::TEProgress progress) { mProgress = progress; }
+ TFunctionValue::TEAdjust range_getAdjust() const { return (TFunctionValue::TEAdjust)mAdjust; }
+ void range_setAdjust(TFunctionValue::TEAdjust adjust) { mAdjust = adjust; }
+ void range_setOutside(TFunctionValue::TEOutside outside) { range_setOutside(outside, outside); }
+ void range_setOutside(TFunctionValue::TEOutside begin, TFunctionValue::TEOutside end) {
+ range_setOutside_begin(begin);
+ range_setOutside_end(end);
+ }
+ void range_setOutside_begin(TFunctionValue::TEOutside begin) { mBegin = begin; }
+ void range_setOutside_end(TFunctionValue::TEOutside end) { mEnd = end; }
+ f64 range_getParameter_outside(f64 arg1) const {
+ f64 temp = arg1 - fBegin_;
+ f64 result = temp;
+ if (temp < *(f64*)&lit_652) {
+ result = TFunctionValue::toFunction(mBegin)(temp, fDifference_);
+ } else if (temp >= fDifference_) {
+ result = TFunctionValue::toFunction(mEnd)(temp, fDifference_);
+ }
+ return result + fBegin_;
+ }
+ f64 range_getParameter_progress(f64 arg1) const { return _20 + _28 * (arg1 - _20); }
+
+private:
+ /* 0x00 */ f64 fBegin_;
+ /* 0x08 */ f64 fEnd_;
+ /* 0x10 */ f64 fDifference_;
+ /* 0x18 */ s8 mProgress;
+ /* 0x19 */ s8 mAdjust;
+ /* 0x1A */ s8 _1a[2];
+ /* 0x1C */ u32 _1c;
+ /* 0x20 */ f64 _20;
+ /* 0x28 */ f64 _28;
+ /* 0x30 */ TFunctionValue::TEOutside mBegin;
+ /* 0x34 */ TFunctionValue::TEOutside mEnd;
+};
+
+class TFunctionValueAttribute_interpolate {
+public:
+ TFunctionValueAttribute_interpolate() : interpolate_(0) {}
+
+ void interpolate_initialize() { interpolate_ = 0; }
+ void interpolate_prepare() {}
+ u32 interpolate_get() const { return interpolate_; }
+ void interpolate_set(TFunctionValue::TEInterpolate interpolate) { interpolate_ = interpolate; }
+
+private:
+ /* 0x0 */ u32 interpolate_;
+};
+
+class TFunctionValue_constant : public TFunctionValue {
+public:
+ /* 8028236C */ TFunctionValue_constant();
+ /* 80283D44 */ virtual ~TFunctionValue_constant() {}
+
+ /* 802823B4 */ virtual u32 getType() const;
+ /* 802823BC */ virtual TFunctionValueAttributeSet getAttributeSet();
+ /* 802823D0 */ virtual void initialize();
+ /* 802823E0 */ virtual void prepare();
+ /* 802823E4 */ virtual f64 getValue(f64);
+
+ void data_set(f64 value) { fValue_ = value; }
+
+private:
+ f64 fValue_;
+};
+
+class TFunctionValue_composite : TFunctionValue, TFunctionValueAttribute_refer {
+public:
+ struct TData {
+ TData(void* data) : u32data((u32)data) {}
+ TData(const void* data) : rawData(data) {}
+ TData(u32 data) : u32data(data) {}
+ TData(f32 data) : f32data(data) {}
+
+ inline void operator=(const TData& rhs) { f32data = rhs.f32data; }
+
+ union {
+ const void* rawData;
+ u32 u32data;
+ f64 f32data;
+ };
+ };
+ typedef f64 (*UnkFunc)(f64, const TFunctionValueAttribute_refer*,
+ const TFunctionValue_composite::TData*);
+ typedef f64 (*CompositeFunc)(const JGadget::TVector_pointer<TFunctionValue>&,
+ const TFunctionValue_composite::TData&, f64);
+
+ /* 80281D5C */ TFunctionValue_composite();
+ /* 80283DA4 */ virtual ~TFunctionValue_composite() {}
+
+ /* 80281DB8 */ virtual u32 getType() const;
+ /* 80281DC0 */ virtual TFunctionValueAttributeSet getAttributeSet();
+ /* 80281DE0 */ virtual void initialize();
+ /* 80281E24 */ virtual void prepare();
+ /* 80281E28 */ virtual f64 getValue(f64);
+ /* 80281E5C */ void composite_raw(TVector_pointer<TFunctionValue*> const&, TData const&, f64);
+ /* 80281EC8 */ void composite_index(TVector_pointer<TFunctionValue*> const&, TData const&, f64);
+ /* 8028202C */ void composite_parameter(TVector_pointer<TFunctionValue*> const&, TData const&,
+ f64);
+ /* 80282094 */ void composite_add(TVector_pointer<JStudio::TFunctionValue*> const&,
+ TData const&, f64);
+ /* 80282118 */ void composite_subtract(TVector_pointer<TFunctionValue*> const&, TData const&,
+ f64);
+ /* 80282200 */ void composite_multiply(TVector_pointer<TFunctionValue*> const&, TData const&,
+ f64);
+ /* 80282284 */ void composite_divide(TVector_pointer<TFunctionValue*> const&, TData const&,
+ f64);
+
+ void data_set(CompositeFunc fn, const TData& dat) {
+ pfn_ = (UnkFunc)fn;
+ data_setData(dat);
+ }
+ const TData* data_getData() const { return &data; }
+ void data_setData(const TData& dat) { data = dat; }
+
+private:
+ UnkFunc pfn_;
+ TData data;
+};
+
+class TFunctionValue_transition : TFunctionValue,
+ TFunctionValueAttribute_range,
+ TFunctionValueAttribute_interpolate {
+public:
+ /* 802823EC */ TFunctionValue_transition();
+ /* 80283CE4 */ virtual ~TFunctionValue_transition() {}
+
+ /* 8028244C */ virtual u32 getType() const;
+ /* 80282454 */ virtual TFunctionValueAttributeSet getAttributeSet();
+ /* 80282484 */ virtual void initialize();
+ /* 802824D0 */ virtual void prepare();
+ /* 802824F4 */ virtual f64 getValue(f64);
+
+ void data_set(f64 a1, f64 a2) {
+ _48 = a1;
+ _50 = a2;
+ }
+
+private:
+ /* 0x48 */ f64 _48;
+ /* 0x50 */ f64 _50;
+};
+
+class TFunctionValue_list : TFunctionValue,
+ TFunctionValueAttribute_range,
+ TFunctionValueAttribute_interpolate {
+public:
+ struct TIndexData_ {
+ f64 _0;
+ f64 _8;
+ u32 _10;
+ };
+ typedef f64 (*update_INTERPOLATE)(const TFunctionValue_list&, const TIndexData_&);
+
+ /* 802826BC */ TFunctionValue_list();
+ virtual ~TFunctionValue_list() {}
+
+ /* 80282720 */ virtual u32 getType() const;
+ /* 80282728 */ virtual TFunctionValueAttributeSet getAttributeSet();
+ /* 80282758 */ virtual void initialize();
+ /* 802827A8 */ virtual void prepare();
+ /* 80282858 */ virtual f64 getValue(f64);
+
+ void data_set(const f32* pf, u32 u) {
+ ASSERT((pf != NULL) || (u == 0));
+ _44 = pf;
+ _48 = u;
+ }
+
+ void data_setInterval(f64 f) {
+ ASSERT(f > TValue(0));
+ _50 = f;
+ }
+
+ /* 80282C10 */ static f64
+ update_INTERPOLATE_NONE_(JStudio::TFunctionValue_list const&,
+ JStudio::TFunctionValue_list::TIndexData_ const&);
+ /* 80282C24 */ static f64
+ update_INTERPOLATE_LINEAR_(JStudio::TFunctionValue_list const&,
+ JStudio::TFunctionValue_list::TIndexData_ const&);
+ /* 80282C58 */ static f64
+ update_INTERPOLATE_PLATEAU_(JStudio::TFunctionValue_list const&,
+ JStudio::TFunctionValue_list::TIndexData_ const&);
+ /* 80282CA8 */ static f64
+ update_INTERPOLATE_BSPLINE_dataMore3_(JStudio::TFunctionValue_list const&,
+ JStudio::TFunctionValue_list::TIndexData_ const&);
+
+private:
+ /* 0x44 */ const f32* _44;
+ /* 0x48 */ u32 _48;
+ /* 0x50 */ f64 _50;
+ /* 0x58 */ update_INTERPOLATE _58;
+};
+
+class TFunctionValue_list_parameter : TFunctionValue,
+ TFunctionValueAttribute_range,
+ TFunctionValueAttribute_interpolate {
+public:
+ struct TIterator_data_ {
+ TIterator_data_(const f32* value) : value_(value) {}
+ TIterator_data_(const TIterator_data_& other) : value_(other.value_) {}
+
+ void operator=(const TIterator_data_& rhs) { value_ = rhs.value_; }
+
+ const f32* get() const { return value_; }
+ void set(const f32* value) { value_ = value; }
+
+ const f32* value_;
+ };
+ typedef f64 (*update_INTERPOLATE)(const TFunctionValue_list_parameter&, f64);
+
+ /* 80282D34 */ TFunctionValue_list_parameter();
+ /* 80283C24 */ virtual ~TFunctionValue_list_parameter() {}
+
+ /* 80282DA0 */ virtual u32 getType() const;
+ /* 80282DA8 */ virtual TFunctionValueAttributeSet getAttributeSet();
+ /* 80282DD8 */ void data_set(f32 const*, u32);
+ /* 80282E08 */ virtual void initialize();
+ /* 80282E60 */ virtual void prepare();
+ /* 80282F10 */ virtual f64 getValue(f64);
+
+ /* 80282FE8 */ static f64
+ update_INTERPOLATE_NONE_(JStudio::TFunctionValue_list_parameter const&, f64);
+ /* 80282FF4 */ static f64
+ update_INTERPOLATE_LINEAR_(JStudio::TFunctionValue_list_parameter const&, f64);
+ /* 80283024 */ static f64
+ update_INTERPOLATE_PLATEAU_(JStudio::TFunctionValue_list_parameter const&, f64);
+ /* 80283060 */ static f64
+ update_INTERPOLATE_BSPLINE_dataMore3_(JStudio::TFunctionValue_list_parameter const&, f64);
+
+private:
+ /* 0x44 */ const f32* _44;
+ /* 0x48 */ u32 _48;
+ /* 0x4c */ TIterator_data_ dat1;
+ /* 0x50 */ TIterator_data_ dat2;
+ /* 0x54 */ TIterator_data_ dat3;
+ /* 0x58 */ update_INTERPOLATE _58;
+};
+
+class TFunctionValue_hermite : TFunctionValue, TFunctionValueAttribute_range {
+public:
+ struct TIterator_data_ {
+ TIterator_data_(const TFunctionValue_hermite& rParent, const f32* value) {
+ value_ = value;
+ size_ = rParent.data_getSize();
+ }
+ TIterator_data_(const TIterator_data_& other) {
+ value_ = other.value_;
+ size_ = other.size_;
+ }
+
+ void set(const f32* value, u32 size) {
+ value_ = value;
+ size_ = size;
+ }
+
+ void operator=(const TIterator_data_& rhs) {
+ value_ = rhs.value_;
+ size_ = rhs.size_;
+ }
+
+ /* 0x00 */ const f32* value_;
+ /* 0x04 */ u32 size_;
+ };
+
+ /* 802832C4 */ TFunctionValue_hermite();
+ /* 80283BC4 */ virtual ~TFunctionValue_hermite() {}
+
+ /* 80283344 */ virtual u32 getType() const;
+ /* 8028334C */ virtual TFunctionValueAttributeSet getAttributeSet();
+ /* 8028336C */ void data_set(f32 const*, u32, u32);
+ /* 802833BC */ virtual void initialize();
+ /* 80283428 */ virtual void prepare();
+ /* 8028344C */ virtual f64 getValue(f64);
+
+ u32 data_getSize() const { return uSize_; }
+
+private:
+ /* 0x40 */ const f32* pf_;
+ /* 0x44 */ u32 u_;
+ /* 0x48 */ u32 uSize_;
+ /* 0x4c */ TIterator_data_ dat1;
+ /* 0x50 */ TIterator_data_ dat2;
+ /* 0x54 */ TIterator_data_ dat3;
+};
+
+} // namespace JStudio
+
#endif /* FUNCTIONVALUE_H */
diff --git a/include/JSystem/JStudio/JStudio/fvb-data-parse.h b/include/JSystem/JStudio/JStudio/fvb-data-parse.h
index af8faac081..93e6ba3b11 100644
--- a/include/JSystem/JStudio/JStudio/fvb-data-parse.h
+++ b/include/JSystem/JStudio/JStudio/fvb-data-parse.h
@@ -1,6 +1,52 @@
#ifndef FVB_DATA_PARSE_H
#define FVB_DATA_PARSE_H
-#include "dolphin/types.h"
+#include "JSystem/JStudio/JStudio/fvb-data.h"
+
+namespace JStudio {
+namespace fvb {
+namespace data {
+
+class TParse_TBlock : public TParseData_aligned<4> {
+public:
+ TParse_TBlock(const void* content) : TParseData_aligned<4>(content) {}
+
+ const TBlock* get() const { return (TBlock*)getRaw(); }
+
+ u32 get_size() const { return get()->size; }
+ const void* getNext() const {
+ u32 size = get_size();
+ return (const void*)((u8*)getRaw() + size);
+ }
+ u16 get_type() const { return get()->type; }
+ u16 get_IDSize() const { return get()->id_size; }
+ const void* getBlockEnd_() const { return (u8*)getRaw() + sizeof(TBlock); }
+ const void* get_ID() const {
+ const void* ret = 0;
+ if (get_IDSize())
+ ret = getBlockEnd_();
+ return ret;
+ }
+ const void* getContent() const {
+ u32 size = align_roundUp(get_IDSize(), 4);
+ return (const void*)((int)getBlockEnd_() + size);
+ }
+};
+
+class TParse_TParagraph : public TParseData_aligned<4> {
+public:
+ struct TData {
+ /* 0x04 */ u32 u32Size;
+ /* 0x08 */ u32 u32Type;
+ /* 0x0C */ const void* pContent;
+ };
+ TParse_TParagraph(const void* content) : TParseData_aligned<4>(content) {}
+
+ /* 802850AC */ void getData(JStudio::fvb::data::TParse_TParagraph::TData*) const;
+};
+
+} // namespace data
+} // namespace fvb
+} // namespace JStudio
#endif /* FVB_DATA_PARSE_H */
diff --git a/include/JSystem/JStudio/JStudio/fvb-data.h b/include/JSystem/JStudio/JStudio/fvb-data.h
index 7615b985b6..bbc3a5d313 100644
--- a/include/JSystem/JStudio/JStudio/fvb-data.h
+++ b/include/JSystem/JStudio/JStudio/fvb-data.h
@@ -1,6 +1,63 @@
#ifndef FVB_DATA_H
#define FVB_DATA_H
-#include "dolphin/types.h"
+#include "JSystem/JGadget/binary.h"
+#include "JSystem/JStudio/JStudio/functionvalue.h"
+
+using namespace JGadget::binary;
+
+namespace JStudio {
+namespace fvb {
+namespace data {
+
+extern f32 ga4cSignature[1 + 1 /* padding */];
+
+const int PARAGRAPH_DATA = 1;
+
+typedef enum TEComposite {
+ /* 0x0 */ COMPOSITE_NONE,
+ /* 0x1 */ COMPOSITE_RAW,
+ /* 0x2 */ COMPOSITE_IDX,
+ /* 0x3 */ COMPOSITE_PARAM,
+ /* 0x4 */ COMPOSITE_ADD,
+ /* 0x5 */ COMPOSITE_SUB,
+ /* 0x6 */ COMPOSITE_MUL,
+ /* 0x7 */ COMPOSITE_DIV,
+ /* 0x8 */ COMPOSITE_ENUM_SIZE,
+};
+
+typedef const void* (*CompositeOperation)(TFunctionValue_composite::TData);
+
+struct TBlock {
+ /* 0x0 */ u32 size;
+ /* 0x4 */ u16 type;
+ /* 0x6 */ u16 id_size;
+ /* 0x8 */ u8 id[0];
+};
+
+struct THeader {
+ /* 0x00 */ char signature[4];
+ /* 0x04 */ u16 byte_order; // must be 0xFEFF
+ /* 0x06 */ u16 version; // 0-1 = obselete, 2-7 = OK
+ /* 0x08 */ u32 _8;
+ /* 0x0C */ u32 block_number;
+ /* 0x10 */ u8 content[0];
+};
+// Parses a THeader
+class TParse_THeader : public TParseData_aligned<4> {
+public:
+ TParse_THeader(const void* p) : TParseData_aligned<4>(p) {}
+
+ const THeader* get() const { return (THeader*)getRaw(); }
+ const void* getContent() const { return ((THeader*)getRaw())->content; }
+ const char* get_signature() const { return get()->signature; }
+ u16 get_byteOrder() const { return get()->byte_order; }
+ u16 get_version() const { return get()->version; }
+ u32 get_blockNumber() const { return get()->block_number; }
+};
+
+} // namespace data
+} // namespace fvb
+} // namespace JStudio
#endif /* FVB_DATA_H */
diff --git a/include/JSystem/JStudio/JStudio/fvb.h b/include/JSystem/JStudio/JStudio/fvb.h
index 1cb30da71d..4303b96c14 100644
--- a/include/JSystem/JStudio/JStudio/fvb.h
+++ b/include/JSystem/JStudio/JStudio/fvb.h
@@ -1,6 +1,159 @@
#ifndef FVB_H
#define FVB_H
-#include "dolphin/types.h"
+#include "JSystem/JGadget/linklist.h"
+#include "JSystem/JStudio/JStudio/fvb-data-parse.h"
+#include "JSystem/JStudio/JStudio/object-id.h"
+#include "global.h"
+
+namespace JStudio {
+namespace fvb {
+
+class TControl;
+
+class TParse : public TParse_header_block {
+public:
+ /* 80284ADC */ TParse(JStudio::fvb::TControl*);
+ /* 80284AFC */ virtual ~TParse();
+ /* 80284B5C */ virtual bool parseHeader_next(void const**, u32*, u32);
+ /* 80284BF0 */ virtual bool parseBlock_next(void const**, u32*, u32);
+
+ TControl* getControl() const { return pControl_; }
+
+private:
+ TControl* pControl_;
+};
+
+class TObject : public object::TObject_ID {
+public:
+ TObject(const data::TParse_TBlock& block);
+ TObject(void const* id, u32 id_size, TFunctionValue* value);
+
+ explicit TObject(const data::TParse_TBlock& block, TFunctionValue* value)
+ : TObject_ID(block.get_ID(), block.get_IDSize()), pfv_(value) {
+ ASSERT(pfv_ != NULL);
+ }
+
+ virtual ~TObject() = 0;
+
+ virtual void prepare_data_(const data::TParse_TParagraph::TData& data, TControl* control) = 0;
+
+ void prepare(const data::TParse_TBlock& block, TControl* control);
+
+ TFunctionValue* const& referFunctionValue() { return pfv_; }
+
+private:
+ /* 0x0C */ JGadget::TLinkListNode mNode;
+ /* 0x14 */ TFunctionValue* pfv_;
+};
+
+class TFactory {
+public:
+ /* 80284918 */ virtual ~TFactory();
+
+ /* 80284960 */ virtual TObject* create(JStudio::fvb::data::TParse_TBlock const&);
+ /* 80284AA0 */ virtual void destroy(JStudio::fvb::TObject*);
+};
+
+class TControl {
+public:
+ /* 80284668 */ TControl();
+ /* 80284698 */ virtual ~TControl();
+
+ /* 80284704 */ void appendObject(JStudio::fvb::TObject*);
+ /* 80284750 */ void removeObject(JStudio::fvb::TObject*);
+ /* 80284780 */ void destroyObject(JStudio::fvb::TObject*);
+ /* 802847D0 */ void destroyObject_all();
+ /* 80284834 */ TObject* getObject(void const*, u32);
+ /* 802848D4 */ TObject* getObject_index(u32);
+
+ TFactory* getFactory() const { return pFactory; }
+
+private:
+ TFactory* pFactory;
+ JGadget::TLinkList<TObject, 12> ocObject_;
+};
+
+class TObject_composite : public TObject {
+public:
+ /* 80284254 */ TObject_composite(JStudio::fvb::data::TParse_TBlock const&);
+ /* 802842D4 */ virtual void prepare_data_(JStudio::fvb::data::TParse_TParagraph::TData const&,
+ JStudio::fvb::TControl*);
+ /* 80284F78 */ virtual ~TObject_composite() {}
+
+private:
+ TFunctionValue_composite fnValue;
+};
+
+class TObject_constant : public TObject {
+public:
+ /* 80284338 */ TObject_constant(data::TParse_TBlock const&);
+ /* 80284EF4 */ virtual ~TObject_constant() {}
+
+ /* 802843B8 */ virtual void prepare_data_(data::TParse_TParagraph::TData const&, TControl*);
+
+private:
+ TFunctionValue_constant fnValue;
+};
+
+class TObject_transition : public TObject {
+public:
+ /* 802843C8 */ TObject_transition(data::TParse_TBlock const&);
+ /* 80284E70 */ virtual ~TObject_transition() {}
+
+ /* 80284448 */ virtual void prepare_data_(data::TParse_TParagraph::TData const&, TControl*);
+
+private:
+ TFunctionValue_transition fnValue;
+};
+
+class TObject_list : public TObject {
+public:
+ struct ListData {
+ /* 0x0 */ f32 _0;
+ /* 0x4 */ u32 _4;
+ /* 0x8 */ f32 _8[0];
+ };
+ /* 80284460 */ TObject_list(data::TParse_TBlock const&);
+ /* 80284DEC */ virtual ~TObject_list() {}
+
+ /* 802844E0 */ virtual void prepare_data_(data::TParse_TParagraph::TData const&, TControl*);
+
+private:
+ TFunctionValue_list fnValue;
+};
+
+class TObject_list_parameter : public TObject {
+public:
+ struct ListData {
+ u32 _0;
+ f32 _4[0];
+ };
+ /* 80284500 */ TObject_list_parameter(data::TParse_TBlock const&);
+ /* 80284D68 */ virtual ~TObject_list_parameter() {}
+
+ /* 80284580 */ virtual void prepare_data_(data::TParse_TParagraph::TData const&, TControl*);
+
+private:
+ TFunctionValue_list_parameter fnValue;
+};
+
+struct TObject_hermite : public TObject {
+public:
+ struct ListData {
+ u32 _0; // u : 28, uSize : 4
+ f32 _4[0];
+ };
+ /* 802845B0 */ TObject_hermite(data::TParse_TBlock const&);
+ /* 80284CE4 */ virtual ~TObject_hermite() {}
+
+ /* 80284630 */ virtual void prepare_data_(data::TParse_TParagraph::TData const&, TControl*);
+
+private:
+ TFunctionValue_hermite fnValue;
+};
+
+} // namespace fvb
+} // namespace JStudio
#endif /* FVB_H */
diff --git a/include/JSystem/JStudio/JStudio/object-id.h b/include/JSystem/JStudio/JStudio/object-id.h
index a0cc9f9024..28864fc5dc 100644
--- a/include/JSystem/JStudio/JStudio/object-id.h
+++ b/include/JSystem/JStudio/JStudio/object-id.h
@@ -3,4 +3,27 @@
#include "dolphin/types.h"
+namespace JStudio {
+namespace object {
+
+struct TPRObject_ID_equal {};
+
+struct TIDData {
+public:
+ TIDData(const void* id, u32 id_size) : mID(id), mID_size(id_size) {}
+
+ /* 80288988 */ void isEqual(JStudio::object::TIDData const&, JStudio::object::TIDData const&);
+
+private:
+ const void* mID;
+ u32 mID_size;
+};
+
+struct TObject_ID : public TIDData {
+ TObject_ID(const void* id, u32 id_size) : TIDData(id, id_size) {}
+};
+
+} // namespace object
+} // namespace JStudio
+
#endif /* OBJECT_ID_H */
diff --git a/include/JSystem/JStudio/JStudio/stb-data-parse.h b/include/JSystem/JStudio/JStudio/stb-data-parse.h
index 3b11abf40b..ef96a0d35f 100644
--- a/include/JSystem/JStudio/JStudio/stb-data-parse.h
+++ b/include/JSystem/JStudio/JStudio/stb-data-parse.h
@@ -1,6 +1,110 @@
#ifndef STB_DATA_PARSE_H
#define STB_DATA_PARSE_H
-#include "dolphin/types.h"
+#include "JSystem/JGadget/binary.h"
+#include "JSystem/JStudio/JStudio/stb-data.h"
+
+using namespace JGadget::binary;
+
+namespace JStudio {
+namespace stb {
+namespace data {
+
+// Parses a THeader
+class TParse_THeader : public TParseData_aligned<4> {
+public:
+ TParse_THeader(const void* p) : TParseData_aligned<4>(p) {}
+
+ const THeader* get() const { return (THeader*)getRaw(); }
+ const void* getContent() const { return ((THeader*)getRaw())->content; }
+ const char* get_signature() const { return get()->signature; }
+ u16 get_byteOrder() const { return get()->byte_order; }
+ u16 get_version() const { return get()->version; }
+ u32 get_blockNumber() const { return get()->block_number; }
+};
+
+class TParse_TBlock : public TParseData_aligned<4> {
+public:
+ TParse_TBlock(const void* content) : TParseData_aligned<4>(content) {}
+
+ const TBlock* get() const { return (TBlock*)getRaw(); }
+ const TBlock* getNext() const { return (TBlock*)((u8*)getRaw() + get_size()); }
+
+ u32 get_size() const { return get()->size; }
+ u32 get_type() const { return get()->type; }
+};
+
+class TParse_TSequence : public TParseData_aligned<4> {
+public:
+ struct TData {
+ /* 0x00 */ u8 type;
+ /* 0x04 */ u32 param;
+ /* 0x08 */ const void* content;
+ /* 0x0C */ const void* next;
+ };
+
+ TParse_TSequence(const void* content) : TParseData_aligned<4>(content) {}
+ /* 802899BC */ void getData(TData*) const;
+
+ const void* get() const { return getRaw(); }
+ u32 get_head() const { return *(u32*)get(); }
+};
+
+class TParse_TParagraph : public TParseData_aligned<4> {
+public:
+ struct TData {
+ /* 0x00 */ u32 type;
+ /* 0x04 */ u32 param;
+ /* 0x08 */ const void* content;
+ /* 0x0C */ const void* next;
+ };
+
+ TParse_TParagraph(const void* content) : TParseData_aligned<4>(content) {}
+ /* 80289A08 */ void getData(TData*) const;
+};
+
+struct TParse_TParagraph_data : public TParseData_aligned<4> {
+ struct TData {
+ /* 0x00 */ u8 _0;
+ /* 0x04 */ u32 _4;
+ /* 0x08 */ u32 _8;
+ /* 0x0C */ const void* _c;
+ /* 0x10 */ const void* _10;
+ };
+
+ TParse_TParagraph_data(const void* content) : TParseData_aligned<4>(content) {}
+ /* 80289A80 */ void getData(TData*) const;
+};
+
+// Parses a TObject ("demo object")
+class TParse_TBlock_object : public TParse_TBlock {
+public:
+ TParse_TBlock_object(const void* content) : TParse_TBlock(content) {}
+
+ const TBlock_object* get() const { return (TBlock_object*)getRaw(); }
+ const void* getContent() const {
+ return ((TBlock_object*)getRaw())->id + align_roundUp(get_IDSize(), 4);
+ }
+
+ u16 get_flag() const { return get()->flag; }
+ u16 get_IDSize() const { return get()->id_size; }
+ const void* get_ID() const { return get()->id; }
+};
+
+class TParse_TParagraph_dataID : public TParseData_aligned<4> {
+public:
+ TParse_TParagraph_dataID(const void* pContent) : TParseData_aligned<4>(pContent) {}
+
+ const TParagraph* get() const { return (TParagraph*)getRaw(); }
+ u16 get_IDSize() const { return get()->id_size; }
+ const void* get_ID() const { return get()->id; }
+ const void* getContent() const {
+ return ((TParagraph*)getRaw())->id + align_roundUp(get_IDSize(), 4);
+ }
+};
+
+} // namespace data
+} // namespace stb
+} // namespace JStudio
#endif /* STB_DATA_PARSE_H */
diff --git a/include/JSystem/JStudio/JStudio/stb-data.h b/include/JSystem/JStudio/JStudio/stb-data.h
index 49b8582354..fde46c96de 100644
--- a/include/JSystem/JStudio/JStudio/stb-data.h
+++ b/include/JSystem/JStudio/JStudio/stb-data.h
@@ -3,4 +3,67 @@
#include "dolphin/types.h"
+namespace JStudio {
+namespace stb {
+namespace data {
+
+const int guBit_TSequence_type = 24;
+
+const int BLOCK_SOUND = 'JSND';
+const int BLOCK_ACTOR = 'JACT';
+const int BLOCK_AMBIENTLIGHT = 'JABL';
+const int BLOCK_CAMERA = 'JCMR';
+const int BLOCK_FOG = 'JFOG';
+const int BLOCK_LIGHT = 'JLIT';
+const int BLOCK_MESSAGE = 'JMSG';
+const int BLOCK_PARTICLE = 'JPTC';
+const int BLOCK_NONE = -1;
+
+// Used to expand a signed 24 int to a signed 32 int
+const u32 gu32Mask_TSequence_value_signExpansion = 0xFF000000;
+extern const u32 ga4cSignature; // 'STB/0'
+extern const u8 gauDataSize_TEParagraph_data[32];
+
+inline void toString_block(char* a5c, u32 arg1) {
+ // from debug, todo
+}
+
+struct THeader {
+ struct Target {
+ /* 0x00 */ char name[8]; // "jstudio"
+ /* 0x08 */ u16 _8[3];
+ /* 0x0E */ u16 target_version;
+ };
+
+ /* 0x00 */ char signature[4];
+ /* 0x04 */ u16 byte_order; // must be 0xFEFF
+ /* 0x06 */ u16 version; // 0-1 = obselete, 2-7 = OK
+ /* 0x08 */ u32 _8;
+ /* 0x0C */ u32 block_number;
+ /* 0x10 */ Target target;
+ /* 0x20 */ u8 content[0];
+};
+
+struct TBlock {
+ /* 0x0 */ u32 size;
+ /* 0x4 */ u32 type; // char[4] JMSG, JSND, JACT, ...
+};
+
+struct TBlock_object : TBlock {
+ /* 0x8 */ u16 flag;
+ /* 0xA */ u16 id_size;
+ /* 0xC */ u8 id[0]; // unique identifier
+ ///* ??? */ u8 content[0];
+};
+
+struct TParagraph {
+ /* 0x0 */ u16 _0;
+ /* 0x2 */ u16 id_size;
+ /* 0x4 */ u8 id[0]; // unique identifier
+};
+
+} // namespace data
+} // namespace stb
+} // namespace JStudio
+
#endif /* STB_DATA_H */
diff --git a/include/JSystem/JStudio/JStudio/stb.h b/include/JSystem/JStudio/JStudio/stb.h
index 8d4b35aa93..e4e0188cc6 100644
--- a/include/JSystem/JStudio/JStudio/stb.h
+++ b/include/JSystem/JStudio/JStudio/stb.h
@@ -1,6 +1,154 @@
#ifndef STB_H
#define STB_H
-#include "dolphin/types.h"
+#include "JSystem/JGadget/linklist.h"
+#include "JSystem/JStudio/JStudio/object-id.h"
+#include "JSystem/JStudio/JStudio/stb-data-parse.h"
+#include "global.h"
+
+namespace JStudio {
+namespace stb {
+
+class TControl;
+
+class TParse : public TParse_header_block {
+public:
+ /* 80289640 */ TParse(TControl*);
+ /* 80289660 */ virtual ~TParse();
+ /* 802896C0 */ virtual bool parseHeader_next(void const**, u32*, u32);
+ /* 8028978C */ virtual bool parseBlock_next(void const**, u32*, u32);
+ /* 802897E0 */ virtual bool parseHeader(data::TParse_THeader const&, u32);
+ /* 802897E8 */ virtual bool parseBlock_block(data::TParse_TBlock const&, u32);
+ /* 80289820 */ virtual bool parseBlock_object(data::TParse_TBlock_object const&, u32);
+
+ TControl* getControl() const { return pControl; }
+
+private:
+ TControl* pControl;
+};
+
+class TObject : public object::TObject_ID {
+public:
+ enum TEStatus {
+ /* 0x0 */ STATUS_STILL = 0,
+ /* 0x1 */ STATUS_END = 1 << 0,
+ /* 0x2 */ STATUS_WAIT = 1 << 1,
+ /* 0x4 */ STATUS_SUSPEND = 1 << 2,
+ /* 0x8 */ STATUS_INACTIVE = 1 << 3,
+ };
+
+ /* 80288AC0 */ TObject(data::TParse_TBlock_object const&);
+ /* 80288A78 */ explicit TObject(u32, void const*, u32);
+ /* 80288B30 */ virtual ~TObject();
+
+ /* 80288B78 */ void setFlag_operation(u8, int);
+ /* 80288BD0 */ void reset(void const*);
+ /* 80288BE8 */ int forward(u32);
+ /* 80288E18 */ virtual void do_begin();
+ /* 80288E1C */ virtual void do_end();
+ /* 80288E20 */ virtual void do_paragraph(u32, void const*, u32);
+ /* 80288E24 */ virtual void do_wait(u32);
+ /* 80288E28 */ virtual void do_data(void const*, u32, void const*, u32);
+ /* 80288E2C */ void process_sequence_();
+ /* 80288F80 */ void process_paragraph_reserved_(u32, void const*, u32);
+
+ const char* toString_status(int status);
+
+ void on_begin() { do_begin(); }
+ void on_end() { do_end(); }
+ void on_paragraph(u32 arg1, const void* arg2, u32 arg3) { do_paragraph(arg1, arg2, arg3); }
+ void on_wait(u32 arg1) { do_wait(arg1); }
+ void on_data(const void* arg1, u32 arg2, const void* arg3, u32 arg4) {
+ do_data(arg1, arg2, arg3, arg4);
+ }
+
+ TControl* getControl() const { return pControl; }
+ void setControl_(TControl* control) { pControl = control; }
+ int getSuspend() const { return _20; }
+ void setSuspend(s32 val) { _20 = val; }
+ bool isSuspended() const { return getSuspend() > 0; }
+ void suspend(s32 val) { _20 += val; }
+ const void* getSequence() const { return pSequence; }
+ void setSequence_(const void* arg1) { pSequence = arg1; }
+ const void* getSequence_offset(s32 i_no) const {
+ int s32Val = (s32)getSequence();
+ return (const void*)(s32Val + i_no);
+ }
+ const void* getSequence_next() const { return pSequence_next; }
+ void setSequence_next(const void* seq) { pSequence_next = seq; }
+ u32 getWait() const { return u32Wait_; }
+ void setWait(u32 wait) { u32Wait_ = wait; }
+ TEStatus getStatus() const { return mStatus; }
+ void setStatus_(TEStatus status) { mStatus = status; }
+ u32 toInt32FromUInt24_(u32 val) {
+ if (val & 0x800000) {
+ val |= data::gu32Mask_TSequence_value_signExpansion;
+ }
+ return val;
+ }
+ void setFlag_operation_(u32 u32Data) {
+ ASSERT((u32Data >> data::guBit_TSequence_type) == 0);
+ setFlag_operation(u32Data >> 16, u32Data & 0xFFFF);
+ }
+
+ /* 0x10 */ JGadget::TLinkListNode ocObject_;
+
+private:
+ /* 0x14 */ TControl* pControl;
+ /* 0x18 */ u32 signature;
+ /* 0x1C */ u16 mFlag;
+ /* 0x1E */ u8 bSequence_;
+ /* 0x20 */ u32 _20; // "second per frame"?
+ /* 0x24 */ const void* pSequence;
+ /* 0x28 */ const void* pSequence_next;
+ /* 0x2C */ u32 u32Wait_;
+ /* 0x30 */ TEStatus mStatus;
+};
+
+class TFactory {
+public:
+ /* 802895B4 */ virtual ~TFactory();
+ /* 802895FC */ virtual TObject* create(data::TParse_TBlock_object const&);
+ /* 80289604 */ virtual void destroy(TObject*);
+};
+
+class TObject_control : public TObject {
+public:
+ /* 80289068 */ TObject_control(void const*, u32);
+ /* 80289134 */ ~TObject_control() {}
+};
+
+// Manages TObjects
+class TControl {
+public:
+ /* 802890B4 */ TControl();
+ /* 80289194 */ virtual ~TControl();
+
+ /* 80289228 */ void appendObject(TObject*);
+ /* 80289278 */ void removeObject(TObject*);
+ /* 802892B0 */ void destroyObject(TObject*);
+ /* 80289300 */ void destroyObject_all();
+ /* 80289364 */ TObject* getObject(void const*, u32);
+ /* 80289404 */ void reset();
+ /* 802894B4 */ void forward(u32);
+
+ void setStatus_(u32 status) { mStatus = status; }
+ void resetStatus_() { setStatus_(0); }
+ bool isSuspended() const { return _54 > 0; }
+ TFactory* getFactory() const { return pFactory; }
+ TObject_control& referObject_control() { return mObject_control; }
+
+private:
+ /* 0x04 */ u32 _4;
+ /* 0x08 */ u32 _8;
+ /* 0x0C */ TFactory* pFactory;
+ /* 0x10 */ JGadget::TLinkList<TObject, 12> mObjectContainer;
+ /* 0x1C */ u32 mStatus;
+ /* 0x20 */ TObject_control mObject_control;
+ /* 0x54 */ s32 _54; // "second per frame"?
+};
+
+} // namespace stb
+} // namespace JStudio
#endif /* STB_H */