mirror of
https://github.com/zeldaret/tww.git
synced 2026-08-21 22:10:59 -04:00
daPy_lk_c::dProcTool and daDemo00_c::execute matched, fix up various inlines and template classes, stb OK
This commit is contained in:
@@ -65,16 +65,16 @@ public:
|
||||
|
||||
static JFWDisplay* getManager() { return sManager; }
|
||||
|
||||
BOOL startFadeOut(int param_0) {
|
||||
BOOL startFadeOut(int fadeTime) {
|
||||
if (mpFader != NULL) {
|
||||
return mpFader->startFadeOut(param_0);
|
||||
return mpFader->startFadeOut(fadeTime);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL startFadeIn(int param_0) {
|
||||
BOOL startFadeIn(int fadeTime) {
|
||||
if (mpFader != NULL) {
|
||||
return mpFader->startFadeIn(param_0);
|
||||
return mpFader->startFadeIn(fadeTime);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define BINARY_H
|
||||
|
||||
#include "dolphin/types.h"
|
||||
#include "JSystem/JGadget/search.h"
|
||||
|
||||
namespace JGadget {
|
||||
namespace binary {
|
||||
@@ -26,11 +27,11 @@ struct TParseData {
|
||||
/* 0x0 */ const void* raw;
|
||||
};
|
||||
|
||||
template <int T>
|
||||
template <int S>
|
||||
struct TParseData_aligned : public TParseData {
|
||||
TParseData_aligned(const void* pContent) : TParseData(pContent) {}
|
||||
void setRaw(const void* p) {
|
||||
/* if ((u32)p % T != 0) {
|
||||
/* if ((u32)p % S != 0) {
|
||||
JUTWarn w;
|
||||
w << "misaligned : " << (u32)p;
|
||||
} */
|
||||
@@ -63,7 +64,12 @@ struct TParse_header_block {
|
||||
template <typename T>
|
||||
struct TParseValue_raw_ {
|
||||
typedef T ParseType;
|
||||
static T parse(const void* data) { return *(T*)data; }
|
||||
static T parse(const void* data) { return (T)*(T*)data; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct TParseValue_raw : public TParseValue_raw_<T> {
|
||||
typedef TParseValue_raw_<T> InnerParseValueClass;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
@@ -71,36 +77,43 @@ struct TParseValue_endian_big_ : public TParseValue_raw_<T> {
|
||||
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
|
||||
};
|
||||
|
||||
template <typename T, template <class> class Parser>
|
||||
struct TParseValue : public Parser<T> {
|
||||
static T parse(const void* data) { return Parser<T>::parse(data); }
|
||||
template <class Parser>
|
||||
struct TParseValue : public Parser {
|
||||
static typename Parser::ParseType parse(const void* data) { return Parser::parse(data); }
|
||||
|
||||
static T parse(const void* data, s32 advanceNum) {
|
||||
return Parser<T>::parse(advance(data, advanceNum));
|
||||
static typename Parser::ParseType parse(const void* data, s32 advanceNum) {
|
||||
return Parser::parse(advance(data, advanceNum));
|
||||
}
|
||||
|
||||
static const void* advance(const void* data, s32 advanceNum) {
|
||||
return (char*)data + (advanceNum * sizeof(T));
|
||||
return (char*)data + (advanceNum * sizeof(Parser::ParseType));
|
||||
}
|
||||
};
|
||||
|
||||
template<class Parser, int size>
|
||||
struct TValueIterator {
|
||||
struct TValueIterator
|
||||
: public JGadget::TIterator<
|
||||
std::random_access_iterator_tag,
|
||||
typename Parser::ParseType,
|
||||
ptrdiff_t,
|
||||
typename Parser::ParseType*,
|
||||
typename Parser::ParseType&
|
||||
>
|
||||
{
|
||||
typedef typename Parser::ParseType ValueType;
|
||||
|
||||
TValueIterator(const void* begin) {
|
||||
mBegin = begin;
|
||||
mBegin = reinterpret_cast<const char*>(begin);
|
||||
}
|
||||
// TValueIterator(const TValueIterator<Parser, size>& other) {
|
||||
// mBegin = other.mBegin;
|
||||
// }
|
||||
|
||||
const void* get() const { return mBegin; }
|
||||
|
||||
typename Parser::ParseType operator*() const {
|
||||
return Parser::parse(get());
|
||||
return TParseValue<typename Parser::InnerParseValueClass>::parse(get());
|
||||
}
|
||||
|
||||
TValueIterator& operator++() {
|
||||
mBegin = reinterpret_cast<u8*>(const_cast<void*>(mBegin)) + size;
|
||||
mBegin += size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -110,13 +123,13 @@ struct TValueIterator {
|
||||
return old;
|
||||
}
|
||||
|
||||
TValueIterator& operator+=(s32 v) {
|
||||
mBegin = reinterpret_cast<u8*>(const_cast<void*>(mBegin)) + size * v;
|
||||
TValueIterator& operator+=(s32 n) {
|
||||
mBegin += size * n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
TValueIterator& operator--() {
|
||||
mBegin = reinterpret_cast<u8*>(const_cast<void*>(mBegin)) - size;
|
||||
mBegin -= size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -126,39 +139,55 @@ struct TValueIterator {
|
||||
return old;
|
||||
}
|
||||
|
||||
const void* mBegin;
|
||||
char const* mBegin;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct TValueIterator_raw : public TValueIterator<TParseValue_raw_<T>, sizeof(T)> {
|
||||
TValueIterator_raw(const void* begin) : TValueIterator<TParseValue_raw_<T>, sizeof(T)>(begin) {}
|
||||
// TValueIterator_raw(const TValueIterator_raw<T>& other) : TValueIterator<TValueIterator_raw<T>, sizeof(T)>(other) {}
|
||||
struct TValueIterator_raw : public TValueIterator<TParseValue_raw<T>, sizeof(T)> {
|
||||
TValueIterator_raw(const void* begin) : TValueIterator<TParseValue_raw<T>, sizeof(T)>(begin) {}
|
||||
|
||||
friend bool operator==(TValueIterator<TParseValue_raw_<T>, sizeof(T)> a, TValueIterator<TParseValue_raw_<T>, sizeof(T)> b) {
|
||||
friend bool operator==(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, TValueIterator<TParseValue_raw<T>, sizeof(T)> b) {
|
||||
return a.mBegin == b.mBegin;
|
||||
}
|
||||
|
||||
friend T* operator+(TValueIterator<TParseValue_raw_<T>, sizeof(T)> a, s32 b) {
|
||||
return (T*)a.mBegin + b;
|
||||
friend bool operator!=(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, TValueIterator<TParseValue_raw<T>, sizeof(T)> b) {
|
||||
return !operator==(a, b);
|
||||
}
|
||||
|
||||
friend TValueIterator<TParseValue_raw<T>, sizeof(T)> operator+(TValueIterator<TParseValue_raw<T>, sizeof(T)> a, s32 b) {
|
||||
TValueIterator<TParseValue_raw<T>, sizeof(T)> it = a;
|
||||
it += b;
|
||||
return it;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct TParseValue_misaligned : TParseValue_raw_<T> {
|
||||
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
|
||||
struct TParseValue_misaligned_ : public TParseValue_raw_<T> {
|
||||
typedef T ParseType;
|
||||
static T parse(const void* data) { return TParseValue<TParseValue_raw_<T> >::parse(data); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct TParseValue_misaligned : public TParseValue_raw_<T> {
|
||||
typedef TParseValue_misaligned_<T> InnerParseValueClass;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct TValueIterator_misaligned : public TValueIterator<TParseValue_misaligned<T>, sizeof(T)> {
|
||||
TValueIterator_misaligned(const void* begin) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(begin) {}
|
||||
// TValueIterator_misaligned(const TValueIterator_misaligned<T>& other) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(other) {}
|
||||
|
||||
friend bool operator==(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, TValueIterator<TParseValue_misaligned<T>, sizeof(T)> b) {
|
||||
return a.mBegin == b.mBegin;
|
||||
}
|
||||
|
||||
friend T* operator+(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, s32 b) {
|
||||
return (T*)a.mBegin + b;
|
||||
friend bool operator!=(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, TValueIterator<TParseValue_misaligned<T>, sizeof(T)> b) {
|
||||
return !operator==(a, b);
|
||||
}
|
||||
|
||||
friend TValueIterator<TParseValue_misaligned<T>, sizeof(T)> operator+(TValueIterator<TParseValue_misaligned<T>, sizeof(T)> a, s32 b) {
|
||||
TValueIterator<TParseValue_misaligned<T>, sizeof(T)> it(a);
|
||||
it += b;
|
||||
return it;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ struct TObject_ID : public TIDData {
|
||||
|
||||
struct TPRObject_ID_equal : public TIDData {
|
||||
TPRObject_ID_equal(const void* id, u32 id_size) : TIDData(id, id_size) {}
|
||||
~TPRObject_ID_equal() {}
|
||||
bool operator()(TObject_ID const& id) const { return TIDData::isEqual(id.getIDData(), *this); }
|
||||
};
|
||||
|
||||
|
||||
@@ -67,12 +67,11 @@ public:
|
||||
|
||||
struct TParse_TParagraph_data : public TParseData {
|
||||
struct TData {
|
||||
// TODO: these field names are wrong
|
||||
/* 0x00 */ u8 status;
|
||||
/* 0x04 */ u32 dataSize;
|
||||
/* 0x08 */ u32 _8;
|
||||
/* 0x0C */ const void* fileCount;
|
||||
/* 0x10 */ const void* _10;
|
||||
/* 0x04 */ u32 entrySize;
|
||||
/* 0x08 */ u32 entryCount;
|
||||
/* 0x0C */ const void* content;
|
||||
/* 0x10 */ const void* next;
|
||||
};
|
||||
|
||||
TParse_TParagraph_data(const void* content) : TParseData(content) {}
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
void setFlag_operation(u8, int);
|
||||
void reset(void const*);
|
||||
u8 forward(u32);
|
||||
bool forward(u32);
|
||||
virtual void do_begin();
|
||||
virtual void do_end();
|
||||
virtual void do_paragraph(u32, void const*, u32);
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
void destroyObject(TObject*);
|
||||
void destroyObject_all();
|
||||
TObject* getObject(void const*, u32);
|
||||
u8 forward(u32);
|
||||
bool forward(u32);
|
||||
|
||||
void setStatus_(u32 status) { mStatus = status; }
|
||||
void resetStatus_() { setStatus_(0); }
|
||||
@@ -142,6 +142,10 @@ public:
|
||||
TObject_control& referObject_control() { return mObject_control; }
|
||||
int getSuspend() const { return _54; }
|
||||
void setSuspend(s32 suspend) { mObject_control.setSuspend(suspend); }
|
||||
void suspend(s32 param_0) { mObject_control.suspend(param_0); }
|
||||
void unsuspend(s32 param_0) { suspend(-param_0); }
|
||||
void getObjectContainer() const {}
|
||||
void referObjectContainer() {}
|
||||
|
||||
private:
|
||||
/* 0x04 */ u32 _4;
|
||||
@@ -159,31 +163,42 @@ struct TParseData : public data::TParse_TParagraph_data::TData {
|
||||
set(data::TParse_TParagraph_data(pContent));
|
||||
}
|
||||
|
||||
TParseData() {
|
||||
set(NULL);
|
||||
}
|
||||
|
||||
void set(const data::TParse_TParagraph_data& data) {
|
||||
data.getData(this);
|
||||
}
|
||||
|
||||
void set(const void* pContent) {
|
||||
set(data::TParse_TParagraph_data(pContent));
|
||||
}
|
||||
|
||||
bool isEnd() const {
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return fileCount == NULL;
|
||||
return content == NULL;
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
return !empty() && status == S;
|
||||
}
|
||||
|
||||
u32 size() const { return _8; }
|
||||
const void* getContent() const { return content; }
|
||||
|
||||
u32 size() const { return entryCount; }
|
||||
};
|
||||
|
||||
template <int S, class Iterator=JGadget::binary::TValueIterator_raw<u8> >
|
||||
struct TParseData_fixed : public TParseData<S> {
|
||||
TParseData_fixed(const void* pContent) : TParseData<S>(pContent) {}
|
||||
TParseData_fixed() : TParseData<S>() {}
|
||||
|
||||
const void* getNext() const {
|
||||
return this->_10;
|
||||
return this->next;
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
@@ -191,31 +206,21 @@ struct TParseData_fixed : public TParseData<S> {
|
||||
}
|
||||
|
||||
Iterator begin() const {
|
||||
return Iterator(this->fileCount);
|
||||
return Iterator(this->content);
|
||||
}
|
||||
|
||||
Iterator end() const {
|
||||
Iterator i(this->fileCount);
|
||||
Iterator i(this->content);
|
||||
i += this->size();
|
||||
return i;
|
||||
}
|
||||
|
||||
// TODO: front and back are needed to daPy_lk_c::dProcTool
|
||||
// these implementations are just guesses though, probably wrong
|
||||
Iterator front() const {
|
||||
// Iterator i = begin();
|
||||
// i++;
|
||||
// return i;
|
||||
|
||||
// Iterator i(begin());
|
||||
// ++i;
|
||||
// return i;
|
||||
|
||||
return Iterator(begin()) + 1;
|
||||
typename Iterator::ValueType front() const {
|
||||
return *begin();
|
||||
}
|
||||
Iterator back() const {
|
||||
Iterator i = end();
|
||||
return i + (-1);
|
||||
|
||||
typename Iterator::ValueType back() const {
|
||||
return *--end();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
virtual void draw();
|
||||
|
||||
s32 getStatus() const { return mStatus; }
|
||||
void setColor(JUtility::TColor& color) { mColor.set(color); }
|
||||
void setColor(JUtility::TColor color) { mColor.set(color); }
|
||||
|
||||
/* 0x04 */ s32 mStatus;
|
||||
/* 0x08 */ u16 mFadeTime;
|
||||
|
||||
@@ -27,7 +27,10 @@ struct TColor : public GXColor {
|
||||
}
|
||||
|
||||
void set(u32 u32Color) { *(u32*)&r = u32Color; }
|
||||
void set(GXColor gxColor) { *(GXColor*)&r = gxColor; }
|
||||
void set(GXColor gxColor) {
|
||||
GXColor* temp = this;
|
||||
*temp = gxColor;
|
||||
}
|
||||
};
|
||||
} // namespace JUtility
|
||||
|
||||
|
||||
Reference in New Issue
Block a user