diff --git a/include/JSystem/JGadget/vector.h b/include/JSystem/JGadget/vector.h index 4c057bf66..f690b4857 100644 --- a/include/JSystem/JGadget/vector.h +++ b/include/JSystem/JGadget/vector.h @@ -52,11 +52,11 @@ struct TVector { void** end() { return mEnd; } void** const end() const { return mEnd; } - u8 _00; - void** mBegin; - void** mEnd; - void** _0C; - vector::ExtendFunc mExtend; + /* 0x04 */ u8 _00; + /* 0x08 */ void** mBegin; + /* 0x0C */ void** mEnd; + /* 0x10 */ void** _0C; + /* 0x14 */ vector::ExtendFunc mExtend; }; struct TVector_pointer_void : TVector { diff --git a/include/JSystem/JMessage/processor.h b/include/JSystem/JMessage/processor.h index f6b0202b2..b758b969d 100644 --- a/include/JSystem/JMessage/processor.h +++ b/include/JSystem/JMessage/processor.h @@ -20,12 +20,12 @@ public: struct TStack_ { TStack_() { clear(); } - TStack_(const TStack_& other) { - for (int i = 0; i < mNum; i++) { - mStack[i] = mStack[i]; - } - mNum = other.mNum; - } + // TStack_(const TStack_& other) { + // for (int i = 0; i < mNum; i++) { + // mStack[i] = mStack[i]; + // } + // mNum = other.mNum; + // } inline void clear() { mNum = 0; } inline void push(const char* str) { @@ -41,12 +41,10 @@ public: /* 0x10 */ u32 mNum; }; - // XXX: None of this shows up in the debug map. Is this TStatusData? - struct TProcess { - TProcess() { reset_normal(); } + struct TStatusData_ { + TStatusData_() { mCallBack = process_onCharacterEnd_normal_; } - void reset_normal() { mCallBack = process_onCharacterEnd_normal_; } - void reset_select() { mCallBack = process_onCharacterEnd_select_; } + void reset() {} // TODO /* 0x00 */ ProcessorCallBack mCallBack; /* 0x04 */ void* mCallBackWork[4]; @@ -89,13 +87,29 @@ public: void on_tag_(); bool process_character_(); + TControl* getControl() const { return mControl; } const char* getCurrent() const { return mCurrent; } + void setCurrent_(const char* v) { mCurrent = v; } + void on_character(int character) { do_character(character); } + void on_tag(u32 tag, const void* data, u32 size) { + if (!do_tag(tag, data, size)) { + do_tag_(tag, data, size); + } + } + void on_begin(const void* param_0, const char* param_1) { do_begin_(param_0, param_1); } + void on_end() { do_end_(); } + + // TODO: these inlines don't work because of circular includes + // const char* on_message(u32 code) { mControl->on_message(code); } + // void on_message_limited(u16 messageIndex) { mControl->on_message_limited(messageIndex); } + // void on_word(u32 messageIndex) { mControl->on_word(messageIndex); } + // void on_isLeadByte(int param_0) { mControl->on_isLeadByte(param_0); } /* 0x00 */ /* vtable */ /* 0x04 */ TControl* mControl; /* 0x08 */ const char* mCurrent; /* 0x0C */ TStack_ mStack; - /* 0x20 */ TProcess mProcess; + /* 0x20 */ TStatusData_ mStatusData; }; struct TSequenceProcessor : public TProcessor { @@ -142,7 +156,7 @@ struct TSequenceProcessor : public TProcessor { void process_setMessageIndex_reserved_(u16); void process_setMessageCode_(const TSequenceProcessor*, u16, u16); - void reset() {} + void reset() { reset_(NULL); } void setBegin(const void* param_1, const char* param_2) { reset_(param_2); do_begin_(param_1, param_2); @@ -164,6 +178,7 @@ struct TRenderingProcessor : public TProcessor { TRenderingProcessor(const TReference*); TRenderingProcessor(TControl*); + void reset() { reset_(NULL); } void setBegin(const void* entry, const char* data) { reset_(data); do_begin_(entry, data); diff --git a/include/JSystem/JStudio/JStudio/functionvalue.h b/include/JSystem/JStudio/JStudio/functionvalue.h index 2c1ab7e91..55a33f3a4 100644 --- a/include/JSystem/JStudio/JStudio/functionvalue.h +++ b/include/JSystem/JStudio/JStudio/functionvalue.h @@ -11,6 +11,7 @@ typedef f64 (*ExtrapolateParameter)(f64, f64); class TFunctionValue; class TFunctionValueAttributeSet; +class TFunctionValueAttributeSet; class TFunctionValueAttribute_refer; class TFunctionValueAttribute_range; @@ -188,8 +189,9 @@ public: }; typedef f64 (*UnkFunc)(f64, const TFunctionValueAttribute_refer*, const TFunctionValue_composite::TData*); - typedef f64 (*CompositeFunc)(const JGadget::TVector_pointer&, + typedef f64 (*CompositeFunc)(const JGadget::TVector_pointer&, const TFunctionValue_composite::TData&, f64); + typedef TFunctionValue_composite::TData (*GetCompositeFunc)(const void*); TFunctionValue_composite(); virtual ~TFunctionValue_composite() {} diff --git a/include/JSystem/JStudio/JStudio/fvb-data-parse.h b/include/JSystem/JStudio/JStudio/fvb-data-parse.h index 4de4c84a1..7934c2216 100644 --- a/include/JSystem/JStudio/JStudio/fvb-data-parse.h +++ b/include/JSystem/JStudio/JStudio/fvb-data-parse.h @@ -28,18 +28,17 @@ public: return ret; } const void* getContent() const { - u32 size = align_roundUp(get_IDSize(), 4); - return (const void*)((int)getBlockEnd_() + size); + return (const void*)((const u8*)getBlockEnd_() + align_roundUp(get_IDSize(), 4)); } }; class TParse_TParagraph : public TParseData_aligned<4> { public: struct TData { - /* 0x04 */ u32 u32Size; - /* 0x08 */ u32 u32Type; - /* 0x0C */ const void* pContent; - /* 0x10 */ const void* next; + /* 0x00 */ u32 u32Size; + /* 0x04 */ u32 u32Type; + /* 0x08 */ const void* pContent; + /* 0x0C */ const void* next; }; TParse_TParagraph(const void* content) : TParseData_aligned<4>(content) {} diff --git a/include/JSystem/JStudio/JStudio/fvb-data.h b/include/JSystem/JStudio/JStudio/fvb-data.h index 6469a3164..204bed7a5 100644 --- a/include/JSystem/JStudio/JStudio/fvb-data.h +++ b/include/JSystem/JStudio/JStudio/fvb-data.h @@ -14,7 +14,7 @@ extern const char ga4cSignature[4]; const int PARAGRAPH_DATA = 1; -typedef enum TEComposite { +enum TEComposite { /* 0x0 */ COMPOSITE_NONE, /* 0x1 */ COMPOSITE_RAW, /* 0x2 */ COMPOSITE_IDX, @@ -26,7 +26,10 @@ typedef enum TEComposite { /* 0x8 */ COMPOSITE_ENUM_SIZE, }; -typedef const void* (*CompositeOperation)(TFunctionValue_composite::TData); +struct CompositeOperation { + TFunctionValue_composite::CompositeFunc mSetFunc; + TFunctionValue_composite::GetCompositeFunc mGetFunc; +}; struct TBlock { /* 0x0 */ u32 size; diff --git a/include/JSystem/JStudio/JStudio/fvb.h b/include/JSystem/JStudio/JStudio/fvb.h index 69a98e0f6..762500a98 100644 --- a/include/JSystem/JStudio/JStudio/fvb.h +++ b/include/JSystem/JStudio/JStudio/fvb.h @@ -72,7 +72,7 @@ public: private: /* 0x4 */ TFactory* pFactory; - /* 0x8 */ JGadget::TLinkList ocObject_; + /* 0x8 */ JGadget::TLinkList ocObject_; }; // Size: 0x14 class TObject_composite : public TObject { diff --git a/include/d/d_bg_s_poly_pass_chk.h b/include/d/d_bg_s_poly_pass_chk.h index 8205fb4e1..56e9533ad 100644 --- a/include/d/d_bg_s_poly_pass_chk.h +++ b/include/d/d_bg_s_poly_pass_chk.h @@ -1,7 +1,7 @@ #ifndef D_BG_D_BG_S_POLY_PASS_CHK_H #define D_BG_D_BG_S_POLY_PASS_CHK_H -#include "dolphin/types.h" +#include "global.h" class cBgS_PolyPassChk { public: diff --git a/src/JSystem/JMessage/control.cpp b/src/JSystem/JMessage/control.cpp index 3d6fa4d71..b60407e23 100644 --- a/src/JSystem/JMessage/control.cpp +++ b/src/JSystem/JMessage/control.cpp @@ -52,11 +52,11 @@ void JMessage::TControl::reset() { reset_(); if (mBaseProcSeq) { - mBaseProcSeq->reset_(NULL); + mBaseProcSeq->reset(); } if (mBaseProcRender) { - mBaseProcRender->reset_(NULL); + mBaseProcRender->reset(); } } diff --git a/src/JSystem/JMessage/processor.cpp b/src/JSystem/JMessage/processor.cpp index 73230a44a..61b6ac4a0 100644 --- a/src/JSystem/JMessage/processor.cpp +++ b/src/JSystem/JMessage/processor.cpp @@ -49,13 +49,13 @@ void TProcessor::pushCurrent(const char* v) { if (!mStack.IsStorable()) return; - mStack.push(mCurrent); - mCurrent = v; + mStack.push(getCurrent()); + setCurrent_(v); } /* 8029EEA4-8029EEC8 .text popCurrent__Q28JMessage10TProcessorFv */ const char* TProcessor::popCurrent() { - mCurrent = mStack.top(); + setCurrent_(mStack.top()); mStack.pop(); } @@ -69,8 +69,8 @@ struct SelectCallBackWork { /* 8029EEC8-8029EF54 .text on_select_begin__Q28JMessage10TProcessorFPFPQ28JMessage10TProcessor_PCcPCvPCcUl */ void TProcessor::on_select_begin(OnSelectBeginCallBack callback, const void* offs, const char* base, u32 rest) { if (mStack.IsStorable()) { - mProcess.reset_select(); - SelectCallBackWork* work = (SelectCallBackWork*)&mProcess.mCallBackWork; + mStatusData.mCallBack = process_onCharacterEnd_select_; + SelectCallBackWork* work = (SelectCallBackWork*)&mStatusData.mCallBackWork; work->mCallBack = callback; work->mBase = base; work->mTable = offs; @@ -84,7 +84,7 @@ void TProcessor::on_select_begin(OnSelectBeginCallBack callback, const void* off /* 8029EF54-8029EFA0 .text on_select_end__Q28JMessage10TProcessorFv */ void TProcessor::on_select_end() { - mProcess.reset_normal(); + mStatusData.mCallBack = process_onCharacterEnd_normal_; popCurrent(); do_select_end(); } @@ -92,7 +92,7 @@ void TProcessor::on_select_end() { /* 8029EFA0-8029EFFC .text on_select_separate__Q28JMessage10TProcessorFv */ void TProcessor::on_select_separate() { popCurrent(); - SelectCallBackWork* work = (SelectCallBackWork*)&mProcess.mCallBackWork; + SelectCallBackWork* work = (SelectCallBackWork*)&mStatusData.mCallBackWork; const char *v = work->mCallBack(this); pushCurrent(v); do_select_separate(); @@ -130,9 +130,9 @@ TProcessor::~TProcessor() { /* 8029F064-8029F080 .text reset___Q28JMessage10TProcessorFPCc */ void TProcessor::reset_(const char* v) { - mCurrent = v; + setCurrent_(v); mStack.clear(); - mProcess.reset_normal(); + mStatusData.mCallBack = process_onCharacterEnd_normal_; } /* 8029F080-8029F120 .text on_tag___Q28JMessage10TProcessorFv */ @@ -141,13 +141,11 @@ void TProcessor::on_tag_() { const u8* current = (const u8*)getCurrent(); size = current[1]; - mCurrent = (const char*)current + size; + setCurrent_((const char*)current + size); u32 tag = (current[2] << 16 | (u8)current[3] << 8); tag |= current[4]; - if (!do_tag(tag, ¤t[5], size - 5)) { - do_tag_(tag, ¤t[5], size - 5); - } + on_tag(tag, ¤t[5], size - 5); } /* 8029F120-8029F248 .text do_tag___Q28JMessage10TProcessorFUlPCvUl */ @@ -188,24 +186,24 @@ void TProcessor::do_systemTagCode_(u16 code, const void* data, u32 size) { /* 8029F2A0-8029F37C .text process_character___Q28JMessage10TProcessorFv */ bool TProcessor::process_character_() { const u8* current = (const u8*)getCurrent(); - u32 r31 = current[0]; + u32 character = current[0]; switch (current[0]) { case 0: - if (!mProcess.mCallBack(this)) + if (!mStatusData.mCallBack(this)) return false; break; case 0x1A: on_tag_(); break; default: - if (mControl->mResourceContainer->IsLeadByte(r31)) { - r31 <<= 8; + if (mControl->mResourceContainer->IsLeadByte(character)) { + character <<= 8; mCurrent++; current = (const u8*)getCurrent(); - r31 |= current[0]; + character |= current[0]; } mCurrent++; - do_character(r31); + on_character(character); break; } return true; @@ -224,7 +222,7 @@ bool TProcessor::process_onCharacterEnd_normal_(TProcessor* proc) { /* 8029F3C4-8029F40C .text process_onCharacterEnd_select___Q28JMessage10TProcessorFPQ28JMessage10TProcessor */ bool TProcessor::process_onCharacterEnd_select_(TProcessor* proc) { - SelectCallBackWork* work = (SelectCallBackWork*) &proc->mProcess.mCallBackWork; + SelectCallBackWork* work = (SelectCallBackWork*) &proc->mStatusData.mCallBackWork; work->mRest--; if (work->mRest != 0) { proc->on_select_separate(); @@ -237,7 +235,7 @@ bool TProcessor::process_onCharacterEnd_select_(TProcessor* proc) { /* 8029F40C-8029F428 .text process_select_limited___Q28JMessage10TProcessorFPQ28JMessage10TProcessor */ const char* TProcessor::process_select_limited_(TProcessor* proc) { - SelectCallBackWork* work = (SelectCallBackWork*) &proc->mProcess.mCallBackWork; + SelectCallBackWork* work = (SelectCallBackWork*) &proc->mStatusData.mCallBackWork; u16 offs = ((const u16*)work->mTable)[0]; work->mTable = (const char*)work->mTable + sizeof(offs); return &work->mBase[offs]; @@ -246,7 +244,7 @@ const char* TProcessor::process_select_limited_(TProcessor* proc) { /* 8029F428-8029F444 .text process_select___Q28JMessage10TProcessorFPQ28JMessage10TProcessor */ const char* TProcessor::process_select_(TProcessor* proc) { /* Nonmatching */ - SelectCallBackWork* work = (SelectCallBackWork*) &proc->mProcess.mCallBackWork; + SelectCallBackWork* work = (SelectCallBackWork*) &proc->mStatusData.mCallBackWork; u32 offs = ((const u32*)work->mTable)[0]; work->mTable = (const char*)work->mTable + sizeof(offs); return &work->mBase[offs]; @@ -282,12 +280,12 @@ const char* TSequenceProcessor::process(const char* stop) { return mCurrent; mStatus = kStatus_Normal; - if (mProcess.mCallBack(this)) + if (mStatusData.mCallBack(this)) on_jump(mControl->getMessageEntry(), mControl->getMessageData_begin()); break; case kStatus_Branch: { - BranchCallBackWork* work = (BranchCallBackWork*) &mProcess.mCallBackWork; + BranchCallBackWork* work = (BranchCallBackWork*) &mStatusData.mCallBackWork; u32 rt = on_branch_queryResult(); if (rt > 0xFFFF) { @@ -300,7 +298,7 @@ const char* TSequenceProcessor::process(const char* stop) { } } else { mStatus = kStatus_Normal; - if (rt < work->mTarget && mProcess.mCallBack(this)) + if (rt < work->mTarget && mStatusData.mCallBack(this)) on_branch(mControl->getMessageEntry(), mControl->getMessageData_begin()); } } @@ -308,7 +306,7 @@ const char* TSequenceProcessor::process(const char* stop) { } if (mCurrent == stop) { - do_end_(); + on_end(); return NULL; } @@ -327,8 +325,8 @@ bool TSequenceProcessor::on_isReady() { /* 8029F684-8029F698 .text on_jump_register__Q28JMessage18TSequenceProcessorFPFPQ28JMessage18TSequenceProcessor_bUl */ void TSequenceProcessor::on_jump_register(OnJumpRegisterCallBack callback, u32 target) { mStatus = kStatus_Jump; - mProcess.mCallBack = (ProcessorCallBack)callback; - JumpCallBackWork* work = (JumpCallBackWork*) &mProcess.mCallBackWork; + mStatusData.mCallBack = (ProcessorCallBack)callback; + JumpCallBackWork* work = (JumpCallBackWork*) &mStatusData.mCallBackWork; work->mTarget = target; } @@ -345,15 +343,15 @@ void TSequenceProcessor::on_jump(const void* target, const char* v) { /* 8029F720-8029F730 .text on_branch_register__Q28JMessage18TSequenceProcessorFPFPQ28JMessage18TSequenceProcessorUl_bPCvUl */ void TSequenceProcessor::on_branch_register(OnBranchRegisterCallBack callback, const void* offset, u32 target) { - mProcess.mCallBack = (ProcessorCallBack)callback; - BranchCallBackWork* work = (BranchCallBackWork*) &mProcess.mCallBackWork; + mStatusData.mCallBack = (ProcessorCallBack)callback; + BranchCallBackWork* work = (BranchCallBackWork*) &mStatusData.mCallBackWork; work->mTable = offset; work->mTarget = target; } /* 8029F730-8029F764 .text on_branch_query__Q28JMessage18TSequenceProcessorFUs */ void TSequenceProcessor::on_branch_query(u16 branch) { - mStatus = 4; + mStatus = kStatus_Branch; do_branch_query(branch); } @@ -478,27 +476,27 @@ void TSequenceProcessor::do_systemTagCode_(u16 code, const void* data, u32 size) /* 8029FA2C-8029FA5C .text process_jump_limited___Q28JMessage18TSequenceProcessorFPQ28JMessage18TSequenceProcessor */ bool TSequenceProcessor::process_jump_limited_(TSequenceProcessor* proc) { - JumpCallBackWork* work = (JumpCallBackWork*) &proc->mProcess.mCallBackWork; + JumpCallBackWork* work = (JumpCallBackWork*) &proc->mStatusData.mCallBackWork; process_setMessage_index_(proc->mControl, work->mTarget); } /* 8029FA5C-8029FA88 .text process_jump___Q28JMessage18TSequenceProcessorFPQ28JMessage18TSequenceProcessor */ bool TSequenceProcessor::process_jump_(TSequenceProcessor* proc) { - JumpCallBackWork* work = (JumpCallBackWork*) &proc->mProcess.mCallBackWork; + JumpCallBackWork* work = (JumpCallBackWork*) &proc->mStatusData.mCallBackWork; process_setMessage_code_(proc->mControl, work->mTarget); } /* 8029FA88-8029FAB8 .text process_branch_limited___Q28JMessage18TSequenceProcessorFPQ28JMessage18TSequenceProcessorUl */ bool TSequenceProcessor::process_branch_limited_(TSequenceProcessor* proc, u32 choice) { /* Nonmatching */ - BranchCallBackWork* work = (BranchCallBackWork*) &proc->mProcess.mCallBackWork; + BranchCallBackWork* work = (BranchCallBackWork*) &proc->mStatusData.mCallBackWork; process_setMessage_index_(proc->mControl, ((u16*)work->mTable)[choice]); } /* 8029FAB8-8029FAE8 .text process_branch___Q28JMessage18TSequenceProcessorFPQ28JMessage18TSequenceProcessorUl */ bool TSequenceProcessor::process_branch_(TSequenceProcessor* proc, u32 choice) { /* Nonmatching */ - BranchCallBackWork* work = (BranchCallBackWork*) &proc->mProcess.mCallBackWork; + BranchCallBackWork* work = (BranchCallBackWork*) &proc->mStatusData.mCallBackWork; process_setMessage_code_(proc->mControl, ((u32*)work->mTable)[choice]); } @@ -512,10 +510,9 @@ TRenderingProcessor::~TRenderingProcessor() { /* 8029FB80-8029FBF0 .text process__Q28JMessage19TRenderingProcessorFPCc */ const char* TRenderingProcessor::process(const char* stop) { - /* Nonmatching */ do { if (mCurrent == stop) { - do_end_(); + on_end(); return NULL; } } while(process_character_()); diff --git a/src/JSystem/JStudio/JStudio/fvb.cpp b/src/JSystem/JStudio/JStudio/fvb.cpp index 1cedc71ed..fae02b53b 100644 --- a/src/JSystem/JStudio/JStudio/fvb.cpp +++ b/src/JSystem/JStudio/JStudio/fvb.cpp @@ -7,6 +7,7 @@ #include "JSystem/JStudio/JStudio/fvb-data.h" #include "JSystem/JUtility/JUTException.h" #include "dolphin/types.h" +#include "algorithm.h" #include "string.h" namespace JStudio { @@ -17,13 +18,12 @@ TObject::~TObject() {} /* 802739AC-80273BD0 .text prepare__Q37JStudio3fvb7TObjectFRCQ47JStudio3fvb4data13TParse_TBlockPQ37JStudio3fvb8TControl */ void TObject::prepare(const data::TParse_TBlock& rBlock, TControl* pControl) { - /* Nonmatching */ - ASSERT(pfv_ != 0); - - ASSERT(pControl != 0); - TFunctionValueAttributeSet set = pfv_->getAttributeSet(); - const void* pNext = rBlock.getNext(); - const void* pData = rBlock.getContent(); + /* Nonmatching - regalloc */ + TFunctionValueAttributeSet_const set = pfv_->getAttributeSet(); + const void* pNext; + const void* pData; + pNext = rBlock.getNext(); + pData = rBlock.getContent(); while (pData < pNext) { data::TParse_TParagraph para(pData); data::TParse_TParagraph::TData dat; @@ -31,136 +31,128 @@ void TObject::prepare(const data::TParse_TBlock& rBlock, TControl* pControl) { u32 u32Type = dat.u32Type; u32 u32Size = dat.u32Size; const void* pContent = dat.pContent; + TFunctionValueAttribute_range* pfvaRange = set.range_get(); + TFunctionValueAttribute_refer* referGet; + TFunctionValueAttribute_interpolate* pfvaInterpolate = set.interpolate_get(); + switch (u32Type) { case 0: - pfv_->prepare(); - return; - case 1: + goto prepare_end; + case 1: { prepare_data_(dat, pControl); - break; + } break; case 0x10: { - JUT_EXPECT(u32Size >= 4); - ASSERT(pContent != 0); - TFunctionValueAttribute_refer* pfvaRefer = set.refer_get(); - JUT_EXPECT(pfvaRefer != NULL); - if (pfvaRefer == NULL) { - JUTWarn w; - w << "invalid paragraph"; - } else { - JGadget::TVector_pointer& rCnt = pfvaRefer->refer_referContainer(); - data::TParse_TParagraph::TData** pBegin = - (data::TParse_TParagraph::TData**)rCnt.mBegin; - // todo: these definitely use a different struct - for (data::TParse_TParagraph::TData* i = *pBegin; i != NULL; i = *pBegin) { - TObject* pObject = pControl->getObject(pContent, i->u32Size); - if (pObject == NULL) { - JUTWarn w; - w << "object not found by ID"; - } else { - TFunctionValue* const& rfv = pObject->referFunctionValue(); - rCnt.push_back(rfv); - } - *pBegin += align_roundUp(i->u32Size, 4); + referGet = set.refer_get(); + + if (!referGet) { + break; + } + + JGadget::TVector_pointer& rCnt = referGet->refer_referContainer(); + + typedef struct { + u32 length; + const u8 data[0]; + } unkDataHeader; + + typedef struct { + u32 count; + unkDataHeader dataArray[0]; + } unkDataArray; + + const unkDataArray* i = static_cast(pContent); + u32 dataCount = i->count; + const unkDataHeader* d = i->dataArray; + + for (; dataCount != 0; dataCount--) { + u32 length = d->length; + + TObject* pObject = pControl->getObject(&d->data, length); + + if (pObject) { + TFunctionValue* rfv = pObject->referFunctionValue(); + rCnt.push_back(rfv); } + +#ifdef __MWERKS__ // clang-format off + (const u8*)d += align_roundUp(length, sizeof(u32)) + sizeof(u32); +#else + d = (const unkDataHeader*)(((const u8*)d) + align_roundUp(length, sizeof(u32)) + sizeof(u32)); +#endif // clang-format on } } break; case 0x11: { - JUT_EXPECT(u32Size >= 4); - ASSERT(pContent != 0); TFunctionValueAttribute_refer* pfvaRefer = set.refer_get(); - JUT_EXPECT(pfvaRefer != NULL); - if (pfvaRefer == NULL) { - JUTWarn w; - w << "invalid paragraph"; - } else { - JGadget::TVector_pointer& rCnt = pfvaRefer->refer_referContainer(); - data::TParse_TParagraph::TData** pBegin = - (data::TParse_TParagraph::TData**)rCnt.mBegin; - for (data::TParse_TParagraph::TData* i = *pBegin; i != NULL; i = *pBegin) { - TObject* pObject = pControl->getObject_index(u32Size); - if (pObject == NULL) { - JUTWarn w; - w << "object not found by index : " << u32Size; - } else { - TFunctionValue* const& rfv = pObject->referFunctionValue(); - rCnt.push_back(rfv); - } - *pBegin += align_roundUp(i->u32Size, 4); + + if (!pfvaRefer) { + break; + } + + JGadget::TVector_pointer& rCnt = pfvaRefer->refer_referContainer(); + + const u32* i = static_cast(pContent); + u32 ii = *i; + + for (; i++, ii != 0; ii--) { + u32 length = *i; + TObject* pObject = pControl->getObject_index(length); + if (pObject) { + TFunctionValue* rfv = pObject->referFunctionValue(); + rCnt.push_back(rfv); } } } break; case 0x12: { - JUT_EXPECT(u32Size == 8); - ASSERT(pContent != 0); - TFunctionValueAttribute_range* pfvaRange = set.range_get(); - JUT_EXPECT(pfvaRange != NULL); - if (pfvaRange == NULL) { - JUTWarn w; - w << "invalid paragraph"; - } else { - f64* arr = (f64*)pContent; - pfvaRange->range_set(arr[0], arr[1]); + if (!pfvaRange) { + break; } + const f32* arr = static_cast(pContent); + + pfvaRange->range_set(arr[0], arr[1]); } break; case 0x13: { - JUT_EXPECT(u32Size == 4); - ASSERT(pContent != 0); - TFunctionValueAttribute_range* pfvaRange = set.range_get(); - JUT_EXPECT(pfvaRange != NULL); - if (pfvaRange == NULL) { - JUTWarn w; - w << "invalid paragraph"; - } else { - TFunctionValue::TEProgress prog = *(TFunctionValue::TEProgress*)pContent; - pfvaRange->range_setProgress(prog); + if (!pfvaRange) { + break; } + + TFunctionValue::TEProgress prog = *static_cast(pContent); + pfvaRange->range_setProgress(prog); + } break; case 0x14: { - JUT_EXPECT(u32Size == 4); - ASSERT(pContent != 0); - TFunctionValueAttribute_range* pfvaRange = set.range_get(); - JUT_EXPECT(pfvaRange != NULL); - if (pfvaRange == NULL) { - JUTWarn w; - w << "invalid paragraph"; - } else { - TFunctionValue::TEAdjust adjust = *(TFunctionValue::TEAdjust*)pContent; - pfvaRange->range_setAdjust(adjust); + if (!pfvaRange) { + break; } + + TFunctionValue::TEAdjust adjust = *static_cast(pContent); + pfvaRange->range_setAdjust(adjust); + } break; case 0x15: { - JUT_EXPECT(u32Size == 4); - ASSERT(pContent != 0); - TFunctionValueAttribute_range* pfvaRange = set.range_get(); - JUT_EXPECT(pfvaRange != NULL); - if (pfvaRange == NULL) { - JUTWarn w; - w << "invalid paragraph"; - } else { - TFunctionValue::TEOutside* out = (TFunctionValue::TEOutside*)pContent; - pfvaRange->range_setOutside(out[0], out[1]); + if (!pfvaRange) { + break; } + + TFunctionValue::TEOutside a = (TFunctionValue::TEOutside)(static_cast(pContent))[0]; + TFunctionValue::TEOutside b = (TFunctionValue::TEOutside)(static_cast(pContent))[1]; + + pfvaRange->range_setOutside(a, b); + } break; case 0x16: { - JUT_EXPECT(u32Size == 4); - ASSERT(pContent != 0); - TFunctionValueAttribute_interpolate* pfvaInterpolate = set.interpolate_get(); - JUT_EXPECT(pfvaInterpolate != NULL); - if (pfvaInterpolate == NULL) { - JUTWarn w; - w << "invalid paragraph"; - } else { - TFunctionValue::TEInterpolate interp = *(TFunctionValue::TEInterpolate*)pContent; - pfvaInterpolate->interpolate_set(interp); + if (!pfvaInterpolate) { + break; } + + TFunctionValue::TEInterpolate interp = *static_cast(pContent); + pfvaInterpolate->interpolate_set(interp); + } break; - default: - JUTWarn w; - w << "unknown paragraph : " << u32Type; } - ASSERT(pData != 0); + pData = dat.next; } - JUT_EXPECT(pData == pNext); + +prepare_end: pfv_->prepare(); } @@ -201,12 +193,20 @@ TFunctionValue_composite::TData getCompositeData_divide_(const void* arg1) { return TFunctionValue_composite::TData(*(f32*)arg1); } -// TODO -static data::CompositeOperation saCompositeOperation_[8]; +static const data::CompositeOperation saCompositeOperation_[data::COMPOSITE_ENUM_SIZE] = { + { NULL, NULL }, // COMPOSITE_NONE + { &TFunctionValue_composite::composite_raw, &getCompositeData_raw_ }, // COMPOSITE_RAW + { &TFunctionValue_composite::composite_index, &getCompositeData_index_ }, // COMPOSITE_IDX + { &TFunctionValue_composite::composite_parameter, &getCompositeData_parameter_ }, // COMPOSITE_PARAM + { &TFunctionValue_composite::composite_add, &getCompositeData_add_ }, // COMPOSITE_ADD + { &TFunctionValue_composite::composite_subtract, &getCompositeData_subtract_ }, // COMPOSITE_SUB + { &TFunctionValue_composite::composite_multiply, &getCompositeData_multiply_ }, // COMPOSITE_MUL + { &TFunctionValue_composite::composite_divide, &getCompositeData_divide_ }, // COMPOSITE_DIV +}; /* 80273C24-80273C38 .text getCompositeOperation___Q37JStudio3fvb17@unnamed@fvb_cpp@FQ47JStudio3fvb4data11TEComposite */ -data::CompositeOperation* getCompositeOperation_(data::TEComposite r3) { - return &saCompositeOperation_[r3*2]; +const data::CompositeOperation* getCompositeOperation_(data::TEComposite r3) { + return &saCompositeOperation_[r3]; } } // namespace @@ -218,22 +218,20 @@ TObject_composite::TObject_composite(const data::TParse_TBlock& block) : TObject /* 80273CB8-80273D1C .text prepare_data___Q37JStudio3fvb17TObject_compositeFRCQ57JStudio3fvb4data17TParse_TParagraph5TDataPQ37JStudio3fvb8TControl */ void TObject_composite::prepare_data_(const data::TParse_TParagraph::TData& rData, TControl* control) { - /* Nonmatching */ - ASSERT(rData.u32Type == data::PARAGRAPH_DATA); + typedef struct { + JStudio::fvb::data::TEComposite _00; + const void* _04; + } unkOperation; u32 u32Size = rData.u32Size; - JUT_EXPECT(u32Size == 8); - const TFunctionValue_composite* pContent = static_cast(rData.pContent); - ASSERT(pContent != NULL); + const void* pControl_ = rData.pContent; + const unkOperation* content = (const unkOperation*)(pControl_); + JStudio::fvb::data::TEComposite v = content->_00; + const data::CompositeOperation* res = getCompositeOperation_(v); + TFunctionValue_composite::GetCompositeFunc pfvaRange = res->mGetFunc; - data::CompositeOperation* ops = getCompositeOperation_(*(data::TEComposite*)pContent); - data::CompositeOperation pfn = ops[1]; - - ASSERT(pfn != NULL); - - pfn(pContent->data); - fnValue.data_set((TFunctionValue_composite::CompositeFunc)*ops, pContent->data); + fnValue.data_set(res->mSetFunc, pfvaRange(&content->_04)); } /* 80273D1C-80273D9C .text __ct__Q37JStudio3fvb16TObject_constantFRCQ47JStudio3fvb4data13TParse_TBlock */ @@ -334,33 +332,52 @@ TControl::TControl() : pFactory(NULL) {} TControl::~TControl() {} /* 802740E8-80274134 .text appendObject__Q37JStudio3fvb8TControlFPQ37JStudio3fvb7TObject */ -void TControl::appendObject(TObject*) { - /* Nonmatching */ +void TControl::appendObject(TObject* pObject) { + ocObject_.Push_back(pObject); } /* 80274134-80274164 .text removeObject__Q37JStudio3fvb8TControlFPQ37JStudio3fvb7TObject */ -void TControl::removeObject(TObject*) { - /* Nonmatching */ +void TControl::removeObject(TObject* pObject) { + ocObject_.Erase(pObject); } /* 80274164-802741B4 .text destroyObject__Q37JStudio3fvb8TControlFPQ37JStudio3fvb7TObject */ -void TControl::destroyObject(TObject*) { - /* Nonmatching */ +void TControl::destroyObject(TObject* pObject) { + removeObject(pObject); + getFactory()->destroy(pObject); } /* 802741B4-80274218 .text destroyObject_all__Q37JStudio3fvb8TControlFv */ void TControl::destroyObject_all() { - /* Nonmatching */ + while (!ocObject_.empty()) { + destroyObject(&ocObject_.back()); + } } /* 80274218-802742B8 .text getObject__Q37JStudio3fvb8TControlFPCvUl */ -TObject* TControl::getObject(const void*, u32) { - /* Nonmatching */ +TObject* TControl::getObject(const void* param_0, u32 param_1) { + /* Nonmatching - TPRObject_ID_equal copy issue */ + JGadget::TLinkList::iterator begin = ocObject_.begin(); + JGadget::TLinkList::iterator end = ocObject_.end(); + JGadget::TLinkList::iterator local_50 = std::find_if(begin, end, object::TPRObject_ID_equal(param_0, param_1)); + if ((local_50 != end) != false) { + return &*local_50; + } + return NULL; } /* 802742B8-802742FC .text getObject_index__Q37JStudio3fvb8TControlFUl */ -TObject* TControl::getObject_index(u32) { - /* Nonmatching */ +TObject* TControl::getObject_index(u32 idx) { + if (idx >= ocObject_.size()) { + return NULL; + } + + JGadget::TLinkList::iterator begin(ocObject_.begin()); + while (idx != 0) { + begin++; + idx--; + } + return &*begin; } /* 802742FC-80274344 .text __dt__Q37JStudio3fvb8TFactoryFv */ diff --git a/src/d/actor/d_a_rd.cpp b/src/d/actor/d_a_rd.cpp index 1ccf3522f..d4166db78 100644 --- a/src/d/actor/d_a_rd.cpp +++ b/src/d/actor/d_a_rd.cpp @@ -1672,7 +1672,7 @@ void daRd_c::debugDraw() { spawnPos.y += 10.0f; cXyz pos = current.pos; pos.y += 10.0f; - (GXColor){0x00, 0xFF, 0x00, 0x80}; // Unused color, needed for the .rodata section to match. + GXColor unused = {0x00, 0xFF, 0x00, 0x80}; // Unused color, needed for the .rodata section to match. dLib_debugDrawFan(pos, mHeadAngle, l_HIO.mCrySpreadAngle, l_HIO.mCryRadius, (GXColor){0xFF, 0xFF, 0x00, 0x80}); dLib_debugDrawFan(pos, shape_angle.y, l_HIO.mAttackSpreadAngle, l_HIO.mAttackRadius, (GXColor){0xFF, 0x00, 0x00, 0x80}); dLib_debugDrawFan(pos, shape_angle.y, l_HIO.m40, l_HIO.m34, (GXColor){0xFF, 0x00, 0xFF, 0x80}); diff --git a/src/dolphin/gx/GXFrameBuf.c b/src/dolphin/gx/GXFrameBuf.c index 262733060..72d087af8 100644 --- a/src/dolphin/gx/GXFrameBuf.c +++ b/src/dolphin/gx/GXFrameBuf.c @@ -346,7 +346,7 @@ static u32 __GXGetNumXfbLines(u32 height, u32 scale) { return actualHeight; } -u16 GXGetNumXfbLines(const u16 efbHeight, f32 yScale) { +u16 GXGetNumXfbLines(u16 efbHeight, f32 yScale) { u32 scale = (u32)(256.0f / yScale) & 0x1FF; return __GXGetNumXfbLines(efbHeight, scale); diff --git a/src/dolphin/os/OSThread.c b/src/dolphin/os/OSThread.c index 39ca93f65..4ac9aa657 100644 --- a/src/dolphin/os/OSThread.c +++ b/src/dolphin/os/OSThread.c @@ -330,10 +330,6 @@ static inline void __OSSwitchThread(OSThread* nextThread) { OSLoadContext(&nextThread->context); } -inline OSThread* i_OSGetCurrentThread(void) { - return OS_CURRENT_THREAD; -} - static OSThread* SelectThread(BOOL yield) { OSContext* currentContext; OSThread* currentThread; @@ -346,7 +342,7 @@ static OSThread* SelectThread(BOOL yield) { } currentContext = OSGetCurrentContext(); - currentThread = i_OSGetCurrentThread(); + currentThread = OSGetCurrentThread(); if (currentContext != ¤tThread->context) { return 0; } diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index e0a081c46..819e468ed 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -1088,10 +1088,10 @@ out: } /* 8000AAC4-8000AB1C .text mCaptureProc__FPv */ -void* mCaptureProc(void* dummy) { - void* bytesCopied = (void*)encode_s3tc(mCaptureCaptureBuffer, mCaptureTextureBuffer, mCaptureSizeWidth, mCaptureSizeHeight, (GXTexFmt)mCaptureCaptureFormat); +u32 mCaptureProc(void* dummy) { + u32 bytesCopied = encode_s3tc(mCaptureCaptureBuffer, mCaptureTextureBuffer, mCaptureSizeWidth, mCaptureSizeHeight, (GXTexFmt)mCaptureCaptureFormat); DCStoreRange(mCaptureTextureBuffer, mCaptureTextureSize); - OSExitThread(bytesCopied); + OSExitThread((void*)bytesCopied); return bytesCopied; } diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index ca27c4270..b87b0ff17 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -440,7 +440,7 @@ void main01() { OSThread mainThread; /* 80006464-800065DC .text main */ -void main() { +int main() { OSThread* current_thread = OSGetCurrentThread(); u8 ALIGN_DECL(0x20) stack[0xF000]; @@ -483,5 +483,5 @@ void main() { OSCreateThread(&mainThread, (void*)main01, 0, stack + sizeof(stack), sizeof(stack), priority, 0); OSResumeThread(&mainThread); OSSetThreadPriority(current_thread, 0x1F); - OSSuspendThread(current_thread); + return OSSuspendThread(current_thread); }