From c11228ea869101e68706f928405f5a4c68b9f752 Mon Sep 17 00:00:00 2001 From: LC Date: Tue, 26 Jan 2021 17:04:10 -0500 Subject: [PATCH] J2DPane: Add names for several unlabeled variables (#103) Should make working on other classes adjacent to J2DPane a little more descriptive in the decompilation process. --- include/JSystem/J2DGraph/J2DPane.h | 56 +++++++-------- libs/JSystem/J2DGraph/J2DPane.cpp | 109 +++++++++++++++-------------- 2 files changed, 84 insertions(+), 81 deletions(-) diff --git a/include/JSystem/J2DGraph/J2DPane.h b/include/JSystem/J2DGraph/J2DPane.h index 62f15b515c7..505c9b7cd9f 100644 --- a/include/JSystem/J2DGraph/J2DPane.h +++ b/include/JSystem/J2DGraph/J2DPane.h @@ -109,8 +109,8 @@ public: /* 0x30 */ virtual void update(); /* 0x34 */ virtual void drawSelf(f32 arg1, f32 arg2); /* 0x38 */ virtual void drawSelf(f32 arg1, f32 arg2, Mtx* mtx); - /* 0x3c */ virtual const class J2DPane* search(u64 arg1); - /* 0x40 */ virtual const class J2DPane* searchUserInfo(u64 arg1); + /* 0x3c */ virtual const J2DPane* search(u64 tag); + /* 0x40 */ virtual const J2DPane* searchUserInfo(u64 tag); /* 0x44 */ virtual void makeMatrix(); /* 0x48 */ virtual void makeMatrix(f32 a, f32 b, f32 c, f32 d); /* 0x4c */ virtual bool isUsed(const ResTIMG* timg); @@ -133,14 +133,14 @@ public: /* 0x90 */ virtual const J2DAnmTransform* animationPane(const J2DAnmTransform* transform); // inlines - f32 getHeight() const { return _20.getHeight(); } - f32 getWidth() const { return _20.getWidth(); } + f32 getHeight() const { return mBounds.getHeight(); } + f32 getWidth() const { return mBounds.getWidth(); } JSUTree* getFirstChild() { return mPaneTree.getFirstChild(); } const JSUTree* getPaneTree() { return &mPaneTree; } // member functions void initiate(); - void initialize(u64 arg1, const TBox2& dim); + void initialize(u64 tag, const TBox2& dim); void makePaneStream(J2DPane* other, JSURandomInputStream* stream); void changeUseTrans(J2DPane* other); bool appendChild(J2DPane* child); @@ -148,15 +148,15 @@ public: void draw(f32 a1, f32 a2, const J2DGrafContext* ctx, bool a4, bool a5); void place(const TBox2& dim); TBox2& getBounds(); - void rotate(f32 a, f32 b, J2DRotateAxis axis, f32 angle); + void rotate(f32 offsetX, f32 offsetY, J2DRotateAxis axis, f32 angle); void rotate(f32 angle); void clip(const TBox2& bounds); void setBasePosition(J2DBasePosition position); void setInfluencedAlpha(bool arg1, bool arg2); void getGlbVtx(u8 arg1) const; - const class J2DPane* getFirstChildPane(); - const class J2DPane* getNextChildPane(); - const class J2DPane* getParentPane(); + const J2DPane* getFirstChildPane(); + const J2DPane* getNextChildPane(); + const J2DPane* getParentPane(); void makePaneExStream(J2DPane* other, JSURandomInputStream* stream); static s16 J2DCast_F32_to_S16(f32 value, u8 arg2); void* getPointer(JSURandomInputStream* stream, u32 size, JKRArchive* archive); @@ -168,30 +168,30 @@ private: /* 0x006 */ u8 _6[2]; /* 0x008 */ int id; /* 0x00c */ u8 _c[4]; - /* 0x010 */ u64 _10; - /* 0x018 */ u64 _18; - /* 0x020 */ TBox2 _20; - /* 0x030 */ TBox2 _30; - /* 0x040 */ TBox2 _40; - /* 0x050 */ Mtx _50; - /* 0x080 */ Mtx _80; + /* 0x010 */ u64 mInfoTag; + /* 0x018 */ u64 mUserInfoTag; + /* 0x020 */ TBox2 mBounds; + /* 0x030 */ TBox2 mGlobalBounds; + /* 0x040 */ TBox2 mClipRect; + /* 0x050 */ Mtx mPositionMtx; + /* 0x080 */ Mtx mGlobalMtx; /* 0x0b0 */ bool mVisible; /* 0x0b1 */ u8 mCullMode; /* 0x0b2 */ u8 mAlpha; - /* 0x0b3 */ u8 _b3; - /* 0x0b4 */ u8 _b4; + /* 0x0b3 */ u8 mColorAlpha; + /* 0x0b4 */ bool mIsInfluencedAlpha; /* 0x0b5 */ bool mConnected; /* 0x0b6 */ char mRotAxis; - /* 0x0b7 */ u8 _b7; - /* 0x0b8 */ f32 _b8; - /* 0x0bc */ f32 _bc; - /* 0x0c0 */ f32 _c0; - /* 0x0c4 */ f32 _c4; - /* 0x0c8 */ f32 _c8; - /* 0x0cc */ f32 _cc; - /* 0x0d0 */ f32 _d0; - /* 0x0d4 */ f32 _d4; - /* 0x0d8 */ f32 _d8; + /* 0x0b7 */ u8 mBasePosition; + /* 0x0b8 */ f32 mRotateX; + /* 0x0bc */ f32 mRotateY; + /* 0x0c0 */ f32 mRotateZ; + /* 0x0c4 */ f32 mRotateOffsetX; + /* 0x0c8 */ f32 mRotateOffsetY; + /* 0x0cc */ f32 mScaleX; + /* 0x0d0 */ f32 mScaleY; + /* 0x0d4 */ f32 mTranslateX; + /* 0x0d8 */ f32 mTranslateY; /* 0x0dc */ JSUTree mPaneTree; /* 0x0f8 */ const J2DAnmTransform* mTransform; /* 0x0fc */ u32 _fc; diff --git a/libs/JSystem/J2DGraph/J2DPane.cpp b/libs/JSystem/J2DGraph/J2DPane.cpp index 7e081401ede..d9c5f258a93 100644 --- a/libs/JSystem/J2DGraph/J2DPane.cpp +++ b/libs/JSystem/J2DGraph/J2DPane.cpp @@ -1,12 +1,12 @@ #include "JSystem/J2DGraph/J2DPane.h" -J2DPane::J2DPane() : _20(), _30(), _40(), mPaneTree(this) { +J2DPane::J2DPane() : mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) { mTransform = NULL; id = 'PAN1'; mVisible = true; - _10 = 0; - _18 = 0; - _20.set(lbl_804561F0, lbl_804561F0, lbl_804561F0, lbl_804561F0); + mInfoTag = 0; + mUserInfoTag = 0; + mBounds.set(lbl_804561F0, lbl_804561F0, lbl_804561F0, lbl_804561F0); initiate(); changeUseTrans(NULL); calcMtx(); @@ -14,14 +14,14 @@ J2DPane::J2DPane() : _20(), _30(), _40(), mPaneTree(this) { void J2DPane::initiate() { _4 = -1; - _c8 = _c4 = _c0 = _bc = _b8 = lbl_804561F0; - _b7 = 0; + mRotateOffsetY = mRotateOffsetX = mRotateZ = mRotateY = mRotateX = lbl_804561F0; + mBasePosition = 0; mRotAxis = AXIS_Z; - _d0 = _cc = lbl_804561F4; + mScaleY = mScaleX = lbl_804561F4; mCullMode = GX_CULL_NONE; mAlpha = 0xFF; - _b4 = 1; - _b3 = 0xFF; + mIsInfluencedAlpha = true; + mColorAlpha = 0xFF; mConnected = false; calcMtx(); @@ -52,12 +52,12 @@ asm void J2DPane_X2_(void) { } #ifdef NONMATCHING // templating..... again -void J2DPane::initialize(u64 arg1, const TBox2& dim) { +void J2DPane::initialize(u64 tag, const TBox2& dim) { id = 'PAN1'; mVisible = true; - _10 = arg1; - _18 = arg1; - _20.set(dim); + mInfoTag = tag; + mUserInfoTag = tag; + mBounds.set(dim); initiate(); changeUseTrans(NULL); calcMtx(); @@ -111,7 +111,7 @@ bool J2DPane::appendChild(J2DPane* child) { bool result = mPaneTree.appendChild(&child->mPaneTree); if (result && parent == NULL) { - child->add(_20.i.x, _20.i.y); + child->add(mBounds.i.x, mBounds.i.y); child->calcMtx(); } @@ -128,7 +128,7 @@ bool J2DPane::insertChild(J2DPane* before, J2DPane* child) { bool result = mPaneTree.insertChild(&before->mPaneTree, &child->mPaneTree); if (result && parent == NULL) { - child->add(_20.i.x, _20.i.y); + child->add(mBounds.i.x, mBounds.i.y); child->calcMtx(); } @@ -167,20 +167,20 @@ asm void J2DPane::move(f32 x, f32 y) { #endif void J2DPane::add(f32 x, f32 y) { - _d4 += x; - _d8 += y; + mTranslateX += x; + mTranslateY += y; calcMtx(); } #ifdef NONMATCHING void J2DPane::resize(f32 x, f32 y) { - TBox2 box = _20; + TBox2 box = mBounds; - box.addPos(TVec2(_d4, _d8)); + box.addPos(TVec2(mTranslateX, mTranslateY)); const J2DPane* parent = getParentPane(); if (parent != NULL) { - box.addPos(TVec2(-parent->_20.i.x, -parent->_20.i.y)); + box.addPos(TVec2(-parent->mBounds.i.x, -parent->mBounds.i.y)); } box.f.x = box.i.x + x; @@ -196,12 +196,12 @@ asm void J2DPane::resize(f32 x, f32 y) { #ifdef NONMATCHING // close ish TBox2& J2DPane::getBounds() { - lbl_804349B0 = _20; - lbl_804349B0.addPos(TVec2(_d4, _d8)); + lbl_804349B0 = mBounds; + lbl_804349B0.addPos(TVec2(mTranslateX, mTranslateY)); const J2DPane* parent = getParentPane(); if (parent != NULL) { - lbl_804349B0.addPos(TVec2(-parent->_20.i.x, -parent->_20.i.y)); + lbl_804349B0.addPos(TVec2(-parent->mBounds.i.x, -parent->mBounds.i.y)); } return lbl_804349B0; @@ -213,20 +213,21 @@ asm TBox2& J2DPane::getBounds() { } #endif -void J2DPane::rotate(f32 a, f32 b, J2DRotateAxis axis, f32 angle) { - _c4 = a; - _c8 = b; +void J2DPane::rotate(f32 offsetX, f32 offsetY, J2DRotateAxis axis, f32 angle) { + mRotateOffsetX = offsetX; + mRotateOffsetY = offsetY; mRotAxis = axis; rotate(angle); } void J2DPane::rotate(f32 angle) { - if (mRotAxis == AXIS_X) - _b8 = angle; - else if (mRotAxis == AXIS_Y) - _bc = angle; - else - _c0 = angle; + if (mRotAxis == AXIS_X) { + mRotateX = angle; + } else if (mRotAxis == AXIS_Y) { + mRotateY = angle; + } else { + mRotateZ = angle; + } calcMtx(); } @@ -244,32 +245,34 @@ asm void clip__7J2DPaneFRCQ29JGeometry8TBox2(void) { // void J2DPane::clip(const TBox2& bounds) { // TBox2 box = bounds; -// box.addPos(TVec2(_30, _34)); -// _40.intersect(box); +// box.addPos(TVec2(mGlobalBounds, _34)); +// mClipRect.intersect(box); // } -const class J2DPane* J2DPane::search(u64 arg1) { - if (arg1 == _10) +const J2DPane* J2DPane::search(u64 tag) { + if (tag == mInfoTag) { return this; + } JSUTreeIterator iter; for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) { - const J2DPane* result = iter.getObject()->search(arg1); - if (result) + if (const J2DPane* result = iter.getObject()->search(tag)) { return result; + } } return NULL; } -const class J2DPane* J2DPane::searchUserInfo(u64 arg1) { - if (arg1 == _18) +const J2DPane* J2DPane::searchUserInfo(u64 tag) { + if (tag == mUserInfoTag) { return this; + } JSUTreeIterator iter; for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) { - const J2DPane* result = iter.getObject()->searchUserInfo(arg1); - if (result) + if (const J2DPane* result = iter.getObject()->searchUserInfo(tag)) { return result; + } } return NULL; } @@ -307,26 +310,26 @@ void J2DPane::setCullBack(GXCullMode mode) { } void J2DPane::setBasePosition(J2DBasePosition position) { - _b7 = position; + mBasePosition = position; mRotAxis = AXIS_Z; - _c4 = lbl_804561F0; + mRotateOffsetX = lbl_804561F0; if (position % 3 == 1) { f32 width = getWidth(); - _c4 = width * lbl_80456208; + mRotateOffsetX = width * lbl_80456208; } else if (position % 3 == 2) { f32 width = getWidth(); - _c4 = width; + mRotateOffsetX = width; } - _c8 = lbl_804561F0; + mRotateOffsetY = lbl_804561F0; if (position / 3 == 1) { f32 height = getHeight(); - _c8 = height * lbl_80456208; + mRotateOffsetY = height * lbl_80456208; } else if (position / 3 == 2) { f32 height = getHeight(); - _c8 = height; + mRotateOffsetY = height; } calcMtx(); @@ -343,27 +346,27 @@ asm void J2DPane::getGlbVtx(u8 arg1) const { } #ifdef NONMATCHING // probably an issue with JSUTree -const class J2DPane* J2DPane::getFirstChildPane() { +const J2DPane* J2DPane::getFirstChildPane() { if (!getFirstChild()) return NULL; return getFirstChild()->getObject(); } #else -asm const class J2DPane* J2DPane::getFirstChildPane() { +asm const J2DPane* J2DPane::getFirstChildPane() { nofralloc #include "JSystem/J2DGraph/J2DPane/asm/func_802F7A8C.s" } #endif -const class J2DPane* J2DPane::getNextChildPane() { +const J2DPane* J2DPane::getNextChildPane() { if (getPaneTree()->getNextChild() == NULL) return NULL; return getPaneTree()->getNextChild()->getObject(); } -const class J2DPane* J2DPane::getParentPane() { +const J2DPane* J2DPane::getParentPane() { if (getPaneTree()->getParent() == NULL) return NULL;