mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-11 05:04:40 -04:00
Reorganize library code into libs/ (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
This commit is contained in:
@@ -0,0 +1,843 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DAnimation.h"
|
||||
#include "JSystem/J2DGraph/J2DScreen.h"
|
||||
#include "JSystem/J3DGraphBase/J3DTexture.h"
|
||||
#include "JSystem/J3DGraphBase/J3DTransform.h"
|
||||
#include "JSystem/JUtility/JUTPalette.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
#include <os.h>
|
||||
|
||||
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, ¶m_2[0], ¶m_2[1], ¶m_2[2], ¶m_2[3], ¶m_2[4], ¶m_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, ¶m_2[0], ¶m_2[1], ¶m_2[3], ¶m_2[4], ¶m_2[5], ¶m_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];
|
||||
u32 maxFrame = xPart->mScaleMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mScale.x = mScaleValues[xPart->mScaleOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mScale.x = mScaleValues[(xPart->mScaleOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mScale.x = mScaleValues[(xPart->mScaleOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = yPart->mScaleMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mScale.y = mScaleValues[yPart->mScaleOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mScale.y = mScaleValues[(yPart->mScaleOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mScale.y = mScaleValues[(yPart->mScaleOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = zPart->mScaleMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mScale.z = mScaleValues[zPart->mScaleOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mScale.z = mScaleValues[(zPart->mScaleOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mScale.z = mScaleValues[(zPart->mScaleOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = xPart->mRotationMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mRotation.x = mRotationValues[xPart->mRotationOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mRotation.x = mRotationValues[(xPart->mRotationOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mRotation.x = mRotationValues[(xPart->mRotationOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = yPart->mRotationMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mRotation.y = mRotationValues[yPart->mRotationOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mRotation.y = mRotationValues[(yPart->mRotationOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mRotation.y = mRotationValues[(yPart->mRotationOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = zPart->mRotationMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mRotation.z = mRotationValues[zPart->mRotationOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mRotation.z = mRotationValues[(zPart->mRotationOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mRotation.z = mRotationValues[(zPart->mRotationOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = xPart->mTranslateMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mTranslate.x = mTranslateValues[xPart->mTranslateOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mTranslate.x = mTranslateValues[(xPart->mTranslateOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mTranslate.x = mTranslateValues[(xPart->mTranslateOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = yPart->mTranslateMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mTranslate.y = mTranslateValues[yPart->mTranslateOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mTranslate.y = mTranslateValues[(yPart->mTranslateOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
transformInfo->mTranslate.y = mTranslateValues[(yPart->mTranslateOffset + (int)mFrame)];
|
||||
}
|
||||
maxFrame = zPart->mTranslateMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
transformInfo->mTranslate.z = mTranslateValues[zPart->mTranslateOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
transformInfo->mTranslate.z = mTranslateValues[(zPart->mTranslateOffset + (maxFrame - 1))];
|
||||
} else {
|
||||
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];
|
||||
J3DAnmTransformKeyTable* zInf = &mInfoTable[idx + 2];
|
||||
switch (xInf->mScaleInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mScale.x = 1;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mScale.x = mScaleValues[xInf->mScaleInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
transformInfo->mScale.x = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &xInf->mScaleInfo, &mScaleValues[xInf->mScaleInfo.mOffset]);
|
||||
}
|
||||
switch (yInf->mScaleInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mScale.y = 1;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mScale.y = mScaleValues[yInf->mScaleInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
transformInfo->mScale.y = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &yInf->mScaleInfo, &mScaleValues[yInf->mScaleInfo.mOffset]);
|
||||
}
|
||||
switch (zInf->mScaleInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mScale.z = 1;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mScale.z = mScaleValues[zInf->mScaleInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
transformInfo->mScale.z = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &zInf->mScaleInfo, &mScaleValues[zInf->mScaleInfo.mOffset]);
|
||||
}
|
||||
switch (xInf->mRotationInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mRotation.x = 0;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mRotation.x = mRotationValues[xInf->mRotationInfo.mOffset] << field_0x24;
|
||||
break;
|
||||
default:
|
||||
transformInfo->mRotation.x =
|
||||
static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
|
||||
param_0, &xInf->mRotationInfo, &mRotationValues[xInf->mRotationInfo.mOffset]))
|
||||
<< field_0x24;
|
||||
}
|
||||
switch (yInf->mRotationInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mRotation.y = 0;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mRotation.y = mRotationValues[yInf->mRotationInfo.mOffset] << field_0x24;
|
||||
break;
|
||||
default:
|
||||
transformInfo->mRotation.y =
|
||||
static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
|
||||
param_0, &yInf->mRotationInfo, &mRotationValues[yInf->mRotationInfo.mOffset]))
|
||||
<< field_0x24;
|
||||
}
|
||||
switch (zInf->mRotationInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mRotation.z = 0;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mRotation.z = mRotationValues[zInf->mRotationInfo.mOffset] << field_0x24;
|
||||
break;
|
||||
default:
|
||||
transformInfo->mRotation.z =
|
||||
static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
|
||||
param_0, &zInf->mRotationInfo, &mRotationValues[zInf->mRotationInfo.mOffset]))
|
||||
<< field_0x24;
|
||||
}
|
||||
switch (xInf->mTranslateInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mTranslate.x = 0;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mTranslate.x = mTranslateValues[xInf->mTranslateInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
transformInfo->mTranslate.x = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &xInf->mTranslateInfo, &mTranslateValues[xInf->mTranslateInfo.mOffset]);
|
||||
}
|
||||
switch (yInf->mTranslateInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mTranslate.y = 0;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mTranslate.y = mTranslateValues[yInf->mTranslateInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
transformInfo->mTranslate.y = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &yInf->mTranslateInfo, &mTranslateValues[yInf->mTranslateInfo.mOffset]);
|
||||
}
|
||||
switch (zInf->mTranslateInfo.mMaxFrame) {
|
||||
case 0:
|
||||
transformInfo->mTranslate.z = 0;
|
||||
break;
|
||||
case 1:
|
||||
transformInfo->mTranslate.z = mTranslateValues[zInf->mTranslateInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
transformInfo->mTranslate.z = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &zInf->mTranslateInfo, &mTranslateValues[zInf->mTranslateInfo.mOffset]);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DAnmColor::searchUpdateMaterialID(J2DScreen* pScreen) {
|
||||
if (pScreen != NULL && pScreen->mNameTable != NULL) {
|
||||
for (u16 entry = 0; entry < this->getUpdateMaterialNum(); entry++) {
|
||||
s32 idx = pScreen->mNameTable->getIndex(this->field_0x20.getName(entry));
|
||||
if (idx != -1) {
|
||||
mUpdateMaterialID[entry] = idx;
|
||||
} else {
|
||||
mUpdateMaterialID[entry] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (mFrame < 0) {
|
||||
pColor->r = mRValues[info->mROffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->r = mRValues[info->mROffset + (maxFrame - 1)];
|
||||
} else {
|
||||
pColor->r = mRValues[info->mROffset + (int)mFrame];
|
||||
}
|
||||
maxFrame = info->mGMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
pColor->g = mGValues[info->mGOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->g = mGValues[info->mGOffset + (maxFrame - 1)];
|
||||
} else {
|
||||
pColor->g = mGValues[info->mGOffset + (int)mFrame];
|
||||
}
|
||||
maxFrame = info->mBMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
pColor->b = mBValues[info->mBOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->b = mBValues[info->mBOffset + (maxFrame - 1)];
|
||||
} else {
|
||||
pColor->b = mBValues[info->mBOffset + (int)mFrame];
|
||||
}
|
||||
maxFrame = info->mAMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
pColor->a = mAValues[info->mAOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->a = mAValues[info->mAOffset + (maxFrame - 1)];
|
||||
} else {
|
||||
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) {
|
||||
case 0:
|
||||
pColor->r = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->r = mRValues[info->mRInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRInfo,
|
||||
&mRValues[info->mRInfo.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->r = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->r = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->r);
|
||||
}
|
||||
}
|
||||
switch (info->mGInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->g = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->g = mGValues[info->mGInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGInfo,
|
||||
&mGValues[info->mGInfo.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->g = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->g = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->g);
|
||||
}
|
||||
}
|
||||
switch (info->mBInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->b = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->b = mBValues[info->mBInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBInfo,
|
||||
&mBValues[info->mBInfo.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->b = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->b = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->b);
|
||||
}
|
||||
}
|
||||
switch (info->mAInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->a = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->a = mAValues[info->mAInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mAInfo,
|
||||
&mAValues[info->mAInfo.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->a = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->a = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (mFrame < 0) {
|
||||
pColor->r = mRValues[info->mROffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->r = mRValues[info->mROffset + (maxFrame - 1)];
|
||||
} else {
|
||||
pColor->r = mRValues[info->mROffset + (int)mFrame];
|
||||
}
|
||||
maxFrame = info->mGMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
pColor->g = mGValues[info->mGOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->g = mGValues[info->mGOffset + (maxFrame - 1)];
|
||||
} else {
|
||||
pColor->g = mGValues[info->mGOffset + (int)mFrame];
|
||||
}
|
||||
maxFrame = info->mBMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
pColor->b = mBValues[info->mBOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->b = mBValues[info->mBOffset + (maxFrame - 1)];
|
||||
} else {
|
||||
pColor->b = mBValues[info->mBOffset + (int)mFrame];
|
||||
}
|
||||
maxFrame = info->mAMaxFrame;
|
||||
if (mFrame < 0) {
|
||||
pColor->a = mAValues[info->mAOffset];
|
||||
} else if (mFrame >= maxFrame) {
|
||||
pColor->a = mAValues[info->mAOffset + (maxFrame - 1)];
|
||||
} else {
|
||||
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) {
|
||||
case 0:
|
||||
pColor->r = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->r = mRValues[info->mRInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRInfo,
|
||||
&mRValues[info->mRInfo.mOffset]);
|
||||
if ((val <= 0)) {
|
||||
pColor->r = 0;
|
||||
} else if (val <= 255) {
|
||||
OSf32tou8(&val, &pColor->r);
|
||||
} else {
|
||||
pColor->r = 255;
|
||||
}
|
||||
}
|
||||
switch (info->mGInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->g = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->g = mGValues[info->mGInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGInfo,
|
||||
&mGValues[info->mGInfo.mOffset]);
|
||||
if (val <= 0) {
|
||||
pColor->g = 0;
|
||||
} else if (val <= 255) {
|
||||
OSf32tou8(&val, &pColor->g);
|
||||
} else {
|
||||
pColor->g = 255;
|
||||
}
|
||||
}
|
||||
switch (info->mBInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->b = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->b = mBValues[info->mBInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBInfo,
|
||||
&mBValues[info->mBInfo.mOffset]);
|
||||
if (val <= 0) {
|
||||
pColor->b = 0;
|
||||
} else if (val <= 255) {
|
||||
OSf32tou8(&val, &pColor->b);
|
||||
} else {
|
||||
pColor->b = 255;
|
||||
}
|
||||
}
|
||||
switch (info->mAInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->a = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->a = mAValues[info->mAInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mAInfo,
|
||||
&mAValues[info->mAInfo.mOffset]);
|
||||
if (val <= 0) {
|
||||
pColor->a = 0;
|
||||
} else if (val <= 255) {
|
||||
OSf32tou8(&val, &pColor->a);
|
||||
} else {
|
||||
pColor->a = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
J3DAnmTransformKeyTable* zInf = &mInfoTable[idx + 2];
|
||||
switch (xInf->mScaleInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pInfo->mScaleX = 1;
|
||||
break;
|
||||
case 1:
|
||||
pInfo->mScaleX = mScaleValues[xInf->mScaleInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
pInfo->mScaleX = J2DGetKeyFrameInterpolation<f32>(param_0, &xInf->mScaleInfo,
|
||||
&mScaleValues[xInf->mScaleInfo.mOffset]);
|
||||
}
|
||||
switch (yInf->mScaleInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pInfo->mScaleY = 1;
|
||||
break;
|
||||
case 1:
|
||||
pInfo->mScaleY = mScaleValues[yInf->mScaleInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
pInfo->mScaleY = J2DGetKeyFrameInterpolation<f32>(param_0, &yInf->mScaleInfo,
|
||||
&mScaleValues[yInf->mScaleInfo.mOffset]);
|
||||
}
|
||||
switch (zInf->mRotationInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pInfo->mRotation = 0;
|
||||
break;
|
||||
case 1:
|
||||
pInfo->mRotation = mRotationValues[zInf->mRotationInfo.mOffset] << field_0x10;
|
||||
break;
|
||||
default:
|
||||
pInfo->mRotation =
|
||||
static_cast<s32>(J2DGetKeyFrameInterpolation<s16>(
|
||||
param_0, &zInf->mRotationInfo, &mRotationValues[zInf->mRotationInfo.mOffset]))
|
||||
<< field_0x10;
|
||||
}
|
||||
switch (xInf->mTranslateInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pInfo->mTranslationX = 0;
|
||||
break;
|
||||
case 1:
|
||||
pInfo->mTranslationX = mTranslationValues[xInf->mTranslateInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
pInfo->mTranslationX = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &xInf->mTranslateInfo, &mTranslationValues[xInf->mTranslateInfo.mOffset]);
|
||||
}
|
||||
switch (yInf->mTranslateInfo.mMaxFrame) {
|
||||
case 0:
|
||||
pInfo->mTranslationY = 0;
|
||||
break;
|
||||
case 1:
|
||||
pInfo->mTranslationY = mTranslationValues[yInf->mTranslateInfo.mOffset];
|
||||
break;
|
||||
default:
|
||||
pInfo->mTranslationY = J2DGetKeyFrameInterpolation<f32>(
|
||||
param_0, &yInf->mTranslateInfo, &mTranslationValues[yInf->mTranslateInfo.mOffset]);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DAnmTextureSRTKey::searchUpdateMaterialID(J2DScreen* pScreen) {
|
||||
if (pScreen != NULL && pScreen->mNameTable != NULL) {
|
||||
for (u16 entry = 0; entry < this->getUpdateMaterialNum(); entry++) {
|
||||
s32 idx = pScreen->mNameTable->getIndex(field_0x34.getName(entry));
|
||||
if (idx != -1) {
|
||||
mUpdateMaterialID[entry] = idx;
|
||||
} else {
|
||||
mUpdateMaterialID[entry] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DAnmTexPattern::searchUpdateMaterialID(J2DScreen* pScreen) {
|
||||
if (pScreen != NULL && pScreen->mNameTable != NULL && pScreen->mTexRes != NULL) {
|
||||
for (u16 entry = 0; entry < this->getUpdateMaterialNum(); entry++) {
|
||||
s32 idx = pScreen->mNameTable->getIndex(field_0x20.getName(entry));
|
||||
if (idx != -1) {
|
||||
mUpdateMaterialID[entry] = idx;
|
||||
} else {
|
||||
mUpdateMaterialID[entry] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
delete[] mTIMGPtrArray;
|
||||
mTIMGPtrArray = new J2DAnmTexPatternTIMGPointer[pScreen->mTexRes->mCount];
|
||||
if (mTIMGPtrArray != NULL) {
|
||||
JUTResReference resRef;
|
||||
for (u16 i = 0; i < pScreen->mTexRes->mCount; i++) {
|
||||
char* var1 = pScreen->mTexRes->getResReference(i);
|
||||
ResTIMG* var2 = NULL;
|
||||
if (var1 != NULL) {
|
||||
var2 = (ResTIMG*)resRef.getResource(var1, 'TIMG', NULL);
|
||||
if (var2 == NULL && J2DScreen::getDataManage() != NULL) {
|
||||
var2 =
|
||||
(ResTIMG*)J2DScreen::getDataManage()->get(pScreen->mTexRes->getName(i));
|
||||
}
|
||||
}
|
||||
mTIMGPtrArray[i].mRes = var2;
|
||||
if (var2 != NULL && var2->indexTexture) {
|
||||
mTIMGPtrArray[i].mPalette = new JUTPalette(
|
||||
GX_TLUT0,
|
||||
GXTlutFmt(var2->colorFormat),
|
||||
JUTTransparency(var2->alphaEnabled),
|
||||
var2->numColors,
|
||||
((u8*)var2) + var2->paletteOffset
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DAnmTexPattern::getTexNo(u16 param_0, u16* pTexNo) const {
|
||||
u16 maxFrame = mAnmTable[param_0].mMaxFrame;
|
||||
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 (mFrame >= maxFrame) {
|
||||
*pTexNo = mValues[mAnmTable[param_0].mOffset + (maxFrame - 1)];
|
||||
} else {
|
||||
*pTexNo = mValues[mAnmTable[param_0].mOffset + (int)mFrame];
|
||||
}
|
||||
}
|
||||
|
||||
ResTIMG* J2DAnmTexPattern::getResTIMG(u16 param_0) const {
|
||||
if (mTIMGPtrArray == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
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 (mFrame >= maxFrame) {
|
||||
*pOut = mValues[mTable[param_0]._2 + (maxFrame - 1)];
|
||||
} else {
|
||||
*pOut = mValues[mTable[param_0]._2 + (int)mFrame];
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
case 0:
|
||||
pColor->r = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->r = mCRValues[info->mRTable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRTable,
|
||||
&mCRValues[info->mRTable.mOffset]);
|
||||
if (val < -0x400) {
|
||||
pColor->r = -0x400;
|
||||
} else if (val > 0x3FF) {
|
||||
pColor->r = 0x3FF;
|
||||
} else {
|
||||
OSf32tos16(&val, &pColor->r);
|
||||
}
|
||||
}
|
||||
switch (info->mGTable.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->g = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->g = mCGValues[info->mGTable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGTable,
|
||||
&mCGValues[info->mGTable.mOffset]);
|
||||
if (val < -0x400) {
|
||||
pColor->g = -0x400;
|
||||
} else if (val > 0x3FF) {
|
||||
pColor->g = 0x3FF;
|
||||
} else {
|
||||
OSf32tos16(&val, &pColor->g);
|
||||
}
|
||||
}
|
||||
switch (info->mBTable.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->b = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->b = mCBValues[info->mBTable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBTable,
|
||||
&mCBValues[info->mBTable.mOffset]);
|
||||
if (val < -0x400) {
|
||||
pColor->b = -0x400;
|
||||
} else if (val > 0x3FF) {
|
||||
pColor->b = 0x3FF;
|
||||
} else {
|
||||
OSf32tos16(&val, &pColor->b);
|
||||
}
|
||||
}
|
||||
switch (info->mATable.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->a = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->a = mCAValues[info->mATable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mATable,
|
||||
&mCAValues[info->mATable.mOffset]);
|
||||
if (val < -0x400) {
|
||||
pColor->a = -0x400;
|
||||
} else if (val > 0x3FF) {
|
||||
pColor->a = 0x3FF;
|
||||
} else {
|
||||
OSf32tos16(&val, &pColor->a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
case 0:
|
||||
pColor->r = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->r = mKRValues[info->mRTable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mRTable,
|
||||
&mKRValues[info->mRTable.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->r = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->r = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->r);
|
||||
}
|
||||
}
|
||||
switch (info->mGTable.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->g = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->g = mKGValues[info->mGTable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mGTable,
|
||||
&mKGValues[info->mGTable.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->g = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->g = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->g);
|
||||
}
|
||||
}
|
||||
switch (info->mBTable.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->b = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->b = mKBValues[info->mBTable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mBTable,
|
||||
&mKBValues[info->mBTable.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->b = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->b = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->b);
|
||||
}
|
||||
}
|
||||
switch (info->mATable.mMaxFrame) {
|
||||
case 0:
|
||||
pColor->a = 0;
|
||||
break;
|
||||
case 1:
|
||||
pColor->a = mKAValues[info->mATable.mOffset];
|
||||
break;
|
||||
default:
|
||||
val = J2DGetKeyFrameInterpolation<s16>(mFrame, &info->mATable,
|
||||
&mKAValues[info->mATable.mOffset]);
|
||||
if (val < 0) {
|
||||
pColor->a = 0;
|
||||
} else if (val > 255) {
|
||||
pColor->a = 255;
|
||||
} else {
|
||||
OSf32tou8(&val, &pColor->a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DAnmTevRegKey::searchUpdateMaterialID(J2DScreen* pScreen) {
|
||||
if (pScreen != NULL && pScreen->mNameTable != NULL) {
|
||||
for (u16 i = 0; i < getCRegUpdateMaterialNum(); i++) {
|
||||
s32 idx = pScreen->mNameTable->getIndex(mCRegNameTab.getName(i));
|
||||
if (idx != -1) {
|
||||
mCRegUpdateMaterialID[i] = idx;
|
||||
} else {
|
||||
mCRegUpdateMaterialID[i] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
for (u16 i = 0; i < getKRegUpdateMaterialNum(); i++) {
|
||||
s32 idx = pScreen->mNameTable->getIndex(mKRegNameTab.getName(i));
|
||||
if (idx != -1) {
|
||||
mKRegUpdateMaterialID[i] = idx;
|
||||
} else {
|
||||
mKRegUpdateMaterialID[i] = 0xFFFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,542 @@
|
||||
//
|
||||
// J2DAnmLoader
|
||||
//
|
||||
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DAnmLoader.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
|
||||
J2DAnmBase* J2DAnmLoaderDataBase::load(void const* p_data) {
|
||||
const J3DAnmDataHeader* hdr = (const J3DAnmDataHeader*)p_data;
|
||||
J3D_PANIC(38, p_data, "Error : null pointer.");
|
||||
|
||||
if (p_data == NULL) {
|
||||
return NULL;
|
||||
} else if (hdr->mMagic == 'J3D1') {
|
||||
switch (hdr->mType) {
|
||||
case 'bck1': {
|
||||
J2DAnmKeyLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmTransformKey();
|
||||
return (J2DAnmBase*)loader.load(p_data);
|
||||
break;
|
||||
}
|
||||
case 'bpk1': {
|
||||
J2DAnmKeyLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmColorKey();
|
||||
return (J2DAnmBase*)loader.load(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;
|
||||
loader.mpResource = new J2DAnmTextureSRTKey();
|
||||
return (J2DAnmBase*)loader.load(p_data);
|
||||
break;
|
||||
}
|
||||
case 'brk1': {
|
||||
J2DAnmKeyLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmTevRegKey();
|
||||
return (J2DAnmBase*)loader.load(p_data);
|
||||
break;
|
||||
}
|
||||
case 'bxk1': {
|
||||
J2DAnmKeyLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmVtxColorKey();
|
||||
return (J2DAnmBase*)loader.load(p_data);
|
||||
break;
|
||||
}
|
||||
case 'bca1': {
|
||||
J2DAnmFullLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmTransformFull();
|
||||
return (J2DAnmBase*)loader.load(p_data);
|
||||
break;
|
||||
}
|
||||
case 'bpa1': {
|
||||
J2DAnmFullLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmColorFull();
|
||||
return (J2DAnmBase*)loader.load(p_data);
|
||||
break;
|
||||
}
|
||||
case 'btp1': {
|
||||
J2DAnmFullLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmTexPattern();
|
||||
return (J2DAnmBase*)loader.load(p_data);
|
||||
}
|
||||
case 'bva1': {
|
||||
J2DAnmFullLoader_v15 loader;
|
||||
loader.mpResource = new J2DAnmVisibilityFull();
|
||||
return (J2DAnmBase*)loader.load(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;
|
||||
}
|
||||
} 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;
|
||||
|
||||
for (s32 i = 0; i < hdr->mCount; i++) {
|
||||
switch (dataPtr->mType) {
|
||||
case 'ANK1':
|
||||
readAnmTransform((J3DAnmTransformKeyData*)dataPtr);
|
||||
break;
|
||||
case 'PAK1':
|
||||
readAnmColor((J3DAnmColorKeyData*)dataPtr);
|
||||
break;
|
||||
case 'TTK1':
|
||||
readAnmTextureSRT((J3DAnmTextureSRTKeyData*)dataPtr);
|
||||
break;
|
||||
case 'VCK1':
|
||||
readAnmVtxColor((J3DAnmVtxColorKeyData*)dataPtr);
|
||||
break;
|
||||
case 'TRK1':
|
||||
readAnmTevReg((J3DAnmTevRegKeyData*)dataPtr);
|
||||
break;
|
||||
default:
|
||||
OS_REPORT("Unknown data block\n");
|
||||
break;
|
||||
}
|
||||
dataPtr = (J3DAnmDataBlockHeader*)((s32)dataPtr + dataPtr->mNextOffset);
|
||||
}
|
||||
|
||||
return mpResource;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
for (s32 i = 0; i < hdr->mCount; i++) {
|
||||
switch (dataPtr->mType) {
|
||||
case 'ANK1':
|
||||
if (p_anm->getKind() == KIND_TRANSFORM) {
|
||||
setAnmTransform((J2DAnmTransformKey*)p_anm, (J3DAnmTransformKeyData*)dataPtr);
|
||||
}
|
||||
break;
|
||||
case 'PAK1':
|
||||
if (p_anm->getKind() == KIND_COLOR) {
|
||||
setAnmColor((J2DAnmColorKey*)p_anm, (J3DAnmColorKeyData*)dataPtr);
|
||||
}
|
||||
break;
|
||||
case 'TTK1':
|
||||
if (p_anm->getKind() == KIND_TEXTURE_SRT) {
|
||||
setAnmTextureSRT((J2DAnmTextureSRTKey*)p_anm,
|
||||
(J3DAnmTextureSRTKeyData*)dataPtr);
|
||||
}
|
||||
break;
|
||||
case 'TRK1':
|
||||
if (p_anm->getKind() == KIND_TEV_REG) {
|
||||
setAnmTevReg((J2DAnmTevRegKey*)p_anm, (J3DAnmTevRegKeyData*)dataPtr);
|
||||
}
|
||||
break;
|
||||
case 'VCK1':
|
||||
if (p_anm->getKind() == KIND_VTX_COLOR) {
|
||||
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) {
|
||||
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;
|
||||
p_anm->field_0x24 = p_data->field_0x9;
|
||||
p_anm->mFrame = 0;
|
||||
p_anm->mInfoTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmTransformKeyTable>(p_data, (void*)p_data->mTableOffset);
|
||||
p_anm->mScaleValues = JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->field_0x18);
|
||||
p_anm->mRotationValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->field_0x1c);
|
||||
p_anm->mTranslateValues =
|
||||
JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->field_0x20);
|
||||
}
|
||||
|
||||
void J2DAnmKeyLoader_v15::readAnmTextureSRT(J3DAnmTextureSRTKeyData const* 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;
|
||||
p_anm->field_0x10 = p_data->field_0x9;
|
||||
p_anm->mFrame = 0;
|
||||
p_anm->mUpdateMaterialNum = p_data->field_0xc;
|
||||
p_anm->field_0x1a = p_data->field_0xe;
|
||||
p_anm->field_0x1c = p_data->field_0x10;
|
||||
p_anm->field_0x1e = p_data->field_0x12;
|
||||
p_anm->mInfoTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmTransformKeyTable>(p_data, (void*)p_data->mTableOffset);
|
||||
p_anm->mUpdateMaterialID = JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mUpdateMatIDOffset);
|
||||
p_anm->field_0x34.setResource(
|
||||
JSUConvertOffsetToPtr<ResNTAB>(p_data, (void*)p_data->mNameTab1Offset));
|
||||
p_anm->mUpdateTexMtxID = JSUConvertOffsetToPtr<u8>(p_data, p_data->mUpdateTexMtxIDOffset);
|
||||
p_anm->field_0x44 = JSUConvertOffsetToPtr<Vec>(p_data, (void*)p_data->unkOffset);
|
||||
p_anm->mScaleValues = JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->mScaleValOffset);
|
||||
p_anm->mRotationValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mRotValOffset);
|
||||
p_anm->mTranslationValues = JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->mTransValOffset);
|
||||
if (p_data->mNameTab2Offset != 0) {
|
||||
p_anm->field_0x68.setResource(
|
||||
JSUConvertOffsetToPtr<ResNTAB>(p_data, (void*)p_data->mNameTab2Offset));
|
||||
}
|
||||
p_anm->field_0x4e = p_data->field_0x34;
|
||||
p_anm->field_0x48 = p_data->field_0x36;
|
||||
p_anm->field_0x4a = p_data->field_0x38;
|
||||
p_anm->field_0x4c = p_data->field_0x3a;
|
||||
p_anm->field_0x5c =
|
||||
JSUConvertOffsetToPtr<J3DAnmTransformKeyTable>(p_data, (void*)p_data->mInfoTable2Offset);
|
||||
p_anm->field_0x64 = JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->field_0x40);
|
||||
p_anm->field_0x60 = JSUConvertOffsetToPtr<u8>(p_data, p_data->field_0x48);
|
||||
p_anm->field_0x78 = JSUConvertOffsetToPtr<Vec>(p_data, (void*)p_data->field_0x4c);
|
||||
p_anm->field_0x50 = JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->field_0x50);
|
||||
p_anm->field_0x54 = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->field_0x54);
|
||||
p_anm->field_0x58 = JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->field_0x58);
|
||||
switch (p_data->field_0x5c) {
|
||||
case 0:
|
||||
p_anm->field_0x7c = 0;
|
||||
break;
|
||||
case 1:
|
||||
p_anm->field_0x7c = 1;
|
||||
break;
|
||||
default:
|
||||
p_anm->field_0x7c = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void J2DAnmKeyLoader_v15::readAnmColor(J3DAnmColorKeyData const* 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;
|
||||
p_anm->mUpdateMaterialNum = p_data->mUpdateMaterialNum;
|
||||
p_anm->field_0x10 = p_data->field_0x10;
|
||||
p_anm->field_0x12 = p_data->field_0x12;
|
||||
p_anm->field_0x14 = p_data->field_0x14;
|
||||
p_anm->field_0x16 = p_data->field_0x16;
|
||||
p_anm->mInfoTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmColorKeyTable>(p_data, (void*)p_data->mTableOffset);
|
||||
p_anm->mRValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mRValOffset);
|
||||
p_anm->mGValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mGValOffset);
|
||||
p_anm->mBValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mBValOffset);
|
||||
p_anm->mAValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mAValOffset);
|
||||
p_anm->mUpdateMaterialID =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mUpdateMaterialIDOffset);
|
||||
p_anm->field_0x20.setResource(
|
||||
JSUConvertOffsetToPtr<ResNTAB>(p_data, (void*)p_data->mNameTabOffset));
|
||||
}
|
||||
|
||||
void J2DAnmKeyLoader_v15::readAnmVtxColor(J3DAnmVtxColorKeyData const* 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;
|
||||
p_anm->mAnmTableNum[0] = p_data->mAnmTableNum[0];
|
||||
p_anm->mAnmTableNum[1] = p_data->mAnmTableNum[1];
|
||||
p_anm->mInfoTable[0] =
|
||||
JSUConvertOffsetToPtr<J3DAnmColorKeyTable>(p_data, (void*)p_data->mTableOffsets[0]);
|
||||
p_anm->mInfoTable[1] =
|
||||
JSUConvertOffsetToPtr<J3DAnmColorKeyTable>(p_data, (void*)p_data->mTableOffsets[1]);
|
||||
p_anm->mVtxColorIndexData[0] = JSUConvertOffsetToPtr<J3DAnmVtxColorIndexData>(
|
||||
p_data, (void*)p_data->mVtxColoIndexDataOffset[0]);
|
||||
p_anm->mVtxColorIndexData[1] = JSUConvertOffsetToPtr<J3DAnmVtxColorIndexData>(
|
||||
p_data, (void*)p_data->mVtxColoIndexDataOffset[1]);
|
||||
p_anm->mVtxColorIndexPointer[0] =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mVtxColoIndexPointerOffset[0]);
|
||||
p_anm->mVtxColorIndexPointer[1] =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mVtxColoIndexPointerOffset[1]);
|
||||
p_anm->mRValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mRValOffset);
|
||||
p_anm->mGValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mGValOffset);
|
||||
p_anm->mBValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mBValOffset);
|
||||
p_anm->mAValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mAValOffset);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
for (s32 i = 0; i < hdr->mCount; i++) {
|
||||
switch (dataPtr->mType) {
|
||||
case 'ANF1':
|
||||
readAnmTransform((J3DAnmTransformFullData*)dataPtr);
|
||||
break;
|
||||
case 'PAF1':
|
||||
readAnmColor((J3DAnmColorFullData*)dataPtr);
|
||||
break;
|
||||
case 'TPT1':
|
||||
readAnmTexPattern((J3DAnmTexPatternFullData*)dataPtr);
|
||||
break;
|
||||
case 'VAF1':
|
||||
readAnmVisibility((J3DAnmVisibilityFullData*)dataPtr);
|
||||
break;
|
||||
case 'VCF1':
|
||||
readAnmVtxColor((J3DAnmVtxColorFullData*)dataPtr);
|
||||
break;
|
||||
default:
|
||||
OS_REPORT("Unknown data block\n");
|
||||
break;
|
||||
}
|
||||
dataPtr = (J3DAnmDataBlockHeader*)((s32)dataPtr + dataPtr->mNextOffset);
|
||||
}
|
||||
return mpResource;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
for (s32 i = 0; i < hdr->mCount; i++) {
|
||||
switch (dataPtr->mType) {
|
||||
case 'ANF1':
|
||||
if (p_anm->getKind() == KIND_TRANSFORM)
|
||||
setAnmTransform((J2DAnmTransformFull*)p_anm,
|
||||
(J3DAnmTransformFullData*)dataPtr);
|
||||
break;
|
||||
case 'PAF1':
|
||||
if (p_anm->getKind() == KIND_COLOR)
|
||||
setAnmColor((J2DAnmColorFull*)p_anm, (J3DAnmColorFullData*)dataPtr);
|
||||
break;
|
||||
case 'TPT1':
|
||||
if (p_anm->getKind() == KIND_TEX_PATTERN)
|
||||
setAnmTexPattern((J2DAnmTexPattern*)p_anm, (J3DAnmTexPatternFullData*)dataPtr);
|
||||
break;
|
||||
case 'VAF1':
|
||||
if (p_anm->getKind() == KIND_VISIBILITY)
|
||||
setAnmVisibility((J2DAnmVisibilityFull*)p_anm,
|
||||
(J3DAnmVisibilityFullData*)dataPtr);
|
||||
break;
|
||||
case 'VCF1':
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
J2DAnmFullLoader_v15::J2DAnmFullLoader_v15() {}
|
||||
|
||||
J2DAnmFullLoader_v15::~J2DAnmFullLoader_v15() {}
|
||||
|
||||
void J2DAnmFullLoader_v15::readAnmTransform(J3DAnmTransformFullData const* 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;
|
||||
p_anm->mFrame = 0;
|
||||
p_anm->mTableInfo =
|
||||
JSUConvertOffsetToPtr<J3DAnmTransformFullTable>(p_data, (void*)p_data->mTableOffset);
|
||||
p_anm->mScaleValues = JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->mScaleValOffset);
|
||||
p_anm->mRotationValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mRotValOffset);
|
||||
p_anm->mTranslateValues = JSUConvertOffsetToPtr<f32>(p_data, (void*)p_data->mTransValOffset);
|
||||
}
|
||||
|
||||
void J2DAnmFullLoader_v15::readAnmColor(J3DAnmColorFullData const* 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;
|
||||
p_anm->mUpdateMaterialNum = p_data->mUpdateMaterialNum;
|
||||
p_anm->mInfoTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmColorFullTable>(p_data, (void*)p_data->mTableOffset);
|
||||
p_anm->mRValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mRValuesOffset);
|
||||
p_anm->mGValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mGValuesOffset);
|
||||
p_anm->mBValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mBValuesOffset);
|
||||
p_anm->mAValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mAValuesOffset);
|
||||
p_anm->mUpdateMaterialID =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mUpdateMaterialIDOffset);
|
||||
p_anm->field_0x20.setResource(
|
||||
JSUConvertOffsetToPtr<ResNTAB>(p_data, (void*)p_data->mNameTabOffset));
|
||||
}
|
||||
|
||||
void J2DAnmFullLoader_v15::readAnmTexPattern(J3DAnmTexPatternFullData const* 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;
|
||||
p_anm->mUpdateMaterialNum = p_data->field_0xc;
|
||||
p_anm->field_0x18 = p_data->field_0xe;
|
||||
p_anm->mAnmTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmTexPatternFullTable>(p_data, (void*)p_data->mTableOffset);
|
||||
p_anm->mValues = JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mValuesOffset);
|
||||
p_anm->mUpdateMaterialID =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mUpdateMaterialIDOffset);
|
||||
p_anm->field_0x20.setResource(
|
||||
JSUConvertOffsetToPtr<ResNTAB>(p_data, (void*)p_data->mNameTabOffset));
|
||||
}
|
||||
|
||||
void J2DAnmKeyLoader_v15::readAnmTevReg(J3DAnmTevRegKeyData const* 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;
|
||||
p_anm->mCRegUpdateMaterialNum = p_data->mCRegUpdateMaterialNum;
|
||||
p_anm->mAnmCRegKeyTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmCRegKeyTable>(p_data, (void*)p_data->mCRegTableOffset);
|
||||
p_anm->mCRegUpdateMaterialID =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mCRegUpdateMaterialIDOffset);
|
||||
p_anm->mCRegNameTab.setResource(
|
||||
JSUConvertOffsetToPtr<ResNTAB>(p_data, (void*)p_data->mCRegNameTabOffset));
|
||||
p_anm->mKRegUpdateMaterialNum = p_data->mKRegUpdateMaterialNum;
|
||||
p_anm->mAnmKRegKeyTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmKRegKeyTable>(p_data, (void*)p_data->mKRegTableOffset);
|
||||
p_anm->mKRegUpdateMaterialID =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mKRegUpdateMaterialIDOffset);
|
||||
p_anm->mKRegNameTab.setResource(
|
||||
JSUConvertOffsetToPtr<ResNTAB>(p_data, (void*)p_data->mKRegNameTabOffset));
|
||||
p_anm->field_0x14 = p_data->field_0x10;
|
||||
p_anm->field_0x16 = p_data->field_0x12;
|
||||
p_anm->field_0x18 = p_data->field_0x14;
|
||||
p_anm->field_0x1a = p_data->field_0x16;
|
||||
p_anm->mCRValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mCRValuesOffset);
|
||||
p_anm->mCGValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mCGValuesOffset);
|
||||
p_anm->mCBValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mCBValuesOffset);
|
||||
p_anm->mCAValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mCAValuesOffset);
|
||||
p_anm->field_0x1c = p_data->field_0x18;
|
||||
p_anm->field_0x1e = p_data->field_0x1a;
|
||||
p_anm->field_0x20 = p_data->field_0x1c;
|
||||
p_anm->field_0x22 = p_data->field_0x1e;
|
||||
p_anm->mKRValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mKRValuesOffset);
|
||||
p_anm->mKGValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mKGValuesOffset);
|
||||
p_anm->mKBValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mKBValuesOffset);
|
||||
p_anm->mKAValues = JSUConvertOffsetToPtr<s16>(p_data, (void*)p_data->mKAValuesOffset);
|
||||
}
|
||||
|
||||
void J2DAnmFullLoader_v15::readAnmVisibility(J3DAnmVisibilityFullData const* 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;
|
||||
p_anm->field_0x10 = p_data->field_0xc;
|
||||
p_anm->field_0x12 = p_data->field_0xe;
|
||||
p_anm->mTable =
|
||||
JSUConvertOffsetToPtr<J3DAnmVisibilityFullTable>(p_data, (void*)p_data->mTableOffset);
|
||||
p_anm->mValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mValuesOffset);
|
||||
}
|
||||
|
||||
void J2DAnmFullLoader_v15::readAnmVtxColor(J3DAnmVtxColorFullData const* 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;
|
||||
p_anm->mAnmTableNum[0] = p_data->mAnmTableNum[0];
|
||||
p_anm->mAnmTableNum[1] = p_data->mAnmTableNum[1];
|
||||
p_anm->mInfoTable[0] =
|
||||
JSUConvertOffsetToPtr<J3DAnmColorFullTable>(p_data, (void*)p_data->mTableOffsets[0]);
|
||||
p_anm->mInfoTable[1] =
|
||||
JSUConvertOffsetToPtr<J3DAnmColorFullTable>(p_data, (void*)p_data->mTableOffsets[1]);
|
||||
p_anm->mVtxColorIndexData[0] = JSUConvertOffsetToPtr<J3DAnmVtxColorIndexData>(
|
||||
p_data, (void*)p_data->mVtxColorIndexDataOffsets[0]);
|
||||
p_anm->mVtxColorIndexData[1] = JSUConvertOffsetToPtr<J3DAnmVtxColorIndexData>(
|
||||
p_data, (void*)p_data->mVtxColorIndexDataOffsets[1]);
|
||||
p_anm->mVtxColorIndexPointer[0] =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mVtxColorIndexPointerOffsets[0]);
|
||||
p_anm->mVtxColorIndexPointer[1] =
|
||||
JSUConvertOffsetToPtr<u16>(p_data, (void*)p_data->mVtxColorIndexPointerOffsets[1]);
|
||||
p_anm->mRValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mRValuesOffset);
|
||||
p_anm->mGValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mGValuesOffset);
|
||||
p_anm->mBValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mBValuesOffset);
|
||||
p_anm->mAValues = JSUConvertOffsetToPtr<u8>(p_data, p_data->mAValuesOffset);
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DGrafContext.h"
|
||||
#include <gx.h>
|
||||
|
||||
J2DGrafContext::J2DGrafContext(f32 x, f32 y, f32 width, f32 height)
|
||||
: mBounds(x, y, x + width, y + height), mScissorBounds(x, y, x + width, y + height) {
|
||||
if (x < 0.0f || y < 0.0f) {
|
||||
OS_REPORT("J2DWarning::ViewPort-Bounds \"Avoid using negative values for left or top.\"\n");
|
||||
}
|
||||
JUtility::TColor color(-1);
|
||||
setColor(color);
|
||||
setLineWidth(6);
|
||||
}
|
||||
|
||||
void J2DGrafContext::setPort() {
|
||||
setScissor();
|
||||
setup2D();
|
||||
|
||||
JGeometry::TBox2<float> bounds(mBounds);
|
||||
|
||||
if (bounds.i.x < 0.0f) {
|
||||
bounds.i.x = 0.0f;
|
||||
}
|
||||
if (bounds.i.y < 0.0f) {
|
||||
bounds.i.y = 0.0f;
|
||||
}
|
||||
GXSetViewport(bounds.i.x, bounds.i.y, bounds.getWidth(), bounds.getHeight(), 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void J2DGrafContext::setup2D() {
|
||||
GXSetNumIndStages(0);
|
||||
for (int i = 0; i < GX_MAX_TEVSTAGE; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetZCompLoc(GX_FALSE);
|
||||
GXSetAlphaCompare(GX_GREATER, 0, GX_AOP_OR, GX_GREATER, 0);
|
||||
GXSetZMode(GX_FALSE, GX_LEQUAL, GX_FALSE);
|
||||
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GXSetNumChans(1);
|
||||
GXSetNumTevStages(1);
|
||||
GXSetNumTexGens(0);
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GXSetCullMode(GX_CULL_NONE);
|
||||
GXLoadPosMtxImm(mPosMtx, 0);
|
||||
Mtx mtx;
|
||||
MTXIdentity(mtx);
|
||||
GXLoadTexMtxImm(mtx, GX_IDENTITY, GX_MTX3x4);
|
||||
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE,
|
||||
GX_AF_NONE);
|
||||
GXSetChanCtrl(GX_COLOR1A1, GX_FALSE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE,
|
||||
GX_AF_NONE);
|
||||
GXSetCurrentMtx(0);
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0xf);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX1, GX_CLR_RGBA, GX_RGBX8, 0xf);
|
||||
GXSetLineWidth(mLineWidth, GX_TO_ZERO);
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_NONE);
|
||||
}
|
||||
|
||||
void J2DGrafContext::setScissor() {
|
||||
JGeometry::TBox2<f32> bounds(0, 0, 1024, 1024);
|
||||
JGeometry::TBox2<f32> curBounds(mScissorBounds);
|
||||
mScissorBounds.intersect(bounds);
|
||||
curBounds.absolute();
|
||||
if (curBounds.intersect(bounds)) {
|
||||
curBounds.i.x = (u32)curBounds.i.x;
|
||||
curBounds.i.y = (u32)curBounds.i.y;
|
||||
curBounds.f.x = ceil(curBounds.f.x);
|
||||
curBounds.f.y = ceil(curBounds.f.y);
|
||||
GXSetScissor(curBounds.i.x, curBounds.i.y, curBounds.getWidth(), curBounds.getHeight());
|
||||
} else {
|
||||
GXSetScissor(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DGrafContext::scissor(JGeometry::TBox2<f32> const& bounds) {
|
||||
mScissorBounds = bounds;
|
||||
}
|
||||
|
||||
void J2DGrafContext::place(JGeometry::TBox2<f32> const& bounds) {
|
||||
if (bounds.i.x < 0.0f || bounds.i.y < 0.0f) {
|
||||
if (mBounds.i.x >= 0.0f && mBounds.i.y >= 0.0f) {
|
||||
OS_REPORT("J2DWarning::ViewPort-Bounds \"Avoid using negative values for left or top.\"\n");
|
||||
}
|
||||
}
|
||||
mBounds = bounds;
|
||||
mScissorBounds = bounds;
|
||||
}
|
||||
|
||||
void J2DGrafContext::setColor(JUtility::TColor colorTL, JUtility::TColor colorTR,
|
||||
JUtility::TColor colorBR, JUtility::TColor colorBL) {
|
||||
mColorTL = colorTL;
|
||||
mColorTR = colorTR;
|
||||
mColorBR = colorBR;
|
||||
mColorBL = colorBL;
|
||||
field_0xb0.mType = GX_BM_BLEND;
|
||||
field_0xb0.mSrcFactor = GX_BL_SRCALPHA;
|
||||
field_0xb0.mDstFactor = GX_BL_INVSRCALPHA;
|
||||
mLinePart.mType = GX_BM_BLEND;
|
||||
mLinePart.mSrcFactor = GX_BL_SRCALPHA;
|
||||
mLinePart.mDstFactor = GX_BL_INVSRCALPHA;
|
||||
mBoxPart.mType = GX_BM_BLEND;
|
||||
mBoxPart.mSrcFactor = GX_BL_SRCALPHA;
|
||||
mBoxPart.mDstFactor = GX_BL_INVSRCALPHA;
|
||||
if ((mColorTL & 0xFF) != 0xFF) {
|
||||
return;
|
||||
}
|
||||
field_0xb0.mType = GX_BM_NONE;
|
||||
field_0xb0.mSrcFactor = GX_BL_ONE;
|
||||
field_0xb0.mDstFactor = GX_BL_ZERO;
|
||||
if ((mColorBR & 0xFF) != 0xFF) {
|
||||
return;
|
||||
}
|
||||
mLinePart.mType = GX_BM_NONE;
|
||||
mLinePart.mSrcFactor = GX_BL_ONE;
|
||||
mLinePart.mDstFactor = GX_BL_ZERO;
|
||||
if ((mColorTR & 0xFF) != 0xFF) {
|
||||
return;
|
||||
}
|
||||
if ((mColorBL & 0xFF) != 0xFF) {
|
||||
return;
|
||||
}
|
||||
mBoxPart.mType = GX_BM_NONE;
|
||||
mBoxPart.mSrcFactor = GX_BL_ONE;
|
||||
mBoxPart.mDstFactor = GX_BL_ZERO;
|
||||
}
|
||||
|
||||
void J2DGrafContext::setLineWidth(u8 lineWidth) {
|
||||
mLineWidth = lineWidth;
|
||||
GXSetLineWidth(mLineWidth, GX_TO_ZERO);
|
||||
}
|
||||
|
||||
void J2DGrafContext::fillBox(JGeometry::TBox2<f32> const& box) {
|
||||
GXSetBlendMode((GXBlendMode)mBoxPart.mType, (GXBlendFactor)mBoxPart.mSrcFactor,
|
||||
(GXBlendFactor)mBoxPart.mDstFactor, GX_LO_SET);
|
||||
GXLoadPosMtxImm(mPosMtx, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
|
||||
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
GXPosition3f32(box.i.x, box.i.y, 0);
|
||||
GXColor1u32(mColorTL);
|
||||
GXPosition3f32(box.f.x, box.i.y, 0);
|
||||
GXColor1u32(mColorTR);
|
||||
GXPosition3f32(box.f.x, box.f.y, 0);
|
||||
GXColor1u32(mColorBL);
|
||||
GXPosition3f32(box.i.x, box.f.y, 0);
|
||||
GXColor1u32(mColorBR);
|
||||
GXEnd();
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
|
||||
}
|
||||
|
||||
void J2DGrafContext::drawFrame(JGeometry::TBox2<f32> const& box) {
|
||||
GXSetBlendMode((GXBlendMode)mBoxPart.mType, (GXBlendFactor)mBoxPart.mSrcFactor,
|
||||
(GXBlendFactor)mBoxPart.mDstFactor, GX_LO_SET);
|
||||
GXLoadPosMtxImm(mPosMtx, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
|
||||
GXBegin(GX_LINESTRIP, GX_VTXFMT0, 5);
|
||||
GXPosition3f32(box.i.x, box.i.y, 0);
|
||||
GXColor1u32(mColorTL);
|
||||
GXPosition3f32(box.f.x, box.i.y, 0);
|
||||
GXColor1u32(mColorTR);
|
||||
GXPosition3f32(box.f.x, box.f.y, 0);
|
||||
GXColor1u32(mColorBL);
|
||||
GXPosition3f32(box.i.x, box.f.y, 0);
|
||||
GXColor1u32(mColorBR);
|
||||
GXPosition3f32(box.i.x, box.i.y, 0);
|
||||
GXColor1u32(mColorTL);
|
||||
GXEnd();
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
|
||||
}
|
||||
|
||||
void J2DGrafContext::line(JGeometry::TVec2<f32> start, JGeometry::TVec2<f32> end) {
|
||||
GXSetBlendMode((GXBlendMode)mLinePart.mType, (GXBlendFactor)mLinePart.mSrcFactor,
|
||||
(GXBlendFactor)mLinePart.mDstFactor, GX_LO_SET);
|
||||
GXLoadPosMtxImm(mPosMtx, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
|
||||
GXBegin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GXPosition3f32(start.x, start.y, 0);
|
||||
GXColor1u32(mColorTL);
|
||||
GXPosition3f32(end.x, end.y, 0);
|
||||
GXColor1u32(mColorBR);
|
||||
GXEnd();
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
|
||||
}
|
||||
|
||||
void J2DGrafContext::lineTo(JGeometry::TVec2<f32> pos) {
|
||||
this->line(mPrevPos, pos);
|
||||
mPrevPos = pos;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DManage.h"
|
||||
#include "JSystem/JSupport/JSUInputStream.h"
|
||||
#include <cstring>
|
||||
|
||||
void* J2DDataManage::get(char const* name) {
|
||||
J2DataManageLink* link;
|
||||
for (link = mList; link != NULL; link = link->mNext) {
|
||||
if (strcmp(link->mName, name) == 0) {
|
||||
return link->mData;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* J2DDataManage::get(JSUInputStream* inputStream) {
|
||||
inputStream->skip(1);
|
||||
u8 nameLen = inputStream->readU8();
|
||||
|
||||
if (nameLen == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char nameBuffer[257];
|
||||
inputStream->read(&nameBuffer, nameLen);
|
||||
nameBuffer[nameLen] = 0;
|
||||
return this->get(nameBuffer);
|
||||
}
|
||||
|
||||
char* J2DResReference::getResReference(u16 idx) const {
|
||||
if (mCount <= idx || idx == 0xFFFF) {
|
||||
return NULL;
|
||||
}
|
||||
u16 offset = mOffsets[idx];
|
||||
return ((char*)this) + offset;
|
||||
}
|
||||
|
||||
char* J2DResReference::getName(u16 idx) const {
|
||||
static char p_name[257];
|
||||
|
||||
char* resRef = (char*)this->getResReference(idx);
|
||||
|
||||
if (resRef == NULL) {
|
||||
p_name[0] = 0;
|
||||
return p_name;
|
||||
} else {
|
||||
switch (resRef[0]) {
|
||||
case 2:
|
||||
case 3:
|
||||
for (s32 i = 0; i < resRef[1]; i++) {
|
||||
p_name[i] = resRef[2 + i];
|
||||
}
|
||||
p_name[resRef[1]] = 0;
|
||||
break;
|
||||
case 4: {
|
||||
s32 tmp = resRef[1];
|
||||
s32 pos = tmp + 1;
|
||||
for (; pos >= 2; pos--) {
|
||||
if (resRef[pos] == '\\' || resRef[pos] == '/') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
s32 i = 0;
|
||||
pos++;
|
||||
for (; pos < resRef[1] + 2; i++, pos++) {
|
||||
p_name[i] = resRef[pos];
|
||||
}
|
||||
p_name[i] = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
p_name[0] = 0;
|
||||
}
|
||||
return p_name;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,324 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DMaterial.h"
|
||||
#include "JSystem/J3DGraphBase/J3DStruct.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JUtility/JUTPalette.h"
|
||||
#include "JSystem/JUtility/JUTTexture.h"
|
||||
|
||||
J2DMaterial::J2DMaterial() {
|
||||
field_0x4 = 0;
|
||||
mIndex = -1;
|
||||
mTevBlock = NULL;
|
||||
mIndBlock = NULL;
|
||||
mAnmPointer = NULL;
|
||||
field_0x8 = 1;
|
||||
mVisible = true;
|
||||
}
|
||||
|
||||
J2DMaterial::~J2DMaterial() {
|
||||
delete mTevBlock;
|
||||
delete mIndBlock;
|
||||
delete mAnmPointer;
|
||||
}
|
||||
|
||||
void J2DMaterial::setGX() {
|
||||
if (mVisible) {
|
||||
getColorBlock()->setGX();
|
||||
getTexGenBlock()->setGX();
|
||||
|
||||
if (getTevBlock() != NULL) {
|
||||
getTevBlock()->setGX();
|
||||
}
|
||||
|
||||
if (getIndBlock() != NULL) {
|
||||
getIndBlock()->setGX();
|
||||
}
|
||||
|
||||
getPEBlock()->setGX();
|
||||
}
|
||||
}
|
||||
|
||||
J2DTevBlock* J2DMaterial::createTevBlock(int block_type, bool noAlign) {
|
||||
J2DTevBlock* block = NULL;
|
||||
|
||||
if (noAlign) {
|
||||
if (block_type <= 1) {
|
||||
block = new J2DTevBlock1();
|
||||
} else if (block_type == 2) {
|
||||
block = new J2DTevBlock2();
|
||||
} else if (block_type <= 4) {
|
||||
block = new J2DTevBlock4();
|
||||
} else if (block_type <= 8) {
|
||||
block = new J2DTevBlock8();
|
||||
} else {
|
||||
block = new J2DTevBlock16();
|
||||
}
|
||||
} else {
|
||||
if (block_type <= 1) {
|
||||
block = new (-4) J2DTevBlock1();
|
||||
} else if (block_type == 2) {
|
||||
block = new (-4) J2DTevBlock2();
|
||||
} else if (block_type <= 4) {
|
||||
block = new (-4) J2DTevBlock4();
|
||||
} else if (block_type <= 8) {
|
||||
block = new (-4) J2DTevBlock8();
|
||||
} else {
|
||||
block = new (-4) J2DTevBlock16();
|
||||
}
|
||||
}
|
||||
ASSERTMSGLINE(101, block, "Error : allocate memory.");
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
J2DIndBlock* J2DMaterial::createIndBlock(int block_type, bool noAlign) {
|
||||
J2DIndBlock* block = NULL;
|
||||
|
||||
if (noAlign) {
|
||||
if (block_type != 0) {
|
||||
block = new J2DIndBlockFull();
|
||||
} else {
|
||||
block = new J2DIndBlockNull();
|
||||
}
|
||||
} else {
|
||||
if (block_type != 0) {
|
||||
block = new (-4) J2DIndBlockFull();
|
||||
} else {
|
||||
block = new (-4) J2DIndBlockNull();
|
||||
}
|
||||
}
|
||||
ASSERTMSGLINE(133, block, "Error : allocate memory.");
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
J2DMaterial::J2DMaterialAnmPointer::J2DMaterialAnmPointer() {
|
||||
mColorAnm = NULL;
|
||||
mColorIds = -1;
|
||||
mSRTAnm = NULL;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mSRTIds[i] = -1;
|
||||
}
|
||||
mPatternAnm = NULL;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mPatternIds[i] = -1;
|
||||
}
|
||||
mTevAnm = NULL;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mTevCRegIds[i] = -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mTevKRegIds[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void J2DMaterial::makeAnmPointer() {
|
||||
int r29;
|
||||
int r28;
|
||||
if (mAnmPointer == NULL) {
|
||||
mAnmPointer = new J2DMaterialAnmPointer();
|
||||
r29 = 1;
|
||||
if (mAnmPointer == NULL) {
|
||||
OS_PANIC(171, "Error : allocate memory.");
|
||||
r28 = 0;
|
||||
if (!r28) {
|
||||
r29 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DMaterial::setAnimation(J2DAnmColor* anm) {
|
||||
if (anm != NULL || mAnmPointer != NULL) {
|
||||
makeAnmPointer();
|
||||
mAnmPointer->mColorAnm = anm;
|
||||
mAnmPointer->mColorIds = -1;
|
||||
|
||||
if (anm != NULL) {
|
||||
u16 matNum = anm->getUpdateMaterialNum();
|
||||
u16 index = getIndex();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
if (index == anm->getUpdateMaterialID(i)) {
|
||||
mAnmPointer->mColorIds = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DMaterial::setAnimation(J2DAnmTextureSRTKey* anm) {
|
||||
if (anm != NULL || mAnmPointer != NULL) {
|
||||
makeAnmPointer();
|
||||
mAnmPointer->mSRTAnm = anm;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mAnmPointer->mSRTIds[i] = -1;
|
||||
}
|
||||
|
||||
if (anm != NULL) {
|
||||
u16 matNum = anm->getUpdateMaterialNum();
|
||||
u16 index = getIndex();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
if (index == anm->getUpdateMaterialID(i)) {
|
||||
u8 mtxID = anm->getUpdateTexMtxID(i);
|
||||
mAnmPointer->mSRTIds[mtxID] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DMaterial::setAnimation(J2DAnmTexPattern* anm) {
|
||||
if (anm != NULL || mAnmPointer != NULL) {
|
||||
makeAnmPointer();
|
||||
mAnmPointer->mPatternAnm = anm;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mAnmPointer->mPatternIds[i] = -1;
|
||||
}
|
||||
|
||||
if (anm != NULL) {
|
||||
u16 matNum = anm->getUpdateMaterialNum();
|
||||
u16 index = getIndex();
|
||||
J3DAnmTexPatternFullTable* anmTbl = anm->getAnmTable();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
if (index == anm->getUpdateMaterialID(i)) {
|
||||
mAnmPointer->mPatternIds[anmTbl[i].mTexNo] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DMaterial::setAnimation(J2DAnmTevRegKey* anm) {
|
||||
if (anm != NULL || mAnmPointer != NULL) {
|
||||
makeAnmPointer();
|
||||
mAnmPointer->mTevAnm = anm;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mAnmPointer->mTevCRegIds[i] = -1;
|
||||
}
|
||||
|
||||
if (anm != NULL) {
|
||||
u16 matNum = anm->getCRegUpdateMaterialNum();
|
||||
u16 index = getIndex();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
if (index == anm->getCRegUpdateMaterialID(i)) {
|
||||
J3DAnmCRegKeyTable* anmTbl = anm->getAnmCRegKeyTable();
|
||||
mAnmPointer->mTevCRegIds[anmTbl[i].mColorId] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mAnmPointer->mTevKRegIds[i] = -1;
|
||||
}
|
||||
|
||||
if (anm != NULL) {
|
||||
u16 matNum = anm->getKRegUpdateMaterialNum();
|
||||
u16 index = getIndex();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
if (index == anm->getKRegUpdateMaterialID(i)) {
|
||||
J3DAnmKRegKeyTable* anmTbl = anm->getAnmKRegKeyTable();
|
||||
mAnmPointer->mTevKRegIds[anmTbl[i].mColorId] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DMaterial::animation() {
|
||||
if (!mAnmPointer) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAnmPointer->mColorAnm && mAnmPointer->mColorIds != 0xFFFF) {
|
||||
GXColor color;
|
||||
mAnmPointer->mColorAnm->getColor(mAnmPointer->mColorIds, &color);
|
||||
getColorBlock()->setMatColor(0, color);
|
||||
}
|
||||
|
||||
if (mAnmPointer->mSRTAnm) {
|
||||
for (u8 i = 0; i < 8; i++) {
|
||||
if (mAnmPointer->mSRTIds[i] != 0xFFFF) {
|
||||
J3DTextureSRTInfo info3D;
|
||||
mAnmPointer->mSRTAnm->getTransform(mAnmPointer->mSRTIds[i], &info3D);
|
||||
J2DTextureSRTInfo info2D;
|
||||
info2D.mScaleX = info3D.mScaleX;
|
||||
info2D.mScaleY = info3D.mScaleY;
|
||||
info2D.mRotationDeg = (360.0f * f32((u16)info3D.mRotation)) / 65535.0f;
|
||||
info2D.mTranslationX = info3D.mTranslationX;
|
||||
info2D.mTranslationY = info3D.mTranslationY;
|
||||
|
||||
J2DTexMtx texMtx;
|
||||
getTexGenBlock()->getTexMtx(i, texMtx);
|
||||
|
||||
texMtx.getTexMtxInfo().mTexSRTInfo = info2D;
|
||||
getTexGenBlock()->setTexMtx(i, texMtx);
|
||||
getTexGenBlock()->getTexCoord(i).setTexGenMtx(i * 3 + 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getTevBlock() && mAnmPointer->mPatternAnm) {
|
||||
for (u8 i = 0; i < 8; i++) {
|
||||
if (mAnmPointer->mPatternIds[i] != 0xFFFF) {
|
||||
JUTTexture* texture = getTevBlock()->getTexture(i);
|
||||
if (!texture) {
|
||||
continue;
|
||||
}
|
||||
|
||||
u16 idx = mAnmPointer->mPatternIds[i];
|
||||
u16 texNo;
|
||||
mAnmPointer->mPatternAnm->getTexNo(idx, &texNo);
|
||||
getTevBlock()->setTexNo(i, texNo);
|
||||
|
||||
ResTIMG* img = mAnmPointer->mPatternAnm->getResTIMG(idx);
|
||||
if (texture->getTexInfo() != img) {
|
||||
JUTPalette* palette = NULL;
|
||||
GXTlut tlut = GX_TLUT0;
|
||||
if (img->indexTexture != 0) {
|
||||
palette = mAnmPointer->mPatternAnm->getPalette(idx);
|
||||
if (palette->getNumColors() > 256) {
|
||||
tlut = (GXTlut)(i % 4 + 16);
|
||||
} else {
|
||||
tlut = (GXTlut)i;
|
||||
}
|
||||
}
|
||||
|
||||
texture->storeTIMG(img, palette, tlut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getTevBlock() && mAnmPointer->mTevAnm) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (mAnmPointer->mTevCRegIds[i] != 0xFFFF) {
|
||||
J2DGXColorS10 color;
|
||||
mAnmPointer->mTevAnm->getTevColorReg(mAnmPointer->mTevCRegIds[i], &color);
|
||||
getTevBlock()->setTevColor(i, color);
|
||||
}
|
||||
}
|
||||
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
u16 idx = mAnmPointer->mTevKRegIds[i];
|
||||
if (idx != 0xFFFF) {
|
||||
JUtility::TColor konstColor;
|
||||
mAnmPointer->mTevAnm->getTevKonstReg(idx, &konstColor);
|
||||
getTevBlock()->setTevKColor(i, konstColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DMaterialFactory.h"
|
||||
#include "JSystem/J2DGraph/J2DMaterial.h"
|
||||
#include "JSystem/J2DGraph/J2DScreen.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
#include <cstring>
|
||||
#include <types.h>
|
||||
|
||||
J2DMaterialFactory::J2DMaterialFactory(J2DMaterialBlock const& param_0) {
|
||||
field_0x0 = param_0.field_0x8;
|
||||
field_0x4 = JSUConvertOffsetToPtr<J2DMaterialInitData>(¶m_0, (void*)param_0.field_0xc);
|
||||
field_0x8 = JSUConvertOffsetToPtr<u16>(¶m_0, (void*)param_0.field_0x10);
|
||||
if (param_0.field_0x18 && param_0.field_0x18 - param_0.field_0x14 > 4) {
|
||||
field_0xc = JSUConvertOffsetToPtr<J2DIndInitData>(¶m_0, (void*)param_0.field_0x18);
|
||||
}
|
||||
else {
|
||||
field_0xc = NULL;
|
||||
}
|
||||
field_0x30 = JSUConvertOffsetToPtr<_GXCullMode>(¶m_0, (void*)param_0.field_0x1c);
|
||||
field_0x10 = JSUConvertOffsetToPtr<GXColor>(¶m_0, (void*)param_0.field_0x20);
|
||||
field_0x14 = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x24);
|
||||
field_0x18 = JSUConvertOffsetToPtr<J2DColorChanInfo>(¶m_0, (void*)param_0.field_0x28);
|
||||
field_0x1c = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x2c);
|
||||
field_0x20 = JSUConvertOffsetToPtr<J2DTexCoordInfo>(¶m_0, (void*)param_0.field_0x30);
|
||||
field_0x24 = JSUConvertOffsetToPtr<J2DTexMtxInfo>(¶m_0, (void*)param_0.field_0x34);
|
||||
field_0x28 = JSUConvertOffsetToPtr<u16>(¶m_0, (void*)param_0.field_0x38);
|
||||
field_0x2c = JSUConvertOffsetToPtr<u16>(¶m_0, (void*)param_0.field_0x3c);
|
||||
field_0x34 = JSUConvertOffsetToPtr<J2DTevOrderInfo>(¶m_0, (void*)param_0.field_0x40);
|
||||
field_0x38 = JSUConvertOffsetToPtr<_GXColorS10>(¶m_0, (void*)param_0.field_0x44);
|
||||
field_0x3c = JSUConvertOffsetToPtr<GXColor>(¶m_0, (void*)param_0.field_0x48);
|
||||
field_0x40 = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x4c);
|
||||
field_0x44 = JSUConvertOffsetToPtr<J2DTevStageInfo>(¶m_0, (void*)param_0.field_0x50);
|
||||
field_0x48 = JSUConvertOffsetToPtr<J2DTevSwapModeInfo>(¶m_0, (void*)param_0.field_0x54);
|
||||
field_0x4c = JSUConvertOffsetToPtr<J2DTevSwapModeTableInfo>(¶m_0, (void*)param_0.field_0x58);
|
||||
field_0x50 = JSUConvertOffsetToPtr<J2DAlphaCompInfo>(¶m_0, (void*)param_0.field_0x5c);
|
||||
field_0x54 = JSUConvertOffsetToPtr<J2DBlendInfo>(¶m_0, (void*)param_0.field_0x60);
|
||||
field_0x58 = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x64);
|
||||
}
|
||||
|
||||
u32 J2DMaterialFactory::countStages(int param_0) const {
|
||||
J2DMaterialInitData* iVar5 = &field_0x4[field_0x8[param_0]];
|
||||
u32 uVar4 = 0;
|
||||
u32 uVar3 = 0;
|
||||
if (iVar5->field_0x4 != 0xff) {
|
||||
uVar3 = field_0x40[iVar5->field_0x4];
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (iVar5->field_0x38[i] != 0xffff) {
|
||||
uVar4++;
|
||||
}
|
||||
}
|
||||
if ((uVar3 != uVar4 && uVar4 != 0)) {
|
||||
return uVar3 > uVar4 ? uVar3 : uVar4;
|
||||
}
|
||||
return uVar3;
|
||||
}
|
||||
|
||||
J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 param_2,
|
||||
J2DResReference* param_3, J2DResReference* param_4,
|
||||
JKRArchive* param_5) const {
|
||||
u32 stages = countStages(index);
|
||||
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));
|
||||
param_0->getColorBlock()->setCullMode(newCullMode(index));
|
||||
param_0->getTexGenBlock()->setTexGenNum(newTexGenNum(index));
|
||||
param_0->getPEBlock()->setAlphaComp(newAlphaComp(index));
|
||||
param_0->getPEBlock()->setBlend(newBlend(index));
|
||||
param_0->getPEBlock()->setDither(newDither(index));
|
||||
param_0->getTevBlock()->setTevStageNum(newTevStageNum(index));
|
||||
param_0->mMaterialAlphaCalc = getMaterialAlphaCalc(index);
|
||||
|
||||
JUTResReference aJStack_12c;
|
||||
for (u8 i = 0; i < local_374; i++) {
|
||||
u16 texNo = newTexNo(index, i);
|
||||
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);
|
||||
if (local_380 == NULL && param_5 != NULL) {
|
||||
local_380 = aJStack_12c.getResource(local_37c, 'TIMG', NULL);
|
||||
}
|
||||
if (local_380 == NULL && J2DScreen::getDataManage() != NULL) {
|
||||
char acStack_230[257];
|
||||
strcpy(acStack_230, param_3->getName(texNo));
|
||||
local_380 = J2DScreen::getDataManage()->get(acStack_230);
|
||||
}
|
||||
}
|
||||
param_0->getTevBlock()->insertTexture(i, (ResTIMG*)local_380);
|
||||
param_0->getTevBlock()->setTexNo(i, texNo);
|
||||
}
|
||||
u16 fontNo = newFontNo(index);
|
||||
param_0->getTevBlock()->setFontNo(fontNo);
|
||||
|
||||
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);
|
||||
if (local_388 == NULL && param_5 != NULL) {
|
||||
local_388 = aJStack_12c.getResource(local_384, 'FONT', NULL);
|
||||
}
|
||||
if (local_388 == NULL && J2DScreen::getDataManage() != NULL) {
|
||||
char acStack_334[257];
|
||||
strcpy(acStack_334, param_4->getName(param_0->getTevBlock()->getFontNo()));
|
||||
local_388 = J2DScreen::getDataManage()->get(acStack_334);
|
||||
}
|
||||
}
|
||||
|
||||
param_0->getTevBlock()->setFont((ResFONT*)local_388);
|
||||
for (u8 i = 0; i < local_370; i++) {
|
||||
param_0->getTevBlock()->setTevOrder(i, newTevOrder(index, 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) {
|
||||
param_0->getTevBlock()->getTevStage(i)->setTexSel(field_0x48[local_38c->field_0xba[i]].mTexSel);
|
||||
param_0->getTevBlock()->getTevStage(i)->setRasSel(field_0x48[local_38c->field_0xba[i]].mRasSel);
|
||||
}
|
||||
}
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
param_0->getTevBlock()->setTevKColor(i, newTevKColor(index, i));
|
||||
}
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
param_0->getTevBlock()->setTevColor(i, newTevColor(index, i));
|
||||
}
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
param_0->getTevBlock()->setTevSwapModeTable(i, newTevSwapModeTable(index, i));
|
||||
}
|
||||
for (u8 i = 0; i < 2; i++) {
|
||||
param_0->getColorBlock()->setMatColor(i, newMatColor(index, i));
|
||||
}
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
J2DColorChan colorChan = newColorChan(index, i);
|
||||
param_0->getColorBlock()->setColorChan(i, colorChan);
|
||||
}
|
||||
for (u8 i = 0; i < 8; i++) {
|
||||
J2DTexCoord texCoord = newTexCoord(index, i);
|
||||
param_0->getTexGenBlock()->setTexCoord(i, &texCoord);
|
||||
}
|
||||
for (u8 i = 0; i < 8; i++) {
|
||||
param_0->getTexGenBlock()->setTexMtx(i, newTexMtx(index, i));
|
||||
}
|
||||
J2DMaterialInitData* local_394 = &field_0x4[field_0x8[index]];
|
||||
for (u8 i = 0; i < local_370; i++) {
|
||||
param_0->getTevBlock()->setTevKColorSel(i, local_394->field_0x52[i]);
|
||||
}
|
||||
for (u8 i = 0; i < local_370; i++) {
|
||||
param_0->getTevBlock()->setTevKAlphaSel(i, local_394->field_0x62[i]);
|
||||
}
|
||||
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++) {
|
||||
param_0->getIndBlock()->setIndTexMtx(i, newIndTexMtx(index, i));
|
||||
}
|
||||
for (u8 i = 0; i < local_410; i++) {
|
||||
param_0->getIndBlock()->setIndTexOrder(i, newIndTexOrder(index, i));
|
||||
}
|
||||
for (u8 i = 0; i < local_410; i++) {
|
||||
param_0->getIndBlock()->setIndTexCoordScale(i, newIndTexCoordScale(index, i));
|
||||
}
|
||||
for (u8 i = 0; i < local_370; i++) {
|
||||
param_0->getTevBlock()->setIndTevStage(i, newIndTevStage(index, i));
|
||||
}
|
||||
}
|
||||
return param_0;
|
||||
}
|
||||
|
||||
JUtility::TColor J2DMaterialFactory::newMatColor(int param_0, int param_1) const {
|
||||
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]];
|
||||
}
|
||||
return local_20;
|
||||
}
|
||||
|
||||
u8 J2DMaterialFactory::newColorChanNum(int param_0) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x2 != 0xff) {
|
||||
return field_0x14[iVar2->field_0x2];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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]]);
|
||||
}
|
||||
return J2DColorChan();
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
J2DTexCoord J2DMaterialFactory::newTexCoord(int param_0, int param_1) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x14[param_1] != 0xffff) {
|
||||
return J2DTexCoord(field_0x20[iVar2->field_0x14[param_1]]);
|
||||
}
|
||||
return J2DTexCoord();
|
||||
}
|
||||
|
||||
J2DTexMtx* J2DMaterialFactory::newTexMtx(int param_0, int param_1) const {
|
||||
J2DTexMtx* rv = NULL;
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x24[param_1] != 0xffff) {
|
||||
rv = new J2DTexMtx(field_0x24[iVar2->field_0x24[param_1]]);
|
||||
rv->calc();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
u16 J2DMaterialFactory::newTexNo(int param_0, int param_1) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x38[param_1] != 0xffff) {
|
||||
return field_0x28[iVar2->field_0x38[param_1]];
|
||||
}
|
||||
return 0xFFFF;
|
||||
}
|
||||
|
||||
u16 J2DMaterialFactory::newFontNo(int param_0) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x48 != 0xffff) {
|
||||
return field_0x2c[iVar2->field_0x48];
|
||||
}
|
||||
return 0xFFFF;
|
||||
}
|
||||
|
||||
J2DTevOrder J2DMaterialFactory::newTevOrder(int param_0, int param_1) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x72[param_1] != 0xffff) {
|
||||
return J2DTevOrder(field_0x34[iVar2->field_0x72[param_1]]);
|
||||
}
|
||||
return J2DTevOrder();
|
||||
}
|
||||
|
||||
J2DGXColorS10 J2DMaterialFactory::newTevColor(int param_0, int param_1) const {
|
||||
GXColorS10 color = {0, 0, 0, 0};
|
||||
J2DGXColorS10 rv = color;
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
|
||||
if (iVar2->field_0x92[param_1] != 0xffff) {
|
||||
return field_0x38[iVar2->field_0x92[param_1]];
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
JUtility::TColor J2DMaterialFactory::newTevKColor(int param_0, int param_1) const {
|
||||
JUtility::TColor local_20 = (GXColor){0xFF, 0xFF, 0xFF, 0xFF};
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x4a[param_1] != 0xffff) {
|
||||
return field_0x3c[iVar2->field_0x4a[param_1]];
|
||||
}
|
||||
return local_20;
|
||||
}
|
||||
|
||||
u8 J2DMaterialFactory::newTevStageNum(int param_0) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x4 != 0xff) {
|
||||
return field_0x40[iVar2->field_0x4];
|
||||
}
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
J2DTevStage J2DMaterialFactory::newTevStage(int param_0, int param_1) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x9a[param_1] != 0xffff) {
|
||||
return J2DTevStage(field_0x44[iVar2->field_0x9a[param_1]]);
|
||||
}
|
||||
return J2DTevStage();
|
||||
}
|
||||
|
||||
J2DTevSwapModeTable J2DMaterialFactory::newTevSwapModeTable(int param_0, int param_1) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0xda[param_1] != 0xffff) {
|
||||
return J2DTevSwapModeTable(field_0x4c[iVar2->field_0xda[param_1]]);
|
||||
}
|
||||
return J2DTevSwapModeTable(j2dDefaultTevSwapModeTable);
|
||||
}
|
||||
|
||||
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 r31;
|
||||
}
|
||||
|
||||
J2DIndTexOrder J2DMaterialFactory::newIndTexOrder(int param_0, int param_1) const {
|
||||
J2DIndTexOrder rv;
|
||||
if (field_0xc != NULL) {
|
||||
if (field_0xc[param_0].field_0x0 == 1) {
|
||||
return J2DIndTexOrder(field_0xc[param_0].field_0x4[param_1]);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
J2DIndTexMtx J2DMaterialFactory::newIndTexMtx(int param_0, int param_1) const {
|
||||
J2DIndTexMtx rv;
|
||||
if (field_0xc != NULL) {
|
||||
if (field_0xc[param_0].field_0x0 == 1) {
|
||||
return J2DIndTexMtx(field_0xc[param_0].field_0xc[param_1]);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
J2DIndTevStage J2DMaterialFactory::newIndTevStage(int param_0, int param_1) const {
|
||||
J2DIndTevStage rv;
|
||||
if (field_0xc != NULL) {
|
||||
if (field_0xc[param_0].field_0x0 == 1) {
|
||||
return J2DIndTevStage(field_0xc[param_0].field_0x68[param_1]);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
J2DIndTexCoordScale J2DMaterialFactory::newIndTexCoordScale(int param_0, int param_1) const {
|
||||
J2DIndTexCoordScale rv;
|
||||
if (field_0xc != NULL) {
|
||||
if (field_0xc[param_0].field_0x0 == 1) {
|
||||
return J2DIndTexCoordScale(field_0xc[param_0].field_0x60[param_1]);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
J2DAlphaComp J2DMaterialFactory::newAlphaComp(int param_0) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0xe2 != 0xffff) {
|
||||
return J2DAlphaComp(field_0x50[iVar2->field_0xe2]);
|
||||
}
|
||||
return J2DAlphaComp();
|
||||
}
|
||||
|
||||
J2DBlend J2DMaterialFactory::newBlend(int param_0) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0xe4 != 0xffff) {
|
||||
return J2DBlend(field_0x54[iVar2->field_0xe4]);
|
||||
}
|
||||
return J2DBlend(j2dDefaultBlendInfo);
|
||||
}
|
||||
|
||||
u8 J2DMaterialFactory::newDither(int param_0) const {
|
||||
J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]];
|
||||
if (iVar2->field_0x5 != 0xff) {
|
||||
return field_0x58[iVar2->field_0x5];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
|
||||
#include <gx.h>
|
||||
|
||||
J2DOrthoGraph::J2DOrthoGraph() : J2DGrafContext(0, 0, 0, 0) {
|
||||
this->setLookat();
|
||||
}
|
||||
|
||||
J2DOrthoGraph::J2DOrthoGraph(f32 x, f32 y, f32 width, f32 height, f32 far, f32 near)
|
||||
: J2DGrafContext(x, y, width, height) {
|
||||
mOrtho = JGeometry::TBox2<f32>(0, 0, width, height);
|
||||
mNear = -near;
|
||||
mFar = -far;
|
||||
this->setLookat();
|
||||
}
|
||||
|
||||
void J2DOrthoGraph::setPort() {
|
||||
this->J2DGrafContext::setPort();
|
||||
C_MTXOrtho(mMtx44, mOrtho.i.y, mOrtho.f.y, mOrtho.i.x, mOrtho.f.x, mNear, mFar);
|
||||
GXSetProjection(mMtx44, GX_ORTHOGRAPHIC);
|
||||
}
|
||||
|
||||
void J2DOrthoGraph::setOrtho(JGeometry::TBox2<f32> const& bounds, f32 far, f32 near) {
|
||||
mOrtho = bounds;
|
||||
mNear = -near;
|
||||
mFar = -far;
|
||||
}
|
||||
|
||||
void J2DOrthoGraph::setLookat() {
|
||||
MTXIdentity(mPosMtx);
|
||||
GXLoadPosMtxImm(mPosMtx, 0);
|
||||
}
|
||||
|
||||
void J2DOrthoGraph::scissorBounds(JGeometry::TBox2<f32>* param_0,
|
||||
JGeometry::TBox2<f32> const* param_1) {
|
||||
f32 widthPower = this->getWidthPower();
|
||||
f32 heightPower = this->getHeightPower();
|
||||
f32 ix = mBounds.i.x >= 0 ? mBounds.i.x : 0;
|
||||
f32 iy = mBounds.i.y >= 0 ? mBounds.i.y : 0;
|
||||
f32 f0 = ix + widthPower * (param_1->i.x - mOrtho.i.x);
|
||||
f32 f2 = ix + widthPower * (param_1->f.x - mOrtho.i.x);
|
||||
f32 f1 = iy + heightPower * (param_1->i.y - mOrtho.i.y);
|
||||
f32 f3 = iy + heightPower * (param_1->f.y - mOrtho.i.y);
|
||||
param_0->set(f0, f1, f2, f3);
|
||||
param_0->intersect(mScissorBounds);
|
||||
}
|
||||
|
||||
void J2DDrawLine(f32 x1, f32 y1, f32 x2, f32 y2, JUtility::TColor color,
|
||||
int line_width) {
|
||||
J2DOrthoGraph oGrph;
|
||||
oGrph.setLineWidth(line_width);
|
||||
oGrph.setColor(color);
|
||||
oGrph.moveTo(x1, y1);
|
||||
oGrph.lineTo(x2, y2);
|
||||
}
|
||||
|
||||
void J2DFillBox(f32 x, f32 y, f32 width, f32 height, JUtility::TColor color) {
|
||||
J2DFillBox(JGeometry::TBox2<f32>(x, y, x + width, y + height),
|
||||
color);
|
||||
}
|
||||
|
||||
void J2DFillBox(JGeometry::TBox2<f32> const& box, JUtility::TColor color) {
|
||||
J2DOrthoGraph oGrph;
|
||||
oGrph.setColor(color);
|
||||
oGrph.fillBox(box);
|
||||
}
|
||||
|
||||
void J2DDrawFrame(f32 x, f32 y, f32 width, f32 height, JUtility::TColor color,
|
||||
u8 line_width) {
|
||||
J2DDrawFrame(JGeometry::TBox2<f32>(x, y, x + width, y + height),
|
||||
color, line_width);
|
||||
}
|
||||
|
||||
void J2DDrawFrame(JGeometry::TBox2<f32> const& box, JUtility::TColor color, u8 line_width) {
|
||||
J2DOrthoGraph oGrph;
|
||||
oGrph.setColor(color);
|
||||
oGrph.setLineWidth(line_width);
|
||||
oGrph.drawFrame(box);
|
||||
}
|
||||
@@ -0,0 +1,868 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DPane.h"
|
||||
#include "JSystem/J2DGraph/J2DAnimation.h"
|
||||
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
|
||||
#include "JSystem/J2DGraph/J2DScreen.h"
|
||||
#include "JSystem/J3DGraphBase/J3DTransform.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
|
||||
J2DPane::J2DPane() : mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) {
|
||||
mTransform = NULL;
|
||||
mKind = 'PAN1';
|
||||
mVisible = true;
|
||||
mInfoTag = 0;
|
||||
mUserInfoTag = 0;
|
||||
mBounds.set(0, 0, 0, 0);
|
||||
initiate();
|
||||
changeUseTrans(NULL);
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
void J2DPane::initiate() {
|
||||
field_0x4 = -1;
|
||||
mRotateX = 0.0f;
|
||||
mRotateY = 0.0f;
|
||||
mRotateZ = 0.0f;
|
||||
mRotateOffsetX = 0.0f;
|
||||
mRotateOffsetY = 0.0f;
|
||||
mBasePosition = 0;
|
||||
mRotAxis = ROTATE_Z;
|
||||
mScaleX = 1.0f;
|
||||
mScaleY = 1.0f;
|
||||
mCullMode = GX_CULL_NONE;
|
||||
mAlpha = 255;
|
||||
mIsInfluencedAlpha = true;
|
||||
mColorAlpha = 255;
|
||||
mConnected = false;
|
||||
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
J2DPane::J2DPane(J2DPane* p_pane, bool visible, u64 tag, JGeometry::TBox2<f32> const& bounds)
|
||||
: mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) {
|
||||
mTransform = NULL;
|
||||
initialize(p_pane, visible, tag, bounds);
|
||||
}
|
||||
|
||||
void J2DPane::initialize(J2DPane* p_pane, bool visible, u64 infoTag,
|
||||
JGeometry::TBox2<f32> const& bounds) {
|
||||
mKind = 'PAN1';
|
||||
mVisible = visible;
|
||||
mInfoTag = infoTag;
|
||||
mUserInfoTag = 0;
|
||||
mBounds.set(bounds);
|
||||
if (p_pane != NULL) {
|
||||
p_pane->mPaneTree.appendChild(&mPaneTree);
|
||||
}
|
||||
|
||||
initiate();
|
||||
changeUseTrans(p_pane);
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
J2DPane::J2DPane(u64 infoTag, JGeometry::TBox2<f32> const& bounds)
|
||||
: mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) {
|
||||
mTransform = NULL;
|
||||
initialize(infoTag, bounds);
|
||||
}
|
||||
|
||||
void J2DPane::initialize(u64 tag, const JGeometry::TBox2<f32>& bounds) {
|
||||
mKind = 'PAN1';
|
||||
mVisible = true;
|
||||
mInfoTag = tag;
|
||||
mUserInfoTag = 0;
|
||||
mBounds.set(bounds);
|
||||
initiate();
|
||||
changeUseTrans(NULL);
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
J2DPane::J2DPane(J2DPane* p_pane, JSURandomInputStream* p_stream, u8 isEx) : mPaneTree(this) {
|
||||
mTransform = NULL;
|
||||
if (!isEx) {
|
||||
s32 position = p_stream->getPosition();
|
||||
|
||||
J2DPaneHeader header;
|
||||
p_stream->read(&header, sizeof(header));
|
||||
mKind = header.mKind;
|
||||
position += header.mSize;
|
||||
makePaneStream(p_pane, p_stream);
|
||||
p_stream->seek(position, JSUStreamSeekFrom_SET);
|
||||
} else {
|
||||
s32 position = p_stream->getPosition();
|
||||
|
||||
J2DPaneHeader header;
|
||||
p_stream->peek(&header, sizeof(header));
|
||||
mKind = header.mKind;
|
||||
position += header.mSize;
|
||||
makePaneExStream(p_pane, p_stream);
|
||||
p_stream->seek(position, JSUStreamSeekFrom_SET);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DPane::makePaneStream(J2DPane* p_pane, JSURandomInputStream* p_stream) {
|
||||
u8 unk;
|
||||
p_stream->read(unk);
|
||||
p_stream->read(mVisible);
|
||||
p_stream->skip(2);
|
||||
|
||||
mInfoTag = p_stream->read32b();
|
||||
|
||||
f32 x0 = p_stream->readS16();
|
||||
f32 y0 = p_stream->readS16();
|
||||
f32 x1 = x0 + p_stream->readS16();
|
||||
f32 y1 = y0 + p_stream->readS16();
|
||||
mBounds.set(x0, y0, x1, y1);
|
||||
|
||||
unk -= u8(6);
|
||||
mRotateX = 0;
|
||||
mRotateY = 0;
|
||||
mRotateZ = 0;
|
||||
if (unk != 0) {
|
||||
mRotateZ = p_stream->readU16();
|
||||
unk--;
|
||||
}
|
||||
|
||||
if (unk != 0) {
|
||||
u8 r28 = p_stream->readU8();
|
||||
mBasePosition = r28;
|
||||
unk--;
|
||||
} else {
|
||||
mBasePosition = 0;
|
||||
}
|
||||
mRotAxis = ROTATE_Z;
|
||||
|
||||
mAlpha = 255;
|
||||
if (unk != 0) {
|
||||
mAlpha = p_stream->readU8();
|
||||
unk--;
|
||||
}
|
||||
|
||||
mIsInfluencedAlpha = true;
|
||||
if (unk != 0) {
|
||||
mIsInfluencedAlpha = p_stream->readU8();
|
||||
unk--;
|
||||
}
|
||||
|
||||
p_stream->align(4);
|
||||
if (p_pane != NULL) {
|
||||
p_pane->mPaneTree.appendChild(&mPaneTree);
|
||||
}
|
||||
|
||||
mCullMode = GX_CULL_NONE;
|
||||
mColorAlpha = 255;
|
||||
mConnected = false;
|
||||
field_0x4 = 0xFFFF;
|
||||
mScaleX = 1;
|
||||
mScaleY = 1;
|
||||
mUserInfoTag = 0;
|
||||
changeUseTrans(p_pane);
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
void J2DPane::changeUseTrans(J2DPane* p_pane) {
|
||||
f32 xOffset = 0;
|
||||
f32 yOffset = 0;
|
||||
if (mBasePosition % 3 == 1) {
|
||||
xOffset = getWidth() / 2;
|
||||
} else if (mBasePosition % 3 == 2) {
|
||||
xOffset = getWidth();
|
||||
}
|
||||
|
||||
if (mBasePosition / 3 == 1) {
|
||||
yOffset = getHeight() / 2;
|
||||
} else if (mBasePosition / 3 == 2) {
|
||||
yOffset = getHeight();
|
||||
}
|
||||
|
||||
mTranslateX = mBounds.i.x + xOffset;
|
||||
mTranslateY = mBounds.i.y + yOffset;
|
||||
|
||||
mRotateOffsetX = xOffset;
|
||||
mRotateOffsetY = yOffset;
|
||||
|
||||
mBounds.addPos(JGeometry::TVec2<f32>(-mTranslateX, -mTranslateY));
|
||||
|
||||
if (p_pane != NULL) {
|
||||
u8 otherBasePos = p_pane->mBasePosition;
|
||||
f32 width = p_pane->getWidth();
|
||||
f32 height = p_pane->getHeight();
|
||||
|
||||
if (otherBasePos % 3 == 1) {
|
||||
mTranslateX -= width / 2;
|
||||
} else if (otherBasePos % 3 == 2) {
|
||||
mTranslateX -= width;
|
||||
}
|
||||
|
||||
if (otherBasePos / 3 == 1) {
|
||||
mTranslateY -= height / 2;
|
||||
} else if (otherBasePos / 3 == 2) {
|
||||
mTranslateY -= height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
J2DPane::~J2DPane() {
|
||||
JSUTreeIterator<J2DPane> iterator = mPaneTree.getFirstChild();
|
||||
for (; iterator != mPaneTree.getEndChild();) {
|
||||
delete (iterator++).getObject();
|
||||
}
|
||||
}
|
||||
|
||||
bool J2DPane::appendChild(J2DPane* p_child) {
|
||||
if (p_child == NULL)
|
||||
return false;
|
||||
|
||||
const J2DPane* parent = p_child->getParentPane();
|
||||
bool result = mPaneTree.appendChild(&p_child->mPaneTree);
|
||||
|
||||
if (result && parent == NULL) {
|
||||
p_child->add(mBounds.i.x, mBounds.i.y);
|
||||
p_child->calcMtx();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool J2DPane::insertChild(J2DPane* p_prev, J2DPane* p_child) {
|
||||
if (p_child == NULL)
|
||||
return false;
|
||||
|
||||
const J2DPane* parent = p_child->getParentPane();
|
||||
|
||||
bool result =
|
||||
mPaneTree.insertChild(p_prev != NULL ? &p_prev->mPaneTree : NULL, &p_child->mPaneTree);
|
||||
|
||||
if (result && parent == NULL) {
|
||||
p_child->add(mBounds.i.x, mBounds.i.y);
|
||||
p_child->calcMtx();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void J2DPane::draw(f32 x, f32 y, J2DGrafContext const* p_grafCtx, bool isOrthoGraf, bool param_4) {
|
||||
param_4 = param_4 && mVisible;
|
||||
if (p_grafCtx->getGrafType() != 1) {
|
||||
isOrthoGraf = false;
|
||||
}
|
||||
|
||||
JSUTree<J2DPane>* parentTree = mPaneTree.getParent();
|
||||
J2DPane* parent = NULL;
|
||||
if (parentTree != NULL) {
|
||||
parent = parentTree->getObject();
|
||||
}
|
||||
|
||||
if (mBounds.isValid()) {
|
||||
mGlobalBounds = mBounds;
|
||||
|
||||
mGlobalBounds.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
|
||||
|
||||
if (param_4) {
|
||||
mClipRect = mBounds;
|
||||
rewriteAlpha();
|
||||
}
|
||||
|
||||
if (parent != NULL) {
|
||||
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 (param_4) {
|
||||
if (isOrthoGraf) {
|
||||
mClipRect = mGlobalBounds;
|
||||
mClipRect.intersect(parent->mClipRect);
|
||||
}
|
||||
|
||||
mColorAlpha = mAlpha;
|
||||
if (mIsInfluencedAlpha) {
|
||||
mColorAlpha = (mAlpha * parent->mColorAlpha) / 255;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#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 (param_4 && isOrthoGraf) {
|
||||
((J2DOrthoGraph*)p_grafCtx)->scissorBounds(&scissorBounds, &mClipRect);
|
||||
}
|
||||
|
||||
if (param_4 && (mClipRect.isValid() || !isOrthoGraf)) {
|
||||
J2DGrafContext tmpGraf(*p_grafCtx);
|
||||
if (isOrthoGraf) {
|
||||
tmpGraf.scissor(scissorBounds);
|
||||
tmpGraf.setScissor();
|
||||
}
|
||||
GXSetCullMode((GXCullMode)mCullMode);
|
||||
drawSelf(x, y, &tmpGraf.mPosMtx);
|
||||
}
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
iter->draw(0, 0, p_grafCtx, isOrthoGraf, param_4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DPane::place(JGeometry::TBox2<f32> const& box) {
|
||||
JGeometry::TBox2<f32> tmpBox;
|
||||
|
||||
if (mBounds.i.x == 0) {
|
||||
tmpBox.i.x = 0;
|
||||
tmpBox.f.x = box.getWidth();
|
||||
mTranslateX = box.i.x;
|
||||
} else if (mBounds.f.x == 0) {
|
||||
tmpBox.i.x = -box.getWidth();
|
||||
tmpBox.f.x = 0;
|
||||
mTranslateX = box.f.x;
|
||||
} else {
|
||||
tmpBox.i.x = -(box.getWidth() / 2);
|
||||
tmpBox.f.x = box.getWidth() / 2;
|
||||
mTranslateX = (box.i.x + box.f.x) / 2;
|
||||
}
|
||||
|
||||
if (mBounds.i.y == 0) {
|
||||
tmpBox.i.y = 0;
|
||||
tmpBox.f.y = box.getHeight();
|
||||
mTranslateY = box.i.y;
|
||||
} else if (mBounds.f.y == 0) {
|
||||
tmpBox.i.y = -box.getHeight();
|
||||
tmpBox.f.y = 0;
|
||||
mTranslateY = box.f.y;
|
||||
} else {
|
||||
tmpBox.i.y = -(box.getHeight() / 2);
|
||||
tmpBox.f.y = box.getHeight() / 2;
|
||||
mTranslateY = (box.i.y + box.f.y) / 2;
|
||||
}
|
||||
|
||||
f32 xOff = tmpBox.i.x - mBounds.i.x;
|
||||
f32 yOff = tmpBox.i.y - mBounds.i.y;
|
||||
J2DPane* child;
|
||||
for (child = getFirstChildPane(); child != NULL; child = child->getNextChildPane()) {
|
||||
child->mTranslateX += xOff;
|
||||
child->mTranslateY += yOff;
|
||||
if (xOff != 0 || yOff != 0) {
|
||||
child->calcMtx();
|
||||
}
|
||||
}
|
||||
mBounds = tmpBox;
|
||||
|
||||
J2DPane* parent = getParentPane();
|
||||
if (parent != NULL) {
|
||||
mTranslateX += parent->mBounds.i.x;
|
||||
mTranslateY += parent->mBounds.i.y;
|
||||
}
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
void J2DPane::move(f32 x, f32 y) {
|
||||
f32 width = mBounds.getWidth();
|
||||
f32 height = mBounds.getHeight();
|
||||
place(JGeometry::TBox2<f32>(x, y, x + width, y + height));
|
||||
}
|
||||
|
||||
void J2DPane::add(f32 x, f32 y) {
|
||||
mTranslateX += x;
|
||||
mTranslateY += y;
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
void J2DPane::resize(f32 x, f32 y) {
|
||||
JGeometry::TBox2<f32> box = mBounds;
|
||||
|
||||
box.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
|
||||
|
||||
const J2DPane* parent = getParentPane();
|
||||
if (parent != NULL) {
|
||||
box.addPos(JGeometry::TVec2<f32>(-parent->mBounds.i.x, -parent->mBounds.i.y));
|
||||
}
|
||||
|
||||
box.f.x = box.i.x + x;
|
||||
box.f.y = box.i.y + y;
|
||||
place(box);
|
||||
}
|
||||
|
||||
JGeometry::TBox2<f32> J2DPane::static_mBounds(0, 0, 0, 0);
|
||||
|
||||
JGeometry::TBox2<f32>& J2DPane::getBounds() {
|
||||
static_mBounds = mBounds;
|
||||
|
||||
static_mBounds.addPos(JGeometry::TVec2<f32>(mTranslateX, mTranslateY));
|
||||
|
||||
const J2DPane* parent = getParentPane();
|
||||
if (parent != NULL) {
|
||||
static_mBounds.addPos(JGeometry::TVec2<f32>(-parent->mBounds.i.x, -parent->mBounds.i.y));
|
||||
}
|
||||
|
||||
return static_mBounds;
|
||||
}
|
||||
|
||||
void J2DPane::rotate(f32 offsetX, f32 offsetY, J2DRotateAxis axis, f32 angle) {
|
||||
mRotateOffsetX = offsetX;
|
||||
mRotateOffsetY = offsetY;
|
||||
mRotAxis = axis;
|
||||
rotate(angle);
|
||||
}
|
||||
|
||||
void J2DPane::rotate(f32 angle) {
|
||||
if (mRotAxis == ROTATE_X) {
|
||||
mRotateX = angle;
|
||||
} else if (mRotAxis == ROTATE_Y) {
|
||||
mRotateY = angle;
|
||||
} else {
|
||||
mRotateZ = angle;
|
||||
}
|
||||
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
void J2DPane::clip(JGeometry::TBox2<f32> const& bounds) {
|
||||
JGeometry::TBox2<f32> box(bounds);
|
||||
box.addPos(JGeometry::TVec2<f32>(mGlobalBounds.i.x, mGlobalBounds.i.y));
|
||||
mClipRect.intersect(box);
|
||||
}
|
||||
|
||||
J2DPane* J2DPane::search(u64 tag) {
|
||||
if (tag == mInfoTag) {
|
||||
return this;
|
||||
}
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
if (J2DPane* result = iter.getObject()->search(tag)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
J2DPane* J2DPane::searchUserInfo(u64 tag) {
|
||||
if (tag == mUserInfoTag) {
|
||||
return this;
|
||||
}
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
if (J2DPane* result = iter.getObject()->searchUserInfo(tag)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool J2DPane::isUsed(const ResTIMG* p_timg) {
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
if (iter.getObject()->isUsed(p_timg))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool J2DPane::isUsed(const ResFONT* p_font) {
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
if (iter.getObject()->isUsed(p_font))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void J2DPane::makeMatrix(f32 param_0, f32 param_1, f32 param_2, f32 param_3) {
|
||||
f32 tmpX = mRotateOffsetX - param_2;
|
||||
f32 tmpY = mRotateOffsetY - param_3;
|
||||
Mtx rotX, rotY, rotZ, rotMtx, mtx, tmp;
|
||||
MTXTrans(mtx, -tmpX, -tmpY, 0);
|
||||
MTXRotRad(rotX, 'x', DEG_TO_RAD(mRotateX));
|
||||
MTXRotRad(rotY, 'y', DEG_TO_RAD(mRotateY));
|
||||
MTXRotRad(rotZ, 'z', DEG_TO_RAD(-mRotateZ));
|
||||
MTXConcat(rotZ, rotX, tmp);
|
||||
MTXConcat(rotY, tmp, rotMtx);
|
||||
MTXScaleApply(mtx, mPositionMtx, mScaleX, mScaleY, 1);
|
||||
MTXConcat(rotMtx, mPositionMtx, tmp);
|
||||
MTXTransApply(tmp, mPositionMtx, param_0 + tmpX, param_1 + tmpY, 0);
|
||||
}
|
||||
|
||||
void J2DPane::setCullBack(GXCullMode mode) {
|
||||
mCullMode = mode;
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
iter.getObject()->setCullBack(mode);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DPane::setBasePosition(J2DBasePosition position) {
|
||||
mBasePosition = position;
|
||||
mRotAxis = ROTATE_Z;
|
||||
|
||||
mRotateOffsetX = 0;
|
||||
|
||||
if (position % 3 == 1) {
|
||||
mRotateOffsetX = getWidth() / 2;
|
||||
} else if (position % 3 == 2) {
|
||||
mRotateOffsetX = getWidth();
|
||||
}
|
||||
|
||||
mRotateOffsetY = 0;
|
||||
if (position / 3 == 1) {
|
||||
mRotateOffsetY = getHeight() / 2;
|
||||
} else if (position / 3 == 2) {
|
||||
mRotateOffsetY = getHeight();
|
||||
}
|
||||
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
void J2DPane::setInfluencedAlpha(bool influencedAlpha, bool param_1) {
|
||||
if (param_1 && mIsInfluencedAlpha != influencedAlpha) {
|
||||
J2DPane* parent = getParentPane();
|
||||
u8 alpha = 255;
|
||||
|
||||
for (; parent != NULL; parent = parent->getParentPane()) {
|
||||
if (parent->getAlpha() == 0) {
|
||||
alpha = 0;
|
||||
break;
|
||||
}
|
||||
alpha = (((f32)alpha) * parent->getAlpha() / 255);
|
||||
if (!parent->isInfluencedAlpha()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (influencedAlpha) {
|
||||
if (alpha == 0) {
|
||||
setAlpha(0);
|
||||
} else {
|
||||
f32 fAlpha = ((f32)getAlpha()) / alpha * 255;
|
||||
|
||||
u8 alpha;
|
||||
if (fAlpha > 255) {
|
||||
alpha = 255;
|
||||
} else {
|
||||
alpha = fAlpha;
|
||||
}
|
||||
setAlpha(alpha);
|
||||
}
|
||||
} else {
|
||||
f32 fAlpha = f32(alpha * getAlpha()) / 255;
|
||||
setAlpha(fAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
mIsInfluencedAlpha = influencedAlpha;
|
||||
}
|
||||
|
||||
Vec J2DPane::getGlbVtx(u8 param_0) const {
|
||||
Vec out;
|
||||
if (param_0 >= 4) {
|
||||
out.x = 0;
|
||||
out.y = 0;
|
||||
out.z = 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
J2DPane* J2DPane::getFirstChildPane() {
|
||||
if (!getFirstChild())
|
||||
return NULL;
|
||||
|
||||
return getFirstChild()->getObject();
|
||||
}
|
||||
|
||||
J2DPane* J2DPane::getNextChildPane() {
|
||||
if (getPaneTree()->getNextChild() == NULL)
|
||||
return NULL;
|
||||
|
||||
return getPaneTree()->getNextChild()->getObject();
|
||||
}
|
||||
|
||||
J2DPane* J2DPane::getParentPane() {
|
||||
if (getPaneTree()->getParent() == NULL)
|
||||
return NULL;
|
||||
|
||||
return getPaneTree()->getParent()->getObject();
|
||||
}
|
||||
|
||||
/* name unknown */
|
||||
struct J2DPaneInfo {
|
||||
/* 0x00 */ u32 mKind;
|
||||
/* 0x04 */ u32 mSize;
|
||||
/* 0x08 */ u16 field_0x8;
|
||||
/* 0x0A */ u16 field_0xa;
|
||||
/* 0x0B */ u8 mVisible;
|
||||
/* 0x0C */ u8 mBasePosition;
|
||||
/* 0x10 */ u64 mInfoTag;
|
||||
/* 0x18 */ u64 mUserInfoTag;
|
||||
/* 0x20 */ f32 mRotOffsetX;
|
||||
/* 0x24 */ f32 mRotOffsetY;
|
||||
/* 0x28 */ f32 mScaleX;
|
||||
/* 0x2C */ f32 mScaleY;
|
||||
/* 0x30 */ f32 mRotateX;
|
||||
/* 0x34 */ f32 mRotateY;
|
||||
/* 0x38 */ f32 mRotateZ;
|
||||
/* 0x3C */ f32 mTranslateX;
|
||||
/* 0x40 */ f32 mTranslateY;
|
||||
}; // Size: 0x48
|
||||
|
||||
void J2DPane::makePaneExStream(J2DPane* p_parent, JSURandomInputStream* p_stream) {
|
||||
s32 r30 = p_stream->getPosition();
|
||||
|
||||
J2DPaneInfo data;
|
||||
p_stream->read(&data, sizeof(data));
|
||||
field_0x4 = data.field_0xa;
|
||||
mVisible = !!data.mVisible;
|
||||
mInfoTag = data.mInfoTag;
|
||||
mUserInfoTag = data.mUserInfoTag;
|
||||
mScaleX = data.mScaleX;
|
||||
mScaleY = data.mScaleY;
|
||||
mRotateX = data.mRotateX;
|
||||
mRotateY = data.mRotateY;
|
||||
mRotateZ = data.mRotateZ;
|
||||
mTranslateX = data.mTranslateX;
|
||||
mTranslateY = data.mTranslateY;
|
||||
mRotAxis = ROTATE_Z;
|
||||
|
||||
if (data.mBasePosition % 3 == 0) {
|
||||
mRotateOffsetX = 0;
|
||||
} else if (data.mBasePosition % 3 == 1) {
|
||||
mRotateOffsetX = data.mRotOffsetX / 2;
|
||||
} else {
|
||||
mRotateOffsetX = data.mRotOffsetX;
|
||||
}
|
||||
|
||||
if (data.mBasePosition / 3 == 0) {
|
||||
mRotateOffsetY = 0;
|
||||
} else if (data.mBasePosition / 3 == 1) {
|
||||
mRotateOffsetY = data.mRotOffsetY / 2;
|
||||
} else {
|
||||
mRotateOffsetY = data.mRotOffsetY;
|
||||
}
|
||||
|
||||
mBounds.set(-mRotateOffsetX, -mRotateOffsetY, data.mRotOffsetX - mRotateOffsetX,
|
||||
data.mRotOffsetY - mRotateOffsetY);
|
||||
mBasePosition = data.mBasePosition;
|
||||
|
||||
mAlpha = 255;
|
||||
mIsInfluencedAlpha = false;
|
||||
|
||||
if (p_parent != NULL) {
|
||||
p_parent->mPaneTree.appendChild(&mPaneTree);
|
||||
}
|
||||
|
||||
mCullMode = GX_CULL_NONE;
|
||||
mColorAlpha = 255;
|
||||
mConnected = false;
|
||||
calcMtx();
|
||||
}
|
||||
|
||||
s16 J2DPane::J2DCast_F32_to_S16(f32 value, u8 arg2) {
|
||||
if (arg2 >= 0xF) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
f32 tmpF;
|
||||
tmpF = value;
|
||||
if (value < 0) {
|
||||
tmpF = -tmpF;
|
||||
}
|
||||
int tmp = tmpF * (1 << arg2);
|
||||
if (tmp >= 0x8000) {
|
||||
if (value < 0) {
|
||||
return 0x8000;
|
||||
} else {
|
||||
return 0x7FFF;
|
||||
}
|
||||
} else if (value < 0) {
|
||||
return ~tmp + 1;
|
||||
} else {
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void* J2DPane::getPointer(JSURandomInputStream* p_stream, u32 param_1, JKRArchive* p_archive) {
|
||||
JUTResReference resRef;
|
||||
|
||||
void* pointer;
|
||||
if (p_archive == NULL) {
|
||||
if (J2DScreen::getDataManage() == NULL) {
|
||||
pointer = resRef.getResource(p_stream, param_1, NULL);
|
||||
} else {
|
||||
s32 prevPos = p_stream->getPosition();
|
||||
pointer = resRef.getResource(p_stream, param_1, NULL);
|
||||
if (pointer == NULL) {
|
||||
p_stream->seek(prevPos, JSUStreamSeekFrom_SET);
|
||||
pointer = J2DScreen::getDataManage()->get(p_stream);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s32 prevPos = p_stream->getPosition();
|
||||
pointer = resRef.getResource(p_stream, param_1, p_archive);
|
||||
if (pointer == NULL) {
|
||||
p_stream->seek(prevPos, JSUStreamSeekFrom_SET);
|
||||
pointer = resRef.getResource(p_stream, param_1, NULL);
|
||||
}
|
||||
|
||||
if (pointer == NULL) {
|
||||
if (J2DScreen::getDataManage() != NULL) {
|
||||
p_stream->seek(prevPos, JSUStreamSeekFrom_SET);
|
||||
pointer = J2DScreen::getDataManage()->get(p_stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pointer;
|
||||
}
|
||||
|
||||
void J2DPane::setAnimation(J2DAnmBase* p_anm) {
|
||||
if (p_anm != NULL) {
|
||||
switch (p_anm->getKind()) {
|
||||
case KIND_TRANSFORM:
|
||||
setAnimation(static_cast<J2DAnmTransform*>(p_anm));
|
||||
break;
|
||||
case KIND_COLOR:
|
||||
setAnimation(static_cast<J2DAnmColor*>(p_anm));
|
||||
break;
|
||||
case KIND_VTX_COLOR:
|
||||
setAnimation(static_cast<J2DAnmVtxColor*>(p_anm));
|
||||
break;
|
||||
case KIND_TEXTURE_SRT:
|
||||
setAnimation(static_cast<J2DAnmTextureSRTKey*>(p_anm));
|
||||
break;
|
||||
case KIND_TEX_PATTERN:
|
||||
setAnimation(static_cast<J2DAnmTexPattern*>(p_anm));
|
||||
break;
|
||||
case KIND_VISIBILITY:
|
||||
setAnimation(static_cast<J2DAnmVisibilityFull*>(p_anm));
|
||||
break;
|
||||
case KIND_TEV_REG:
|
||||
setAnimation(static_cast<J2DAnmTevRegKey*>(p_anm));
|
||||
break;
|
||||
default:
|
||||
OS_REPORT("J2DPane: this is not a J3D Binary.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DPane::setAnimation(J2DAnmTransform* p_anm) {
|
||||
mTransform = p_anm;
|
||||
}
|
||||
|
||||
void J2DPane::animationTransform() {
|
||||
if (mTransform != NULL)
|
||||
animationTransform(mTransform);
|
||||
}
|
||||
|
||||
void J2DPane::clearAnmTransform() {
|
||||
setAnimation((J2DAnmTransform*)NULL);
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
iter.getObject()->clearAnmTransform();
|
||||
}
|
||||
}
|
||||
|
||||
const J2DAnmTransform* J2DPane::animationTransform(const J2DAnmTransform* p_transform) {
|
||||
const J2DAnmTransform* p = p_transform;
|
||||
if (mTransform != NULL)
|
||||
p = mTransform;
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
iter.getObject()->animationTransform(p);
|
||||
}
|
||||
|
||||
updateTransform(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
void J2DPane::setVisibileAnimation(J2DAnmVisibilityFull* p_visibility) {
|
||||
setAnimationVF(p_visibility);
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
iter.getObject()->setVisibileAnimation(p_visibility);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DPane::setVtxColorAnimation(J2DAnmVtxColor* p_vtxColor) {
|
||||
setAnimationVC(p_vtxColor);
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
iter.getObject()->setVtxColorAnimation(p_vtxColor);
|
||||
}
|
||||
}
|
||||
|
||||
const J2DAnmTransform* J2DPane::animationPane(const J2DAnmTransform* p_transform) {
|
||||
const J2DAnmTransform* p = p_transform;
|
||||
if (mTransform != NULL)
|
||||
p = mTransform;
|
||||
|
||||
for (JSUTreeIterator<J2DPane> iter = mPaneTree.getFirstChild(); iter != mPaneTree.getEndChild(); ++iter) {
|
||||
iter.getObject()->animationPane(p);
|
||||
}
|
||||
|
||||
updateTransform(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
void J2DPane::updateTransform(J2DAnmTransform const* p_anmTransform) {
|
||||
if (field_0x4 != 0xFFFF && p_anmTransform != NULL) {
|
||||
J3DTransformInfo info;
|
||||
p_anmTransform->getTransform(field_0x4, &info);
|
||||
mScaleX = info.mScale.x;
|
||||
mScaleY = info.mScale.z;
|
||||
mRotateX = (u16)info.mRotation.x * 360.0f / 65535.0f;
|
||||
mRotateY = (u16)info.mRotation.z * 360.0f / 65535.0f;
|
||||
mRotateZ = (u16)info.mRotation.y * 360.0f / 65535.0f;
|
||||
mTranslateX = info.mTranslate.x;
|
||||
mTranslateY = info.mTranslate.z;
|
||||
calcMtx();
|
||||
}
|
||||
}
|
||||
|
||||
static void dummy(J2DPane* pane) {
|
||||
pane->drawSelf(0.0f, 0.0f);
|
||||
pane->update();
|
||||
pane->setConnectParent(false);
|
||||
pane->setCullBack(false);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,603 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DPrint.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JUtility/JUTFont.h"
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
char* J2DPrint::mStrBuff;
|
||||
|
||||
static bool sStrBufInitialized;
|
||||
|
||||
size_t J2DPrint::mStrBuffSize;
|
||||
|
||||
static u8 data_8045158C[4];
|
||||
|
||||
f32 J2DPrint_print_alpha_va(J2DPrint* pPrint, u8 alpha, const char* fmt, va_list args) {
|
||||
pPrint->initchar();
|
||||
s32 length = vsnprintf(J2DPrint::mStrBuff, J2DPrint::mStrBuffSize, fmt, args);
|
||||
|
||||
J2DPrint::TSize size;
|
||||
if (length < 0) {
|
||||
return 0.0f;
|
||||
} else if (length >= J2DPrint::mStrBuffSize) {
|
||||
length = J2DPrint::mStrBuffSize - 1;
|
||||
data_8045158C[0] = 1;
|
||||
}
|
||||
|
||||
pPrint->parse((u8*)J2DPrint::mStrBuff, length, 0x80000000 - 1, NULL, size, alpha, true);
|
||||
return size.field_0x0;
|
||||
}
|
||||
|
||||
J2DPrint::J2DPrint(JUTFont* pFont, JUtility::TColor charColor, JUtility::TColor gradColor) {
|
||||
private_initiate(pFont, 0.0f, 0.0f, charColor, gradColor, 0, 0xFFFFFFFF, true);
|
||||
}
|
||||
|
||||
J2DPrint::J2DPrint(JUTFont* pFont, f32 charSpacing, f32 lineSpacing, JUtility::TColor charColor,
|
||||
JUtility::TColor gradColor, JUtility::TColor blackColor, JUtility::TColor whiteColor) {
|
||||
private_initiate(pFont, charSpacing, lineSpacing, charColor, gradColor, blackColor, whiteColor, false);
|
||||
}
|
||||
|
||||
J2DPrint::~J2DPrint() {}
|
||||
|
||||
void J2DPrint::initiate() {
|
||||
if (mFont != NULL) {
|
||||
mFont->setGX(mBlackColor, mWhiteColor);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DPrint::private_initiate(JUTFont* pFont, f32 charSpacing, f32 lineSpacing, JUtility::TColor charColor,
|
||||
JUtility::TColor gradColor, JUtility::TColor blackColor,
|
||||
JUtility::TColor whiteColor, bool param_7) {
|
||||
if (mStrBuff == NULL) {
|
||||
setBuffer(0x400);
|
||||
}
|
||||
|
||||
mFont = pFont;
|
||||
mCharSpacing = charSpacing;
|
||||
mLineSpacing = 32.0f;
|
||||
|
||||
if (mFont != NULL) {
|
||||
mLineSpacing = param_7 == false ? lineSpacing : mFont->getLeading();
|
||||
}
|
||||
|
||||
field_0x5a = 1;
|
||||
locate(0.0f, 0.0f);
|
||||
|
||||
mCharColor = charColor;
|
||||
mGradColor = gradColor;
|
||||
mBlackColor = blackColor;
|
||||
mWhiteColor = whiteColor;
|
||||
|
||||
if (mFont == NULL) {
|
||||
field_0x58 = 80;
|
||||
} else {
|
||||
field_0x58 = mFont->getWidth() << 2;
|
||||
}
|
||||
|
||||
if (mFont != NULL) {
|
||||
setFontSize();
|
||||
mFont->setGX(mBlackColor, mWhiteColor);
|
||||
}
|
||||
|
||||
initchar();
|
||||
}
|
||||
|
||||
u8* J2DPrint::setBuffer(size_t size) {
|
||||
JUT_ASSERT(335, size > 0);
|
||||
|
||||
u8* u8Buff = (u8*)mStrBuff;
|
||||
if (sStrBufInitialized) {
|
||||
delete mStrBuff;
|
||||
}
|
||||
|
||||
mStrBuff = new (JKRGetSystemHeap(), 0) char[size];
|
||||
mStrBuffSize = size;
|
||||
sStrBufInitialized = true;
|
||||
return u8Buff;
|
||||
}
|
||||
|
||||
void J2DPrint::setFontSize() {
|
||||
if (mFont != NULL) {
|
||||
mFontSizeX = mFont->getCellWidth();
|
||||
mFontSizeY = mFont->getCellHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void J2DPrint::locate(f32 cursorH, f32 cursorV) {
|
||||
field_0x24 = cursorH;
|
||||
field_0x28 = cursorV;
|
||||
mCursorH = cursorH;
|
||||
mCursorV = cursorV;
|
||||
field_0x34 = 0.0f;
|
||||
}
|
||||
|
||||
f32 J2DPrint::print(f32 cursorH, f32 cursorV, u8 alpha, char const* fmt, ...) {
|
||||
locate(cursorH, cursorV);
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
f32 var_f31 = print_va(alpha, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
return var_f31;
|
||||
}
|
||||
|
||||
void J2DPrint::printReturn(char const* pString, f32 param_1, f32 param_2,
|
||||
J2DTextBoxHBinding hBind, J2DTextBoxVBinding vBind, f32 param_5,
|
||||
f32 param_6, u8 alpha) {
|
||||
if (mFont != NULL) {
|
||||
initchar();
|
||||
field_0x24 = mCursorH;
|
||||
field_0x28 = mCursorV;
|
||||
|
||||
size_t length = strlen(pString);
|
||||
if (length >= mStrBuffSize) {
|
||||
length = mStrBuffSize - 1;
|
||||
data_8045158C[0] = 1;
|
||||
}
|
||||
|
||||
f32 var_f26 = mLineSpacing;
|
||||
|
||||
u16 local_2b0[260];
|
||||
TSize size;
|
||||
f32 var_f31 = parse((u8*)pString, length, param_1, local_2b0, size, alpha, false);
|
||||
f32 dVar12 = mFont->getAscent()*(mFontSizeY / mFont->getCellHeight());
|
||||
var_f31 += dVar12;
|
||||
|
||||
switch (vBind) {
|
||||
case VBIND_TOP:
|
||||
break;
|
||||
case VBIND_BOTTOM:
|
||||
param_6 += (s32)(param_2 - var_f31 - 0.5f);
|
||||
break;
|
||||
case VBIND_CENTER:
|
||||
param_6 += (s32)(param_2 - var_f31 - 0.5f) / 2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; local_2b0[i] != 0xFFFF; i++) {
|
||||
switch (hBind) {
|
||||
case HBIND_LEFT:
|
||||
local_2b0[i] = 0;
|
||||
break;
|
||||
case HBIND_RIGHT:
|
||||
local_2b0[i] = param_1 - local_2b0[i];
|
||||
break;
|
||||
case HBIND_CENTER:
|
||||
local_2b0[i] = (param_1 - local_2b0[i]) / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
initchar();
|
||||
|
||||
mCursorH += param_5;
|
||||
mCursorV += param_6 + dVar12;
|
||||
field_0x24 = mCursorH;
|
||||
field_0x28 = mCursorV;
|
||||
parse((u8*)pString, length, param_1, local_2b0, size, alpha, true);
|
||||
}
|
||||
}
|
||||
|
||||
f32 J2DPrint::parse(const u8* pString, int length, int param_2, u16* param_3,
|
||||
TSize& size, u8 alpha, bool param_6) {
|
||||
if (mFont == NULL) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
const u8* pStringStart = pString;
|
||||
u16 someIndex = 0;
|
||||
|
||||
f32 prevCursorH = mCursorH;
|
||||
f32 prevCursorV = mCursorV;
|
||||
f32 f31 = prevCursorH;
|
||||
f32 local_a8 = prevCursorV;
|
||||
int iCharacter = *(pString++);
|
||||
|
||||
f32 f29 = mCursorH;
|
||||
f32 local_ac = mCursorH;
|
||||
f32 local_b0 = mCursorV;
|
||||
f32 local_b4 = mCursorV;
|
||||
|
||||
JUtility::TColor local_b8 = field_0x8;
|
||||
JUtility::TColor local_bc = field_0xc;
|
||||
f32 local_c0;
|
||||
|
||||
local_b8.a = local_b8.a * alpha / 0xFF;
|
||||
local_bc.a = local_bc.a * alpha / 0xFF;
|
||||
mFont->setGradColor(local_b8, field_0x22 ? local_bc : local_b8);
|
||||
|
||||
do {
|
||||
bool b2ByteCharacter = false;
|
||||
bool r25;
|
||||
if (mFont->isLeadByte(iCharacter)) {
|
||||
iCharacter = (iCharacter << 8) | *(pString++);
|
||||
b2ByteCharacter = true;
|
||||
}
|
||||
|
||||
if (iCharacter == 0 || ((uintptr_t)pString - (uintptr_t)pStringStart) > length) {
|
||||
if (!param_6 && param_3 != NULL) {
|
||||
param_3[someIndex] = 0.5f + f31;
|
||||
}
|
||||
someIndex++;
|
||||
break;
|
||||
} else {
|
||||
r25 = true;
|
||||
local_c0 = mCursorH;
|
||||
if (iCharacter < ' ') {
|
||||
if (iCharacter == '\x1B') {
|
||||
u16 code = doEscapeCode(&pString, alpha);
|
||||
if (code == 'HM') {
|
||||
if (!param_6 && param_3 != NULL) {
|
||||
param_3[someIndex] = 0.5f + f31;
|
||||
}
|
||||
|
||||
mCursorH = prevCursorH;
|
||||
mCursorV = prevCursorV;
|
||||
|
||||
someIndex++;
|
||||
if (someIndex == 0x100) {
|
||||
break;
|
||||
}
|
||||
|
||||
f31 = 0.0f;
|
||||
}
|
||||
|
||||
if (code != 0) {
|
||||
r25 = false;
|
||||
}
|
||||
} else {
|
||||
doCtrlCode(iCharacter);
|
||||
r25 = false;
|
||||
if (iCharacter == 10) {
|
||||
if (!param_6 && param_3 != NULL) {
|
||||
param_3[someIndex] = 0.5f + f31;
|
||||
}
|
||||
|
||||
someIndex++;
|
||||
if (someIndex == 0x100) {
|
||||
break;
|
||||
}
|
||||
|
||||
f31 = 0.0f;
|
||||
}
|
||||
}
|
||||
} else if (b2ByteCharacter && ((uintptr_t)pString - (uintptr_t)pStringStart > (u32)length)) {
|
||||
if (!param_6 && param_3 != NULL) {
|
||||
param_3[someIndex] = 0.5f + f31;
|
||||
}
|
||||
someIndex++;
|
||||
break;
|
||||
} else {
|
||||
if (mFont->isFixed()) {
|
||||
field_0x34 = mFont->getFixedWidth();
|
||||
} else {
|
||||
JUTFont::TWidth width;
|
||||
mFont->getWidthEntry(iCharacter, &width);
|
||||
field_0x34 = width.field_0x1;
|
||||
}
|
||||
|
||||
field_0x34 *= mScaleX / mFont->getCellWidth();
|
||||
|
||||
f32 fVar6 = ((mCursorH + field_0x34) - field_0x24);
|
||||
fVar6 = 10000.0f * fVar6;
|
||||
f32 local_c8 = s32(fVar6) / 10000.0f;
|
||||
if (local_c8 > param_2 && mCursorH > prevCursorH) {
|
||||
u32 characterSize;
|
||||
if (b2ByteCharacter) {
|
||||
characterSize = 2;
|
||||
} else {
|
||||
characterSize = 1;
|
||||
}
|
||||
|
||||
pString -= characterSize;
|
||||
mCursorV += field_0x14;
|
||||
|
||||
if (!param_6 && (param_3 != NULL)) {
|
||||
param_3[someIndex] = 0.5f + f31;
|
||||
}
|
||||
|
||||
someIndex++;
|
||||
if (someIndex == 0x100) {
|
||||
break;
|
||||
}
|
||||
|
||||
mCursorH = field_0x24;
|
||||
f31 = 0.0f;
|
||||
r25 = false;
|
||||
} else {
|
||||
if (param_6) {
|
||||
if (param_3 != NULL) {
|
||||
mFont->drawChar_scale(mCursorH + (s16)param_3[someIndex], mCursorV, (s32)mScaleX, (s32)mScaleY, iCharacter, true);
|
||||
} else {
|
||||
mFont->drawChar_scale(mCursorH, mCursorV, (s32)mScaleX, (s32)mScaleY, iCharacter, true);
|
||||
}
|
||||
}
|
||||
mCursorH += field_0x34;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (r25) {
|
||||
if (mCursorH - prevCursorH > f31) {
|
||||
f31 = mCursorH - prevCursorH;
|
||||
}
|
||||
mCursorH += field_0x10;
|
||||
field_0x34 += field_0x10;
|
||||
|
||||
f32 local_cc = (mScaleY / mFont->getHeight()) * mFont->getDescent();
|
||||
if (local_a8 < mCursorV + local_cc) {
|
||||
local_a8 = mCursorV + local_cc;
|
||||
}
|
||||
if (mCursorH > local_ac) {
|
||||
local_ac = mCursorH;
|
||||
}
|
||||
if (mCursorH < f29) {
|
||||
f29 = mCursorH;
|
||||
}
|
||||
if (local_c0 < f29) {
|
||||
f29 = local_c0;
|
||||
}
|
||||
if (mCursorV > local_b4) {
|
||||
local_b4 = mCursorV;
|
||||
}
|
||||
if (mCursorV < local_b0) {
|
||||
local_b0 = mCursorV;
|
||||
}
|
||||
}
|
||||
|
||||
iCharacter = *(pString++);
|
||||
} while (true);
|
||||
|
||||
if (param_3 != NULL) {
|
||||
param_3[someIndex] = 0xFFFF;
|
||||
}
|
||||
|
||||
size.field_0x0 = local_ac - f29;
|
||||
size.field_0x4 = local_b4 - local_b0 + mFont->getLeading();
|
||||
|
||||
if (!param_6) {
|
||||
mCursorH = prevCursorH;
|
||||
mCursorV = prevCursorV;
|
||||
}
|
||||
|
||||
return local_a8 - prevCursorV;
|
||||
}
|
||||
|
||||
void J2DPrint::doCtrlCode(int iCharacter) {
|
||||
switch (iCharacter) {
|
||||
case '\b':
|
||||
mCursorH -= field_0x34;
|
||||
field_0x34 = 0.0f;
|
||||
break;
|
||||
case '\t':
|
||||
if (field_0x20 > 0) {
|
||||
f32 fVar1 = mCursorH;
|
||||
mCursorH = field_0x20 + field_0x20 * ((int)mCursorH / field_0x20);
|
||||
field_0x34 = mCursorH - fVar1;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
field_0x34 = 0.0f;
|
||||
mCursorH = field_0x24;
|
||||
mCursorV += field_0x14;
|
||||
break;
|
||||
case '\r':
|
||||
field_0x34 = 0.0f;
|
||||
mCursorH = field_0x24;
|
||||
break;
|
||||
case '\x1C':
|
||||
mCursorH += 1.0f;
|
||||
break;
|
||||
case '\x1D':
|
||||
mCursorH -= 1.0f;
|
||||
break;
|
||||
case '\x1E':
|
||||
mCursorV -= 1.0f;
|
||||
break;
|
||||
case '\x1F':
|
||||
mCursorV += + 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
u16 J2DPrint::doEscapeCode(const u8** ppu8String, u8 alpha) {
|
||||
const u8* pStringStart = *ppu8String;
|
||||
u16 code = 0;
|
||||
|
||||
u16 codeLower;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (mFont->isLeadByte(**ppu8String)) {
|
||||
codeLower = ((**ppu8String) << 8) | (*ppu8String)[1];
|
||||
(*ppu8String) += 2;
|
||||
} else {
|
||||
codeLower = **ppu8String;
|
||||
(*ppu8String)++;
|
||||
}
|
||||
|
||||
if (codeLower >= 0x80 || codeLower < 0x20) {
|
||||
*ppu8String = pStringStart;
|
||||
return 0;
|
||||
}
|
||||
|
||||
code = (code << 8) | codeLower;
|
||||
}
|
||||
|
||||
JUtility::TColor local_40 = field_0x8;
|
||||
JUtility::TColor local_44 = field_0xc;
|
||||
f32 scaleNumber;
|
||||
|
||||
switch(code) {
|
||||
case 'CU': // Cursor Up
|
||||
mCursorV -= getNumberF32(ppu8String, 1.0f, 0.0f, 10);
|
||||
break;
|
||||
case 'CD': // Cursor Down
|
||||
mCursorV += getNumberF32(ppu8String, 1.0f, 0.0f, 10);
|
||||
break;
|
||||
case 'CL': // Cursor Left
|
||||
mCursorH -= getNumberF32(ppu8String, 1.0f, 0.0f, 10);
|
||||
break;
|
||||
case 'CR': // Cursor Right
|
||||
mCursorH += getNumberF32(ppu8String, 1.0f, 0.0f, 10);
|
||||
break;
|
||||
case 'LU': // Line Up?
|
||||
mCursorV -= field_0x14;
|
||||
break;
|
||||
case 'LD': // Line Down?
|
||||
mCursorV += field_0x14;
|
||||
break;
|
||||
case 'ST': {
|
||||
s32 number = getNumberS32(ppu8String, field_0x20, field_0x20, 10);
|
||||
if (number > 0) {
|
||||
field_0x20 = number;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'CC': { // Character Color
|
||||
field_0x8 = getNumberS32(ppu8String, (u32)mCharColor, (u32)field_0x8, 16);
|
||||
local_40 = field_0x8;
|
||||
local_40.a = local_40.a * alpha / 0xff;
|
||||
local_44.a = local_44.a * alpha / 0xff;
|
||||
|
||||
mFont->setGradColor(local_40, field_0x22 != 0 ? local_44 : local_40);
|
||||
break;
|
||||
}
|
||||
case 'GC': { // Gradient Color
|
||||
field_0xc = getNumberS32(ppu8String, (u32)mGradColor, (u32)field_0xc, 16);
|
||||
local_44 = field_0xc;
|
||||
local_40.a = local_40.a * alpha / 0xFF;
|
||||
local_44.a = local_44.a * alpha / 0xFF;
|
||||
|
||||
mFont->setGradColor(local_40, field_0x22 != 0 ? local_44 : local_40);
|
||||
break;
|
||||
}
|
||||
case 'FX': { // Font Scale X
|
||||
scaleNumber = getNumberF32(ppu8String, mFontSizeX, mScaleX, 10);
|
||||
if (scaleNumber >= 0) {
|
||||
mScaleX = scaleNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'FY': { // Font Scale Y
|
||||
scaleNumber = getNumberF32(ppu8String, mFontSizeY, mScaleY, 10);
|
||||
if (scaleNumber >= 0) {
|
||||
mScaleY = scaleNumber;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'SH': // Space Horizontal?
|
||||
field_0x10 = getNumberF32(ppu8String, mCharSpacing, field_0x10, 10);
|
||||
break;
|
||||
case 'SV': // Space Vertical?
|
||||
field_0x14 = getNumberF32(ppu8String, mLineSpacing, field_0x14, 10);
|
||||
break;
|
||||
case 'GM': {
|
||||
field_0x22 = getNumberS32(ppu8String, field_0x22 == 0, field_0x22, 10);
|
||||
local_40.a = local_40.a * alpha / 0xFF;
|
||||
local_44.a = local_44.a * alpha / 0xFF;
|
||||
|
||||
mFont->setGradColor(local_40, field_0x22 != 0 ? local_44 : local_40);
|
||||
break;
|
||||
}
|
||||
case 'HM':
|
||||
break;
|
||||
default:
|
||||
*ppu8String = pStringStart;
|
||||
code = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
void J2DPrint::initchar() {
|
||||
field_0x8 = mCharColor;
|
||||
field_0xc = mGradColor;
|
||||
field_0x10 = mCharSpacing;
|
||||
field_0x14 = mLineSpacing;
|
||||
field_0x22 = field_0x5a;
|
||||
field_0x20 = field_0x58;
|
||||
mScaleX = mFontSizeX;
|
||||
mScaleY = mFontSizeY;
|
||||
}
|
||||
|
||||
s32 J2DPrint::getNumberS32(const u8** ppu8String, s32 defaultValue, s32 errorValue, int base) {
|
||||
const u8* pStringStart = *ppu8String;
|
||||
if (**ppu8String != '[') {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
(*ppu8String)++;
|
||||
|
||||
s32 number = 0;
|
||||
char* pEnd;
|
||||
if (base == 10) {
|
||||
number = strtol((char*)*ppu8String, &pEnd, base);
|
||||
} else if (base == 16) {
|
||||
number = strtoul((char*)*ppu8String, &pEnd, base);
|
||||
if ((uintptr_t)pEnd - (uintptr_t)*ppu8String != 8) {
|
||||
if ((uintptr_t)pEnd - (uintptr_t)*ppu8String == 6) {
|
||||
number = (number << 8) | 0xFF;
|
||||
} else {
|
||||
*ppu8String = pStringStart;
|
||||
return errorValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pEnd[0] != ']') {
|
||||
*ppu8String = pStringStart;
|
||||
return errorValue;
|
||||
} else {
|
||||
if ((char*)*ppu8String == pEnd) {
|
||||
*ppu8String = (const u8*)pEnd + 1;
|
||||
return defaultValue;
|
||||
} else {
|
||||
*ppu8String = (const u8*)pEnd + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return number;
|
||||
}
|
||||
|
||||
f32 J2DPrint::getNumberF32(const u8** ppu8String, f32 defaultValue, f32 errorValue, int base) {
|
||||
const u8* pStringStart = *ppu8String;
|
||||
if (**ppu8String != '[') {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
(*ppu8String)++;
|
||||
|
||||
s32 number = 0;
|
||||
char* pEnd;
|
||||
if (base == 10) {
|
||||
number = strtol((char*)*ppu8String, &pEnd, base);
|
||||
} else if (base == 16) {
|
||||
number = strtoul((char*)*ppu8String, &pEnd, base);
|
||||
if ((uintptr_t)pEnd - (uintptr_t)*ppu8String != 8) {
|
||||
if ((uintptr_t)pEnd - (uintptr_t)*ppu8String == 6) {
|
||||
number = (number << 8) | 0xFF;
|
||||
} else {
|
||||
*ppu8String = pStringStart;
|
||||
return errorValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pEnd[0] != ']') {
|
||||
*ppu8String = pStringStart;
|
||||
return errorValue;
|
||||
} else {
|
||||
if ((char*)*ppu8String == pEnd) {
|
||||
*ppu8String = (const u8*)pEnd + 1;
|
||||
return defaultValue;
|
||||
} else {
|
||||
*ppu8String = (const u8*)pEnd + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return number;
|
||||
}
|
||||
@@ -0,0 +1,516 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DScreen.h"
|
||||
#include "JSystem/J2DGraph/J2DMaterialFactory.h"
|
||||
#include "JSystem/J2DGraph/J2DPictureEx.h"
|
||||
#include "JSystem/J2DGraph/J2DTextBoxEx.h"
|
||||
#include "JSystem/J2DGraph/J2DWindowEx.h"
|
||||
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JSupport/JSUMemoryStream.h"
|
||||
#include <types.h>
|
||||
|
||||
J2DScreen::J2DScreen()
|
||||
: J2DPane(NULL, true, 'root', JGeometry::TBox2<f32>(JGeometry::TVec2<f32>(0, 0), JGeometry::TVec2<f32>(640, 480))), mColor() {
|
||||
field_0x4 = -1;
|
||||
mScissor = false;
|
||||
mMaterialNum = 0;
|
||||
mMaterials = NULL;
|
||||
mTexRes = NULL;
|
||||
mFontRes = NULL;
|
||||
mNameTable = NULL;
|
||||
}
|
||||
|
||||
J2DScreen::~J2DScreen() {
|
||||
clean();
|
||||
}
|
||||
|
||||
void J2DScreen::clean() {
|
||||
delete[] mMaterials;
|
||||
mMaterialNum = 0;
|
||||
mMaterials = NULL;
|
||||
|
||||
delete[] mTexRes;
|
||||
mTexRes = NULL;
|
||||
|
||||
delete[] mFontRes;
|
||||
mFontRes = NULL;
|
||||
|
||||
if (mNameTable != NULL) {
|
||||
delete[] mNameTable->getResNameTable();
|
||||
delete mNameTable;
|
||||
mNameTable = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool J2DScreen::setPriority(char const* resName, u32 param_1, JKRArchive* p_archive) {
|
||||
if (p_archive == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void* res = JKRGetNameResource(resName, p_archive);
|
||||
if (res != NULL) {
|
||||
JSUMemoryInputStream stream(res, p_archive->getExpandedResSize(res));
|
||||
return setPriority(&stream, param_1, p_archive);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool J2DScreen::setPriority(JSURandomInputStream* p_stream, u32 param_1, JKRArchive* p_archive) {
|
||||
if (p_archive == NULL) {
|
||||
return false;
|
||||
} else {
|
||||
return private_set(p_stream, param_1, p_archive);
|
||||
}
|
||||
}
|
||||
|
||||
bool J2DScreen::private_set(JSURandomInputStream* p_stream, u32 param_1, JKRArchive* p_archive) {
|
||||
if (!checkSignature(p_stream)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getScreenInformation(p_stream)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool make_end = makeHierarchyPanes(this, p_stream, param_1, p_archive) != 2;
|
||||
|
||||
if (!(param_1 & 0x1F0000)) {
|
||||
clean();
|
||||
}
|
||||
|
||||
return make_end ? p_stream->isGood() : false;
|
||||
}
|
||||
|
||||
bool J2DScreen::checkSignature(JSURandomInputStream* p_stream) {
|
||||
J2DScrnHeader header;
|
||||
p_stream->read(&header, sizeof(J2DScrnHeader));
|
||||
|
||||
if (header.mTag != 'SCRN' || (header.mType != 'blo1' && header.mType != 'blo2')) {
|
||||
JUT_WARN(257, "%s", "SCRN resource is broken.\n")
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool J2DScreen::getScreenInformation(JSURandomInputStream* p_stream) {
|
||||
J2DScrnInfoHeader info;
|
||||
p_stream->read(&info, sizeof(J2DScrnInfoHeader));
|
||||
|
||||
if (info.mTag != 'INF1') {
|
||||
JUT_WARN(282, "%s", "SCRN resource is broken.\n")
|
||||
return false;
|
||||
}
|
||||
|
||||
place(JGeometry::TBox2<f32>(0.0f, 0.0f, info.mWidth, info.mHeight));
|
||||
|
||||
mColor = info.mColor;
|
||||
|
||||
if (info.mSize > 0x10) {
|
||||
p_stream->skip(info.mSize - 0x10);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
s32 J2DScreen::makeHierarchyPanes(J2DPane* p_basePane, JSURandomInputStream* p_stream, u32 param_2,
|
||||
JKRArchive* p_archive) {
|
||||
J2DPane* next_pane = p_basePane;
|
||||
|
||||
while (true) {
|
||||
J2DScrnBlockHeader header;
|
||||
p_stream->peek(&header, sizeof(J2DScrnBlockHeader));
|
||||
|
||||
switch (header.mTag) {
|
||||
case 'EXT1':
|
||||
p_stream->seek(header.mSize, JSUStreamSeekFrom_CUR);
|
||||
return 1;
|
||||
case 'BGN1': {
|
||||
p_stream->seek(header.mSize, JSUStreamSeekFrom_CUR);
|
||||
|
||||
s32 ret = makeHierarchyPanes(next_pane, p_stream, param_2, p_archive);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'END1':
|
||||
p_stream->seek(header.mSize, JSUStreamSeekFrom_CUR);
|
||||
return 0;
|
||||
case 'TEX1':
|
||||
if ((mTexRes = getResReference(p_stream, param_2)) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case 'FNT1':
|
||||
if ((mFontRes = getResReference(p_stream, param_2)) == NULL) {
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
case 'MAT1':
|
||||
if (!createMaterial(p_stream, param_2, p_archive)) {
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (p_archive == NULL) {
|
||||
next_pane = createPane(header, p_stream, p_basePane, param_2);
|
||||
} else {
|
||||
next_pane = createPane(header, p_stream, p_basePane, param_2, p_archive);
|
||||
}
|
||||
|
||||
if (next_pane == NULL) {
|
||||
return 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
J2DPane* J2DScreen::createPane(J2DScrnBlockHeader const& header, JSURandomInputStream* p_stream,
|
||||
J2DPane* p_basePane, u32 param_3, JKRArchive* p_archive) {
|
||||
J2DPane* newPane = NULL;
|
||||
|
||||
switch (header.mTag) {
|
||||
case 'PAN1':
|
||||
newPane = new J2DPane(p_basePane, p_stream, 0);
|
||||
break;
|
||||
case 'WIN1':
|
||||
newPane = new J2DWindow(p_basePane, p_stream, p_archive);
|
||||
break;
|
||||
case 'PIC1':
|
||||
newPane = new J2DPicture(p_basePane, p_stream, p_archive);
|
||||
break;
|
||||
case 'TBX1':
|
||||
newPane = new J2DTextBox(p_basePane, p_stream, p_archive);
|
||||
break;
|
||||
case 'PAN2':
|
||||
newPane = new J2DPane(p_basePane, p_stream, 1);
|
||||
break;
|
||||
case 'WIN2':
|
||||
if (param_3 & 0x1F0000) {
|
||||
newPane = new J2DWindowEx(p_basePane, p_stream, param_3, mMaterials);
|
||||
break;
|
||||
}
|
||||
newPane = new J2DWindow(p_basePane, p_stream, mMaterials);
|
||||
break;
|
||||
case 'PIC2':
|
||||
if (param_3 & 0x1F0000) {
|
||||
newPane = new J2DPictureEx(p_basePane, p_stream, param_3, mMaterials);
|
||||
break;
|
||||
}
|
||||
newPane = new J2DPicture(p_basePane, p_stream, mMaterials);
|
||||
break;
|
||||
case 'TBX2':
|
||||
if (param_3 & 0x1F0000) {
|
||||
newPane = new J2DTextBoxEx(p_basePane, p_stream, param_3, mMaterials);
|
||||
break;
|
||||
}
|
||||
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;
|
||||
|
||||
newPane = new J2DPane(p_basePane, p_stream, 0);
|
||||
p_stream->seek(start, JSUStreamSeekFrom_SET);
|
||||
break;
|
||||
}
|
||||
|
||||
return newPane;
|
||||
}
|
||||
|
||||
void J2DScreen::draw(f32 x, f32 y, J2DGrafContext const* grafCtx) {
|
||||
u32 l_x, l_y, width, height;
|
||||
|
||||
if (mScissor) {
|
||||
GXGetScissor(&l_x, &l_y, &width, &height);
|
||||
}
|
||||
|
||||
if (grafCtx != NULL) {
|
||||
J2DPane::draw(x, y, grafCtx, mScissor, true);
|
||||
} else {
|
||||
J2DOrthoGraph ortho(0.0f, 0.0f, 640.0f, 480.0f, -1.0f, 1.0f);
|
||||
ortho.setPort();
|
||||
J2DPane::draw(x, y, &ortho, mScissor, true);
|
||||
}
|
||||
|
||||
if (mScissor) {
|
||||
GXSetScissor(l_x, l_y, width, height);
|
||||
}
|
||||
|
||||
GXSetNumIndStages(0);
|
||||
for (int i = 0; i < 0x10; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetNumTevStages(1);
|
||||
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_NONE);
|
||||
GXSetCullMode(GX_CULL_NONE);
|
||||
GXSetNumTexGens(0);
|
||||
GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE,
|
||||
GX_AF_NONE);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
GXSetTevSwapModeTable((GXTevSwapSel)i, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA);
|
||||
}
|
||||
}
|
||||
|
||||
J2DPane* J2DScreen::search(u64 tag) {
|
||||
if (tag == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return J2DPane::search(tag);
|
||||
}
|
||||
|
||||
J2DPane* J2DScreen::searchUserInfo(u64 tag) {
|
||||
if (tag == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return J2DPane::searchUserInfo(tag);
|
||||
}
|
||||
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
||||
color = JUtility::TColor(alpha | ((u32)color & 0xFFFFFF00));
|
||||
|
||||
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(0.0f, 0.0f, 0.0f);
|
||||
GXColor1u32(color);
|
||||
|
||||
GXPosition3f32(getWidth(), 0.0f, 0.0f);
|
||||
GXColor1u32(color);
|
||||
|
||||
GXPosition3f32(getWidth(), getHeight(), 0.0f);
|
||||
GXColor1u32(color);
|
||||
|
||||
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) {
|
||||
s32 position = p_stream->getPosition();
|
||||
p_stream->skip(4);
|
||||
|
||||
s32 size1, size2;
|
||||
size1 = p_stream->readS32();
|
||||
p_stream->skip(4);
|
||||
size2 = p_stream->readS32();
|
||||
p_stream->seek(position + size2, JSUStreamSeekFrom_SET);
|
||||
|
||||
size1 = size1 - size2;
|
||||
|
||||
char* buffer;
|
||||
if (param_1 & 0x1F0000) {
|
||||
buffer = new char[size1];
|
||||
} else {
|
||||
buffer = new (-4) char[size1];
|
||||
}
|
||||
|
||||
if (buffer != NULL) {
|
||||
p_stream->read(buffer, size1);
|
||||
}
|
||||
|
||||
return (J2DResReference*)buffer;
|
||||
}
|
||||
|
||||
bool J2DScreen::createMaterial(JSURandomInputStream* p_stream, u32 param_1, JKRArchive* p_archive) {
|
||||
s32 position = p_stream->getPosition();
|
||||
|
||||
J2DScrnBlockHeader header;
|
||||
p_stream->read(&header, 8);
|
||||
mMaterialNum = p_stream->readU16();
|
||||
|
||||
p_stream->skip(2);
|
||||
|
||||
if (param_1 & 0x1F0000) {
|
||||
mMaterials = new J2DMaterial[mMaterialNum];
|
||||
} else {
|
||||
mMaterials = new (-4) J2DMaterial[mMaterialNum];
|
||||
}
|
||||
|
||||
u8* buffer = new (-4) u8[header.mSize];
|
||||
if (mMaterials != NULL && buffer != NULL) {
|
||||
J2DMaterialBlock* pBlock = (J2DMaterialBlock*)buffer;
|
||||
p_stream->seek(position, JSUStreamSeekFrom_SET);
|
||||
p_stream->read(buffer, header.mSize);
|
||||
J2DMaterialFactory factory(*pBlock);
|
||||
|
||||
for (u16 i = 0; i < mMaterialNum; i++) {
|
||||
factory.create(&mMaterials[i], i, param_1, mTexRes, mFontRes, p_archive);
|
||||
}
|
||||
|
||||
if (param_1 & 0x1F0000) {
|
||||
u32 offset =
|
||||
buffer[0x14] << 0x18 | buffer[0x15] << 0x10 | buffer[0x16] << 8 | buffer[0x17];
|
||||
ResNTAB* sec_s = (ResNTAB*)(buffer + offset);
|
||||
u16 entryNum = sec_s->mEntryNum;
|
||||
u16 lastOffset = sec_s->mEntries[entryNum - 1].mOffs;
|
||||
char* ptr = (char*)sec_s;
|
||||
u16 size = lastOffset;
|
||||
while (ptr[size] != 0) {
|
||||
size++;
|
||||
}
|
||||
size++;
|
||||
|
||||
u8* nametab = new u8[size];
|
||||
if (nametab == NULL) {
|
||||
goto failure;
|
||||
}
|
||||
for (u16 i = 0; i < size; i++) {
|
||||
nametab[i] = (buffer + offset)[i];
|
||||
}
|
||||
|
||||
mNameTable = new JUTNameTab((ResNTAB*)nametab);
|
||||
if (mNameTable == NULL) {
|
||||
delete[] nametab;
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
||||
success:
|
||||
delete[] buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
failure:
|
||||
delete[] buffer;
|
||||
clean();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool J2DScreen::isUsed(ResTIMG const* p_timg) {
|
||||
return J2DPane::isUsed(p_timg);
|
||||
}
|
||||
|
||||
bool J2DScreen::isUsed(ResFONT const* p_font) {
|
||||
return J2DPane::isUsed(p_font);
|
||||
}
|
||||
|
||||
J2DDataManage* J2DScreen::mDataManage;
|
||||
|
||||
void* J2DScreen::getNameResource(char const* resName) {
|
||||
void* res = JKRGetNameResource(resName, NULL);
|
||||
|
||||
if (res == NULL && mDataManage != NULL) {
|
||||
res = mDataManage->get(resName);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void J2DScreen::animation() {
|
||||
animationPane(mTransform);
|
||||
|
||||
for (u16 i = 0; i < mMaterialNum; i++) {
|
||||
mMaterials[i].animation();
|
||||
}
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimation(J2DAnmColor* p_anmColor) {
|
||||
p_anmColor->searchUpdateMaterialID(this);
|
||||
u16 matNum = p_anmColor->getUpdateMaterialNum();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
u16 matID = p_anmColor->getUpdateMaterialID(i);
|
||||
if (matID < mMaterialNum) {
|
||||
mMaterials[matID].setAnimation(p_anmColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimation(J2DAnmTextureSRTKey* p_anmSRTKey) {
|
||||
p_anmSRTKey->searchUpdateMaterialID(this);
|
||||
u16 matNum = p_anmSRTKey->getUpdateMaterialNum();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
u16 matID = p_anmSRTKey->getUpdateMaterialID(i);
|
||||
if (matID < mMaterialNum) {
|
||||
mMaterials[matID].setAnimation(p_anmSRTKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimation(J2DAnmTexPattern* p_anmPattern) {
|
||||
p_anmPattern->searchUpdateMaterialID(this);
|
||||
u16 matNum = p_anmPattern->getUpdateMaterialNum();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
u16 matID = p_anmPattern->getUpdateMaterialID(i);
|
||||
if (matID < mMaterialNum) {
|
||||
mMaterials[matID].setAnimation(p_anmPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimation(J2DAnmTevRegKey* p_anmRegKey) {
|
||||
p_anmRegKey->searchUpdateMaterialID(this);
|
||||
|
||||
u16 cMatNum = p_anmRegKey->getCRegUpdateMaterialNum();
|
||||
for (u16 i = 0; i < cMatNum; i++) {
|
||||
u16 matID = p_anmRegKey->getCRegUpdateMaterialID(i);
|
||||
if (matID < mMaterialNum) {
|
||||
mMaterials[matID].setAnimation(p_anmRegKey);
|
||||
}
|
||||
}
|
||||
|
||||
u16 kMatNum = p_anmRegKey->getKRegUpdateMaterialNum();
|
||||
for (u16 i = 0; i < kMatNum; i++) {
|
||||
u16 matID = p_anmRegKey->getKRegUpdateMaterialID(i);
|
||||
if (matID < mMaterialNum) {
|
||||
mMaterials[matID].setAnimation(p_anmRegKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimation(J2DAnmVtxColor* p_anmVtxColor) {
|
||||
J2DPane::setVtxColorAnimation(p_anmVtxColor);
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimation(J2DAnmVisibilityFull* p_anmVisibility) {
|
||||
J2DPane::setVisibileAnimation(p_anmVisibility);
|
||||
}
|
||||
|
||||
J2DPane* J2DScreen::createPane(J2DScrnBlockHeader const& header, JSURandomInputStream* p_stream,
|
||||
J2DPane* p_basePane, u32 param_3) {
|
||||
return createPane(header, p_stream, p_basePane, param_3, NULL);
|
||||
}
|
||||
|
||||
u16 J2DScreen::getTypeID() const {
|
||||
return 8;
|
||||
}
|
||||
|
||||
void J2DScreen::calcMtx() {
|
||||
makeMatrix(mTranslateX, mTranslateY);
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimation(J2DAnmBase* p_anm) {
|
||||
J2DPane::setAnimation(p_anm);
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimationVF(J2DAnmVisibilityFull*) {
|
||||
/* empty function */
|
||||
}
|
||||
|
||||
void J2DScreen::setAnimationVC(J2DAnmVtxColor*) {
|
||||
/* empty function */
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
//
|
||||
// J2DTevs
|
||||
//
|
||||
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DTevs.h"
|
||||
#include "JSystem/J2DGraph/J2DMaterial.h"
|
||||
#include <cmath>
|
||||
#include <gx.h>
|
||||
|
||||
void J2DTexMtx::load(u32 mtxIdx) {
|
||||
GXLoadTexMtxImm(mTexMtx, mtxIdx * 3 + GX_TEXMTX0, (GXTexMtxType)mInfo.mTexMtxType);
|
||||
}
|
||||
|
||||
void J2DTexMtx::calc() {
|
||||
u32 dcc = mInfo.mTexMtxDCC;
|
||||
if (dcc == J2DTexMtxInfo::DCC_NONE) {
|
||||
getTextureMtx(mInfo.mTexSRTInfo, mInfo.mCenter, mTexMtx);
|
||||
} else if (dcc == J2DTexMtxInfo::DCC_MAYA) {
|
||||
getTextureMtxMaya(mInfo.mTexSRTInfo, mTexMtx);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTexMtx::getTextureMtx(J2DTextureSRTInfo const& param_0, Vec param_1, Mtx param_2) {
|
||||
float f31 = (param_0.mRotationDeg * M_PI) / 180.0f;
|
||||
param_2[0][0] = param_0.mScaleX * cosf(f31);
|
||||
param_2[0][1] = -param_0.mScaleX * sinf(f31);
|
||||
param_2[0][2] = 0.0f;
|
||||
param_2[0][3] = -param_0.mScaleX * cosf(f31) * param_1.x + param_1.y * (param_0.mScaleX * sinf(f31)) +
|
||||
param_1.x + param_0.mTranslationX;
|
||||
param_2[1][0] = param_0.mScaleY * sinf(f31);
|
||||
param_2[1][1] = param_0.mScaleY * cosf(f31);
|
||||
param_2[1][2] = 0.0f;
|
||||
param_2[1][3] = -param_0.mScaleY * sinf(f31) * param_1.x - param_1.y * (param_0.mScaleY * cosf(f31)) +
|
||||
param_1.y + param_0.mTranslationY;
|
||||
param_2[2][0] = 0.0f;
|
||||
param_2[2][1] = 0.0f;
|
||||
param_2[2][2] = 1.0f;
|
||||
param_2[2][3] = 0.0f;
|
||||
}
|
||||
|
||||
void J2DTexMtx::getTextureMtxMaya(J2DTextureSRTInfo const& param_0, Mtx param_1) {
|
||||
float f31 = (param_0.mRotationDeg * M_PI) / 180.0f;
|
||||
param_1[0][0] = param_0.mScaleX * cosf(f31);
|
||||
param_1[0][1] = param_0.mScaleY * sinf(f31);
|
||||
param_1[0][2] = 0.0f;
|
||||
param_1[0][3] = (param_0.mTranslationX - 0.5f) * cosf(f31) -
|
||||
(param_0.mTranslationY - 0.5f + param_0.mScaleY) * sinf(f31) + 0.5f;
|
||||
param_1[1][0] = -param_0.mScaleX * sinf(f31);
|
||||
param_1[1][1] = param_0.mScaleY * cosf(f31);
|
||||
param_1[1][2] = 0.0f;
|
||||
param_1[1][3] = -(param_0.mTranslationX - 0.5f) * sinf(f31) -
|
||||
(param_0.mTranslationY - 0.5f + param_0.mScaleY) * cosf(f31) + 0.5f;
|
||||
param_1[2][0] = 0.0f;
|
||||
param_1[2][1] = 0.0f;
|
||||
param_1[2][2] = 1.0f;
|
||||
param_1[2][3] = 0.0f;
|
||||
}
|
||||
|
||||
void J2DIndTevStage::load(u8 tevStage) {
|
||||
GXSetTevIndirect((GXTevStageID)tevStage, (GXIndTexStageID)getIndStage(), (GXIndTexFormat)getIndFormat(), (GXIndTexBiasSel)getBiasSel(),
|
||||
(GXIndTexMtxID)getMtxSel(), (GXIndTexWrap)getWrapS(), (GXIndTexWrap)getWrapT(), (GXBool)getPrev(), (GXBool)getLod(), (GXIndTexAlphaSel)getAlphaSel());
|
||||
}
|
||||
|
||||
void J2DIndTexMtx::load(u8 indTexMtx) {
|
||||
GXSetIndTexMtx((GXIndTexMtxID)(GX_ITM_0 + indTexMtx), mIndTexMtxInfo.mMtx,
|
||||
mIndTexMtxInfo.mScaleExp);
|
||||
}
|
||||
|
||||
void J2DIndTexCoordScale::load(u8 indTexStage) {
|
||||
GXSetIndTexCoordScale((GXIndTexStageID)indTexStage, (GXIndTexScale)mInfo.mScaleS, (GXIndTexScale)mInfo.mScaleT);
|
||||
}
|
||||
|
||||
void J2DIndTexOrder::load(u8 indTexStage) {
|
||||
GXSetIndTexOrder((GXIndTexStageID)indTexStage, (GXTexCoordID)mInfo.mTexCoordID, (GXTexMapID)mInfo.mTexMapID);
|
||||
}
|
||||
|
||||
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);
|
||||
J2DGXColorS10 color(*block->getTevColor(0));
|
||||
block->getTevStage(0);
|
||||
block->getTevSwapModeTable(0);
|
||||
}
|
||||
|
||||
J2DTexCoordInfo const j2dDefaultTexCoordInfo[8] = {
|
||||
{GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX1, GX_IDENTITY, 0},
|
||||
{GX_TG_MTX2x4, GX_TG_TEX2, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX3, GX_IDENTITY, 0},
|
||||
{GX_TG_MTX2x4, GX_TG_TEX4, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX5, GX_IDENTITY, 0},
|
||||
{GX_TG_MTX2x4, GX_TG_TEX6, GX_IDENTITY, 0}, {GX_TG_MTX2x4, GX_TG_TEX7, GX_IDENTITY, 0},
|
||||
};
|
||||
|
||||
J2DTexMtxInfo const j2dDefaultTexMtxInfo = {1, 1, 255, 255, 0.5f, 0.5f,
|
||||
0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo = {{0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f}, 1};
|
||||
|
||||
J2DTevStageInfo const j2dDefaultTevStageInfo = {
|
||||
4, GX_CC_RASC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV, GX_TEV_ADD,
|
||||
GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV, GX_CA_RASA, GX_CA_ZERO,
|
||||
GX_CA_ZERO, GX_CA_APREV, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1,
|
||||
GX_TEVPREV};
|
||||
|
||||
const J2DIndTevStageInfo j2dDefaultIndTevStageInfo = {
|
||||
GX_INDTEXSTAGE0, GX_ITB_NONE, GX_ITB_NONE, GX_ITM_OFF, GX_ITW_OFF,
|
||||
GX_ITW_OFF, 0, 0, GX_ITBA_OFF,
|
||||
};
|
||||
|
||||
const GXColor j2dDefaultColInfo = {255, 255, 255, 255};
|
||||
|
||||
const J2DTevOrderInfo j2dDefaultTevOrderInfoNull = {
|
||||
GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL, 0};
|
||||
|
||||
const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull = {
|
||||
GX_TEXCOORD_NULL,
|
||||
GX_TEXMAP_NULL,
|
||||
};
|
||||
|
||||
const GXColorS10 j2dDefaultTevColor = {255, 255, 255, 255};
|
||||
|
||||
const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo = {
|
||||
GX_ITS_1,
|
||||
GX_ITS_1,
|
||||
};
|
||||
|
||||
const GXColor j2dDefaultTevKColor = {255, 255, 255, 255};
|
||||
|
||||
const J2DTevSwapModeInfo j2dDefaultTevSwapMode = {GX_TEV_SWAP0, GX_TEV_SWAP0, 0, 0};
|
||||
|
||||
const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable = {
|
||||
GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA};
|
||||
|
||||
const J2DBlendInfo j2dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA,
|
||||
GX_LO_NOOP};
|
||||
|
||||
const u8 j2dDefaultPEBlockDither = 0;
|
||||
|
||||
const J2DColorChanInfo j2dDefaultColorChanInfo = {0, 3, 0, 0};
|
||||
|
||||
const u8 j2dDefaultTevSwapTableID = 0x1B;
|
||||
|
||||
const u16 j2dDefaultAlphaCmp = 0x00E7;
|
||||
@@ -0,0 +1,449 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DTextBox.h"
|
||||
#include "JSystem/J2DGraph/J2DPrint.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "JSystem/JUtility/JUTResFont.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
#include <cstring>
|
||||
|
||||
J2DTextBox::J2DTextBox()
|
||||
: mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL), mWhiteColor(), mBlackColor() {
|
||||
initiate(NULL, NULL, 0, HBIND_LEFT, VBIND_TOP);
|
||||
}
|
||||
|
||||
J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, JKRArchive* p_archive)
|
||||
: mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL), mWhiteColor(), mBlackColor() {
|
||||
private_readStream(p_pane, p_stream, p_archive);
|
||||
}
|
||||
|
||||
J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, u32 param_2,
|
||||
J2DMaterial* p_material)
|
||||
: mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL), mWhiteColor(), mBlackColor() {
|
||||
J2DTextBoxInfo info;
|
||||
|
||||
int startPos = p_stream->getPosition();
|
||||
|
||||
J2DTbxBlockHeader header;
|
||||
p_stream->read(&header, 8);
|
||||
mKind = 'TBX1';
|
||||
|
||||
int panHeaderPos = p_stream->getPosition();
|
||||
J2DTbxBlockHeader panHeader;
|
||||
p_stream->peek(&panHeader, 8);
|
||||
makePaneExStream(p_pane, p_stream);
|
||||
p_stream->seek(panHeaderPos + panHeader.mSize, JSUStreamSeekFrom_SET);
|
||||
|
||||
p_stream->read(&info, 0x20);
|
||||
J2DMaterial* mat = NULL;
|
||||
|
||||
if (info.mMaterialNum != 0xFFFF) {
|
||||
mat = &p_material[info.mMaterialNum];
|
||||
|
||||
if (mat != NULL) {
|
||||
if (mat->getTevBlock() != NULL) {
|
||||
JUTFont* font = mat->getTevBlock()->getFont();
|
||||
|
||||
if (font != NULL) {
|
||||
mFont = font;
|
||||
mat->getTevBlock()->setFontUndeleteFlag();
|
||||
}
|
||||
}
|
||||
mAlpha = mat->getColorBlock()->getMatColor(0)->a;
|
||||
}
|
||||
}
|
||||
|
||||
mCharSpacing = info.mCharSpace;
|
||||
mLineSpacing = info.mLineSpace;
|
||||
mFontSizeX = info.mFontSizeX;
|
||||
mFontSizeY = info.mFontSizeY;
|
||||
mFlags = (info.mHBind << 2) | info.mVBind;
|
||||
mCharColor = JUtility::TColor(info.mCharColor);
|
||||
mGradientColor = JUtility::TColor(info.mGradColor);
|
||||
setConnectParent(info.mConnected);
|
||||
|
||||
u16 strLength = 0;
|
||||
if (!(param_2 & 0x2000000)) {
|
||||
strLength = info.field_0x1c;
|
||||
if ((s16)info.field_0x1c == -1) {
|
||||
strLength = info.field_0x1e + 1;
|
||||
}
|
||||
}
|
||||
|
||||
mStringLength = 0;
|
||||
mStringPtr = NULL;
|
||||
|
||||
if (strLength != 0) {
|
||||
mStringPtr = new char[strLength];
|
||||
}
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
mStringLength = strLength;
|
||||
|
||||
u16 var_r26_2 = strLength - 1 < info.field_0x1e ? u16(strLength - 1) : info.field_0x1e;
|
||||
|
||||
p_stream->peek(mStringPtr, var_r26_2);
|
||||
mStringPtr[var_r26_2] = 0;
|
||||
}
|
||||
|
||||
p_stream->skip(info.field_0x1e);
|
||||
p_stream->seek(startPos + header.mSize, JSUStreamSeekFrom_SET);
|
||||
mBlackColor = JUtility::TColor(0);
|
||||
mWhiteColor = JUtility::TColor(0xFFFFFFFF);
|
||||
|
||||
if (mat != NULL && mat->getTevBlock() != NULL) {
|
||||
u8 tevStageNum = u32(mat->getTevBlock()->getTevStageNum());
|
||||
if (tevStageNum != 1) {
|
||||
J2DGXColorS10 color0(*mat->getTevBlock()->getTevColor(0));
|
||||
|
||||
J2DGXColorS10 color1(*mat->getTevBlock()->getTevColor(1));
|
||||
|
||||
mBlackColor = JUtility::TColor(((u8)color0.r << 0x18) | ((u8)color0.g << 0x10) |
|
||||
((u8)color0.b << 8) | (u8)color0.a);
|
||||
mWhiteColor = JUtility::TColor(((u8)color1.r << 0x18) | ((u8)color1.g << 0x10) |
|
||||
((u8)color1.b << 8) | (u8)color1.a);
|
||||
}
|
||||
}
|
||||
|
||||
field_0x10c = 0.0f;
|
||||
field_0x110 = 0.0f;
|
||||
mTextFontOwned = true;
|
||||
}
|
||||
|
||||
J2DTextBox::J2DTextBox(u64 tag, JGeometry::TBox2<f32> const& bounds, ResFONT const* p_font,
|
||||
char const* string, s16 strLength, J2DTextBoxHBinding hBind,
|
||||
J2DTextBoxVBinding vBind)
|
||||
: J2DPane(tag, bounds), mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL),
|
||||
mWhiteColor(), mBlackColor() {
|
||||
initiate(p_font, string, strLength, hBind, vBind);
|
||||
}
|
||||
|
||||
void J2DTextBox::initiate(ResFONT const* p_font, char const* string, s16 length,
|
||||
J2DTextBoxHBinding hBind, J2DTextBoxVBinding vBind) {
|
||||
if (p_font != NULL) {
|
||||
mFont = new JUTResFont(p_font, NULL);
|
||||
}
|
||||
|
||||
mCharColor.set(0xFFFFFFFF);
|
||||
mGradientColor.set(0xFFFFFFFF);
|
||||
mBlackColor = JUtility::TColor(0);
|
||||
mWhiteColor = JUtility::TColor(0xFFFFFFFF);
|
||||
|
||||
mFlags = (hBind << 2) | vBind;
|
||||
mStringLength = 0;
|
||||
mStringPtr = NULL;
|
||||
|
||||
if (string != NULL && length != 0) {
|
||||
u32 len = strlen(string);
|
||||
u16 stringLen = length;
|
||||
|
||||
if (length == -1) {
|
||||
if (len >= 0xFFFF) {
|
||||
len = 0xFFFF - 1;
|
||||
}
|
||||
stringLen = len + 1;
|
||||
}
|
||||
|
||||
mStringPtr = new char[stringLen];
|
||||
|
||||
if (stringLen != 0 && mStringPtr != NULL) {
|
||||
strncpy(mStringPtr, string, stringLen - 1);
|
||||
mStringPtr[stringLen - 1] = 0;
|
||||
mStringLength = stringLen;
|
||||
}
|
||||
}
|
||||
|
||||
field_0x10c = 0.0f;
|
||||
field_0x110 = 0.0f;
|
||||
mCharSpacing = 0.0f;
|
||||
|
||||
if (mFont == NULL) {
|
||||
mLineSpacing = 0.0f;
|
||||
mFontSizeX = 0.0f;
|
||||
mFontSizeY = 0.0f;
|
||||
} else {
|
||||
mLineSpacing = mFont->getLeading();
|
||||
mFontSizeX = mFont->getWidth();
|
||||
mFontSizeY = mFont->getHeight();
|
||||
}
|
||||
|
||||
mKind = 'TBX1';
|
||||
mTextFontOwned = true;
|
||||
}
|
||||
|
||||
void J2DTextBox::private_readStream(J2DPane* p_pane, JSURandomInputStream* p_stream,
|
||||
JKRArchive* p_archive) {
|
||||
int position = p_stream->getPosition();
|
||||
|
||||
J2DTbxBlockHeader header;
|
||||
p_stream->read(&header, 8);
|
||||
mKind = header.mTag;
|
||||
|
||||
makePaneStream(p_pane, p_stream);
|
||||
{JUTResReference ref;}
|
||||
u8 spA = p_stream->readU8();
|
||||
|
||||
ResFONT* fontPtr = (ResFONT*)getPointer(p_stream, 'FONT', p_archive);
|
||||
if (fontPtr != NULL) {
|
||||
mFont = new JUTResFont(fontPtr, NULL);
|
||||
}
|
||||
|
||||
mCharColor.set(p_stream->read32b());
|
||||
mGradientColor.set(p_stream->read32b());
|
||||
u8 tmp = p_stream->read8b();
|
||||
mFlags = tmp;
|
||||
mCharSpacing = p_stream->readS16();
|
||||
mLineSpacing = p_stream->readS16();
|
||||
mFontSizeX = p_stream->read16b();
|
||||
mFontSizeY = p_stream->read16b();
|
||||
|
||||
s16 stringLen = p_stream->read16b();
|
||||
mStringPtr = new char[stringLen + 1];
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
p_stream->read(mStringPtr, stringLen);
|
||||
mStringPtr[stringLen] = 0;
|
||||
mStringLength = stringLen + 1;
|
||||
} else {
|
||||
p_stream->skip(stringLen);
|
||||
mStringLength = 0;
|
||||
}
|
||||
|
||||
spA -= 10;
|
||||
if (spA != 0) {
|
||||
tmp = p_stream->read8b();
|
||||
if (tmp != 0) {
|
||||
setConnectParent(true);
|
||||
}
|
||||
|
||||
spA--;
|
||||
}
|
||||
|
||||
mBlackColor = JUtility::TColor(0);
|
||||
mWhiteColor = JUtility::TColor(0xFFFFFFFF);
|
||||
|
||||
if (spA != 0) {
|
||||
mBlackColor.set(p_stream->read32b());
|
||||
spA--;
|
||||
}
|
||||
|
||||
if (spA != 0) {
|
||||
mWhiteColor.set(p_stream->read32b());
|
||||
spA--;
|
||||
}
|
||||
|
||||
field_0x10c = 0.0f;
|
||||
field_0x110 = 0.0f;
|
||||
p_stream->seek(position + header.mSize, JSUStreamSeekFrom_SET);
|
||||
mTextFontOwned = true;
|
||||
}
|
||||
|
||||
J2DTextBox::~J2DTextBox() {
|
||||
if (mTextFontOwned) {
|
||||
delete mFont;
|
||||
}
|
||||
|
||||
delete[] mStringPtr;
|
||||
}
|
||||
|
||||
void J2DTextBox::setFont(JUTFont* p_font) {
|
||||
if (p_font) {
|
||||
if (mTextFontOwned) {
|
||||
delete mFont;
|
||||
}
|
||||
mFont = p_font;
|
||||
mTextFontOwned = false;
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBox::draw(f32 posX, f32 posY) {
|
||||
Mtx m;
|
||||
|
||||
if (isVisible()) {
|
||||
J2DPrint print(mFont, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
|
||||
mWhiteColor);
|
||||
print.setFontSize(mFontSizeX, mFontSizeY);
|
||||
makeMatrix(posX, posY, 0.0f, 0.0f);
|
||||
|
||||
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
|
||||
GXSetCurrentMtx(0);
|
||||
GXSetNumIndStages(0);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetNumTexGens(1);
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60);
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
print.print(0.0f, 0.0f, mAlpha, "%s", mStringPtr);
|
||||
}
|
||||
MTXIdentity(m);
|
||||
GXLoadPosMtxImm(m, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBox::draw(f32 posX, f32 posY, f32 param_2, J2DTextBoxHBinding hBind) {
|
||||
Mtx m;
|
||||
|
||||
if (isVisible()) {
|
||||
J2DPrint print(mFont, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
|
||||
mWhiteColor);
|
||||
print.setFontSize(mFontSizeX, mFontSizeY);
|
||||
makeMatrix(posX, posY, 0.0f, 0.0f);
|
||||
|
||||
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
|
||||
GXSetCurrentMtx(0);
|
||||
GXSetNumIndStages(0);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetNumTexGens(1);
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60);
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
print.printReturn(mStringPtr, param_2, 0.0f, hBind, VBIND_TOP, 0.0f, -mFontSizeY,
|
||||
mAlpha);
|
||||
}
|
||||
MTXIdentity(m);
|
||||
GXLoadPosMtxImm(m, 0);
|
||||
}
|
||||
}
|
||||
|
||||
char* J2DTextBox::getStringPtr() const {
|
||||
return mStringPtr;
|
||||
}
|
||||
|
||||
s32 J2DTextBox::setString(char const* string, ...) {
|
||||
va_list args;
|
||||
va_start(args, string);
|
||||
|
||||
delete[] mStringPtr;
|
||||
|
||||
u32 len = strlen(string);
|
||||
|
||||
if (len >= 0xFFFF) {
|
||||
len = 0xFFFF - 1;
|
||||
}
|
||||
|
||||
mStringLength = 0;
|
||||
mStringPtr = new char[len + 1];
|
||||
|
||||
if (mStringPtr) {
|
||||
mStringLength = len + 1;
|
||||
strcpy(mStringPtr, string);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
return len;
|
||||
}
|
||||
|
||||
s32 J2DTextBox::setString(s16 length, char const* string, ...) {
|
||||
va_list args;
|
||||
va_start(args, string);
|
||||
|
||||
delete[] mStringPtr;
|
||||
mStringPtr = NULL;
|
||||
|
||||
u32 len = strlen(string);
|
||||
u16 stringLen = length;
|
||||
|
||||
if (length == -1) {
|
||||
if (len >= 0xFFFF) {
|
||||
len = 0xFFFF - 1;
|
||||
}
|
||||
stringLen = len + 1;
|
||||
}
|
||||
|
||||
mStringLength = 0;
|
||||
|
||||
if (stringLen != 0) {
|
||||
mStringPtr = new char[stringLen];
|
||||
}
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
strncpy(mStringPtr, string, stringLen - 1);
|
||||
mStringPtr[stringLen - 1] = 0;
|
||||
mStringLength = stringLen;
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
return len;
|
||||
}
|
||||
|
||||
bool J2DTextBox::setConnectParent(bool connected) {
|
||||
if (getPaneTree()->getParent() == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getPaneTree()->getParent()->getObject()->getTypeID() != 0x11) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mConnected = connected;
|
||||
return connected;
|
||||
}
|
||||
|
||||
void J2DTextBox::drawSelf(f32 param_0, f32 param_1) {
|
||||
Mtx identity;
|
||||
MTXIdentity(identity);
|
||||
|
||||
drawSelf(param_0, param_1, &identity);
|
||||
}
|
||||
|
||||
void J2DTextBox::drawSelf(f32 param_0, f32 param_1, Mtx* p_mtx) {
|
||||
Mtx m;
|
||||
|
||||
J2DPrint print(mFont, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
|
||||
mWhiteColor);
|
||||
print.setFontSize(mFontSizeX, mFontSizeY);
|
||||
MTXConcat(*p_mtx, mGlobalMtx, m);
|
||||
|
||||
GXLoadPosMtxImm(m, GX_PNMTX0);
|
||||
GXSetNumIndStages(0);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetNumTexGens(1);
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60);
|
||||
|
||||
print.locate(param_0 + mBounds.i.x, param_1 + mBounds.i.y);
|
||||
if (mStringPtr != NULL) {
|
||||
print.printReturn(mStringPtr, mBounds.getWidth() + 0.0001f, mBounds.getHeight(),
|
||||
getHBinding(), getVBinding(), field_0x10c, field_0x110, mColorAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBox::resize(f32 x, f32 y) {
|
||||
if (mConnected && getPaneTree() != NULL && getPaneTree()->getParent() != NULL) {
|
||||
J2DPane* obj = getPaneTree()->getParent()->getObject();
|
||||
|
||||
if (obj->getTypeID() == 0x11) {
|
||||
f32 obj_x = obj->getWidth() + (x - getWidth());
|
||||
f32 obj_y = obj->getHeight() + (y - getHeight());
|
||||
obj->resize(obj_x, obj_y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
J2DPane::resize(x, y);
|
||||
}
|
||||
|
||||
bool J2DTextBox::isUsed(ResFONT const* p_font) {
|
||||
if (mFont != NULL && mFont->getResFont() == p_font) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return J2DPane::isUsed(p_font);
|
||||
}
|
||||
|
||||
u16 J2DTextBox::getTypeID() const {
|
||||
return 19;
|
||||
}
|
||||
|
||||
bool J2DTextBox::isUsed(ResTIMG const* p_timg) {
|
||||
return J2DPane::isUsed(p_timg);
|
||||
}
|
||||
|
||||
void J2DTextBox::rewriteAlpha() {
|
||||
/* empty function */
|
||||
}
|
||||
@@ -0,0 +1,536 @@
|
||||
//
|
||||
// J2DTextBoxEx
|
||||
//
|
||||
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DTextBoxEx.h"
|
||||
#include "JSystem/J2DGraph/J2DPrint.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "JSystem/JUtility/JUTResFont.h"
|
||||
|
||||
J2DTextBoxEx::J2DTextBoxEx(J2DPane* p_pane, JSURandomInputStream* p_stream, u32 param_2,
|
||||
J2DMaterial* p_material) {
|
||||
J2DTextBoxInfo info;
|
||||
|
||||
mVisibilityAnm = NULL;
|
||||
|
||||
int startPos = p_stream->getPosition();
|
||||
|
||||
J2DTbxBlockHeader header;
|
||||
p_stream->read(&header, 8);
|
||||
mKind = header.mTag;
|
||||
|
||||
int panHeaderPos = p_stream->getPosition();
|
||||
J2DTbxBlockHeader panHeader;
|
||||
p_stream->peek(&panHeader, 8);
|
||||
makePaneExStream(p_pane, p_stream);
|
||||
p_stream->seek(panHeaderPos + panHeader.mSize, JSUStreamSeekFrom_SET);
|
||||
|
||||
p_stream->read(&info, 0x20);
|
||||
field_0x13c = info.field_0x2;
|
||||
field_0x13e = info.mMaterialNum;
|
||||
mMaterial = NULL;
|
||||
|
||||
if (field_0x13e != 0xFFFF) {
|
||||
mMaterial = &p_material[field_0x13e];
|
||||
p_material[field_0x13e].field_0x4 = this;
|
||||
rewriteAlpha();
|
||||
|
||||
if (mMaterial != NULL) {
|
||||
if (mMaterial->getTevBlock() != NULL) {
|
||||
mFont = mMaterial->getTevBlock()->getFont();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mCharSpacing = info.mCharSpace;
|
||||
mLineSpacing = info.mLineSpace;
|
||||
mFontSizeX = info.mFontSizeX;
|
||||
mFontSizeY = info.mFontSizeY;
|
||||
mFlags = (info.mHBind << 2) | info.mVBind;
|
||||
mCharColor = JUtility::TColor(info.mCharColor);
|
||||
mGradientColor = JUtility::TColor(info.mGradColor);
|
||||
setConnectParent(info.mConnected);
|
||||
|
||||
u16 strLength = 0;
|
||||
if (!(param_2 & 0x2000000)) {
|
||||
strLength = info.field_0x1c;
|
||||
if ((s16)info.field_0x1c == -1) {
|
||||
strLength = info.field_0x1e + 1;
|
||||
}
|
||||
}
|
||||
|
||||
mStringLength = 0;
|
||||
mStringPtr = NULL;
|
||||
|
||||
if (strLength != 0) {
|
||||
mStringPtr = new char[strLength];
|
||||
}
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
mStringLength = strLength;
|
||||
|
||||
u16 var_r26_2 = strLength - 1 < info.field_0x1e ? u16(strLength - 1) : info.field_0x1e;
|
||||
|
||||
p_stream->peek(mStringPtr, var_r26_2);
|
||||
mStringPtr[var_r26_2] = 0;
|
||||
}
|
||||
|
||||
p_stream->skip(info.field_0x1e);
|
||||
p_stream->seek(startPos + header.mSize, JSUStreamSeekFrom_SET);
|
||||
|
||||
field_0x10c = 0.0f;
|
||||
field_0x110 = 0.0f;
|
||||
mTextFontOwned = false;
|
||||
field_0x140 = 0;
|
||||
}
|
||||
|
||||
J2DTextBoxEx::~J2DTextBoxEx() {
|
||||
if (field_0x140 != 0) {
|
||||
delete mMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::drawSelf(f32 param_0, f32 param_1, Mtx* p_mtx) {
|
||||
Mtx m;
|
||||
|
||||
JUTFont* font = NULL;
|
||||
if (mMaterial != NULL && mMaterial->getTevBlock() != NULL) {
|
||||
font = mMaterial->getTevBlock()->getFont();
|
||||
}
|
||||
|
||||
J2DPrint print(font, (int)mCharSpacing, (int)mLineSpacing, mCharColor, mGradientColor, mBlackColor,
|
||||
mWhiteColor);
|
||||
print.setFontSize((int)mFontSizeX, (int)mFontSizeY);
|
||||
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->setGX();
|
||||
MTXConcat(*p_mtx, mGlobalMtx, m);
|
||||
|
||||
GXLoadPosMtxImm(m, GX_PNMTX0);
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
print.locate(param_0 + mBounds.i.x, param_1 + mBounds.i.y);
|
||||
|
||||
if (mMaterial->isVisible() && mStringPtr != NULL) {
|
||||
u8 alpha = 255;
|
||||
|
||||
if (mMaterial->getColorBlock()->getColorChan(1)->getMatSrc() == 1) {
|
||||
if (mMaterial->getMaterialAlphaCalc() == 1) {
|
||||
alpha = mColorAlpha;
|
||||
}
|
||||
} else if (mIsInfluencedAlpha) {
|
||||
GXSetChanMatColor(GX_ALPHA0, JUtility::TColor(mColorAlpha));
|
||||
}
|
||||
|
||||
print.printReturn(mStringPtr, (int)(mBounds.getWidth() + 0.0001f), (int)mBounds.getHeight(),
|
||||
getHBinding(), getVBinding(), field_0x10c, field_0x110, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::draw(f32 posX, f32 posY) {
|
||||
Mtx m;
|
||||
|
||||
if (isVisible()) {
|
||||
JUTFont* font = NULL;
|
||||
if (mMaterial != NULL && mMaterial->getTevBlock() != NULL) {
|
||||
font = mMaterial->getTevBlock()->getFont();
|
||||
}
|
||||
|
||||
J2DPrint print(font, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
|
||||
mWhiteColor);
|
||||
print.setFontSize(mFontSizeX, mFontSizeY);
|
||||
mColorAlpha = mAlpha;
|
||||
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->setGX();
|
||||
makeMatrix(posX, posY, 0.0f, 0.0f);
|
||||
|
||||
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
|
||||
GXSetCurrentMtx(0);
|
||||
|
||||
if (!mMaterial->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
u8 alpha = 255;
|
||||
if (mMaterial->getMaterialAlphaCalc() == 1) {
|
||||
alpha = mColorAlpha;
|
||||
}
|
||||
|
||||
print.print(0.0f, 0.0f, alpha, "%s", mStringPtr);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
GXSetTevSwapModeTable((GXTevSwapSel)i, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA);
|
||||
}
|
||||
|
||||
GXSetNumIndStages(0);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
|
||||
MTXIdentity(m);
|
||||
GXLoadPosMtxImm(m, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::draw(f32 posX, f32 posY, f32 param_2, J2DTextBoxHBinding hBind) {
|
||||
Mtx m;
|
||||
|
||||
if (isVisible()) {
|
||||
JUTFont* font = NULL;
|
||||
if (mMaterial != NULL && mMaterial->getTevBlock() != NULL) {
|
||||
font = mMaterial->getTevBlock()->getFont();
|
||||
}
|
||||
|
||||
J2DPrint print(font, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
|
||||
mWhiteColor);
|
||||
print.setFontSize(mFontSizeX, mFontSizeY);
|
||||
mColorAlpha = mAlpha;
|
||||
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->setGX();
|
||||
makeMatrix(posX, posY, 0.0f, 0.0f);
|
||||
|
||||
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
|
||||
GXSetCurrentMtx(0);
|
||||
|
||||
if (!mMaterial->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
u8 alpha = 255;
|
||||
if (mMaterial->getMaterialAlphaCalc() == 1) {
|
||||
alpha = mColorAlpha;
|
||||
}
|
||||
|
||||
print.printReturn(mStringPtr, param_2, 0.0f, hBind, VBIND_TOP, 0.0f, -mFontSizeY,
|
||||
alpha);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
GXSetTevSwapModeTable((GXTevSwapSel)i, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA);
|
||||
}
|
||||
|
||||
GXSetNumIndStages(0);
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
|
||||
MTXIdentity(m);
|
||||
GXLoadPosMtxImm(m, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setFont(JUTFont* p_font) {
|
||||
if (p_font != NULL && mMaterial != NULL && mMaterial->getTevBlock() != NULL) {
|
||||
mMaterial->getTevBlock()->setFont(p_font);
|
||||
mFont = p_font;
|
||||
}
|
||||
}
|
||||
|
||||
JUTFont* J2DTextBoxEx::getFont() const {
|
||||
if (mMaterial != NULL && mMaterial->getTevBlock() != NULL) {
|
||||
return mMaterial->getTevBlock()->getFont();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setTevOrder(bool param_0) {
|
||||
u16 local_18[2];
|
||||
if (!param_0) {
|
||||
local_18[0] = 4;
|
||||
local_18[1] = 0xffff;
|
||||
} else {
|
||||
local_18[0] = 0xff;
|
||||
local_18[1] = 0xff04;
|
||||
}
|
||||
for (u8 i = 0; i < 2; i++) {
|
||||
if (mMaterial->getTevBlock()->getMaxStage() > i) {
|
||||
J2DTevOrderInfo info;
|
||||
info.mTexCoord = (local_18[i]) >> 8;
|
||||
info.mTexMap = (local_18[i]) >> 8;
|
||||
info.mColor = local_18[i] & 0xff;
|
||||
J2DTevOrder tevOrder = info;
|
||||
mMaterial->getTevBlock()->setTevOrder(i, tevOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setTevStage(bool param_0) {
|
||||
J2DTevStage* stage = mMaterial->getTevBlock()->getTevStage(0);
|
||||
|
||||
if (!param_0) {
|
||||
setStage(stage, STAGE_0);
|
||||
} else {
|
||||
setStage(stage, STAGE_1);
|
||||
stage = mMaterial->getTevBlock()->getTevStage(1);
|
||||
setStage(stage, STAGE_2);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setStage(J2DTevStage* param_0, J2DTextBoxEx::stage_enum param_1) {
|
||||
const u8 tevColors[3][4] = {
|
||||
{0x0F, 0x08, 0x0A, 0x0F}, {0x02, 0x04, 0x08, 0x0F}, {0x0F, 0x0A, 0x00, 0x0F},
|
||||
};
|
||||
const u8 tevAlpha[3][4] = {
|
||||
{0x07, 0x04, 0x05, 0x07}, {0x01, 0x02, 0x04, 0x07}, {0x07, 0x05, 0x00, 0x07},
|
||||
};
|
||||
|
||||
const u8 tevColorOps[3][5] = {
|
||||
{0x00, 0x00, 0x00, 0x01, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x01, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x01, 0x00},
|
||||
};
|
||||
|
||||
const u8 tevAlphaOps[3][5] = {
|
||||
{0x00, 0x00, 0x00, 0x01, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x01, 0x00},
|
||||
{0x00, 0x00, 0x00, 0x01, 0x00},
|
||||
};
|
||||
|
||||
param_0->setTevColorAB(tevColors[param_1][0], tevColors[param_1][1]);
|
||||
param_0->setTevColorCD(tevColors[param_1][2], tevColors[param_1][3]);
|
||||
param_0->setTevColorOp(
|
||||
tevColorOps[param_1][0], tevColorOps[param_1][1], tevColorOps[param_1][2], tevColorOps[param_1][3], tevColorOps[param_1][4]);
|
||||
param_0->setAlphaABCD(
|
||||
tevAlpha[param_1][0], tevAlpha[param_1][1], tevAlpha[param_1][2], tevAlpha[param_1][3]);
|
||||
param_0->setTevAlphaOp(
|
||||
tevAlphaOps[param_1][0], tevAlphaOps[param_1][1], tevAlphaOps[param_1][2], tevAlphaOps[param_1][3], tevAlphaOps[param_1][4]);
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::setBlack(JUtility::TColor black) {
|
||||
JUtility::TColor tevBlack;
|
||||
JUtility::TColor tevWhite;
|
||||
|
||||
if (!getBlackWhite(&tevBlack, &tevWhite)) {
|
||||
return false;
|
||||
} else {
|
||||
return setBlackWhite(black, tevWhite);
|
||||
}
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::setWhite(JUtility::TColor white) {
|
||||
JUtility::TColor tevBlack;
|
||||
JUtility::TColor tevWhite;
|
||||
|
||||
if (!getBlackWhite(&tevBlack, &tevWhite)) {
|
||||
return false;
|
||||
} else {
|
||||
return setBlackWhite(tevBlack, white);
|
||||
}
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::setBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) {
|
||||
if (mMaterial == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mMaterial->getTevBlock() == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isSetBlackWhite(param_0, param_1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bvar = (param_0 != 0) || (param_1 != -1);
|
||||
|
||||
u8 stageNum = bvar ? 2 : 1;
|
||||
mMaterial->getTevBlock()->setTevStageNum(stageNum);
|
||||
setTevOrder(bvar);
|
||||
setTevStage(bvar);
|
||||
|
||||
if (bvar) {
|
||||
J2DGXColorS10 color;
|
||||
color.r = param_0.r;
|
||||
color.g = param_0.g;
|
||||
color.b = param_0.b;
|
||||
color.a = param_0.a;
|
||||
mMaterial->getTevBlock()->setTevColor(0, color);
|
||||
|
||||
color.r = param_1.r;
|
||||
color.g = param_1.g;
|
||||
color.b = param_1.b;
|
||||
color.a = param_1.a;
|
||||
mMaterial->getTevBlock()->setTevColor(1, color);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::getBlackWhite(JUtility::TColor* param_0, JUtility::TColor* param_1) const {
|
||||
if (mMaterial == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mMaterial->getTevBlock() == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 tevStageNum = mMaterial->getTevBlock()->getTevStageNum();
|
||||
bool manyTevStages = tevStageNum == 1 ? false : true;
|
||||
*param_0 = JUtility::TColor(0);
|
||||
*param_1 = JUtility::TColor(0xffffffff);
|
||||
if (manyTevStages) {
|
||||
J2DGXColorS10 color0(*mMaterial->getTevBlock()->getTevColor(0));
|
||||
J2DGXColorS10 color1(*mMaterial->getTevBlock()->getTevColor(1));
|
||||
*param_0 = JUtility::TColor(
|
||||
(((u8)color0.r) << 24) | (((u8)color0.g) << 16) | (((u8)color0.b) << 8) |
|
||||
((u8)color0.a));
|
||||
*param_1 = JUtility::TColor(
|
||||
(((u8)color1.r) << 24) | (((u8)color1.g) << 16) | (((u8)color1.b) << 8) |
|
||||
((u8)color1.a));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::isSetBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) const {
|
||||
if (param_0 == 0 && param_1 == 0xffffffff) {
|
||||
return 1;
|
||||
}
|
||||
u32 tevStageNum = mMaterial->getTevBlock()->getTevStageNum();
|
||||
u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
|
||||
if (maxStage == 1) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
JUtility::TColor J2DTextBoxEx::getBlack() const {
|
||||
JUtility::TColor black;
|
||||
JUtility::TColor white;
|
||||
if (getBlackWhite(&black, &white) == 0) {
|
||||
return JUtility::TColor(0);
|
||||
}
|
||||
return black;
|
||||
}
|
||||
|
||||
JUtility::TColor J2DTextBoxEx::getWhite() const {
|
||||
JUtility::TColor black;
|
||||
JUtility::TColor white;
|
||||
if (getBlackWhite(&black, &white) == 0) {
|
||||
return JUtility::TColor(0xffffffff);
|
||||
}
|
||||
return white;
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAlpha(u8 alpha) {
|
||||
mAlpha = alpha;
|
||||
|
||||
if (mMaterial == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mMaterial->getColorBlock()->getMatColor(0) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMaterial->getColorBlock()->getMatColor(0)->a = alpha;
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setCullBack(GXCullMode mode) {
|
||||
mCullMode = mode;
|
||||
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->getColorBlock()->setCullMode(mode);
|
||||
}
|
||||
|
||||
J2DPane::setCullBack(mode);
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::rewriteAlpha() {
|
||||
if (mMaterial == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAlpha = mMaterial->getColorBlock()->getMatColor(0)->a;
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::isUsed(ResFONT const* p_font) {
|
||||
if (getFont() != NULL && getFont()->getResFont() == p_font) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return J2DPane::isUsed(p_font);
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAnimation(J2DAnmColor* anm) {
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->setAnimation(anm);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAnimation(J2DAnmTextureSRTKey* anm) {
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->setAnimation(anm);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAnimation(J2DAnmTexPattern* anm) {
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->setAnimation(anm);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAnimation(J2DAnmTevRegKey* anm) {
|
||||
if (mMaterial != NULL) {
|
||||
mMaterial->setAnimation(anm);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAnimation(J2DAnmVisibilityFull* anm) {
|
||||
mVisibilityAnm = anm;
|
||||
}
|
||||
|
||||
const J2DAnmTransform* J2DTextBoxEx::animationPane(J2DAnmTransform const* param_0) {
|
||||
if (mVisibilityAnm != NULL && field_0x13c != 0xffff) {
|
||||
u8 visibility;
|
||||
mVisibilityAnm->getVisibility(field_0x13c, &visibility);
|
||||
if (visibility != 0) {
|
||||
show();
|
||||
} else {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
return J2DPane::animationPane(param_0);
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setCullBack(bool param_0) {
|
||||
setCullBack(param_0 ? GX_CULL_BACK : GX_CULL_NONE);
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::isUsed(ResTIMG const* p_timg) {
|
||||
return J2DPane::isUsed(p_timg);
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAnimation(J2DAnmVtxColor* param_0) {
|
||||
/* empty function */
|
||||
}
|
||||
|
||||
void J2DTextBoxEx::setAnimation(J2DAnmBase* anm) {
|
||||
J2DPane::setAnimation(anm);
|
||||
}
|
||||
@@ -0,0 +1,630 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DWindow.h"
|
||||
#include "JSystem/J2DGraph/J2DScreen.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "JSystem/JUtility/JUTPalette.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
#include "JSystem/JUtility/JUTTexture.h"
|
||||
|
||||
J2DWindow::J2DWindow()
|
||||
: field_0x100(NULL), field_0x104(NULL), field_0x108(NULL), field_0x10c(NULL), field_0x110(NULL),
|
||||
mPalette(NULL) {
|
||||
field_0x144 = 0;
|
||||
setContentsColor(JUtility::TColor(0xffffffff));
|
||||
mBlack = JUtility::TColor(0);
|
||||
mWhite = JUtility::TColor(0xffffffff);
|
||||
}
|
||||
|
||||
J2DWindow::J2DWindow(J2DPane* param_0, JSURandomInputStream* param_1, JKRArchive* param_2)
|
||||
: field_0x100(NULL), field_0x104(NULL), field_0x108(NULL), field_0x10c(NULL), field_0x110(NULL),
|
||||
mPalette(NULL) {
|
||||
private_readStream(param_0, param_1, param_2);
|
||||
}
|
||||
|
||||
struct J2DWindowData {
|
||||
u8 field_0x0[0x10];
|
||||
u16 field_0x10[4];
|
||||
u8 field_0x18;
|
||||
u8 field_0x19;
|
||||
u16 field_0x1a;
|
||||
u16 field_0x1c;
|
||||
u16 field_0x1e;
|
||||
u16 field_0x20;
|
||||
u16 field_0x22;
|
||||
u16 field_0x24;
|
||||
u8 field_0x26[0xa];
|
||||
u32 field_0x30[4];
|
||||
};
|
||||
|
||||
J2DWindow::J2DWindow(J2DPane* param_0, JSURandomInputStream* param_1, J2DMaterial* param_2) :
|
||||
field_0x100(NULL),
|
||||
field_0x104(NULL),
|
||||
field_0x108(NULL),
|
||||
field_0x10c(NULL),
|
||||
field_0x110(NULL),
|
||||
mPalette(NULL) {
|
||||
u32 auStack_78[2];
|
||||
u32 position = param_1->getPosition();
|
||||
param_1->read(auStack_78, 8);
|
||||
mKind = 'WIN1';
|
||||
u32 local_dc = param_1->getPosition();
|
||||
int auStack_b8[2];
|
||||
param_1->peek(auStack_b8, 8);
|
||||
makePaneExStream(param_0, param_1);
|
||||
param_1->seek(local_dc + auStack_b8[1], JSUStreamSeekFrom_SET);
|
||||
J2DWindowData buffer;
|
||||
param_1->read(&buffer, sizeof(J2DWindowData));
|
||||
|
||||
JUtility::TColor* colors[4] = {
|
||||
&field_0x128,
|
||||
&field_0x12C,
|
||||
&field_0x130,
|
||||
&field_0x134,
|
||||
};
|
||||
|
||||
u16 local_c0[4];
|
||||
J2DMaterial *local_98[4];
|
||||
for (int iVar7 = 0; iVar7 < 4; iVar7++) {
|
||||
local_c0[iVar7] = buffer.field_0x10[iVar7];
|
||||
local_98[iVar7] = NULL;
|
||||
if (local_c0[iVar7] != 0xffff) {
|
||||
local_98[iVar7] = param_2 + local_c0[iVar7];
|
||||
}
|
||||
*colors[iVar7] = JUtility::TColor(buffer.field_0x30[iVar7]);
|
||||
}
|
||||
|
||||
field_0x144 = buffer.field_0x18;
|
||||
field_0x114.set(
|
||||
buffer.field_0x1a,
|
||||
buffer.field_0x1c,
|
||||
buffer.field_0x1a + buffer.field_0x1e,
|
||||
buffer.field_0x1c + buffer.field_0x20);
|
||||
u16 temp = buffer.field_0x24;
|
||||
J2DMaterial* pJVar5 = NULL;
|
||||
if (temp != 0xffff) {
|
||||
pJVar5 = param_2 + temp;
|
||||
}
|
||||
|
||||
param_1->seek(position + auStack_78[1], JSUStreamSeekFrom_SET);
|
||||
if (local_98[0] != NULL) {
|
||||
mAlpha = local_98[0]->getColorBlock()->getMatColor(0)->a;
|
||||
}
|
||||
|
||||
mBlack = JUtility::TColor(0);
|
||||
mWhite = JUtility::TColor(0xffffffff);
|
||||
|
||||
if (local_98[0] != NULL && local_98[0]->getTevBlock() != NULL) {
|
||||
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)local_c8.r) << 24) | (((u8)local_c8.g) << 16) | (((u8)local_c8.b) << 8) |
|
||||
((u8)local_c8.a));
|
||||
mWhite = JUtility::TColor(
|
||||
(((u8)local_d0.r) << 24) | (((u8)local_d0.g) << 16) | (((u8)local_d0.b) << 8) |
|
||||
((u8)local_d0.a));
|
||||
}
|
||||
}
|
||||
|
||||
JUTTexture** textures[4] = {
|
||||
&field_0x100,
|
||||
&field_0x104,
|
||||
&field_0x108,
|
||||
&field_0x10c,
|
||||
};
|
||||
|
||||
for (u32 uVar6 = 0; uVar6 < 4; uVar6++) {
|
||||
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;
|
||||
local_98[uVar6]->getTevBlock()->setUndeleteFlag(0xfe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
field_0x110 = NULL;
|
||||
if (pJVar5 != NULL && pJVar5->getTevBlock() != NULL) {
|
||||
JUTTexture* local_e0 = pJVar5->getTevBlock()->getTexture(0);
|
||||
if (local_e0 != NULL) {
|
||||
field_0x110 = local_e0;
|
||||
pJVar5->getTevBlock()->setUndeleteFlag(0xfe);
|
||||
}
|
||||
}
|
||||
initinfo2();
|
||||
}
|
||||
|
||||
J2DWindow::J2DWindow(u64 param_0, const JGeometry::TBox2<f32>& param_1, const char* param_2, J2DTextureBase param_3, const ResTLUT* param_4) :
|
||||
J2DPane(param_0, param_1),
|
||||
field_0x100(NULL),
|
||||
field_0x104(NULL),
|
||||
field_0x108(NULL),
|
||||
field_0x10c(NULL),
|
||||
field_0x110(NULL),
|
||||
mPalette(NULL) {
|
||||
const ResTIMG* r30 = (const ResTIMG*)J2DScreen::getNameResource(param_2);
|
||||
initiate(r30, r30, r30, r30, param_4, convertMirror(param_3), param_1);
|
||||
}
|
||||
|
||||
void J2DWindow::initiate(const ResTIMG* param_0, const ResTIMG* param_1, const ResTIMG* param_2, const ResTIMG* param_3, const ResTLUT* param_4, J2DWindowMirror param_5, const JGeometry::TBox2<f32>& param_6) {
|
||||
if (param_0) {
|
||||
field_0x100 = new JUTTexture(param_0, 0);
|
||||
}
|
||||
if (param_1) {
|
||||
field_0x104 = new JUTTexture(param_1, 0);
|
||||
}
|
||||
if (param_2) {
|
||||
field_0x108 = new JUTTexture(param_2, 0);
|
||||
}
|
||||
if (param_3) {
|
||||
field_0x10c = new JUTTexture(param_3, 0);
|
||||
}
|
||||
if (param_4) {
|
||||
mPalette = new JUTPalette(GX_TLUT0, const_cast<ResTLUT*>(param_4));
|
||||
}
|
||||
field_0x144 = param_5;
|
||||
if (field_0x100 && field_0x104 && field_0x108 && field_0x10c) {
|
||||
field_0x114.set(field_0x100->getWidth(), field_0x100->getHeight(), param_6.getWidth() - field_0x104->getWidth(), param_6.getHeight() - field_0x108->getHeight());
|
||||
} else {
|
||||
field_0x114.set(0.0f, 0.0f, param_6.getWidth(), param_6.getHeight());
|
||||
}
|
||||
initinfo();
|
||||
}
|
||||
|
||||
void J2DWindow::private_readStream(J2DPane* param_0, JSURandomInputStream* param_1,
|
||||
JKRArchive* param_2) {
|
||||
s32 local_188 = param_1->getPosition();
|
||||
u32 local_180[2];
|
||||
param_1->read(local_180, 8);
|
||||
mKind = local_180[0];
|
||||
makePaneStream(param_0, param_1);
|
||||
JUTResReference stack_178;
|
||||
u8 r27 = param_1->readU8();
|
||||
f32 f31 = param_1->read16b();
|
||||
f32 f30 = param_1->read16b();
|
||||
f32 f29 = f31 + param_1->read16b();
|
||||
f32 f28 = f30 + param_1->read16b();
|
||||
field_0x114.set(f31, f30, f29, f28);
|
||||
ResTIMG* timg = (ResTIMG*)getPointer(param_1, 'TIMG', param_2);
|
||||
if (timg) {
|
||||
field_0x100 = new JUTTexture(timg, 0);
|
||||
}
|
||||
timg = (ResTIMG*)getPointer(param_1, 'TIMG', param_2);
|
||||
if (timg) {
|
||||
field_0x104 = new JUTTexture(timg, 0);
|
||||
}
|
||||
timg = (ResTIMG*)getPointer(param_1, 'TIMG', param_2);
|
||||
if (timg) {
|
||||
field_0x108 = new JUTTexture(timg, 0);
|
||||
}
|
||||
timg = (ResTIMG*)getPointer(param_1, 'TIMG', param_2);
|
||||
if (timg) {
|
||||
field_0x10c = new JUTTexture(timg, 0);
|
||||
}
|
||||
ResTLUT* tlut = (ResTLUT*)getPointer(param_1, 'TLUT', param_2);
|
||||
if (tlut) {
|
||||
mPalette = new JUTPalette(GX_TLUT0, tlut);
|
||||
}
|
||||
field_0x144 = param_1->read8b();
|
||||
field_0x128.set(param_1->read32b());
|
||||
field_0x12C.set(param_1->read32b());
|
||||
field_0x130.set(param_1->read32b());
|
||||
field_0x134.set(param_1->read32b());
|
||||
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);
|
||||
}
|
||||
r27--;
|
||||
}
|
||||
mBlack = JUtility::TColor(0);
|
||||
mWhite = JUtility::TColor(0xffffffff);
|
||||
if (r27) {
|
||||
mBlack = JUtility::TColor(param_1->readU32());
|
||||
r27--;
|
||||
}
|
||||
if (r27) {
|
||||
mWhite = JUtility::TColor(param_1->readU32());
|
||||
r27--;
|
||||
}
|
||||
param_1->seek(local_188 + local_180[1], JSUStreamSeekFrom_SET);
|
||||
initinfo2();
|
||||
}
|
||||
|
||||
void J2DWindow::initinfo() {
|
||||
mKind = 'WIN1';
|
||||
setContentsColor(JUtility::TColor(0xffffffff));
|
||||
mBlack = JUtility::TColor(0);
|
||||
mWhite = JUtility::TColor(0xffffffff);
|
||||
initinfo2();
|
||||
}
|
||||
|
||||
void J2DWindow::initinfo2() {
|
||||
if (field_0x100 && field_0x104 && field_0x108 && field_0x10c) {
|
||||
field_0x140 = field_0x100->getWidth() + field_0x104->getWidth();
|
||||
field_0x142 = field_0x100->getHeight() + field_0x108->getHeight();
|
||||
} else {
|
||||
field_0x140 = 1;
|
||||
field_0x142 = 1;
|
||||
return;
|
||||
}
|
||||
field_0x145 = 0;
|
||||
JUTTexture* r30 = field_0x100;
|
||||
if (*field_0x104 != *r30) {
|
||||
field_0x145 |= 1;
|
||||
r30 = field_0x104;
|
||||
}
|
||||
if (*field_0x10c != *r30) {
|
||||
field_0x145 |= 2;
|
||||
r30 = field_0x10c;
|
||||
}
|
||||
if (*field_0x108 != *r30) {
|
||||
field_0x145 |= 4;
|
||||
}
|
||||
}
|
||||
|
||||
J2DWindowMirror J2DWindow::convertMirror(J2DTextureBase texBase) {
|
||||
J2DWindowMirror winMirror = WINDOWMIRROR_39;
|
||||
switch (texBase) {
|
||||
case TEXTUREBASE_0:
|
||||
winMirror = WINDOWMIRROR_39;
|
||||
break;
|
||||
case TEXTUREBASE_1:
|
||||
winMirror = WINDOWMIRROR_141;
|
||||
break;
|
||||
case TEXTUREBASE_2:
|
||||
winMirror = WINDOWMIRROR_114;
|
||||
break;
|
||||
case TEXTUREBASE_3:
|
||||
winMirror = WINDOWMIRROR_216;
|
||||
break;
|
||||
}
|
||||
return winMirror;
|
||||
}
|
||||
|
||||
J2DWindow::~J2DWindow() {
|
||||
delete field_0x100;
|
||||
delete field_0x104;
|
||||
delete field_0x108;
|
||||
delete field_0x10c;
|
||||
delete mPalette;
|
||||
delete field_0x110;
|
||||
}
|
||||
|
||||
void J2DWindow::draw(JGeometry::TBox2<f32> const& param_0) {
|
||||
JGeometry::TBox2<f32> stack_58;
|
||||
if (field_0x100 && field_0x104 && field_0x108 && field_0x10c) {
|
||||
stack_58.set(field_0x100->getWidth(), field_0x100->getHeight(),
|
||||
param_0.getWidth() - field_0x104->getWidth(),
|
||||
param_0.getHeight() - field_0x108->getHeight());
|
||||
} else {
|
||||
stack_58.set(0.0f, 0.0f, param_0.getWidth(), param_0.getHeight());
|
||||
}
|
||||
draw(param_0, stack_58);
|
||||
}
|
||||
|
||||
void J2DWindow::draw_private(JGeometry::TBox2<f32> const& param_0,
|
||||
JGeometry::TBox2<f32> const& param_1) {
|
||||
JGeometry::TBox2<f32> stack_a0(param_1);
|
||||
stack_a0.addPos(param_0.i);
|
||||
drawContents(stack_a0);
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
GXSetNumTexGens(1);
|
||||
if (field_0x100 && field_0x104 && field_0x108 && field_0x10c) {
|
||||
f32 f29 = param_0.i.x;
|
||||
f32 f28 = param_0.i.y;
|
||||
f32 f31 = param_0.f.x - field_0x10c->getWidth();
|
||||
f32 f30 = param_0.f.y - field_0x10c->getHeight();
|
||||
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 = field_0x145 & 1;
|
||||
drawFrameTexture(field_0x104, f31, f28, field_0x144 & 0x20, field_0x144 & 0x10, r24);
|
||||
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);
|
||||
GXSetNumTexGens(0);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_NONE);
|
||||
}
|
||||
|
||||
void J2DWindow::draw(JGeometry::TBox2<f32> const& param_0, JGeometry::TBox2<f32> const& param_1) {
|
||||
if (param_0.getWidth() >= field_0x140 && param_0.getHeight() >= field_0x142 && isVisible()) {
|
||||
makeMatrix(param_0.i.x, param_0.i.y, 0, 0);
|
||||
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
|
||||
GXSetCurrentMtx(0);
|
||||
mColorAlpha = mAlpha;
|
||||
JGeometry::TBox2<f32> stack_70(0.0f, 0.0f, param_0.getWidth(), param_0.getHeight());
|
||||
draw_private(stack_70, param_1);
|
||||
Mtx stack_60;
|
||||
MTXIdentity(stack_60);
|
||||
GXLoadPosMtxImm(stack_60, GX_PNMTX0);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindow::resize(f32 param_0, f32 param_1) {
|
||||
f32 f31 = getWidth();
|
||||
f32 f30 = getHeight();
|
||||
J2DPane::resize(param_0, param_1);
|
||||
field_0x114.f.x += param_0 - f31;
|
||||
field_0x114.f.y += param_1 - f30;
|
||||
for (JSUTreeIterator<J2DPane> it(getFirstChild()); it != getEndChild(); it++) {
|
||||
if (it->getTypeID() == 19 && it->isConnectParent()) {
|
||||
f32 f29 = param_0 - f31 + it->getWidth();
|
||||
f32 f28 = param_1 - f30 + it->getHeight();
|
||||
it->J2DPane::resize(f29, f28);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindow::setContentsColor(JUtility::TColor param_0, JUtility::TColor param_1,
|
||||
JUtility::TColor param_2, JUtility::TColor param_3) {
|
||||
field_0x128.set(param_0);
|
||||
field_0x12C.set(param_1);
|
||||
field_0x130.set(param_2);
|
||||
field_0x134.set(param_3);
|
||||
}
|
||||
|
||||
void J2DWindow::drawSelf(f32 param_0, f32 param_1) {
|
||||
Mtx stack_38;
|
||||
MTXIdentity(stack_38);
|
||||
drawSelf(param_0, param_1, &stack_38);
|
||||
}
|
||||
|
||||
void J2DWindow::drawSelf(f32 param_0, f32 param_1, Mtx* param_2) {
|
||||
JGeometry::TBox2<f32> stack_50(mBounds);
|
||||
stack_50.addPos(JGeometry::TVec2<f32>(param_0, param_1));
|
||||
if (stack_50.getWidth() >= field_0x140 && stack_50.getHeight() >= field_0x142) {
|
||||
Mtx stack_40;
|
||||
MTXConcat(*param_2, mGlobalMtx, stack_40);
|
||||
GXLoadPosMtxImm(stack_40, GX_PNMTX0);
|
||||
draw_private(stack_50, field_0x114);
|
||||
}
|
||||
clip(field_0x114);
|
||||
}
|
||||
|
||||
void J2DWindow::drawContents(JGeometry::TBox2<f32> const& param_0) {
|
||||
if (param_0.isValid()) {
|
||||
GXSetNumChans(1);
|
||||
GXSetNumTexGens(0);
|
||||
GXSetNumTevStages(1);
|
||||
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
if ((field_0x128 & 0xff) == 0xff && (field_0x12C & 0xff) == 0xff &&
|
||||
(field_0x130 & 0xff) == 0xff && (field_0x134 & 0xff) == 0xff && mColorAlpha == 0xff)
|
||||
{
|
||||
GXSetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_SET);
|
||||
} else {
|
||||
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
|
||||
}
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetChanCtrl(GX_COLOR0A0, 0, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE,
|
||||
GX_AF_NONE);
|
||||
GXSetNumIndStages(0);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
GXSetTevDirect(GXTevStageID(i));
|
||||
}
|
||||
if (field_0x110 == NULL) {
|
||||
JUtility::TColor color1(field_0x128);
|
||||
JUtility::TColor color2(field_0x130);
|
||||
JUtility::TColor color3(field_0x12C);
|
||||
JUtility::TColor color4(field_0x134);
|
||||
if (mColorAlpha != 0xff) {
|
||||
color1.a = color1.a * mColorAlpha / 0xff;
|
||||
color2.a = color2.a * mColorAlpha / 0xff;
|
||||
color3.a = color3.a * mColorAlpha / 0xff;
|
||||
color4.a = color4.a * mColorAlpha / 0xff;
|
||||
}
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
GXPosition3f32(param_0.i.x, param_0.i.y, 0.0f);
|
||||
GXColor1u32(color1);
|
||||
GXPosition3f32(param_0.f.x, param_0.i.y, 0.0f);
|
||||
GXColor1u32(color3);
|
||||
GXPosition3f32(param_0.f.x, param_0.f.y, 0.0f);
|
||||
GXColor1u32(color4);
|
||||
GXPosition3f32(param_0.i.x, param_0.f.y, 0.0f);
|
||||
GXColor1u32(color2);
|
||||
GXEnd();
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
|
||||
} else {
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
GXSetNumTexGens(1);
|
||||
drawContentsTexture(param_0.i.x, param_0.i.y, param_0.getWidth(), param_0.getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindow::drawFrameTexture(JUTTexture* param_0, f32 param_1, f32 param_2, f32 param_3,
|
||||
f32 param_4, u16 param_5, u16 param_6, u16 param_7, u16 param_8,
|
||||
bool param_9) {
|
||||
f32 f31 = param_1 + param_3;
|
||||
f32 f30 = param_2 + param_4;
|
||||
if (param_9) {
|
||||
param_0->load(GX_TEXMAP0);
|
||||
setTevMode(param_0, mBlack, mWhite);
|
||||
}
|
||||
JUtility::TColor stack_64(mColorAlpha | 0xffffff00);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
GXPosition3f32(param_1, param_2, 0.0f);
|
||||
GXColor1u32(stack_64);
|
||||
GXTexCoord2u16(param_7, param_8);
|
||||
GXPosition3f32(f31, param_2, 0.0f);
|
||||
GXColor1u32(stack_64);
|
||||
GXTexCoord2u16(param_5, param_8);
|
||||
GXPosition3f32(f31, f30, 0.0f);
|
||||
GXColor1u32(stack_64);
|
||||
GXTexCoord2u16(param_5, param_6);
|
||||
GXPosition3f32(param_1, f30, 0.0f);
|
||||
GXColor1u32(stack_64);
|
||||
GXTexCoord2u16(param_7, param_6);
|
||||
GXEnd();
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
|
||||
}
|
||||
|
||||
void J2DWindow::drawFrameTexture(JUTTexture* param_0, f32 param_1, f32 param_2, bool param_3,
|
||||
bool param_4, bool param_5) {
|
||||
u16 r31, r30, r29, r28;
|
||||
if (param_4) {
|
||||
r31 = 0x8000;
|
||||
} else {
|
||||
r31 = 0;
|
||||
}
|
||||
if (param_3) {
|
||||
r30 = 0x8000;
|
||||
} else {
|
||||
r30 = 0;
|
||||
}
|
||||
if (param_4) {
|
||||
r29 = 0;
|
||||
} else {
|
||||
r29 = 0x8000;
|
||||
}
|
||||
if (param_3) {
|
||||
r28 = 0;
|
||||
} else {
|
||||
r28 = 0x8000;
|
||||
}
|
||||
drawFrameTexture(param_0, param_1, param_2, param_0->getWidth(), param_0->getHeight(), r28, r29,
|
||||
r30, r31, param_5);
|
||||
}
|
||||
|
||||
void J2DWindow::drawContentsTexture(f32 param_0, f32 param_1, f32 param_2, f32 param_3) {
|
||||
f32 f29 = param_0 + param_2;
|
||||
f32 f28 = param_1 + param_3;
|
||||
f32 width = field_0x110->getWidth();
|
||||
f32 height = field_0x110->getHeight();
|
||||
f32 f27 = -(param_2 / width - 1.0f) / 2.0f;
|
||||
f32 f26 = -(param_3 / height - 1.0f) / 2.0f;
|
||||
f32 f25 = f27 + param_2 / width;
|
||||
f32 f24 = f26 + param_3 / height;
|
||||
TContentsColor stack_f0;
|
||||
getContentsColor(stack_f0);
|
||||
if (mColorAlpha != 0xff) {
|
||||
stack_f0.field_0x0.a = stack_f0.field_0x0.a * mColorAlpha / 0xff;
|
||||
stack_f0.field_0x4.a = stack_f0.field_0x4.a * mColorAlpha / 0xff;
|
||||
stack_f0.field_0x8.a = stack_f0.field_0x8.a * mColorAlpha / 0xff;
|
||||
stack_f0.field_0xc.a = stack_f0.field_0xc.a * mColorAlpha / 0xff;
|
||||
}
|
||||
field_0x110->load(GX_TEXMAP0);
|
||||
setTevMode(field_0x110, 0, 0xffffffff);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBA6, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
GXPosition3f32(param_0, param_1, 0.0f);
|
||||
GXColor1u32(stack_f0.field_0x0);
|
||||
GXTexCoord2f32(f27, f26);
|
||||
GXPosition3f32(f29, param_1, 0.0f);
|
||||
GXColor1u32(stack_f0.field_0x4);
|
||||
GXTexCoord2f32(f25, f26);
|
||||
GXPosition3f32(f29, f28, 0.0f);
|
||||
GXColor1u32(stack_f0.field_0xc);
|
||||
GXTexCoord2f32(f25, f24);
|
||||
GXPosition3f32(param_0, f28, 0.0f);
|
||||
GXColor1u32(stack_f0.field_0x8);
|
||||
GXTexCoord2f32(f27, f24);
|
||||
GXEnd();
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGBX8, 0xf);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
|
||||
}
|
||||
|
||||
void J2DWindow::setTevMode(JUTTexture* param_0, JUtility::TColor param_1,
|
||||
JUtility::TColor param_2) {
|
||||
if (param_1 == 0 && param_2 == 0xffffffff) {
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_TEXC, GX_CC_RASC, GX_CC_ZERO);
|
||||
if (param_0->getTransparency()) {
|
||||
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_TEXA, GX_CA_RASA, GX_CA_ZERO);
|
||||
} else {
|
||||
GXSetTevColor(GX_TEVREG2, JUtility::TColor(0xffffffff));
|
||||
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_A2, GX_CA_RASA, GX_CA_ZERO);
|
||||
}
|
||||
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
|
||||
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
|
||||
GXSetNumTevStages(1);
|
||||
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
|
||||
} else {
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
|
||||
GXSetTevColor(GX_TEVREG0, param_1);
|
||||
GXSetTevColor(GX_TEVREG1, param_2);
|
||||
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_C0, GX_CC_C1, GX_CC_TEXC, GX_CC_ZERO);
|
||||
if (param_0->getTransparency()) {
|
||||
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_TEXA, GX_CA_ZERO);
|
||||
} else {
|
||||
GXSetTevColor(GX_TEVREG2, JUtility::TColor(0xffffffff));
|
||||
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_A0, GX_CA_A1, GX_CA_A2, GX_CA_ZERO);
|
||||
}
|
||||
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
|
||||
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
|
||||
GXSetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_CPREV, GX_CC_RASC, GX_CC_ZERO);
|
||||
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_APREV, GX_CA_RASA, GX_CA_ZERO);
|
||||
GXSetTevColorOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
|
||||
GXSetTevAlphaOp(GX_TEVSTAGE1, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV);
|
||||
GXSetNumTevStages(2);
|
||||
}
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
|
||||
}
|
||||
|
||||
JUTTexture* J2DWindow::getFrameTexture(u8 param_0, u8 param_1) const {
|
||||
JUTTexture* tmp[4] = {field_0x100, field_0x104, field_0x108, field_0x10c};
|
||||
if (param_0 >= 4 || param_1 != 0) {
|
||||
return NULL;
|
||||
}
|
||||
return tmp[param_0];
|
||||
}
|
||||
|
||||
bool J2DWindow::isUsed(ResTIMG const* param_0) {
|
||||
JUTTexture* tmp[5] = {field_0x100, field_0x104, field_0x108, field_0x10c, field_0x110};
|
||||
for (u8 i = 0; i < 5; i++) {
|
||||
if (tmp[i] && tmp[i]->getTexInfo() == param_0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return J2DPane::isUsed(param_0);
|
||||
}
|
||||
@@ -0,0 +1,862 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DWindowEx.h"
|
||||
#include "JSystem/JUtility/JUTTexture.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
|
||||
struct J2DWindowExDef {
|
||||
u32 field_0x0[4];
|
||||
u16 field_0x10[4];
|
||||
u8 field_0x18;
|
||||
u8 field_0x19;
|
||||
u16 field_0x1A;
|
||||
u16 field_0x1C;
|
||||
u16 field_0x1E;
|
||||
u16 field_0x20;
|
||||
u16 field_0x22;
|
||||
u16 field_0x24;
|
||||
u16 field_0x26;
|
||||
u16 field_0x28[4];
|
||||
u32 field_0x30[4];
|
||||
};
|
||||
|
||||
STATIC_ASSERT(sizeof(J2DWindowExDef) == 0x40);
|
||||
|
||||
J2DWindowEx::J2DWindowEx(J2DPane* param_0, JSURandomInputStream* param_1, u32 param_2,
|
||||
J2DMaterial* param_3) : J2DWindow() {
|
||||
mAnmVisibilityFull = NULL;
|
||||
mAnmVtxColor = NULL;
|
||||
s32 position = param_1->getPosition();
|
||||
int uStack_88[2];
|
||||
param_1->read(uStack_88, 8);
|
||||
mKind = uStack_88[0];
|
||||
s32 iVar2 = param_1->getPosition();
|
||||
int auStack_90[2];
|
||||
param_1->peek(auStack_90, 8);
|
||||
makePaneExStream(param_0, param_1);
|
||||
param_1->seek(iVar2 + auStack_90[1], JSUStreamSeekFrom_SET);
|
||||
J2DWindowExDef auStack_70;
|
||||
param_1->read(&auStack_70, sizeof(J2DWindowExDef));
|
||||
|
||||
JUtility::TColor* colors[4] = {
|
||||
&field_0x128,
|
||||
&field_0x12C,
|
||||
&field_0x130,
|
||||
&field_0x134
|
||||
};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
field_0x158[i] = auStack_70.field_0x10[i];
|
||||
mFrameMaterial[i] = 0;
|
||||
if (field_0x158[i] != 0xffff) {
|
||||
mFrameMaterial[i] = param_3 + field_0x158[i];
|
||||
(param_3 + field_0x158[i])->field_0x4 = this;
|
||||
}
|
||||
field_0x168[i] = auStack_70.field_0x28[i];
|
||||
*(colors[i]) = JUtility::TColor(auStack_70.field_0x30[i]);
|
||||
}
|
||||
|
||||
field_0x144 = auStack_70.field_0x18;
|
||||
field_0x114.set(auStack_70.field_0x1A, auStack_70.field_0x1C,
|
||||
auStack_70.field_0x1A + auStack_70.field_0x1E,
|
||||
auStack_70.field_0x1C + auStack_70.field_0x20);
|
||||
field_0x166 = auStack_70.field_0x22;
|
||||
field_0x164 = auStack_70.field_0x24;
|
||||
mContentsMaterial = NULL;
|
||||
|
||||
if (field_0x164 != 0xffff) {
|
||||
mContentsMaterial = ¶m_3[field_0x164];
|
||||
param_3[field_0x164].field_0x4 = this;
|
||||
}
|
||||
|
||||
param_1->seek(position + uStack_88[1], JSUStreamSeekFrom_SET);
|
||||
rewriteAlpha();
|
||||
field_0x100 = NULL;
|
||||
field_0x104 = NULL;
|
||||
field_0x108 = NULL;
|
||||
field_0x10c = NULL;
|
||||
mPalette = NULL;
|
||||
field_0x110 = NULL;
|
||||
field_0x170 = 0;
|
||||
setMinSize();
|
||||
}
|
||||
|
||||
static void dummy(J2DTexGenBlock* block) {
|
||||
block->setTexCoord(0, J2DTexCoord());
|
||||
}
|
||||
|
||||
void J2DWindowEx::setMinSize() {
|
||||
field_0x140 = 1;
|
||||
field_0x142 = 1;
|
||||
|
||||
if (mFrameMaterial[0] == NULL) return;
|
||||
if (mFrameMaterial[1] == NULL) return;
|
||||
if (mFrameMaterial[2] == NULL) return;
|
||||
if (mFrameMaterial[3] == NULL) return;
|
||||
if (mFrameMaterial[0]->getTevBlock() == NULL) return;
|
||||
if (mFrameMaterial[1]->getTevBlock() == NULL) return;
|
||||
if (mFrameMaterial[2]->getTevBlock() == NULL) return;
|
||||
if (mFrameMaterial[3]->getTevBlock() == NULL) return;
|
||||
if (mFrameMaterial[0]->getTevBlock()->getTexture(0) == NULL) return;
|
||||
if (mFrameMaterial[1]->getTevBlock()->getTexture(0) == NULL) return;
|
||||
if (mFrameMaterial[2]->getTevBlock()->getTexture(0) == NULL) return;
|
||||
if (mFrameMaterial[3]->getTevBlock()->getTexture(0) == NULL) return;
|
||||
|
||||
field_0x140 = mFrameMaterial[0]->getTevBlock()->getTexture(0)->getWidth()
|
||||
+ mFrameMaterial[1]->getTevBlock()->getTexture(0)->getWidth();
|
||||
field_0x142 = mFrameMaterial[0]->getTevBlock()->getTexture(0)->getHeight()
|
||||
+ mFrameMaterial[2]->getTevBlock()->getTexture(0)->getHeight();
|
||||
}
|
||||
|
||||
J2DWindowEx::~J2DWindowEx() {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (field_0x170 & (1 << i)) {
|
||||
delete mFrameMaterial[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (field_0x170 & 0x10) {
|
||||
delete mContentsMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindowEx::drawSelf(f32 param_0, f32 param_1, f32 (*param_2)[3][4]) {
|
||||
JGeometry::TBox2<f32> aTStack_50(mBounds);
|
||||
Mtx auStack_40;
|
||||
aTStack_50.addPos(JGeometry::TVec2<f32>(param_0, param_1));
|
||||
MTXConcat(*param_2, mGlobalMtx, auStack_40);
|
||||
GXLoadPosMtxImm(auStack_40, 0);
|
||||
draw_private(aTStack_50, field_0x114);
|
||||
clip(field_0x114);
|
||||
}
|
||||
|
||||
void J2DWindowEx::draw_private(JGeometry::TBox2<f32> const& param_0,
|
||||
JGeometry::TBox2<f32> const& param_1) {
|
||||
if (param_0.getWidth() >= field_0x140 && param_0.getHeight() >= field_0x142) {
|
||||
JUTTexture* textures[4];
|
||||
bool foundNullTexture = false;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (mFrameMaterial[i] == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mFrameMaterial[i]->getTevBlock() == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
textures[i] = mFrameMaterial[i]->getTevBlock()->getTexture(0);
|
||||
if (textures[i] == NULL) {
|
||||
foundNullTexture = true;
|
||||
}
|
||||
}
|
||||
|
||||
JGeometry::TBox2<f32> aTStack_38(param_1);
|
||||
aTStack_38.addPos(param_0.i);
|
||||
drawContents(aTStack_38);
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
|
||||
if (!foundNullTexture) {
|
||||
f32 minX = param_0.i.x;
|
||||
f32 minY = param_0.i.y;
|
||||
f32 f31 = param_0.f.x - textures[3]->getWidth();
|
||||
f32 f30 = param_0.f.y - textures[3]->getHeight();
|
||||
f32 maxX0 = minX + textures[0]->getWidth();
|
||||
f32 maxY0 = minY + textures[0]->getHeight();
|
||||
|
||||
u16 r29 = (field_0x144 & 0x80 ? (u16)0 : (u16)0x8000);
|
||||
u16 r28 = (field_0x144 & 0x40 ? (u16)0 : (u16)0x8000);
|
||||
drawFrameTexture(minX, minY, textures[0]->getWidth(), textures[0]->getHeight(), r29, r28,
|
||||
0x8000 - r29, 0x8000 - r28, mFrameMaterial[0], true);
|
||||
|
||||
bool r9 = mFrameMaterial[1] != mFrameMaterial[0];
|
||||
r29 = field_0x144 & 0x20 ? (u16)0 : (u16)0x8000;
|
||||
r28 = field_0x144 & 0x10 ? (u16)0 : (u16)0x8000;
|
||||
drawFrameTexture(f31, minY, textures[3]->getWidth(), textures[0]->getHeight(), r29, r28,
|
||||
0x8000 - r29, 0x8000 - r28, mFrameMaterial[1], r9);
|
||||
|
||||
r29 = field_0x144 & 0x20 ? (u16)0x8000 : (u16)0;
|
||||
u16 sp_30 = r29;
|
||||
r28 = field_0x144 & 0x10 ? (u16)0 : (u16)0x8000;
|
||||
drawFrameTexture(maxX0, minY, f31 - maxX0, textures[0]->getHeight(), r29, r28, sp_30,
|
||||
r28 ^ 0x8000, mFrameMaterial[1], false);
|
||||
|
||||
r9 = mFrameMaterial[3] != mFrameMaterial[1];
|
||||
r29 = field_0x144 & 0x2 ? (u16)0 : (u16)0x8000;
|
||||
r28 = field_0x144 & 0x1 ? (u16)0 : (u16)0x8000;
|
||||
drawFrameTexture(f31, f30, textures[3]->getWidth(), textures[3]->getHeight(), r29, r28,
|
||||
0x8000 - r29, 0x8000 - r28, mFrameMaterial[3], r9);
|
||||
|
||||
r29 = field_0x144 & 0x2 ? (u16)0x8000 : (u16)0;
|
||||
sp_30 = r29;
|
||||
r28 = field_0x144 & 0x1 ? (u16)0 : (u16)0x8000;
|
||||
drawFrameTexture(maxX0, f30, f31 - maxX0, textures[3]->getHeight(), r29, r28, sp_30,
|
||||
r28 ^ 0x8000, mFrameMaterial[3], false);
|
||||
|
||||
r29 = field_0x144 & 0x2 ? (u16)0 : (u16)0x8000;
|
||||
r28 = field_0x144 & 0x1 ? (u16)0x8000 : (u16)0;
|
||||
u16 sp_2E = r28;
|
||||
drawFrameTexture(f31, maxY0, textures[3]->getWidth(), f30 - maxY0, r29, r28, r29 ^ 0x8000,
|
||||
sp_2E, mFrameMaterial[3], false);
|
||||
|
||||
r9 = mFrameMaterial[2] != mFrameMaterial[3];
|
||||
r29 = field_0x144 & 0x8 ? (u16)0 : (u16)0x8000;
|
||||
r28 = field_0x144 & 0x4 ? (u16)0 : (u16)0x8000;
|
||||
drawFrameTexture(minX, f30, textures[0]->getWidth(), textures[3]->getHeight(), r29, r28,
|
||||
0x8000 - r29, 0x8000 - r28, mFrameMaterial[2], r9);
|
||||
|
||||
r29 = field_0x144 & 0x8 ? (u16)0 : (u16)0x8000;
|
||||
r28 = field_0x144 & 0x4 ? (u16)0x8000 : (u16)0;
|
||||
sp_2E = r28;
|
||||
drawFrameTexture(minX, maxY0, textures[0]->getWidth(), f30 - maxY0, r29, r28, r29 ^ 0x8000,
|
||||
sp_2E, mFrameMaterial[2], false);
|
||||
}
|
||||
|
||||
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GXSetNumTexGens(0);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static f32 dummy_literal() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void J2DWindowEx::drawContents(JGeometry::TBox2<f32> const& param_1) {
|
||||
if (!param_1.isValid() || mContentsMaterial == NULL) {
|
||||
return;
|
||||
}
|
||||
if (!mContentsMaterial->isVisible()) {
|
||||
return;
|
||||
}
|
||||
mContentsMaterial->setGX();
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
JUtility::TColor TStack_b4(field_0x128);
|
||||
JUtility::TColor TStack_b8(field_0x130);
|
||||
JUtility::TColor TStack_bc(field_0x12C);
|
||||
JUtility::TColor TStack_c0(field_0x134);
|
||||
if (mContentsMaterial->getColorBlock()->getColorChan(1)->getMatSrc() == 1) {
|
||||
if (mContentsMaterial->getMaterialAlphaCalc() == 1) {
|
||||
TStack_b4.a = (TStack_b4.a * mColorAlpha) / 0xff;
|
||||
TStack_b8.a = (TStack_b8.a * mColorAlpha) / 0xff;
|
||||
TStack_bc.a = (TStack_bc.a * mColorAlpha) / 0xff;
|
||||
TStack_c0.a = (TStack_c0.a * mColorAlpha) / 0xff;
|
||||
}
|
||||
} else if (mIsInfluencedAlpha) {
|
||||
GXSetChanMatColor(GX_ALPHA0, JUtility::TColor(mColorAlpha));
|
||||
}
|
||||
bool bVar5 = false;
|
||||
f32 in_f31;
|
||||
f32 in_f30;
|
||||
f32 in_f29;
|
||||
f32 in_f28;
|
||||
if (mContentsMaterial->getTevBlock() != NULL) {
|
||||
if (mContentsMaterial->getTevBlock()->getTexture(0)) {
|
||||
bVar5 = true;
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
f32 dVar15 = mContentsMaterial->getTevBlock()->getTexture(0)->getWidth();
|
||||
f32 dVar14 = mContentsMaterial->getTevBlock()->getTexture(0)->getHeight();
|
||||
|
||||
f32 dVar12 = param_1.getWidth();
|
||||
f32 dVar13 = param_1.getHeight();
|
||||
in_f31 = -(dVar12 / dVar15 - 1.0f) / 2;
|
||||
in_f30 = -((dVar13 / dVar14) - 1.0f) / 2;
|
||||
in_f29 = in_f31 + (dVar12 / dVar15);
|
||||
in_f28 = in_f30 + (dVar13 / dVar14);
|
||||
}
|
||||
}
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0);
|
||||
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
GXPosition3f32(param_1.i.x, param_1.i.y,
|
||||
0.0f);
|
||||
GXColor1u32(TStack_b4);
|
||||
if (bVar5) {
|
||||
GXTexCoord2f32(in_f31, in_f30);
|
||||
}
|
||||
GXPosition3f32(param_1.f.x, param_1.i.y,
|
||||
0.0f);
|
||||
GXColor1u32(TStack_bc);
|
||||
if (bVar5) {
|
||||
GXTexCoord2f32(in_f29, in_f30);
|
||||
}
|
||||
GXPosition3f32(param_1.f.x, param_1.f.y,
|
||||
0.0f);
|
||||
GXColor1u32(TStack_c0);
|
||||
if (bVar5) {
|
||||
GXTexCoord2f32(in_f29, in_f28);
|
||||
}
|
||||
GXPosition3f32(param_1.i.x, param_1.f.y,
|
||||
0.0f);
|
||||
GXColor1u32(TStack_b8);
|
||||
if (bVar5) {
|
||||
GXTexCoord2f32(in_f31, in_f28);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void J2DWindowEx::drawFrameTexture(f32 param_1, f32 param_2, f32 param_3, f32 param_4, u16 param_5,
|
||||
u16 param_6, u16 param_7, u16 param_8, J2DMaterial* param_9,
|
||||
bool param_10) {
|
||||
if (param_9 != NULL && param_9->isVisible()) {
|
||||
f32 dVar15 = param_1 + param_3;
|
||||
f32 dVar14 = param_2 + param_4;
|
||||
if (param_10) {
|
||||
param_9->setGX();
|
||||
}
|
||||
JUtility::TColor aTStack_84(0xffffffff);
|
||||
J2DPane* parentPane = getParentPane();
|
||||
if (param_9->getColorBlock()->getColorChan(1)->getMatSrc() == 1) {
|
||||
if (param_9->getMaterialAlphaCalc() == 1) {
|
||||
u8 uVar11 = 0xff;
|
||||
if (param_9->getColorBlock()->getMatColor(0) != 0) {
|
||||
uVar11 = param_9->getColorBlock()->getMatColor(0)->a;
|
||||
}
|
||||
if (parentPane != NULL && mIsInfluencedAlpha != 0) {
|
||||
uVar11 = ((uVar11 * parentPane->mColorAlpha) / 0xff);
|
||||
}
|
||||
aTStack_84 = JUtility::TColor((u32)uVar11 | 0xffffff00);
|
||||
}
|
||||
} else if (parentPane != NULL && mIsInfluencedAlpha != 0 && param_10) {
|
||||
u8 matColorAlpha = param_9->getColorBlock()->getMatColor(0)->a;
|
||||
matColorAlpha = matColorAlpha * parentPane->mColorAlpha / 0xff;
|
||||
GXSetChanMatColor(GX_ALPHA0, JUtility::TColor(matColorAlpha));
|
||||
}
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
|
||||
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
GXPosition3f32(param_1, param_2, 0.0f);
|
||||
GXColor1u32(aTStack_84);
|
||||
GXTexCoord2u16(param_7, param_8);
|
||||
GXPosition3f32(dVar15, param_2, 0.0f);
|
||||
GXColor1u32(aTStack_84);
|
||||
GXTexCoord2u16(param_5, param_8);
|
||||
GXPosition3f32(dVar15, dVar14, 0.0f);
|
||||
GXColor1u32(aTStack_84);
|
||||
GXTexCoord2u16(param_5, param_6);
|
||||
GXPosition3f32(param_1, dVar14, 0.0f);
|
||||
GXColor1u32(aTStack_84);
|
||||
GXTexCoord2u16(param_7, param_6);
|
||||
GXEnd();
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_RGBA4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindowEx::draw(JGeometry::TBox2<f32> const& param_1) {
|
||||
bool isMissingTexture = false;
|
||||
JUTTexture* local_68[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (mFrameMaterial[i] == NULL) {
|
||||
return;
|
||||
}
|
||||
if (mFrameMaterial[i]->getTevBlock() == NULL) {
|
||||
return;
|
||||
}
|
||||
local_68[i] = mFrameMaterial[i]->getTevBlock()->getTexture(0);
|
||||
if (local_68[i] == NULL) {
|
||||
isMissingTexture = true;
|
||||
}
|
||||
}
|
||||
JGeometry::TBox2<f32> aTStack_78;
|
||||
if (!isMissingTexture) {
|
||||
aTStack_78.set(local_68[0]->getWidth(), local_68[0]->getHeight(),
|
||||
param_1.getWidth() - local_68[1]->getWidth(),
|
||||
param_1.getHeight() - local_68[2]->getHeight());
|
||||
} else {
|
||||
aTStack_78.set(0.0f, 0.0f, param_1.getWidth(), param_1.getHeight());
|
||||
}
|
||||
draw(param_1, aTStack_78);
|
||||
}
|
||||
|
||||
void J2DWindowEx::draw(JGeometry::TBox2<f32> const& param_1, JGeometry::TBox2<f32> const& param_2) {
|
||||
rewriteAlpha();
|
||||
mColorAlpha = mAlpha;
|
||||
makeMatrix(param_1.i.x, param_1.i.y, 0.0f, 0.0f);
|
||||
GXLoadPosMtxImm(mPositionMtx, 0);
|
||||
GXSetCurrentMtx(0);
|
||||
JGeometry::TBox2<f32> aTStack_70(0.0f, 0.0f, param_1.getWidth(), param_1.getHeight());
|
||||
draw_private(aTStack_70, param_2);
|
||||
for (int i = GX_TEV_SWAP0; i < GX_MAX_TEVSWAP; i++) {
|
||||
GXSetTevSwapModeTable((GXTevSwapSel)i, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA);
|
||||
}
|
||||
GXSetNumIndStages(0);
|
||||
for (int i = GX_TEVSTAGE0; i < GX_MAX_TEVSTAGE; i++) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
Mtx auStack_60;
|
||||
MTXIdentity(auStack_60);
|
||||
GXLoadPosMtxImm(auStack_60, 0);
|
||||
}
|
||||
|
||||
void J2DWindowEx::setTevOrder(bool param_0) {
|
||||
u16 local_28[2];
|
||||
if (!param_0) {
|
||||
local_28[0] = (u16)4;
|
||||
local_28[1] = (u16)0xffff;
|
||||
} else {
|
||||
local_28[0] = (u16)0xff;
|
||||
local_28[1] = (u16)0xff04;
|
||||
}
|
||||
for (u8 i = 0; i < 2; i++) {
|
||||
J2DTevOrderInfo info;
|
||||
info.mTexCoord = local_28[i] >> 8;
|
||||
info.mTexMap = local_28[i] >> 8;
|
||||
info.mColor = local_28[i] & 0xff;
|
||||
J2DTevOrder local_30(info);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
if (mFrameMaterial[j]->getTevBlock()->getMaxStage() > i) {
|
||||
mFrameMaterial[j]->getTevBlock()->setTevOrder(i, local_30);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindowEx::setTevStage(bool param_1) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
J2DTevStage* pJVar3 = mFrameMaterial[i]->getTevBlock()->getTevStage(0);
|
||||
const JUTTexture* this_00 = mFrameMaterial[i]->getTevBlock()->getTexture(0);
|
||||
bool bVar1 = false;
|
||||
if (this_00 != NULL && ((s32)this_00->getFormat() == 0 || (s32)this_00->getFormat() == 1) &&
|
||||
this_00->getTransparency() == 0)
|
||||
{
|
||||
bVar1 = true;
|
||||
}
|
||||
if (!param_1) {
|
||||
setStage(pJVar3, bVar1 ? STAGE_ENUM_1 : STAGE_ENUM_0);
|
||||
} else {
|
||||
setStage(pJVar3, bVar1 ? STAGE_ENUM_4 : STAGE_ENUM_3);
|
||||
pJVar3 = mFrameMaterial[i]->getTevBlock()->getTevStage(1);
|
||||
setStage(pJVar3, STAGE_ENUM_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static u8 const lit_1557[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static u8 const lit_1566[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static u8 const lit_1575[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
|
||||
static u8 const lit_1581[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
|
||||
static u8 const lit_1587[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static u8 const lit_1596[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static u8 const lit_1605[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static u8 const lit_1612[16] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
void J2DWindowEx::setStage(J2DTevStage* param_0, J2DWindowEx::stage_enum param_1) {
|
||||
s8 local_30[6][4] = {
|
||||
{0x0f, 0x08, 0x0a, 0x0f}, {0x0f, 0x08, 0x0a, 0x0f}, {0x0f, 0x0a, 0x00, 0x0f},
|
||||
{0x02, 0x04, 0x08, 0x0f}, {0x02, 0x04, 0x08, 0x0f}, {0x0f, 0x0f, 0x0f, 0x0a},
|
||||
};
|
||||
s8 local_48[6][4] = {
|
||||
{0x07, 0x04, 0x05, 0x07}, {0x05, 0x07, 0x07, 0x07}, {0x07, 0x05, 0x00, 0x07},
|
||||
{0x01, 0x02, 0x04, 0x07}, {0x07, 0x07, 0x07, 0x02}, {0x07, 0x07, 0x07, 0x05},
|
||||
};
|
||||
s8 local_68[6][5] = {
|
||||
{0, 0, 0, 1, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 1, 0},
|
||||
{0, 0, 0, 1, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 1, 0},
|
||||
};
|
||||
|
||||
param_0->setTevColorAB(local_30[param_1][0], local_30[param_1][1]);
|
||||
param_0->setTevColorCD(local_30[param_1][2], local_30[param_1][3]);
|
||||
param_0->setTevColorOp(local_68[param_1][0], local_68[param_1][1], local_68[param_1][2],
|
||||
local_68[param_1][3], local_68[param_1][4]);
|
||||
param_0->setAlphaABCD(local_48[param_1][0], local_48[param_1][1], local_48[param_1][2],
|
||||
local_48[param_1][3]);
|
||||
param_0->setTevAlphaOp(local_68[param_1][0], local_68[param_1][1], local_68[param_1][2],
|
||||
local_68[param_1][3], local_68[param_1][4]);
|
||||
}
|
||||
|
||||
|
||||
bool J2DWindowEx::setBlack(JUtility::TColor i_black) {
|
||||
JUtility::TColor black, white;
|
||||
|
||||
if (!getBlackWhite(&black, &white)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return setBlackWhite(i_black, white);
|
||||
}
|
||||
|
||||
bool J2DWindowEx::setWhite(JUtility::TColor i_white) {
|
||||
JUtility::TColor black, white;
|
||||
|
||||
if (!getBlackWhite(&black, &white)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return setBlackWhite(black, i_white);
|
||||
}
|
||||
|
||||
// NONMATCHING - J2DGXColorS10 issue
|
||||
bool J2DWindowEx::setBlackWhite(JUtility::TColor black, JUtility::TColor white) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (mFrameMaterial[i] == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mFrameMaterial[i]->getTevBlock() == NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isSetBlackWhite(black, white)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bVar1 = (u32)black != 0 || (u32)white != 0xffffffff;
|
||||
u8 uVar3 = bVar1 ? 2 : 1;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mFrameMaterial[i]->getTevBlock()->setTevStageNum(uVar3);
|
||||
}
|
||||
setTevOrder(bVar1);
|
||||
setTevStage(bVar1);
|
||||
if (bVar1) {
|
||||
J2DGXColorS10 color0, color1;
|
||||
color0.r = black.r;
|
||||
color0.g = black.g;
|
||||
color0.b = black.b;
|
||||
color0.a = black.a;
|
||||
color1.r = white.r;
|
||||
color1.g = white.g;
|
||||
color1.b = white.b;
|
||||
color1.a = white.a;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mFrameMaterial[i]->getTevBlock()->setTevColor(0, color0);
|
||||
mFrameMaterial[i]->getTevBlock()->setTevColor(1, color1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool J2DWindowEx::getBlackWhite(JUtility::TColor* o_black, JUtility::TColor* o_white) const {
|
||||
if (mFrameMaterial[0] == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mFrameMaterial[0]->getTevBlock() == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 stageNum = mFrameMaterial[0]->getTevBlock()->getTevStageNum();
|
||||
bool cVar6 = stageNum == 1 ? false : true;
|
||||
*o_black = JUtility::TColor(0);
|
||||
*o_white = JUtility::TColor(0xffffffff);
|
||||
if (cVar6) {
|
||||
J2DGXColorS10 color0 = *mFrameMaterial[0]->getTevBlock()->getTevColor(0);
|
||||
J2DGXColorS10 color1 = *mFrameMaterial[0]->getTevBlock()->getTevColor(1);
|
||||
#define FAST_GX_COLOR_U32(r, g, b, a) (((u8)(r) << 0x18) | ((u8)(g) << 0x10) | ((u8)(b) << 0x8) | ((u8)(a)))
|
||||
*o_black = JUtility::TColor(FAST_GX_COLOR_U32(color0.r, color0.g, color0.b, color0.a));
|
||||
*o_white = JUtility::TColor(FAST_GX_COLOR_U32(color1.r, color1.g, color1.b, color1.a));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool J2DWindowEx::isSetBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) const {
|
||||
if ((u32)param_0 == 0 && (u32)param_1 == 0xffffffff) {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
u8 stage = mFrameMaterial[i]->getTevBlock()->getMaxStage();
|
||||
if (stage == 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
JUtility::TColor J2DWindowEx::getBlack() const {
|
||||
JUtility::TColor black, white;
|
||||
if (!getBlackWhite(&black, &white)) {
|
||||
return JUtility::TColor(0);
|
||||
}
|
||||
|
||||
return black;
|
||||
}
|
||||
|
||||
JUtility::TColor J2DWindowEx::getWhite() const {
|
||||
JUtility::TColor black, white;
|
||||
if (!getBlackWhite(&black, &white)) {
|
||||
return JUtility::TColor(0xffffffff);
|
||||
}
|
||||
|
||||
return white;
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAlpha(u8 param_0) {
|
||||
mAlpha = param_0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (mFrameMaterial[i] != NULL) {
|
||||
if (mFrameMaterial[i]->getColorBlock()->getMatColor(0) != NULL) {
|
||||
mFrameMaterial[i]->getColorBlock()->getMatColor(0)->a = param_0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mContentsMaterial != NULL) {
|
||||
if (mContentsMaterial->getColorBlock()->getMatColor(0) != 0) {
|
||||
mContentsMaterial->getColorBlock()->getMatColor(0)->a = param_0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindowEx::setCullBack(_GXCullMode param_0) {
|
||||
mCullMode = param_0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (mFrameMaterial[i] != NULL) {
|
||||
mFrameMaterial[i]->getColorBlock()->setCullMode(param_0);
|
||||
}
|
||||
}
|
||||
|
||||
if (mContentsMaterial != NULL) {
|
||||
mContentsMaterial->getColorBlock()->setCullMode(param_0);
|
||||
}
|
||||
J2DPane::setCullBack(param_0);
|
||||
}
|
||||
|
||||
void J2DWindowEx::rewriteAlpha() {
|
||||
if (mContentsMaterial != NULL) {
|
||||
mAlpha = mContentsMaterial->getColorBlock()->getMatColor(0)->a;
|
||||
}
|
||||
}
|
||||
|
||||
JUTTexture* J2DWindowEx::getFrameTexture(u8 param_0, u8 param_1) const {
|
||||
J2DMaterial* frameMaterial = getFrameMaterial(param_0);
|
||||
if (frameMaterial != NULL && frameMaterial->getTevBlock() != NULL) {
|
||||
return frameMaterial->getTevBlock()->getTexture(param_1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JUTTexture* J2DWindowEx::getContentsTexture(u8 param_0) const {
|
||||
J2DMaterial* frameMaterial = getContentsMaterial();
|
||||
if (frameMaterial != NULL && frameMaterial->getTevBlock() != NULL) {
|
||||
return frameMaterial->getTevBlock()->getTexture(param_0);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool J2DWindowEx::isUsed(ResTIMG const* timg) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (mFrameMaterial[i] != NULL && mFrameMaterial[i]->getTevBlock() != NULL) {
|
||||
for (u32 j = 0; j < 8; j++) {
|
||||
JUTTexture* texture = mFrameMaterial[i]->getTevBlock()->getTexture(j);
|
||||
if (texture != NULL && texture->getTexInfo() == timg) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mContentsMaterial != NULL && mContentsMaterial->getTevBlock() != NULL) {
|
||||
for (u32 j = 0; j < 8; j++) {
|
||||
JUTTexture* texture = mContentsMaterial->getTevBlock()->getTexture(j);
|
||||
if (texture != NULL && texture->getTexInfo() == timg) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return J2DPane::isUsed(timg);
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAnimation(J2DAnmColor* anmColor) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (isNeedSetAnm(i)) {
|
||||
mFrameMaterial[i]->setAnimation(anmColor);
|
||||
}
|
||||
}
|
||||
if (mContentsMaterial != NULL) {
|
||||
mContentsMaterial->setAnimation(anmColor);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAnimation(J2DAnmTextureSRTKey* param_0) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (isNeedSetAnm(i)) {
|
||||
mFrameMaterial[i]->setAnimation(param_0);
|
||||
}
|
||||
}
|
||||
if (mContentsMaterial != NULL) {
|
||||
mContentsMaterial->setAnimation(param_0);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAnimation(J2DAnmTexPattern* param_0) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (isNeedSetAnm(i)) {
|
||||
mFrameMaterial[i]->setAnimation(param_0);
|
||||
}
|
||||
}
|
||||
if (mContentsMaterial != NULL) {
|
||||
mContentsMaterial->setAnimation(param_0);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAnimation(J2DAnmTevRegKey* param_0) {
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (isNeedSetAnm(i)) {
|
||||
mFrameMaterial[i]->setAnimation(param_0);
|
||||
}
|
||||
}
|
||||
if (mContentsMaterial != NULL) {
|
||||
mContentsMaterial->setAnimation(param_0);
|
||||
}
|
||||
}
|
||||
|
||||
bool J2DWindowEx::isNeedSetAnm(u8 param_0) {
|
||||
for (u8 i = 0; i < param_0; i++) {
|
||||
if (mFrameMaterial[i] == mFrameMaterial[param_0]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mFrameMaterial[param_0] != NULL;
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAnimation(J2DAnmVisibilityFull* param_0) {
|
||||
mAnmVisibilityFull = param_0;
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAnimation(J2DAnmVtxColor* param_0) {
|
||||
mAnmVtxColor = param_0;
|
||||
field_0x17c = 0;
|
||||
if (param_0 != NULL) {
|
||||
u16 uVar3 = param_0->getAnmTableNum(0);
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if (field_0x168[i] != 0xffff) {
|
||||
for (u16 j = 0; j < uVar3; j++) {
|
||||
J3DAnmVtxColorIndexData* puVar1 = param_0->getAnmVtxColorIndexData(0, j);
|
||||
u16* indexPointer2 =
|
||||
param_0->getVtxColorIndexPointer(0) + (uintptr_t)puVar1->mpData;
|
||||
for (u16 k = 0; k < puVar1->mNum; k++) {
|
||||
if (indexPointer2[k] == field_0x168[i]) {
|
||||
mAnmVtxColor = param_0;
|
||||
field_0x17c |= 1 << i;
|
||||
goto nexti;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nexti:;
|
||||
}
|
||||
}
|
||||
|
||||
if (field_0x17c == 0) {
|
||||
mAnmVtxColor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const J2DAnmTransform* J2DWindowEx::animationPane(J2DAnmTransform const* param_0) {
|
||||
if (mAnmVisibilityFull != 0 && field_0x166 != 0xffff) {
|
||||
u8 visibility;
|
||||
mAnmVisibilityFull->getVisibility(field_0x166, &visibility);
|
||||
if (visibility) {
|
||||
J2DPane::show();
|
||||
} else {
|
||||
J2DPane::hide();
|
||||
}
|
||||
}
|
||||
|
||||
JUtility::TColor* local_38[4] = {
|
||||
&field_0x128,
|
||||
&field_0x12C,
|
||||
&field_0x130,
|
||||
&field_0x134,
|
||||
};
|
||||
|
||||
if (mAnmVtxColor != NULL) {
|
||||
u16 uVar3 = mAnmVtxColor->getAnmTableNum(0);
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
if ((field_0x17c & (1 << i))) {
|
||||
for (u16 j = 0; j < uVar3; j++) {
|
||||
J3DAnmVtxColorIndexData* puVar1 = mAnmVtxColor->getAnmVtxColorIndexData(0, j);
|
||||
u16* indexPointer2 =
|
||||
mAnmVtxColor->getVtxColorIndexPointer(0) + (uintptr_t)puVar1->mpData;
|
||||
for (u16 k = 0; k < puVar1->mNum; k++) {
|
||||
if (indexPointer2[k] == field_0x168[i]) {
|
||||
mAnmVtxColor->getColor(0, j, local_38[i]);
|
||||
goto nexti;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nexti:;
|
||||
}
|
||||
}
|
||||
return J2DPane::animationPane(param_0);
|
||||
}
|
||||
|
||||
J2DMaterial* J2DWindowEx::getFrameMaterial(u8 index) const {
|
||||
if (index >= 4) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mFrameMaterial[index];
|
||||
}
|
||||
|
||||
J2DMaterial* J2DWindowEx::getContentsMaterial() const {
|
||||
return mContentsMaterial;
|
||||
}
|
||||
|
||||
void J2DWindowEx::getMaterial(J2DWindow::TMaterial& param_0) const {
|
||||
param_0.field_0x0 = mFrameMaterial[0];
|
||||
param_0.field_0x4 = mFrameMaterial[1];
|
||||
param_0.field_0x8 = mFrameMaterial[2];
|
||||
param_0.field_0xc = mFrameMaterial[3];
|
||||
param_0.field_0x10 = mContentsMaterial;
|
||||
}
|
||||
|
||||
void J2DWindowEx::draw(f32 param_0, f32 param_1, f32 param_2, f32 param_3) {
|
||||
draw(JGeometry::TBox2<f32>(JGeometry::TVec2<f32>(param_0, param_1),
|
||||
JGeometry::TVec2<f32>(param_0 + param_2, param_1 + param_3)));
|
||||
}
|
||||
|
||||
void J2DWindowEx::setCullBack(bool param_0) {
|
||||
_GXCullMode mode;
|
||||
if (param_0) {
|
||||
mode = GX_CULL_BACK;
|
||||
} else {
|
||||
mode = GX_CULL_NONE;
|
||||
}
|
||||
setCullBack(mode);
|
||||
}
|
||||
|
||||
bool J2DWindowEx::isUsed(ResFONT const* param_0) {
|
||||
return J2DPane::isUsed(param_0);
|
||||
}
|
||||
|
||||
void J2DWindowEx::setAnimation(J2DAnmBase* param_0) {
|
||||
J2DPane::setAnimation(param_0);
|
||||
}
|
||||
Reference in New Issue
Block a user