mirror of
https://github.com/zeldaret/tp
synced 2026-08-09 10:54:11 -04:00
Port JStudio work to new branch (#160)
* build fix * stb * functionvalue * fvb * jstudio cleanup * d
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
Reference in New Issue
Block a user