summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJcw87 <Jcw87@users.noreply.github.com>2026-01-11 19:00:04 -0800
committerGitHub <noreply@github.com>2026-01-11 19:00:04 -0800
commit2dd7e2ea62daaa33195b2adbca8b086ceaa6d464 (patch)
treed56016fab9d536e646ebde852dd8ef2ad81ba732 /src
parent6e76f12dd3b49acc9b682eeb811dbec64bc3519c (diff)
J2DGraph debug (#3028)
* J2DGraph debug * J2DGraph debug
Diffstat (limited to 'src')
-rw-r--r--src/JSystem/J2DGraph/J2DAnimation.cpp424
-rw-r--r--src/JSystem/J2DGraph/J2DAnmLoader.cpp79
-rw-r--r--src/JSystem/J2DGraph/J2DManage.cpp21
-rw-r--r--src/JSystem/J2DGraph/J2DMatBlock.cpp101
-rw-r--r--src/JSystem/J2DGraph/J2DMaterial.cpp20
-rw-r--r--src/JSystem/J2DGraph/J2DMaterialFactory.cpp52
-rw-r--r--src/JSystem/J2DGraph/J2DPane.cpp231
-rw-r--r--src/JSystem/J2DGraph/J2DPicture.cpp208
-rw-r--r--src/JSystem/J2DGraph/J2DPictureEx.cpp160
-rw-r--r--src/JSystem/J2DGraph/J2DScreen.cpp40
-rw-r--r--src/JSystem/J2DGraph/J2DTevs.cpp17
-rw-r--r--src/JSystem/J2DGraph/J2DWindow.cpp131
-rw-r--r--src/JSystem/J2DGraph/J2DWindowEx.cpp4
13 files changed, 735 insertions, 753 deletions
diff --git a/src/JSystem/J2DGraph/J2DAnimation.cpp b/src/JSystem/J2DGraph/J2DAnimation.cpp
index bd10f3f369..5ca534a3a1 100644
--- a/src/JSystem/J2DGraph/J2DAnimation.cpp
+++ b/src/JSystem/J2DGraph/J2DAnimation.cpp
@@ -7,90 +7,138 @@
#include "JSystem/JUtility/JUTResource.h"
#include "dolphin/os.h"
-f32 J2DGetKeyFrameInterpolationf(f32 param_0, J3DAnmKeyTableBase* param_1, f32* param_2);
-f32 J2DGetKeyFrameInterpolations(f32 param_0, J3DAnmKeyTableBase* param_1, s16* param_2);
+template<typename T>
+f32 J2DGetKeyFrameInterpolation(f32 param_0, J3DAnmKeyTableBase* param_1, T* param_2) {
+ J3D_PANIC(101, param_2, "Error : null pointer.");
+ if (param_0 < param_2[0]) {
+ return param_2[1];
+ } else {
+ if (param_1->mType == 0) {
+ if (param_2[(param_1->mMaxFrame - 1) * 3] <= param_0) {
+ return param_2[(param_1->mMaxFrame - 1) * 3 + 1];
+ } else {
+ u32 tmp = param_1->mMaxFrame;
+ while (tmp > 1) {
+ u32 halfTmp = tmp / 2;
+ u32 upIdx = halfTmp * 3;
+ if (param_0 >= param_2[upIdx]) {
+ param_2 = param_2 + upIdx;
+ tmp -= halfTmp;
+ } else {
+ tmp = halfTmp;
+ }
+ }
+ f32 result = J2DHermiteInterpolation(param_0, &param_2[0], &param_2[1], &param_2[2], &param_2[3], &param_2[4], &param_2[5]);
+ return result;
+ }
+ } else {
+ if (param_2[(param_1->mMaxFrame - 1) * 4] <= param_0) {
+ return param_2[(param_1->mMaxFrame - 1) * 4 + 1];
+ } else {
+ u32 tmp = param_1->mMaxFrame;
+ while (tmp > 1) {
+ u32 halfTmp = tmp / 2;
+ u32 upIdx = halfTmp * 4;
+ if (param_0 >= param_2[upIdx]) {
+ param_2 = param_2 + upIdx;
+ tmp -= halfTmp;
+ } else {
+ tmp = halfTmp;
+ }
+ }
+ f32 result = J2DHermiteInterpolation(param_0, &param_2[0], &param_2[1], &param_2[3], &param_2[4], &param_2[5], &param_2[6]);
+ return result;
+ }
+ }
+ }
+}
void J2DAnmTransformFull::getTransform(u16 param_0, J3DTransformInfo* transformInfo) const {
+ u32 local_3c = mFrame;
+ J3D_PANIC(169, param_0 < field_0x22, "Error : range over.");
+ J3D_PANIC(170, transformInfo, "Error : null pointer.");
u16 idx = (param_0 * 3);
J3DAnmTransformFullTable* xPart = &mTableInfo[idx];
J3DAnmTransformFullTable* yPart = &mTableInfo[idx + 1];
J3DAnmTransformFullTable* zPart = &mTableInfo[idx + 2];
- u16 xMaxFrame = xPart->mScaleMaxFrame;
- if (getFrame() < 0) {
+ u32 maxFrame = xPart->mScaleMaxFrame;
+ if (mFrame < 0) {
transformInfo->mScale.x = mScaleValues[xPart->mScaleOffset];
- } else if (getFrame() >= xMaxFrame) {
- transformInfo->mScale.x = mScaleValues[(xPart->mScaleOffset + (xMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mScale.x = mScaleValues[(xPart->mScaleOffset + (maxFrame - 1))];
} else {
- transformInfo->mScale.x = mScaleValues[(xPart->mScaleOffset + (int)getFrame())];
+ transformInfo->mScale.x = mScaleValues[(xPart->mScaleOffset + (int)mFrame)];
}
- u16 yMaxFrame = yPart->mScaleMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = yPart->mScaleMaxFrame;
+ if (mFrame < 0) {
transformInfo->mScale.y = mScaleValues[yPart->mScaleOffset];
- } else if (getFrame() >= yMaxFrame) {
- transformInfo->mScale.y = mScaleValues[(yPart->mScaleOffset + (yMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mScale.y = mScaleValues[(yPart->mScaleOffset + (maxFrame - 1))];
} else {
- transformInfo->mScale.y = mScaleValues[(yPart->mScaleOffset + (int)getFrame())];
+ transformInfo->mScale.y = mScaleValues[(yPart->mScaleOffset + (int)mFrame)];
}
- u16 zMaxFrame = zPart->mScaleMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = zPart->mScaleMaxFrame;
+ if (mFrame < 0) {
transformInfo->mScale.z = mScaleValues[zPart->mScaleOffset];
- } else if (getFrame() >= zMaxFrame) {
- transformInfo->mScale.z = mScaleValues[(zPart->mScaleOffset + (zMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mScale.z = mScaleValues[(zPart->mScaleOffset + (maxFrame - 1))];
} else {
- transformInfo->mScale.z = mScaleValues[(zPart->mScaleOffset + (int)getFrame())];
+ transformInfo->mScale.z = mScaleValues[(zPart->mScaleOffset + (int)mFrame)];
}
- xMaxFrame = xPart->mRotationMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = xPart->mRotationMaxFrame;
+ if (mFrame < 0) {
transformInfo->mRotation.x = mRotationValues[xPart->mRotationOffset];
- } else if (getFrame() >= xMaxFrame) {
- transformInfo->mRotation.x = mRotationValues[(xPart->mRotationOffset + (xMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mRotation.x = mRotationValues[(xPart->mRotationOffset + (maxFrame - 1))];
} else {
- transformInfo->mRotation.x = mRotationValues[(xPart->mRotationOffset + (int)getFrame())];
+ transformInfo->mRotation.x = mRotationValues[(xPart->mRotationOffset + (int)mFrame)];
}
- yMaxFrame = yPart->mRotationMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = yPart->mRotationMaxFrame;
+ if (mFrame < 0) {
transformInfo->mRotation.y = mRotationValues[yPart->mRotationOffset];
- } else if (getFrame() >= yMaxFrame) {
- transformInfo->mRotation.y = mRotationValues[(yPart->mRotationOffset + (yMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mRotation.y = mRotationValues[(yPart->mRotationOffset + (maxFrame - 1))];
} else {
- transformInfo->mRotation.y = mRotationValues[(yPart->mRotationOffset + (int)getFrame())];
+ transformInfo->mRotation.y = mRotationValues[(yPart->mRotationOffset + (int)mFrame)];
}
- zMaxFrame = zPart->mRotationMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = zPart->mRotationMaxFrame;
+ if (mFrame < 0) {
transformInfo->mRotation.z = mRotationValues[zPart->mRotationOffset];
- } else if (getFrame() >= zMaxFrame) {
- transformInfo->mRotation.z = mRotationValues[(zPart->mRotationOffset + (zMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mRotation.z = mRotationValues[(zPart->mRotationOffset + (maxFrame - 1))];
} else {
- transformInfo->mRotation.z = mRotationValues[(zPart->mRotationOffset + (int)getFrame())];
+ transformInfo->mRotation.z = mRotationValues[(zPart->mRotationOffset + (int)mFrame)];
}
- xMaxFrame = xPart->mTranslateMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = xPart->mTranslateMaxFrame;
+ if (mFrame < 0) {
transformInfo->mTranslate.x = mTranslateValues[xPart->mTranslateOffset];
- } else if (getFrame() >= xMaxFrame) {
- transformInfo->mTranslate.x = mTranslateValues[(xPart->mTranslateOffset + (xMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mTranslate.x = mTranslateValues[(xPart->mTranslateOffset + (maxFrame - 1))];
} else {
- transformInfo->mTranslate.x = mTranslateValues[(xPart->mTranslateOffset + (int)getFrame())];
+ transformInfo->mTranslate.x = mTranslateValues[(xPart->mTranslateOffset + (int)mFrame)];
}
- yMaxFrame = yPart->mTranslateMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = yPart->mTranslateMaxFrame;
+ if (mFrame < 0) {
transformInfo->mTranslate.y = mTranslateValues[yPart->mTranslateOffset];
- } else if (getFrame() >= yMaxFrame) {
- transformInfo->mTranslate.y = mTranslateValues[(yPart->mTranslateOffset + (yMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mTranslate.y = mTranslateValues[(yPart->mTranslateOffset + (maxFrame - 1))];
} else {
- transformInfo->mTranslate.y = mTranslateValues[(yPart->mTranslateOffset + (int)getFrame())];
+ transformInfo->mTranslate.y = mTranslateValues[(yPart->mTranslateOffset + (int)mFrame)];
}
- zMaxFrame = zPart->mTranslateMaxFrame;
- if (getFrame() < 0) {
+ maxFrame = zPart->mTranslateMaxFrame;
+ if (mFrame < 0) {
transformInfo->mTranslate.z = mTranslateValues[zPart->mTranslateOffset];
- } else if (getFrame() >= zMaxFrame) {
- transformInfo->mTranslate.z = mTranslateValues[(zPart->mTranslateOffset + (zMaxFrame - 1))];
+ } else if (mFrame >= maxFrame) {
+ transformInfo->mTranslate.z = mTranslateValues[(zPart->mTranslateOffset + (maxFrame - 1))];
} else {
- transformInfo->mTranslate.z = mTranslateValues[(zPart->mTranslateOffset + (int)getFrame())];
+ transformInfo->mTranslate.z = mTranslateValues[(zPart->mTranslateOffset + (int)mFrame)];
}
}
void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
J3DTransformInfo* transformInfo) const {
+ J3D_PANIC(268, param_1 < field_0x22, "Error : range over.");
+ J3D_PANIC(269, transformInfo, "Error : null pointer.");
u16 idx = param_1 * 3;
J3DAnmTransformKeyTable* xInf = &mInfoTable[idx];
J3DAnmTransformKeyTable* yInf = &mInfoTable[idx + 1];
@@ -103,7 +151,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
transformInfo->mScale.x = mScaleValues[xInf->mScaleInfo.mOffset];
break;
default:
- transformInfo->mScale.x = J2DGetKeyFrameInterpolationf(
+ transformInfo->mScale.x = J2DGetKeyFrameInterpolation<f32>(
param_0, &xInf->mScaleInfo, &mScaleValues[xInf->mScaleInfo.mOffset]);
}
switch (yInf->mScaleInfo.mMaxFrame) {
@@ -114,7 +162,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
transformInfo->mScale.y = mScaleValues[yInf->mScaleInfo.mOffset];
break;
default:
- transformInfo->mScale.y = J2DGetKeyFrameInterpolationf(
+ transformInfo->mScale.y = J2DGetKeyFrameInterpolation<f32>(
param_0, &yInf->mScaleInfo, &mScaleValues[yInf->mScaleInfo.mOffset]);
}
switch (zInf->mScaleInfo.mMaxFrame) {
@@ -125,7 +173,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
transformInfo->mScale.z = mScaleValues[zInf->mScaleInfo.mOffset];
break;
default:
- transformInfo->mScale.z = J2DGetKeyFrameInterpolationf(
+ transformInfo->mScale.z = J2DGetKeyFrameInterpolation<f32>(
param_0, &zInf->mScaleInfo, &mScaleValues[zInf->mScaleInfo.mOffset]);
}
switch (xInf->mRotationInfo.mMaxFrame) {
@@ -137,7 +185,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
break;
default:
transformInfo->mRotation.x =
- static_cast<s32>(J2DGetKeyFrameInterpolations(
+ static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
param_0, &xInf->mRotationInfo, &mRotationValues[xInf->mRotationInfo.mOffset]))
<< field_0x24;
}
@@ -150,7 +198,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
break;
default:
transformInfo->mRotation.y =
- static_cast<s32>(J2DGetKeyFrameInterpolations(
+ static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
param_0, &yInf->mRotationInfo, &mRotationValues[yInf->mRotationInfo.mOffset]))
<< field_0x24;
}
@@ -163,7 +211,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
break;
default:
transformInfo->mRotation.z =
- static_cast<s32>(J2DGetKeyFrameInterpolations(
+ static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
param_0, &zInf->mRotationInfo, &mRotationValues[zInf->mRotationInfo.mOffset]))
<< field_0x24;
}
@@ -175,7 +223,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
transformInfo->mTranslate.x = mTranslateValues[xInf->mTranslateInfo.mOffset];
break;
default:
- transformInfo->mTranslate.x = J2DGetKeyFrameInterpolationf(
+ transformInfo->mTranslate.x = J2DGetKeyFrameInterpolation<f32>(
param_0, &xInf->mTranslateInfo, &mTranslateValues[xInf->mTranslateInfo.mOffset]);
}
switch (yInf->mTranslateInfo.mMaxFrame) {
@@ -186,7 +234,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
transformInfo->mTranslate.y = mTranslateValues[yInf->mTranslateInfo.mOffset];
break;
default:
- transformInfo->mTranslate.y = J2DGetKeyFrameInterpolationf(
+ transformInfo->mTranslate.y = J2DGetKeyFrameInterpolation<f32>(
param_0, &yInf->mTranslateInfo, &mTranslateValues[yInf->mTranslateInfo.mOffset]);
}
switch (zInf->mTranslateInfo.mMaxFrame) {
@@ -197,7 +245,7 @@ void J2DAnmTransformKey::calcTransform(f32 param_0, u16 param_1,
transformInfo->mTranslate.z = mTranslateValues[zInf->mTranslateInfo.mOffset];
break;
default:
- transformInfo->mTranslate.z = J2DGetKeyFrameInterpolationf(
+ transformInfo->mTranslate.z = J2DGetKeyFrameInterpolation<f32>(
param_0, &zInf->mTranslateInfo, &mTranslateValues[zInf->mTranslateInfo.mOffset]);
}
}
@@ -216,42 +264,46 @@ void J2DAnmColor::searchUpdateMaterialID(J2DScreen* pScreen) {
}
void J2DAnmColorFull::getColor(u16 param_0, _GXColor* pColor) const {
+ J3D_PANIC(432, param_0 < mUpdateMaterialNum, "Error : range over.");
+ J3D_PANIC(433, pColor, "Error : null pointer.");
J3DAnmColorFullTable* info = &mInfoTable[param_0];
u16 maxFrame = info->mRMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->r = mRValues[info->mROffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->r = mRValues[info->mROffset + (maxFrame - 1)];
} else {
- pColor->r = mRValues[info->mROffset + (int)getFrame()];
+ pColor->r = mRValues[info->mROffset + (int)mFrame];
}
maxFrame = info->mGMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->g = mGValues[info->mGOffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->g = mGValues[info->mGOffset + (maxFrame - 1)];
} else {
- pColor->g = mGValues[info->mGOffset + (int)getFrame()];
+ pColor->g = mGValues[info->mGOffset + (int)mFrame];
}
maxFrame = info->mBMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->b = mBValues[info->mBOffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->b = mBValues[info->mBOffset + (maxFrame - 1)];
} else {
- pColor->b = mBValues[info->mBOffset + (int)getFrame()];
+ pColor->b = mBValues[info->mBOffset + (int)mFrame];
}
maxFrame = info->mAMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->a = mAValues[info->mAOffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->a = mAValues[info->mAOffset + (maxFrame - 1)];
} else {
- pColor->a = mAValues[info->mAOffset + (int)getFrame()];
+ pColor->a = mAValues[info->mAOffset + (int)mFrame];
}
}
void J2DAnmColorKey::getColor(u16 param_0, _GXColor* pColor) const {
+ J3D_PANIC(490, param_0 < mUpdateMaterialNum, "Error : range over.");
+ J3D_PANIC(491, pColor, "Error : null pointer.");
J3DAnmColorKeyTable* info = &mInfoTable[param_0];
f32 val;
switch (info->mRInfo.mMaxFrame) {
@@ -262,7 +314,7 @@ void J2DAnmColorKey::getColor(u16 param_0, _GXColor* pColor) const {
pColor->r = mRValues[info->mRInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mRInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRInfo,
&mRValues[info->mRInfo.mOffset]);
if (val < 0) {
pColor->r = 0;
@@ -280,7 +332,7 @@ void J2DAnmColorKey::getColor(u16 param_0, _GXColor* pColor) const {
pColor->g = mGValues[info->mGInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mGInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGInfo,
&mGValues[info->mGInfo.mOffset]);
if (val < 0) {
pColor->g = 0;
@@ -298,7 +350,7 @@ void J2DAnmColorKey::getColor(u16 param_0, _GXColor* pColor) const {
pColor->b = mBValues[info->mBInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mBInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBInfo,
&mBValues[info->mBInfo.mOffset]);
if (val < 0) {
pColor->b = 0;
@@ -316,7 +368,7 @@ void J2DAnmColorKey::getColor(u16 param_0, _GXColor* pColor) const {
pColor->a = mAValues[info->mAInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mAInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mAInfo,
&mAValues[info->mAInfo.mOffset]);
if (val < 0) {
pColor->a = 0;
@@ -329,42 +381,44 @@ void J2DAnmColorKey::getColor(u16 param_0, _GXColor* pColor) const {
}
void J2DAnmVtxColorFull::getColor(u8 param_0, u16 param_1, _GXColor* pColor) const {
+ J3D_PANIC(597, pColor, "Error : null pointer.");
J3DAnmColorFullTable* info = &mInfoTable[param_0][param_1];
u16 maxFrame = info->mRMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->r = mRValues[info->mROffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->r = mRValues[info->mROffset + (maxFrame - 1)];
} else {
- pColor->r = mRValues[info->mROffset + (int)getFrame()];
+ pColor->r = mRValues[info->mROffset + (int)mFrame];
}
maxFrame = info->mGMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->g = mGValues[info->mGOffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->g = mGValues[info->mGOffset + (maxFrame - 1)];
} else {
- pColor->g = mGValues[info->mGOffset + (int)getFrame()];
+ pColor->g = mGValues[info->mGOffset + (int)mFrame];
}
maxFrame = info->mBMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->b = mBValues[info->mBOffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->b = mBValues[info->mBOffset + (maxFrame - 1)];
} else {
- pColor->b = mBValues[info->mBOffset + (int)getFrame()];
+ pColor->b = mBValues[info->mBOffset + (int)mFrame];
}
maxFrame = info->mAMaxFrame;
- if (getFrame() < 0) {
+ if (mFrame < 0) {
pColor->a = mAValues[info->mAOffset];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
pColor->a = mAValues[info->mAOffset + (maxFrame - 1)];
} else {
- pColor->a = mAValues[info->mAOffset + (int)getFrame()];
+ pColor->a = mAValues[info->mAOffset + (int)mFrame];
}
}
void J2DAnmVtxColorKey::getColor(u8 param_0, u16 param_1, _GXColor* pColor) const {
+ J3D_PANIC(658, pColor, "Error : null pointer.");
J3DAnmColorKeyTable* info = &mInfoTable[param_0][param_1];
f32 val;
switch (info->mRInfo.mMaxFrame) {
@@ -375,7 +429,7 @@ void J2DAnmVtxColorKey::getColor(u8 param_0, u16 param_1, _GXColor* pColor) cons
pColor->r = mRValues[info->mRInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mRInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRInfo,
&mRValues[info->mRInfo.mOffset]);
if ((val <= 0)) {
pColor->r = 0;
@@ -393,7 +447,7 @@ void J2DAnmVtxColorKey::getColor(u8 param_0, u16 param_1, _GXColor* pColor) cons
pColor->g = mGValues[info->mGInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mGInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGInfo,
&mGValues[info->mGInfo.mOffset]);
if (val <= 0) {
pColor->g = 0;
@@ -411,7 +465,7 @@ void J2DAnmVtxColorKey::getColor(u8 param_0, u16 param_1, _GXColor* pColor) cons
pColor->b = mBValues[info->mBInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mBInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBInfo,
&mBValues[info->mBInfo.mOffset]);
if (val <= 0) {
pColor->b = 0;
@@ -429,7 +483,7 @@ void J2DAnmVtxColorKey::getColor(u8 param_0, u16 param_1, _GXColor* pColor) cons
pColor->a = mAValues[info->mAInfo.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mAInfo,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mAInfo,
&mAValues[info->mAInfo.mOffset]);
if (val <= 0) {
pColor->a = 0;
@@ -442,6 +496,8 @@ void J2DAnmVtxColorKey::getColor(u8 param_0, u16 param_1, _GXColor* pColor) cons
}
void J2DAnmTextureSRTKey::calcTransform(f32 param_0, u16 param_1, J3DTextureSRTInfo* pInfo) const {
+ J3D_PANIC(766, param_1 < mUpdateMaterialNum, "Error : range over.");
+ J3D_PANIC(767, pInfo, "Error : null pointer.");
u16 idx = param_1 * 3;
J3DAnmTransformKeyTable* xInf = &mInfoTable[idx];
J3DAnmTransformKeyTable* yInf = &mInfoTable[idx + 1];
@@ -454,7 +510,7 @@ void J2DAnmTextureSRTKey::calcTransform(f32 param_0, u16 param_1, J3DTextureSRTI
pInfo->mScaleX = mScaleValues[xInf->mScaleInfo.mOffset];
break;
default:
- pInfo->mScaleX = J2DGetKeyFrameInterpolationf(param_0, &xInf->mScaleInfo,
+ pInfo->mScaleX = J2DGetKeyFrameInterpolation<f32>(param_0, &xInf->mScaleInfo,
&mScaleValues[xInf->mScaleInfo.mOffset]);
}
switch (yInf->mScaleInfo.mMaxFrame) {
@@ -465,7 +521,7 @@ void J2DAnmTextureSRTKey::calcTransform(f32 param_0, u16 param_1, J3DTextureSRTI
pInfo->mScaleY = mScaleValues[yInf->mScaleInfo.mOffset];
break;
default:
- pInfo->mScaleY = J2DGetKeyFrameInterpolationf(param_0, &yInf->mScaleInfo,
+ pInfo->mScaleY = J2DGetKeyFrameInterpolation<f32>(param_0, &yInf->mScaleInfo,
&mScaleValues[yInf->mScaleInfo.mOffset]);
}
switch (zInf->mRotationInfo.mMaxFrame) {
@@ -477,7 +533,7 @@ void J2DAnmTextureSRTKey::calcTransform(f32 param_0, u16 param_1, J3DTextureSRTI
break;
default:
pInfo->mRotation =
- static_cast<s32>(J2DGetKeyFrameInterpolations(
+ static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
param_0, &zInf->mRotationInfo, &mRotationValues[zInf->mRotationInfo.mOffset]))
<< field_0x10;
}
@@ -489,7 +545,7 @@ void J2DAnmTextureSRTKey::calcTransform(f32 param_0, u16 param_1, J3DTextureSRTI
pInfo->mTranslationX = mTranslationValues[xInf->mTranslateInfo.mOffset];
break;
default:
- pInfo->mTranslationX = J2DGetKeyFrameInterpolationf(
+ pInfo->mTranslationX = J2DGetKeyFrameInterpolation<f32>(
param_0, &xInf->mTranslateInfo, &mTranslationValues[xInf->mTranslateInfo.mOffset]);
}
switch (yInf->mTranslateInfo.mMaxFrame) {
@@ -500,7 +556,7 @@ void J2DAnmTextureSRTKey::calcTransform(f32 param_0, u16 param_1, J3DTextureSRTI
pInfo->mTranslationY = mTranslationValues[yInf->mTranslateInfo.mOffset];
break;
default:
- pInfo->mTranslationY = J2DGetKeyFrameInterpolationf(
+ pInfo->mTranslationY = J2DGetKeyFrameInterpolation<f32>(
param_0, &yInf->mTranslateInfo, &mTranslationValues[yInf->mTranslateInfo.mOffset]);
}
}
@@ -533,7 +589,7 @@ void J2DAnmTexPattern::searchUpdateMaterialID(J2DScreen* pScreen) {
if (mTIMGPtrArray != NULL) {
JUTResReference resRef;
for (u16 i = 0; i < pScreen->mTexRes->mCount; i++) {
- s8* var1 = pScreen->mTexRes->getResReference(i);
+ char* var1 = pScreen->mTexRes->getResReference(i);
ResTIMG* var2 = NULL;
if (var1 != NULL) {
var2 = (ResTIMG*)resRef.getResource(var1, 'TIMG', NULL);
@@ -544,11 +600,13 @@ void J2DAnmTexPattern::searchUpdateMaterialID(J2DScreen* pScreen) {
}
mTIMGPtrArray[i].mRes = var2;
if (var2 != NULL && var2->indexTexture) {
- JUTPalette* palette =
- new JUTPalette(GX_TLUT0, (_GXTlutFmt)var2->colorFormat,
- (JUTTransparency)var2->alphaEnabled, var2->numColors,
- ((u8*)var2) + var2->paletteOffset);
- mTIMGPtrArray[i].mPalette = palette;
+ mTIMGPtrArray[i].mPalette = new JUTPalette(
+ GX_TLUT0,
+ GXTlutFmt(var2->colorFormat),
+ JUTTransparency(var2->alphaEnabled),
+ var2->numColors,
+ ((u8*)var2) + var2->paletteOffset
+ );
}
}
}
@@ -557,49 +615,56 @@ void J2DAnmTexPattern::searchUpdateMaterialID(J2DScreen* pScreen) {
void J2DAnmTexPattern::getTexNo(u16 param_0, u16* pTexNo) const {
u16 maxFrame = mAnmTable[param_0].mMaxFrame;
- f32 frame = getFrame();
- if (frame < 0) {
+ J3D_PANIC(1024, param_0 < mUpdateMaterialNum, "Error : range over.");
+ J3D_PANIC(1025, pTexNo, "Error : null pointer.");
+ if (mFrame < 0) {
*pTexNo = mValues[mAnmTable[param_0].mOffset];
- } else if (frame >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
*pTexNo = mValues[mAnmTable[param_0].mOffset + (maxFrame - 1)];
} else {
- *pTexNo = mValues[mAnmTable[param_0].mOffset + (int)frame];
+ *pTexNo = mValues[mAnmTable[param_0].mOffset + (int)mFrame];
}
}
ResTIMG* J2DAnmTexPattern::getResTIMG(u16 param_0) const {
if (mTIMGPtrArray == NULL) {
return NULL;
- } else {
- u16 texNo;
- this->getTexNo(param_0, &texNo);
- return mTIMGPtrArray[texNo].mRes;
}
+ u16 maxFrame = mAnmTable[param_0].mMaxFrame;
+ J3D_PANIC(1053, param_0 < mUpdateMaterialNum, "Error : range over.");
+
+ u16 texNo;
+ this->getTexNo(param_0, &texNo);
+ return mTIMGPtrArray[texNo].mRes;
}
JUTPalette* J2DAnmTexPattern::getPalette(u16 param_0) const {
if (mTIMGPtrArray == NULL) {
return NULL;
- } else {
- u16 texNo;
- this->getTexNo(param_0, &texNo);
- return mTIMGPtrArray[texNo].mPalette;
}
+ u16 maxFrame = mAnmTable[param_0].mMaxFrame;
+ J3D_PANIC(1076, param_0 < mUpdateMaterialNum, "Error : range over.");
+ u16 texNo;
+ this->getTexNo(param_0, &texNo);
+ return mTIMGPtrArray[texNo].mPalette;
}
void J2DAnmVisibilityFull::getVisibility(u16 param_0, u8* pOut) const {
u16 maxFrame = mTable[param_0]._0;
- if (getFrame() < 0) {
+ J3D_PANIC(1094, param_0 < field_0x10, "Error : range over.");
+ J3D_PANIC(1095, pOut, "Error : null pointer.");
+ if (mFrame < 0) {
*pOut = mValues[mTable[param_0]._2];
- } else if (getFrame() >= maxFrame) {
+ } else if (mFrame >= maxFrame) {
*pOut = mValues[mTable[param_0]._2 + (maxFrame - 1)];
} else {
- int frame = getFrame();
- *pOut = mValues[mTable[param_0]._2 + frame];
+ *pOut = mValues[mTable[param_0]._2 + (int)mFrame];
}
}
-void J2DAnmTevRegKey::getTevColorReg(u16 param_0, _GXColorS10* pColor) const {
+void J2DAnmTevRegKey::getTevColorReg(u16 param_0, GXColorS10* pColor) const {
+ J3D_PANIC(1116, param_0 < mCRegUpdateMaterialNum, "Error : range over.");
+ J3D_PANIC(1117, pColor, "Error : null pointer.");
J3DAnmCRegKeyTable* info = &mAnmCRegKeyTable[param_0];
f32 val;
switch (info->mRTable.mMaxFrame) {
@@ -610,7 +675,7 @@ void J2DAnmTevRegKey::getTevColorReg(u16 param_0, _GXColorS10* pColor) const {
pColor->r = mCRValues[info->mRTable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mRTable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRTable,
&mCRValues[info->mRTable.mOffset]);
if (val < -0x400) {
pColor->r = -0x400;
@@ -628,7 +693,7 @@ void J2DAnmTevRegKey::getTevColorReg(u16 param_0, _GXColorS10* pColor) const {
pColor->g = mCGValues[info->mGTable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mGTable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGTable,
&mCGValues[info->mGTable.mOffset]);
if (val < -0x400) {
pColor->g = -0x400;
@@ -646,7 +711,7 @@ void J2DAnmTevRegKey::getTevColorReg(u16 param_0, _GXColorS10* pColor) const {
pColor->b = mCBValues[info->mBTable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mBTable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBTable,
&mCBValues[info->mBTable.mOffset]);
if (val < -0x400) {
pColor->b = -0x400;
@@ -664,7 +729,7 @@ void J2DAnmTevRegKey::getTevColorReg(u16 param_0, _GXColorS10* pColor) const {
pColor->a = mCAValues[info->mATable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mATable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mATable,
&mCAValues[info->mATable.mOffset]);
if (val < -0x400) {
pColor->a = -0x400;
@@ -676,7 +741,9 @@ void J2DAnmTevRegKey::getTevColorReg(u16 param_0, _GXColorS10* pColor) const {
}
}
-void J2DAnmTevRegKey::getTevKonstReg(u16 param_0, _GXColor* pColor) const {
+void J2DAnmTevRegKey::getTevKonstReg(u16 param_0, GXColor* pColor) const {
+ J3D_PANIC(1222, param_0 < mKRegUpdateMaterialNum, "Error : range over.");
+ J3D_PANIC(1223, pColor, "Error : null pointer.");
J3DAnmKRegKeyTable* info = &mAnmKRegKeyTable[param_0];
f32 val;
switch (info->mRTable.mMaxFrame) {
@@ -687,7 +754,7 @@ void J2DAnmTevRegKey::getTevKonstReg(u16 param_0, _GXColor* pColor) const {
pColor->r = mKRValues[info->mRTable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mRTable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRTable,
&mKRValues[info->mRTable.mOffset]);
if (val < 0) {
pColor->r = 0;
@@ -705,7 +772,7 @@ void J2DAnmTevRegKey::getTevKonstReg(u16 param_0, _GXColor* pColor) const {
pColor->g = mKGValues[info->mGTable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mGTable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGTable,
&mKGValues[info->mGTable.mOffset]);
if (val < 0) {
pColor->g = 0;
@@ -723,7 +790,7 @@ void J2DAnmTevRegKey::getTevKonstReg(u16 param_0, _GXColor* pColor) const {
pColor->b = mKBValues[info->mBTable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mBTable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBTable,
&mKBValues[info->mBTable.mOffset]);
if (val < 0) {
pColor->b = 0;
@@ -741,7 +808,7 @@ void J2DAnmTevRegKey::getTevKonstReg(u16 param_0, _GXColor* pColor) const {
pColor->a = mKAValues[info->mATable.mOffset];
break;
default:
- val = J2DGetKeyFrameInterpolations(getFrame(), &info->mATable,
+ val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mATable,
&mKAValues[info->mATable.mOffset]);
if (val < 0) {
pColor->a = 0;
@@ -755,7 +822,7 @@ void J2DAnmTevRegKey::getTevKonstReg(u16 param_0, _GXColor* pColor) const {
void J2DAnmTevRegKey::searchUpdateMaterialID(J2DScreen* pScreen) {
if (pScreen != NULL && pScreen->mNameTable != NULL) {
- for (u16 i = 0; i < mCRegUpdateMaterialNum; i++) {
+ for (u16 i = 0; i < getCRegUpdateMaterialNum(); i++) {
s32 idx = pScreen->mNameTable->getIndex(mCRegNameTab.getName(i));
if (idx != -1) {
mCRegUpdateMaterialID[i] = idx;
@@ -763,7 +830,7 @@ void J2DAnmTevRegKey::searchUpdateMaterialID(J2DScreen* pScreen) {
mCRegUpdateMaterialID[i] = 0xFFFF;
}
}
- for (u16 i = 0; i < mKRegUpdateMaterialNum; i++) {
+ for (u16 i = 0; i < getKRegUpdateMaterialNum(); i++) {
s32 idx = pScreen->mNameTable->getIndex(mKRegNameTab.getName(i));
if (idx != -1) {
mKRegUpdateMaterialID[i] = idx;
@@ -773,106 +840,3 @@ void J2DAnmTevRegKey::searchUpdateMaterialID(J2DScreen* pScreen) {
}
}
}
-
-// should be J2DGetKeyFrameInterpolation<s16>
-f32 J2DGetKeyFrameInterpolations(f32 param_0, J3DAnmKeyTableBase* param_1, s16* param_2) {
- if (param_0 < param_2[0]) {
- return param_2[1];
- } else {
- if (param_1->mType == 0) {
- if (param_2[(param_1->mMaxFrame - 1) * 3] <= param_0) {
- return param_2[(param_1->mMaxFrame - 1) * 3 + 1];
- } else {
- u32 tmp = param_1->mMaxFrame;
- while (tmp > 1) {
- u32 halfTmp = tmp / 2;
- u32 upIdx = halfTmp * 3;
- if (param_0 >= param_2[upIdx]) {
- param_2 = param_2 + upIdx;
- tmp -= halfTmp;
- } else {
- tmp = halfTmp;
- }
- }
- return J2DHermiteInterpolation<s16>(param_0, &param_2[0], &param_2[1], &param_2[2],
- &param_2[3], &param_2[4], &param_2[5]);
- }
- } else {
- if (param_2[(param_1->mMaxFrame - 1) * 4] <= param_0) {
- return param_2[(param_1->mMaxFrame - 1) * 4 + 1];
- } else {
- u32 tmp = param_1->mMaxFrame;
- while (tmp > 1) {
- u32 halfTmp = tmp / 2;
- u32 upIdx = halfTmp * 4;
- if (param_0 >= param_2[upIdx]) {
- param_2 = param_2 + upIdx;
- tmp -= halfTmp;
- } else {
- tmp = halfTmp;
- }
- }
- return J2DHermiteInterpolation<s16>(param_0, &param_2[0], &param_2[1], &param_2[3],
- &param_2[4], &param_2[5], &param_2[6]);
- }
- }
- }
-}
-
-// should be J2DGetKeyFrameInterpolation<s16>
-f32 J2DGetKeyFrameInterpolationf(f32 param_0, J3DAnmKeyTableBase* param_1, f32* param_2) {
- if (param_0 < param_2[0]) {
- return param_2[1];
- } else {
- if (param_1->mType == 0) {
- if (param_2[(param_1->mMaxFrame - 1) * 3] <= param_0) {
- return param_2[(param_1->mMaxFrame - 1) * 3 + 1];
- } else {
- u32 tmp = param_1->mMaxFrame;
- while (tmp > 1) {
- u32 halfTmp = tmp / 2;
- u32 upIdx = halfTmp * 3;
- if (param_0 >= param_2[upIdx]) {
- param_2 = param_2 + upIdx;
- tmp -= halfTmp;
- } else {
- tmp = halfTmp;
- }
- }
- return J2DHermiteInterpolation<f32>(param_0, &param_2[0], &param_2[1], &param_2[2],
- &param_2[3], &param_2[4], &param_2[5]);
- }
- } else {
- if (param_2[(param_1->mMaxFrame - 1) * 4] <= param_0) {
- return param_2[(param_1->mMaxFrame - 1) * 4 + 1];
- } else {
- u32 tmp = param_1->mMaxFrame;
- while (tmp > 1) {
- u32 halfTmp = tmp / 2;
- u32 upIdx = halfTmp * 4;
- if (param_0 >= param_2[upIdx]) {
- param_2 = param_2 + upIdx;
- tmp -= halfTmp;
- } else {
- tmp = halfTmp;
- }
- }
- return J2DHermiteInterpolation<f32>(param_0, &param_2[0], &param_2[1], &param_2[3],
- &param_2[4], &param_2[5], &param_2[6]);
- }
- }
- }
-}
-
-J2DAnmTexPattern::J2DAnmTexPatternTIMGPointer::J2DAnmTexPatternTIMGPointer() {
- mRes = NULL;
- mPalette = NULL;
-}
-
-J2DAnmTexPattern::J2DAnmTexPatternTIMGPointer::~J2DAnmTexPatternTIMGPointer() {
- delete mPalette;
-}
-
-static void dummyDelete(J2DAnmTexPattern* pattern) {
- delete pattern;
-}
diff --git a/src/JSystem/J2DGraph/J2DAnmLoader.cpp b/src/JSystem/J2DGraph/J2DAnmLoader.cpp
index 4e6f6b065e..9dda6c1f9b 100644
--- a/src/JSystem/J2DGraph/J2DAnmLoader.cpp
+++ b/src/JSystem/J2DGraph/J2DAnmLoader.cpp
@@ -9,8 +9,9 @@
J2DAnmBase* J2DAnmLoaderDataBase::load(void const* p_data) {
const J3DAnmDataHeader* hdr = (const J3DAnmDataHeader*)p_data;
+ J3D_PANIC(38, p_data, "Error : null pointer.");
- if (hdr == NULL) {
+ if (p_data == NULL) {
return NULL;
} else if (hdr->mMagic == 'J3D1') {
switch (hdr->mType) {
@@ -27,6 +28,7 @@ J2DAnmBase* J2DAnmLoaderDataBase::load(void const* p_data) {
break;
}
case 'blk1':
+ OS_REPORT("J2DAnmLoader: this is a J3D Binary that cannot use J2D.\n");
return NULL;
case 'btk1': {
J2DAnmKeyLoader_v15 loader;
@@ -70,24 +72,32 @@ J2DAnmBase* J2DAnmLoaderDataBase::load(void const* p_data) {
break;
}
case 'bla1':
+ OS_REPORT("J2DAnmLoader: this is a J3D Binary that cannot use J2D.\n");
return NULL;
case 'bxa1': {
J2DAnmFullLoader_v15 loader;
loader.mpResource = new J2DAnmVtxColorFull();
return (J2DAnmBase*)loader.load(p_data);
}
+ default:
+ OS_REPORT("J2DAnmLoader: this is not a J3D Binary.\n");
+ return NULL;
}
- return NULL;
} else {
return NULL;
}
}
+static void dummy() {
+ OS_REPORT("J3DAnmLoader: this is not a J3D Binary.\n");
+}
+
J2DAnmKeyLoader_v15::J2DAnmKeyLoader_v15() {}
J2DAnmKeyLoader_v15::~J2DAnmKeyLoader_v15() {}
void* J2DAnmKeyLoader_v15::load(void const* p_data) {
+ J3D_PANIC(317, p_data, "Error : null pointer.");
const J3DAnmDataHeader* hdr = (const J3DAnmDataHeader*)p_data;
const J3DAnmDataBlockHeader* dataPtr = &hdr->mFirst;
@@ -108,6 +118,9 @@ void* J2DAnmKeyLoader_v15::load(void const* p_data) {
case 'TRK1':
readAnmTevReg((J3DAnmTevRegKeyData*)dataPtr);
break;
+ default:
+ OS_REPORT("Unknown data block\n");
+ break;
}
dataPtr = (J3DAnmDataBlockHeader*)((s32)dataPtr + dataPtr->mNextOffset);
}
@@ -116,6 +129,7 @@ void* J2DAnmKeyLoader_v15::load(void const* p_data) {
}
void J2DAnmKeyLoader_v15::setResource(J2DAnmBase* p_anm, void const* p_data) {
+ J3D_PANIC(355, p_data, "Error : null pointer.");
const J3DAnmDataHeader* hdr = (const J3DAnmDataHeader*)p_data;
const J3DAnmDataBlockHeader* dataPtr = &hdr->mFirst;
@@ -147,17 +161,23 @@ void J2DAnmKeyLoader_v15::setResource(J2DAnmBase* p_anm, void const* p_data) {
setAnmVtxColor((J2DAnmVtxColorKey*)p_anm, (J3DAnmVtxColorKeyData*)dataPtr);
}
break;
+ default:
+ OS_REPORT("Unknown data block\n");
+ break;
}
dataPtr = (J3DAnmDataBlockHeader*)((s32)dataPtr + dataPtr->mNextOffset);
}
}
void J2DAnmKeyLoader_v15::readAnmTransform(J3DAnmTransformKeyData const* p_data) {
- setAnmTransform((J2DAnmTransformKey*)mpResource, p_data);
+ J2DAnmTransformKey* p_anm = (J2DAnmTransformKey*)mpResource;
+ setAnmTransform(p_anm, p_data);
}
void J2DAnmKeyLoader_v15::setAnmTransform(J2DAnmTransformKey* p_anm,
J3DAnmTransformKeyData const* p_data) {
+ J3D_PANIC(439, p_anm, "Error : null pointer.");
+ J3D_PANIC(440, p_data, "Error : null pointer.");
p_anm->field_0x22 = p_data->field_0xc;
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
@@ -172,11 +192,14 @@ void J2DAnmKeyLoader_v15::setAnmTransform(J2DAnmTransformKey* p_anm,
}
void J2DAnmKeyLoader_v15::readAnmTextureSRT(J3DAnmTextureSRTKeyData const* p_data) {
- setAnmTextureSRT((J2DAnmTextureSRTKey*)mpResource, p_data);
+ J2DAnmTextureSRTKey* p_anm = (J2DAnmTextureSRTKey*)mpResource;
+ setAnmTextureSRT(p_anm, p_data);
}
void J2DAnmKeyLoader_v15::setAnmTextureSRT(J2DAnmTextureSRTKey* p_anm,
J3DAnmTextureSRTKeyData const* p_data) {
+ J3D_PANIC(480, p_anm, "Error : null pointer.");
+ J3D_PANIC(481, p_data, "Error : null pointer.");
p_anm->mUpdateMaterialNum = p_data->field_0xc;
p_anm->mFrameMax = p_data->field_0xa;
p_anm->field_0x4 = p_data->field_0x8;
@@ -226,10 +249,13 @@ void J2DAnmKeyLoader_v15::setAnmTextureSRT(J2DAnmTextureSRTKey* p_anm,
}
void J2DAnmKeyLoader_v15::readAnmColor(J3DAnmColorKeyData const* p_data) {
- setAnmColor((J2DAnmColorKey*)mpResource, p_data);
+ J2DAnmColorKey* p_anm = (J2DAnmColorKey*)mpResource;
+ setAnmColor(p_anm, p_data);
}
void J2DAnmKeyLoader_v15::setAnmColor(J2DAnmColorKey* p_anm, J3DAnmColorKeyData const* p_data) {
+ J3D_PANIC(573, p_anm, "Error : null pointer.");
+ J3D_PANIC(574, p_data, "Error : null pointer.");
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
p_anm->mFrame = 0;
@@ -251,11 +277,14 @@ void J2DAnmKeyLoader_v15::setAnmColor(J2DAnmColorKey* p_anm, J3DAnmColorKeyData
}
void J2DAnmKeyLoader_v15::readAnmVtxColor(J3DAnmVtxColorKeyData const* p_data) {
- setAnmVtxColor((J2DAnmVtxColorKey*)mpResource, p_data);
+ J2DAnmVtxColorKey* p_anm = (J2DAnmVtxColorKey*)mpResource;
+ setAnmVtxColor(p_anm, p_data);
}
void J2DAnmKeyLoader_v15::setAnmVtxColor(J2DAnmVtxColorKey* p_anm,
J3DAnmVtxColorKeyData const* p_data) {
+ J3D_PANIC(628, p_anm, "Error : null pointer.");
+ J3D_PANIC(629, p_data, "Error : null pointer.");
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
p_anm->mFrame = 0;
@@ -280,6 +309,7 @@ void J2DAnmKeyLoader_v15::setAnmVtxColor(J2DAnmVtxColorKey* p_anm,
}
void* J2DAnmFullLoader_v15::load(void const* p_data) {
+ J3D_PANIC(670, p_data, "Error : null pointer.");
const J3DAnmDataHeader* hdr = (const J3DAnmDataHeader*)p_data;
const J3DAnmDataBlockHeader* dataPtr = &hdr->mFirst;
@@ -300,6 +330,9 @@ void* J2DAnmFullLoader_v15::load(void const* p_data) {
case 'VCF1':
readAnmVtxColor((J3DAnmVtxColorFullData*)dataPtr);
break;
+ default:
+ OS_REPORT("Unknown data block\n");
+ break;
}
dataPtr = (J3DAnmDataBlockHeader*)((s32)dataPtr + dataPtr->mNextOffset);
}
@@ -307,6 +340,7 @@ void* J2DAnmFullLoader_v15::load(void const* p_data) {
}
void J2DAnmFullLoader_v15::setResource(J2DAnmBase* p_anm, void const* p_data) {
+ J3D_PANIC(710, p_data, "Error : null pointer.");
const J3DAnmDataHeader* hdr = (const J3DAnmDataHeader*)p_data;
const J3DAnmDataBlockHeader* dataPtr = &hdr->mFirst;
@@ -334,6 +368,9 @@ void J2DAnmFullLoader_v15::setResource(J2DAnmBase* p_anm, void const* p_data) {
if (p_anm->getKind() == KIND_VTX_COLOR)
setAnmVtxColor((J2DAnmVtxColorFull*)p_anm, (J3DAnmVtxColorFullData*)dataPtr);
break;
+ default:
+ OS_REPORT("Unknown data block\n");
+ break;
}
dataPtr = (J3DAnmDataBlockHeader*)((s32)dataPtr + dataPtr->mNextOffset);
}
@@ -344,11 +381,14 @@ J2DAnmFullLoader_v15::J2DAnmFullLoader_v15() {}
J2DAnmFullLoader_v15::~J2DAnmFullLoader_v15() {}
void J2DAnmFullLoader_v15::readAnmTransform(J3DAnmTransformFullData const* p_data) {
- setAnmTransform((J2DAnmTransformFull*)mpResource, p_data);
+ J2DAnmTransformFull* p_anm = (J2DAnmTransformFull*)mpResource;
+ setAnmTransform(p_anm, p_data);
}
void J2DAnmFullLoader_v15::setAnmTransform(J2DAnmTransformFull* p_anm,
J3DAnmTransformFullData const* p_data) {
+ J3D_PANIC(813, p_anm, "Error : null pointer.");
+ J3D_PANIC(814, p_data, "Error : null pointer.");
p_anm->field_0x22 = p_data->field_0xc;
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
@@ -361,10 +401,13 @@ void J2DAnmFullLoader_v15::setAnmTransform(J2DAnmTransformFull* p_anm,
}
void J2DAnmFullLoader_v15::readAnmColor(J3DAnmColorFullData const* p_data) {
- setAnmColor((J2DAnmColorFull*)mpResource, p_data);
+ J2DAnmColorFull* p_anm = (J2DAnmColorFull*)mpResource;
+ setAnmColor(p_anm, p_data);
}
void J2DAnmFullLoader_v15::setAnmColor(J2DAnmColorFull* p_anm, J3DAnmColorFullData const* p_data) {
+ J3D_PANIC(857, p_anm, "Error : null pointer.");
+ J3D_PANIC(858, p_data, "Error : null pointer.");
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
p_anm->mFrame = 0;
@@ -382,11 +425,14 @@ void J2DAnmFullLoader_v15::setAnmColor(J2DAnmColorFull* p_anm, J3DAnmColorFullDa
}
void J2DAnmFullLoader_v15::readAnmTexPattern(J3DAnmTexPatternFullData const* p_data) {
- setAnmTexPattern((J2DAnmTexPattern*)mpResource, p_data);
+ J2DAnmTexPattern* p_anm = (J2DAnmTexPattern*)mpResource;
+ setAnmTexPattern(p_anm, p_data);
}
void J2DAnmFullLoader_v15::setAnmTexPattern(J2DAnmTexPattern* p_anm,
J3DAnmTexPatternFullData const* p_data) {
+ J3D_PANIC(906, p_anm, "Error : null pointer.");
+ J3D_PANIC(907, p_data, "Error : null pointer.");
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
p_anm->mFrame = 0;
@@ -402,10 +448,13 @@ void J2DAnmFullLoader_v15::setAnmTexPattern(J2DAnmTexPattern* p_anm,
}
void J2DAnmKeyLoader_v15::readAnmTevReg(J3DAnmTevRegKeyData const* p_data) {
- setAnmTevReg((J2DAnmTevRegKey*)mpResource, p_data);
+ J2DAnmTevRegKey* p_anm = (J2DAnmTevRegKey*)mpResource;
+ setAnmTevReg(p_anm, p_data);
}
void J2DAnmKeyLoader_v15::setAnmTevReg(J2DAnmTevRegKey* p_anm, J3DAnmTevRegKeyData const* p_data) {
+ J3D_PANIC(955, p_anm, "Error : null pointer.");
+ J3D_PANIC(956, p_data, "Error : null pointer.");
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
p_anm->mFrame = 0;
@@ -442,11 +491,14 @@ void J2DAnmKeyLoader_v15::setAnmTevReg(J2DAnmTevRegKey* p_anm, J3DAnmTevRegKeyDa
}
void J2DAnmFullLoader_v15::readAnmVisibility(J3DAnmVisibilityFullData const* p_data) {
- setAnmVisibility((J2DAnmVisibilityFull*)mpResource, p_data);
+ J2DAnmVisibilityFull* p_anm = (J2DAnmVisibilityFull*)mpResource;
+ setAnmVisibility(p_anm, p_data);
}
void J2DAnmFullLoader_v15::setAnmVisibility(J2DAnmVisibilityFull* p_anm,
J3DAnmVisibilityFullData const* p_data) {
+ J3D_PANIC(1025, p_anm, "Error : null pointer.");
+ J3D_PANIC(1026, p_data, "Error : null pointer.");
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
p_anm->mFrame = 0;
@@ -458,11 +510,14 @@ void J2DAnmFullLoader_v15::setAnmVisibility(J2DAnmVisibilityFull* p_anm,
}
void J2DAnmFullLoader_v15::readAnmVtxColor(J3DAnmVtxColorFullData const* p_data) {
- setAnmVtxColor((J2DAnmVtxColorFull*)mpResource, p_data);
+ J2DAnmVtxColorFull* p_anm = (J2DAnmVtxColorFull*)mpResource;
+ setAnmVtxColor(p_anm, p_data);
}
void J2DAnmFullLoader_v15::setAnmVtxColor(J2DAnmVtxColorFull* p_anm,
J3DAnmVtxColorFullData const* p_data) {
+ J3D_PANIC(1070, p_anm, "Error : null pointer.");
+ J3D_PANIC(1071, p_data, "Error : null pointer.");
p_anm->mFrameMax = p_data->mFrameMax;
p_anm->field_0x4 = p_data->field_0x8;
p_anm->mFrame = 0;
diff --git a/src/JSystem/J2DGraph/J2DManage.cpp b/src/JSystem/J2DGraph/J2DManage.cpp
index 10758a8268..19a04db031 100644
--- a/src/JSystem/J2DGraph/J2DManage.cpp
+++ b/src/JSystem/J2DGraph/J2DManage.cpp
@@ -5,7 +5,8 @@
#include <string>
void* J2DDataManage::get(char const* name) {
- for (J2DataManageLink* link = mList; link != NULL; link = link->mNext) {
+ J2DataManageLink* link;
+ for (link = mList; link != NULL; link = link->mNext) {
if (strcmp(link->mName, name) == 0) {
return link->mData;
}
@@ -19,26 +20,26 @@ void* J2DDataManage::get(JSUInputStream* inputStream) {
if (nameLen == 0) {
return NULL;
- } else {
- char nameBuffer[257];
- inputStream->read(&nameBuffer, nameLen);
- nameBuffer[nameLen] = 0;
- return this->get(nameBuffer);
}
+
+ char nameBuffer[257];
+ inputStream->read(&nameBuffer, nameLen);
+ nameBuffer[nameLen] = 0;
+ return this->get(nameBuffer);
}
-s8* J2DResReference::getResReference(u16 idx) const {
+char* J2DResReference::getResReference(u16 idx) const {
if (mCount <= idx || idx == 0xFFFF) {
return NULL;
- } else {
- return (((s8*)this) + mOffsets[idx]);
}
+ u16 offset = mOffsets[idx];
+ return ((char*)this) + offset;
}
char* J2DResReference::getName(u16 idx) const {
static char p_name[257];
- s8* resRef = this->getResReference(idx);
+ char* resRef = (char*)this->getResReference(idx);
if (resRef == NULL) {
p_name[0] = 0;
diff --git a/src/JSystem/J2DGraph/J2DMatBlock.cpp b/src/JSystem/J2DGraph/J2DMatBlock.cpp
index b7e34c8338..f8f530924a 100644
--- a/src/JSystem/J2DGraph/J2DMatBlock.cpp
+++ b/src/JSystem/J2DGraph/J2DMatBlock.cpp
@@ -76,11 +76,13 @@ void J2DTexGenBlock::setTexMtx(u32 param_0, J2DTexMtx& param_1) {
void J2DTexGenBlock::getTexMtx(u32 param_0, J2DTexMtx& param_1) {
J3D_PANIC(123, param_0 < 8, "Error : range over.");
-
- if (mTexMtx[param_0]) {
- J2DTexMtxInfo& texMtxInfo = mTexMtx[param_0]->getTexMtxInfo();
- param_1.setTexMtxInfo(texMtxInfo);
+
+ if (!mTexMtx[param_0]) {
+ return;
}
+
+ J2DTexMtxInfo& texMtxInfo = mTexMtx[param_0]->getTexMtxInfo();
+ param_1.setTexMtxInfo(texMtxInfo);
}
JUTTexture* J2DTevBlock::getTexture(u32) {
@@ -349,6 +351,7 @@ void J2DTevBlock1::shiftDeleteFlag(u8, bool) {
void J2DTevBlock1::setGX() {
loadTexture(GX_TEXMAP0, 0);
+ (void)bool(mFont);
GXSetTevOrder(GX_TEVSTAGE0, (GXTexCoordID)mTevOrder[0].getTexCoord(), (GXTexMapID)mTevOrder[0].getTexMap(), (GXChannelID)mTevOrder[0].getColor());
for (int i = 0; i < 4; i++) {
@@ -366,10 +369,10 @@ void J2DTevBlock1::setGX() {
GXTevAlphaArg(mTevStage[0].getAlphaD()));
GXSetTevColorOp(GX_TEVSTAGE0, GXTevOp(mTevStage[0].getCOp()),
GXTevBias(mTevStage[0].getCBias()), GXTevScale(mTevStage[0].getCScale()),
- mTevStage[0].getCClamp(), GXTevRegID(mTevStage[0].getCReg()));
+ GXBool(mTevStage[0].getCClamp()), GXTevRegID(mTevStage[0].getCReg()));
GXSetTevAlphaOp(GX_TEVSTAGE0, (GXTevOp)mTevStage[0].getAOp(),
GXTevBias(mTevStage[0].getABias()), GXTevScale(mTevStage[0].getAScale()),
- mTevStage[0].getAClamp(), GXTevRegID(mTevStage[0].getAReg()));
+ GXBool(mTevStage[0].getAClamp()), GXTevRegID(mTevStage[0].getAReg()));
GXSetTevKColorSel(GX_TEVSTAGE0, mTevKColorSel[0] != 0xff ? GXTevKColorSel(mTevKColorSel[0]) : GX_TEV_KCSEL_1);
GXSetTevKAlphaSel(GX_TEVSTAGE0, mTevKAlphaSel[0] != 0xff ? GXTevKAlphaSel(mTevKAlphaSel[0]) : GX_TEV_KASEL_1);
for (int i = 0; i < 4; i++) {
@@ -483,28 +486,27 @@ bool J2DTevBlock2::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette*
return false;
}
- JUTTexture* tex;
u8 tlutid = 0;
- if (p_timg->indexTexture && p_tlut == NULL) {
- tex = mTexture[0];
- if (tex != NULL && tex->getTexInfo() != NULL && tex->getTexInfo()->indexTexture) {
- int tlutname = tex->getTlutName();
+ if (p_timg->indexTexture && p_tlut == NULL && mTexture[0] != NULL) {
+ const ResTIMG* timg = mTexture[0]->getTexInfo();
+ if (timg != NULL && timg->indexTexture) {
+ int tlutname = mTexture[0]->getTlutName();
if (tlutname == GX_TLUT0 || tlutname == GX_BIGTLUT0) {
tlutid = 1;
}
}
}
- tex = mTexture[texNo];
- if (tex == NULL) {
- JUTTexture* newtex = new JUTTexture(p_timg, tlutid);
+ JUTTexture* tex;
+ if (mTexture[texNo] == NULL) {
+ tex = new JUTTexture(p_timg, tlutid);
- if (newtex == NULL) {
+ if (tex == NULL) {
return false;
}
if (p_tlut != NULL) {
- newtex->storeTIMG(p_timg, p_tlut);
+ tex->storeTIMG(p_timg, p_tlut);
}
if (param_0 == 0) {
@@ -512,10 +514,11 @@ bool J2DTevBlock2::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette*
mPalette[1] = mPalette[0];
mTexNo[1] = mTexNo[0];
}
- mTexture[param_0] = newtex;
+ mTexture[param_0] = tex;
shiftDeleteFlag(param_0, true);
mUndeleteFlag |= (1 << param_0);
} else {
+ tex = mTexture[texNo];
if (p_tlut == NULL) {
tex->storeTIMG(p_timg, tlutid);
} else {
@@ -604,9 +607,8 @@ bool J2DTevBlock2::setTexture(u32 param_0, ResTIMG const* p_timg) {
const ResTIMG* timg = mTexture[idx]->getTexInfo();
if (timg != NULL && timg->indexTexture) {
int tlutname = mTexture[idx]->getTlutName();
- u8 tlut_no = tlutname - (tlutname >= GX_BIGTLUT0 ? GX_BIGTLUT0 : GX_TLUT0);
- if (tlut_no == 0) {
+ if (u8(tlutname - (tlutname >= GX_BIGTLUT0 ? GX_BIGTLUT0 : GX_TLUT0)) == 0) {
tlutid = 1;
}
}
@@ -763,7 +765,7 @@ void J2DTevBlock2::shiftDeleteFlag(u8 param_0, bool param_1) {
mUndeleteFlag = (mUndeleteFlag & ((1 << param_0) - 1)) | ((mUndeleteFlag & ~((1 << (param_0 + 1)) - 1)) >> 1);
}
- mUndeleteFlag = (mUndeleteFlag | tmpFlags) & 0xFF;
+ mUndeleteFlag = u8(mUndeleteFlag | tmpFlags);
}
void J2DTevBlock2::setGX() {
@@ -771,6 +773,8 @@ void J2DTevBlock2::setGX() {
loadTexture(GXTexMapID(i), i);
}
+ (void)bool(mFont);
+
for (int i = 0; i < mTevStageNum; i++) {
GXSetTevOrder(GXTevStageID(i), (GXTexCoordID)mTevOrder[i].getTexCoord(), (GXTexMapID)mTevOrder[i].getTexMap(), (GXChannelID)mTevOrder[i].getColor());
}
@@ -791,10 +795,10 @@ void J2DTevBlock2::setGX() {
GXTevAlphaArg(mTevStage[i].getAlphaD()));
GXSetTevColorOp(GXTevStageID(i), GXTevOp(mTevStage[i].getCOp()),
GXTevBias(mTevStage[i].getCBias()), GXTevScale(mTevStage[i].getCScale()),
- mTevStage[i].getCClamp(), GXTevRegID(mTevStage[i].getCReg()));
+ GXBool(mTevStage[i].getCClamp()), GXTevRegID(mTevStage[i].getCReg()));
GXSetTevAlphaOp(GXTevStageID(i), (GXTevOp)mTevStage[i].getAOp(),
GXTevBias(mTevStage[i].getABias()), GXTevScale(mTevStage[i].getAScale()),
- mTevStage[i].getAClamp(), GXTevRegID(mTevStage[i].getAReg()));
+ GXBool(mTevStage[i].getAClamp()), GXTevRegID(mTevStage[i].getAReg()));
GXSetTevKColorSel(GXTevStageID(i), mTevKColorSel[i] != 0xff ? GXTevKColorSel(mTevKColorSel[i]) : GX_TEV_KCSEL_1);
GXSetTevKAlphaSel(GXTevStageID(i), mTevKAlphaSel[i] != 0xff ? GXTevKAlphaSel(mTevKAlphaSel[i]) : GX_TEV_KASEL_1);
}
@@ -943,8 +947,9 @@ bool J2DTevBlock4::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette*
}
}
}
+ JUTTexture* texture;
if (!mTexture[idx]) {
- JUTTexture* texture = new JUTTexture(p_timg, local_43);
+ texture = new JUTTexture(p_timg, local_43);
if (!texture) {
return false;
}
@@ -960,7 +965,7 @@ bool J2DTevBlock4::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette*
shiftDeleteFlag(param_0, true);
mUndeleteFlag |= 1 << param_0;
} else {
- JUTTexture* texture = mTexture[idx];
+ texture = mTexture[idx];
if (!p_tlut) {
texture->storeTIMG(p_timg, local_43);
} else {
@@ -1037,10 +1042,9 @@ bool J2DTevBlock4::setTexture(u32 param_0, ResTIMG const* p_timg) {
return false;
}
- u8 used_tlut;
u8 tlutid = 0;
if (p_timg != NULL && p_timg->indexTexture) {
- used_tlut = 0;
+ u8 used_tlut = 0;
for (int i = 0; i < 4; i++) {
if (i != param_0 && mTexture[i] != NULL) {
const ResTIMG* timg = mTexture[i]->getTexInfo();
@@ -1213,13 +1217,14 @@ void J2DTevBlock4::shiftDeleteFlag(u8 param_0, bool param_1) {
mUndeleteFlag = (mUndeleteFlag & ((1 << param_0) - 1)) | ((mUndeleteFlag & ~((1 << (param_0 + 1)) - 1)) >> 1);
}
- mUndeleteFlag |= tmpFlags;
+ mUndeleteFlag = u8(mUndeleteFlag | tmpFlags);
}
void J2DTevBlock4::setGX() {
for (int i = 0; i < 4; i++) {
loadTexture(GXTexMapID(i), i);
}
+ (void)bool(mFont);
for (int i = 0; i < mTevStageNum; i++) {
GXSetTevOrder(GXTevStageID(i), (GXTexCoordID)mTevOrder[i].getTexCoord(), (GXTexMapID)mTevOrder[i].getTexMap(), (GXChannelID)mTevOrder[i].getColor());
}
@@ -1238,10 +1243,10 @@ void J2DTevBlock4::setGX() {
GXTevAlphaArg(mTevStage[i].getAlphaD()));
GXSetTevColorOp(GXTevStageID(i), GXTevOp(mTevStage[i].getCOp()),
GXTevBias(mTevStage[i].getCBias()), GXTevScale(mTevStage[i].getCScale()),
- mTevStage[i].getCClamp(), GXTevRegID(mTevStage[i].getCReg()));
+ GXBool(mTevStage[i].getCClamp()), GXTevRegID(mTevStage[i].getCReg()));
GXSetTevAlphaOp(GXTevStageID(i), (GXTevOp)mTevStage[i].getAOp(),
GXTevBias(mTevStage[i].getABias()), GXTevScale(mTevStage[i].getAScale()),
- mTevStage[i].getAClamp(), GXTevRegID(mTevStage[i].getAReg()));
+ GXBool(mTevStage[i].getAClamp()), GXTevRegID(mTevStage[i].getAReg()));
GXSetTevKColorSel(GXTevStageID(i), mTevKColorSel[i] != 0xff ? GXTevKColorSel(mTevKColorSel[i]) : GX_TEV_KCSEL_1);
GXSetTevKAlphaSel(GXTevStageID(i), mTevKAlphaSel[i] != 0xff ? GXTevKAlphaSel(mTevKAlphaSel[i]) : GX_TEV_KASEL_1);
}
@@ -1387,8 +1392,9 @@ bool J2DTevBlock8::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette*
}
}
}
+ JUTTexture* texture;
if (!mTexture[idx]) {
- JUTTexture* texture = new JUTTexture(p_timg, local_43);
+ texture = new JUTTexture(p_timg, local_43);
if (!texture) {
return false;
}
@@ -1404,7 +1410,7 @@ bool J2DTevBlock8::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette*
shiftDeleteFlag(param_0, true);
mUndeleteFlag |= 1 << param_0;
} else {
- JUTTexture* texture = mTexture[idx];
+ texture = mTexture[idx];
if (!p_tlut) {
texture->storeTIMG(p_timg, local_43);
} else {
@@ -1459,7 +1465,7 @@ bool J2DTevBlock8::insertTexture(u32 param_0, JUTTexture* p_tex) {
delete mTexture[7];
}
- mUndeleteFlag &= 0x7F;
+ mUndeleteFlag &= ~0x80;
}
for (u8 i = 7; i > param_0; i--) {
@@ -1481,10 +1487,9 @@ bool J2DTevBlock8::setTexture(u32 param_0, ResTIMG const* p_timg) {
return false;
}
- u8 used_tlut;
u8 tlutid = 0;
if (p_timg != NULL && p_timg->indexTexture) {
- used_tlut = 0;
+ u8 used_tlut = 0;
for (int i = 0; i < 8; i++) {
if (i != param_0 && mTexture[i] != NULL) {
const ResTIMG* timg = mTexture[i]->getTexInfo();
@@ -1659,6 +1664,7 @@ void J2DTevBlock8::setGX() {
for (int i = 0; i < 8; i++) {
loadTexture(GXTexMapID(i), i);
}
+ (void)bool(mFont);
for (int i = 0; i < mTevStageNum; i++) {
GXSetTevOrder(GXTevStageID(i), (GXTexCoordID)mTevOrder[i].getTexCoord(), (GXTexMapID)mTevOrder[i].getTexMap(), (GXChannelID)mTevOrder[i].getColor());
}
@@ -1677,10 +1683,10 @@ void J2DTevBlock8::setGX() {
GXTevAlphaArg(mTevStage[i].getAlphaD()));
GXSetTevColorOp(GXTevStageID(i), GXTevOp(mTevStage[i].getCOp()),
GXTevBias(mTevStage[i].getCBias()), GXTevScale(mTevStage[i].getCScale()),
- mTevStage[i].getCClamp(), GXTevRegID(mTevStage[i].getCReg()));
+ GXBool(mTevStage[i].getCClamp()), GXTevRegID(mTevStage[i].getCReg()));
GXSetTevAlphaOp(GXTevStageID(i), (GXTevOp)mTevStage[i].getAOp(),
GXTevBias(mTevStage[i].getABias()), GXTevScale(mTevStage[i].getAScale()),
- mTevStage[i].getAClamp(), GXTevRegID(mTevStage[i].getAReg()));
+ GXBool(mTevStage[i].getAClamp()), GXTevRegID(mTevStage[i].getAReg()));
GXSetTevKColorSel(GXTevStageID(i), mTevKColorSel[i] != 0xff ? GXTevKColorSel(mTevKColorSel[i]) : GX_TEV_KCSEL_1);
GXSetTevKAlphaSel(GXTevStageID(i), mTevKAlphaSel[i] != 0xff ? GXTevKAlphaSel(mTevKAlphaSel[i]) : GX_TEV_KASEL_1);
}
@@ -1826,8 +1832,9 @@ bool J2DTevBlock16::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette
}
}
}
+ JUTTexture* texture;
if (!mTexture[idx]) {
- JUTTexture* texture = new JUTTexture(p_timg, local_43);
+ texture = new JUTTexture(p_timg, local_43);
if (!texture) {
return false;
}
@@ -1843,7 +1850,7 @@ bool J2DTevBlock16::insertTexture(u32 param_0, ResTIMG const* p_timg, JUTPalette
shiftDeleteFlag(param_0, true);
mUndeleteFlag |= 1 << param_0;
} else {
- JUTTexture* texture = mTexture[idx];
+ texture = mTexture[idx];
if (!p_tlut) {
texture->storeTIMG(p_timg, local_43);
} else {
@@ -1898,7 +1905,7 @@ bool J2DTevBlock16::insertTexture(u32 param_0, JUTTexture* p_tex) {
delete mTexture[7];
}
- mUndeleteFlag &= 0x7F;
+ mUndeleteFlag &= ~0x80;
}
for (u8 i = 7; i > param_0; i--) {
@@ -1920,10 +1927,9 @@ bool J2DTevBlock16::setTexture(u32 param_0, ResTIMG const* p_timg) {
return false;
}
- u8 used_tlut;
u8 tlutid = 0;
if (p_timg != NULL && p_timg->indexTexture) {
- used_tlut = 0;
+ u8 used_tlut = 0;
for (int i = 0; i < 8; i++) {
if (i != param_0 && mTexture[i] != NULL) {
const ResTIMG* timg = mTexture[i]->getTexInfo();
@@ -2098,6 +2104,7 @@ void J2DTevBlock16::setGX() {
for (int i = 0; i < 8; i++) {
loadTexture(GXTexMapID(i), i);
}
+ (void)bool(mFont);
for (int i = 0; i < mTevStageNum; i++) {
GXSetTevOrder(GXTevStageID(i), (GXTexCoordID)mTevOrder[i].getTexCoord(), (GXTexMapID)mTevOrder[i].getTexMap(), (GXChannelID)mTevOrder[i].getColor());
}
@@ -2116,10 +2123,10 @@ void J2DTevBlock16::setGX() {
GXTevAlphaArg(mTevStage[i].getAlphaD()));
GXSetTevColorOp(GXTevStageID(i), GXTevOp(mTevStage[i].getCOp()),
GXTevBias(mTevStage[i].getCBias()), GXTevScale(mTevStage[i].getCScale()),
- mTevStage[i].getCClamp(), GXTevRegID(mTevStage[i].getCReg()));
+ GXBool(mTevStage[i].getCClamp()), GXTevRegID(mTevStage[i].getCReg()));
GXSetTevAlphaOp(GXTevStageID(i), (GXTevOp)mTevStage[i].getAOp(),
GXTevBias(mTevStage[i].getABias()), GXTevScale(mTevStage[i].getAScale()),
- mTevStage[i].getAClamp(), GXTevRegID(mTevStage[i].getAReg()));
+ GXBool(mTevStage[i].getAClamp()), GXTevRegID(mTevStage[i].getAReg()));
GXSetTevKColorSel(GXTevStageID(i), mTevKColorSel[i] != 0xff ? GXTevKColorSel(mTevKColorSel[i]) : GX_TEV_KCSEL_1);
GXSetTevKAlphaSel(GXTevStageID(i), mTevKAlphaSel[i] != 0xff ? GXTevKAlphaSel(mTevKAlphaSel[i]) : GX_TEV_KASEL_1);
}
@@ -2149,13 +2156,13 @@ void J2DTevBlock16::loadTexture(GXTexMapID texmapID, u32 texIndex) {
void J2DIndBlockFull::initialize() {
mIndTexStageNum = 0;
for (int i = 0; i < 4; i++) {
- mIndTexOrder[i] = j2dDefaultIndTexOrderNull;
+ mIndTexOrder[i].setIndTexOrderInfo(j2dDefaultIndTexOrderNull);
}
for (int i = 0; i < 3; i++) {
- mIndTexMtx[i] = j2dDefaultIndTexMtxInfo;
+ mIndTexMtx[i].setIndTexMtxInfo(j2dDefaultIndTexMtxInfo);
}
for (int i = 0; i < 4; i++) {
- mTexCoordScale[i] = j2dDefaultIndTexCoordScaleInfo;
+ mTexCoordScale[i].setIndTexCoordScaleInfo(j2dDefaultIndTexCoordScaleInfo);
}
}
@@ -2181,5 +2188,5 @@ void J2DPEBlock::initialize() {
void J2DPEBlock::setGX() {
GXSetAlphaCompare(GXCompare(mAlphaComp.getComp0()), mAlphaComp.getRef0(), GXAlphaOp(mAlphaComp.getOp()), GXCompare(mAlphaComp.getComp1()), mAlphaComp.getRef1());
GXSetBlendMode(GXBlendMode(mBlend.getType()), GXBlendFactor(mBlend.getSrcFactor()), GXBlendFactor(mBlend.getDstFactor()), GXLogicOp(mBlend.getOp()));
- GXSetDither(mDither);
+ GXSetDither(GXBool(mDither));
}
diff --git a/src/JSystem/J2DGraph/J2DMaterial.cpp b/src/JSystem/J2DGraph/J2DMaterial.cpp
index 4fadaf5ace..57cccf8255 100644
--- a/src/JSystem/J2DGraph/J2DMaterial.cpp
+++ b/src/JSystem/J2DGraph/J2DMaterial.cpp
@@ -67,9 +67,7 @@ J2DTevBlock* J2DMaterial::createTevBlock(int block_type, bool noAlign) {
block = new (-4) J2DTevBlock16();
}
}
- if (!block) {
- OS_PANIC(101, "Error : allocate memory.");
- }
+ ASSERTMSGLINE(101, block, "Error : allocate memory.");
return block;
}
@@ -90,9 +88,7 @@ J2DIndBlock* J2DMaterial::createIndBlock(int block_type, bool noAlign) {
block = new (-4) J2DIndBlockNull();
}
}
- if (!block) {
- OS_PANIC(133, "Error : allocate memory.");
- }
+ ASSERTMSGLINE(133, block, "Error : allocate memory.");
return block;
}
@@ -148,9 +144,7 @@ void J2DMaterial::setAnimation(J2DAnmColor* anm) {
u16 index = getIndex();
for (u16 i = 0; i < matNum; i++) {
- u16 matID = anm->getUpdateMaterialID(i);
-
- if (index == matID) {
+ if (index == anm->getUpdateMaterialID(i)) {
mAnmPointer->mColorIds = i;
return;
}
@@ -219,9 +213,7 @@ void J2DMaterial::setAnimation(J2DAnmTevRegKey* anm) {
u16 index = getIndex();
for (u16 i = 0; i < matNum; i++) {
- u16 matID = anm->getCRegUpdateMaterialID(i);
-
- if (index == matID) {
+ if (index == anm->getCRegUpdateMaterialID(i)) {
J3DAnmCRegKeyTable* anmTbl = anm->getAnmCRegKeyTable();
mAnmPointer->mTevCRegIds[anmTbl[i].mColorId] = i;
}
@@ -237,9 +229,7 @@ void J2DMaterial::setAnimation(J2DAnmTevRegKey* anm) {
u16 index = getIndex();
for (u16 i = 0; i < matNum; i++) {
- u16 matID = anm->getKRegUpdateMaterialID(i);
-
- if (index == matID) {
+ if (index == anm->getKRegUpdateMaterialID(i)) {
J3DAnmKRegKeyTable* anmTbl = anm->getAnmKRegKeyTable();
mAnmPointer->mTevKRegIds[anmTbl[i].mColorId] = i;
}
diff --git a/src/JSystem/J2DGraph/J2DMaterialFactory.cpp b/src/JSystem/J2DGraph/J2DMaterialFactory.cpp
index a4ef4b6672..55a8ca4c36 100644
--- a/src/JSystem/J2DGraph/J2DMaterialFactory.cpp
+++ b/src/JSystem/J2DGraph/J2DMaterialFactory.cpp
@@ -52,10 +52,7 @@ u32 J2DMaterialFactory::countStages(int param_0) const {
}
}
if ((uVar3 != uVar4 && uVar4 != 0)) {
- if (uVar3 > uVar4) {
- return uVar3;
- }
- return uVar4;
+ return uVar3 > uVar4 ? uVar3 : uVar4;
}
return uVar3;
}
@@ -64,16 +61,14 @@ J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 par
J2DResReference* param_3, J2DResReference* param_4,
JKRArchive* param_5) const {
u32 stages = countStages(index);
- u32 uVar1 = ((param_2 & 0x1f0000) >> 16);
- u32 r28 = stages > uVar1 ? stages : uVar1;
-
- u32 r25 = r28 <= 8 ? r28 : 8;
-
- s32 local_3bc = ((param_2 & 0x1000000) != 0);
- s32 local_3c0 = (param_2 & 0x1f0000) ? local_3bc : 0;
- bool temp = (param_2 & 0x1f0000);
- param_0->mTevBlock = J2DMaterial::createTevBlock((u16)r28, temp);
- param_0->mIndBlock = J2DMaterial::createIndBlock(local_3c0, temp);
+ u32 local_36c = ((param_2 & 0x1f0000) >> 16);
+ u32 local_370 = stages > local_36c ? stages : local_36c;
+ u32 local_374 = local_370 > 8 ? 8 : local_370;
+ s32 local_378 = (param_2 & 0x1000000) ? 1 : 0;
+ local_378 = (param_2 & 0x1f0000) ? local_378 : 0;
+ bool local_403 = (param_2 & 0x1f0000);
+ param_0->mTevBlock = J2DMaterial::createTevBlock((u16)local_370, local_403);
+ param_0->mIndBlock = J2DMaterial::createIndBlock(local_378, local_403);
param_0->mIndex = index;
param_0->field_0x8 = getMaterialMode(index);
param_0->getColorBlock()->setColorChanNum(newColorChanNum(index));
@@ -86,9 +81,9 @@ J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 par
param_0->mMaterialAlphaCalc = getMaterialAlphaCalc(index);
JUTResReference aJStack_12c;
- for (u8 i = 0; i < r25; i++) {
+ for (u8 i = 0; i < local_374; i++) {
u16 texNo = newTexNo(index, i);
- s8* local_37c = param_3->getResReference(texNo);
+ char* local_37c = param_3->getResReference(texNo);
void* local_380 = NULL;
if (local_37c != NULL) {
local_380 = aJStack_12c.getResource(local_37c, 'TIMG', param_5);
@@ -107,7 +102,7 @@ J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 par
u16 fontNo = newFontNo(index);
param_0->getTevBlock()->setFontNo(fontNo);
- s8* local_384 = param_4->getResReference(param_0->getTevBlock()->getFontNo());
+ char* local_384 = param_4->getResReference(param_0->getTevBlock()->getFontNo());
void* local_388 = NULL;
if (local_384 != NULL) {
local_388 = aJStack_12c.getResource(local_384, 'FONT', param_5);
@@ -122,10 +117,10 @@ J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 par
}
param_0->getTevBlock()->setFont((ResFONT*)local_388);
- for (u8 i = 0; i < r28; i++) {
+ for (u8 i = 0; i < local_370; i++) {
param_0->getTevBlock()->setTevOrder(i, newTevOrder(index, i));
}
- for (u8 i = 0; i < r28; i++) {
+ for (u8 i = 0; i < local_370; i++) {
J2DMaterialInitData* local_38c = &field_0x4[field_0x8[index]];
param_0->getTevBlock()->setTevStage(i, newTevStage(index, i));
if (local_38c->field_0xba[i] != 0xffff) {
@@ -157,13 +152,13 @@ J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 par
param_0->getTexGenBlock()->setTexMtx(i, newTexMtx(index, i));
}
J2DMaterialInitData* local_394 = &field_0x4[field_0x8[index]];
- for (u8 i = 0; i < r28; i++) {
+ for (u8 i = 0; i < local_370; i++) {
param_0->getTevBlock()->setTevKColorSel(i, local_394->field_0x52[i]);
}
- for (u8 i = 0; i < r28; i++) {
+ for (u8 i = 0; i < local_370; i++) {
param_0->getTevBlock()->setTevKAlphaSel(i, local_394->field_0x62[i]);
}
- if (field_0xc != NULL || local_3c0 != 0) {
+ if (field_0xc != NULL || local_378 != 0) {
u8 local_410 = newIndTexStageNum(index);
param_0->mIndBlock->setIndTexStageNum(local_410);
for (u8 i = 0; i < local_410; i++) {
@@ -175,7 +170,7 @@ J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 par
for (u8 i = 0; i < local_410; i++) {
param_0->getIndBlock()->setIndTexCoordScale(i, newIndTexCoordScale(index, i));
}
- for (u8 i = 0; i < r28; i++) {
+ for (u8 i = 0; i < local_370; i++) {
param_0->getTevBlock()->setIndTevStage(i, newIndTevStage(index, i));
}
}
@@ -183,8 +178,7 @@ J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 par
}
JUtility::TColor J2DMaterialFactory::newMatColor(int param_0, int param_1) const {
- GXColor color = {0xff,0xff,0xff,0xff};
- JUtility::TColor local_20 = GXColor(color);
+ JUtility::TColor local_20 = (GXColor){0xff,0xff,0xff,0xff};
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
if (iVar2->field_0x8[param_1] != 0xffff) {
return field_0x10[iVar2->field_0x8[param_1]];
@@ -201,6 +195,7 @@ u8 J2DMaterialFactory::newColorChanNum(int param_0) const {
}
J2DColorChan J2DMaterialFactory::newColorChan(int param_0, int param_1) const {
+ int r29 = 0;
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
if (iVar2->field_0xc[param_1] != 0xffff) {
return J2DColorChan(field_0x18[iVar2->field_0xc[param_1]]);
@@ -209,6 +204,7 @@ J2DColorChan J2DMaterialFactory::newColorChan(int param_0, int param_1) const {
}
u32 J2DMaterialFactory::newTexGenNum(int param_0) const {
+ int r30 = 0;
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
if (iVar2->field_0x3 != 0xff) {
return field_0x1c[iVar2->field_0x3];
@@ -235,6 +231,7 @@ J2DTexMtx* J2DMaterialFactory::newTexMtx(int param_0, int param_1) const {
}
u8 J2DMaterialFactory::newCullMode(int param_0) const {
+ int r30 = 0;
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
if (iVar2->field_0x1 != 0xff) {
return field_0x30[iVar2->field_0x1];
@@ -312,12 +309,13 @@ J2DTevSwapModeTable J2DMaterialFactory::newTevSwapModeTable(int param_0, int par
}
u8 J2DMaterialFactory::newIndTexStageNum(int param_0) const {
+ u8 r31 = 0;
if (field_0xc != NULL) {
if (field_0xc[param_0].field_0x0 == 1) {
return field_0xc[param_0].field_0x1;
}
}
- return 0;
+ return r31;
}
J2DIndTexOrder J2DMaterialFactory::newIndTexOrder(int param_0, int param_1) const {
@@ -373,7 +371,7 @@ J2DBlend J2DMaterialFactory::newBlend(int param_0) const {
if (iVar2->field_0xe4 != 0xffff) {
return J2DBlend(field_0x54[iVar2->field_0xe4]);
}
- return J2DBlend();
+ return J2DBlend(j2dDefaultBlendInfo);
}
u8 J2DMaterialFactory::newDither(int param_0) const {
diff --git a/src/JSystem/J2DGraph/J2DPane.cpp b/src/JSystem/J2DGraph/J2DPane.cpp
index 231488bd77..18d7e87626 100644
--- a/src/JSystem/J2DGraph/J2DPane.cpp
+++ b/src/JSystem/J2DGraph/J2DPane.cpp
@@ -21,10 +21,15 @@ J2DPane::J2DPane() : mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) {
void J2DPane::initiate() {
field_0x4 = -1;
- mRotateOffsetY = mRotateOffsetX = mRotateZ = mRotateY = mRotateX = 0;
+ mRotateX = 0.0f;
+ mRotateY = 0.0f;
+ mRotateZ = 0.0f;
+ mRotateOffsetX = 0.0f;
+ mRotateOffsetY = 0.0f;
mBasePosition = 0;
mRotAxis = ROTATE_Z;
- mScaleY = mScaleX = 1;
+ mScaleX = 1.0f;
+ mScaleY = 1.0f;
mCullMode = GX_CULL_NONE;
mAlpha = 255;
mIsInfluencedAlpha = true;
@@ -98,8 +103,8 @@ J2DPane::J2DPane(J2DPane* p_pane, JSURandomInputStream* p_stream, u8 isEx) : mPa
void J2DPane::makePaneStream(J2DPane* p_pane, JSURandomInputStream* p_stream) {
u8 unk;
- p_stream->read(&unk, 1);
- p_stream->read(&mVisible, 1);
+ p_stream->read(unk);
+ p_stream->read(mVisible);
p_stream->skip(2);
mInfoTag = p_stream->read32b();
@@ -110,7 +115,7 @@ void J2DPane::makePaneStream(J2DPane* p_pane, JSURandomInputStream* p_stream) {
f32 y1 = y0 + p_stream->readS16();
mBounds.set(x0, y0, x1, y1);
- unk -= 6;
+ unk -= u8(6);
mRotateX = 0;
mRotateY = 0;
mRotateZ = 0;
@@ -120,7 +125,8 @@ void J2DPane::makePaneStream(J2DPane* p_pane, JSURandomInputStream* p_stream) {
}
if (unk != 0) {
- mBasePosition = p_stream->readU8();
+ u8 r28 = p_stream->readU8();
+ mBasePosition = r28;
unk--;
} else {
mBasePosition = 0;
@@ -159,15 +165,15 @@ void J2DPane::changeUseTrans(J2DPane* p_pane) {
f32 xOffset = 0;
f32 yOffset = 0;
if (mBasePosition % 3 == 1) {
- xOffset = mBounds.getWidth() / 2;
+ xOffset = getWidth() / 2;
} else if (mBasePosition % 3 == 2) {
- xOffset = mBounds.getWidth();
+ xOffset = getWidth();
}
if (mBasePosition / 3 == 1) {
- yOffset = mBounds.getHeight() / 2;
+ yOffset = getHeight() / 2;
} else if (mBasePosition / 3 == 2) {
- yOffset = mBounds.getHeight();
+ yOffset = getHeight();
}
mTranslateX = mBounds.i.x + xOffset;
@@ -176,9 +182,7 @@ void J2DPane::changeUseTrans(J2DPane* p_pane) {
mRotateOffsetX = xOffset;
mRotateOffsetY = yOffset;
- f32 addX = -mTranslateX;
- f32 addY = -mTranslateY;
- mBounds.addPos(addX, addY);
+ mBounds.addPos(JGeometry::TVec2<f32>(-mTranslateX, -mTranslateY));
if (p_pane != NULL) {
u8 otherBasePos = p_pane->mBasePosition;
@@ -200,10 +204,9 @@ void J2DPane::changeUseTrans(J2DPane* p_pane) {
}
J2DPane::~J2DPane() {
- JSUTreeIterator<J2DPane> iterator;
- for (iterator = mPaneTree.getFirstChild(); iterator != mPaneTree.getEndChild();) {
- J2DPane* child = (iterator++).getObject();
- delete child;
+ JSUTreeIterator<J2DPane> iterator = mPaneTree.getFirstChild();
+ for (; iterator != mPaneTree.getEndChild();) {
+ delete (iterator++).getObject();
}
}
@@ -240,7 +243,7 @@ bool J2DPane::insertChild(J2DPane* p_prev, J2DPane* p_child) {
}
void J2DPane::draw(f32 x, f32 y, J2DGrafContext const* p_grafCtx, bool isOrthoGraf, bool param_4) {
- bool unkBool = param_4 && mVisible;
+ param_4 = param_4 && mVisible;
if (p_grafCtx->getGrafType() != 1) {
isOrthoGraf = false;
}
@@ -254,22 +257,36 @@ void J2DPane::draw(f32 x, f32 y, J2DGrafContext const* p_grafCtx, bool isOrthoGr
if (mBounds.isValid()) {
mGlobalBounds = mBounds;
- f32 addX = mTranslateX;
- f32 addY = mTranslateY;
- mGlobalBounds.addPos(addX, addY);
+ mGlobalBounds.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
- if (unkBool) {
+ if (param_4) {
mClipRect = mBounds;
rewriteAlpha();
}
if (parent != NULL) {
- f32 width = parent->mGlobalBounds.i.x - parent->mBounds.i.x;
- f32 height = parent->mGlobalBounds.i.y - parent->mBounds.i.y;
- mGlobalBounds.addPos(width, height);
+ mGlobalBounds.addPos(JGeometry::TVec2<f32>(parent->mGlobalBounds.i.x - parent->mBounds.i.x, parent->mGlobalBounds.i.y - parent->mBounds.i.y));
+#if !PLATFORM_GCN
+ f32 f28 = mPositionMtx[0][0];
+ f32 f27 = mPositionMtx[1][0];
+ f32 f26 = mPositionMtx[2][0];
+ if (getUserInfo() == 'n_43' && p_grafCtx->getGrafType() == 1) {
+ JGeometry::TBox2<f32>* bounds = ((J2DOrthoGraph*)p_grafCtx)->getBounds();
+ const JGeometry::TBox2<f32>* ortho = ((J2DOrthoGraph*)p_grafCtx)->getOrtho();
+ f32 f31 = 608.0f / (ortho->f.x - ortho->i.x);
+ mPositionMtx[0][0] *= f31;
+ mPositionMtx[0][1] *= f31;
+ mPositionMtx[0][2] *= f31;
+ }
+#endif
MTXConcat(parent->mGlobalMtx, mPositionMtx, mGlobalMtx);
+#if !PLATFORM_GCN
+ mPositionMtx[0][0] = f28;
+ mPositionMtx[1][0] = f27;
+ mPositionMtx[2][0] = f26;
+#endif
- if (unkBool) {
+ if (param_4) {
if (isOrthoGraf) {
mClipRect = mGlobalBounds;
mClipRect.intersect(parent->mClipRect);
@@ -281,19 +298,35 @@ void J2DPane::draw(f32 x, f32 y, J2DGrafContext const* p_grafCtx, bool isOrthoGr
}
}
} else {
- mGlobalBounds.addPos(x, y);
+#if !PLATFORM_GCN
+ f32 f25 = mScaleX;
+ f32 f24 = mTranslateX;
+ if (getUserInfo() != 'n_43' && p_grafCtx->getGrafType() == 1) {
+ JGeometry::TBox2<f32>* bounds = ((J2DOrthoGraph*)p_grafCtx)->getBounds();
+ const JGeometry::TBox2<f32>* ortho = ((J2DOrthoGraph*)p_grafCtx)->getOrtho();
+ f32 f30 = (ortho->f.x - ortho->i.x) / 608.0f;
+ f32 f29 = 304.0f;
+ mScaleX *= f30;
+ mTranslateX = f30 * (mTranslateX - f29) + f29;
+ }
+#endif
+ mGlobalBounds.addPos(JGeometry::TVec2<f32>(x, y));
makeMatrix(mTranslateX + x, mTranslateY + y);
MTXCopy(mPositionMtx, mGlobalMtx);
mClipRect = mGlobalBounds;
mColorAlpha = mAlpha;
+#if !PLATFORM_GCN
+ mScaleX = f25;
+ mTranslateX = f24;
+#endif
}
JGeometry::TBox2<f32> scissorBounds(0, 0, 0, 0);
- if (unkBool && isOrthoGraf) {
+ if (param_4 && isOrthoGraf) {
((J2DOrthoGraph*)p_grafCtx)->scissorBounds(&scissorBounds, &mClipRect);
}
- if (unkBool && (mClipRect.isValid() || !isOrthoGraf)) {
+ if (param_4 && (mClipRect.isValid() || !isOrthoGraf)) {
J2DGrafContext tmpGraf(*p_grafCtx);
if (isOrthoGraf) {
tmpGraf.scissor(scissorBounds);
@@ -303,9 +336,8 @@ void J2DPane::draw(f32 x, f32 y, J2DGrafContext const* p_grafCtx, bool isOrthoGr
drawSelf(x, y, &tmpGraf.mPosMtx);
}
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
- iter.getObject()->draw(0, 0, p_grafCtx, isOrthoGraf, unkBool);
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ iter.getObject()->draw(0, 0, p_grafCtx, isOrthoGraf, param_4);
}
}
}
@@ -362,8 +394,8 @@ void J2DPane::place(JGeometry::TBox2<f32> const& box) {
}
void J2DPane::move(f32 x, f32 y) {
- f32 width = getWidth();
- f32 height = getHeight();
+ f32 width = mBounds.getWidth();
+ f32 height = mBounds.getHeight();
place(JGeometry::TBox2<f32>(x, y, x + width, y + height));
}
@@ -376,16 +408,11 @@ void J2DPane::add(f32 x, f32 y) {
void J2DPane::resize(f32 x, f32 y) {
JGeometry::TBox2<f32> box = mBounds;
- f32 tX = mTranslateX;
- f32 tY = mTranslateY;
-
- box.addPos(tX, tY);
+ box.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
const J2DPane* parent = getParentPane();
if (parent != NULL) {
- f32 xAdd = -parent->mBounds.i.x;
- f32 yAdd = -parent->mBounds.i.y;
- box.addPos(xAdd, yAdd);
+ box.addPos(JGeometry::TVec2<f32>(-parent->mBounds.i.x, -parent->mBounds.i.y));
}
box.f.x = box.i.x + x;
@@ -398,16 +425,11 @@ JGeometry::TBox2<f32> J2DPane::static_mBounds(0, 0, 0, 0);
JGeometry::TBox2<f32>& J2DPane::getBounds() {
static_mBounds = mBounds;
- f32 tX = mTranslateX;
- f32 tY = mTranslateY;
-
- static_mBounds.addPos(tX, tY);
+ static_mBounds.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
const J2DPane* parent = getParentPane();
if (parent != NULL) {
- f32 xAdd = -parent->mBounds.i.x;
- f32 yAdd = -parent->mBounds.i.y;
- static_mBounds.addPos(xAdd, yAdd);
+ static_mBounds.addPos(JGeometry::TVec2<f32>(-parent->mBounds.i.x, -parent->mBounds.i.y));
}
return static_mBounds;
@@ -443,8 +465,7 @@ J2DPane* J2DPane::search(u64 tag) {
return this;
}
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
if (J2DPane* result = iter.getObject()->search(tag)) {
return result;
}
@@ -457,8 +478,7 @@ J2DPane* J2DPane::searchUserInfo(u64 tag) {
return this;
}
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
if (J2DPane* result = iter.getObject()->searchUserInfo(tag)) {
return result;
}
@@ -467,8 +487,7 @@ J2DPane* J2DPane::searchUserInfo(u64 tag) {
}
bool J2DPane::isUsed(const ResTIMG* p_timg) {
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
if (iter.getObject()->isUsed(p_timg))
return true;
}
@@ -476,8 +495,7 @@ bool J2DPane::isUsed(const ResTIMG* p_timg) {
}
bool J2DPane::isUsed(const ResFONT* p_font) {
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
if (iter.getObject()->isUsed(p_font))
return true;
}
@@ -502,8 +520,7 @@ void J2DPane::makeMatrix(f32 param_0, f32 param_1, f32 param_2, f32 param_3) {
void J2DPane::setCullBack(GXCullMode mode) {
mCullMode = mode;
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
iter.getObject()->setCullBack(mode);
}
}
@@ -515,20 +532,16 @@ void J2DPane::setBasePosition(J2DBasePosition position) {
mRotateOffsetX = 0;
if (position % 3 == 1) {
- f32 width = getWidth();
- mRotateOffsetX = width / 2;
+ mRotateOffsetX = getWidth() / 2;
} else if (position % 3 == 2) {
- f32 width = getWidth();
- mRotateOffsetX = width;
+ mRotateOffsetX = getWidth();
}
mRotateOffsetY = 0;
if (position / 3 == 1) {
- f32 height = getHeight();
- mRotateOffsetY = height / 2;
+ mRotateOffsetY = getHeight() / 2;
} else if (position / 3 == 2) {
- f32 height = getHeight();
- mRotateOffsetY = height;
+ mRotateOffsetY = getHeight();
}
calcMtx();
@@ -545,7 +558,7 @@ void J2DPane::setInfluencedAlpha(bool influencedAlpha, bool param_1) {
break;
}
alpha = (((f32)alpha) * parent->getAlpha() / 255);
- if (!parent->mIsInfluencedAlpha) {
+ if (!parent->isInfluencedAlpha()) {
break;
}
}
@@ -554,7 +567,7 @@ void J2DPane::setInfluencedAlpha(bool influencedAlpha, bool param_1) {
if (alpha == 0) {
setAlpha(0);
} else {
- f32 fAlpha = ((f32)mAlpha) / alpha * 255;
+ f32 fAlpha = ((f32)getAlpha()) / alpha * 255;
u8 alpha;
if (fAlpha > 255) {
@@ -565,7 +578,8 @@ void J2DPane::setInfluencedAlpha(bool influencedAlpha, bool param_1) {
setAlpha(alpha);
}
} else {
- setAlpha((f32)(alpha * mAlpha) / 255);
+ f32 fAlpha = f32(alpha * getAlpha()) / 255;
+ setAlpha(fAlpha);
}
}
@@ -579,25 +593,15 @@ Vec J2DPane::getGlbVtx(u8 param_0) const {
out.y = 0;
out.z = 0;
return out;
- } else {
- f32 x, y;
- if (param_0 & 1) {
- x = mBounds.f.x;
- } else {
- x = mBounds.i.x;
- }
+ }
- if (param_0 & 2) {
- y = mBounds.f.y;
- } else {
- y = mBounds.i.y;
- }
+ f32 x = param_0 & 1 ? mBounds.f.x : mBounds.i.x;
+ f32 y = param_0 & 2 ? mBounds.f.y : mBounds.i.y;
- out.x = x * mGlobalMtx[0][0] + y * mGlobalMtx[0][1] + mGlobalMtx[0][3];
- out.y = x * mGlobalMtx[1][0] + y * mGlobalMtx[1][1] + mGlobalMtx[1][3];
- out.z = x * mGlobalMtx[2][0] + y * mGlobalMtx[2][1] + mGlobalMtx[2][3];
- return out;
- }
+ out.x = x * mGlobalMtx[0][0] + y * mGlobalMtx[0][1] + mGlobalMtx[0][3];
+ out.y = x * mGlobalMtx[1][0] + y * mGlobalMtx[1][1] + mGlobalMtx[1][3];
+ out.z = x * mGlobalMtx[2][0] + y * mGlobalMtx[2][1] + mGlobalMtx[2][3];
+ return out;
}
J2DPane* J2DPane::getFirstChildPane() {
@@ -643,7 +647,7 @@ struct J2DPaneInfo {
}; // Size: 0x48
void J2DPane::makePaneExStream(J2DPane* p_parent, JSURandomInputStream* p_stream) {
- p_stream->getPosition();
+ s32 r30 = p_stream->getPosition();
J2DPaneInfo data;
p_stream->read(&data, sizeof(data));
@@ -696,24 +700,24 @@ void J2DPane::makePaneExStream(J2DPane* p_parent, JSURandomInputStream* p_stream
s16 J2DPane::J2DCast_F32_to_S16(f32 value, u8 arg2) {
if (arg2 >= 0xF) {
return 0;
- } else {
- f32 tmpF;
- tmpF = value;
+ }
+
+ f32 tmpF;
+ tmpF = value;
+ if (value < 0) {
+ tmpF = -tmpF;
+ }
+ int tmp = tmpF * (1 << arg2);
+ if (tmp >= 0x8000) {
if (value < 0) {
- tmpF = -value;
- }
- int tmp = tmpF * (1 << arg2);
- if (tmp >= 0x8000) {
- if (value < 0) {
- return 0x8000;
- } else {
- return 0x7FFF;
- }
- } else if (value < 0) {
- return ~tmp + 1;
+ return 0x8000;
} else {
- return tmp;
+ return 0x7FFF;
}
+ } else if (value < 0) {
+ return ~tmp + 1;
+ } else {
+ return tmp;
}
}
@@ -753,8 +757,6 @@ void* J2DPane::getPointer(JSURandomInputStream* p_stream, u32 param_1, JKRArchiv
void J2DPane::setAnimation(J2DAnmBase* p_anm) {
if (p_anm != NULL) {
switch (p_anm->getKind()) {
- default:
- break;
case KIND_TRANSFORM:
setAnimation(static_cast<J2DAnmTransform*>(p_anm));
break;
@@ -776,6 +778,9 @@ void J2DPane::setAnimation(J2DAnmBase* p_anm) {
case KIND_TEV_REG:
setAnimation(static_cast<J2DAnmTevRegKey*>(p_anm));
break;
+ default:
+ OS_REPORT("J2DPane: this is not a J3D Binary.\n");
+ break;
}
}
}
@@ -790,11 +795,9 @@ void J2DPane::animationTransform() {
}
void J2DPane::clearAnmTransform() {
- J2DAnmTransform* none = NULL;
- setAnimation(none);
+ setAnimation((J2DAnmTransform*)NULL);
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
iter.getObject()->clearAnmTransform();
}
}
@@ -804,8 +807,7 @@ const J2DAnmTransform* J2DPane::animationTransform(const J2DAnmTransform* p_tran
if (mTransform != NULL)
p = mTransform;
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
iter.getObject()->animationTransform(p);
}
@@ -816,8 +818,7 @@ const J2DAnmTransform* J2DPane::animationTransform(const J2DAnmTransform* p_tran
void J2DPane::setVisibileAnimation(J2DAnmVisibilityFull* p_visibility) {
setAnimationVF(p_visibility);
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
iter.getObject()->setVisibileAnimation(p_visibility);
}
}
@@ -825,8 +826,7 @@ void J2DPane::setVisibileAnimation(J2DAnmVisibilityFull* p_visibility) {
void J2DPane::setVtxColorAnimation(J2DAnmVtxColor* p_vtxColor) {
setAnimationVC(p_vtxColor);
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
iter.getObject()->setVtxColorAnimation(p_vtxColor);
}
}
@@ -836,8 +836,7 @@ const J2DAnmTransform* J2DPane::animationPane(const J2DAnmTransform* p_transform
if (mTransform != NULL)
p = mTransform;
- JSUTreeIterator<J2DPane> iter;
- for (iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
+ for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
iter.getObject()->animationPane(p);
}
diff --git a/src/JSystem/J2DGraph/J2DPicture.cpp b/src/JSystem/J2DGraph/J2DPicture.cpp
index 6968df2572..7208db3cd7 100644
--- a/src/JSystem/J2DGraph/J2DPicture.cpp
+++ b/src/JSystem/J2DGraph/J2DPicture.cpp
@@ -10,7 +10,7 @@
#include "dolphin/gx.h"
J2DPicture::J2DPicture() : mPalette(NULL) {
- for (int i = 0; i < 2; i++) {
+ for (u32 i = 0; i < 2; i++) {
mTexture[i] = NULL;
}
@@ -67,23 +67,12 @@ J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, J2DMater
if (material != NULL && material->getTevBlock() != NULL) {
u8 texgenNum = material->getTexGenBlock()->getTexGenNum();
- u32 stageNum = material->getTevBlock()->getTevStageNum();
+ u8 stageNum = u8(material->getTevBlock()->getTevStageNum());
if ((texgenNum == 1 && stageNum != 1) || (texgenNum != 1 && (int)stageNum != texgenNum + 1))
{
- J2DGXColorS10* color0p = material->getTevBlock()->getTevColor(0);
- GXColorS10 color0;
- color0.r = color0p->r;
- color0.g = color0p->g;
- color0.b = color0p->b;
- color0.a = color0p->a;
-
- J2DGXColorS10* color1p = material->getTevBlock()->getTevColor(1);
- GXColorS10 color1;
- color1.r = color1p->r;
- color1.g = color1p->g;
- color1.b = color1p->b;
- color1.a = color1p->a;
+ J2DGXColorS10 color0 = *material->getTevBlock()->getTevColor(0);
+ J2DGXColorS10 color1 = *material->getTevBlock()->getTevColor(1);
mBlack = JUtility::TColor(((u8)color0.r << 0x18) | ((u8)color0.g << 0x10) |
((u8)color0.b << 8) | (u8)color0.a);
@@ -91,7 +80,7 @@ J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, J2DMater
((u8)color1.b << 8) | (u8)color1.a);
}
- mTextureNum = texgenNum <= 2 ? texgenNum : 2;
+ mTextureNum = texgenNum > 2 ? 2 : texgenNum;
}
field_0x109 = 0;
@@ -127,7 +116,7 @@ J2DPicture::J2DPicture(J2DPane* p_pane, JSURandomInputStream* p_stream, J2DMater
}
J2DPicture::J2DPicture(ResTIMG const* p_timg) {
- for (int i = 0; i < 2; i++) {
+ for (u32 i = 0; i < 2; i++) {
mTexture[i] = NULL;
}
@@ -145,7 +134,7 @@ J2DPicture::J2DPicture(ResTIMG const* p_timg) {
J2DPicture::J2DPicture(u64 tag, JGeometry::TBox2<f32> const& bounds, ResTIMG const* p_timg,
ResTLUT const* p_tlut)
: J2DPane(tag, bounds), mPalette(NULL) {
- for (int i = 0; i < 2; i++) {
+ for (u32 i = 0; i < 2; i++) {
mTexture[i] = NULL;
}
@@ -169,47 +158,48 @@ void J2DPicture::private_readStream(J2DPane* parent, JSURandomInputStream* strea
ResTIMG* img;
ResTLUT* lut;
- u32 var_r27 = 0;
- u8 var_r26 = stream->readU8();
+ u8 local_172 = 0;
+ u8 local_173 = 0;
+ u8 r29 = stream->readU8();
img = (ResTIMG*)getPointer(stream, 'TIMG', archive);
lut = (ResTLUT*)getPointer(stream, 'TLUT', archive);
- u8 spA = stream->read8b();
+ local_172 = stream->read8b();
- var_r26 -= 3;
- if (var_r26 != 0) {
- var_r27 = stream->read8b();
- var_r26--;
+ r29 -= 3;
+ if (r29 != 0) {
+ local_173 = stream->read8b();
+ r29--;
}
- if (var_r26 != 0) {
- stream->read8b();
- var_r26--;
+ if (r29 != 0) {
+ u8 local_174 = stream->read8b();
+ r29--;
}
mBlack = 0;
mWhite = 0xFFFFFFFF;
- if (var_r26 != 0) {
+ if (r29 != 0) {
mBlack = stream->readU32();
- var_r26--;
+ r29--;
}
- if (var_r26 != 0) {
+ if (r29 != 0) {
mWhite = stream->readU32();
- var_r26--;
+ r29--;
}
setCornerColor(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
- for (int i = 0; var_r26 != 0 && i < 4; i++) {
+ for (int i = 0; r29 != 0 && i < 4; i++) {
mCornerColor[i] = stream->readU32();
- var_r26--;
+ r29--;
}
stream->seek(headerPosition + header.mSize, JSUStreamSeekFrom_SET);
- for (int i = 0; i < 2; i++) {
+ for (u32 i = 0; i < 2; i++) {
mTexture[i] = NULL;
}
@@ -226,7 +216,7 @@ void J2DPicture::private_readStream(J2DPane* parent, JSURandomInputStream* strea
mTexture[0]->attachPalette(mPalette);
}
- setTexCoord(mTexture[0], (J2DBinding)spA, (J2DMirror)(var_r27 & 3), (bool)((var_r27 >> 2) & 1));
+ setTexCoord(mTexture[0], J2DBinding(local_172), J2DMirror(local_173 & 3), bool(local_173 & 4));
setBlendRatio(1.0f, 1.0f);
}
@@ -295,8 +285,7 @@ bool J2DPicture::prepareTexture(u8 param_0) {
}
if (mTexture[i] == NULL) {
- JUTTexture* tmp = new JUTTexture();
- mTexture[i] = tmp;
+ mTexture[i] = new JUTTexture();
if (mTexture[i] == NULL) {
return 0;
@@ -337,12 +326,12 @@ bool J2DPicture::insert(ResTIMG const* img, JUTPalette* palette, u8 param_2, f32
} else {
var_r31 = mTexture[mTextureNum];
if (palette == NULL) {
- mTexture[mTextureNum]->storeTIMG(img, var_r26);
+ var_r31->storeTIMG(img, var_r26);
} else {
- mTexture[mTextureNum]->storeTIMG(img, palette);
+ var_r31->storeTIMG(img, palette);
}
- u8 sp8[2];
+ bool sp8[2];
for (u8 i = 0; i < 2; i++) {
sp8[i] = (field_0x109 & (1 << i)) != 0;
}
@@ -382,8 +371,7 @@ bool J2DPicture::insert(ResTIMG const* img, JUTPalette* palette, u8 param_2, f32
bool J2DPicture::insert(char const* resName, JUTPalette* palette, u8 param_2, f32 param_3) {
- void* resource = J2DScreen::getNameResource(resName);
- return insert((ResTIMG*)resource, palette, param_2, param_3);
+ return insert((ResTIMG*)J2DScreen::getNameResource(resName), palette, param_2, param_3);
}
bool J2DPicture::insert(JUTTexture* texture, u8 param_1, f32 param_2) {
@@ -464,8 +452,7 @@ const ResTIMG* J2DPicture::changeTexture(ResTIMG const* img, u8 texIndex) {
const ResTIMG* result;
if (texIndex < mTextureNum) {
- JUTTexture* tex = getTexture(texIndex);
- result = tex->getTexInfo();
+ result = getTexture(texIndex)->getTexInfo();
u8 var_r30 = 0;
if (img->indexTexture != 0) {
@@ -481,8 +468,7 @@ const ResTIMG* J2DPicture::changeTexture(ResTIMG const* img, u8 texIndex) {
const ResTIMG* J2DPicture::changeTexture(char const* resName, u8 param_1) {
- void* resource = J2DScreen::getNameResource(resName);
- return changeTexture((ResTIMG*)resource, param_1);
+ return changeTexture((ResTIMG*)J2DScreen::getNameResource(resName), param_1);
}
static bool dummy_weak_order(JUTTexture* tex) {
@@ -497,12 +483,12 @@ const ResTIMG* J2DPicture::changeTexture(ResTIMG const* img, u8 texIndex, JUTPal
const ResTIMG* result;
if (texIndex < mTextureNum) {
- JUTTexture* tex = getTexture(texIndex);
- result = tex->getTexInfo();
+ result = getTexture(texIndex)->getTexInfo();
GXTlut var_r30 = GX_TLUT0;
if (img->indexTexture != 0) {
- var_r30 = getTlutID(img, getUsableTlut(texIndex));
+ u8 tlut = getUsableTlut(texIndex);
+ var_r30 = getTlutID(img, tlut);
}
getTexture(texIndex)->storeTIMG(img, palette, var_r30);
return result;
@@ -514,8 +500,7 @@ const ResTIMG* J2DPicture::changeTexture(ResTIMG const* img, u8 texIndex, JUTPal
const ResTIMG* J2DPicture::changeTexture(char const* param_0, u8 param_1, JUTPalette* param_2) {
- void* resource = J2DScreen::getNameResource(param_0);
- return changeTexture((ResTIMG*)resource, param_1, param_2);
+ return changeTexture((ResTIMG*)J2DScreen::getNameResource(param_0), param_1, param_2);
}
void J2DPicture::drawSelf(f32 param_0, f32 param_1) {
@@ -528,7 +513,7 @@ void J2DPicture::drawSelf(f32 param_0, f32 param_1) {
void J2DPicture::drawSelf(f32 param_0, f32 param_1, Mtx* param_2) {
if (mTexture[0] != NULL && mTextureNum != 0) {
drawFullSet(mGlobalBounds.i.x + param_0, mGlobalBounds.i.y + param_1,
- mBounds.f.x - mBounds.i.x, mBounds.f.y - mBounds.i.y, param_2);
+ getWidth(), getHeight(), param_2);
}
}
@@ -543,6 +528,8 @@ void J2DPicture::drawFullSet(f32 param_0, f32 param_1, f32 param_2, f32 param_3,
void J2DPicture::draw(f32 x, f32 y, f32 width, f32 height, bool mirrorX, bool mirrorY,
bool rotate90) {
if (isVisible() && mTextureNum != 0 && mTexture[0] != NULL) {
+ f32 x2 = x + width;
+ f32 y2 = y + height;
for (u8 i = 0; i < mTextureNum; i++) {
load(i);
}
@@ -802,6 +789,36 @@ void J2DPicture::swap(f32& lhs, f32& rhs) {
rhs = tmp;
}
+J2DBinding J2DPicture::getBinding() const {
+ int r30 = J2DBind_None;
+ bool r29 = isTumble();
+ if (field_0x10a[0].x == 0 || field_0x10a[0].x == 256) {
+ r30 |= !r29 ? J2DBind_Left : J2DBind_Top;
+ }
+ if (field_0x10a[0].y == 0 || field_0x10a[0].y == 256) {
+ r30 |= !r29 ? J2DBind_Top : J2DBind_Left;
+ }
+ if (field_0x10a[3].x == 0 || field_0x10a[3].x == 256) {
+ r30 |= !r29 ? J2DBind_Right : J2DBind_Bottom;
+ }
+ if (field_0x10a[3].y == 0 || field_0x10a[3].y == 256) {
+ r30 |= !r29 ? J2DBind_Bottom : J2DBind_Right;
+ }
+ return J2DBinding(r30);
+}
+
+void J2DPicture::setMirror(J2DMirror mirror) {
+ if (getTexture(0)) {
+ J2DBinding binding = getBinding();
+ bool r28 = isTumble();
+ setTexCoord(getTexture(0), binding, mirror, r28);
+ }
+}
+
+bool J2DPicture::isTumble() const {
+ return field_0x10a[1] == JGeometry::TVec2<s16>(s16(field_0x10a[0].x), s16(field_0x10a[3].y));
+}
+
void J2DPicture::setBlendColorRatio(f32 param_0, f32 param_1) {
field_0x11c[0] = param_0;
field_0x11c[1] = param_1;
@@ -822,10 +839,9 @@ void J2DPicture::setBlendKonstColor() {
tmp += field_0x11c[j];
}
- f32 tmp2 = tmp + field_0x11c[i];
- if (tmp2 != 0.0f) {
- // probably fake match but idk whats happening here
- uvar3 |= (u8)(255.0f * (1.0f - tmp / tmp2)) << (i - 1) * 8;
+ if (tmp + field_0x11c[i] != 0.0f) {
+ f32 tmp2 = 255.0f * (1.0f - tmp / (tmp + field_0x11c[i]));
+ uvar3 |= (u8)tmp2 << (i - 1) * 8;
}
}
mBlendKonstColor = uvar3;
@@ -839,10 +855,9 @@ void J2DPicture::setBlendKonstAlpha() {
tmp += field_0x124[j];
}
- f32 tmp2 = tmp + field_0x124[i];
- if (tmp2 != 0.0f) {
- // probably fake match but idk whats happening here
- uvar3 |= (u8)(255.0f * (1.0f - tmp / tmp2)) << (i - 1) * 8;
+ if (tmp + field_0x124[i] != 0.0f) {
+ f32 tmp2 = 255.0f * (1.0f - tmp / (tmp + field_0x124[i]));
+ uvar3 |= (u8)tmp2 << (i - 1) * 8;
}
}
mBlendKonstAlpha = uvar3;
@@ -875,45 +890,15 @@ void J2DPicture::setTexCoord(JGeometry::TVec2<s16>* param_0, JUTTexture const* p
bool bindBottom;
if (!rotate90) {
- if (mirror & J2DMirror_X)
- bindLeft = binding & J2DBind_Right;
- else
- bindLeft = binding & J2DBind_Left;
-
- if (mirror & J2DMirror_X)
- bindRight = binding & J2DBind_Left;
- else
- bindRight = binding & J2DBind_Right;
-
- if (mirror & J2DMirror_Y)
- bindTop = binding & J2DBind_Bottom;
- else
- bindTop = binding & J2DBind_Top;
-
- if (mirror & J2DMirror_Y)
- bindBottom = binding & J2DBind_Top;
- else
- bindBottom = binding & J2DBind_Bottom;
+ bindLeft = mirror & J2DMirror_X ? bool(binding & J2DBind_Right) : bool(binding & J2DBind_Left);
+ bindRight = mirror & J2DMirror_X ? bool(binding & J2DBind_Left) : bool(binding & J2DBind_Right);
+ bindTop = mirror & J2DMirror_Y ? bool(binding & J2DBind_Bottom) : bool(binding & J2DBind_Top);
+ bindBottom = mirror & J2DMirror_Y ? bool(binding & J2DBind_Top) : bool(binding & J2DBind_Bottom);
} else {
- if (mirror & J2DMirror_X)
- bindLeft = binding & J2DBind_Bottom;
- else
- bindLeft = binding & J2DBind_Top;
-
- if (mirror & J2DMirror_X)
- bindRight = binding & J2DBind_Top;
- else
- bindRight = binding & J2DBind_Bottom;
-
- if (mirror & J2DMirror_Y)
- bindTop = binding & J2DBind_Left;
- else
- bindTop = binding & J2DBind_Right;
-
- if (mirror & J2DMirror_Y)
- bindBottom = binding & J2DBind_Right;
- else
- bindBottom = binding & J2DBind_Left;
+ bindLeft = mirror & J2DMirror_X ? bool(binding & J2DBind_Bottom) : bool(binding & J2DBind_Top);
+ bindRight = mirror & J2DMirror_X ? bool(binding & J2DBind_Top) : bool(binding & J2DBind_Bottom);
+ bindTop = mirror & J2DMirror_Y ? bool(binding & J2DBind_Left) : bool(binding & J2DBind_Right);
+ bindBottom = mirror & J2DMirror_Y ? bool(binding & J2DBind_Right) : bool(binding & J2DBind_Left);
}
f32 rectWidth;
@@ -992,7 +977,7 @@ bool J2DPicture::isUsed(ResTIMG const* param_0) {
}
u8 J2DPicture::getUsableTlut(u8 param_0) {
- u8 var_r8 = 0;
+ u8 r27 = 0;
for (u8 i = 0; i < mTextureNum; i++) {
if (i != param_0 && mTexture[i] != NULL) {
@@ -1000,25 +985,32 @@ u8 J2DPicture::getUsableTlut(u8 param_0) {
if (img != NULL && img->indexTexture != 0) {
int name = mTexture[i]->getTlutName();
- int var_r0 = name >= GX_BIGTLUT0 ? GX_BIGTLUT0 : GX_TLUT0;
- u8 temp_r0 = name - var_r0;
- if (temp_r0 < 2) {
- var_r8 |= (1 << temp_r0);
+ GXTlut local_34;
+ (void)&local_34; // force this variable to the stack
+ if (name >= GX_BIGTLUT0) {
+ local_34 = GX_BIGTLUT0;
+ } else {
+ local_34 = GX_TLUT0;
+ }
+
+ u8 r24 = name - local_34;
+ if (r24 < 2) {
+ r27 |= (1 << r24);
}
}
}
}
- u8 var_r26 = 0;
+ u8 r23 = 0;
for (u8 i = 0; i < 2; i++) {
- if (!(var_r8 & (1 << i))) {
- var_r26 = i;
+ if (!(r27 & (1 << i))) {
+ r23 = i;
break;
}
}
- return var_r26;
+ return r23;
}
GXTlut J2DPicture::getTlutID(ResTIMG const* img, u8 param_1) {
diff --git a/src/JSystem/J2DGraph/J2DPictureEx.cpp b/src/JSystem/J2DGraph/J2DPictureEx.cpp
index 9b33e0dcb5..eafa5619fe 100644
--- a/src/JSystem/J2DGraph/J2DPictureEx.cpp
+++ b/src/JSystem/J2DGraph/J2DPictureEx.cpp
@@ -8,8 +8,8 @@
#include "dolphin/types.h"
void J2DPictureEx::initiate(ResTIMG const* param_0, ResTLUT const* param_1) {
- J2DTexGenBlock* this_00 = mMaterial->getTexGenBlock();
- if (this_00->getTexGenNum() == 0 && append(param_0, 1.0f) && param_1 != NULL) {
+ u32 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
+ if (texGenNum == 0 && append(param_0, 1.0f) && param_1 != NULL) {
if (mMaterial->getTevBlock()->getPalette(0) == NULL) {
mMaterial->getTevBlock()->setPalette(0, param_1);
}
@@ -102,43 +102,44 @@ void J2DPictureEx::drawTexCoord(f32 param_0, f32 param_1, f32 param_2, f32 param
f32 dVar11 = param_1 + param_3;
Mtx auStack_88;
MTXConcat(*param_12, mGlobalMtx, auStack_88);
- if (mMaterial == NULL || mMaterial->isVisible()) {
- GXLoadPosMtxImm(auStack_88, 0);
- JUtility::TColor TStack_8c = mCornerColor[0];
- JUtility::TColor TStack_90 = mCornerColor[1];
- JUtility::TColor TStack_94 = mCornerColor[2];
- JUtility::TColor TStack_98 = mCornerColor[3];
- if (mMaterial != NULL) {
- if (mMaterial->getColorBlock()->getColorChan(1)->getMatSrc() == 1) {
- if (mMaterial->getMaterialAlphaCalc() == 1) {
- TStack_8c.a = TStack_8c.a * mColorAlpha / 255;
- TStack_90.a = TStack_90.a * mColorAlpha / 255;
- TStack_94.a = TStack_94.a * mColorAlpha / 255;
- TStack_98.a = TStack_98.a * mColorAlpha / 255;
- }
- } else if (mIsInfluencedAlpha) {
- GXSetChanMatColor(GX_ALPHA0, JUtility::TColor(mColorAlpha));
+ if (mMaterial && !mMaterial->isVisible()) {
+ return;
+ }
+ GXLoadPosMtxImm(auStack_88, 0);
+ JUtility::TColor TStack_8c = mCornerColor[0];
+ JUtility::TColor TStack_90 = mCornerColor[1];
+ JUtility::TColor TStack_94 = mCornerColor[2];
+ JUtility::TColor TStack_98 = mCornerColor[3];
+ if (mMaterial != NULL) {
+ if (mMaterial->getColorBlock()->getColorChan(1)->getMatSrc() == 1) {
+ if (mMaterial->getMaterialAlphaCalc() == 1) {
+ TStack_8c.a = TStack_8c.a * mColorAlpha / 255;
+ TStack_90.a = TStack_90.a * mColorAlpha / 255;
+ TStack_94.a = TStack_94.a * mColorAlpha / 255;
+ TStack_98.a = TStack_98.a * mColorAlpha / 255;
}
+ } else if (mIsInfluencedAlpha) {
+ GXSetChanMatColor(GX_ALPHA0, JUtility::TColor(mColorAlpha));
}
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBA4, 8);
- GXBegin(GX_QUADS, GX_VTXFMT0, 4);
- GXPosition3f32(param_0, param_1, 0.0f);
- GXColor1u32(TStack_8c);
- GXTexCoord2s16(param_4, param_5);
- GXPosition3f32(dVar12, param_1, 0.0f);
- GXColor1u32(TStack_90);
- GXTexCoord2s16(param_6, param_7);
- GXPosition3f32(dVar12, dVar11, 0.0f);
- GXColor1u32(TStack_98);
- GXTexCoord2s16(param_10, param_11);
- GXPosition3f32(param_0, dVar11, 0.0f);
- GXColor1u32(TStack_94);
- GXTexCoord2s16(param_8, param_9);
- GXEnd();
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0xf);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
}
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBA4, 8);
+ GXBegin(GX_QUADS, GX_VTXFMT0, 4);
+ GXPosition3f32(param_0, param_1, 0.0f);
+ GXColor1u32(TStack_8c);
+ GXTexCoord2s16(param_4, param_5);
+ GXPosition3f32(dVar12, param_1, 0.0f);
+ GXColor1u32(TStack_90);
+ GXTexCoord2s16(param_6, param_7);
+ GXPosition3f32(dVar12, dVar11, 0.0f);
+ GXColor1u32(TStack_98);
+ GXTexCoord2s16(param_10, param_11);
+ GXPosition3f32(param_0, dVar11, 0.0f);
+ GXColor1u32(TStack_94);
+ GXTexCoord2s16(param_8, param_9);
+ GXEnd();
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0xf);
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
}
@@ -147,7 +148,8 @@ bool J2DPictureEx::append(ResTIMG const* param_0, JUTPalette* param_1, f32 param
return false;
}
- return insert(param_0, param_1, mMaterial->getTexGenBlock()->getTexGenNum(), param_2);
+ u32 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
+ return insert(param_0, param_1, texGenNum, param_2);
}
bool J2DPictureEx::append(char const* param_0, JUTPalette* param_1, f32 param_2) {
@@ -155,7 +157,8 @@ bool J2DPictureEx::append(char const* param_0, JUTPalette* param_1, f32 param_2)
return false;
}
- return insert(param_0, param_1, mMaterial->getTexGenBlock()->getTexGenNum(), param_2);
+ u32 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
+ return insert(param_0, param_1, texGenNum, param_2);
}
bool J2DPictureEx::append(JUTTexture* param_0, f32 param_1) {
@@ -163,7 +166,8 @@ bool J2DPictureEx::append(JUTTexture* param_0, f32 param_1) {
return false;
}
- return insert(param_0, mMaterial->getTexGenBlock()->getTexGenNum(), param_1);
+ u32 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
+ return insert(param_0, texGenNum, param_1);
}
bool J2DPictureEx::insert(ResTIMG const* param_0, JUTPalette* param_1, u8 param_2,
@@ -182,8 +186,7 @@ bool J2DPictureEx::insert(ResTIMG const* param_0, JUTPalette* param_1, u8 param_
}
bool J2DPictureEx::insert(char const* param_0, JUTPalette* param_1, u8 param_2, f32 param_3) {
- ResTIMG const* resource = (ResTIMG const*)J2DScreen::getNameResource(param_0);
- return insert(resource, param_1, param_2, param_3);
+ return insert((ResTIMG*)J2DScreen::getNameResource(param_0), param_1, param_2, param_3);
}
bool J2DPictureEx::insert(JUTTexture* param_0, u8 param_1, f32 param_2) {
@@ -201,15 +204,14 @@ bool J2DPictureEx::insert(JUTTexture* param_0, u8 param_1, f32 param_2) {
}
void J2DPictureEx::insertCommon(u8 pos, f32 param_1) {
- u8 new_tev_stage_num;
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
- mMaterial->getTevBlock()->getMaxStage();
- int tev_stage_num = mMaterial->getTevBlock()->getTevStageNum();
+ u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
+ u8 tev_stage_num = u8(mMaterial->getTevBlock()->getTevStageNum());
bool bVar1;
if (tex_gen_num <= 1) {
- bVar1 = tev_stage_num != 1;
+ bVar1 = tev_stage_num == 1 ? false : true;
} else {
- bVar1 = tev_stage_num != tex_gen_num + 1;
+ bVar1 = int(tev_stage_num) == tex_gen_num + 1 ? false : true;
}
shiftSetBlendRatio(pos, param_1, true, true);
@@ -228,21 +230,22 @@ void J2DPictureEx::insertCommon(u8 pos, f32 param_1) {
}
for (int i = tex_gen_num - 1; i > pos; i--) {
- mMaterial->getTexGenBlock()->setTexMtx((u8)i, mMaterial->getTexGenBlock()->getTexMtx((u8)(i - 1)));
+ J2DTexMtx* texMtx = &mMaterial->getTexGenBlock()->getTexMtx((u8)(i - 1));
+ mMaterial->getTexGenBlock()->setTexMtx((u8)i, *texMtx);
}
J2DTexMtx tex_mtx;
mMaterial->getTexGenBlock()->setTexMtx(pos, tex_mtx);
if (tex_gen_num == 1) {
- new_tev_stage_num = 1;
+ tev_stage_num = 1;
} else {
- new_tev_stage_num = tex_gen_num + (bVar1 ? 2 : 1);
+ tev_stage_num = tex_gen_num + (bVar1 ? 2 : 1);
}
- mMaterial->getTevBlock()->setTevStageNum(new_tev_stage_num);
+ mMaterial->getTevBlock()->setTevStageNum(tev_stage_num);
- setTevOrder(tex_gen_num, new_tev_stage_num, bVar1);
- setTevStage(tex_gen_num, new_tev_stage_num, bVar1);
+ setTevOrder(tex_gen_num, tev_stage_num, bVar1);
+ setTevStage(tex_gen_num, tev_stage_num, bVar1);
setTevKColor(tex_gen_num);
setTevKColorSel(tex_gen_num);
setTevKAlphaSel(tex_gen_num);
@@ -265,7 +268,8 @@ bool J2DPictureEx::isInsert(u8 pos) const {
return false;
}
- if (maxStage == mMaterial->getTevBlock()->getTevStageNum() && texGenNum != 0) {
+ u8 tevStageNum = u8(mMaterial->getTevBlock()->getTevStageNum());
+ if (maxStage == tevStageNum && texGenNum != 0) {
return false;
}
@@ -278,7 +282,7 @@ bool J2DPictureEx::remove(u8 pos) {
}
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
- u8 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum();
+ u8 tev_stage_num = u8(mMaterial->getTevBlock()->getTevStageNum());
bool bVar1 = tev_stage_num == tex_gen_num + 1 ? false : true;
shiftSetBlendRatio(pos, 0.0f, true, false);
@@ -360,18 +364,17 @@ void J2DPictureEx::draw(f32 param_0, f32 param_1, u8 texNo, bool param_3, bool p
return;
}
- if (!isVisible()) {
- return;
- }
-
- if (texNo >= mMaterial->getTexGenBlock()->getTexGenNum()) {
- return;
- }
+ if (isVisible()) {
+ u32 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
+ if (texNo >= texGenNum) {
+ return;
+ }
- JUTTexture* texture = mMaterial->getTevBlock()->getTexture(texNo);
- if (texture != NULL) {
- draw(param_0, param_1, texture->getWidth(), texture->getHeight(),
- param_3, param_4, param_5);
+ JUTTexture* texture = mMaterial->getTevBlock()->getTexture(texNo);
+ if (texture != NULL) {
+ draw(param_0, param_1, texture->getWidth(), texture->getHeight(),
+ param_3, param_4, param_5);
+ }
}
}
@@ -616,8 +619,9 @@ void J2DPictureEx::setTevOrder(u8 param_0, u8 param_1, bool param_2) {
}
void J2DPictureEx::setTevStage(u8 param_0, u8 param_1, bool param_2) {
+ J2DTevStage* stage;
if (param_0 == 1) {
- J2DTevStage* stage = mMaterial->getTevBlock()->getTevStage(0);
+ stage = mMaterial->getTevBlock()->getTevStage(0);
JUTTexture* texture = mMaterial->getTevBlock()->getTexture(0);
bool bVar1 = false;
if (texture != NULL && texture->getTexInfo() != NULL
@@ -634,7 +638,7 @@ void J2DPictureEx::setTevStage(u8 param_0, u8 param_1, bool param_2) {
setStage(stage, STAGE_4);
}
} else if (!param_2) {
- J2DTevStage* stage = mMaterial->getTevBlock()->getTevStage(0);
+ stage = mMaterial->getTevBlock()->getTevStage(0);
setStage(stage, STAGE_2);
for (u8 i = 1; i < param_0; i++) {
stage = mMaterial->getTevBlock()->getTevStage(i);
@@ -643,7 +647,7 @@ void J2DPictureEx::setTevStage(u8 param_0, u8 param_1, bool param_2) {
stage = mMaterial->getTevBlock()->getTevStage(param_0);
setStage(stage, STAGE_4);
} else {
- J2DTevStage* stage = mMaterial->getTevBlock()->getTevStage(0);
+ stage = mMaterial->getTevBlock()->getTevStage(0);
setStage(stage, STAGE_2);
for (u8 i = 1; i < param_0; i++) {
stage = mMaterial->getTevBlock()->getTevStage(i);
@@ -812,7 +816,8 @@ void J2DPictureEx::setBlendColorRatio(f32 param_0, f32 param_1) {
field_0x160[i] = 1.0f;
}
- setTevKColor(mMaterial->getTexGenBlock()->getTexGenNum());
+ u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
+ setTevKColor(texGenNum);
}
@@ -828,7 +833,8 @@ void J2DPictureEx::setBlendAlphaRatio(f32 param_0, f32 param_1) {
field_0x178[i] = 1.0f;
}
- setTevKColor(mMaterial->getTexGenBlock()->getTexGenNum());
+ u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
+ setTevKColor(texGenNum);
}
@@ -862,8 +868,7 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
}
const ResTIMG* J2DPictureEx::changeTexture(char const* param_0, u8 param_1) {
- ResTIMG const* resource = (ResTIMG const*)J2DScreen::getNameResource(param_0);
- return changeTexture(resource, param_1);
+ return changeTexture((ResTIMG*)J2DScreen::getNameResource(param_0), param_1);
}
const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, JUTPalette* param_2) {
@@ -884,7 +889,8 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, J
const ResTIMG* texInfo = getTexture(param_1)->getTexInfo();
GXTlut _Var7 = GX_TLUT0;
if (param_0->indexTexture != 0) {
- _Var7 = getTlutID(param_0, getUsableTlut(param_1));
+ u8 tlut = getUsableTlut(param_1);
+ _Var7 = getTlutID(param_0, tlut);
}
getTexture(param_1)->storeTIMG(param_0, param_2, _Var7);
return texInfo;
@@ -894,8 +900,7 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, J
}
const ResTIMG* J2DPictureEx::changeTexture(char const* param_0, u8 param_1, JUTPalette* param_2) {
- ResTIMG const* resource = (ResTIMG const*)J2DScreen::getNameResource(param_0);
- return changeTexture(resource, param_1, param_2);
+ return changeTexture((ResTIMG*)J2DScreen::getNameResource(param_0), param_1, param_2);
}
JUTTexture* J2DPictureEx::getTexture(u8 param_0) const {
@@ -952,10 +957,7 @@ bool J2DPictureEx::setBlackWhite(JUtility::TColor param_0, JUtility::TColor para
bool bVar1;
u8 uVar2;
u8 texGenNum = mMaterial->getTexGenBlock()->getTexGenNum();
- bVar1 = true;
- if ((param_0 == 0) && (param_1 == 0xffffffff)) {
- bVar1 = false;
- }
+ bVar1 = (param_0 != 0) || (param_1 != 0xffffffff);
if (texGenNum == 1) {
uVar2 = (bVar1) ? 2 : 1;
} else {
diff --git a/src/JSystem/J2DGraph/J2DScreen.cpp b/src/JSystem/J2DGraph/J2DScreen.cpp
index 93989d1938..28f90beeaa 100644
--- a/src/JSystem/J2DGraph/J2DScreen.cpp
+++ b/src/JSystem/J2DGraph/J2DScreen.cpp
@@ -172,7 +172,7 @@ s32 J2DScreen::makeHierarchyPanes(J2DPane* p_basePane, JSURandomInputStream* p_s
J2DPane* J2DScreen::createPane(J2DScrnBlockHeader const& header, JSURandomInputStream* p_stream,
J2DPane* p_basePane, u32 param_3, JKRArchive* p_archive) {
- J2DPane* newPane;
+ J2DPane* newPane = NULL;
switch (header.mTag) {
case 'PAN1':
@@ -212,6 +212,7 @@ J2DPane* J2DScreen::createPane(J2DScrnBlockHeader const& header, JSURandomInputS
newPane = new J2DTextBox(p_basePane, p_stream, param_3, mMaterials);
break;
default:
+ JUT_WARN(446, "%s", "unknown pane");
s32 position = p_stream->getPosition();
s32 size = header.mSize;
s32 start = size + position;
@@ -280,29 +281,30 @@ void J2DScreen::drawSelf(f32 param_0, f32 param_1, Mtx* param_2) {
JUtility::TColor color(mColor);
u8 alpha = (color.a * mAlpha) / 255;
- if (alpha != 0) {
- JUtility::TColor sp8(alpha | ((u32)color & 0xFFFFFF00));
- color = sp8;
+ if (alpha == 0) {
+ return;
+ }
- GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
- GXBegin(GX_QUADS, GX_VTXFMT0, 4);
+ color = JUtility::TColor(alpha | ((u32)color & 0xFFFFFF00));
- GXPosition3f32(0.0f, 0.0f, 0.0f);
- GXColor1u32(color);
+ GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
+ GXBegin(GX_QUADS, GX_VTXFMT0, 4);
- GXPosition3f32(getWidth(), 0.0f, 0.0f);
- GXColor1u32(color);
+ GXPosition3f32(0.0f, 0.0f, 0.0f);
+ GXColor1u32(color);
- GXPosition3f32(getWidth(), getHeight(), 0.0f);
- GXColor1u32(color);
+ GXPosition3f32(getWidth(), 0.0f, 0.0f);
+ GXColor1u32(color);
- GXPosition3f32(0.0f, getHeight(), 0.0f);
- GXColor1u32(color);
+ GXPosition3f32(getWidth(), getHeight(), 0.0f);
+ GXColor1u32(color);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
- GXEnd();
- }
+ GXPosition3f32(0.0f, getHeight(), 0.0f);
+ GXColor1u32(color);
+ GXEnd();
+
+ GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
}
J2DResReference* J2DScreen::getResReference(JSURandomInputStream* p_stream, u32 param_1) {
@@ -407,7 +409,7 @@ bool J2DScreen::isUsed(ResFONT const* p_font) {
J2DDataManage* J2DScreen::mDataManage;
void* J2DScreen::getNameResource(char const* resName) {
- void* res = JKRFileLoader::getGlbResource(resName, NULL);
+ void* res = JKRGetNameResource(resName, NULL);
if (res == NULL && mDataManage != NULL) {
res = mDataManage->get(resName);
diff --git a/src/JSystem/J2DGraph/J2DTevs.cpp b/src/JSystem/J2DGraph/J2DTevs.cpp
index 3f6010e4df..68469cc0fa 100644
--- a/src/JSystem/J2DGraph/J2DTevs.cpp
+++ b/src/JSystem/J2DGraph/J2DTevs.cpp
@@ -5,7 +5,7 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J2DGraph/J2DTevs.h"
-#include "JSystem/J2DGraph/J2DMatBlock.h"
+#include "JSystem/J2DGraph/J2DMaterial.h"
#include <math>
#include "dolphin/gx.h"
@@ -76,22 +76,33 @@ void J2DIndTexOrder::load(u8 indTexStage) {
GXSetIndTexOrder((GXIndTexStageID)indTexStage, (GXTexCoordID)mInfo.mTexCoordID, (GXTexMapID)mInfo.mTexMapID);
}
-static void dummyVirtual(J2DTevBlock* block, J2DIndBlock* indBlock) {
+static void dummyVirtual(J2DMaterial* material) {
+ J2DIndBlock* indBlock = material->getIndBlock();
indBlock->getIndTexStageNum();
indBlock->getIndTexOrder(0);
indBlock->getIndTexStageNum();
indBlock->getIndTexOrder(0);
indBlock->getIndTexMtx(0);
indBlock->getIndTexCoordScale(0);
+ J2DColorBlock* colorBlock = material->getColorBlock();
+ J2DTexGenBlock* texGenBlock = material->getTexGenBlock();
+ texGenBlock->getTexGenNum();
+ J2DTevBlock* block = material->getTevBlock();
block->getIndTevStage(0);
block->getTevStageNum();
+ material->getPEBlock();
+ material->getMaterialAlphaCalc();
+ colorBlock->getMatColor(0);
+ colorBlock->getColorChan(0);
+ texGenBlock->getTexCoord(0);
+ texGenBlock->getTexMtx(0).getTexMtxInfo();
block->getTexNo(0);
block->getFontNo();
block->getTevKColor(0);
block->getTevKColorSel(0);
block->getTevKAlphaSel(0);
block->getTevOrder(0);
- block->getTevColor(0);
+ J2DGXColorS10 color(*block->getTevColor(0));
block->getTevStage(0);
block->getTevSwapModeTable(0);
}
diff --git a/src/JSystem/J2DGraph/J2DWindow.cpp b/src/JSystem/J2DGraph/J2DWindow.cpp
index c33fd3c095..78c89ff2b8 100644
--- a/src/JSystem/J2DGraph/J2DWindow.cpp
+++ b/src/JSystem/J2DGraph/J2DWindow.cpp
@@ -95,23 +95,16 @@ J2DWindow::J2DWindow(J2DPane* param_0, JSURandomInputStream* param_1, J2DMateria
mWhite = JUtility::TColor(0xffffffff);
if (local_98[0] != NULL && local_98[0]->getTevBlock() != NULL) {
- if (local_98[0]->getTevBlock()->getTevStageNum() != 1) {
- J2DGXColorS10* local_c8 = local_98[0]->getTevBlock()->getTevColor(0);
- s16 blackr = local_c8->r;
- s16 blackg = local_c8->g;
- s16 blackb = local_c8->b;
- s16 blacka = local_c8->a;
- J2DGXColorS10* local_d0 = local_98[0]->getTevBlock()->getTevColor(1);
- s16 whiter = local_d0->r;
- s16 whiteg = local_d0->g;
- s16 whiteb = local_d0->b;
- s16 whitea = local_d0->a;
+ u8 tevStageNum = u8(local_98[0]->getTevBlock()->getTevStageNum());
+ if (tevStageNum != 1) {
+ J2DGXColorS10 local_c8 = *local_98[0]->getTevBlock()->getTevColor(0);
+ J2DGXColorS10 local_d0 = *local_98[0]->getTevBlock()->getTevColor(1);
mBlack = JUtility::TColor(
- (((u8)blackr) << 24) | (((u8)blackg) << 16) | (((u8)blackb) << 8) |
- ((u8)blacka));
+ (((u8)local_c8.r) << 24) | (((u8)local_c8.g) << 16) | (((u8)local_c8.b) << 8) |
+ ((u8)local_c8.a));
mWhite = JUtility::TColor(
- (((u8)whiter) << 24) | (((u8)whiteg) << 16) | (((u8)whiteb) << 8) |
- ((u8)whitea));
+ (((u8)local_d0.r) << 24) | (((u8)local_d0.g) << 16) | (((u8)local_d0.b) << 8) |
+ ((u8)local_d0.a));
}
}
@@ -122,14 +115,12 @@ J2DWindow::J2DWindow(J2DPane* param_0, JSURandomInputStream* param_1, J2DMateria
&field_0x10c,
};
- J2DMaterial * mat;
for (u32 uVar6 = 0; uVar6 < 4; uVar6++) {
- mat = local_98[uVar6];
- if (mat != NULL && mat->getTevBlock() != NULL) {
- JUTTexture* local_e0 = mat->getTevBlock()->getTexture(0);
+ if (local_98[uVar6] != NULL && local_98[uVar6]->getTevBlock() != NULL) {
+ JUTTexture* local_e0 = local_98[uVar6]->getTevBlock()->getTexture(0);
if (local_e0 != NULL) {
*textures[uVar6] = local_e0;
- mat->getTevBlock()->setUndeleteFlag(0xfe);
+ local_98[uVar6]->getTevBlock()->setUndeleteFlag(0xfe);
}
}
}
@@ -224,6 +215,7 @@ void J2DWindow::private_readStream(J2DPane* param_0, JSURandomInputStream* param
r27 -= u8(14);
field_0x110 = NULL;
if (r27) {
+ int unused;
timg = (ResTIMG*)getPointer(param_1, 'TIMG', param_2);
if (timg) {
field_0x110 = new JUTTexture(timg, 0);
@@ -334,74 +326,39 @@ void J2DWindow::draw_private(JGeometry::TBox2<f32> const& param_0,
f32 f27 = f29 + field_0x100->getWidth();
f32 f26 = f28 + field_0x100->getHeight();
drawFrameTexture(field_0x100, f29, f28, field_0x144 & 0x80, field_0x144 & 0x40, true);
- bool r24 = isField0x145Set(1);
+ bool r24 = field_0x145 & 1;
drawFrameTexture(field_0x104, f31, f28, field_0x144 & 0x20, field_0x144 & 0x10, r24);
- u16 local_a6;
- if (field_0x144 & 0x20) {
- local_a6 = 0x8000;
- } else {
- local_a6 = 0;
- }
- u16 local_a8;
- if (field_0x144 & 0x10) {
- local_a8 = 0;
- } else {
- local_a8 = 0x8000;
- }
- u16 local_a82 = local_a8 ^ 0x8000;
-
- drawFrameTexture(field_0x104, f27, f28, f31 - f27, field_0x104->getHeight(), local_a6,
- local_a8, local_a6, local_a82, false);
- bool isset2 = isField0x145Set(2);
- drawFrameTexture(field_0x10c, f31, f30, field_0x144 & 2, field_0x144 & 1, isset2);
- u16 local_aa;
- if (field_0x144 & 2) {
- local_aa = 0x8000;
- } else {
- local_aa = 0;
- }
- u16 local_ac;
- if (field_0x144 & 1) {
- local_ac = 0;
- } else {
- local_ac = 0x8000;
- }
- local_a82 = local_ac ^ 0x8000;
- drawFrameTexture(field_0x10c, f27, f30, f31 - f27, field_0x10c->getHeight(), local_aa,
- local_ac, local_aa, local_a82, false);
- u16 local_ae;
- if (field_0x144 & 2) {
- local_ae = 0;
- } else {
- local_ae = 0x8000;
- }
- u16 local_ae2 = local_ae ^ 0x8000;
- u16 local_b0;
- if (field_0x144 & 1) {
- local_b0 = 0x8000;
- } else {
- local_b0 = 0;
- }
- drawFrameTexture(field_0x10c, f31, f26, field_0x10c->getWidth(), f30 - f26, local_ae,
- local_b0, local_ae2, local_b0, false);
- bool isset4 = isField0x145Set(4);
- drawFrameTexture(field_0x108, f29, f30, field_0x144 & 8, field_0x144 & 4, isset4);
-
- u16 local_b2;
- if (field_0x144 & 8) {
- local_b2 = 0;
- } else {
- local_b2 = 0x8000;
- }
- u16 local_b22 = local_b2 ^ 0x8000;
- u16 local_b4;
- if (field_0x144 & 4) {
- local_b4 = 0x8000;
- } else {
- local_b4 = 0;
- }
- drawFrameTexture(field_0x108, f29, f26, field_0x108->getWidth(), f30 - f26, local_b2,
- local_b4, local_b22, local_b4, false);
+ u16 r29, r28, r27, r26;
+ r27 = field_0x144 & 0x20 ? u16(0x8000) : u16(0);
+ r29 = r27;
+ r28 = field_0x144 & 0x10 ? u16(0) : u16(0x8000);
+ r26 = r28 ^ 0x8000;
+
+ drawFrameTexture(field_0x104, f27, f28, f31 - f27, field_0x104->getHeight(), r29,
+ r28, r27, r26, false);
+ r24 = field_0x145 & 2;
+ drawFrameTexture(field_0x10c, f31, f30, field_0x144 & 2, field_0x144 & 1, r24);
+ r27 = field_0x144 & 2 ? u16(0x8000) : u16(0);
+ r29 = r27;
+ r28 = field_0x144 & 1 ? u16(0) : u16(0x8000);
+ r26 = r28 ^ 0x8000;
+ drawFrameTexture(field_0x10c, f27, f30, f31 - f27, field_0x10c->getHeight(), r29,
+ r28, r27, r26, false);
+ r29 = field_0x144 & 2 ? u16(0) : u16(0x8000);
+ r27 = r29 ^ 0x8000;
+ r26 = field_0x144 & 1 ? u16(0x8000) : u16(0);
+ r28 = r26;
+ drawFrameTexture(field_0x10c, f31, f26, field_0x10c->getWidth(), f30 - f26, r29,
+ r28, r27, r26, false);
+ r24 = field_0x145 & 4;
+ drawFrameTexture(field_0x108, f29, f30, field_0x144 & 8, field_0x144 & 4, r24);
+
+ r29 = field_0x144 & 8 ? u16(0) : u16(0x8000);
+ r27 = r29 ^ 0x8000;
+ r26 = field_0x144 & 4 ? u16(0x8000) : u16(0);
+ r28 = r26;
+ drawFrameTexture(field_0x108, f29, f26, field_0x108->getWidth(), f30 - f26, r29,
+ r28, r27, r26, false);
}
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
diff --git a/src/JSystem/J2DGraph/J2DWindowEx.cpp b/src/JSystem/J2DGraph/J2DWindowEx.cpp
index 0d3b3d144f..6b1b6748d2 100644
--- a/src/JSystem/J2DGraph/J2DWindowEx.cpp
+++ b/src/JSystem/J2DGraph/J2DWindowEx.cpp
@@ -81,6 +81,10 @@ J2DWindowEx::J2DWindowEx(J2DPane* param_0, JSURandomInputStream* param_1, u32 pa
setMinSize();
}
+static void dummy(J2DTexGenBlock* block) {
+ block->setTexCoord(0, J2DTexCoord());
+}
+
void J2DWindowEx::setMinSize() {
field_0x140 = 1;
field_0x142 = 1;