mirror of
https://github.com/zeldaret/tww.git
synced 2026-06-08 12:17:12 -04:00
daPy_lk_c::dProcTool 99%
This commit is contained in:
@@ -30,6 +30,10 @@ 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);
|
||||
}
|
||||
};
|
||||
@@ -58,6 +62,7 @@ struct TParse_header_block {
|
||||
|
||||
template <typename T>
|
||||
struct TParseValue_raw_ {
|
||||
typedef T ParseType;
|
||||
static T parse(const void* data) { return *(T*)data; }
|
||||
};
|
||||
|
||||
@@ -79,6 +84,84 @@ struct TParseValue : public Parser<T> {
|
||||
}
|
||||
};
|
||||
|
||||
template<class Parser, int size>
|
||||
struct TValueIterator {
|
||||
TValueIterator(const void* begin) {
|
||||
mBegin = 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());
|
||||
}
|
||||
|
||||
TValueIterator& operator++() {
|
||||
mBegin = reinterpret_cast<u8*>(const_cast<void*>(mBegin)) + size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const TValueIterator operator++(int) {
|
||||
TValueIterator old(*this);
|
||||
++(*this);
|
||||
return old;
|
||||
}
|
||||
|
||||
TValueIterator& operator+=(s32 v) {
|
||||
mBegin = reinterpret_cast<u8*>(const_cast<void*>(mBegin)) + size * v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
TValueIterator& operator--() {
|
||||
mBegin = reinterpret_cast<u8*>(const_cast<void*>(mBegin)) - size;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const TValueIterator operator--(int) {
|
||||
TValueIterator old(*this);
|
||||
--(*this);
|
||||
return old;
|
||||
}
|
||||
|
||||
const void* 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) {}
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct TParseValue_misaligned : TParseValue_raw_<T> {
|
||||
static T parse(const void* data) { return TParseValue_raw_<T>::parse(data); }
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace binary
|
||||
} // namespace JGadget
|
||||
|
||||
|
||||
@@ -228,12 +228,12 @@ inline u32 JKRReadIdxResource(void* buffer, u32 bufferSize, u32 index, JKRArchiv
|
||||
return arc->readIdxResource(buffer, bufferSize, index);
|
||||
}
|
||||
|
||||
inline u32 JKRReadIdResource(void* buffer, u32 bufferSize, u16 id, JKRArchive* arc) {
|
||||
return arc->readResource(buffer, bufferSize, id);
|
||||
}
|
||||
|
||||
inline u32 JKRReadResource(void* buffer, u32 bufferSize, u16 id, JKRArchive* arc) {
|
||||
return arc->readResource(buffer, bufferSize, id);
|
||||
}
|
||||
|
||||
inline u32 JKRReadIdResource(void* buffer, u32 bufferSize, u16 id, JKRArchive* arc) {
|
||||
return JKRReadResource(buffer, bufferSize, id, arc);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -65,8 +65,9 @@ public:
|
||||
void getData(TData*) const;
|
||||
};
|
||||
|
||||
struct TParse_TParagraph_data : public TParseData_aligned<4> {
|
||||
struct TParse_TParagraph_data : public TParseData {
|
||||
struct TData {
|
||||
// TODO: these field names are wrong
|
||||
/* 0x00 */ u8 status;
|
||||
/* 0x04 */ u32 dataSize;
|
||||
/* 0x08 */ u32 _8;
|
||||
@@ -74,7 +75,7 @@ struct TParse_TParagraph_data : public TParseData_aligned<4> {
|
||||
/* 0x10 */ const void* _10;
|
||||
};
|
||||
|
||||
TParse_TParagraph_data(const void* content) : TParseData_aligned<4>(content) {}
|
||||
TParse_TParagraph_data(const void* content) : TParseData(content) {}
|
||||
void getData(TData* pData) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -153,43 +153,69 @@ private:
|
||||
/* 0x54 */ s32 _54;
|
||||
};
|
||||
|
||||
template <int T>
|
||||
struct TParseData {
|
||||
template <int S>
|
||||
struct TParseData : public data::TParse_TParagraph_data::TData {
|
||||
TParseData(const void* pContent) {
|
||||
data::TParse_TParagraph_data data(pContent);
|
||||
set(data);
|
||||
set(data::TParse_TParagraph_data(pContent));
|
||||
}
|
||||
|
||||
void set(const data::TParse_TParagraph_data& data) {
|
||||
//data::TParse_TParagraph_data::TData* p = (data::TParse_TParagraph_data::TData*)this;
|
||||
data.getData(m_data);
|
||||
data.getData(this);
|
||||
}
|
||||
|
||||
bool isEnd() const {
|
||||
return m_data->status == 0;
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return m_data->fileCount == NULL;
|
||||
return fileCount == NULL;
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
return !empty() && m_data->status == 50;
|
||||
return !empty() && status == S;
|
||||
}
|
||||
|
||||
data::TParse_TParagraph_data::TData* m_data;
|
||||
u32 size() const { return _8; }
|
||||
};
|
||||
|
||||
template <int T>
|
||||
struct TParseData_fixed : public TParseData<T> {
|
||||
TParseData_fixed(const void* pContent) : TParseData<T>(pContent) {}
|
||||
template <int S, class Iterator=JGadget::binary::TValueIterator_raw<u8> >
|
||||
struct TParseData_fixed : public TParseData<S> {
|
||||
TParseData_fixed(const void* pContent) : TParseData<S>(pContent) {}
|
||||
|
||||
const void* getNext() const {
|
||||
return this->m_data->fileCount;
|
||||
return this->_10;
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
return TParseData<T>::isValid() && getNext() != NULL;
|
||||
return TParseData<S>::isValid() && getNext() != NULL;
|
||||
}
|
||||
|
||||
Iterator begin() const {
|
||||
return Iterator(this->fileCount);
|
||||
}
|
||||
|
||||
Iterator end() const {
|
||||
Iterator i(this->fileCount);
|
||||
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;
|
||||
}
|
||||
Iterator back() const {
|
||||
Iterator i = end();
|
||||
return i + (-1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ void TParse_TParagraph_data::getData(TParse_TParagraph_data::TData* pData) const
|
||||
u8* set2;
|
||||
|
||||
int dSize = pData->dataSize = 0;
|
||||
pData->_8 = 0;
|
||||
pData->fileCount = NULL;
|
||||
pData->_10 = NULL;
|
||||
pData->_8 = 0;
|
||||
pData->fileCount = NULL;
|
||||
pData->_10 = NULL;
|
||||
u8* filedata = (u8*)getRaw();
|
||||
if (filedata == NULL)
|
||||
return;
|
||||
u8 set = *filedata;
|
||||
u8 set = *filedata;
|
||||
pData->status = set & ~0x8;
|
||||
if (!set)
|
||||
return;
|
||||
@@ -67,14 +67,14 @@ void TParse_TParagraph_data::getData(TParse_TParagraph_data::TData* pData) const
|
||||
if (set2 = (filedata + 1), is8) {
|
||||
set3 = *set2++;
|
||||
}
|
||||
pData->_8 = set3;
|
||||
pData->_8 = set3;
|
||||
pData->fileCount = set2;
|
||||
|
||||
if (!(set & 7))
|
||||
return;
|
||||
dSize = (gauDataSize_TEParagraph_data)[set &= 7];
|
||||
dSize = (gauDataSize_TEParagraph_data)[set &= 7];
|
||||
pData->dataSize = dSize;
|
||||
pData->_10 = (u8*)set2 + (dSize * set3);
|
||||
pData->_10 = (u8*)set2 + (dSize * set3);
|
||||
}
|
||||
|
||||
} // namespace data
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "f_op/f_op_camera.h"
|
||||
#include "f_op/f_op_camera_mng.h"
|
||||
#include "m_Do/m_Do_graphic.h"
|
||||
#include "JSystem/J3DGraphLoader/J3DAnmLoader.h"
|
||||
|
||||
/* 8012CD60-8012CDD4 .text getDemoLookActor__9daPy_lk_cFv */
|
||||
fopAc_ac_c* daPy_lk_c::getDemoLookActor() {
|
||||
@@ -176,7 +177,179 @@ BOOL daPy_lk_c::dProcTool_init() {
|
||||
|
||||
/* 8012D3C4-8012DA3C .text dProcTool__9daPy_lk_cFv */
|
||||
BOOL daPy_lk_c::dProcTool() {
|
||||
/* Nonmatching */
|
||||
/* Nonmatching - stack/instruction ordering issues related to JStudio inlines */
|
||||
dDemo_actor_c* demo_actor = dComIfGp_demo_getActor(demoActorID);
|
||||
daPy_anmHeap_c* anm_heap_under = &m_anm_heap_under[0];
|
||||
m3574 = 0;
|
||||
#if VERSION > VERSION_DEMO
|
||||
m34D6 = 0;
|
||||
#endif
|
||||
|
||||
if (demo_actor) {
|
||||
u16 r29 = 0xFFFF;
|
||||
u16 r28 = (mDemo.getDemoMode() / daPy_demo_c::DEMO_NEW_ANM0_e) - 1;
|
||||
f32 f31 = 0.0f;
|
||||
if (demo_actor->checkEnable(dDemo_actor_c::ENABLE_TRANS_e)) {
|
||||
current.pos = *demo_actor->getTrans();
|
||||
}
|
||||
if (demo_actor->checkEnable(dDemo_actor_c::ENABLE_ROTATE_e)) {
|
||||
current.angle = shape_angle = *demo_actor->getRatate();
|
||||
}
|
||||
if (demo_actor->checkEnable(dDemo_actor_c::ENABLE_ANM_FRAME_e)) {
|
||||
f31 = demo_actor->getAnmFrame();
|
||||
}
|
||||
f32 f30 = -1.0f;
|
||||
if (demo_actor->checkEnable(dDemo_actor_c::ENABLE_UNK_e)) {
|
||||
dDemo_prm_data* data = demo_actor->getPrm()->getData();
|
||||
u32 id = demo_actor->getPrm()->getId();
|
||||
if (
|
||||
id == 0 || id == 2
|
||||
#if VERSION > VERSION_DEMO
|
||||
|| id == 4
|
||||
#endif
|
||||
) {
|
||||
JStudio::stb::TParseData_fixed<50, TValueIterator_misaligned<u16> > spC4(data);
|
||||
r29 = *spC4.begin();
|
||||
JStudio::stb::TParseData_fixed<49, TValueIterator_raw<u8> > spB0(spC4.getNext());
|
||||
if (spB0.size() == 3) {
|
||||
mLeftHandIdx = *spB0.begin();
|
||||
// TValueIterator_raw<u8> it(spB0.begin());
|
||||
// mRightHandIdx = *++spB0.begin();
|
||||
// mRightHandIdx = *spB0.front();
|
||||
mRightHandIdx = *TValueIterator_raw<u8>(spB0.front());
|
||||
// mRightHandIdx = *TValueIterator_raw<u8>(spB0.begin() + 1);
|
||||
f30 = *--spB0.end();
|
||||
} else {
|
||||
mLeftHandIdx = *spB0.begin();
|
||||
mRightHandIdx = *--spB0.end();
|
||||
}
|
||||
|
||||
if (demo_actor->getPrm()->getId() == 2) {
|
||||
m3574 = 1;
|
||||
}
|
||||
#if VERSION > VERSION_DEMO
|
||||
else if (demo_actor->getPrm()->getId() == 4) {
|
||||
m34D6 = 1;
|
||||
}
|
||||
#endif
|
||||
} else if (
|
||||
id == 1 || id == 3
|
||||
#if VERSION > VERSION_DEMO
|
||||
|| id == 5
|
||||
#endif
|
||||
) {
|
||||
JStudio::stb::TParseData_fixed<50, TValueIterator_misaligned<u16> > sp9C(data);
|
||||
r29 = *sp9C.begin();
|
||||
// setDemoTextureAnime(*++sp9C.begin(), *--sp9C.end(), 0, r28);
|
||||
// setDemoTextureAnime(*(sp9C.begin() + 1), *--sp9C.end(), 0, r28);
|
||||
// setDemoTextureAnime(*sp9C.front(), *--sp9C.end(), 0, r28);
|
||||
// setDemoTextureAnime(*(u16*)sp9C.front().get(), *--sp9C.end(), 0, r28);
|
||||
// TValueIterator_misaligned<u16> it1(sp9C.begin());
|
||||
// TValueIterator_misaligned<u16> it2(sp9C.end());
|
||||
// setDemoTextureAnime(*it1, *it2, 0, r28);
|
||||
setDemoTextureAnime(*TValueIterator_misaligned<u16>(sp9C.front()), *--sp9C.end(), 0, r28);
|
||||
JStudio::stb::TParseData_fixed<49, TValueIterator_raw<u8> > sp88(sp9C.getNext());
|
||||
if (sp88.size() == 3) {
|
||||
mLeftHandIdx = *sp88.begin();
|
||||
// mRightHandIdx = *++sp88.begin();
|
||||
// mRightHandIdx = *sp88.front();
|
||||
mRightHandIdx = *TValueIterator_raw<u8>(sp88.front());
|
||||
f30 = *--sp88.end();
|
||||
} else {
|
||||
mLeftHandIdx = *sp88.begin();
|
||||
mRightHandIdx = *--sp88.end();
|
||||
}
|
||||
|
||||
if (demo_actor->getPrm()->getId() == 3) {
|
||||
m3574 = 1;
|
||||
}
|
||||
#if VERSION > VERSION_DEMO
|
||||
else if (demo_actor->getPrm()->getId() == 5) {
|
||||
m34D6 = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
u8 itemNo = dItem_NONE_e;
|
||||
if (mLeftHandIdx == 0xC8) {
|
||||
itemNo = dItem_SWORD_e;
|
||||
} else if (mLeftHandIdx == 0xC9) {
|
||||
itemNo = dItem_MASTER_SWORD_1_e;
|
||||
} else if (mLeftHandIdx == 0xCA) {
|
||||
itemNo = dItem_MASTER_SWORD_2_e;
|
||||
} else if (mLeftHandIdx == 0xCB) {
|
||||
itemNo = dItem_MASTER_SWORD_3_e;
|
||||
}
|
||||
if (itemNo != dItem_NONE_e) {
|
||||
mLeftHandIdx = 3;
|
||||
if (mEquipItem != daPyItem_SWORD_e || itemNo != dComIfGs_getSelectEquip(0)) {
|
||||
dComIfGs_setSelectEquip(0, itemNo);
|
||||
deleteEquipItem(FALSE);
|
||||
#if VERSION == VERSION_DEMO
|
||||
setSwordModel();
|
||||
#else
|
||||
setSwordModel(TRUE);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (mLeftHandIdx == 0xCC) {
|
||||
if (mEquipItem != dItem_WIND_WAKER_e) {
|
||||
deleteEquipItem(FALSE);
|
||||
}
|
||||
mLeftHandIdx = 5;
|
||||
setTactModel();
|
||||
} else if (mEquipItem != daPyItem_NONE_e) {
|
||||
deleteEquipItem(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (mRightHandIdx == 0xC8 || mRightHandIdx == 0xC9) {
|
||||
m34D4 = 1;
|
||||
if (mRightHandIdx == 0xC8) {
|
||||
dComIfGs_setSelectEquip(1, dItem_SHIELD_e);
|
||||
} else {
|
||||
dComIfGs_setSelectEquip(1, dItem_MIRROR_SHIELD_e);
|
||||
}
|
||||
mRightHandIdx = 0x08;
|
||||
} else {
|
||||
m34D4 = 0;
|
||||
if (mRightHandIdx != 0) {
|
||||
mRightHandIdx += 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (r29 != 0xFFFF && (anm_heap_under->field_0x4 != r29 || anm_heap_under->field_0x6 != r28)) {
|
||||
JKRReadIdResource(anm_heap_under->m_buffer, 0xB400, r29, dComIfGp_getLkDemoAnmArchive());
|
||||
JKRHeap* oldHeap = setAnimeHeap(anm_heap_under->mpAnimeHeap);
|
||||
J3DAnmTransform* r26 = (J3DAnmTransform*)J3DAnmLoaderDataBase::load(anm_heap_under->m_buffer);
|
||||
mDoExt_setCurrentHeap(oldHeap);
|
||||
|
||||
setFrameCtrl(&mFrameCtrlUnder[UNDER_MOVE0_e], r26->getAttribute(), 0, r26->getFrameMax(), 1.0f, f31);
|
||||
r26->setFrame(f31);
|
||||
anm_heap_under->mIdx = 0xFFFF;
|
||||
anm_heap_under->field_0x4 = r29;
|
||||
anm_heap_under->field_0x6 = r28;
|
||||
mAnmRatioUnder[UNDER_MOVE0_e].setAnmTransform(r26);
|
||||
mAnmRatioUpper[UPPER_MOVE0_e].setAnmTransform(r26);
|
||||
m34C3 = 0;
|
||||
if (f30 >= 0.0f) {
|
||||
m_old_fdata->initOldFrameMorf(f30, 0, 0x2A);
|
||||
}
|
||||
demo_actor->setAnmFrameMax(r26->getFrameMax());
|
||||
setSeAnime(anm_heap_under, &mFrameCtrlUnder[UNDER_MOVE0_e]);
|
||||
} else {
|
||||
if (demo_actor->checkEnable(dDemo_actor_c::ENABLE_ANM_FRAME_e)) {
|
||||
mAnmRatioUnder[UNDER_MOVE0_e].getAnmTransform()->setFrame(f31);
|
||||
demo_actor->setAnmFrameMax(mAnmRatioUnder[UNDER_MOVE0_e].getAnmTransform()->getFrameMax());
|
||||
mFrameCtrlUnder[UNDER_MOVE0_e].setFrame(f31);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
checkNextMode(0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* 8012DA3C-8012DBD0 .text dProcTalk_init__9daPy_lk_cFv */
|
||||
|
||||
@@ -623,7 +623,7 @@ void daPy_lk_c::setTextureAnimeResource(J3DAnmTexPattern* btp, int r31) {
|
||||
J3DAnmTexPattern* daPy_lk_c::loadTextureAnimeResource(u32 btpIdx, BOOL isDemo) {
|
||||
J3DAnmTexPattern* btp;
|
||||
if (isDemo) {
|
||||
JKRReadResource(m_tex_anm_heap.m_buffer, 0x1000, btpIdx, dComIfGp_getLkDemoAnmArchive());
|
||||
JKRReadIdResource(m_tex_anm_heap.m_buffer, 0x1000, btpIdx, dComIfGp_getLkDemoAnmArchive());
|
||||
} else {
|
||||
JKRReadIdxResource(m_tex_anm_heap.m_buffer, 0x1000, btpIdx, dComIfGp_getAnmArchive());
|
||||
}
|
||||
@@ -937,7 +937,7 @@ void daPy_lk_c::setTextureScrollResource(J3DAnmTextureSRTKey* btk, int r31) {
|
||||
J3DAnmTextureSRTKey* daPy_lk_c::loadTextureScrollResource(u32 btkIdx, BOOL isDemo) {
|
||||
J3DAnmTextureSRTKey* btk;
|
||||
if (isDemo) {
|
||||
JKRReadResource(m_tex_scroll_heap.m_buffer, 0x800, btkIdx, dComIfGp_getLkDemoAnmArchive());
|
||||
JKRReadIdResource(m_tex_scroll_heap.m_buffer, 0x800, btkIdx, dComIfGp_getLkDemoAnmArchive());
|
||||
} else {
|
||||
JKRReadIdxResource(m_tex_scroll_heap.m_buffer, 0x800, btkIdx, dComIfGp_getAnmArchive());
|
||||
}
|
||||
|
||||
+2
-2
@@ -624,8 +624,8 @@ void dSv_player_bag_item_c::setReserveItemEmpty() {
|
||||
}
|
||||
|
||||
/* 8005A7C0-8005A7E4 .text setReserveItemEmpty__21dSv_player_bag_item_cFUc */
|
||||
void dSv_player_bag_item_c::setReserveItemEmpty(u8 i_itemNo) {
|
||||
setReserveItemChange(i_itemNo, dItem_NONE_e);
|
||||
void dSv_player_bag_item_c::setReserveItemEmpty(u8 i_itemBtn) {
|
||||
setReserveItemChange(i_itemBtn, dItem_NONE_e);
|
||||
}
|
||||
|
||||
/* 8005A7E4-8005A854 .text setReserveItem__21dSv_player_bag_item_cFUc */
|
||||
|
||||
Reference in New Issue
Block a user