Merge decomp/main into dusk

Merges 44 upstream commits from zeldaret/tp decomp/main.

Conflict resolutions:
- .github/workflows/build.yml: keep deleted (not needed for PC port)
- README.md: keep PC port README
- J3DAnimation.h: keep OFFSET_PTR macro + add upstream forward decl
- J3DModelLoader.h: keep BE(u32) mBlockNum + add field_0x1c
- d_com_inf_game.h: keep PC port inlines + add upstream declarations
- global.h: keep MULTI_CHAR macro + add FABSF macro
- JUTConsole.cpp: keep uintptr_t cast for 64-bit
- JUTDbPrint.cpp: keep PC enter_() helper + add cstring include
- JUTResFont.cpp: take upstream loop/struct improvements with BE types
- JUTCacheFont.cpp: take upstream decomp fix
- float.h: use upstream !PLATFORM_GCN guard
- d_a_npc_bouS/theB.cpp: keep MULTI_CHAR() for PC portability
- d_a_npc_henna.cpp: keep uintptr_t + use upstream var name
- d_demo.cpp: keep near_/far_ field renames for PC
- d_resorce.cpp: keep uintptr_t + fix var name to res
- d_s_room.cpp, m_Do_graphic.cpp: keep dusk includes + add cstring
- m_Do_main.cpp: keep JHIComPortManager + use JAS_GLOBAL_INSTANCE_INIT
- angle_utils.h: remove redundant types.h include
This commit is contained in:
Luke Street
2026-02-28 13:28:42 -07:00
3803 changed files with 240344 additions and 16831 deletions
+1
View File
@@ -3,6 +3,7 @@
#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 <dolphin/os.h>
+1
View File
@@ -4,6 +4,7 @@
#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"
#ifndef __MWERKS__
+1 -2
View File
@@ -471,8 +471,7 @@ const ResTIMG* J2DPicture::changeTexture(char const* resName, u8 param_1) {
return changeTexture((ResTIMG*)J2DScreen::getNameResource(resName), param_1);
}
static bool dummy_weak_order(JUTTexture* tex) {
J2DPicture* picture;
static bool dummy_weak_order(J2DPicture* picture, JUTTexture* tex) {
return picture->append(tex, 1.0f);
}
+1
View File
@@ -5,6 +5,7 @@
#include "JSystem/JUtility/JUTFont.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
char* J2DPrint::mStrBuff;
+1
View File
@@ -5,6 +5,7 @@
#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() {
@@ -1,6 +1,7 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J3DGraphAnimator/J3DAnimation.h"
#include "JSystem/J3DGraphAnimator/J3DModelData.h"
#include "JSystem/J3DGraphBase/J3DStruct.h"
#include "JSystem/JMath/JMath.h"
@@ -26,14 +26,6 @@ J3DMtxBuffer* J3DMtxCalc::mMtxBuffer;
J3DJoint* J3DMtxCalc::mJoint;
inline s32 checkScaleOne(const Vec& param_0) {
if (param_0.x == 1.0f && param_0.y == 1.0f && param_0.z == 1.0f) {
return true;
} else {
return false;
}
}
void J3DMtxCalcCalcTransformBasic::calcTransform(J3DTransformInfo const& transInfo) {
J3DJoint* joint = J3DMtxCalc::getJoint();
J3DMtxBuffer* mtxBuf = J3DMtxCalc::getMtxBuffer();
+25
View File
@@ -0,0 +1,25 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J3DU/J3DUFur.h"
#include "JSystem/J3DGraphAnimator/J3DModel.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "JSystem/J3DGraphBase/J3DVertex.h"
static void dummy(J3DShape* shape, J3DVertexBuffer* vtxBuf, J3DModel* model, J3DModelData* modelData) {
J3DMaterial* material = shape->getMaterial();
J3DJoint* joint = material->getJoint();
vtxBuf->swapTransformedVtxPos();
J3DVertexData* vtxData = vtxBuf->getVertexData();
vtxBuf->getTransformedVtxPos(0);
vtxBuf->getCurrentVtxNrm();
vtxBuf->setCurrentVtxPos(NULL);
model->getVertexBuffer();
vtxData->getNrmNum();
modelData->getNrmNum();
vtxData->getVtxNum();
modelData->getVtxNum();
}
+16
View File
@@ -0,0 +1,16 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J3DU/J3DUMotion.h"
#include "JSystem/J3DGraphAnimator/J3DJoint.h"
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
#include "JSystem/JMath/JMath.h"
static void dummy(J3DMtxCalcJ3DSysInitSoftimage* img, Vec* vec) {
Mtx mtx;
img->init(*vec, mtx);
checkScaleOne(*vec);
J3DMtxCalc::getMtxBuffer();
JMAFastReciprocal(0.0f);
JMath::fastReciprocal(0.0f);
}
+20
View File
@@ -0,0 +1,20 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J3DU/J3DUShadow.h"
#include "JSystem/JGeometry.h"
#include "JSystem/JMath/JMath.h"
#include "JSystem/JUtility/JUTTexture.h"
void J3DUShadow_dummy(JUTTexture* tex, JGeometry::TVec3<f32>* vec) {
JMAAbs(0.0f);
JMathInlineVEC::C_VECDotProduct(NULL, NULL);
vec->dot(*vec);
vec->length();
tex->getCaptureFlag();
tex->getFormat();
JMath::fastSqrt<f32>(0.0f);
JUTTexture tex2;
tex2.setCaptureFlag(false);
}
+1
View File
@@ -4,6 +4,7 @@
#include "JSystem/JAHostIO/JAHioMessage.h"
#include "JSystem/JAHostIO/JAHioMgr.h"
#include "JSystem/JHostIO/JORServer.h"
#include <cstring>
JAHioNode::JAHioNode(const char* name) : mTree(this) {
mLastChild = NULL;
-12
View File
@@ -263,9 +263,6 @@ s16 const JASCalc::CUTOFF_TO_IIR_TABLE[128][4] = {
0x7FFF, 0x0000, 0x0000, 0x0000,
};
template <>
s16 JASCalc::clamp(s32);
// currently required because of missing functions
// JASCalc::hannWindow(short *, u32)
// JASCalc::hammWindow(short *, u32)
@@ -319,12 +316,3 @@ f32 JASCalc::pow2(f32 x) {
return ret;
}
template <>
s16 JASCalc::clamp(s32 x) {
if (x <= std::numeric_limits<s16>::min())
return std::numeric_limits<s16>::min();
if (x >= std::numeric_limits<s16>::max())
return std::numeric_limits<s16>::max();
return x;
}
+5
View File
@@ -0,0 +1,5 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JAudio2/JAUAudience.h"
// NONMATCHING
+1
View File
@@ -15,6 +15,7 @@
#include "JSystem/JAudio2/JAUStreamFileTable.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include <dolphin/dvd.h>
#include <cstring>
namespace {
class TPushCurrentHeap {
+9
View File
@@ -0,0 +1,9 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JAudio2/JAUSoundObject.h"
#include "JSystem/JGeometry.h"
static void dummy(JGeometry::TVec3<f32>* vec_1, JGeometry::TVec3<f32>* vec_2) {
*vec_1 = *vec_2;
}
+2 -2
View File
@@ -337,10 +337,10 @@ JKRFileFinder* JKRArchive::getFirstFile(const char* path) const {
return NULL;
}
u32 JKRArchive::getFileAttribute(u32 index) const {
u8 JKRArchive::getFileAttribute(u32 index) const {
SDIFileEntry* fileEntry = findIdxResource(index);
if (fileEntry) {
return u8(fileEntry->type_flags_and_name_offset >> 24);
return fileEntry->type_flags_and_name_offset >> 24;
}
return 0;
+358 -347
View File
@@ -135,15 +135,7 @@ void JPACalcClrIdxNormal(JPAEmitterWorkData* work) {
void JPACalcClrIdxNormal(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
s16 age = param_1->mAge;
s16 maxFrm = shape->getClrAnmMaxFrm();
s16 keyFrame;
if (age < maxFrm) {
keyFrame = age;
} else {
keyFrame = maxFrm;
}
work->mClrKeyFrame = keyFrame;
work->mClrKeyFrame = param_1->mAge < shape->getClrAnmMaxFrm() ? param_1->mAge : shape->getClrAnmMaxFrm();
}
void JPACalcClrIdxRepeat(JPAEmitterWorkData* work) {
@@ -153,27 +145,25 @@ void JPACalcClrIdxRepeat(JPAEmitterWorkData* work) {
void JPACalcClrIdxRepeat(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
s32 tick = shape->getClrLoopOfst(param_1->mAnmRandom);
tick = param_1->mAge + tick;
work->mClrKeyFrame = tick % (shape->getClrAnmMaxFrm() + 1);
s32 r28 = shape->getClrAnmMaxFrm() + 1;
work->mClrKeyFrame = (param_1->mAge + shape->getClrLoopOfst(param_1->mAnmRandom)) % r28;
}
void JPACalcClrIdxReverse(JPAEmitterWorkData* work) {
JPABaseShape* shape = work->mpRes->getBsp();
int maxFrm = shape->getClrAnmMaxFrm();
u32 tick = work->mpEmtr->mTick;
u32 uVar1 = tick / maxFrm;
tick = tick % maxFrm;
uVar1 &= 1;
work->mClrKeyFrame = tick + (uVar1) * (maxFrm - tick * 2);
u32 div = (work->mpEmtr->mTick / maxFrm) & 1;
u32 rem = work->mpEmtr->mTick % maxFrm;
work->mClrKeyFrame = rem + (div) * (maxFrm - rem * 2);
}
void JPACalcClrIdxReverse(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
s32 tick = param_1->mAge + shape->getClrLoopOfst(param_1->mAnmRandom);
s32 r29 = param_1->mAge + shape->getClrLoopOfst(param_1->mAnmRandom);
s32 maxFrm = shape->getClrAnmMaxFrm();
s32 rem = tick % maxFrm;
work->mClrKeyFrame = rem + ((tick / maxFrm) & 1) * (maxFrm - rem * 2);
s32 div = (r29 / maxFrm) & 1;
s32 rem = r29 % maxFrm;
work->mClrKeyFrame = rem + (div) * (maxFrm - rem * 2);
}
void JPACalcClrIdxMerge(JPAEmitterWorkData* work) {
@@ -183,8 +173,7 @@ void JPACalcClrIdxMerge(JPAEmitterWorkData* work) {
void JPACalcClrIdxMerge(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
s32 maxFrm = shape->getClrAnmMaxFrm() + 1;
s32 tick = (s32)(param_1->mTime * maxFrm) + shape->getClrLoopOfst(param_1->mAnmRandom);
work->mClrKeyFrame = tick % maxFrm;
work->mClrKeyFrame = (s32(param_1->mTime * maxFrm) + shape->getClrLoopOfst(param_1->mAnmRandom)) % maxFrm;
}
void JPACalcClrIdxRandom(JPAEmitterWorkData* work) {
@@ -193,9 +182,7 @@ void JPACalcClrIdxRandom(JPAEmitterWorkData* work) {
void JPACalcClrIdxRandom(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
s32 tick = shape->getClrLoopOfst(param_1->mAnmRandom);
s32 maxFrm = shape->getClrAnmMaxFrm() + 1;
work->mClrKeyFrame = tick % maxFrm;
work->mClrKeyFrame = shape->getClrLoopOfst(param_1->mAnmRandom) % (shape->getClrAnmMaxFrm() + 1);
}
void JPACalcPrm(JPAEmitterWorkData* work) {
@@ -221,15 +208,15 @@ void JPACalcColorCopy(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
}
void JPAGenTexCrdMtxIdt(JPAEmitterWorkData* param_0) {
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
}
void JPAGenTexCrdMtxAnm(JPAEmitterWorkData* param_0) {
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX0, GX_FALSE, GX_PTIDENTITY);
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX0);
}
void JPAGenTexCrdMtxPrj(JPAEmitterWorkData* param_0) {
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_POS, GX_TEXMTX0, GX_FALSE, GX_PTIDENTITY);
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_POS, GX_TEXMTX0);
}
void JPAGenCalcTexCrdMtxAnm(JPAEmitterWorkData* work) {
@@ -260,7 +247,7 @@ void JPAGenCalcTexCrdMtxAnm(JPAEmitterWorkData* work) {
local_108[2][2] = 1.0f;
local_108[2][3] = 0.0f;
GXLoadTexMtxImm(local_108, 0x1e, GX_MTX2x4);
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 0x1e, false, 0x7d);
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_TEXMTX0);
}
void JPALoadCalcTexCrdMtxAnm(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
@@ -307,16 +294,12 @@ void JPALoadTexAnm(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
void JPACalcTexIdxNormal(JPAEmitterWorkData* work) {
JPABaseShape* shape = work->mpRes->getBsp();
u8 tick = shape->getTexAnmKeyNum() - 1 < work->mpEmtr->mTick
? shape->getTexAnmKeyNum() - 1 : work->mpEmtr->mTick;
work->mpEmtr->mTexAnmIdx = shape->getTexIdx(tick);
work->mpEmtr->mTexAnmIdx = shape->getTexIdx(shape->getTexAnmKeyNum() - 1 < work->mpEmtr->mTick ? shape->getTexAnmKeyNum() - 1 : work->mpEmtr->mTick);
}
void JPACalcTexIdxNormal(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
u8 tick = shape->getTexAnmKeyNum() - 1 < param_1->mAge
? shape->getTexAnmKeyNum() - 1 : param_1->mAge;
param_1->mTexAnmIdx = shape->getTexIdx(tick);
param_1->mTexAnmIdx = shape->getTexIdx(shape->getTexAnmKeyNum() - 1 < param_1->mAge ? shape->getTexAnmKeyNum() - 1 : param_1->mAge);
}
void JPACalcTexIdxRepeat(JPAEmitterWorkData* work) {
@@ -335,18 +318,18 @@ void JPACalcTexIdxReverse(JPAEmitterWorkData* work) {
JPABaseShape* shape = work->mpRes->getBsp();
int tick = work->mpEmtr->mTick;
int keyNum = (int)shape->getTexAnmKeyNum() - 1;
int div = tick / keyNum;
int div = tick / keyNum & 1;
int rem = tick % keyNum;
work->mpEmtr->mTexAnmIdx = shape->getTexIdx(rem + (div & 1) * (keyNum - rem * 2));
work->mpEmtr->mTexAnmIdx = shape->getTexIdx(rem + div * (keyNum - rem * 2));
}
void JPACalcTexIdxReverse(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
s32 tick = shape->getTexLoopOfst(param_1->mAnmRandom) + param_1->mAge;
int keyNum = (int)shape->getTexAnmKeyNum() - 1;
int div = tick / keyNum;
int div = tick / keyNum & 1;
int rem = tick % keyNum;
param_1->mTexAnmIdx = shape->getTexIdx(rem + (div & 1) * (keyNum - rem * 2));
param_1->mTexAnmIdx = shape->getTexIdx(rem + div * (keyNum - rem * 2));
}
void JPACalcTexIdxMerge(JPAEmitterWorkData* work) {
@@ -356,8 +339,7 @@ void JPACalcTexIdxMerge(JPAEmitterWorkData* work) {
void JPACalcTexIdxMerge(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
JPABaseShape* shape = work->mpRes->getBsp();
s32 maxFrm = shape->getTexAnmKeyNum();
s32 tick = (s32)(maxFrm * param_1->mTime) + shape->getTexLoopOfst(param_1->mAnmRandom);
param_1->mTexAnmIdx = shape->getTexIdx(tick % maxFrm);
param_1->mTexAnmIdx = shape->getTexIdx((s32(maxFrm * param_1->mTime) + shape->getTexLoopOfst(param_1->mAnmRandom)) % maxFrm);
}
void JPACalcTexIdxRandom(JPAEmitterWorkData* work) {
@@ -435,124 +417,122 @@ static projectionFunc p_prj[3] = {
};
void JPADrawBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, param_1->mPosition, local_48);
Mtx local_38;
local_38[0][0] = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
local_38[0][3] = local_48.x;
local_38[1][1] = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
local_38[1][3] = local_48.y;
local_38[2][2] = 1.0f;
local_38[2][3] = local_48.z;
local_38[2][1] = 0.0f;
local_38[2][0] = 0.0f;
local_38[1][2] = 0.0f;
local_38[1][0] = 0.0f;
local_38[0][2] = 0.0f;
local_38[0][1] = 0.0f;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, &param_1->mPosition, &local_48);
Mtx local_38;
local_38[0][0] = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
local_38[0][3] = local_48.x;
local_38[1][1] = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
local_38[1][3] = local_48.y;
local_38[2][2] = 1.0f;
local_38[2][3] = local_48.z;
local_38[0][1] = local_38[0][2] = local_38[1][0] = local_38[1][2] = local_38[2][0] = local_38[2][1] = 0.0f;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
}
void JPADrawRotBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, param_1->mPosition, local_48);
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
f32 particleX = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx local_38;
local_38[0][0] = cosRot * particleX;
local_38[0][1] = -sinRot * particleY;
local_38[0][3] = local_48.x;
local_38[1][0] = sinRot * particleX;
local_38[1][1] = cosRot * particleY;
local_38[1][3] = local_48.y;
local_38[2][2] = 1.0f;
local_38[2][3] = local_48.z;
local_38[2][1] = 0.0f;
local_38[2][0] = 0.0f;
local_38[1][2] = 0.0f;
local_38[0][2] = 0.0f;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, &param_1->mPosition, &local_48);
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
f32 particleX = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx local_38;
local_38[0][0] = cosRot * particleX;
local_38[0][1] = -sinRot * particleY;
local_38[0][3] = local_48.x;
local_38[1][0] = sinRot * particleX;
local_38[1][1] = cosRot * particleY;
local_38[1][3] = local_48.y;
local_38[2][2] = 1.0f;
local_38[2][3] = local_48.z;
local_38[0][2] = local_38[1][2] = local_38[2][0] = local_38[2][1] = 0.0f;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
}
void JPADrawYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, param_1->mPosition, local_48);
Mtx local_38;
f32 particleY = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
local_38[0][0] = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
local_38[0][3] = local_48.x;
local_38[1][1] = work->mYBBCamMtx[1][1] * particleY;
local_38[1][2] = work->mYBBCamMtx[1][2];
local_38[1][3] = local_48.y;
local_38[2][1] = work->mYBBCamMtx[2][1] * particleY;
local_38[2][2] = work->mYBBCamMtx[2][2];
local_38[2][3] = local_48.z;
local_38[2][0] = 0.0f;
local_38[1][0] = 0.0f;
local_38[0][2] = 0.0f;
local_38[0][1] = 0.0f;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, &param_1->mPosition, &local_48);
Mtx local_38;
f32 particleX = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
local_38[0][0] = particleX;
local_38[0][3] = local_48.x;
local_38[1][1] = work->mYBBCamMtx[1][1] * particleY;
local_38[1][2] = work->mYBBCamMtx[1][2];
local_38[1][3] = local_48.y;
local_38[2][1] = work->mYBBCamMtx[2][1] * particleY;
local_38[2][2] = work->mYBBCamMtx[2][2];
local_38[2][3] = local_48.z;
local_38[0][1] = local_38[0][2] = local_38[1][0] = local_38[2][0] = 0.0f;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
}
void JPADrawRotYBillboard(JPAEmitterWorkData* work, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, param_1->mPosition, local_48);
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
Mtx local_38;
f32 particleX = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
f32 local_98 = (float)(sinRot * particleX);
f32 local_94 = (float)(cosRot * particleY);
f32 local_90 = work->mYBBCamMtx[1][1];
f32 fVar1 = work->mYBBCamMtx[2][1];
local_38[0][0] = (float)(cosRot * particleX);
local_38[0][1] = (float)(-sinRot * particleY);
local_38[0][2] = 0.0f;
local_38[0][3] = local_48.x;
local_38[1][0] = local_98 * local_90;
local_38[1][1] = local_94 * local_90;
local_38[1][2] = -fVar1;
local_38[1][3] = local_48.y;
local_38[2][0] = local_98 * fVar1;
local_38[2][1] = local_94 * fVar1;
local_38[2][2] = local_90;
local_38[2][3] = local_48.z;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
JGeometry::TVec3<f32> local_48;
MTXMultVec(work->mPosCamMtx, &param_1->mPosition, &local_48);
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
Mtx local_38;
f32 particleX = work->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = work->mGlobalPtclScl.y * param_1->mParticleScaleY;
f32 local_98 = (float)(sinRot * particleX);
f32 local_94 = (float)(cosRot * particleY);
f32 local_90 = work->mYBBCamMtx[1][1];
f32 fVar1 = work->mYBBCamMtx[2][1];
local_38[0][0] = (float)(cosRot * particleX);
local_38[0][1] = (float)(-sinRot * particleY);
local_38[0][2] = 0.0f;
local_38[0][3] = local_48.x;
local_38[1][0] = local_98 * local_90;
local_38[1][1] = local_94 * local_90;
local_38[1][2] = -fVar1;
local_38[1][3] = local_48.y;
local_38[2][0] = local_98 * fVar1;
local_38[2][1] = local_94 * fVar1;
local_38[2][2] = local_90;
local_38[2][3] = local_48.z;
GXLoadPosMtxImm(local_38, 0);
p_prj[work->mPrjType](work, local_38);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
}
void dirTypeVel(JPAEmitterWorkData const* work, JPABaseParticle const* param_1,
JGeometry::TVec3<f32>* param_2) {
param_1->getVelVec(*param_2);
param_1->getVelVec(param_2);
}
void dirTypePos(JPAEmitterWorkData const* work, JPABaseParticle const* param_1,
JGeometry::TVec3<f32>* param_2) {
param_1->getLocalPosition(*param_2);
param_1->getLocalPosition(param_2);
}
void dirTypePosInv(JPAEmitterWorkData const* work, JPABaseParticle const* param_1,
JGeometry::TVec3<f32>* param_2) {
param_1->getLocalPosition(*param_2);
param_1->getLocalPosition(param_2);
param_2->negate();
}
@@ -564,13 +544,10 @@ void dirTypeEmtrDir(JPAEmitterWorkData const* work, JPABaseParticle const* param
void dirTypePrevPtcl(JPAEmitterWorkData const* work, JPABaseParticle const* param_1,
JGeometry::TVec3<f32>* param_2) {
JGeometry::TVec3<f32> aTStack_24;
param_1->getGlobalPosition(aTStack_24);
JPANode<JPABaseParticle>* end = work->mpAlivePtcl->getEnd();
JPANode<JPABaseParticle>* prev = work->mpCurNode->getPrev();
if (end != prev) {
JPABaseParticle* particle = work->mpCurNode->getPrev()->getObject();
particle->getGlobalPosition(*param_2);
param_1->getGlobalPosition(&aTStack_24);
if (work->mpCurNode->getPrev() != work->mpAlivePtcl->getEnd()) {
work->mpCurNode->getPrev()->getObject()->getGlobalPosition(param_2);
} else {
work->mpEmtr->calcEmitterGlobalPosition(param_2);
}
@@ -623,23 +600,22 @@ static void rotTypeZ(f32 param_0, f32 param_1, Mtx& param_2) {
}
static void rotTypeXYZ(f32 param_0, f32 param_1, Mtx& param_2) {
f32 f3 = 0.33333298563957214f * (1.0f - param_1);
f32 fVar1;
f32 f4;
f4 = f3 + 0.5773500204086304f * param_0;
fVar1 = f3 - 0.5773500204086304f * param_0;
f3 += param_1;
param_2[0][0] = f3;
param_2[0][1] = fVar1;
param_2[0][2] = f4;
f32 f31 = 0.33333298563957214f * (1.0f - param_1);
f32 f30 = 0.57735f * param_0;
f32 f29 = f31 + f30;
f30 = f31 - f30;
f31 += param_1;
param_2[0][0] = f31;
param_2[0][1] = f30;
param_2[0][2] = f29;
param_2[0][3] = 0.0f;
param_2[1][0] = f4;
param_2[1][1] = f3;
param_2[1][2] = fVar1;
param_2[1][0] = f29;
param_2[1][1] = f31;
param_2[1][2] = f30;
param_2[1][3] = 0.0f;
param_2[2][0] = fVar1;
param_2[2][1] = f4;
param_2[2][2] = f3;
param_2[2][0] = f30;
param_2[2][1] = f29;
param_2[2][2] = f31;
param_2[2][3] = 0.0f;
}
@@ -704,141 +680,160 @@ static u8* p_dl[2] = {
};
void JPADrawDirection(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
JGeometry::TVec3<f32> local_6c;
JGeometry::TVec3<f32> local_78;
p_direction[param_0->mDirType](param_0, param_1, &local_6c);
if (!local_6c.isZero()) {
local_6c.normalize();
local_78.cross(param_1->mBaseAxis, local_6c);
if (!local_78.isZero()) {
local_78.normalize();
param_1->mBaseAxis.cross(local_6c, local_78);
param_1->mBaseAxis.normalize();
Mtx local_60;
f32 fVar1 = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 fVar2 = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
local_60[0][0] = param_1->mBaseAxis.x;
local_60[0][1] = local_6c.x;
local_60[0][2] = local_78.x;
local_60[0][3] = param_1->mPosition.x;
local_60[1][0] = param_1->mBaseAxis.y;
local_60[1][1] = local_6c.y;
local_60[1][2] = local_78.y;
local_60[1][3] = param_1->mPosition.y;
local_60[2][0] = param_1->mBaseAxis.z;
local_60[2][1] = local_6c.z;
local_60[2][2] = local_78.z;
local_60[2][3] = param_1->mPosition.z;
p_plane[param_0->mPlaneType](local_60, fVar1, fVar2);
MTXConcat(param_0->mPosCamMtx, local_60, local_60);
GXLoadPosMtxImm(local_60, 0);
p_prj[param_0->mPrjType](param_0, local_60);
GXCallDisplayList(p_dl[param_0->mDLType], sizeof(jpa_dl));
}
}
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
JGeometry::TVec3<f32> local_6c;
JGeometry::TVec3<f32> local_78;
p_direction[param_0->mDirType](param_0, param_1, &local_6c);
if (local_6c.isZero()) {
return;
}
local_6c.normalize();
local_78.cross(param_1->mBaseAxis, local_6c);
if (local_78.isZero()) {
return;
}
local_78.normalize();
param_1->mBaseAxis.cross(local_6c, local_78);
param_1->mBaseAxis.normalize();
Mtx local_60;
f32 fVar1 = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 fVar2 = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
local_60[0][0] = param_1->mBaseAxis.x;
local_60[0][1] = local_6c.x;
local_60[0][2] = local_78.x;
local_60[0][3] = param_1->mPosition.x;
local_60[1][0] = param_1->mBaseAxis.y;
local_60[1][1] = local_6c.y;
local_60[1][2] = local_78.y;
local_60[1][3] = param_1->mPosition.y;
local_60[2][0] = param_1->mBaseAxis.z;
local_60[2][1] = local_6c.z;
local_60[2][2] = local_78.z;
local_60[2][3] = param_1->mPosition.z;
p_plane[param_0->mPlaneType](local_60, fVar1, fVar2);
MTXConcat(param_0->mPosCamMtx, local_60, local_60);
GXLoadPosMtxImm(local_60, 0);
p_prj[param_0->mPrjType](param_0, local_60);
GXCallDisplayList(p_dl[param_0->mDLType], sizeof(jpa_dl));
}
void JPADrawRotDirection(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
JGeometry::TVec3<f32> local_6c;
JGeometry::TVec3<f32> local_78;
p_direction[param_0->mDirType](param_0, param_1, &local_6c);
if (!local_6c.isZero()) {
local_6c.normalize();
local_78.cross(param_1->mBaseAxis, local_6c);
if (!local_78.isZero()) {
local_78.normalize();
param_1->mBaseAxis.cross(local_6c, local_78);
param_1->mBaseAxis.normalize();
f32 particleX = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx auStack_80;
Mtx local_60;
p_rot[param_0->mRotType](sinRot, cosRot, auStack_80);
p_plane[param_0->mPlaneType](auStack_80, particleX, particleY);
local_60[0][0] = param_1->mBaseAxis.x;
local_60[0][1] = local_6c.x;
local_60[0][2] = local_78.x;
local_60[0][3] = param_1->mPosition.x;
local_60[1][0] = param_1->mBaseAxis.y;
local_60[1][1] = local_6c.y;
local_60[1][2] = local_78.y;
local_60[1][3] = param_1->mPosition.y;
local_60[2][0] = param_1->mBaseAxis.z;
local_60[2][1] = local_6c.z;
local_60[2][2] = local_78.z;
local_60[2][3] = param_1->mPosition.z;
MTXConcat(local_60, auStack_80, auStack_80);
MTXConcat(param_0->mPosCamMtx, auStack_80, local_60);
GXLoadPosMtxImm(local_60, 0);
p_prj[param_0->mPrjType](param_0, local_60);
GXCallDisplayList(p_dl[param_0->mDLType], sizeof(jpa_dl));
}
}
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
JGeometry::TVec3<f32> local_6c;
JGeometry::TVec3<f32> local_78;
p_direction[param_0->mDirType](param_0, param_1, &local_6c);
if (local_6c.isZero()) {
return;
}
local_6c.normalize();
local_78.cross(param_1->mBaseAxis, local_6c);
if (local_78.isZero()) {
return;
}
local_78.normalize();
param_1->mBaseAxis.cross(local_6c, local_78);
param_1->mBaseAxis.normalize();
f32 particleX = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx auStack_80;
Mtx local_60;
p_rot[param_0->mRotType](sinRot, cosRot, auStack_80);
p_plane[param_0->mPlaneType](auStack_80, particleX, particleY);
local_60[0][0] = param_1->mBaseAxis.x;
local_60[0][1] = local_6c.x;
local_60[0][2] = local_78.x;
local_60[0][3] = param_1->mPosition.x;
local_60[1][0] = param_1->mBaseAxis.y;
local_60[1][1] = local_6c.y;
local_60[1][2] = local_78.y;
local_60[1][3] = param_1->mPosition.y;
local_60[2][0] = param_1->mBaseAxis.z;
local_60[2][1] = local_6c.z;
local_60[2][2] = local_78.z;
local_60[2][3] = param_1->mPosition.z;
MTXConcat(local_60, auStack_80, auStack_80);
MTXConcat(param_0->mPosCamMtx, auStack_80, local_60);
GXLoadPosMtxImm(local_60, 0);
p_prj[param_0->mPrjType](param_0, local_60);
GXCallDisplayList(p_dl[param_0->mDLType], sizeof(jpa_dl));
}
void JPADrawDBillboard(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
JGeometry::TVec3<f32> local_70;
p_direction[param_0->mDirType](param_0, param_1, &local_70);
JGeometry::TVec3<f32> aTStack_7c;
aTStack_7c.set(param_0->mPosCamMtx[2][0], param_0->mPosCamMtx[2][1],
param_0->mPosCamMtx[2][2]);
local_70.cross(local_70, aTStack_7c);
if (!local_70.isZero()) {
local_70.normalize();
MTXMultVecSR(param_0->mPosCamMtx, local_70, local_70);
JGeometry::TVec3<f32> local_88;
MTXMultVec(param_0->mPosCamMtx, param_1->mPosition, local_88);
f32 particleX = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx local_60;
local_60[0][0] = local_70.x * particleX;
local_60[0][1] = -local_70.y * particleY;
local_60[0][3] = local_88.x;
local_60[1][0] = local_70.y * particleX;
local_60[1][1] = local_70.x * particleY;
local_60[1][3] = local_88.y;
local_60[2][2] = 1.0f;
local_60[2][3] = local_88.z;
local_60[2][1] = 0.0f;
local_60[2][0] = 0.0f;
local_60[1][2] = 0.0f;
local_60[0][2] = 0.0f;
GXLoadPosMtxImm(local_60, 0);
p_prj[param_0->mPrjType](param_0, local_60);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
}
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
JGeometry::TVec3<f32> local_70;
p_direction[param_0->mDirType](param_0, param_1, &local_70);
JGeometry::TVec3<f32> aTStack_7c(param_0->mPosCamMtx[2][0], param_0->mPosCamMtx[2][1], param_0->mPosCamMtx[2][2]);
local_70.cross(local_70, aTStack_7c);
if (local_70.isZero()) {
return;
}
local_70.normalize();
MTXMultVecSR(param_0->mPosCamMtx, &local_70, &local_70);
JGeometry::TVec3<f32> local_88;
MTXMultVec(param_0->mPosCamMtx, &param_1->mPosition, &local_88);
f32 particleX = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx local_60;
local_60[0][0] = local_70.x * particleX;
local_60[0][1] = -local_70.y * particleY;
local_60[0][3] = local_88.x;
local_60[1][0] = local_70.y * particleX;
local_60[1][1] = local_70.x * particleY;
local_60[1][3] = local_88.y;
local_60[2][2] = 1.0f;
local_60[2][3] = local_88.z;
local_60[0][2] = local_60[1][2] = local_60[2][0] = local_60[2][1] = 0.0f;
GXLoadPosMtxImm(local_60, 0);
p_prj[param_0->mPrjType](param_0, local_60);
GXCallDisplayList(jpa_dl, sizeof(jpa_dl));
}
void JPADrawRotation(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
f32 particleX = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx auStack_88;
p_rot[param_0->mRotType](sinRot, cosRot, auStack_88);
p_plane[param_0->mPlaneType](auStack_88, particleX, particleY);
auStack_88[0][3] = param_1->mPosition.x;
auStack_88[1][3] = param_1->mPosition.y;
auStack_88[2][3] = param_1->mPosition.z;
MTXConcat(param_0->mPosCamMtx, auStack_88, auStack_88);
GXLoadPosMtxImm(auStack_88, 0);
p_prj[param_0->mPrjType](param_0, auStack_88);
GXCallDisplayList(p_dl[param_0->mDLType], sizeof(jpa_dl));
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
f32 sinRot = JMASSin(param_1->mRotateAngle);
f32 cosRot = JMASCos(param_1->mRotateAngle);
f32 particleX = param_0->mGlobalPtclScl.x * param_1->mParticleScaleX;
f32 particleY = param_0->mGlobalPtclScl.y * param_1->mParticleScaleY;
Mtx auStack_88;
p_rot[param_0->mRotType](sinRot, cosRot, auStack_88);
p_plane[param_0->mPlaneType](auStack_88, particleX, particleY);
auStack_88[0][3] = param_1->mPosition.x;
auStack_88[1][3] = param_1->mPosition.y;
auStack_88[2][3] = param_1->mPosition.z;
MTXConcat(param_0->mPosCamMtx, auStack_88, auStack_88);
GXLoadPosMtxImm(auStack_88, 0);
p_prj[param_0->mPrjType](param_0, auStack_88);
GXCallDisplayList(p_dl[param_0->mDLType], sizeof(jpa_dl));
}
void JPADrawPoint(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
if (!!(ptcl->mStatus & JPAPtclStts_Invisible))
if (ptcl->checkStatus(JPAPtclStts_Invisible)) {
return;
}
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
@@ -851,26 +846,30 @@ void JPADrawPoint(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
}
void JPADrawLine(JPAEmitterWorkData* param_0, JPABaseParticle* param_1) {
if (param_1->checkStatus(8) == 0) {
JGeometry::TVec3<f32> local_1c;
JGeometry::setTVec3f(&param_1->mPosition.x, &local_1c.x);
JGeometry::TVec3<f32> local_28;
param_1->getVelVec(local_28);
if (!local_28.isZero()) {
local_28.setLength(param_0->mGlobalPtclScl.y * (25.0f * param_1->mParticleScaleY));
local_28.sub(local_1c, local_28);
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GXBegin(GX_LINES, GX_VTXFMT1, 2);
GXPosition3f32(local_1c.x, local_1c.y, local_1c.z);
GXTexCoord2f32(0.0f, 0.0f);
GXPosition3f32(local_28.x, local_28.y, local_28.z);
GXTexCoord2f32(0.0f, 1.0f);
GXEnd();
GXSetVtxDesc(GX_VA_POS, GX_INDEX8);
GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8);
}
if (param_1->checkStatus(JPAPtclStts_Invisible)) {
return;
}
JGeometry::TVec3<f32> local_1c(param_1->mPosition);
JGeometry::TVec3<f32> local_28;
param_1->getVelVec(&local_28);
if (local_28.isZero()) {
return;
}
local_28.setLength(param_0->mGlobalPtclScl.y * (25.0f * param_1->mParticleScaleY));
local_28.sub(local_1c, local_28);
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GXBegin(GX_LINES, GX_VTXFMT1, 2);
GXPosition3f32(local_1c.x, local_1c.y, local_1c.z);
GXTexCoord2f32(0.0f, 0.0f);
GXPosition3f32(local_28.x, local_28.y, local_28.z);
GXTexCoord2f32(0.0f, 1.0f);
GXEnd();
GXSetVtxDesc(GX_VA_POS, GX_INDEX8);
GXSetVtxDesc(GX_VA_TEX0, GX_INDEX8);
}
JPANode<JPABaseParticle>* getNext(JPANode<JPABaseParticle>* param_0) {
@@ -901,8 +900,8 @@ void JPADrawStripe(JPAEmitterWorkData* param_0) {
JGeometry::TVec3<f32> local_e0[2];
JGeometry::TVec3<f32> local_f8;
JGeometry::TVec3<f32> local_104;
getNodeFunc node_func;
JPANode<JPABaseParticle>* startNode;
JPANode<JPABaseParticle>* startNode = NULL;
getNodeFunc node_func = NULL;
if (shape->isDrawFwdAhead()) {
startNode = param_0->mpAlivePtcl->getLast();
node_func = getPrev;
@@ -990,8 +989,8 @@ void JPADrawStripeX(JPAEmitterWorkData* param_0) {
JGeometry::TVec3<f32> local_a8[2];
JGeometry::TVec3<f32> local_c0;
JGeometry::TVec3<f32> local_cc;
JPANode<JPABaseParticle>* startNode;
getNodeFunc node_func;
JPANode<JPABaseParticle>* startNode = NULL;
getNodeFunc node_func = NULL;
if (shape->isDrawFwdAhead()) {
startNode = param_0->mpAlivePtcl->getLast();
node_func = getPrev;
@@ -1109,22 +1108,27 @@ void JPADrawStripeX(JPAEmitterWorkData* param_0) {
}
void JPADrawEmitterCallBackB(JPAEmitterWorkData* work) {
if (work->mpEmtr->mpEmtrCallBack == NULL)
JPABaseEmitter* emtr = work->mpEmtr;
if (emtr->mpEmtrCallBack == NULL) {
return;
}
work->mpEmtr->mpEmtrCallBack->draw(work->mpEmtr);
emtr->mpEmtrCallBack->draw(emtr);
}
void JPADrawParticleCallBack(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
if (work->mpEmtr->mpPtclCallBack == NULL)
JPABaseEmitter* emtr = work->mpEmtr;
if (emtr->mpPtclCallBack == NULL) {
return;
}
work->mpEmtr->mpPtclCallBack->draw(work->mpEmtr, ptcl);
emtr->mpPtclCallBack->draw(emtr, ptcl);
}
static void makeColorTable(GXColor** o_color_table, JPAClrAnmKeyData const* i_data, u8 param_2,
s16 i_size, JKRHeap* i_heap) {
GXColor* color_table = (GXColor*)JKRAllocFromHeap(i_heap, (i_size + 1) * 4, 4);
GXColor* p_clr_tbl = (GXColor*)JKRAllocFromHeap(i_heap, (i_size + 1) * 4, 4);
JUT_ASSERT(1548, p_clr_tbl);
f32 r_step, g_step, b_step, a_step;
r_step = g_step = b_step = a_step = 0.0f;
f32 r = i_data[0].color.r;
@@ -1134,7 +1138,7 @@ static void makeColorTable(GXColor** o_color_table, JPAClrAnmKeyData const* i_da
int j = 0;
for (s16 i = 0; i < i_size + 1; i++) {
if (i == i_data[j].index) {
color_table[i] = i_data[j].color;
p_clr_tbl[i] = i_data[j].color;
r = i_data[j].color.r;
g = i_data[j].color.g;
b = i_data[j].color.b;
@@ -1151,49 +1155,16 @@ static void makeColorTable(GXColor** o_color_table, JPAClrAnmKeyData const* i_da
}
} else {
r += r_step;
color_table[i].r = r;
p_clr_tbl[i].r = r;
g += g_step;
color_table[i].g = g;
p_clr_tbl[i].g = g;
b += b_step;
color_table[i].b = b;
p_clr_tbl[i].b = b;
a += a_step;
color_table[i].a = a;
p_clr_tbl[i].a = a;
}
}
*o_color_table = color_table;
}
JPABaseShape::JPABaseShape(u8 const* pData, JKRHeap* pHeap) {
mpData = (const JPABaseShapeData*)pData;
if (isTexCrdAnm()) {
mpTexCrdMtxAnmTbl = (const void*)(pData + sizeof(JPABaseShapeData));
} else {
mpTexCrdMtxAnmTbl = NULL;
}
if (isTexAnm()) {
u32 offs = sizeof(JPABaseShapeData);
if (isTexCrdAnm())
offs = sizeof(JPABaseShapeData) + 0x28;
mpTexIdxAnimTbl = (const u8*)(pData + offs);
} else {
mpTexIdxAnimTbl = NULL;
}
if (isPrmAnm()) {
makeColorTable(&mpPrmClrAnmTbl, (JPAClrAnmKeyData*)(pData + mpData->mClrPrmAnmOffset),
mpData->mClrPrmKeyNum, mpData->mClrAnmFrmMax, pHeap);
} else {
mpPrmClrAnmTbl = NULL;
}
if (isEnvAnm()) {
makeColorTable(&mpEnvClrAnmTbl, (JPAClrAnmKeyData*)(pData + mpData->mClrEnvAnmOffset),
mpData->mClrEnvKeyNum, mpData->mClrAnmFrmMax, pHeap);
} else {
mpEnvClrAnmTbl = NULL;
}
*o_color_table = p_clr_tbl;
}
GXBlendMode JPABaseShape::st_bm[3] = {
@@ -1279,15 +1250,55 @@ GXTevAlphaArg JPABaseShape::st_aa[2][4] = {
},
};
JPABaseShape::JPABaseShape(u8 const* pData, JKRHeap* pHeap) {
pBsd = (const JPABaseShapeData*)pData;
if (isTexCrdAnm()) {
mpTexCrdMtxAnmTbl = (const void*)(pData + sizeof(JPABaseShapeData));
} else {
mpTexCrdMtxAnmTbl = NULL;
}
if (isTexAnm()) {
JUT_ASSERT(1698, pBsd->texAnmKeyNum != NULL);
u32 offs = sizeof(JPABaseShapeData);
if (isTexCrdAnm()) {
offs += 0x28;
}
mpTexIdxAnimTbl = (const u8*)(pData + offs);
} else {
mpTexIdxAnimTbl = NULL;
}
if (isPrmAnm()) {
JUT_ASSERT(1707, pBsd->prmAnmKeyNum != NULL);
JPAClrAnmKeyData* anmKeyData = (JPAClrAnmKeyData*)(pData + pBsd->mClrPrmAnmOffset);
makeColorTable(&mpPrmClrAnmTbl, anmKeyData,
pBsd->prmAnmKeyNum, pBsd->mClrAnmFrmMax, pHeap);
} else {
mpPrmClrAnmTbl = NULL;
}
if (isEnvAnm()) {
JUT_ASSERT(1716, pBsd->envAnmKeyNum != NULL);
JPAClrAnmKeyData* anmKeyData = (JPAClrAnmKeyData*)(pData + pBsd->mClrEnvAnmOffset);
makeColorTable(&mpEnvClrAnmTbl, anmKeyData,
pBsd->envAnmKeyNum, pBsd->mClrAnmFrmMax, pHeap);
} else {
mpEnvClrAnmTbl = NULL;
}
}
void JPABaseShape::setGX(JPAEmitterWorkData* work) const {
const GXTevColorArg* colorArg = getTevColorArg();
const GXTevAlphaArg* alphaArg = getTevAlphaArg();
GXSetBlendMode(getBlendMode(), getBlendSrc(), getBlendDst(), getLogicOp());
GXSetZMode(getZEnable(), getZCmp(), getZUpd());
GXSetAlphaCompare(getAlphaCmp0(), getAlphaRef0(), getAlphaOp(), getAlphaCmp1(), getAlphaRef1());
JPAExtraShape* extraShape = work->mpRes->getEsp();
const GXTevColorArg* colorArg = st_ca[(pBsd->mFlags >> 0x0F) & 0x07];
const GXTevAlphaArg* alphaArg = st_aa[(pBsd->mFlags >> 0x12) & 0x01];
GXSetBlendMode(st_bm[pBsd->mBlendModeCfg & 0x03], st_bf[(pBsd->mBlendModeCfg >> 2) & 0x0F], st_bf[(pBsd->mBlendModeCfg >> 6) & 0x0F], st_lo[(pBsd->mBlendModeCfg >> 10) & 0x0F]);
GXSetZMode(pBsd->mZModeCfg & 0x01, st_c[(pBsd->mZModeCfg >> 1) & 0x07], (pBsd->mZModeCfg >> 4) & 0x01);
GXSetAlphaCompare(st_c[pBsd->mAlphaCompareCfg & 0x07], pBsd->mAlphaRef0, st_ao[(pBsd->mAlphaCompareCfg >> 3) & 0x03], st_c[(pBsd->mAlphaCompareCfg >> 5) & 0x07], pBsd->mAlphaRef1);
GXSetTevColorIn(GX_TEVSTAGE0, colorArg[0], colorArg[1], colorArg[2], colorArg[3]);
GXSetTevAlphaIn(GX_TEVSTAGE0, alphaArg[0], alphaArg[1], alphaArg[2], alphaArg[3]);
GXSetTevDirect(GX_TEVSTAGE0);
GXSetTevDirect(GX_TEVSTAGE1);
GXSetZCompLoc(getZCompLoc());
GXSetZCompLoc((pBsd->mZModeCfg >> 5) & 0x01);
}
+22 -32
View File
@@ -63,11 +63,11 @@ void JPAVolumeCube(JPAEmitterWorkData* work) {
}
static void JPAVolumeSphere(JPAEmitterWorkData* work) {
s16 phi, theta;
s16 phi, r28;
if (work->mpEmtr->checkFlag(JPADynFlag_FixedInterval)) {
phi = (u16)(work->mVolumeX * 0x8000 / (work->mDivNumber - 1) + 0x4000);
f32 tmp = (u16)(work->mVolumeAngleNum * 0x10000 / (work->mVolumeAngleMax - 1));
theta = tmp * work->mVolumeSweep + 0x8000;
phi = u16(work->mVolumeX * 0x8000 / (work->mDivNumber - 1) + 0x4000);
u16 r26 = u16(work->mVolumeAngleNum * 0x10000 / (work->mVolumeAngleMax - 1));
r28 = f32(r26) * work->mVolumeSweep + 0x8000;
work->mVolumeAngleNum++;
if (work->mVolumeAngleNum == work->mVolumeAngleMax) {
work->mVolumeAngleNum = 0;
@@ -81,30 +81,30 @@ static void JPAVolumeSphere(JPAEmitterWorkData* work) {
}
} else {
phi = work->mpEmtr->get_r_ss() >> 1;
theta = work->mVolumeSweep * work->mpEmtr->get_r_ss();
r28 = work->mVolumeSweep * work->mpEmtr->get_r_ss();
}
f32 rnd = work->mpEmtr->get_r_f();
f32 f31 = work->mpEmtr->get_r_f();
if (work->mpEmtr->checkFlag(JPADynFlag_FixedDensity)) {
rnd = 1.0f - rnd * rnd * rnd;
f31 = 1.0f - f31 * f31 * f31;
}
f32 rad = work->mVolumeSize * (work->mVolumeMinRad + rnd * (1.0f - work->mVolumeMinRad));
work->mVolumeCalcData.mVolumePos.set(rad * JMASCos(phi) * JMASSin(theta), -rad * JMASSin(phi),
rad * JMASCos(phi) * JMASCos(theta));
f31 = work->mVolumeSize * (work->mVolumeMinRad + f31 * (1.0f - work->mVolumeMinRad));
work->mVolumeCalcData.mVolumePos.set(f31 * JMASCos(phi) * JMASSin(r28), -f31 * JMASSin(phi),
f31 * JMASCos(phi) * JMASCos(r28));
work->mVolumeCalcData.mVelOmni.mul(work->mVolumeCalcData.mVolumePos, work->mGlobalScl);
work->mVolumeCalcData.mVelAxis.set(work->mVolumeCalcData.mVolumePos.x, 0.0f,
work->mVolumeCalcData.mVolumePos.z);
}
static void JPAVolumeCylinder(JPAEmitterWorkData* work) {
s16 theta = work->mVolumeSweep * work->mpEmtr->get_r_ss();
f32 rnd = work->mpEmtr->get_r_f();
s16 r30 = work->mVolumeSweep * work->mpEmtr->get_r_ss();
f32 f31 = work->mpEmtr->get_r_f();
if (work->mpEmtr->checkFlag(JPADynFlag_FixedDensity)) {
rnd = 1.0f - rnd * rnd;
f31 = 1.0f - f31 * f31;
}
f32 rad = work->mVolumeSize * (work->mVolumeMinRad + rnd * (1.0f - work->mVolumeMinRad));
f31 = work->mVolumeSize * (work->mVolumeMinRad + f31 * (1.0f - work->mVolumeMinRad));
work->mVolumeCalcData.mVolumePos.set(
rad * JMASSin(theta), work->mVolumeSize * work->mpEmtr->get_r_zp(), rad * JMASCos(theta));
f31 * JMASSin(r30), work->mVolumeSize * work->mpEmtr->get_r_zp(), f31 * JMASCos(r30));
work->mVolumeCalcData.mVelOmni.mul(work->mVolumeCalcData.mVolumePos, work->mGlobalScl);
work->mVolumeCalcData.mVelAxis.set(work->mVolumeCalcData.mVolumePos.x, 0.0f,
work->mVolumeCalcData.mVolumePos.z);
@@ -166,26 +166,16 @@ void JPADynamicsBlock::init() {
void JPADynamicsBlock::create(JPAEmitterWorkData* work) {
if (work->mpEmtr->checkStatus(JPAEmtrStts_RateStepEmit)) {
s32 emitCount;
s32 createCount;
s32 emitCount = 0;
// Probably an inlined function.
if (work->mpEmtr->checkFlag(JPADynFlag_FixedInterval)) {
s32 count;
if (getVolumeType() == VOL_Sphere) {
count = 4 * getDivNumber() * getDivNumber() + 2;
} else {
count = getDivNumber();
}
emitCount = count;
emitCount = getVolumeType() == VOL_Sphere ? 4 * getDivNumber() * getDivNumber() + 2 : getDivNumber();
work->mVolumeEmitIdx = 0;
} else {
f32 newPtclCount =
work->mpEmtr->mRate * (getRateRndm() * work->mpEmtr->get_r_zp() + 1.0f);
f32 newEmitCount = work->mpEmtr->mEmitCount + newPtclCount;
work->mpEmtr->mEmitCount = newEmitCount;
emitCount = (s32)newEmitCount;
emitCount = work->mpEmtr->mEmitCount += newPtclCount;
work->mpEmtr->mEmitCount -= emitCount;
if (work->mpEmtr->checkStatus(JPAEmtrStts_FirstEmit) && 0.0f < newPtclCount &&
@@ -198,10 +188,10 @@ void JPADynamicsBlock::create(JPAEmitterWorkData* work) {
emitCount = 0;
}
// Probably an inlined function.
createCount = emitCount;
JPABaseParticle* ptcl = NULL;
s32 createCount = emitCount;
while (createCount > 0) {
JPABaseParticle* ptcl = work->mpEmtr->createParticle();
ptcl = work->mpEmtr->createParticle();
if (ptcl == NULL)
break;
createCount--;
@@ -209,7 +199,7 @@ void JPADynamicsBlock::create(JPAEmitterWorkData* work) {
}
if (++work->mpEmtr->mRateStepTimer >= (work->mpEmtr->mRateStep + 1)) {
work->mpEmtr->mRateStepTimer -= (work->mpEmtr->mRateStep + 1);
work->mpEmtr->mRateStepTimer -= work->mpEmtr->mRateStep + 1;
work->mpEmtr->setStatus(JPAEmtrStts_RateStepEmit);
} else {
work->mpEmtr->clearStatus(JPAEmtrStts_RateStepEmit);
+36 -40
View File
@@ -12,38 +12,31 @@ JPAEmitterCallBack::~JPAEmitterCallBack() {
void JPABaseEmitter::init(JPAEmitterManager* param_0, JPAResource* param_1) {
mpEmtrMgr = param_0;
mpRes = param_1;
mpRes->getDyn()->getEmitterScl(&mLocalScl);
mpRes->getDyn()->getEmitterTrs(&mLocalTrs);
mpRes->getDyn()->getEmitterDir(&mLocalDir);
pRes = param_1;
pRes->getDyn()->getEmitterScl(&mLocalScl);
pRes->getDyn()->getEmitterTrs(&mLocalTrs);
pRes->getDyn()->getEmitterDir(&mLocalDir);
mLocalDir.normalize();
mpRes->getDyn()->getEmitterRot(&mLocalRot);
mMaxFrame = mpRes->getDyn()->getMaxFrame();
mLifeTime = mpRes->getDyn()->getLifetime();
mVolumeSize = mpRes->getDyn()->getVolumeSize();
mRate = mpRes->getDyn()->getRate();
mRateStep = mpRes->getDyn()->getRateStep();
mVolumeSweep = mpRes->getDyn()->getVolumeSweep();
mVolumeMinRad = mpRes->getDyn()->getVolumeMinRad();
mAwayFromCenterSpeed = mpRes->getDyn()->getInitVelOmni();
mAwayFromAxisSpeed = mpRes->getDyn()->getInitVelAxis();
mDirSpeed = mpRes->getDyn()->getInitVelDir();
mSpread = mpRes->getDyn()->getInitVelDirSp();
mRndmDirSpeed = mpRes->getDyn()->getInitVelRndm();
mAirResist = mpRes->getDyn()->getAirRes();
pRes->getDyn()->getEmitterRot(&mLocalRot);
mMaxFrame = pRes->getDyn()->getMaxFrame();
mLifeTime = pRes->getDyn()->getLifetime();
mVolumeSize = pRes->getDyn()->getVolumeSize();
mRate = pRes->getDyn()->getRate();
mRateStep = pRes->getDyn()->getRateStep();
mVolumeSweep = pRes->getDyn()->getVolumeSweep();
mVolumeMinRad = pRes->getDyn()->getVolumeMinRad();
mAwayFromCenterSpeed = pRes->getDyn()->getInitVelOmni();
mAwayFromAxisSpeed = pRes->getDyn()->getInitVelAxis();
mDirSpeed = pRes->getDyn()->getInitVelDir();
mSpread = pRes->getDyn()->getInitVelDirSp();
mRndmDirSpeed = pRes->getDyn()->getInitVelRndm();
mAirResist = pRes->getDyn()->getAirRes();
mRndm.set_seed(mpEmtrMgr->pWd->mRndm.get_rndm_u());
MTXIdentity(mGlobalRot);
mGlobalScl.set(1.0f, 1.0f, 1.0f);
mGlobalTrs.zero();
mGlobalPScl.set(1.0f, 1.0f);
mGlobalEnvClr.a = 0xff;
mGlobalEnvClr.b = 0xff;
mGlobalEnvClr.g = 0xff;
mGlobalEnvClr.r = 0xff;
mGlobalPrmClr.a = 0xff;
mGlobalPrmClr.b = 0xff;
mGlobalPrmClr.g = 0xff;
mGlobalPrmClr.r = 0xff;
mGlobalPrmClr.r = mGlobalPrmClr.g = mGlobalPrmClr.b = mGlobalPrmClr.a = mGlobalEnvClr.r = mGlobalEnvClr.g = mGlobalEnvClr.b = mGlobalEnvClr.a = 0xff;
param_1->getBsp()->getPrmClr(&mPrmClr);
param_1->getBsp()->getEnvClr(&mEnvClr);
mpUserWork = NULL;
@@ -61,9 +54,11 @@ JPABaseParticle* JPABaseEmitter::createParticle() {
if (mpPtclPool->getNum() != 0) {
JPANode<JPABaseParticle>* node = mpPtclPool->pop_front();
mAlivePtclBase.push_front(node);
mpRes->getDyn()->calc(mpEmtrMgr->pWd);
node->mData.init_p(mpEmtrMgr->pWd);
return &node->mData;
pRes->getDyn()->calc(mpEmtrMgr->pWd);
node->getObject()->init_p(mpEmtrMgr->pWd);
return node->getObject();
} else {
JUT_WARN(128, "%s", "JPA : Can NOT create particle more\n");
}
return NULL;
@@ -73,8 +68,10 @@ JPABaseParticle* JPABaseEmitter::createChild(JPABaseParticle* parent) {
if (mpPtclPool->getNum() != 0) {
JPANode<JPABaseParticle>* node = mpPtclPool->pop_front();
mAlivePtclChld.push_front(node);
node->mData.init_c(mpEmtrMgr->pWd, parent);
return &node->mData;
node->getObject()->init_c(mpEmtrMgr->pWd, parent);
return node->getObject();
} else {
JUT_WARN(151, "%s", "JPA : Can NOT create child particle more\n")
}
return NULL;
@@ -88,14 +85,12 @@ void JPABaseEmitter::deleteAllParticle() {
}
bool JPABaseEmitter::processTillStartFrame() {
JPADynamicsBlock* dyn = mpRes->getDyn();
s16 startFrame = dyn->getStartFrame();
if (mWaitTime >= startFrame)
if (mWaitTime >= pRes->getDyn()->getStartFrame())
return true;
if (!(mStatus & 2))
if (!checkStatus(2)) {
mWaitTime++;
}
return false;
}
@@ -111,7 +106,7 @@ bool JPABaseEmitter::processTermination() {
if (mMaxFrame < 0) {
setStatus(8);
return getParticleNumber() == 0;
}
}
if (mTick >= mMaxFrame) {
setStatus(8);
if (checkStatus(0x40)) {
@@ -129,7 +124,7 @@ void JPABaseEmitter::calcEmitterGlobalPosition(JGeometry::TVec3<f32>* dst) const
mtx[0][3] = mGlobalTrs.x;
mtx[1][3] = mGlobalTrs.y;
mtx[2][3] = mGlobalTrs.z;
MTXMultVec(mtx, mLocalTrs, *dst);
MTXMultVec(mtx, &mLocalTrs, dst);
}
u32 JPABaseEmitter::getCurrentCreateNumber() const {
@@ -140,7 +135,8 @@ u8 JPABaseEmitter::getDrawCount() const {
return mpEmtrMgr->pWd->mDrawCount;
}
bool JPABaseEmitter::loadTexture(u8 idx, GXTexMapID texMapID) {
mpEmtrMgr->pWd->mpResMgr->load(mpRes->getTexIdx(idx), texMapID);
bool JPABaseEmitter::loadTexture(u8 no, GXTexMapID texMapID) {
JUT_ASSERT(286, pRes->texNum > no);
mpEmtrMgr->pWd->mpResMgr->load(pRes->getTexIdx(no), texMapID);
return true;
}
+2 -2
View File
@@ -79,7 +79,7 @@ void JPAEmitterManager::calc(u8 group_id) {
JPABaseEmitter* emtr = pLink->getObject();
if (emtr->mpRes->calc(pWd, emtr) && !emtr->checkStatus(0x200))
if (emtr->pRes->calc(pWd, emtr) && !emtr->checkStatus(0x200))
forceDeleteEmitter(emtr);
}
}
@@ -115,7 +115,7 @@ void JPAEmitterManager::draw(JPADrawInfo const* drawInfo, u8 group_id) {
JPABaseEmitter* emtr = pLink->getObject();
if (!emtr->checkStatus(0x04)) {
pWd->mpResMgr = pResMgrAry[emtr->mResMgrID];
emtr->mpRes->draw(pWd, emtr);
emtr->pRes->draw(pWd, emtr);
}
}
}
+4 -8
View File
@@ -10,18 +10,14 @@ void JPALoadExTex(JPAEmitterWorkData* work) {
GXTexCoordID secTexCoordID = GX_TEXCOORD1;
if (ets->isUseIndirect()) {
GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE,
GX_PTIDENTITY);
u8 texIdx = ets->getIndTexIdx();
work->mpResMgr->load(work->mpRes->getTexIdx(texIdx), GX_TEXMAP2);
GXSetTexCoordGen(secTexCoordID, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
work->mpResMgr->load(work->mpRes->getTexIdx(ets->getIndTexIdx()), GX_TEXMAP2);
secTexCoordID = GX_TEXCOORD2;
}
if (ets->isUseSecTex()) {
GXSetTexCoordGen2(secTexCoordID, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE,
GX_PTIDENTITY);
u8 texIdx = ets->getSecTexIdx();
work->mpResMgr->load(work->mpRes->getTexIdx(texIdx), GX_TEXMAP3);
GXSetTexCoordGen(secTexCoordID, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
work->mpResMgr->load(work->mpRes->getTexIdx(ets->getSecTexIdx()), GX_TEXMAP3);
}
}
+7 -9
View File
@@ -35,7 +35,6 @@ void JPACalcScaleY(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
}
void JPACalcScaleCopy(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
JPAExtraShape* esp = work->mpRes->getEsp();
ptcl->mParticleScaleY = ptcl->mParticleScaleX;
}
@@ -55,21 +54,21 @@ void JPACalcScaleAnmRepeatY(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
void JPACalcScaleAnmReverseX(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
JPAExtraShape* esp = work->mpRes->getEsp();
s32 cycle = ptcl->mAge / esp->getScaleAnmCycleX();
f32 cycle = ptcl->mAge / esp->getScaleAnmCycleX() & 1;
f32 base = (ptcl->mAge % esp->getScaleAnmCycleX()) / (f32)esp->getScaleAnmCycleX();
work->mScaleAnm = base + ((cycle & 1) * (1.0f - base * 2.0f));
work->mScaleAnm = base + cycle * (1.0f - base * 2.0f);
}
void JPACalcScaleAnmReverseY(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
JPAExtraShape* esp = work->mpRes->getEsp();
s32 cycle = ptcl->mAge / esp->getScaleAnmCycleY();
f32 cycle = ptcl->mAge / esp->getScaleAnmCycleY() & 1;
f32 base = (ptcl->mAge % esp->getScaleAnmCycleY()) / (f32)esp->getScaleAnmCycleY();
work->mScaleAnm = base + ((cycle & 1) * (1.0f - base * 2.0f));
work->mScaleAnm = base + cycle * (1.0f - base * 2.0f);
}
void JPACalcAlphaAnm(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
JPAExtraShape* esp = work->mpRes->getEsp();
f32 alpha;
f32 alpha = 0.0f;
if (ptcl->mTime < esp->getAlphaInTiming()) {
alpha = 255.0f * (esp->getAlphaInValue() + esp->getAlphaIncRate() * ptcl->mTime);
} else if (ptcl->mTime > esp->getAlphaOutTiming()) {
@@ -83,7 +82,7 @@ void JPACalcAlphaAnm(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
void JPACalcAlphaFlickAnm(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
JPAExtraShape* esp = work->mpRes->getEsp();
f32 alpha;
f32 alpha = 0.0f;
if (ptcl->mTime < esp->getAlphaInTiming()) {
alpha = (esp->getAlphaInValue() + esp->getAlphaIncRate() * ptcl->mTime);
} else if (ptcl->mTime > esp->getAlphaOutTiming()) {
@@ -92,8 +91,7 @@ void JPACalcAlphaFlickAnm(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
} else {
alpha = esp->getAlphaBaseValue();
}
s32 theta = ptcl->mAlphaWaveRandom * ptcl->mAge * 16384.0f * (1.0f - esp->getAlphaFreq());
f32 wave = JMASSin(theta);
f32 wave = JMASSin(ptcl->mAlphaWaveRandom * ptcl->mAge * 16384.0f * (1.0f - esp->getAlphaFreq()));
alpha *= (1.0f + esp->getAlphaAmp() * (wave - 1.0f) * 0.5f) * 255.0f;
OSf32tou8(&alpha, &ptcl->mPrmColorAlphaAnm);
}
+14 -12
View File
@@ -57,7 +57,7 @@ void JPAFieldAir::prepare(JPAEmitterWorkData* work, JPAFieldBlock* block) {
if (block->checkStatus(2)) {
mAccel.scale(block->getMag(), vec);
} else {
MTXMultVecSR(work->mRotationMtx, vec, mAccel);
MTXMultVecSR(work->mRotationMtx, &vec, &mAccel);
mAccel.scale(block->getMag());
}
}
@@ -129,7 +129,7 @@ void JPAFieldConvection::prepare(JPAEmitterWorkData* work, JPAFieldBlock* block)
vec2.cross(block->getPos(), block->getDir());
vec1.cross(block->getDir(), vec2);
MTXMultVecSR(work->mGlobalRot, &vec1, &field_0x10);
MTXMultVecSR(work->mGlobalRot, &block->getDir(), field_0x1c);
MTXMultVecSR(work->mGlobalRot, &block->getDir(), &field_0x1c);
MTXMultVecSR(work->mGlobalRot, &vec2, &field_0x28);
field_0x10.normalize();
field_0x1c.normalize();
@@ -224,34 +224,36 @@ void JPAFieldBlock::init(JKRHeap* heap) {
switch (getType()) {
case FIELD_GRAVITY:
mpField = new (heap, 0) JPAFieldGravity();
pFld = new (heap, 0) JPAFieldGravity();
break;
case FIELD_AIR:
mpField = new (heap, 0) JPAFieldAir();
pFld = new (heap, 0) JPAFieldAir();
break;
case FIELD_MAGNET:
mpField = new (heap, 0) JPAFieldMagnet();
pFld = new (heap, 0) JPAFieldMagnet();
break;
case FIELD_NEWTON:
mpField = new (heap, 0) JPAFieldNewton();
pFld = new (heap, 0) JPAFieldNewton();
break;
case FIELD_VORTEX:
mpField = new (heap, 0) JPAFieldVortex();
pFld = new (heap, 0) JPAFieldVortex();
break;
case FIELD_RANDOM:
mpField = new (heap, 0) JPAFieldRandom();
pFld = new (heap, 0) JPAFieldRandom();
break;
case FIELD_DRAG:
mpField = new (heap, 0) JPAFieldDrag();
pFld = new (heap, 0) JPAFieldDrag();
break;
case FIELD_CONVECTION:
mpField = new (heap, 0) JPAFieldConvection();
pFld = new (heap, 0) JPAFieldConvection();
break;
case FIELD_SPIN:
mpField = new (heap, 0) JPAFieldSpin();
pFld = new (heap, 0) JPAFieldSpin();
break;
default:
mpField = NULL;
pFld = NULL;
JUT_WARN(483, "JPA : WRONG ID (%d) in field data\n", getType());
break;
}
JUT_ASSERT(485, pFld != 0);
}
+3 -3
View File
@@ -10,11 +10,11 @@ JPAKeyBlock::JPAKeyBlock(const u8* data)
}
f32 JPAKeyBlock::calc(float p1) {
if (mDataStart[0xB] != '\0') {
int v1 = (int)field_0x4[(mDataStart[9] - 1) * 4] + 1;
if (isLoop()) {
int v1 = (int)getKeyData()[(getKeyNum() - 1) * 4] + 1;
// p1 -= (v1 * ((int)p1 / v1));
int v2 = ((int)p1 / v1);
p1 = p1 - (v2 * v1);
}
return JPACalcKeyAnmValue(p1, mDataStart[9], field_0x4);
return JPACalcKeyAnmValue(p1, getKeyNum(), getKeyData());
}
+11 -17
View File
@@ -50,10 +50,7 @@ void JPAGetYZRotateMtx(s16 angleY, s16 angleZ, f32 (*param_2)[4]) {
param_2[1][2] = (siny * sinz);
param_2[2][0] = -siny;
param_2[2][2] = cosy;
param_2[2][3] = 0.0f;
param_2[2][1] = 0.0f;
param_2[1][3] = 0.0f;
param_2[0][3] = 0.0f;
param_2[0][3] = param_2[1][3] = param_2[2][1] = param_2[2][3] = 0.0f;
}
void JPAGetXYZRotateMtx(s16 x, s16 y, s16 z, Mtx mtx) {
@@ -68,17 +65,15 @@ void JPAGetXYZRotateMtx(s16 x, s16 y, s16 z, Mtx mtx) {
mtx[2][0] = -siny;
mtx[2][1] = sinx * cosy;
mtx[2][2] = cosx * cosy;
f32 cosxsinz = cosx * sinz;
f32 sinxcosz = sinx * cosz;
mtx[0][1] = sinxcosz * siny - cosxsinz;
mtx[1][2] = cosxsinz * siny - sinxcosz;
f32 sinxsinz = sinx * sinz;
f32 cosxcosz = cosx * cosz;
mtx[0][2] = sinxsinz + cosxcosz * siny;
mtx[1][1] = cosxcosz + sinxsinz * siny;
mtx[2][3] = 0.0f;
mtx[1][3] = 0.0f;
mtx[0][3] = 0.0f;
f32 f30 = cosx * sinz;
f32 f29 = sinx * cosz;
mtx[0][1] = f29 * siny - f30;
mtx[1][2] = f30 * siny - f29;
f30 = sinx * sinz;
f29 = cosx * cosz;
mtx[0][2] = f30 + f29 * siny;
mtx[1][1] = f29 + f30 * siny;
mtx[0][3] = mtx[1][3] = mtx[2][3] = 0.0f;
}
void JPASetRMtxTVecfromMtx(f32 const (*param_0)[4], f32 (*param_1)[4],
@@ -89,8 +84,7 @@ void JPASetRMtxTVecfromMtx(f32 const (*param_0)[4], f32 (*param_1)[4],
void JPASetRMtxSTVecfromMtx(f32 const (*param_0)[4], f32 (*param_1)[4],
JGeometry::TVec3<f32>* param_2, JGeometry::TVec3<f32>* param_3) {
JGeometry::TVec3<float> aTStack_54;
aTStack_54.set(param_0[0][0], param_0[1][0], param_0[2][0]);
JGeometry::TVec3<float> aTStack_54(param_0[0][0], param_0[1][0], param_0[2][0]);
param_2->x = aTStack_54.length();
aTStack_54.set(param_0[0][1], param_0[1][1], param_0[2][1]);
param_2->y = aTStack_54.length();
+143 -149
View File
@@ -15,32 +15,17 @@
#include "global.h"
JPAResource::JPAResource() {
mpDrawEmitterChildFuncList = NULL;
mpDrawEmitterFuncList = NULL;
mpCalcEmitterFuncList = NULL;
mpDrawParticleChildFuncList = NULL;
mpCalcParticleChildFuncList = NULL;
mpDrawParticleFuncList = NULL;
mpCalcParticleFuncList = NULL;
mpBaseShape = NULL;
mpExtraShape = NULL;
mpChildShape = NULL;
mpExTexShape = NULL;
mpDynamicsBlock = NULL;
mpFieldBlocks = NULL;
mpKeyBlocks = NULL;
mpCalcEmitterFuncList = mpDrawEmitterFuncList = mpDrawEmitterChildFuncList = NULL;
mpCalcParticleFuncList = mpDrawParticleFuncList = mpCalcParticleChildFuncList = mpDrawParticleChildFuncList = NULL;
pBsp = NULL;
pEsp = NULL;
pCsp = NULL;
pEts = NULL;
pDyn = NULL;
ppFld = NULL;
ppKey = NULL;
mpTDB1 = NULL;
mpDrawParticleChildFuncListNum = 0;
mpCalcParticleChildFuncListNum = 0;
mpDrawParticleFuncListNum = 0;
mpCalcParticleFuncListNum = 0;
mpDrawEmitterChildFuncListNum = 0;
mpDrawEmitterFuncListNum = 0;
mpCalcEmitterFuncListNum = 0;
mTDB1Num = 0;
mKeyBlockNum = 0;
mFieldBlockNum = 0;
mUsrIdx = 0;
mUsrIdx = fldNum = keyNum = texNum = mpCalcEmitterFuncListNum = mpDrawEmitterFuncListNum = mpDrawEmitterChildFuncListNum = mpCalcParticleFuncListNum = mpDrawParticleFuncListNum = mpCalcParticleChildFuncListNum = mpDrawParticleChildFuncListNum = 0;
}
static u8 jpa_pos[324] ATTRIBUTE_ALIGN(32) = {
@@ -73,30 +58,31 @@ static u8 jpa_crd[32] ATTRIBUTE_ALIGN(32) = {
};
void JPAResource::init(JKRHeap* heap) {
BOOL is_glbl_clr_anm = mpBaseShape->isGlblClrAnm();
BOOL is_glbl_tex_anm = mpBaseShape->isGlblTexAnm();
BOOL is_prm_anm = mpBaseShape->isPrmAnm();
BOOL is_env_anm = mpBaseShape->isEnvAnm();
BOOL is_tex_anm = mpBaseShape->isTexAnm();
BOOL is_tex_crd_anm = mpBaseShape->isTexCrdAnm();
BOOL is_prj_tex = mpBaseShape->isPrjTex();
BOOL is_enable_scale_anm = mpExtraShape != NULL && mpExtraShape->isEnableScaleAnm();
BOOL is_enable_alpha_anm = mpExtraShape != NULL && mpExtraShape->isEnableAlphaAnm();
BOOL is_enable_alpha_flick = mpExtraShape != NULL && mpExtraShape->isEnableAlphaAnm()
&& mpExtraShape->isEnableAlphaFlick();
BOOL is_enable_rotate_anm = mpExtraShape != NULL && mpExtraShape->isEnableRotateAnm();
BOOL is_glbl_clr_anm = pBsp->isGlblClrAnm();
BOOL is_glbl_tex_anm = pBsp->isGlblTexAnm();
BOOL is_prm_anm = pBsp->isPrmAnm();
BOOL is_env_anm = pBsp->isEnvAnm();
BOOL is_tex_anm = pBsp->isTexAnm();
BOOL is_tex_crd_anm = pBsp->isTexCrdAnm();
BOOL is_prj_tex = pBsp->isPrjTex();
BOOL is_enable_scale_anm = pEsp != NULL && pEsp->isEnableScaleAnm();
BOOL is_enable_alpha_anm = pEsp != NULL && pEsp->isEnableAlphaAnm();
BOOL is_enable_alpha_flick = pEsp != NULL && pEsp->isEnableAlphaAnm()
&& pEsp->isEnableAlphaFlick();
BOOL is_enable_rotate_anm = pEsp != NULL && pEsp->isEnableRotateAnm();
BOOL is_rotate_on = is_enable_rotate_anm
|| (mpChildShape != NULL && mpChildShape->isRotateOn());
BOOL base_type_5_6 = mpBaseShape->getType() == 5 || mpBaseShape->getType() == 6;
BOOL base_type_0 = mpBaseShape->getType() == 0;
BOOL base_type_0_1 = mpBaseShape->getType() == 0 || mpBaseShape->getType() == 1;
BOOL child_type_5_6 = mpChildShape != NULL
&& (mpChildShape->getType() == 5 || mpChildShape->getType() == 6);
BOOL child_type_0 = mpChildShape != NULL && mpChildShape->getType() == 0;
BOOL child_type_0_1 = mpChildShape != NULL
&& (mpChildShape->getType() == 0 || mpChildShape->getType() == 1);
BOOL is_draw_parent = !mpBaseShape->isNoDrawParent();
BOOL is_draw_child = !mpBaseShape->isNoDrawChild();
|| (pCsp != NULL && pCsp->isRotateOn());
BOOL base_type_5_6 = pBsp->getType() == 5 || pBsp->getType() == 6;
BOOL base_type_0 = pBsp->getType() == 0;
BOOL base_type_0_1 = pBsp->getType() == 0 || pBsp->getType() == 1;
BOOL child_type_5_6 = pCsp != NULL
&& (pCsp->getType() == 5 || pCsp->getType() == 6);
BOOL child_type_0 = pCsp != NULL && pCsp->getType() == 0;
BOOL child_type_0_1 = pCsp != NULL
&& (pCsp->getType() == 0 || pCsp->getType() == 1);
BOOL is_draw_parent = !pBsp->isNoDrawParent();
BOOL is_draw_child = !pBsp->isNoDrawChild();
int func_no = 0;
if (is_glbl_tex_anm && is_tex_anm) {
mpCalcEmitterFuncListNum++;
@@ -119,10 +105,10 @@ void JPAResource::init(JKRHeap* heap) {
(EmitterFunc*)JKRAllocFromHeap(heap, mpCalcEmitterFuncListNum * 4, 4);
}
int func_no = 0;
func_no = 0;
if (is_glbl_tex_anm && is_tex_anm) {
switch (mpBaseShape->getTexAnmType()) {
switch (pBsp->getTexAnmType()) {
case 0:
mpCalcEmitterFuncList[func_no] = &JPACalcTexIdxNormal;
break;
@@ -152,7 +138,7 @@ void JPAResource::init(JKRHeap* heap) {
func_no++;
}
if (is_prm_anm || is_env_anm) {
switch (mpBaseShape->getClrAnmType()) {
switch (pBsp->getClrAnmType()) {
case 0:
mpCalcEmitterFuncList[func_no] = &JPACalcClrIdxNormal;
break;
@@ -169,6 +155,7 @@ void JPAResource::init(JKRHeap* heap) {
mpCalcEmitterFuncList[func_no] = &JPACalcClrIdxRandom;
break;
}
func_no++;
}
}
@@ -195,9 +182,9 @@ void JPAResource::init(JKRHeap* heap) {
}
if (is_enable_scale_anm) {
if (mpBaseShape->getType() != 0) {
if (mpExtraShape->isScaleXYDiff()) {
if (mpExtraShape->getScaleAnmTypeX() == 0 && mpExtraShape->getScaleAnmTypeY() == 0) {
if (pBsp->getType() != 0) {
if (pEsp->isScaleXYDiff()) {
if (pEsp->getScaleAnmTypeX() == 0 && pEsp->getScaleAnmTypeY() == 0) {
mpCalcParticleFuncListNum++;
} else {
mpCalcParticleFuncListNum++;
@@ -219,7 +206,7 @@ void JPAResource::init(JKRHeap* heap) {
func_no = 0;
if (!is_glbl_tex_anm && is_tex_anm) {
switch (mpBaseShape->getTexAnmType()) {
switch (pBsp->getTexAnmType()) {
case 0:
mpCalcParticleFuncList[func_no] = &JPACalcTexIdxNormal;
break;
@@ -259,7 +246,7 @@ void JPAResource::init(JKRHeap* heap) {
func_no++;
}
if (is_prm_anm || is_env_anm) {
switch (mpBaseShape->getClrAnmType()) {
switch (pBsp->getClrAnmType()) {
case 0:
mpCalcParticleFuncList[func_no] = &JPACalcClrIdxNormal;
break;
@@ -284,12 +271,12 @@ void JPAResource::init(JKRHeap* heap) {
}
if (is_enable_scale_anm) {
if (mpBaseShape->getType() != 0) {
if (mpExtraShape->isScaleXYDiff()) {
if (pBsp->getType() != 0) {
if (pEsp->isScaleXYDiff()) {
mpCalcParticleFuncList[func_no] = &JPACalcScaleY;
func_no++;
if (mpExtraShape->getScaleAnmTypeY() != 0 || mpExtraShape->getScaleAnmTypeX() != 0) {
switch (mpExtraShape->getScaleAnmTypeY()) {
if (pEsp->getScaleAnmTypeY() != 0 || pEsp->getScaleAnmTypeX() != 0) {
switch (pEsp->getScaleAnmTypeY()) {
case 0:
mpCalcParticleFuncList[func_no] = &JPACalcScaleAnmNormal;
break;
@@ -309,7 +296,7 @@ void JPAResource::init(JKRHeap* heap) {
}
mpCalcParticleFuncList[func_no] = &JPACalcScaleX;
func_no++;
switch (mpExtraShape->getScaleAnmTypeX()) {
switch (pEsp->getScaleAnmTypeX()) {
case 0:
mpCalcParticleFuncList[func_no] = &JPACalcScaleAnmNormal;
break;
@@ -320,13 +307,14 @@ void JPAResource::init(JKRHeap* heap) {
mpCalcParticleFuncList[func_no] = &JPACalcScaleAnmReverseX;
break;
}
func_no++;
}
if (mpChildShape != NULL && mpChildShape->isScaleOutOn()) {
if (pCsp != NULL && pCsp->isScaleOutOn()) {
mpCalcParticleChildFuncListNum++;
}
if (mpChildShape != NULL && mpChildShape->isAlphaOutOn()) {
if (pCsp != NULL && pCsp->isAlphaOutOn()) {
mpCalcParticleChildFuncListNum++;
}
@@ -337,13 +325,14 @@ void JPAResource::init(JKRHeap* heap) {
func_no = 0;
if (mpChildShape != NULL && mpChildShape->isScaleOutOn()) {
if (pCsp != NULL && pCsp->isScaleOutOn()) {
mpCalcParticleChildFuncList[func_no] = &JPACalcChildScaleOut;
func_no++;
}
if (mpChildShape != NULL && mpChildShape->isAlphaOutOn()) {
if (pCsp != NULL && pCsp->isAlphaOutOn()) {
mpCalcParticleChildFuncList[func_no] = &JPACalcChildAlphaOut;
func_no++;
}
if (is_draw_parent && base_type_5_6) {
@@ -352,7 +341,7 @@ void JPAResource::init(JKRHeap* heap) {
mpDrawEmitterFuncListNum++;
if (mpExTexShape != NULL) {
if (pEts != NULL) {
mpDrawEmitterFuncListNum++;
}
@@ -382,7 +371,7 @@ void JPAResource::init(JKRHeap* heap) {
func_no = 0;
if (is_draw_parent && base_type_5_6) {
if (mpBaseShape->getType() == 5) {
if (pBsp->getType() == 5) {
mpDrawEmitterFuncList[func_no] = &JPADrawStripe;
func_no++;
} else {
@@ -394,7 +383,7 @@ void JPAResource::init(JKRHeap* heap) {
mpDrawEmitterFuncList[func_no] = &JPADrawEmitterCallBackB;
func_no++;
if (mpExTexShape != NULL) {
if (pEts != NULL) {
mpDrawEmitterFuncList[func_no] = &JPALoadExTex;
func_no++;
}
@@ -444,17 +433,22 @@ void JPAResource::init(JKRHeap* heap) {
if (is_glbl_clr_anm) {
if (base_type_5_6 || !is_enable_alpha_anm) {
mpDrawEmitterFuncList[func_no] = &JPARegistPrmEnv;
func_no++;
} else if (is_enable_alpha_anm) {
mpDrawEmitterFuncList[func_no] = &JPARegistEnv;
func_no++;
}
} else if (!is_prm_anm && !is_enable_alpha_anm) {
if (!is_env_anm) {
mpDrawEmitterFuncList[func_no] = &JPARegistPrmEnv;
func_no++;
} else {
mpDrawEmitterFuncList[func_no] = &JPARegistPrm;
func_no++;
}
} else if (!is_env_anm) {
mpDrawEmitterFuncList[func_no] = &JPARegistEnv;
func_no++;
}
if (is_draw_child && child_type_5_6) {
@@ -467,8 +461,8 @@ void JPAResource::init(JKRHeap* heap) {
mpDrawEmitterChildFuncListNum++;
}
if (mpChildShape != NULL && !mpChildShape->isAlphaOutOn() && !mpChildShape->isAlphaInherited()
&& !mpChildShape->isColorInherited()) {
if (pCsp != NULL && !pCsp->isAlphaOutOn() && !pCsp->isAlphaInherited()
&& !pCsp->isColorInherited()) {
mpDrawEmitterChildFuncListNum++;
}
@@ -480,7 +474,7 @@ void JPAResource::init(JKRHeap* heap) {
func_no = 0;
if (is_draw_child && child_type_5_6) {
if (mpChildShape->getType() == 5) {
if (pCsp->getType() == 5) {
mpDrawEmitterChildFuncList[func_no] = &JPADrawStripe;
func_no++;
} else {
@@ -497,9 +491,10 @@ void JPAResource::init(JKRHeap* heap) {
func_no++;
}
if (mpChildShape != NULL && !mpChildShape->isAlphaOutOn() && !mpChildShape->isAlphaInherited()
&& !mpChildShape->isColorInherited()) {
if (pCsp != NULL && !pCsp->isAlphaOutOn() && !pCsp->isAlphaInherited()
&& !pCsp->isColorInherited()) {
mpDrawEmitterChildFuncList[func_no] = &JPARegistChildPrmEnv;
func_no++;
}
if (is_draw_parent && !base_type_5_6) {
@@ -529,7 +524,7 @@ void JPAResource::init(JKRHeap* heap) {
func_no = 0;
if (is_draw_parent && !base_type_5_6) {
switch (mpBaseShape->getType()) {
switch (pBsp->getType()) {
case 2:
if (is_enable_rotate_anm) {
mpDrawParticleFuncList[func_no] = &JPADrawRotBillboard;
@@ -594,23 +589,29 @@ void JPAResource::init(JKRHeap* heap) {
if (is_prm_anm) {
if (is_env_anm) {
mpDrawParticleFuncList[func_no] = &JPARegistPrmAlphaEnv;
func_no++;
} else {
mpDrawParticleFuncList[func_no] = &JPARegistPrmAlpha;
func_no++;
}
} else if (is_enable_alpha_anm) {
if (is_env_anm) {
mpDrawParticleFuncList[func_no] = &JPARegistAlphaEnv;
func_no++;
} else {
mpDrawParticleFuncList[func_no] = &JPARegistAlpha;
func_no++;
}
} else if (is_env_anm) {
mpDrawParticleFuncList[func_no] = &JPARegistEnv;
func_no++;
}
} else if (is_enable_alpha_anm && !base_type_5_6) {
mpDrawParticleFuncList[func_no] = &JPARegistAlpha;
func_no++;
}
if (is_draw_child && mpChildShape != NULL && !child_type_5_6) {
if (is_draw_child && pCsp != NULL && !child_type_5_6) {
mpDrawParticleChildFuncListNum++;
}
@@ -620,8 +621,8 @@ void JPAResource::init(JKRHeap* heap) {
mpDrawParticleChildFuncListNum++;
}
if (mpChildShape != NULL && (mpChildShape->isAlphaOutOn() || mpChildShape->isAlphaInherited()
|| mpChildShape->isColorInherited())) {
if (pCsp != NULL && (pCsp->isAlphaOutOn() || pCsp->isAlphaInherited()
|| pCsp->isColorInherited())) {
mpDrawParticleChildFuncListNum++;
}
@@ -632,8 +633,8 @@ void JPAResource::init(JKRHeap* heap) {
func_no = 0;
if (is_draw_child && mpChildShape != NULL && !child_type_5_6) {
switch (mpChildShape->getType()) {
if (is_draw_child && pCsp != NULL && !child_type_5_6) {
switch (pCsp->getType()) {
case 2:
if (is_rotate_on) {
mpDrawParticleChildFuncList[func_no] = &JPADrawRotBillboard;
@@ -686,9 +687,10 @@ void JPAResource::init(JKRHeap* heap) {
}
}
if (mpChildShape != NULL && (mpChildShape->isAlphaOutOn() || mpChildShape->isAlphaInherited()
|| mpChildShape->isColorInherited())) {
if (pCsp != NULL && (pCsp->isAlphaOutOn() || pCsp->isAlphaInherited()
|| pCsp->isColorInherited())) {
mpDrawParticleChildFuncList[func_no] = &JPARegistPrmAlphaEnv;
func_no++;
}
}
@@ -720,8 +722,8 @@ bool JPAResource::calc(JPAEmitterWorkData* work, JPABaseEmitter* emtr) {
} else {
calcKey(work);
for (int i = mFieldBlockNum - 1; i >= 0; i--) {
mpFieldBlocks[i]->initOpParam();
for (int i = fldNum - 1; i >= 0; i--) {
ppFld[i]->initOpParam();
}
if (emtr->mpEmtrCallBack != NULL) {
@@ -737,12 +739,12 @@ bool JPAResource::calc(JPAEmitterWorkData* work, JPABaseEmitter* emtr) {
(*mpCalcEmitterFuncList[i])(work);
}
for (int i = mFieldBlockNum - 1; i >= 0; i--) {
mpFieldBlocks[i]->prepare(work);
for (int i = fldNum - 1; i >= 0; i--) {
ppFld[i]->prepare(work);
}
if (!emtr->checkStatus(8)) {
mpDynamicsBlock->create(work);
pDyn->create(work);
}
if (emtr->mpEmtrCallBack != NULL) {
@@ -752,23 +754,19 @@ bool JPAResource::calc(JPAEmitterWorkData* work, JPABaseEmitter* emtr) {
}
}
JPANode<JPABaseParticle>* node = emtr->mAlivePtclBase.getFirst();
JPANode<JPABaseParticle>* next;
while (node != emtr->mAlivePtclBase.getEnd()) {
JPANode<JPABaseParticle>* next = NULL;
for (JPANode<JPABaseParticle>* node = emtr->mAlivePtclBase.getFirst(); node != emtr->mAlivePtclBase.getEnd(); node = next) {
next = node->getNext();
if (node->getObject()->calc_p(work)) {
emtr->mpPtclPool->push_front(emtr->mAlivePtclBase.erase(node));
}
node = next;
}
node = emtr->mAlivePtclChld.getFirst();
while (node != emtr->mAlivePtclChld.getEnd()) {
for (JPANode<JPABaseParticle>* node = emtr->mAlivePtclChld.getFirst(); node != emtr->mAlivePtclChld.getEnd(); node = next) {
next = node->getNext();
if (node->getObject()->calc_c(work)) {
emtr->mpPtclPool->push_front(emtr->mAlivePtclChld.erase(node));
}
node = next;
}
emtr->mTick++;
@@ -782,13 +780,13 @@ void JPAResource::draw(JPAEmitterWorkData* work, JPABaseEmitter* emtr) {
work->mpRes = this;
work->mDrawCount = 0;
calcWorkData_d(work);
mpBaseShape->setGX(work);
pBsp->setGX(work);
for (s32 i = 1; i <= emtr->getDrawTimes(); i++) {
work->mDrawCount++;
if (mpBaseShape->isDrawPrntAhead() && mpChildShape != NULL)
if (pBsp->isDrawPrntAhead() && pCsp != NULL)
drawC(work);
drawP(work);
if (!mpBaseShape->isDrawPrntAhead() && mpChildShape != NULL)
if (!pBsp->isDrawPrntAhead() && pCsp != NULL)
drawC(work);
}
}
@@ -796,28 +794,28 @@ void JPAResource::draw(JPAEmitterWorkData* work, JPABaseEmitter* emtr) {
void JPAResource::drawP(JPAEmitterWorkData* work) {
work->mpEmtr->clearStatus(0x80);
work->mGlobalPtclScl.x = work->mpEmtr->mGlobalPScl.x * mpBaseShape->getBaseSizeX();
work->mGlobalPtclScl.y = work->mpEmtr->mGlobalPScl.y * mpBaseShape->getBaseSizeY();
work->mGlobalPtclScl.x = work->mpEmtr->mGlobalPScl.x * pBsp->getBaseSizeX();
work->mGlobalPtclScl.y = work->mpEmtr->mGlobalPScl.y * pBsp->getBaseSizeY();
if (mpBaseShape->getType() == 0) {
if (pBsp->getType() == 0) {
work->mGlobalPtclScl.x *= 1.02f;
} else if (mpBaseShape->getType() == 1) {
} else if (pBsp->getType() == 1) {
work->mGlobalPtclScl.x *= 1.02f;
work->mGlobalPtclScl.y *= 0.4f;
}
if (mpExtraShape != NULL && mpExtraShape->isEnableScaleAnm()) {
work->mPivot.x = mpExtraShape->getScaleCenterX() - 1.0f;
work->mPivot.y = mpExtraShape->getScaleCenterY() - 1.0f;
if (pEsp != NULL && pEsp->isEnableScaleAnm()) {
work->mPivot.x = pEsp->getScaleCenterX() - 1.0f;
work->mPivot.y = pEsp->getScaleCenterY() - 1.0f;
} else {
work->mPivot.x = work->mPivot.y = 0.0f;
}
work->mDirType = mpBaseShape->getDirType();
work->mRotType = mpBaseShape->getRotType();
work->mDLType = mpBaseShape->getType() == 4 || mpBaseShape->getType() == 8;
work->mPlaneType = work->mDLType ? 2 : mpBaseShape->getBasePlaneType();
work->mPrjType = mpBaseShape->isPrjTex() ? (mpBaseShape->isTexCrdAnm() ? 2 : 1) : 0;
work->mDirType = pBsp->getDirType();
work->mRotType = pBsp->getRotType();
work->mDLType = pBsp->getType() == 4 || pBsp->getType() == 8;
work->mPlaneType = work->mDLType ? 2 : pBsp->getBasePlaneType();
work->mPrjType = pBsp->isPrjTex() ? (pBsp->isTexCrdAnm() ? 2 : 1) : 0;
work->mpAlivePtcl = &work->mpEmtr->mAlivePtclBase;
setPTev();
@@ -826,7 +824,7 @@ void JPAResource::drawP(JPAEmitterWorkData* work) {
(*mpDrawEmitterFuncList[i])(work);
}
if (mpBaseShape->isDrawFwdAhead()) {
if (pBsp->isDrawFwdAhead()) {
JPANode<JPABaseParticle>* node = work->mpEmtr->mAlivePtclBase.getLast();
for (; node != work->mpEmtr->mAlivePtclBase.getEnd(); node = node->getPrev()) {
work->mpCurNode = node;
@@ -858,27 +856,27 @@ void JPAResource::drawP(JPAEmitterWorkData* work) {
void JPAResource::drawC(JPAEmitterWorkData* work) {
work->mpEmtr->setStatus(0x80);
if (mpChildShape->isScaleInherited()) {
work->mGlobalPtclScl.x = work->mpEmtr->mGlobalPScl.x * mpBaseShape->getBaseSizeX();
work->mGlobalPtclScl.y = work->mpEmtr->mGlobalPScl.y * mpBaseShape->getBaseSizeY();
if (pCsp->isScaleInherited()) {
work->mGlobalPtclScl.x = work->mpEmtr->mGlobalPScl.x * pBsp->getBaseSizeX();
work->mGlobalPtclScl.y = work->mpEmtr->mGlobalPScl.y * pBsp->getBaseSizeY();
} else {
work->mGlobalPtclScl.x = work->mpEmtr->mGlobalPScl.x * mpChildShape->getScaleX();
work->mGlobalPtclScl.y = work->mpEmtr->mGlobalPScl.y * mpChildShape->getScaleY();
work->mGlobalPtclScl.x = work->mpEmtr->mGlobalPScl.x * pCsp->getScaleX();
work->mGlobalPtclScl.y = work->mpEmtr->mGlobalPScl.y * pCsp->getScaleY();
}
if (mpChildShape->getType() == 0) {
if (pCsp->getType() == 0) {
work->mGlobalPtclScl.x *= 1.02f;
} else if (mpChildShape->getType() == 1) {
} else if (pCsp->getType() == 1) {
work->mGlobalPtclScl.x *= 1.02f;
work->mGlobalPtclScl.y *= 0.4f;
}
work->mPivot.x = work->mPivot.y = 0.0f;
work->mDirType = mpChildShape->getDirType();
work->mRotType = mpChildShape->getRotType();
work->mDLType = mpChildShape->getType() == 4 || mpChildShape->getType() == 8;
work->mPlaneType = work->mDLType ? 2 : mpChildShape->getBasePlaneType();
work->mDirType = pCsp->getDirType();
work->mRotType = pCsp->getRotType();
work->mDLType = pCsp->getType() == 4 || pCsp->getType() == 8;
work->mPlaneType = work->mDLType ? 2 : pCsp->getBasePlaneType();
work->mPrjType = 0;
work->mpAlivePtcl = &work->mpEmtr->mAlivePtclChld;
@@ -888,7 +886,7 @@ void JPAResource::drawC(JPAEmitterWorkData* work) {
(*mpDrawEmitterChildFuncList[i])(work);
}
if (mpBaseShape->isDrawFwdAhead()) {
if (pBsp->isDrawFwdAhead()) {
JPANode<JPABaseParticle>* node = work->mpEmtr->mAlivePtclChld.getLast();
for (; node != work->mpEmtr->mAlivePtclChld.getEnd(); node = node->getPrev()) {
work->mpCurNode = node;
@@ -923,33 +921,27 @@ void JPAResource::setPTev() {
u8 tex_gens = 1;
u8 ind_stages = 0;
int base_plane_type = (mpBaseShape->getType() == 3 || mpBaseShape->getType() == 7) ?
mpBaseShape->getBasePlaneType() : 0;
int center_offset;
if (mpExtraShape != NULL) {
center_offset =
(mpExtraShape->getScaleCenterX() + 3 * mpExtraShape->getScaleCenterY()) * 0xC;
} else {
center_offset = 0x30;
}
int base_plane_type = (pBsp->getType() == 3 || pBsp->getType() == 7) ?
pBsp->getBasePlaneType() : 0;
int center_offset = pEsp != NULL ? (pEsp->getScaleCenterX() + 3 * pEsp->getScaleCenterY()) * 0xC : 0x30;
int pos_offset = center_offset + base_plane_type * 0x6C;
int crd_offset = (mpBaseShape->getTilingS() + 2 * mpBaseShape->getTilingT()) * 8;
int crd_offset = (pBsp->getTilingS() + 2 * pBsp->getTilingT()) * 8;
GXSetArray(GX_VA_POS, jpa_pos + pos_offset, 3);
GXSetArray(GX_VA_TEX0, jpa_crd + crd_offset, 2);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL);
if (mpExTexShape != NULL) {
if (mpExTexShape->isUseIndirect()) {
GXSetIndTexOrder(GX_INDTEXSTAGE0, GX_TEXCOORD1, GX_TEXMAP2);
if (pEts != NULL) {
if (pEts->isUseIndirect()) {
GXSetIndTexOrder(GX_INDTEXSTAGE0, tex_coord, GX_TEXMAP2);
GXSetIndTexCoordScale(GX_INDTEXSTAGE0, GX_ITS_1, GX_ITS_1);
GXSetIndTexMtx(GX_ITM_0, (f32(*)[3])mpExTexShape->getIndTexMtx(), mpExTexShape->getExpScale());
GXSetIndTexMtx(GX_ITM_0, (f32(*)[3])pEts->getIndTexMtx(), pEts->getExpScale());
GXSetTevIndirect(GX_TEVSTAGE0, GX_INDTEXSTAGE0, GX_ITF_8, GX_ITB_STU, GX_ITM_0,
GX_ITW_OFF, GX_ITW_OFF, 0, 0, GX_ITBA_OFF);
ind_stages++;
tex_gens++;
tex_coord = GX_TEXCOORD2;
}
if (mpExTexShape->isUseSecTex()) {
if (pEts->isUseSecTex()) {
GXSetTevOrder(GX_TEVSTAGE1, tex_coord, GX_TEXMAP3, GX_COLOR_NULL);
GXSetTevColorIn(GX_TEVSTAGE1, GX_CC_ZERO, GX_CC_TEXC, GX_CC_CPREV, GX_CC_ZERO);
GXSetTevAlphaIn(GX_TEVSTAGE1, GX_CA_ZERO, GX_CA_TEXA, GX_CA_APREV, GX_CA_ZERO);
@@ -964,7 +956,7 @@ void JPAResource::setPTev() {
GXSetNumTevStages(tev_stages);
GXSetNumIndStages(ind_stages);
if (mpBaseShape->isClipOn()) {
if (pBsp->isClipOn()) {
GXSetMisc(GX_MT_XF_FLUSH, 8);
GXSetClipMode(GX_CLIP_ENABLE);
} else {
@@ -974,8 +966,8 @@ void JPAResource::setPTev() {
}
void JPAResource::setCTev(JPAEmitterWorkData* work) {
int base_plane_type = (mpChildShape->getType() == 3 || mpChildShape->getType() == 7) ?
mpChildShape->getBasePlaneType() : 0;
int base_plane_type = (pCsp->getType() == 3 || pCsp->getType() == 7) ?
pCsp->getBasePlaneType() : 0;
int pos_offset = 0x30 + base_plane_type * 0x6C;
GXSetArray(GX_VA_POS, jpa_pos + pos_offset, 3);
GXSetArray(GX_VA_TEX0, jpa_crd, 2);
@@ -984,14 +976,14 @@ void JPAResource::setCTev(JPAEmitterWorkData* work) {
GXSetTevDirect(GX_TEVSTAGE0);
GXSetNumTevStages(1);
GXSetNumIndStages(0);
if (mpChildShape->isClipOn()) {
if (pCsp->isClipOn()) {
GXSetMisc(GX_MT_XF_FLUSH, 8);
GXSetClipMode(GX_CLIP_ENABLE);
} else {
GXSetClipMode(GX_CLIP_DISABLE);
}
GXSetNumTexGens(1);
work->mpResMgr->load(work->mpRes->getTexIdx(mpChildShape->getTexIdx()), GX_TEXMAP1);
work->mpResMgr->load(work->mpRes->getTexIdx(pCsp->getTexIdx()), GX_TEXMAP1);
}
void JPAResource::calc_p(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
@@ -1011,15 +1003,15 @@ void JPAResource::calc_c(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
}
void JPAResource::calcField(JPAEmitterWorkData* work, JPABaseParticle* ptcl) {
for (int i = mFieldBlockNum - 1; i >= 0; i--) {
mpFieldBlocks[i]->calc(work, ptcl);
for (int i = fldNum - 1; i >= 0; i--) {
ppFld[i]->calc(work, ptcl);
}
}
void JPAResource::calcKey(JPAEmitterWorkData* work) {
for (int i = mKeyBlockNum - 1; i >= 0; i--) {
f32 val = mpKeyBlocks[i]->calc(work->mpEmtr->mTick);
switch (mpKeyBlocks[i]->getID()) {
for (int i = keyNum - 1; i >= 0; i--) {
f32 val = ppKey[i]->calc(work->mpEmtr->mTick);
switch (ppKey[i]->getID()) {
case 0:
work->mpEmtr->mRate = val;
break;
@@ -1047,6 +1039,9 @@ void JPAResource::calcKey(JPAEmitterWorkData* work) {
case 10:
work->mpEmtr->mScaleOut = val;
break;
default:
JUT_WARN(917, "%s", "JPA : WRONG ID in key data\n");
break;
}
}
}
@@ -1055,10 +1050,9 @@ void JPAResource::calcWorkData_c(JPAEmitterWorkData* work) {
work->mVolumeSize = work->mpEmtr->mVolumeSize;
work->mVolumeMinRad = work->mpEmtr->mVolumeMinRad;
work->mVolumeSweep = work->mpEmtr->mVolumeSweep;
work->mVolumeX = 0;
work->mVolumeAngleNum = 0;
work->mVolumeAngleNum = work->mVolumeX = 0;
work->mVolumeAngleMax = 1;
work->mDivNumber = mpDynamicsBlock->getDivNumber() * 2 + 1;
work->mDivNumber = pDyn->getDivNumber() * 2 + 1;
Mtx local_scl_mtx, local_rot_mtx, global_mtx;
MTXScale(local_scl_mtx, work->mpEmtr->mLocalScl.x, work->mpEmtr->mLocalScl.y,
work->mpEmtr->mLocalScl.z);
+70 -32
View File
@@ -12,12 +12,35 @@
#include "JSystem/JParticle/JPAResource.h"
#include "JSystem/JParticle/JPAResourceManager.h"
static void dummy1() {
JUT_WARN(0, "JPA : wrong version file %s\n");
OS_REPORT("JPA : no jpa file\n");
}
JPAResourceLoader::JPAResourceLoader(u8 const* data, JPAResourceManager* mgr) {
if (*(u32*)(data + 4) == '2-10') {
load_jpc(data, mgr);
} else {
JUT_WARN(48, "JPA : wrong version file\n");
}
}
static void dummy2() {
OS_REPORT("tex_num && \"a resource have to use one or more texture\"");
OS_REPORT("p_res != 0");
OS_REPORT("(p_res->ppFld != 0) || (p_res->fldNum == 0)");
OS_REPORT("(p_res->ppKey != 0) || (p_res->keyNum == 0)");
OS_REPORT("(p_res->texIdxTbl != 0) || (p_res->texNum == 0)");
OS_REPORT("p_res->ppFld[fld_no] != 0");
OS_REPORT("p_res->ppKey[key_no] != 0");
OS_REPORT("p_res->pDyn != 0");
OS_REPORT("p_res->pBsp != 0");
OS_REPORT("p_res->pEsp != 0");
OS_REPORT("p_res->pCsp != 0");
OS_REPORT("p_res->pEts != 0");
OS_REPORT("JPA : wrong type block in jpc file %x\n");
}
struct JPAResourceHeader {
/* 0x0 */ u16 mUsrIdx;
/* 0x2 */ u16 mBlockNum;
@@ -26,74 +49,89 @@ struct JPAResourceHeader {
/* 0x6 */ u8 mTDB1Num;
};
void JPAResourceLoader::load_jpc(u8 const* data, JPAResourceManager* mgr) {
JKRHeap* heap = mgr->mpHeap;
mgr->mResMax = *(u16*)(data + 8);
mgr->mTexMax = *(u16*)(data + 0xA);
mgr->mpResArr = new (heap, 0) JPAResource*[mgr->mResMax];
mgr->mpTexArr = new (heap, 0) JPATexture*[mgr->mTexMax];
void JPAResourceLoader::load_jpc(u8 const* data, JPAResourceManager* p_res_mgr) {
JKRHeap* heap = p_res_mgr->mpHeap;
p_res_mgr->resMaxNum = *(u16*)(data + 8);
p_res_mgr->texMaxNum = *(u16*)(data + 0xA);
p_res_mgr->pResAry = new (heap, 0) JPAResource*[p_res_mgr->resMaxNum];
p_res_mgr->pTexAry = new (heap, 0) JPATexture*[p_res_mgr->texMaxNum];
JUT_ASSERT(199, (p_res_mgr->pResAry != NULL) && (p_res_mgr->pTexAry != 0));
u32 offset = 0x10;
for (int i = 0; i < *(u16*)(data + 8); i++) {
JPAResourceHeader* header = (JPAResourceHeader*)(data + offset);
JPAResource* res = new (heap, 0) JPAResource();
res->mFieldBlockNum = header->mFieldBlockNum;
res->mpFieldBlocks = res->mFieldBlockNum != 0 ?
new (heap, 0) JPAFieldBlock*[res->mFieldBlockNum] : NULL;
res->mKeyBlockNum = header->mKeyBlockNum;
res->mpKeyBlocks = res->mKeyBlockNum != 0 ?
new (heap, 0) JPAKeyBlock*[res->mKeyBlockNum] : NULL;
res->mTDB1Num = header->mTDB1Num;
res->mpTDB1 = NULL;
res->mUsrIdx = header->mUsrIdx;
JPAResource* p_res = new (heap, 0) JPAResource();
JUT_ASSERT(211, p_res != NULL);
p_res->fldNum = header->mFieldBlockNum;
p_res->ppFld = p_res->fldNum != 0 ?
new (heap, 0) JPAFieldBlock*[p_res->fldNum] : NULL;
JUT_ASSERT(216, (p_res->ppFld != NULL) || (p_res->fldNum == 0));
p_res->keyNum = header->mKeyBlockNum;
p_res->ppKey = p_res->keyNum != 0 ?
new (heap, 0) JPAKeyBlock*[p_res->keyNum] : NULL;
JUT_ASSERT(221, (p_res->ppKey != NULL) || (p_res->keyNum == 0));
p_res->texNum = header->mTDB1Num;
p_res->mpTDB1 = NULL;
p_res->mUsrIdx = header->mUsrIdx;
offset += 8;
u32 field_idx = 0;
u32 key_idx = 0;
u32 fld_no = 0;
u32 key_no = 0;
for (int j = 0; j < header->mBlockNum; j++) {
u32 magic = *(u32*)(data + offset);
u32 size = *(u32*)(data + offset + 4);
switch (magic) {
case 'FLD1':
res->mpFieldBlocks[field_idx] = new (heap, 0) JPAFieldBlock(data + offset, heap);
field_idx++;
p_res->ppFld[fld_no] = new (heap, 0) JPAFieldBlock(data + offset, heap);
JUT_ASSERT(244, p_res->ppFld[fld_no] != NULL);
fld_no++;
break;
case 'KFA1':
res->mpKeyBlocks[key_idx] = new (heap, 0) JPAKeyBlock(data + offset);
key_idx++;
p_res->ppKey[key_no] = new (heap, 0) JPAKeyBlock(data + offset);
JUT_ASSERT(249, p_res->ppKey[key_no] != NULL);
key_no++;
break;
case 'BEM1':
res->mpDynamicsBlock = new (heap, 0) JPADynamicsBlock(data + offset);
p_res->pDyn = new (heap, 0) JPADynamicsBlock(data + offset);
JUT_ASSERT(254, p_res->pDyn != NULL);
break;
case 'BSP1':
res->mpBaseShape = new (heap, 0) JPABaseShape(data + offset, heap);
p_res->pBsp = new (heap, 0) JPABaseShape(data + offset, heap);
JUT_ASSERT(258, p_res->pBsp != NULL);
break;
case 'ESP1':
res->mpExtraShape = new (heap, 0) JPAExtraShape(data + offset);
p_res->pEsp = new (heap, 0) JPAExtraShape(data + offset);
JUT_ASSERT(262, p_res->pEsp != NULL);
break;
case 'SSP1':
res->mpChildShape = new (heap, 0) JPAChildShape(data + offset);
p_res->pCsp = new (heap, 0) JPAChildShape(data + offset);
JUT_ASSERT(266, p_res->pCsp != NULL);
break;
case 'ETX1':
res->mpExTexShape = new (heap, 0) JPAExTexShape(data + offset);
p_res->pEts = new (heap, 0) JPAExTexShape(data + offset);
JUT_ASSERT(270, p_res->pEts != NULL);
break;
case 'TDB1':
res->mpTDB1 = (const u16*)(data + offset + 8);
p_res->mpTDB1 = (const u16*)(data + offset + 8);
break;
default:
JUT_WARN(275, "JPA : wrong type block in jpc file %d %x\n", header->mBlockNum, offset);
break;
}
offset += size;
}
res->init(heap);
mgr->registRes(res);
p_res->init(heap);
p_res_mgr->registRes(p_res);
}
offset = *(u32*)(data + 0xC);
for (int i = 0; i < *(u16*)(data + 0xA); i++) {
u32 size = *(u32*)(data + offset + 4);
JPATexture* tex = new (heap, 0) JPATexture(data + offset);
mgr->registTex(tex);
JPATexture* p_tex = new (heap, 0) JPATexture(data + offset);
JUT_ASSERT(298, p_tex != NULL);
p_res_mgr->registTex(p_tex);
offset += size;
}
}
+24 -20
View File
@@ -9,37 +9,39 @@ struct JPAResourceLoader {
JPAResourceLoader(u8 const*, JPAResourceManager*);
};
JPAResourceManager::JPAResourceManager(void const* pData, JKRHeap* pHeap) {
mpResArr = NULL;
mpTexArr = NULL;
mResMax = 0;
mResNum = 0;
mTexMax = 0;
mTexNum = 0;
JPAResourceManager::JPAResourceManager(void const* p_jpc, JKRHeap* pHeap) {
pResAry = NULL;
pTexAry = NULL;
resMaxNum = 0;
resRegNum = 0;
texMaxNum = 0;
texRegNum = 0;
mpHeap = pHeap;
JPAResourceLoader loader((u8 const*)pData, this);
JUT_ASSERT(49, (p_jpc != 0) && (pHeap != 0));
JPAResourceLoader loader((u8 const*)p_jpc, this);
}
JPAResource* JPAResourceManager::getResource(u16 usrIdx) const {
for (u16 i = 0; i < mResNum; i++)
if (mpResArr[i]->getUsrIdx() == usrIdx)
return mpResArr[i];
for (u16 i = 0; i < resRegNum; i++)
if (pResAry[i]->getUsrIdx() == usrIdx)
return pResAry[i];
return NULL;
}
bool JPAResourceManager::checkUserIndexDuplication(u16 usrIdx) const {
for (s32 i = 0; i < mResNum; i++)
if (mpResArr[i]->getUsrIdx() == usrIdx)
for (s32 i = 0; i < resRegNum; i++)
if (pResAry[i]->getUsrIdx() == usrIdx)
return true;
return false;
}
const ResTIMG* JPAResourceManager::swapTexture(ResTIMG const* img, char const* swapName) {
const ResTIMG* ret = NULL;
JUTTexture* tex = NULL;
for (s32 i = 0; i < mTexNum; i++) {
if (strcmp(swapName, mpTexArr[i]->getName()) == 0) {
JUTTexture* tex = mpTexArr[i]->getJUTTexture();
for (s32 i = 0; i < texRegNum; i++) {
if (strcmp(swapName, pTexAry[i]->getName()) == 0) {
tex = pTexAry[i]->getJUTTexture();
ret = tex->getTexInfo();
tex->storeTIMG(img, (u8)0);
break;
@@ -50,13 +52,15 @@ const ResTIMG* JPAResourceManager::swapTexture(ResTIMG const* img, char const* s
}
void JPAResourceManager::registRes(JPAResource* res) {
mpResArr[mResNum] = res;
mResNum++;
JUT_ASSERT(151, resRegNum < resMaxNum);
pResAry[resRegNum] = res;
resRegNum++;
}
void JPAResourceManager::registTex(JPATexture* tex) {
mpTexArr[mTexNum] = tex;
mTexNum++;
JUT_ASSERT(166, texRegNum < texMaxNum);
pTexAry[texRegNum] = tex;
texRegNum++;
}
u32 JPAResourceManager::getResUserWork(u16 usrIdx) const {
+9 -2
View File
@@ -116,8 +116,9 @@ void showAssert_f_va(u32 device, const char* file, int line, const char* msg, va
OSEnableInterrupts();
u32 retrace_count = VIGetRetraceCount();
do {
} while (retrace_count == VIGetRetraceCount());
while (retrace_count == VIGetRetraceCount()){
// nop
}
// busy loop for 2 seconds
OSTime var1 = OSGetTime();
@@ -129,6 +130,8 @@ void showAssert_f_va(u32 device, const char* file, int line, const char* msg, va
}
void showAssert_f(u32 device, const char* file, int line, const char* msg, ...) {
UNUSED(msg);
va_list args;
va_start(args, msg);
showAssert_f_va(device, file, line, msg, args);
@@ -159,6 +162,8 @@ void setWarningMessage_f_va(u32 device, const char* file, int line, const char*
}
void setWarningMessage_f(u32 device, char* file, int line, const char* msg, ...) {
UNUSED(msg);
va_list args;
va_start(args, msg);
setWarningMessage_f_va(device, file, line, msg, args);
@@ -189,6 +194,8 @@ void setLogMessage_f_va(u32 device, const char* file, int line, const char* msg,
}
void setLogMessage_f(u32 device, char* file, int line, const char* msg, ...) {
UNUSED(msg);
va_list args;
va_start(args, msg);
setLogMessage_f_va(device, file, line, msg, args);
+7 -7
View File
@@ -7,6 +7,8 @@
#include "JSystem/JKernel/JKRAram.h"
#include <dolphin/gx.h>
#include <stdint.h>
#include <cstring>
#include "angle_utils.h"
JUTCacheFont::JUTCacheFont(ResFONT const* p_fontRes, u32 cacheSize, JKRHeap* p_heap) {
initialize_state();
@@ -70,7 +72,6 @@ int JUTCacheFont::getMemorySize(ResFONT const* p_font, u16* o_widCount, u32* o_w
u32 totalGlySize = 0;
u32 totalMapSize = 0;
u32 maxGlyTexSize = 0;
u32 glyTexSize;
u8* fontInf = (u8*)p_font->data;
for (int i = 0; i < (int)p_font->numBlocks; i++) {
@@ -84,11 +85,10 @@ int JUTCacheFont::getMemorySize(ResFONT const* p_font, u16* o_widCount, u32* o_w
widBlockCount++;
break;
case 'GLY1':
totalGlySize += blkSize;
glyTexSize = ((ResFONT::GLY1*)fontInf)->textureSize;
totalGlySize += ((BlockHeader*)fontInf)->size;
glyBlockCount++;
if (glyTexSize > maxGlyTexSize) {
maxGlyTexSize = glyTexSize;
if (((ResFONT::GLY1*)fontInf)->textureSize > maxGlyTexSize) {
maxGlyTexSize = ((ResFONT::GLY1*)fontInf)->textureSize;
}
break;
case 'MAP1':
@@ -185,7 +185,7 @@ bool JUTCacheFont::allocArea(void* cacheBuffer, u32 param_1, JKRHeap* heap) {
}
if (mGly1BlockNum != 0) {
field_0x80 = new (heap, 0) ResFONT::GLY1[mGly1BlockNum];
field_0x80 = new (heap, 0) u8[mGly1BlockNum * sizeof(ResFONT::GLY1)];
if (field_0x80 == NULL) {
return false;
}
@@ -350,7 +350,7 @@ void JUTCacheFont::getGlyphFromAram(JUTCacheFont::TGlyphCacheInfo* param_0,
prepend(pGylphCacheInfo);
int iVar3 = pGylphCacheInfo->field_0x16 * pGylphCacheInfo->field_0x18;
int iVar2 = *r30 / iVar3;
pGylphCacheInfo->field_0x8 += iVar2 * iVar3;
U16_ADD_2(pGylphCacheInfo->field_0x8, iVar2 * iVar3);
u16 local_30 = pGylphCacheInfo->field_0x8 + iVar3 - 1;
pGylphCacheInfo->field_0xa = pGylphCacheInfo->field_0xa < local_30 ? pGylphCacheInfo->field_0xa : local_30;
*param_3 = iVar2;
+110 -53
View File
@@ -31,6 +31,7 @@ JUTConsole* JUTConsole::create(unsigned int param_0, void* buffer, u32 bufferSiz
JUT_ASSERT(59, pManager != NULL);
JUT_ASSERT(62, ( (uintptr_t)buffer & 0x3 ) == 0);
u32 maxLines = getLineFromObjectSize(bufferSize, param_0);
JUTConsole* console = new (buffer) JUTConsole(param_0, maxLines, false);
@@ -66,6 +67,10 @@ JUTConsole::JUTConsole(unsigned int param_0, unsigned int maxLines, bool param_2
field_0x64 = 8;
}
static void dummystring1() {
UNUSED("console != 0");
}
JUTConsole::~JUTConsole() {
JUT_ASSERT(154, JUTConsoleManager::getManager());
JUTConsoleManager::getManager()->removeConsole(this);
@@ -77,7 +82,8 @@ size_t JUTConsole::getObjectSizeFromBufferSize(unsigned int param_0, unsigned in
}
size_t JUTConsole::getLineFromObjectSize(u32 bufferSize, unsigned int param_1) {
size_t result = (bufferSize - sizeof(JUTConsole)) / (param_1 + 2);
bufferSize -= sizeof(JUTConsole);
size_t result = (bufferSize) / (param_1 + 2);
return result;
}
@@ -102,7 +108,9 @@ void JUTConsole::doDraw(JUTConsole::EConsoleType consoleType) const {
if (mVisible && (mFont != NULL || consoleType == CONSOLE_TYPE_2)) {
if (mHeight != 0) {
bool temp_r30 = consoleType == CONSOLE_TYPE_0;
bool spA = consoleType == CONSOLE_TYPE_0 ? true : false;
int spA4 = spA ? 1 : 0;
spA4 = 0;
font_yOffset = 2.0f + mFontSizeY;
if (consoleType != CONSOLE_TYPE_2) {
@@ -115,21 +123,13 @@ void JUTConsole::doDraw(JUTConsole::EConsoleType consoleType) const {
ortho.setPort();
}
const JUtility::TColor* color;
if (temp_r30) {
color = &field_0x60;
} else {
color = &field_0x5c;
}
J2DFillBox(mPositionX - 2, (int)(mPositionY - font_yOffset),
(int)((mFontSizeX * field_0x20) + 4.0f), (int)(font_yOffset * mHeight),
*color);
(int)((mFontSizeX * field_0x20) + 4.0f),
(int)(font_yOffset * (mHeight + spA4)), spA ? field_0x60 : field_0x5c);
mFont->setGX();
if (temp_r30) {
s32 s = (diffIndex(field_0x30, field_0x38) - mHeight) + 1;
if (s <= 0) {
if (spA) {
if (((diffIndex(field_0x30, field_0x38) - (int)mHeight) + 1) <= 0) {
mFont->setCharColor(JUtility::TColor(255, 255, 255, 255));
} else if (field_0x30 == field_0x34) {
mFont->setCharColor(JUtility::TColor(255, 230, 230, 255));
@@ -146,38 +146,81 @@ void JUTConsole::doDraw(JUTConsole::EConsoleType consoleType) const {
JUTDirectPrint::getManager()->setCharColor(JUtility::TColor(255, 255, 255, 255));
}
char* linePtr;
s32 curLine = field_0x30;
s32 yFactor = 0;
u8* linePtr;
do {
linePtr = (char*)getLinePtr(curLine);
if ((u8)linePtr[-1] != NULL) {
if (consoleType != CONSOLE_TYPE_2) {
mFont->drawString_scale(mPositionX, ((yFactor * font_yOffset) + mPositionY),
mFontSizeX, mFontSizeY, linePtr, true);
} else {
JUTDirectPrint::getManager()->drawString(
mPositionX, ((yFactor * font_yOffset) + mPositionY), linePtr);
}
changeLine_1 = curLine + 1;
yFactor += 1;
changeLine_2 = changeLine_1 & ~(-((s32)mMaxLines <= (s32)changeLine_1));
curLine = changeLine_2;
} else {
while (true) {
linePtr = getLinePtr(curLine);
u8 sp9 = linePtr[-1];
if (sp9 == 0) {
break;
}
} while (yFactor < mHeight && changeLine_2 != field_0x34);
if (consoleType != CONSOLE_TYPE_2) {
mFont->drawString_scale(mPositionX, ((yFactor * font_yOffset) + mPositionY),
mFontSizeX, mFontSizeY, (char*)linePtr, true);
} else {
JUTDirectPrint::getManager()->drawString(
mPositionX, ((yFactor * font_yOffset) + mPositionY), (char*)linePtr);
}
curLine = nextIndex(curLine);
yFactor++;
if (yFactor >= mHeight || curLine == field_0x34) {
break;
}
}
if (spA4 != 0) {
f32 f31 = mPositionX;
int sp94 = mHeight * font_yOffset + mPositionY;
mFont->setCharColor(JUtility::TColor(0xff, mVisible ? 0xff : 200, 0xc8, 0xff));
mFont->drawString_scale((int)f31, sp94, mFontSizeX, mFontSizeY, "X", TRUE);
f31 += mFontSizeX;
mFont->drawString_scale((int)f31, sp94, mFontSizeX, mFontSizeY,
mVisible ? "[ON]" : "[OFF]", TRUE);
f31 += (int)(mFontSizeX * 6.0f);
if (this == NULL) // ????
{
mFont->setCharColor(JUtility::TColor(0xff, 0xff, 0x64, 0xff));
mFont->drawString_scale((int)(f31 - mFontSizeX), mFontSizeX, mFontSizeY, sp94,
"*", TRUE);
}
mFont->setCharColor(JUtility::TColor(0xc8, 0xc8, 0xc8, 0xff));
char spA8[] = "S----------E";
char spB8[0x20];
int sp90 = diffIndex(field_0x34, field_0x38) + 1;
int sp8C = diffIndex(field_0x34, field_0x30);
int sp88 = 0;
int sp84;
if (sp90 <= mHeight) {
sp84 = 9;
sp88 = 1;
} else {
sp84 = (sp8C * 9) / (int)(sp90 - mHeight);
}
spA8[sp84 + 1] = 'O';
mFont->drawString_scale((int)f31, sp94, mFontSizeX, mFontSizeY, spA8, TRUE);
f31 += mFontSizeX * 13.0f;
if (sp88) {
sprintf(spB8, "ALL");
} else {
f32 f29 = sp8C / (f32)(sp90 - mHeight);
sprintf(spB8, "%3d%%(%dL)", (int)(100.0 * f29), sp90);
}
mFont->drawString_scale(f31, sp94, mFontSizeX, mFontSizeY, spB8, TRUE);
}
}
}
}
void JUTConsole::print_f(char const* fmt, ...) {
UNUSED(fmt);
va_list args;
va_start(args, fmt);
JUTConsole_print_f_va_(this, fmt, args);
JUTConsole::print_f_va(fmt, args);
va_end(args);
}
@@ -187,48 +230,48 @@ void JUTConsole::print(char const* str) {
}
if (mOutput & 1) {
const u8* r29 = (const u8*)str;
u8* r28 = getLinePtr(field_0x38) + field_0x3c;
while (*r29) {
u8* src = (u8*)const_cast<char*>(str); // needs to be non-const to match debug
u8* dst = (u8*)getLinePtr(field_0x38) + field_0x3c;
while (*src != 0) {
if (field_0x6a && field_0x34 == nextIndex(field_0x38)) {
break;
}
if (*r29 == '\n') {
r29++;
if (*src == '\n') {
src++;
field_0x3c = field_0x20;
} else if (*r29 == '\t') {
r29++;
} else if (*src == '\t') {
src++;
while (field_0x3c < field_0x20) {
*(r28++) = ' ';
*dst++ = ' ';
field_0x3c++;
if (field_0x3c % field_0x64 == 0) {
break;
}
}
} else if (mFont && mFont->isLeadByte(*r29)) {
} else if (mFont && mFont->isLeadByte(*src)) {
if (field_0x3c + 1 < field_0x20) {
*(r28++) = *(r29++);
*(r28++) = *(r29++);
*dst++ = *src++;
*dst++ = *src++;
field_0x3c++;
field_0x3c++;
} else {
*(r28++) = 0;
*dst++ = '\0';
field_0x3c++;
}
} else {
*(r28++) = *(r29++);
*dst++ = *src++;
field_0x3c++;
}
if (field_0x3c < field_0x20) {
continue;
}
*r28 = 0;
*dst = '\0';
field_0x38 = nextIndex(field_0x38);
field_0x3c = 0;
setLineAttr(field_0x38, 0xff);
r28 = getLinePtr(field_0x38);
*r28 = 0;
dst = getLinePtr(field_0x38);
*dst = '\0';
int local_28 = diffIndex(field_0x30, field_0x38);
if (local_28 == mHeight) {
field_0x30 = nextIndex(field_0x30);
@@ -244,7 +287,7 @@ void JUTConsole::print(char const* str) {
break;
}
}
*r28 = 0;
*dst = '\0';
}
}
@@ -300,6 +343,15 @@ void JUTConsole::dumpToTerminal(unsigned int param_0) {
OS_REPORT(":::dump of console[%x] END----------------------------\n", this);
}
static void dummyStrings2()
{
UNUSED("console != this && console != 0");
UNUSED("\n:::dump of console[%x]----------------\n");
UNUSED(":::dump of console[%x] END------------\n");
UNUSED("sManager == 0");
UNUSED("consoleManager != 0 && sManager == consoleManager");
}
void JUTConsole::scroll(int scrollAmnt) {
if (scrollAmnt < 0) {
int diff = diffIndex(field_0x34, field_0x30);
@@ -404,8 +456,9 @@ void JUTConsoleManager::drawDirect(bool waitRetrace) const {
s32 interrupt_status = OSEnableInterrupts();
u32 retrace_count = VIGetRetraceCount();
u32 new_count;
do {
} while (retrace_count == VIGetRetraceCount());
while (retrace_count == VIGetRetraceCount()){
// nop
}
OSRestoreInterrupts(interrupt_status);
}
mDirectConsole->doDraw(JUTConsole::CONSOLE_TYPE_2);
@@ -459,6 +512,8 @@ extern "C" void JUTReportConsole_f_va(const char* fmt, va_list args) {
}
extern "C" void JUTReportConsole_f(const char* fmt, ...) {
UNUSED(fmt);
va_list args;
va_start(args, fmt);
JUTReportConsole_f_va(fmt, args);
@@ -490,6 +545,8 @@ void JUTWarningConsole_f_va(const char* fmt, va_list args) {
}
void JUTWarningConsole_f(const char* fmt, ...) {
UNUSED(fmt);
va_list args;
va_start(args, fmt);
JUTReportConsole_f_va(fmt, args);
+13 -16
View File
@@ -5,18 +5,7 @@
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JUtility/JUTVideo.h"
#include <cstdio>
#ifndef __MWERKS__
#include <cstdarg>
#endif
inline void enter_(int param_0, int param_1, int param_2, const char* fmt, va_list args) {
char buf[0x100];
int ret = vsnprintf(buf, 0x100, fmt, args);
if (ret < 0) {
return;
}
JUTDbPrint::getManager()->enter(param_0, param_1, param_2, buf, ret < 0x100 ? ret : 0xFF);
}
#include <cstring>
JUTDbPrint::JUTDbPrint(JUTFont* pFont, JKRHeap* pHeap) {
mFont = pFont;
@@ -62,9 +51,13 @@ void JUTDbPrint::enter(int param_0, int param_1, int param_2, const char* param_
}
}
static void dummy() {
va_list args;
enter_(0, 0, 0, 0, args);
static inline void enter_(int param_0, int param_1, int param_2, const char* fmt, va_list args) {
char buf[0x100];
int ret = vsnprintf(buf, 0x100, fmt, args);
if (ret >= 0) {
JUTDbPrint::getManager()->enter(param_0, param_1, param_2, buf, ret < 0x100 ? ret : 0xFF);
}
}
void JUTDbPrint::flush() {
@@ -104,13 +97,17 @@ void JUTDbPrint::drawString(int posX, int posY, int len, const u8* str) {
}
void JUTReport(int param_0, int param_1, char const* fmt, ...) {
UNUSED(fmt); // although not really unused
va_list args;
va_start(args, fmt);
enter_(param_0, param_1, 1, fmt, args);
enter_(param_0, param_1, TRUE, fmt, args);
va_end(args);
}
void JUTReport(int param_0, int param_1, int param_2, char const* fmt, ...) {
UNUSED(fmt); // although not really unused
va_list args;
va_start(args, fmt);
enter_(param_0, param_1, param_2, fmt, args);
+16 -13
View File
@@ -4,6 +4,7 @@
#include <cstdio>
#include <dolphin/os.h>
#include "global.h"
#include "angle_utils.h"
JUTDirectPrint* JUTDirectPrint::sDirectPrint;
@@ -160,7 +161,7 @@ void JUTDirectPrint::printSub(u16 position_x, u16 position_y, char const* format
for (; 0 < buffer_length; buffer_length--, ptr++) {
int codepoint = sAsciiTable[*ptr & 0x7f];
if (codepoint == 0xfe) {
position_y += 7;
U16_ADD_2(position_y, 7);
position_x = x;
} else if (codepoint == 0xfd) {
position_x = position_x + 0x30 - ((position_x - x + 0x2f) % 0x30);
@@ -168,7 +169,7 @@ void JUTDirectPrint::printSub(u16 position_x, u16 position_y, char const* format
if (codepoint != 0xff) {
drawChar(position_x, position_y, codepoint);
}
position_x += 6;
U16_ADD_2(position_x, 6);
}
}
}
@@ -177,6 +178,8 @@ void JUTDirectPrint::printSub(u16 position_x, u16 position_y, char const* format
}
void JUTDirectPrint::print(u16 position_x, u16 position_y, char const* format, ...) {
UNUSED(format);
if (mFrameBuffer) {
va_list args;
va_start(args, format);
@@ -190,6 +193,8 @@ void JUTDirectPrint::drawString(u16 position_x, u16 position_y, char* text) {
}
void JUTDirectPrint::drawString_f(u16 position_x, u16 position_y, char const* format, ...) {
UNUSED(format);
if (mFrameBuffer) {
va_list args;
va_start(args, format);
@@ -204,17 +209,15 @@ void JUTDirectPrint::setCharColor(JUtility::TColor color) {
void JUTDirectPrint::setCharColor(u8 r, u8 g, u8 b) {
mCharColor = JUtility::TColor(r, g, b, 0xFF);
int Cb = -0.148 * (int)r - 0.291 * (int)g + 0.439 * (int)b + 128;
int Cr = 0.439 * (int)r - 0.368 * (int)g - 0.071 * (int)b + 128;
int Y = 0.257 * (int)r + 0.504 * (int)g + 0.098 * (int)b + 16;
mCharColor_Y = Y << 8;
int Y = 0.257 * (int)r + 0.504 * (int)g + 0.098 * (int)b + 16.0f;
int Cb = -0.148 * (int)r - 0.291 * (int)g + 0.439 * (int)b + 128.0f;
int Cr = 0.439 * (int)r - 0.368 * (int)g - 0.071 * (int)b + 128.0f;
mCharColor_Y = (u16)Y * 256;
mCharColor_Cb = Cb;
mCharColor_Cb2 = (Cb >> 1) & 0x7fff;
mCharColor_Cb4 = (Cb >> 2) & 0x3fff;
mCharColor_Cb2 = (u16)Cb / 2;
mCharColor_Cb4 = (u16)Cb / 4;
mCharColor_Cr = Cr;
mCharColor_Cr2 = (Cr >> 1) & 0x7fff;
mCharColor_Cr4 = (Cr >> 2) & 0x3fff;
mCharColor_Cr2 = (u16)Cr / 2;
mCharColor_Cr4 = (u16)Cr / 4;
}
+86 -73
View File
@@ -9,6 +9,7 @@
#include <cstdlib>
#include <dolphin/dolphin.h>
#include <stdint.h>
#include <cstring>
struct CallbackObject {
/* 0x00 */ JUTExceptionUserCallback callback;
@@ -190,6 +191,8 @@ void JUTException::panic_f_va(char const* file, int line, char const* format, va
}
void JUTException::panic_f(char const* file, int line, char const* format, ...) {
UNUSED(format);
va_list args;
va_start(args, format);
panic_f_va(file, line, format, args);
@@ -308,7 +311,9 @@ void JUTException::showStack(OSContext* context) {
u32* stackPointer = (u32*)mStackPointer;
sConsole->print_f("Address: BackChain LR save\n");
for (i = 0; (stackPointer != NULL) && (stackPointer != (u32*)0xFFFFFFFF) && (i++ < 0x100);) {
for (i = 0; (stackPointer != NULL) && ((uintptr_t)stackPointer != -1) && (i++ < 0x100);
stackPointer = (u32*)stackPointer[0])
{
if (i > mTraceSuppress) {
sConsole->print("Suppress trace.\n");
return;
@@ -318,7 +323,6 @@ void JUTException::showStack(OSContext* context) {
showMapInfo_subroutine(stackPointer[1], false);
JUTConsoleManager::getManager()->drawDirect(true);
waitTime(mPrintWaitTime1);
stackPointer = (u32*)stackPointer[0];
}
}
@@ -529,8 +533,10 @@ bool JUTException::isEnablePad() const {
bool JUTException::readPad(u32* out_trigger, u32* out_button) {
bool result = false;
OSTime start_time = OSGetTime();
do {
} while (OSTicksToMilliseconds(OSGetTime() - start_time) < 0x32);
OSTime ms;
while (((OSGetTime() - start_time) / (OS_TIMER_CLOCK / 1000)) < 50){
// nop
}
if (mGamePad == (JUTGamePad*)0xffffffff) {
JUTGamePad gamePad0(JUTGamePad::EPort1);
@@ -683,7 +689,7 @@ void JUTException::printContext(OSError error, OSContext* context, u32 dsisr, u3
int down = 0;
int up = 0;
do {
while (true) {
readPad(&trigger, &button);
bool draw = false;
@@ -720,7 +726,7 @@ void JUTException::printContext(OSError error, OSContext* context, u32 dsisr, u3
}
waitTime(30);
} while (true);
}
}
while (true) {
@@ -750,19 +756,19 @@ void JUTException::printContext(OSError error, OSContext* context, u32 dsisr, u3
}
void JUTException::waitTime(s32 timeout_ms) {
if (!timeout_ms) {
return;
OSTime start_time;
if (timeout_ms) {
start_time = OSGetTime();
while (((OSGetTime() - start_time) / (OS_TIMER_CLOCK / 1000)) < timeout_ms) {
// nop
}
}
OSTime start_time = OSGetTime();
do {
} while (OSTicksToMilliseconds(OSGetTime() - start_time) < timeout_ms);
}
void JUTException::createFB() {
_GXRenderModeObj* renderMode = &GXNtsc480Int;
void* end = (void*)OSGetArenaHi();
u32 size = (u16(ALIGN_NEXT(u16(renderMode->fbWidth), 16)) * renderMode->xfbHeight) * 2;
u32 size = ((u16)ALIGN_NEXT((u16)renderMode->fbWidth, 16) * renderMode->xfbHeight) * 2;
void* begin = (void*)ALIGN_PREV((uintptr_t)end - size, 32);
void* object = (void*)ALIGN_PREV((intptr_t)begin - sizeof(JUTExternalFB), 32);
@@ -777,8 +783,9 @@ void JUTException::createFB() {
for (int i = 0; i < 3; i++) {
u32 start = VIGetRetraceCount();
while (start == VIGetRetraceCount())
;
while (start == VIGetRetraceCount()) {
// nop
}
}
mFrameMemory = (JUTExternalFB*)object;
@@ -892,68 +899,74 @@ bool JUTException::queryMapAddress_single(char* mapPath, u32 address, s32 sectio
if (section_id >= 0 && section_id != section_idx)
continue;
int length;
int length;
while (true) {
if ((length = file.fgets(buffer, ARRAY_SIZEU(buffer))) <= 4) {
break;
}
if (length >= 28) {
u32 addr;
if (buffer[28] == '4') {
addr = ((buffer[18] - '0') << 28) | strtol(buffer + 19, NULL, 16);
int size = strtol(buffer + 11, NULL, 16);
if ((addr <= address && address < addr + size)) {
if (out_addr) {
*out_addr = addr;
}
while (true) {
if ((length = file.fgets(buffer, ARRAY_SIZEU(buffer))) <= 4)
break;
if ((length < 28))
continue;
if (buffer[28] == '4') {
u32 addr = ((buffer[18] - '0') << 28) | strtol(buffer + 19, NULL, 16);
int size = strtol(buffer + 11, NULL, 16);
if ((addr <= address && address < addr + size)) {
if (out_addr)
*out_addr = addr;
if (out_size) {
*out_size = size;
}
if (out_size)
*out_size = size;
if (out_line) {
const u8* src = (const u8*)&buffer[30];
u8* dst = (u8*)out_line;
u32 i = 0;
if (out_line) {
const u8* src = (const u8*)&buffer[0x1e];
u8* dst = (u8*)out_line;
u32 i = 0;
for (i = 0; i < line_length - 1; src++) {
if ((u8)*src < (u32)' ' && *src != (u32)'\t') {
break;
}
if ((*src == ' ' || *src == (u32)'\t') && (i != 0)) {
if (dst[-1] != ' ') {
*dst = ' ';
dst++;
i++;
}
} else {
*dst++ = *src;
i++;
}
}
if (i != 0 && dst[-1] == ' ') {
dst--;
i--;
}
(void)*src; // needed to match debug
*dst = 0;
if (print) {
if (begin_with_newline) {
sConsole->print("\n");
}
sConsole->print_f(" [%08X]: .%s [%08X: %XH]\n %s\n", address,
section_name, addr, size, out_line);
begin_with_newline = false;
}
}
result = true;
break;
}
}
}
}
for (i = 0; i < line_length - 1; ++src) {
if ((u32)(*src) < ' ' && (u32)*src != '\t')
break;
if ((*src == ' ' || (u32)*src == '\t') && (i != 0)) {
if (dst[-1] != ' ') {
*dst = ' ';
dst++;
++i;
}
} else {
*dst++ = *src;
i++;
}
}
if (i != 0 && dst[-1] == ' ') {
dst--;
i--;
}
*dst = 0;
if (print) {
if (begin_with_newline) {
sConsole->print("\n");
}
sConsole->print_f(" [%08X]: .%s [%08X: %XH]\n %s\n", address, section_name, addr, size, out_line);
begin_with_newline = false;
}
}
result = true;
break;
}
}
if (result || (section_id >= 0 && section_id == section_idx)) {
if (print && begin_with_newline) {
sConsole->print("\n");
}
break;
}
if (!result && (section_id < 0 || section_id != section_idx)) {
continue;
}
if (print && begin_with_newline) {
sConsole->print("\n");
}
break;
}
file.fclose();
@@ -961,7 +974,7 @@ bool JUTException::queryMapAddress_single(char* mapPath, u32 address, s32 sectio
}
void JUTException::createConsole(void* console_buffer, u32 console_buffer_size) {
if (!console_buffer || !console_buffer_size) {
if (console_buffer == NULL || console_buffer_size == 0) {
return;
}
+3 -4
View File
@@ -35,15 +35,14 @@ f32 JUTFont::drawString_size_scale(f32 a1, f32 a2, f32 a3, f32 a4, const char* s
bool a7) {
f32 temp = a1;
for (; usz > 0; --usz, ++str) {
u32 c = *(u8*)str;
u32 b = c;
for (; usz != 0; --usz, ++str) {
s32 b = (u8)*str;
if (isLeadByte(b)) {
JUT_ASSERT(114, usz >= 2);
usz--;
str++;
b <<= 8;
b |= *(u8*)str;
b |= (u8)*str;
}
a1 += drawChar_scale(a1, a2, a3, a4, b, a7);
+12 -12
View File
@@ -391,26 +391,26 @@ u32 JUTGamePad::CStick::update(s8 x, s8 y, JUTGamePad::EStickMode mode,
}
u32 JUTGamePad::CStick::getButton(u32 buttons) {
u32 button = buttons & 0xF;
u32 button = buttons & (PAD_BUTTON_UP | PAD_BUTTON_DOWN | PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT);
if (-sReleasePoint < mPosX && mPosX < sReleasePoint) {
button = button & ~0x3;
button &= ~(PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT);
} else if (mPosX <= -sPressPoint) {
button = (button & ~0x2);
button |= 1;
button &= ~PAD_BUTTON_RIGHT;
button |= PAD_BUTTON_LEFT;
} else if (mPosX >= sPressPoint) {
button = (button & ~0x1);
button |= 2;
button &= ~PAD_BUTTON_LEFT;
button |= PAD_BUTTON_RIGHT;
}
if (-sReleasePoint < mPosY && mPosY < sReleasePoint) {
button = button & ~0xC;
button &= ~(PAD_BUTTON_UP | PAD_BUTTON_DOWN);
} else if (mPosY <= -sPressPoint) {
button = (button & ~0x8);
button |= 4;
button &= ~PAD_BUTTON_UP;
button |= PAD_BUTTON_DOWN;
} else if (mPosY >= sPressPoint) {
button = (button & ~0x4);
button |= 8;
button &= ~PAD_BUTTON_DOWN;
button |= PAD_BUTTON_UP;
}
return button;
@@ -481,7 +481,7 @@ void JUTGamePad::CRumble::update(s16 port) {
return;
} else {
bool enabled = getNumBit(mPattern, mFrame % mFrameCount);
u8 status = mStatus[port] != false;
u32 status = mStatus[port] != false;
if (enabled && !status) {
startMotor(port);
+8 -7
View File
@@ -9,16 +9,16 @@ static bool data_804514B8;
JUTGraphFifo* JUTGraphFifo::sCurrentFifo;
JUTGraphFifo::JUTGraphFifo(u32 size) {
mSize = size + 0x1F & ~0x1F;
mSize = ROUND(size, 0x20);
if (data_804514B8) {
u32 r29 = sizeof(GXFifoObj);
mFifo = (GXFifoObj*)JKRAllocFromSysHeap(mSize + r29, 32);
mBase = (u8*)mFifo + r29;
u32 fifoSize = sizeof(GXFifoObj);
mFifo = (GXFifoObj*)JKRAllocFromSysHeap(fifoSize + mSize, 32);
mBase = (u8*)mFifo + fifoSize;
GXInitFifoBase(mFifo, mBase, mSize);
GXInitFifoPtrs(mFifo, mBase, mBase);
} else {
mBase = JKRAllocFromSysHeap(mSize + 0xA0, 32);
mBase = (void*)((intptr_t)mBase + 0x1F & ~0x1F);
mBase = (void*)ROUND((intptr_t)mBase, 0x20);
mFifo = GXInit(mBase, mSize);
GXSetColorUpdate(GX_ENABLE);
data_804514B8 = true;
@@ -31,8 +31,9 @@ bool JUTGraphFifo::mGpStatus[5];
JUTGraphFifo::~JUTGraphFifo() {
sCurrentFifo->save();
do {
} while (isGPActive());
while (isGPActive()) {
// nop
}
if (sCurrentFifo == this) {
sCurrentFifo = NULL;
+2 -2
View File
@@ -9,8 +9,8 @@ void JUTPalette::storeTLUT(GXTlut param_0, ResTLUT* tlut) {
OSPanic("JUTPalette.cpp", 35, "JUTTexture: TLUT is NULL\n");
}
mTlutName = param_0;
mFormat = tlut->format;
mTransparency = tlut->transparency;
mFormat = (const u8)tlut->format;
mTransparency = (const u8)tlut->transparency;
mNumColors = tlut->numColors;
mColorTable = (ResTLUT*)((u8*)tlut + 0x20);
GXInitTlutObj(&mTlutObj, (void*)mColorTable, (GXTlutFmt)mFormat, mNumColors);
+18 -10
View File
@@ -81,8 +81,9 @@ void JUTProcBar::adjustMeterLength(u32 param_0, f32* param_1, f32 param_2, f32 p
int* param_4) {
BOOL var2 = false;
float var1 = *param_1;
u32 frameDuration = 16666;
while (var1 > param_2) {
if (param_0 * var1 * 20.0f / 16666.0f <= mParams.mWidth - 30.0f)
if (param_0 * var1 * 20.0f / frameDuration <= mParams.mWidth - 30.0f)
break;
var1 -= (1.0f / 10.0f);
@@ -98,7 +99,7 @@ void JUTProcBar::adjustMeterLength(u32 param_0, f32* param_1, f32 param_2, f32 p
(*param_4)++;
if (*param_4 < 0x1e)
break;
if ((param_0 * var1 * 20.0f / 16666.0f) < (mParams.mWidth - 60.0f))
if ((param_0 * var1 * 20.0f / frameDuration) < (mParams.mWidth - 60.0f))
var1 += (1.0f / 5.0f);
break;
}
@@ -113,10 +114,13 @@ void JUTProcBar::draw() {
void JUTProcBar::drawProcessBar() {
if (mVisible) {
int frameDuration = 16666; // duration in miliseconds? for how long a frame takes,
if (JUTVideo::getManager() && ((JUTVideo::getManager()->getRenderMode()->viTVmode >> 2) &
0x0f) == 1) // possibly a define
frameDuration = 20000; // duration for PAL
if (JUTVideo::getManager()) {
int viMode = JUTVideo::getManager()->getRenderMode()->viTVmode;
int viMode2 = ((viMode >> 2) & 0x0f);
if (viMode2 == 1) { // possibly a define
frameDuration = 20000; // duration for PAL
}
}
static int cnt = 0;
adjustMeterLength(mWholeLoop.mCost, &oneFrameRate, 1.0f, 10.0f, &cnt);
int r28 = oneFrameRate * 20.0f;
@@ -168,14 +172,15 @@ void JUTProcBar::drawProcessBar() {
int r21 = mParams.mPosX + 1;
bar_subroutine(r21, r22, r26, r28, frameDuration, gpuTime, -1,
JUtility::TColor(80, 255, 80, 255), JUtility::TColor(80, 255, 80, 255));
int thingy1 = gpuTime * r28 / frameDuration + r21; // inline or define?
J2DFillBox(thingy1, r22, mGpWait.calcBarSize(r28, frameDuration), r26,
J2DFillBox((int)(gpuTime * r28 / frameDuration + r21), r22,
(int)(mGpWait.mCost * r28 / frameDuration), r26,
JUtility::TColor(0, 255, 0, 255));
int r30 = mGp.calcBarSize(r28, frameDuration) + r21;
int r30 = mGp.mCost * r28 / frameDuration + r21;
r21 += totalTime * r28 / frameDuration;
r22 += mParams.mBarWidth * 2;
bar_subroutine(r21, r22, r26, r28, frameDuration, mCpu.mCost, -1,
JUtility::TColor(255, 80, 80, 255), JUtility::TColor(255, 80, 80, 255));
r21 += mCpu.mCost * r28 / frameDuration;
r22 += mParams.mBarWidth * 2;
bar_subroutine(r30, r22, r26, r28, frameDuration, mIdle.mCost, -1,
JUtility::TColor(180, 180, 160, 255),
@@ -192,6 +197,7 @@ void JUTProcBar::drawProcessBar() {
u32 temp3 = 0;
for (int i = 0; i < 8; i++) {
CTime* time = &mUsers[i];
u32 sp17c = time->mCost;
if (++time->field_0xc >= 0x10 || time->mCost > time->field_0x8) {
time->field_0x8 = time->mCost;
time->field_0xc = 0;
@@ -199,7 +205,8 @@ void JUTProcBar::drawProcessBar() {
if (time->field_0x8 > temp3)
temp3 = time->field_0x8;
}
if ((bool)temp3 == true) {
bool sp11 = temp3 ? true : false;
if (sp11 == true) {
static int cntUser = 0;
adjustMeterLength(temp3, &oneFrameRateUser, 1.0f, 10.0f, &cntUser);
int r21 = oneFrameRateUser * 20.0f;
@@ -209,6 +216,7 @@ void JUTProcBar::drawProcessBar() {
JUtility::TColor(50, 50, 150, 255), 6);
for (int i = 0; i < 8; i++) {
CTime* time = &mUsers[i];
int unsued = time->mCost;
if (++time->field_0xc >= 0x10 || time->mCost > time->field_0x8) {
time->field_0x8 = time->mCost;
time->field_0xc = 0;
+43 -46
View File
@@ -90,9 +90,8 @@ void JUTResFont::countBlock() {
mMap1BlockNum = 0;
u8* pData = (u8*)&mResFont->data;
for (u32 i = 0; i < mResFont->numBlocks; i++, pData += ((BlockHeader*)pData)->size) {
u32 magic = ((BlockHeader*)pData)->magic;
switch (magic) {
for (u32 i = 0; i < mResFont->numBlocks; i++) {
switch (((BlockHeader*)pData)->magic) {
case 'WID1':
mWid1BlockNum++;
break;
@@ -107,6 +106,7 @@ void JUTResFont::countBlock() {
default:
JUTReportConsole("JUTResFont: Unknown data block\n");
}
pData += ((BlockHeader*)pData)->size;
}
}
@@ -117,20 +117,18 @@ IsLeadByte_func const JUTResFont::saoAboutEncoding_[3] = {
};
void JUTResFont::setBlock() {
s32 widthNum, glyphNum, mapNum;
widthNum = 0;
glyphNum = 0;
mapNum = 0;
s32 widthNum = 0;
s32 glyphNum = 0;
s32 mapNum = 0;
u32 u;
mMaxCode = -1;
BlockHeader* data = (BlockHeader*)mResFont->data;
for (u32 i = 0; i < mResFont->numBlocks;
data = (BlockHeader*)((u8*)data + data->size), i++) {
u32 magic = data->magic;
switch (magic) {
BlockHeader* data = (BlockHeader*)mResFont->data;
for (u32 i = 0; i < mResFont->numBlocks; i++) {
switch (data->magic) {
case 'INF1': {
mInf1Ptr = (ResFONT::INF1*)data;
u32 u = mInf1Ptr->fontType;
u = mInf1Ptr->fontType;
JUT_ASSERT(244, u < suAboutEncoding_);
mIsLeadByte = &saoAboutEncoding_[u];
break;
@@ -158,6 +156,7 @@ void JUTResFont::setBlock() {
JUTReportConsole("Unknown data block\n");
break;
}
data = (BlockHeader*)(((Ptr)data) + data->size);
}
}
@@ -214,8 +213,8 @@ void JUTResFont::setGX(JUtility::TColor col1, JUtility::TColor col2) {
f32 JUTResFont::drawChar_scale(f32 pos_x, f32 pos_y, f32 scale_x, f32 scale_y, int str_int,
bool flag) {
f32 x1;
f32 y1;
f32 x2;
f32 y1;
JUT_ASSERT(378, mValid);
JUTFont::TWidth width;
@@ -339,48 +338,44 @@ int JUTResFont::getFontCode(int chr) const {
int ret = mInf1Ptr->defaultCode;
if ((getFontType() == 2) && (mMaxCode >= 0x8000U) && (chr >= 0x20) && (chr < 0x7FU)) {
chr = halftofull[chr - 32];
chr = (halftofull - 0x20)[chr];
}
for (int i = 0; i < mMap1BlockNum; i++) {
u16 sc = mpMapBlocks[i]->startCode;
u16 ec = mpMapBlocks[i]->endCode;
u16 mm = mpMapBlocks[i]->mappingMethod;
if ((sc <= chr) && (chr <= ec)) {
if (mm == 0) {
ret = chr - sc;
break;
} else if (mm == 2) {
if ((mpMapBlocks[i]->startCode <= chr) && (chr <= mpMapBlocks[i]->endCode)) {
if (mpMapBlocks[i]->mappingMethod == 0) {
ret = chr - mpMapBlocks[i]->startCode;
} else if (mpMapBlocks[i]->mappingMethod == 2) {
BE(u16)* leading_temp = &mpMapBlocks[i]->mLeading;
ret = leading_temp[chr - sc];
break;
} else if (mm == 3) {
BE(u16)* leading_temp = &mpMapBlocks[i]->mLeading;
int phi_r5 = 0;
int phi_r6_2 = mpMapBlocks[i]->numEntries - 1;
ret = leading_temp[chr - mpMapBlocks[i]->startCode];
} else if (mpMapBlocks[i]->mappingMethod == 3) {
// invented struct to help match debug, unsure of real struct
struct paired_u16 {
BE(u16) fullChar;
BE(u16) fontCode;
};
while (phi_r6_2 >= phi_r5) {
int temp_r7 = (phi_r6_2 + phi_r5) / 2;
paired_u16* leading_temp = (paired_u16*)&mpMapBlocks[i]->mLeading;
int binarySearchMin = 0;
int binarySearchMax = mpMapBlocks[i]->numEntries - 1;
if (chr < leading_temp[temp_r7 * 2]) {
phi_r6_2 = temp_r7 - 1;
continue;
while (binarySearchMax >= binarySearchMin) {
int midIndex = (binarySearchMax + binarySearchMin) / 2;
if (chr < leading_temp[midIndex].fullChar) {
binarySearchMax = midIndex - 1;
} else if (chr > leading_temp[midIndex].fullChar) {
binarySearchMin = midIndex + 1;
} else {
ret = leading_temp[midIndex].fontCode;
break;
}
if (chr > leading_temp[temp_r7 * 2]) {
phi_r5 = temp_r7 + 1;
continue;
}
ret = leading_temp[temp_r7 * 2 + 1];
break;
}
} else if (mm == 1) {
} else if (mpMapBlocks[i]->mappingMethod == 1) {
BE(u16)* phi_r5_2 = NULL;
if (mpMapBlocks[i]->numEntries == 1) {
phi_r5_2 = &mpMapBlocks[i]->mLeading;
}
ret = convertSjis(chr, phi_r5_2);
break;
}
break;
}
@@ -421,8 +416,10 @@ void JUTResFont::loadImage(int code, GXTexMapID id){
if (pageIdx != mTexPageIdx || i != field_0x66)
{
GXInitTexObj(&mTexObj, &mpGlyphBlocks[i]->data[pageIdx * texSize], texW,
texH, (GXTexFmt)texFmt, GX_CLAMP, GX_CLAMP, 0);
void* pImg = &mpGlyphBlocks[i]->data[pageIdx * mpGlyphBlocks[i]->textureSize];
GXInitTexObj(&mTexObj, pImg, mpGlyphBlocks[i]->textureWidth,
mpGlyphBlocks[i]->textureHeight, (GXTexFmt)(u16)mpGlyphBlocks[i]->textureFormat,
GX_CLAMP, GX_CLAMP, 0);
GXInitTexObjLOD(&mTexObj, GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, 0U, 0U, GX_ANISO_1);
mTexPageIdx = pageIdx;
+4 -3
View File
@@ -19,11 +19,12 @@ void* JUTResReference::getResource(JSUInputStream* stream, u32 resType, JKRArchi
void* JUTResReference::getResource(const void* data, u32 resType, JKRArchive* archive) {
mType = *(u8*)data;
mNameLength = *((u8*)data + 1);
const u8* pData = (const u8*)data;
mType = pData[0];
mNameLength = pData[1];
if (mNameLength != 0) {
memcpy(&mName, &((u8*)data)[2], mNameLength);
memcpy(&mName, &pData[2], mNameLength);
}
if (mType == RESTYPE_Unk2 || mType == RESTYPE_Unk3 || mType == RESTYPE_Unk4) {
+2 -12
View File
@@ -139,12 +139,7 @@ void JUTTexture::init() {
}
void JUTTexture::initTexObj() {
GXBool mipmapEnabled;
if (mTexInfo->mipmapEnabled != 0) {
mipmapEnabled = 1;
} else {
mipmapEnabled = 0;
}
GXBool mipmapEnabled = mTexInfo->mipmapEnabled != 0 ? GX_TRUE : GX_FALSE;
u8* image = ((u8*)mTexInfo);
u32 imgOffset = RES_U32(mTexInfo->imageOffset);
image += (imgOffset ? imgOffset : 0x20);
@@ -157,12 +152,7 @@ void JUTTexture::initTexObj() {
}
void JUTTexture::initTexObj(GXTlut param_0) {
GXBool mipmapEnabled;
if (mTexInfo->mipmapEnabled != 0) {
mipmapEnabled = 1;
} else {
mipmapEnabled = 0;
}
GXBool mipmapEnabled = mTexInfo->mipmapEnabled != 0 ? GX_TRUE : GX_FALSE;
mTlutName = param_0;
u8* image = ((u8*)mTexInfo);
u32 imgOffset = RES_U32(mTexInfo->imageOffset); // Swap!