Port JStudio work to new branch (#160)

* build fix

* stb

* functionvalue

* fvb

* jstudio cleanup

* d
This commit is contained in:
notyourav
2021-11-26 06:50:22 -08:00
committed by GitHub
parent 74ed2da8bc
commit c4ef30bc95
35 changed files with 2540 additions and 2121 deletions
+48
View File
@@ -3,4 +3,52 @@
#include "dolphin/types.h"
namespace JGadget {
namespace binary {
struct TEBit {
u32 value;
};
const void* parseVariableUInt_16_32_following(const void* pu16, u32* pu32First, u32* pu32Second,
TEBit* tebit);
inline u32 align_roundUp(u32 arg0, u32 uAlign) {
return (arg0 + uAlign - 1) & ~(uAlign - 1);
}
struct TParseData {
TParseData(const void* pContent) : raw(pContent) {}
const void* getRaw() const { return raw; }
void setRaw(const void* p) { raw = p; }
const void* raw;
};
template <int T>
struct TParseData_aligned : public TParseData {
TParseData_aligned(const void* pContent) : TParseData(pContent) {}
void setRaw(const void* p) {
if ((u32)p % T != 0) {
JUTWarn w;
w << "misaligned : " << (u32)p;
}
static_cast<TParseData*>(this)->setRaw(p);
}
};
// Base for header and/or block parsing
struct TParse_header_block {
virtual ~TParse_header_block();
virtual bool parseHeader_next(const void** ppData_inout, u32* puBlock_out, u32 arg2) = 0;
virtual bool parseBlock_next(const void** ppData_inout, u32* puData_out, u32 arg2) = 0;
bool parse_next(const void** ppData_inout, u32 a2);
};
} // namespace binary
} // namespace JGadget
#endif /* BINARY_H */
+12 -7
View File
@@ -22,15 +22,15 @@ struct TNodeLinkList {
TLinkListNode* node;
};
TNodeLinkList() : mListNode() { Initialize_(); }
TNodeLinkList() : ocObject_() { Initialize_(); }
void Initialize_() {
ptr = NULL;
mListNode.mNext = &mListNode;
mListNode.mPrev = &mListNode;
ocObject_.mNext = &ocObject_;
ocObject_.mPrev = &ocObject_;
}
iterator end() {
iterator iter(&mListNode);
iterator iter(&ocObject_);
return iter;
}
@@ -40,11 +40,11 @@ struct TNodeLinkList {
/* 802DCB08 */ void splice(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList&,
JGadget::TNodeLinkList::iterator);
/* 802DCBA8 */ void Insert(JGadget::TNodeLinkList::iterator, JGadget::TLinkListNode*);
/* 802DCBD4 */ void Erase(JGadget::TLinkListNode*);
/* 802DCBD4 */ iterator Erase(JGadget::TLinkListNode*);
/* 802DCBF8 */ void Remove(JGadget::TLinkListNode*);
/* 0x00 */ TNodeLinkList* ptr;
/* 0x04 */ TLinkListNode mListNode;
/* 0x04 */ TLinkListNode ocObject_;
}; // Size: 0xC
template <typename T, int I>
@@ -55,13 +55,18 @@ struct TLinkList : public TNodeLinkList {
iterator(TNodeLinkList::iterator iter) : TNodeLinkList::iterator(iter) {}
};
TLinkListNode* Element_toNode(T* element) const { return &element->mListNode; }
TLinkListNode* Element_toNode(T* element) const { return &element->ocObject_; }
void Insert(TLinkList::iterator iter, T* element) {
TLinkListNode* node = Element_toNode(element);
TNodeLinkList::Insert(iter, node);
}
iterator Erase(T* element) {
TLinkListNode* node = Element_toNode(element);
return ((TNodeLinkList*)this)->Erase(node);
}
TLinkList::iterator end() {
TNodeLinkList::iterator node_iter = TNodeLinkList::end();
TLinkList::iterator iter(node_iter);
+19
View File
@@ -0,0 +1,19 @@
#ifndef SEARCH_H
#define SEARCH_H
#include "global.h"
namespace JGadget {
//! @todo: mangled name isn't correct, fix this
//! Current: toValueFromIndex<PFdd_d>__7JGadgetFiPCPFdd_dUlRCPFdd_d
//! Target: toValueFromIndex<PFdd_d>__7JGadgetFiPCPFdd_dUlRCPFdd_d_RCPFdd_d
template <typename T>
inline const T& toValueFromIndex(int idx, const T* pValue, u32 count, const T& fallback) {
ASSERT(pValue != NULL);
return (idx >= count) ? fallback : pValue[idx];
}
} // namespace JGadget
#endif /* SEARCH_H */
+71
View File
@@ -0,0 +1,71 @@
#ifndef VECTOR_H
#define VECTOR_H
#include "global.h"
extern u8 data_804511E0;
extern u8 lit_569[];
namespace JGadget {
namespace vector {
u32 extend_default(u32 arg1, u32 arg2, u32 arg3);
typedef u32 (*ExtendFunc)(u32, u32, u32);
} // namespace vector
template <typename T>
struct TAllocator {
static TAllocator get() {}
inline TAllocator() { _0 = lit_569[0]; }
/* 0x0 */ u8 _0;
/* 0x4 */ u32 _4;
/* 0x8 */ u32 _8;
/* 0xc */ u32 _c;
};
template <typename T, template <class> class Allocator>
struct TVector {
TVector(Allocator<T> alloc) {
_0 = NULL;
pBegin_ = _0;
_c = NULL;
extend = vector::extend_default;
}
void** begin() { return pBegin_; }
void** end() { return pEnd_; }
// void erase(void** arg1, void** arg2) {}
void** _0;
void** pBegin_;
void** pEnd_;
u32 _c;
vector::ExtendFunc extend;
};
struct TVector_pointer_void : TVector<void*, TAllocator> {
/* 802DCCD0 */ TVector_pointer_void(JGadget::TAllocator<void*> const&);
/* 802DCCFC */ ~TVector_pointer_void();
/* 802DCDC4 */ void erase(void**, void**);
void insert(void**, void* const&);
void clear() { erase(begin(), end()); }
void push_back(const void*& ref) { insert(end(), (void* const&)ref); }
};
template <typename T>
struct TVector_pointer : TVector_pointer_void {
// TVector_pointer(const TAllocator<void*>& allocator) : TVector_pointer_void(allocator) {}
~TVector_pointer() {}
void push_back(const T& ref) {
static_cast<TVector_pointer_void*>(this)->push_back((const void*&)ref);
}
};
} // namespace JGadget
#endif /* VECTOR_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 */
@@ -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 */
+58 -1
View File
@@ -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 */
+154 -1
View File
@@ -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 */
@@ -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 */
@@ -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 */
@@ -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 */
+149 -1
View File
@@ -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 */