summaryrefslogtreecommitdiff
path: root/src/JSystem/J3DGraphBase
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2025-09-04 07:56:59 -0700
committerGitHub <noreply@github.com>2025-09-04 17:56:59 +0300
commitb45a089e15d79821b07be020db628e01a49b1fd2 (patch)
tree948057548cc19b19d644bd4f300ca6434e6bff11 /src/JSystem/J3DGraphBase
parentee8b843996f4d888903f8c125b95ec1af376877e (diff)
some J3D/misc cleanup (#2628)
* some j3d cleanup * begin using uintptr_t * j3dgraphbase cleanup * j3dgraphanimator cleanup
Diffstat (limited to 'src/JSystem/J3DGraphBase')
-rw-r--r--src/JSystem/J3DGraphBase/J3DDrawBuffer.cpp199
-rw-r--r--src/JSystem/J3DGraphBase/J3DGD.cpp703
-rw-r--r--src/JSystem/J3DGraphBase/J3DMatBlock.cpp426
-rw-r--r--src/JSystem/J3DGraphBase/J3DMaterial.cpp333
-rw-r--r--src/JSystem/J3DGraphBase/J3DPacket.cpp221
-rw-r--r--src/JSystem/J3DGraphBase/J3DShape.cpp114
-rw-r--r--src/JSystem/J3DGraphBase/J3DShapeDraw.cpp24
-rw-r--r--src/JSystem/J3DGraphBase/J3DShapeMtx.cpp161
-rw-r--r--src/JSystem/J3DGraphBase/J3DSys.cpp137
-rw-r--r--src/JSystem/J3DGraphBase/J3DTevs.cpp82
-rw-r--r--src/JSystem/J3DGraphBase/J3DTexture.cpp32
-rw-r--r--src/JSystem/J3DGraphBase/J3DTransform.cpp85
-rw-r--r--src/JSystem/J3DGraphBase/J3DVertex.cpp68
13 files changed, 1365 insertions, 1220 deletions
diff --git a/src/JSystem/J3DGraphBase/J3DDrawBuffer.cpp b/src/JSystem/J3DGraphBase/J3DDrawBuffer.cpp
index 52a31e0d57..b1321abfb9 100644
--- a/src/JSystem/J3DGraphBase/J3DDrawBuffer.cpp
+++ b/src/JSystem/J3DGraphBase/J3DDrawBuffer.cpp
@@ -8,26 +8,27 @@
#include "JSystem/JKernel/JKRHeap.h"
void J3DDrawBuffer::calcZRatio() {
- mZRatio = (mZFar - mZNear) / (f32)mBufSize;
+ mZRatio = (mZFar - mZNear) / (f32)mEntryTableSize;
}
void J3DDrawBuffer::initialize() {
- mDrawType = DRAW_HEAD;
- mSortType = SORT_MAT;
+ mDrawMode = J3DDrawBufDrawMode_Head;
+ mSortMode = J3DDrawBufSortMode_Mat;
mZNear = 1.0f;
mZFar = 10000.0f;
mpZMtx = NULL;
mpCallBackPacket = NULL;
- mBufSize = 0x20;
+ mEntryTableSize = 0x20;
calcZRatio();
}
-J3DError J3DDrawBuffer::allocBuffer(u32 bufSize) {
- mpBuf = new (0x20) J3DPacket*[bufSize];
- if (mpBuf == NULL)
+int J3DDrawBuffer::allocBuffer(u32 size) {
+ mpBuffer = new (0x20) J3DPacket*[size];
+ if (mpBuffer == NULL)
return kJ3DError_Alloc;
- mBufSize = bufSize;
+ mEntryTableSize = size;
+
frameInit();
calcZRatio();
return kJ3DError_Success;
@@ -36,15 +37,15 @@ J3DError J3DDrawBuffer::allocBuffer(u32 bufSize) {
J3DDrawBuffer::~J3DDrawBuffer() {
frameInit();
- delete[] mpBuf;
- mpBuf = NULL;
+ delete[] mpBuffer;
+ mpBuffer = NULL;
}
/* 80325068-8032509C 31F9A8 0034+00 2/2 1/1 0/0 .text frameInit__13J3DDrawBufferFv */
void J3DDrawBuffer::frameInit() {
- u32 bufSize = mBufSize;
+ u32 bufSize = mEntryTableSize;
for (u32 i = 0; i < bufSize; i++)
- mpBuf[i] = NULL;
+ mpBuffer[i] = NULL;
mpCallBackPacket = NULL;
}
@@ -52,80 +53,89 @@ void J3DDrawBuffer::frameInit() {
/* 8032509C-803251E4 31F9DC 0148+00 2/1 0/0 0/0 .text
* entryMatSort__13J3DDrawBufferFP12J3DMatPacket */
int J3DDrawBuffer::entryMatSort(J3DMatPacket* pMatPacket) {
+ J3D_ASSERT_NULLPTR(122, pMatPacket != NULL);
+
pMatPacket->drawClear();
pMatPacket->getShapePacket()->drawClear();
if (pMatPacket->isChanged()) {
- pMatPacket->setNextPacket(mpBuf[0]);
- mpBuf[0] = pMatPacket;
+ pMatPacket->setNextPacket(mpBuffer[0]);
+ mpBuffer[0] = pMatPacket;
return 1;
}
- J3DTexture* texture = j3dSys.getTexture();
- u32 hash;
+ J3DTexture* pTexture = j3dSys.getTexture();
u16 texNo = pMatPacket->getMaterial()->getTexNo(0);
+ J3D_ASSERT_NULLPTR(150, pTexture != NULL);
+
+ u32 hash;
if (texNo == 0xFFFF) {
hash = 0;
} else {
- hash = ((u32)texture->getResTIMG(texNo) + texture->getResTIMG(texNo)->imageOffset) >> 5;
+ hash = ((uintptr_t)pTexture->getResTIMG(texNo) + pTexture->getResTIMG(texNo)->imageOffset) >> 5;
}
- u32 slot = hash & (mBufSize - 1);
+ u32 slot = hash & (mEntryTableSize - 1);
- if (mpBuf[slot] == NULL) {
- mpBuf[slot] = pMatPacket;
+ if (mpBuffer[slot] == NULL) {
+ mpBuffer[slot] = pMatPacket;
return 1;
- } else {
- for (J3DMatPacket* pkt = (J3DMatPacket*)mpBuf[slot]; pkt != NULL;
- pkt = (J3DMatPacket*)pkt->getNextPacket())
- {
- if (pkt->isSame(pMatPacket)) {
- pkt->addShapePacket(pMatPacket->getShapePacket());
- return 0;
- }
- }
+ }
- pMatPacket->setNextPacket(mpBuf[slot]);
- mpBuf[slot] = pMatPacket;
- return 1;
+ J3DMatPacket* packet;
+ for (packet = (J3DMatPacket*)mpBuffer[slot]; packet != NULL; packet = (J3DMatPacket*)packet->getNextPacket())
+ {
+ if (packet->isSame(pMatPacket)) {
+ packet->addShapePacket(pMatPacket->getShapePacket());
+ return 0;
+ }
}
+
+ pMatPacket->setNextPacket(mpBuffer[slot]);
+ mpBuffer[slot] = pMatPacket;
+ return 1;
}
/* 803251E4-8032529C 31FB24 00B8+00 1/0 0/0 0/0 .text
* entryMatAnmSort__13J3DDrawBufferFP12J3DMatPacket */
int J3DDrawBuffer::entryMatAnmSort(J3DMatPacket* pMatPacket) {
+ J3D_ASSERT_NULLPTR(199, pMatPacket != NULL);
+
J3DMaterialAnm* pMaterialAnm = pMatPacket->mpMaterialAnm;
- u32 slot = (u32)pMaterialAnm & (mBufSize - 1);
+ u32 slot = (uintptr_t)pMaterialAnm & (mEntryTableSize - 1);
if (pMaterialAnm == NULL) {
return entryMatSort(pMatPacket);
- } else {
- pMatPacket->drawClear();
- pMatPacket->getShapePacket()->drawClear();
- if (mpBuf[slot] == NULL) {
- mpBuf[slot] = pMatPacket;
- return 1;
- } else {
- for (J3DMatPacket* pkt = (J3DMatPacket*)mpBuf[slot]; pkt != NULL;
- pkt = (J3DMatPacket*)pkt->getNextPacket())
- {
- if (pkt->mpMaterialAnm == pMaterialAnm) {
- pkt->addShapePacket(pMatPacket->getShapePacket());
- return 0;
- }
- }
-
- pMatPacket->setNextPacket(mpBuf[slot]);
- mpBuf[slot] = pMatPacket;
- return 1;
+ }
+
+ pMatPacket->drawClear();
+ pMatPacket->getShapePacket()->drawClear();
+
+ if (mpBuffer[slot] == NULL) {
+ mpBuffer[slot] = pMatPacket;
+ return 1;
+ }
+
+ J3DMatPacket* packet;
+ for (packet = (J3DMatPacket*)mpBuffer[slot]; packet != NULL; packet = (J3DMatPacket*)packet->getNextPacket())
+ {
+ if (packet->mpMaterialAnm == pMaterialAnm) {
+ packet->addShapePacket(pMatPacket->getShapePacket());
+ return 0;
}
}
+
+ pMatPacket->setNextPacket(mpBuffer[slot]);
+ mpBuffer[slot] = pMatPacket;
+ return 1;
}
/* 8032529C-803253B4 31FBDC 0118+00 1/0 0/0 0/0 .text entryZSort__13J3DDrawBufferFP12J3DMatPacket
*/
-int J3DDrawBuffer::entryZSort(J3DMatPacket* i_packet) {
- i_packet->drawClear();
- i_packet->getShapePacket()->drawClear();
+int J3DDrawBuffer::entryZSort(J3DMatPacket* pMatPacket) {
+ J3D_ASSERT_NULLPTR(257, pMatPacket != NULL);
+
+ pMatPacket->drawClear();
+ pMatPacket->getShapePacket()->drawClear();
Vec tmp;
tmp.x = mpZMtx[0][3];
@@ -134,32 +144,33 @@ int J3DDrawBuffer::entryZSort(J3DMatPacket* i_packet) {
f32 value = -J3DCalcZValue(j3dSys.getViewMtx(), tmp);
- u32 uvar4;
+ u32 index;
if (mZNear + mZRatio < value) {
if (mZFar - mZRatio > value) {
- uvar4 = value / mZRatio;
+ index = value / mZRatio;
} else {
- uvar4 = mBufSize - 1;
+ index = mEntryTableSize - 1;
}
} else {
- uvar4 = 0;
+ index = 0;
}
- u32 idx = (mBufSize - 1) - uvar4;
- i_packet->setNextPacket(mpBuf[idx]);
- mpBuf[idx] = i_packet;
-
+ index = (mEntryTableSize - 1) - index;
+ pMatPacket->setNextPacket(mpBuffer[index]);
+ mpBuffer[index] = pMatPacket;
return 1;
}
/* 803253B4-80325404 31FCF4 0050+00 1/0 0/0 0/0 .text
* entryModelSort__13J3DDrawBufferFP12J3DMatPacket */
-int J3DDrawBuffer::entryModelSort(J3DMatPacket* i_packet) {
- i_packet->drawClear();
- i_packet->getShapePacket()->drawClear();
+int J3DDrawBuffer::entryModelSort(J3DMatPacket* pMatPacket) {
+ J3D_ASSERT_NULLPTR(316, pMatPacket != NULL);
+
+ pMatPacket->drawClear();
+ pMatPacket->getShapePacket()->drawClear();
if (mpCallBackPacket != NULL) {
- mpCallBackPacket->addChildPacket(i_packet);
+ mpCallBackPacket->addChildPacket(pMatPacket);
return 1;
}
@@ -168,57 +179,67 @@ int J3DDrawBuffer::entryModelSort(J3DMatPacket* i_packet) {
/* 80325404-80325458 31FD44 0054+00 1/0 0/0 0/0 .text
* entryInvalidSort__13J3DDrawBufferFP12J3DMatPacket */
-int J3DDrawBuffer::entryInvalidSort(J3DMatPacket* i_packet) {
- i_packet->drawClear();
- i_packet->getShapePacket()->drawClear();
+int J3DDrawBuffer::entryInvalidSort(J3DMatPacket* pMatPacket) {
+ J3D_ASSERT_NULLPTR(343, pMatPacket != NULL);
+
+ pMatPacket->drawClear();
+ pMatPacket->getShapePacket()->drawClear();
if (mpCallBackPacket != NULL) {
- mpCallBackPacket->addChildPacket(i_packet->getShapePacket());
+ mpCallBackPacket->addChildPacket(pMatPacket->getShapePacket());
return 1;
}
return 0;
}
-int J3DDrawBuffer::entryNonSort(J3DMatPacket* i_packet) {
- i_packet->drawClear();
- i_packet->mpShapePacket->drawClear();
+int J3DDrawBuffer::entryNonSort(J3DMatPacket* pMatPacket) {
+ J3D_ASSERT_NULLPTR(370, pMatPacket != NULL);
- i_packet->setNextPacket(mpBuf[0]);
- mpBuf[0] = i_packet;
+ pMatPacket->drawClear();
+ pMatPacket->getShapePacket()->drawClear();
+ pMatPacket->setNextPacket(mpBuffer[0]);
+ mpBuffer[0] = pMatPacket;
return 1;
}
-int J3DDrawBuffer::entryImm(J3DPacket* i_packet, u16 index) {
- i_packet->setNextPacket(mpBuf[index]);
- mpBuf[index] = i_packet;
+int J3DDrawBuffer::entryImm(J3DPacket* pPacket, u16 index) {
+ J3D_ASSERT_NULLPTR(394, pPacket != NULL);
+ J3D_ASSERT_RANGE(395, index < mEntryTableSize);
+ pPacket->setNextPacket(mpBuffer[index]);
+ mpBuffer[index] = pPacket;
return 1;
}
/* 803CEC30-803CEC78 02BD50 0048+00 0/1 1/1 0/0 .data sortFuncTable__13J3DDrawBuffer */
-sortFunc J3DDrawBuffer::sortFuncTable[6] = {
+J3DDrawBuffer::sortFunc J3DDrawBuffer::sortFuncTable[6] = {
&J3DDrawBuffer::entryMatSort, &J3DDrawBuffer::entryMatAnmSort, &J3DDrawBuffer::entryZSort,
&J3DDrawBuffer::entryModelSort, &J3DDrawBuffer::entryInvalidSort, &J3DDrawBuffer::entryNonSort,
};
/* 803CEC90-803CECA8 02BDB0 0018+00 1/2 0/0 0/0 .data drawFuncTable__13J3DDrawBuffer */
-drawFunc J3DDrawBuffer::drawFuncTable[2] = {
+J3DDrawBuffer::drawFunc J3DDrawBuffer::drawFuncTable[2] = {
&J3DDrawBuffer::drawHead,
&J3DDrawBuffer::drawTail,
};
+/* 804515E0-804515E8 000AE0 0004+04 0/0 1/1 0/0 .sbss entryNum__13J3DDrawBuffer */
+int J3DDrawBuffer::entryNum;
+
/* 803254AC-80325500 31FDEC 0054+00 0/0 2/2 0/0 .text draw__13J3DDrawBufferCFv */
void J3DDrawBuffer::draw() const {
- drawFunc func = drawFuncTable[mDrawType];
+ J3D_ASSERT_RANGE(411, mDrawMode < J3DDrawBufDrawMode_MAX);
+
+ drawFunc func = drawFuncTable[mDrawMode];
(this->*func)();
}
/* 80325500-80325578 31FE40 0078+00 1/0 0/0 0/0 .text drawHead__13J3DDrawBufferCFv */
void J3DDrawBuffer::drawHead() const {
- u32 size = mBufSize;
- J3DPacket** buf = mpBuf;
+ u32 size = mEntryTableSize;
+ J3DPacket** buf = mpBuffer;
for (u32 i = 0; i < size; i++) {
for (J3DPacket* packet = buf[i]; packet != NULL; packet = packet->getNextPacket()) {
@@ -229,15 +250,9 @@ void J3DDrawBuffer::drawHead() const {
/* 80325578-803255F0 31FEB8 0078+00 1/0 0/0 0/0 .text drawTail__13J3DDrawBufferCFv */
void J3DDrawBuffer::drawTail() const {
- int num = mBufSize - 1;
-
- for (int i = num; i >= 0; i--) {
- for (J3DPacket* packet = mpBuf[i]; packet != NULL; packet = packet->getNextPacket()) {
+ for (int i = mEntryTableSize - 1; i >= 0; i--) {
+ for (J3DPacket* packet = mpBuffer[i]; packet != NULL; packet = packet->getNextPacket()) {
packet->draw();
}
}
}
-
-/* ############################################################################################## */
-/* 804515E0-804515E8 000AE0 0004+04 0/0 1/1 0/0 .sbss entryNum__13J3DDrawBuffer */
-int J3DDrawBuffer::entryNum; \ No newline at end of file
diff --git a/src/JSystem/J3DGraphBase/J3DGD.cpp b/src/JSystem/J3DGraphBase/J3DGD.cpp
index 2bb4e24c82..018e8d5418 100644
--- a/src/JSystem/J3DGraphBase/J3DGD.cpp
+++ b/src/JSystem/J3DGraphBase/J3DGD.cpp
@@ -3,29 +3,28 @@
//
#include "JSystem/J3DGraphBase/J3DGD.h"
-#include "dolphin/gd.h"
-#include "dolphin/os.h"
+#include "JSystem/J3DGraphBase/J3DFifo.h"
/* 8030D098-8030D210 3079D8 0178+00 0/0 1/1 0/0 .text J3DGDSetGenMode__FUcUcUcUc11_GXCullMode */
-void J3DGDSetGenMode(u8 texGenNum, u8 colorChanNum, u8 tevStageNum, u8 indTexStageNum,
- GXCullMode cullMode) {
- GDOverflowCheck(0xa);
- J3DGDWriteBPCmd(0xfe07fc3f);
+void J3DGDSetGenMode(u8 nTexGens, u8 nChans, u8 nTevs, u8 nInds,
+ GXCullMode cm) {
static u8 cm2hw[4] = {0, 2, 1, 3};
- J3DGDWriteBPCmd(texGenNum | colorChanNum << 4 | (tevStageNum - 1) << 0xa |
- cm2hw[cullMode] << 0xe | indTexStageNum << 0x10);
+
+ GDOverflowCheck(10);
+ J3DGDWriteBPCmd(0xFE07FC3F);
+ J3DGDWriteBPCmd(BP_GEN_MODE(nTexGens, nChans, nTevs - 1, cm2hw[cm], nInds));
}
/* 8030D210-8030D364 307B50 0154+00 0/0 1/1 0/0 .text J3DGDSetGenMode_3Param__FUcUcUc */
-void J3DGDSetGenMode_3Param(u8 texGenNum, u8 tevStageNum, u8 indTexStageNum) {
- GDOverflowCheck(0xa);
- J3DGDWriteBPCmd(0xfe073c0f);
- J3DGDWriteBPCmd(texGenNum | (tevStageNum - 1) << 0xa | indTexStageNum << 0x10);
+void J3DGDSetGenMode_3Param(u8 nTexGens, u8 nTevs, u8 nInds) {
+ GDOverflowCheck(10);
+ J3DGDWriteBPCmd(0xFE073C0F);
+ J3DGDWriteBPCmd(BP_GEN_MODE(nTexGens, 0, nTevs - 1, 0, nInds));
}
/* 8030D364-8030D65C 307CA4 02F8+00 0/0 1/1 0/0 .text J3DGDSetLightAttn__F10_GXLightIDffffff */
-void J3DGDSetLightAttn(GXLightID id, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32 k2) {
- J3DGDWriteXFCmdHdr(0x0604 + __GDLightID2Offset(id), 6);
+void J3DGDSetLightAttn(GXLightID light, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32 k2) {
+ J3DGDWriteXFCmdHdr(XF_LIGHT_ATTN_ID + __GDLightID2Offset(light), 6);
J3DGDWrite_f32(a0);
J3DGDWrite_f32(a1);
J3DGDWrite_f32(a2);
@@ -36,15 +35,15 @@ void J3DGDSetLightAttn(GXLightID id, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32
/* 8030D65C-8030D76C 307F9C 0110+00 0/0 1/1 0/0 .text J3DGDSetLightColor__F10_GXLightID8_GXColor
*/
-void J3DGDSetLightColor(GXLightID id, GXColor color) {
- J3DGDWriteXFCmd(0x0603 + __GDLightID2Offset(id),
+void J3DGDSetLightColor(GXLightID light, GXColor color) {
+ J3DGDWriteXFCmd(XF_LIGHT_COLOR_ID + __GDLightID2Offset(light),
(color.r << 24) | (color.g << 16) | (color.b << 8) | (color.a << 0));
}
/* 8030D76C-8030D938 3080AC 01CC+00 0/0 1/1 0/0 .text J3DGDSetLightPos__F10_GXLightIDfff
*/
-void J3DGDSetLightPos(GXLightID id, f32 x, f32 y, f32 z) {
- J3DGDWriteXFCmdHdr(0x060A + __GDLightID2Offset(id), 3);
+void J3DGDSetLightPos(GXLightID light, f32 x, f32 y, f32 z) {
+ J3DGDWriteXFCmdHdr(XF_LIGHT_POS_ID + __GDLightID2Offset(light), 3);
J3DGDWrite_f32(x);
J3DGDWrite_f32(y);
J3DGDWrite_f32(z);
@@ -52,223 +51,241 @@ void J3DGDSetLightPos(GXLightID id, f32 x, f32 y, f32 z) {
/* 8030D938-8030DB04 308278 01CC+00 0/0 1/1 0/0 .text J3DGDSetLightDir__F10_GXLightIDfff
*/
-void J3DGDSetLightDir(GXLightID id, f32 x, f32 y, f32 z) {
- J3DGDWriteXFCmdHdr(0x060D + __GDLightID2Offset(id), 3);
- J3DGDWrite_f32(x);
- J3DGDWrite_f32(y);
- J3DGDWrite_f32(z);
+void J3DGDSetLightDir(GXLightID light, f32 nx, f32 ny, f32 nz) {
+ J3DGDWriteXFCmdHdr(XF_LIGHT_DIR_ID + __GDLightID2Offset(light), 3);
+ J3DGDWrite_f32(nx);
+ J3DGDWrite_f32(ny);
+ J3DGDWrite_f32(nz);
}
/* 8030DB04-8030E064 308444 0560+00 1/0 1/1 0/0 .text
* J3DGDSetVtxAttrFmtv__F9_GXVtxFmtPC17_GXVtxAttrFmtListb */
-void J3DGDSetVtxAttrFmtv(GXVtxFmt fmt, GXVtxAttrFmtList const* fmtList, bool param_2) {
- u32 pos_cnt = GX_POS_XYZ;
- u32 pos_type = GX_F32;
- u32 pos_shift = 0;
- u32 nrm_cnt = GX_NRM_XYZ;
- u32 nrm_type = GX_F32;
- u32 local_34 = 0;
- u32 clr0_cnt = GX_CLR_RGBA;
- u32 clr0_type = GX_RGBA8;
- u32 clr1_cnt = GX_CLR_RGBA;
- u32 clr1_type = GX_RGBA8;
- u32 tex0_cnt = GX_TEX_ST;
- u32 tex0_type = GX_F32;
- u32 tex0_shift = 0;
- u32 tex1_cnt = GX_TEX_ST;
- u32 tex1_type = GX_F32;
- u32 tex1_shift = 0;
- u32 tex2_cnt = GX_TEX_ST;
- u32 tex2_type = GX_F32;
- u32 tex2_shift = 0;
- u32 tex3_cnt = GX_TEX_ST;
- u32 tex3_type = GX_F32;
- u32 tex3_shift = 0;
- u32 tex4_cnt = GX_TEX_ST;
- u32 tex4_type = GX_F32;
- u32 tex4_shift = 0;
- u32 tex5_cnt = GX_TEX_ST;
- u32 tex5_type = GX_F32;
- u32 tex5_shift = 0;
- u32 tex6_cnt = GX_TEX_ST;
- u32 tex6_type = GX_F32;
- u32 tex6_shift = 0;
- u32 tex7_cnt = GX_TEX_ST;
- u32 tex7_type = GX_F32;
- u32 tex7_shift = 0;
- for (; fmtList->attr != GX_VA_NULL; fmtList++) {
- switch (fmtList->attr) {
+void J3DGDSetVtxAttrFmtv(GXVtxFmt vtxfmt, const GXVtxAttrFmtList* list, bool param_2) {
+ u32 posCnt = GX_POS_XYZ;
+ u32 posType = GX_F32;
+ u32 posFrac = 0;
+
+ u32 nrmCnt = GX_NRM_XYZ;
+ u32 nrmType = GX_F32;
+ u32 nrmIdx3 = 0;
+
+ u32 c0Cnt = GX_CLR_RGBA;
+ u32 c0Type = GX_RGBA8;
+
+ u32 c1Cnt = GX_CLR_RGBA;
+ u32 c1Type = GX_RGBA8;
+
+ u32 tx0Cnt = GX_TEX_ST;
+ u32 tx0Type = GX_F32;
+ u32 tx0Frac = 0;
+
+ u32 tx1Cnt = GX_TEX_ST;
+ u32 tx1Type = GX_F32;
+ u32 tx1Frac = 0;
+
+ u32 tx2Cnt = GX_TEX_ST;
+ u32 tx2Type = GX_F32;
+ u32 tx2Frac = 0;
+
+ u32 tx3Cnt = GX_TEX_ST;
+ u32 tx3Type = GX_F32;
+ u32 tx3Frac = 0;
+
+ u32 tx4Cnt = GX_TEX_ST;
+ u32 tx4Type = GX_F32;
+ u32 tx4Frac = 0;
+
+ u32 tx5Cnt = GX_TEX_ST;
+ u32 tx5Type = GX_F32;
+ u32 tx5Frac = 0;
+
+ u32 tx6Cnt = GX_TEX_ST;
+ u32 tx6Type = GX_F32;
+ u32 tx6Frac = 0;
+
+ u32 tx7Cnt = GX_TEX_ST;
+ u32 tx7Type = GX_F32;
+ u32 tx7Frac = 0;
+
+ ASSERTMSGLINE(240, vtxfmt < GX_MAX_VTXFMT, "GDSetVtxAttrFmtv: invalid vtx fmt");
+
+ for (; list->attr != GX_VA_NULL; ++list) {
+ ASSERTMSGLINE(245, list->attr >= GX_VA_POS && list->attr <= GX_VA_TEX7, "GDSetVtxAttrFmtv: invalid attribute");
+ ASSERTMSGLINE(246, list->frac < 32, "GDSetVtxAttrFmtv: invalid frac value");
+
+ switch (list->attr) {
case GX_VA_POS:
- pos_cnt = fmtList->cnt;
- pos_type = fmtList->type;
- pos_shift = fmtList->frac;
+ posCnt = list->cnt;
+ posType = list->type;
+ posFrac = list->frac;
break;
case GX_VA_NRM:
case GX_VA_NBT:
- nrm_type = fmtList->type;
- if (fmtList->cnt == GX_NRM_NBT3) {
- nrm_cnt = GX_NRM_NBT;
- local_34 = 1;
+ nrmType = list->type;
+ if (list->cnt == GX_NRM_NBT3) {
+ nrmCnt = GX_NRM_NBT;
+ nrmIdx3 = 1;
} else {
if (param_2) {
- nrm_cnt = GX_NRM_NBT;
+ nrmCnt = GX_NRM_NBT;
} else {
- nrm_cnt = fmtList->cnt;
+ nrmCnt = list->cnt;
}
- local_34 = 0;
+ nrmIdx3 = 0;
}
break;
case GX_VA_CLR0:
- clr0_cnt = fmtList->cnt;
- clr0_type = fmtList->type;
+ c0Cnt = list->cnt;
+ c0Type = list->type;
break;
case GX_VA_CLR1:
- clr1_cnt = fmtList->cnt;
- clr1_type = fmtList->type;
+ c1Cnt = list->cnt;
+ c1Type = list->type;
break;
case GX_VA_TEX0:
- tex0_cnt = fmtList->cnt;
- tex0_type = fmtList->type;
- tex0_shift = fmtList->frac;
+ tx0Cnt = list->cnt;
+ tx0Type = list->type;
+ tx0Frac = list->frac;
break;
case GX_VA_TEX1:
- tex1_cnt = fmtList->cnt;
- tex1_type = fmtList->type;
- tex1_shift = fmtList->frac;
+ tx1Cnt = list->cnt;
+ tx1Type = list->type;
+ tx1Frac = list->frac;
break;
case GX_VA_TEX2:
- tex2_cnt = fmtList->cnt;
- tex2_type = fmtList->type;
- tex2_shift = fmtList->frac;
+ tx2Cnt = list->cnt;
+ tx2Type = list->type;
+ tx2Frac = list->frac;
break;
case GX_VA_TEX3:
- tex3_cnt = fmtList->cnt;
- tex3_type = fmtList->type;
- tex3_shift = fmtList->frac;
+ tx3Cnt = list->cnt;
+ tx3Type = list->type;
+ tx3Frac = list->frac;
break;
case GX_VA_TEX4:
- tex4_cnt = fmtList->cnt;
- tex4_type = fmtList->type;
- tex4_shift = fmtList->frac;
+ tx4Cnt = list->cnt;
+ tx4Type = list->type;
+ tx4Frac = list->frac;
break;
case GX_VA_TEX5:
- tex5_cnt = fmtList->cnt;
- tex5_type = fmtList->type;
- tex5_shift = fmtList->frac;
+ tx5Cnt = list->cnt;
+ tx5Type = list->type;
+ tx5Frac = list->frac;
break;
case GX_VA_TEX6:
- tex6_cnt = fmtList->cnt;
- tex6_type = fmtList->type;
- tex6_shift = fmtList->frac;
+ tx6Cnt = list->cnt;
+ tx6Type = list->type;
+ tx6Frac = list->frac;
break;
case GX_VA_TEX7:
- tex7_cnt = fmtList->cnt;
- tex7_type = fmtList->type;
- tex7_shift = fmtList->frac;
- break;
+ tx7Cnt = list->cnt;
+ tx7Type = list->type;
+ tx7Frac = list->frac;
}
}
- GDOverflowCheck(0x12);
- J3DGDWriteCPCmd(CP_REG_VAT_GRP0_ID + fmt,
- pos_cnt | pos_type << 1 | pos_shift << 4 | nrm_cnt << 9 | nrm_type << 0xa |
- clr0_cnt << 0xd | clr0_type << 0xe | clr1_cnt << 0x11 | clr1_type << 0x12 |
- tex0_cnt << 0x15 | tex0_type << 0x16 | tex0_shift << 0x19 | 0x40000000 |
- local_34 << 0x1f);
- J3DGDWriteCPCmd(CP_REG_VAT_GRP1_ID + fmt,
- tex1_cnt | tex1_type << 1 | tex1_shift << 4 | tex2_cnt << 9 | tex2_type << 0xa |
- tex2_shift << 0xd | tex3_cnt << 0x12 | tex3_type << 0x13 |
- tex3_shift << 0x16 | tex4_cnt << 0x1b | tex4_type << 0x1c | 0x80000000);
- J3DGDWriteCPCmd(CP_REG_VAT_GRP2_ID + fmt,
- tex4_shift | tex5_cnt << 5 | tex5_type << 6 | tex5_shift << 9 |
- tex6_cnt << 0xe | tex6_type << 0xf | tex6_shift << 0x12 | tex7_cnt << 0x17 |
- tex7_type << 0x18 | tex7_shift << 0x1b);
+
+ GDOverflowCheck(18);
+ J3DGDWriteCPCmd(vtxfmt + CP_REG_VAT_GRP0_ID, CP_REG_VAT_GRP0(posCnt, posType, posFrac, nrmCnt, nrmType, c0Cnt, c0Type, c1Cnt, c1Type, tx0Cnt, tx0Type, tx0Frac, 1, nrmIdx3));
+ J3DGDWriteCPCmd(vtxfmt + CP_REG_VAT_GRP1_ID, CP_REG_VAT_GRP1(tx1Cnt, tx1Type, tx1Frac, tx2Cnt, tx2Type, tx2Frac, tx3Cnt, tx3Type, tx3Frac, tx4Cnt, tx4Type, 1));
+ J3DGDWriteCPCmd(vtxfmt + CP_REG_VAT_GRP2_ID, CP_REG_VAT_GRP2(tx4Frac, tx5Cnt, tx5Type, tx5Frac, tx6Cnt, tx6Type, tx6Frac, tx7Cnt, tx7Type, tx7Frac));
}
/* 8030E064-8030E234 3089A4 01D0+00 1/0 1/1 0/0 .text
* J3DGDSetTexCoordGen__F13_GXTexGenType12_GXTexGenSrc */
-void J3DGDSetTexCoordGen(GXTexGenType texGenType, GXTexGenSrc texGenSrc) {
- u32 input_form = 0;
- u32 proj_type = 0;
- u32 src_row = 5;
- u32 bump_src_tex = 5;
- u32 bump_src_light = 0;
- u32 texgen_type;
- switch (texGenSrc) {
+void J3DGDSetTexCoordGen(GXTexGenType func, GXTexGenSrc src_param) {
+ u32 tgType;
+ u32 form;
+ u32 proj;
+ u32 row;
+ u32 embossRow;
+ u32 embossLit;
+
+ form = 0;
+ proj = 0;
+ row = 5;
+ embossRow = 5;
+ embossLit = 0;
+
+ switch(src_param) {
case GX_TG_POS:
- src_row = 0;
- input_form = 1;
+ row = 0;
+ form = 1;
break;
case GX_TG_NRM:
- src_row = 1;
- input_form = 1;
+ row = 1;
+ form = 1;
break;
case GX_TG_BINRM:
- src_row = 3;
- input_form = 1;
+ row = 3;
+ form = 1;
break;
case GX_TG_TANGENT:
- src_row = 4;
- input_form = 1;
+ row = 4;
+ form = 1;
break;
case GX_TG_COLOR0:
- src_row = 2;
+ row = 2;
break;
case GX_TG_COLOR1:
- src_row = 2;
+ row = 2;
break;
case GX_TG_TEX0:
- src_row = 5;
+ row = 5;
break;
case GX_TG_TEX1:
- src_row = 6;
+ row = 6;
break;
case GX_TG_TEX2:
- src_row = 7;
+ row = 7;
break;
case GX_TG_TEX3:
- src_row = 8;
+ row = 8;
break;
case GX_TG_TEX4:
- src_row = 9;
+ row = 9;
break;
case GX_TG_TEX5:
- src_row = 10;
+ row = 10;
break;
case GX_TG_TEX6:
- src_row = 11;
+ row = 11;
break;
case GX_TG_TEX7:
- src_row = 12;
+ row = 12;
break;
case GX_TG_TEXCOORD0:
- bump_src_tex = 0;
+ embossRow = 0;
break;
case GX_TG_TEXCOORD1:
- bump_src_tex = 1;
+ embossRow = 1;
break;
case GX_TG_TEXCOORD2:
- bump_src_tex = 2;
+ embossRow = 2;
break;
case GX_TG_TEXCOORD3:
- bump_src_tex = 3;
+ embossRow = 3;
break;
case GX_TG_TEXCOORD4:
- bump_src_tex = 4;
+ embossRow = 4;
break;
case GX_TG_TEXCOORD5:
- bump_src_tex = 5;
+ embossRow = 5;
break;
case GX_TG_TEXCOORD6:
- bump_src_tex = 6;
+ embossRow = 6;
+ break;
+ default:
+ ASSERTMSGLINE(433, 0, "GDSetTexCoordGen: invalid texgen source");
break;
}
- switch (texGenType) {
+
+ switch (func) {
case GX_TG_MTX2x4:
- texgen_type = 0;
+ tgType = 0;
break;
case GX_TG_MTX3x4:
- texgen_type = 0;
- proj_type = 1;
+ tgType = 0;
+ proj = 1;
break;
case GX_TG_BUMP0:
case GX_TG_BUMP1:
@@ -278,34 +295,33 @@ void J3DGDSetTexCoordGen(GXTexGenType texGenType, GXTexGenSrc texGenSrc) {
case GX_TG_BUMP5:
case GX_TG_BUMP6:
case GX_TG_BUMP7:
- texgen_type = 1;
- bump_src_light = texGenType - 2;
+ ASSERTMSGLINE(457, src_param >= GX_TG_TEXCOORD0 && src_param <= GX_TG_TEXCOORD6, "GDSetTexCoordGen: invalid emboss source");
+ tgType = 1;
+ embossLit = func - GX_TG_BUMP0;
break;
case GX_TG_SRTG:
- if (texGenSrc == GX_TG_COLOR0) {
- texgen_type = 2;
+ if (src_param == GX_TG_COLOR0) {
+ tgType = 2;
} else {
- texgen_type = 3;
+ tgType = 3;
}
break;
+ default:
+ ASSERTMSGLINE(473, 0, "GDSetTexCoordGen: invalid texgen function");
+ break;
}
- J3DGDWrite_u32(
- proj_type << (31 - GX_XF_TEX_PROJTYPE_END) | input_form << (31 - GX_XF_TEX_INPUTFORM_END) |
- texgen_type << (31 - GX_XF_TEX_TEXGENTYPE_END) | src_row << (31 - GX_XF_TEX_SRCROW_END) |
- bump_src_tex << (31 - GX_XF_TEX_BUMPSRCTEX_END) |
- bump_src_light << (31 - GX_XF_TEX_BUMPSRCLIGHT_END));
+
+ J3DGDWrite_u32(XF_REG_TEX(proj, form, tgType, row, embossRow, embossLit));
}
/* 8030E234-8030E438 308B74 0204+00 0/0 16/16 0/0 .text
* J3DGDSetTexCoordScale2__F13_GXTexCoordIDUsUcUcUsUcUc */
-void J3DGDSetTexCoordScale2(GXTexCoordID param_0, u16 param_1, u8 param_2, u8 param_3, u16 param_4,
- u8 param_5, u8 param_6) {
- GDOverflowCheck(0xf);
- J3DGDWriteBPCmd(0xfe03ffff);
- J3DGDWriteBPCmd((param_1 - 1) | param_2 << 0x10 | param_3 << 0x11 |
- (param_0 * 2 + 0x30) << 0x18);
- J3DGDWriteBPCmd((param_4 - 1) | param_5 << 0x10 | param_6 << 0x11 |
- (param_0 * 2 + 0x31) << 0x18);
+void J3DGDSetTexCoordScale2(GXTexCoordID coord, u16 s_scale, u8 s_bias,
+ u8 s_wrap, u16 t_scale, u8 t_bias, u8 t_wrap) {
+ GDOverflowCheck(15);
+ J3DGDWriteBPCmd(0xFE03FFFF);
+ J3DGDWriteBPCmd(BP_TEXCOORD_S_SCALE(s_scale - 1, s_bias, s_wrap, 0, 0, coord * 2 + 0x30));
+ J3DGDWriteBPCmd(BP_TEXCOORD_T_SCALE(t_scale - 1, t_bias, t_wrap, coord * 2 + 0x31));
}
/* 8045090C-80450914 00038C 0008+00 1/1 0/0 0/0 .sdata J3DGDTexMode0Ids */
@@ -341,228 +357,308 @@ static u8 GX2HWFiltConv[6] = {
/* 8030E438-8030E5D4 308D78 019C+00 0/0 1/1 0/0 .text
* J3DGDSetTexLookupMode__F11_GXTexMapID14_GXTexWrapMode14_GXTexWrapMode12_GXTexFilter12_GXTexFilterfffUcUc13_GXAnisotropy
*/
-void J3DGDSetTexLookupMode(GXTexMapID param_0, GXTexWrapMode param_1, GXTexWrapMode param_2,
- GXTexFilter param_3, GXTexFilter param_4, f32 param_5, f32 param_6,
- f32 param_7, u8 param_8, u8 param_9, GXAnisotropy param_10) {
- J3DGDWriteBPCmd(param_1 | param_2 << 2 | (param_4 == GX_LINEAR) << 4 |
- GX2HWFiltConv[param_3] << 5 | (param_9 == 0) << 8 |
- ((int)(param_7 * 32.0f) & 0xff) << 9 | param_10 << 0x13 | param_8 << 0x15 |
- J3DGDTexMode0Ids[param_0] << 0x18);
- J3DGDWriteBPCmd(((int)(param_5 * 16.0f) & 0xff) | ((int)(param_6 * 16.0f) & 0xff) << 8 |
- J3DGDTexMode1Ids[param_0] << 0x18);
+void J3DGDSetTexLookupMode(GXTexMapID id, GXTexWrapMode wrap_s,
+ GXTexWrapMode wrap_t, GXTexFilter min_filt,
+ GXTexFilter mag_filt, f32 min_lod, f32 max_lod,
+ f32 lod_bias, u8 bias_clamp, u8 do_edge_lod,
+ GXAnisotropy max_aniso) {
+ J3DGDWriteBPCmd(BP_TEX_MODE0(wrap_s, wrap_t, mag_filt == TRUE, GX2HWFiltConv[min_filt], !do_edge_lod, (u8)(32.0f * lod_bias), max_aniso, bias_clamp, J3DGDTexMode0Ids[id]));
+ J3DGDWriteBPCmd(BP_TEX_MODE1((u8)(16.0f * min_lod), (u8)(16.0f * max_lod), J3DGDTexMode1Ids[id]));
}
/* 8030E5D4-8030E67C 308F14 00A8+00 0/0 1/1 0/0 .text
* J3DGDSetTexImgAttr__F11_GXTexMapIDUsUs9_GXTexFmt */
-void J3DGDSetTexImgAttr(GXTexMapID param_0, u16 param_1, u16 param_2, GXTexFmt param_3) {
- J3DGDWriteBPCmd((param_1 - 1) | (param_2 - 1) << 0xa | param_3 << 0x14 |
- J3DGDTexImage0Ids[param_0] << 0x18);
+void J3DGDSetTexImgAttr(GXTexMapID id, u16 width, u16 height, GXTexFmt format) {
+ J3DGDWriteBPCmd(BP_IMAGE_ATTR(width - 1, height - 1, format, J3DGDTexImage0Ids[id]));
}
/* 8030E67C-8030E70C 308FBC 0090+00 0/0 1/1 0/0 .text J3DGDSetTexImgPtr__F11_GXTexMapIDPv
*/
-void J3DGDSetTexImgPtr(GXTexMapID param_0, void* param_1) {
- J3DGDWriteBPCmd(OSCachedToPhysical(param_1) >> 5 | J3DGDTexImage3Ids[param_0] << 0x18);
+void J3DGDSetTexImgPtr(GXTexMapID id, void* image_ptr) {
+ J3DGDWriteBPCmd(BP_IMAGE_PTR(OSCachedToPhysical(image_ptr) >> 5, J3DGDTexImage3Ids[id]));
}
/* 8030E70C-8030E7E0 30904C 00D4+00 0/0 1/1 0/0 .text J3DGDSetTexImgPtrRaw__F11_GXTexMapIDUl */
-void J3DGDSetTexImgPtrRaw(GXTexMapID param_0, u32 param_1) {
+void J3DGDSetTexImgPtrRaw(GXTexMapID id, u32 image_ptr_raw) {
GDOverflowCheck(5);
- J3DGDWriteBPCmd(param_1 | J3DGDTexImage3Ids[param_0] << 0x18);
+ J3DGDWriteBPCmd(BP_IMAGE_PTR(image_ptr_raw, J3DGDTexImage3Ids[id]));
}
/* 8030E7E0-8030E878 309120 0098+00 0/0 1/1 0/0 .text
* J3DGDSetTexTlut__F11_GXTexMapIDUl10_GXTlutFmt */
-void J3DGDSetTexTlut(GXTexMapID param_0, u32 param_1, GXTlutFmt param_2) {
- J3DGDWriteBPCmd((param_1 - 0x80000) >> 9 | param_2 << 0xa | J3DGDTexTlutIds[param_0] << 0x18);
+void J3DGDSetTexTlut(GXTexMapID id, u32 tmem_addr, GXTlutFmt format) {
+ J3DGDWriteBPCmd(BP_TEX_TLUT((tmem_addr - 0x80000) >> 9, format, J3DGDTexTlutIds[id]));
}
/* 8030E878-8030EB30 3091B8 02B8+00 0/0 1/1 0/0 .text J3DGDLoadTlut__FPvUl11_GXTlutSize
*/
-void J3DGDLoadTlut(void* param_0, u32 param_1, GXTlutSize param_2) {
- J3DGDWriteBPCmd(0xfeffff00);
- J3DGDWriteBPCmd(0x0f000000);
- J3DGDWriteBPCmd(OSCachedToPhysical(param_0) >> 5 | 0x64000000);
- J3DGDWriteBPCmd((param_1 - 0x80000) >> 9 | param_2 << 0xa | 0x65000000);
- J3DGDWriteBPCmd(0xfeffff00);
- J3DGDWriteBPCmd(0x0f000000);
+void J3DGDLoadTlut(void* tlut_ptr, u32 tmem_addr, GXTlutSize size) {
+ ASSERTMSGLINE(735, !(tmem_addr & 0x1ff), "GDLoadTlut: invalid TMEM pointer");
+ ASSERTMSGLINE(736, size <= 0x400, "GDLoadTlut: invalid TLUT size");
+
+ J3DGDWriteBPCmd(0xFEFFFF00);
+ J3DGDWriteBPCmd(0xF000000);
+ J3DGDWriteBPCmd(BP_LOAD_TLUT0(OSCachedToPhysical(tlut_ptr) >> 5, 0x64));
+ J3DGDWriteBPCmd(BP_LOAD_TLUT1((tmem_addr - 0x80000) >> 9, size, 0x65));
+ J3DGDWriteBPCmd(0xFEFFFF00);
+ J3DGDWriteBPCmd(0xF000000);
}
/* 8030EB30-8030EE10 309470 02E0+00 0/0 2/2 0/0 .text J3DGDSetIndTexMtx__F14_GXIndTexMtxIDPA3_fSc
*/
-void J3DGDSetIndTexMtx(GXIndTexMtxID id, Mtx3P mtx, s8 exp) {
- s32 mtx32[6];
- u32 idx;
+void J3DGDSetIndTexMtx(GXIndTexMtxID mtx_id, f32 offset[2][3], s8 scale_exp) {
+ s32 offsetS32[6];
+ u32 id_offset;
- switch (id) {
+ switch (mtx_id) {
case GX_ITM_0:
case GX_ITM_1:
case GX_ITM_2:
- idx = (u32)(id - GX_ITM_0);
+ id_offset = (u32)(mtx_id - GX_ITM_0);
break;
case GX_ITM_S0:
case GX_ITM_S1:
case GX_ITM_S2:
- idx = (u32)(id - GX_ITM_S0);
+ id_offset = (u32)(mtx_id - GX_ITM_S0);
break;
case GX_ITM_T0:
case GX_ITM_T1:
case GX_ITM_T2:
- idx = (u32)(id - GX_ITM_T0);
+ id_offset = (u32)(mtx_id - GX_ITM_T0);
break;
default:
- idx = 0;
+ id_offset = 0;
break;
}
- exp += 17;
-
- mtx32[0] = (s32)(mtx[0][0] * 1024.0f) & 0x7FF;
- mtx32[1] = (s32)(mtx[1][0] * 1024.0f) & 0x7FF;
+ offsetS32[0] = (s32)(offset[0][0] * 0x400) & 0x7FF;
+ offsetS32[1] = (s32)(offset[1][0] * 0x400) & 0x7FF;
- mtx32[2] = (s32)(mtx[0][1] * 1024.0f) & 0x7FF;
- mtx32[3] = (s32)(mtx[1][1] * 1024.0f) & 0x7FF;
+ offsetS32[2] = (s32)(offset[0][1] * 0x400) & 0x7FF;
+ offsetS32[3] = (s32)(offset[1][1] * 0x400) & 0x7FF;
- mtx32[4] = (s32)(mtx[0][2] * 1024.0f) & 0x7FF;
- mtx32[5] = (s32)(mtx[1][2] * 1024.0f) & 0x7FF;
+ offsetS32[4] = (s32)(offset[0][2] * 0x400) & 0x7FF;
+ offsetS32[5] = (s32)(offset[1][2] * 0x400) & 0x7FF;
+ scale_exp += (s8)17;
GDOverflowCheck(15);
- J3DGDWriteBPCmd((mtx32[0] << 0) | (mtx32[1] << 11) | (((exp >> 0) & 0x03) << 22) |
- (0x06 + idx * 3) << 24);
- J3DGDWriteBPCmd((mtx32[2] << 0) | (mtx32[3] << 11) | (((exp >> 2) & 0x03) << 22) |
- (0x07 + idx * 3) << 24);
- J3DGDWriteBPCmd((mtx32[4] << 0) | (mtx32[5] << 11) | (((exp >> 4) & 0x03) << 22) |
- (0x08 + idx * 3) << 24);
+ J3DGDWriteBPCmd(BP_IND_MTX(
+ offsetS32[0],
+ offsetS32[1],
+ scale_exp & 3,
+ 6 + id_offset * 3
+ ));
+
+ J3DGDWriteBPCmd(BP_IND_MTX(
+ offsetS32[2],
+ offsetS32[3],
+ (scale_exp >> 2) & 3,
+ 7 + id_offset * 3
+ ));
+
+ J3DGDWriteBPCmd(BP_IND_MTX(
+ offsetS32[4],
+ offsetS32[5],
+ (scale_exp >> 4) & 3,
+ 8 + id_offset * 3
+ ));
}
/* 8030EE10-8030EF08 309750 00F8+00 0/0 2/2 0/0 .text
* J3DGDSetIndTexCoordScale__F16_GXIndTexStageID14_GXIndTexScale14_GXIndTexScale14_GXIndTexScale14_GXIndTexScale
*/
-void J3DGDSetIndTexCoordScale(GXIndTexStageID stage, GXIndTexScale scale0, GXIndTexScale scale1,
- GXIndTexScale scale2, GXIndTexScale scale3) {
+void J3DGDSetIndTexCoordScale(GXIndTexStageID indStageEven, GXIndTexScale scaleS0,
+ GXIndTexScale scaleT0, GXIndTexScale scaleS1,
+ GXIndTexScale scaleT1) {
GDOverflowCheck(5);
- J3DGDWriteBPCmd(scale0 | scale1 << 4 | scale2 << 8 | scale3 << 0xc |
- ((stage >> 1) + GX_BP_REG_RAS1_SS0) << 0x18);
+ J3DGDWriteBPCmd(BP_IND_TEXCOORD_SCALE(
+ scaleS0,
+ scaleT0,
+ scaleS1,
+ scaleT1,
+ 0x25 + (indStageEven >> 1)
+ ));
}
/* 8030EF08-8030F108 309848 0200+00 0/0 2/2 0/0 .text
* J3DGDSetIndTexOrder__FUl13_GXTexCoordID11_GXTexMapID13_GXTexCoordID11_GXTexMapID13_GXTexCoordID11_GXTexMapID13_GXTexCoordID11_GXTexMapID
*/
-void J3DGDSetIndTexOrder(u32 count, GXTexCoordID coord0, GXTexMapID map0, GXTexCoordID coord1,
- GXTexMapID map1, GXTexCoordID coord2, GXTexMapID map2, GXTexCoordID coord3,
- GXTexMapID map3) {
- GDOverflowCheck(0xa);
- J3DGDWriteBPCmd(map0 & 7 | (coord0 & 7) << 3 | (map1 & 7) << 6 | (coord1 & 7) << 9 |
- (map2 & 7) << 0xc | (coord2 & 7) << 0xf | (map3 & 7) << 0x12 |
- (coord3 & 7) << 0x15 | GX_BP_REG_RAS1_IREF << 0x18);
- u32 imask = 0;
+void J3DGDSetIndTexOrder(u32 count, GXTexCoordID texCoord0, GXTexMapID texMap0,
+ GXTexCoordID texCoord1, GXTexMapID texMap1,
+ GXTexCoordID texCoord2, GXTexMapID texMap2,
+ GXTexCoordID texCoord3, GXTexMapID texMap3) {
+ GDOverflowCheck(10);
+ J3DGDWriteBPCmd(BP_IND_TEX_ORDER(
+ texMap0 & 7,
+ texCoord0 & 7,
+ texMap1 & 7,
+ texCoord1 & 7,
+ texMap2 & 7,
+ texCoord2 & 7,
+ texMap3 & 7,
+ texCoord3 & 7,
+ 0x27
+ ));
+
+ u32 mask = 0;
for (u32 i = 0; i < count; i++) {
switch (i) {
case 0:
- imask |= 1 << (map0 & 7);
+ mask |= 1 << (texMap0 & 7);
break;
case 1:
- imask |= 1 << (map1 & 7);
+ mask |= 1 << (texMap1 & 7);
break;
case 2:
- imask |= 1 << (map2 & 7);
+ mask |= 1 << (texMap2 & 7);
break;
case 3:
- imask |= 1 << (map3 & 7);
+ mask |= 1 << (texMap3 & 7);
break;
}
}
- J3DGDWriteBPCmd(imask | GX_BP_REG_INDIMASK << 0x18);
+
+ J3DGDWriteBPCmd(BP_IND_MASK(mask, 0xF));
}
/* 8030F108-8030F294 309A48 018C+00 0/0 9/9 0/0 .text
* J3DGDSetTevOrder__F13_GXTevStageID13_GXTexCoordID11_GXTexMapID12_GXChannelID13_GXTexCoordID11_GXTexMapID12_GXChannelID
*/
-void J3DGDSetTevOrder(GXTevStageID stage, GXTexCoordID coord0, GXTexMapID map0,
- GXChannelID channel0, GXTexCoordID coord1, GXTexMapID map1,
- GXChannelID channel1) {
- coord0 = coord0 >= GX_MAX_TEXCOORD ? GX_TEXCOORD0 : coord0;
- coord1 = coord1 >= GX_MAX_TEXCOORD ? GX_TEXCOORD0 : coord1;
- GDOverflowCheck(5);
+void J3DGDSetTevOrder(GXTevStageID evenStage, GXTexCoordID coord0, GXTexMapID map0,
+ GXChannelID color0, GXTexCoordID coord1, GXTexMapID map1,
+ GXChannelID color1) {
static u8 c2r[] = {0, 1, 0, 1, 0, 1, 7, 5, 6, 0, 0, 0, 0, 0, 0, 7};
- J3DGDWriteBPCmd((map0 & 7) | coord0 << 3 |
- (map0 != GX_TEXMAP_NULL && !(map0 & GX_TEX_DISABLE)) << 6 |
- c2r[channel0 & 0xf] << 7 | (map1 & 7) << 0xc | coord1 << 0xf |
- (map1 != GX_TEXMAP_NULL && !(map1 & GX_TEX_DISABLE)) << 0x12 |
- c2r[channel1 & 0xf] << 0x13 | (stage / 2 + GX_BP_REG_RAS1_TREF0) << 0x18);
+
+ GXTexCoordID coord0_ = coord0 >= GX_MAX_TEXCOORD ? GX_TEXCOORD0 : coord0;
+ GXTexCoordID coord1_ = coord1 >= GX_MAX_TEXCOORD ? GX_TEXCOORD0 : coord1;
+ GDOverflowCheck(5);
+ J3DGDWriteBPCmd(BP_TEV_ORDER(
+ map0 & 7,
+ coord0_,
+ map0 != GX_TEXMAP_NULL && !(map0 & GX_TEX_DISABLE),
+ c2r[color0 & 0xF],
+ map1 & 7,
+ coord1_,
+ map1 != GX_TEXMAP_NULL && !(map1 & GX_TEX_DISABLE),
+ c2r[color1 & 0xF],
+ evenStage / 2 + 0x28
+ ));
}
/* 8030F294-8030F3FC 309BD4 0168+00 0/0 11/11 0/0 .text
* J3DGDSetTevKColor__F14_GXTevKColorID8_GXColor */
-void J3DGDSetTevKColor(GXTevKColorID id, GXColor color) {
- u32 cmd0 = color.r | color.a << 0xc | 0x800000 | (id * 2 + GX_BP_REG_TEVREG0LO) << 0x18;
- u32 cmd1 = color.b | color.g << 0xc | 0x800000 | (id * 2 + GX_BP_REG_TEVREG0HI) << 0x18;
+void J3DGDSetTevKColor(GXTevKColorID reg, GXColor color) {
+ u32 regRA;
+ u32 regBG;
+
+ regRA = BP_TEV_COLOR_REG_RA(color.r, color.a, 1, 0xE0 + reg * 2);
+ regBG = BP_TEV_COLOR_REG_BG(color.b, color.g, 1, 0xE1 + reg * 2);
+
GDOverflowCheck(0xa);
- J3DGDWriteBPCmd(cmd0);
- J3DGDWriteBPCmd(cmd1);
+ J3DGDWriteBPCmd(regRA);
+ J3DGDWriteBPCmd(regBG);
}
/* 8030F3FC-8030F630 309D3C 0234+00 0/0 11/11 0/0 .text
* J3DGDSetTevColorS10__F11_GXTevRegID11_GXColorS10 */
-void J3DGDSetTevColorS10(GXTevRegID id, GXColorS10 color) {
- u32 cmd0 =
- (color.r & 0x7ff) | (color.a & 0x7ff) << 0xc | (id * 2 + GX_BP_REG_TEVREG0LO) << 0x18;
- u32 cmd1 =
- (color.b & 0x7ff) | (color.g & 0x7ff) << 0xc | (id * 2 + GX_BP_REG_TEVREG0HI) << 0x18;
+void J3DGDSetTevColorS10(GXTevRegID reg, GXColorS10 color) {
+ u32 regRA;
+ u32 regBG;
+
+ regRA = BP_TEV_COLOR_REG_RA(color.r & 0x7FF, color.a & 0x7FF, 0, 0xE0 + reg * 2);
+ regBG = BP_TEV_COLOR_REG_BG(color.b & 0x7FF, color.g & 0x7FF, 0, 0xE1 + reg * 2);
+
GDOverflowCheck(0x14);
- J3DGDWriteBPCmd(cmd0);
- J3DGDWriteBPCmd(cmd1);
- J3DGDWriteBPCmd(cmd1);
- J3DGDWriteBPCmd(cmd1);
+ J3DGDWriteBPCmd(regRA);
+ J3DGDWriteBPCmd(regBG);
+ J3DGDWriteBPCmd(regBG);
+ J3DGDWriteBPCmd(regBG);
}
/* 8030F630-8030F994 309F70 0364+00 0/0 3/3 0/0 .text J3DGDSetFog__F10_GXFogTypeffff8_GXColor */
-void J3DGDSetFog(GXFogType fogType, f32 param_1, f32 param_2, f32 nearZ, f32 farZ, GXColor color) {
- f32 fvar1, fvar2, fvar3;
- if (farZ == nearZ || param_2 == param_1) {
- fvar1 = 0.0f;
- fvar2 = 0.5f;
- fvar3 = 0.0f;
+void J3DGDSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor color) {
+ f32 A;
+ f32 B;
+ f32 B_mant;
+ f32 C;
+ f32 A_f;
+ u32 b_expn;
+ u32 b_m;
+ u32 a_hex;
+ u32 c_hex;
+
+ ASSERTMSGLINE(1036, farz >= 0.0f, "GDSetFog: The farz should be positive value");
+ ASSERTMSGLINE(1037, farz >= nearz, "GDSetFog: The farz should be larger than nearz");
+
+
+ if (farz == nearz || endz == startz) {
+ A = 0.0f;
+ B = 0.5f;
+ C = 0.0f;
} else {
- fvar1 = (farZ * nearZ) / ((farZ - nearZ) * (param_2 - param_1));
- fvar2 = farZ / (farZ - nearZ);
- fvar3 = param_1 / (param_2 - param_1);
+ A = (farz * nearz) / ((farz - nearz) * (endz - startz));
+ B = farz / (farz - nearz);
+ C = startz / (endz - startz);
}
- u32 shift = 1;
- for (; fvar2 > 1.0; fvar2 *= 0.5f) {
- shift++;
+
+ B_mant = B;
+ b_expn = 1;
+
+ while (B_mant > 1.0) {
+ B_mant *= 0.5f;
+ b_expn++;
}
- for (; fvar2 > 0.0f && fvar2 < 0.5; fvar2 *= 2.0f) {
- shift--;
+
+ while (B_mant > 0.0f && B_mant < 0.5) {
+ B_mant *= 2.0f;
+ b_expn--;
}
- f32 fvar4 = (fvar1 / (1 << shift));
- u32 param1 = fvar2 * 8388638.0f;
- u32 param0 = *(u32*)&fvar4;
- u32 param3 = *(u32*)&fvar3;
- J3DGDWriteBPCmd(param0 >> 0xc | GX_BP_REG_FOGPARAM0 << 0x18);
- J3DGDWriteBPCmd(param1 | GX_BP_REG_FOGPARAM1 << 0x18);
- J3DGDWriteBPCmd(shift | GX_BP_REG_FOGPARAM2 << 0x18);
- J3DGDWriteBPCmd(param3 >> 0xc | fogType << 0x15 | GX_BP_REG_FOGPARAM3 << 0x18);
- J3DGDWriteBPCmd(color.b | color.g << 8 | color.r << 0x10 | GX_BP_REG_FOGCOLOR << 0x18);
+
+ A_f = A / (1 << b_expn);
+ b_m = (u32) (8388638.0f * B_mant);
+
+ a_hex = *(u32*)&A_f;
+ c_hex = *(u32*)&C;
+
+ J3DGDWriteBPCmd(BP_FOG_UNK0(a_hex >> 12, 0xEE));
+ J3DGDWriteBPCmd(BP_FOG_UNK1(b_m, 0xEF));
+ J3DGDWriteBPCmd(BP_FOG_UNK2(b_expn, 0xF0));
+ J3DGDWriteBPCmd(BP_FOG_UNK3(c_hex >> 12, 0, type, 0xF1));
+ J3DGDWriteBPCmd(BP_FOG_COLOR(color.r, color.g, color.b, 0xF2));
}
+#define BP_FOG_RANGE_ADJ_K0(arg0, arg1, arg2) \
+ ( \
+ (u32)(arg2) << 24 | \
+ (u32)(arg1) << 12 | \
+ (u32)(arg0) << 0 \
+ )
+
+#define BP_FOG_RANGE_ADJ(arg0, arg1, arg2) \
+ ( \
+ (u32)(arg2) << 24 | \
+ (u32)(arg0) << 0 | \
+ (u32)(arg1) << 10 \
+ )
+
/* 8030F994-8030FAE0 30A2D4 014C+00 0/0 3/3 0/0 .text J3DGDSetFogRangeAdj__FUcUsP14_GXFogAdjTable
*/
-void J3DGDSetFogRangeAdj(u8 param_0, u16 param_1, GXFogAdjTable* table) {
- if (param_0 != 0) {
- for (int i = 0; i < 0xa; i += 2) {
- J3DGDWriteBPCmd((i / 2 + GX_BP_REG_FOGRANGEK0) << 0x18 | table->r[i + 1] << 0xc |
- table->r[i]);
+void J3DGDSetFogRangeAdj(GXBool enable, u16 center, GXFogAdjTable* table) {
+ if (enable) {
+ for (int i = 0; i < 10; i += 2) {
+ u32 range_adj = BP_FOG_RANGE_ADJ_K0(table->r[i], table->r[i + 1], i / 2 + 0xE9);
+ J3DGDWriteBPCmd(range_adj);
}
}
- u32 cmd = GX_BP_REG_FOGRANGE << 0x18 | (param_1 + 0x156) | param_0 << 0xa;
- J3DGDWriteBPCmd(cmd);
+
+ u32 range_c = BP_FOG_RANGE_ADJ(center + 342, enable, GX_BP_REG_FOGRANGE);
+ J3DGDWriteBPCmd(range_c);
}
/* 8030FAE0-8030FB60 30A420 0080+00 0/0 10/10 0/0 .text J3DFifoLoadPosMtxImm__FPA4_fUl */
-void J3DFifoLoadPosMtxImm(MtxP mtx, u32 addr) {
- J3DFifoWriteXFCmdHdr((addr & 0x3fff) << 2, 0xc);
+void J3DFifoLoadPosMtxImm(MtxP mtx, u32 id) {
+ J3DFifoWriteXFCmdHdr(4 * id, 12);
J3DGXCmd1f32ptr(&mtx[0][0]);
J3DGXCmd1f32ptr(&mtx[0][1]);
J3DGXCmd1f32ptr(&mtx[0][2]);
@@ -578,8 +674,8 @@ void J3DFifoLoadPosMtxImm(MtxP mtx, u32 addr) {
}
/* 8030FB60-8030FBCC 30A4A0 006C+00 0/0 9/9 0/0 .text J3DFifoLoadNrmMtxImm__FPA4_fUl */
-void J3DFifoLoadNrmMtxImm(MtxP mtx, u32 addr) {
- J3DFifoWriteXFCmdHdr(addr * 3 + 0x400, 9);
+void J3DFifoLoadNrmMtxImm(MtxP mtx, u32 id) {
+ J3DFifoWriteXFCmdHdr(id * 3 + 0x400, 9);
J3DGXCmd1f32ptr(&mtx[0][0]);
J3DGXCmd1f32ptr(&mtx[0][1]);
J3DGXCmd1f32ptr(&mtx[0][2]);
@@ -593,8 +689,8 @@ void J3DFifoLoadNrmMtxImm(MtxP mtx, u32 addr) {
/* 8030FBCC-8030FC38 30A50C 006C+00 0/0 3/3 0/0 .text J3DFifoLoadNrmMtxImm3x3__FPA3_fUl
*/
-void J3DFifoLoadNrmMtxImm3x3(Mtx3P mtx, u32 addr) {
- J3DFifoWriteXFCmdHdr(addr * 3 + 0x400, 9);
+void J3DFifoLoadNrmMtxImm3x3(Mtx3P mtx, u32 id) {
+ J3DFifoWriteXFCmdHdr(id * 3 + 0x400, 9);
J3DGXCmd1f32ptr(&mtx[0][0]);
J3DGXCmd1f32ptr(&mtx[0][1]);
J3DGXCmd1f32ptr(&mtx[0][2]);
@@ -608,8 +704,8 @@ void J3DFifoLoadNrmMtxImm3x3(Mtx3P mtx, u32 addr) {
/* 8030FC38-8030FCD0 30A578 0098+00 0/0 4/4 0/0 .text J3DFifoLoadNrmMtxToTexMtx__FPA4_fUl
*/
-void J3DFifoLoadNrmMtxToTexMtx(MtxP mtx, u32 addr) {
- J3DFifoWriteXFCmdHdr((addr & 0x3fff) << 2, 0xc);
+void J3DFifoLoadNrmMtxToTexMtx(MtxP mtx, u32 id) {
+ J3DFifoWriteXFCmdHdr(4 * id, 12);
J3DGXCmd1f32ptr(&mtx[0][0]);
J3DGXCmd1f32ptr(&mtx[0][1]);
J3DGXCmd1f32ptr(&mtx[0][2]);
@@ -625,8 +721,8 @@ void J3DFifoLoadNrmMtxToTexMtx(MtxP mtx, u32 addr) {
}
/* 8030FCD0-8030FD68 30A610 0098+00 0/0 2/2 0/0 .text J3DFifoLoadNrmMtxToTexMtx3x3__FPA3_fUl */
-void J3DFifoLoadNrmMtxToTexMtx3x3(Mtx3P mtx, u32 addr) {
- J3DFifoWriteXFCmdHdr((addr & 0x3fff) << 2, 0xc);
+void J3DFifoLoadNrmMtxToTexMtx3x3(Mtx3P mtx, u32 id) {
+ J3DFifoWriteXFCmdHdr(4 * id, 0xc);
J3DGXCmd1f32ptr(&mtx[0][0]);
J3DGXCmd1f32ptr(&mtx[0][1]);
J3DGXCmd1f32ptr(&mtx[0][2]);
@@ -653,12 +749,11 @@ static u8 J3DTexImage2Ids[8] = {
/* 8030FD68-8030FDE8 30A6A8 0080+00 0/0 1/1 0/0 .text
* J3DFifoLoadTexCached__F11_GXTexMapIDUl15_GXTexCacheSizeUl15_GXTexCacheSize */
-void J3DFifoLoadTexCached(GXTexMapID id, u32 param_1, GXTexCacheSize param_2, u32 param_3,
- GXTexCacheSize param_4) {
- J3DFifoLoadBPCmd(param_1 >> 5 | (param_2 + 3) << 0xf | (param_2 + 3) << 0x12 |
- J3DTexImage1Ids[id] << 0x18);
- if (param_4 != GX_TEXCACHE_NONE && param_3 < 0x100000) {
- J3DFifoLoadBPCmd(param_3 >> 5 | (param_4 + 3) << 0xf | (param_4 + 3) << 0x12 |
- J3DTexImage2Ids[id] << 0x18);
+void J3DFifoLoadTexCached(GXTexMapID id, u32 tmem_even, GXTexCacheSize size_even,
+ u32 tmem_odd, GXTexCacheSize size_odd) {
+ J3DFifoLoadBPCmd(BP_TEX_CACHE_EVEN(tmem_even >> 5, size_even + 3, size_even + 3, 0, J3DTexImage1Ids[id]));
+
+ if (size_odd != 3 && tmem_odd < 0x100000) {
+ J3DFifoLoadBPCmd(BP_TEX_CACHE_ODD(tmem_odd >> 5, size_odd + 3, size_odd + 3, J3DTexImage2Ids[id]));
}
}
diff --git a/src/JSystem/J3DGraphBase/J3DMatBlock.cpp b/src/JSystem/J3DGraphBase/J3DMatBlock.cpp
index c4076f9c25..776b0381de 100644
--- a/src/JSystem/J3DGraphBase/J3DMatBlock.cpp
+++ b/src/JSystem/J3DGraphBase/J3DMatBlock.cpp
@@ -1,15 +1,9 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DMatBlock
-//
-
#include "JSystem/J3DGraphBase/J3DMatBlock.h"
#include "JSystem/J3DGraphBase/J3DPacket.h"
#include "JSystem/J3DGraphBase/J3DSys.h"
#include "JSystem/J3DGraphBase/J3DTransform.h"
-#include "dolphin/os.h"
#include "global.h"
-#include "string.h"
+#include <string.h>
inline void loadMatColors(const J3DGXColor* color) {
J3DGDWriteXFCmdHdr(0x100C, 2);
@@ -38,7 +32,7 @@ inline void loadTevKColor(u32 reg, const J3DGXColor& color) {
/* 8031747C-803174DC 311DBC 0060+00 0/0 1/1 0/0 .text initialize__21J3DColorBlockLightOffFv */
void J3DColorBlockLightOff::initialize() {
mColorChanNum = 0;
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mMatColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mMatColor); i++) {
mMatColor[i] = j3dDefaultColInfo;
}
mMatColorOffset = 0;
@@ -48,10 +42,10 @@ void J3DColorBlockLightOff::initialize() {
/* 803174DC-80317580 311E1C 00A4+00 0/0 1/1 0/0 .text initialize__22J3DColorBlockAmbientOnFv */
void J3DColorBlockAmbientOn::initialize() {
mColorChanNum = 0;
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mMatColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mMatColor); i++) {
mMatColor[i] = j3dDefaultColInfo;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mAmbColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mAmbColor); i++) {
mAmbColor[i] = j3dDefaultAmbInfo;
}
mMatColorOffset = 0;
@@ -61,13 +55,13 @@ void J3DColorBlockAmbientOn::initialize() {
/* 80317580-80317644 311EC0 00C4+00 0/0 1/1 0/0 .text initialize__20J3DColorBlockLightOnFv */
void J3DColorBlockLightOn::initialize() {
mColorChanNum = 0;
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mMatColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mMatColor); i++) {
mMatColor[i] = j3dDefaultColInfo;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mAmbColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mAmbColor); i++) {
mAmbColor[i] = j3dDefaultAmbInfo;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mLight); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mLight); i++) {
mLight[i] = NULL;
}
mMatColorOffset = 0;
@@ -77,7 +71,7 @@ void J3DColorBlockLightOn::initialize() {
/* 80317644-80317674 311F84 0030+00 0/0 2/2 0/0 .text initialize__21J3DTexGenBlockPatchedFv */
void J3DTexGenBlockPatched::initialize() {
mTexGenNum = 0;
- for (s32 i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++)
mTexMtx[i] = NULL;
mTexMtxOffset = 0;
}
@@ -85,7 +79,7 @@ void J3DTexGenBlockPatched::initialize() {
/* 80317674-803176A4 311FB4 0030+00 0/0 1/1 0/0 .text initialize__15J3DTexGenBlock4Fv */
void J3DTexGenBlock4::initialize() {
mTexGenNum = 0;
- for (s32 i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
mTexMtx[i] = NULL;
mTexMtxOffset = 0;
}
@@ -94,7 +88,7 @@ void J3DTexGenBlock4::initialize() {
*/
void J3DTexGenBlockBasic::initialize() {
mTexGenNum = 0;
- for (s32 i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++)
mTexMtx[i] = NULL;
mTexMtxOffset = 0;
}
@@ -107,21 +101,22 @@ void J3DTevBlockNull::initialize() {
/* 803176E0-803177E8 312020 0108+00 0/0 1/1 0/0 .text initialize__18J3DTevBlockPatchedFv
*/
void J3DTevBlockPatched::initialize() {
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTexNo); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTexNo); i++) {
mTexNo[i] = 0xFFFF;
}
- for (s32 i = 0; i < ARRAY_SIZE(mTevStage); i++) {
+ for (int i = 0; i < ARRAY_SIZEU(mTevStage); i++) {
mTevStage[i].setStageNo(i);
}
- for (s32 i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
mTevColor[i] = j3dDefaultTevColor;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
mTevKColor[i] = j3dDefaultTevKColor;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColorSel); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTevKColorSel); i++) {
mTevKColorSel[i] = GX_TEV_KCSEL_K0;
}
+
mTevStageNum = 1;
mTexNoOffset = 0;
mTevRegOffset = 0;
@@ -147,12 +142,13 @@ void J3DTevBlock2::initialize() {
mTevKAlphaSel[0] = GX_TEV_KASEL_K0_A;
mTevKAlphaSel[1] = GX_TEV_KASEL_K0_A;
- for (s32 i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
mTevColor[i] = j3dDefaultTevColor;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
mTevKColor[i] = j3dDefaultTevKColor;
}
+
mTexNoOffset = 0;
mTevRegOffset = 0;
}
@@ -169,6 +165,7 @@ void J3DTevBlock4::initialize() {
mTevStage[1].setStageNo(1);
mTevStage[2].setStageNo(2);
mTevStage[3].setStageNo(3);
+
mTevKColorSel[0] = GX_TEV_KCSEL_K0;
mTevKColorSel[1] = GX_TEV_KCSEL_K0;
mTevKColorSel[2] = GX_TEV_KCSEL_K0;
@@ -178,37 +175,41 @@ void J3DTevBlock4::initialize() {
mTevKAlphaSel[2] = GX_TEV_KASEL_K0_A;
mTevKAlphaSel[3] = GX_TEV_KASEL_K0_A;
- for (s32 i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
mTevColor[i] = j3dDefaultTevColor;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
mTevKColor[i] = j3dDefaultTevKColor;
}
+
mTexNoOffset = 0;
mTevRegOffset = 0;
}
/* 80317A00-80317B28 312340 0128+00 0/0 1/1 0/0 .text initialize__13J3DTevBlock16Fv */
void J3DTevBlock16::initialize() {
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTexNo); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTexNo); i++) {
mTexNo[i] = 0xFFFF;
}
+
mTevStageNum = 1;
- for (s32 i = 0; i < 3; i++) {
+
+ for (int i = 0; i < 3; i++) {
mTevColor[i] = j3dDefaultTevColor;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
mTevKColor[i] = j3dDefaultTevKColor;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColorSel); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTevKColorSel); i++) {
mTevKColorSel[i] = GX_TEV_KCSEL_K0;
}
- for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColorSel); i++) {
+ for (int i = 0; i < ARRAY_SIZE(mTevKColorSel); i++) {
mTevKAlphaSel[i] = GX_TEV_KASEL_K0_A;
}
- for (s32 i = 0; i < ARRAY_SIZE(mTevStage); i++) {
+ for (int i = 0; i < ARRAY_SIZEU(mTevStage); i++) {
mTevStage[i].setStageNo(i);
}
+
mTexNoOffset = 0;
mTevRegOffset = 0;
}
@@ -324,10 +325,10 @@ s32 J3DPEBlockFull::countDLSize() {
}
/* 80450960-80450964 0003E0 0004+00 5/5 0/0 0/0 .sdata SizeOfLoadMatColors */
-static u32 SizeOfLoadMatColors = 0x0000000D;
+static u32 SizeOfLoadMatColors = 13;
/* 80450964-80450968 0003E4 0004+00 2/2 0/0 0/0 .sdata SizeOfLoadAmbColors */
-static u32 SizeOfLoadAmbColors = 0x0000000D;
+static u32 SizeOfLoadAmbColors = 13;
/* 80450968-80450970 0003E8 0004+04 5/5 0/0 0/0 .sdata SizeOfLoadColorChans */
static u32 SizeOfLoadColorChans = 21;
@@ -343,7 +344,8 @@ void J3DColorBlockLightOff::load() {
mMatColorOffset = GDGetCurrOffset();
loadMatColors(mMatColor);
mColorChanOffset = GDGetCurrOffset();
- J3DGDWriteXFCmdHdr(0x100e, 4);
+ J3DGDWriteXFCmdHdr(XF_REG_COLOR0CNTRL_ID, 4);
+
mColorChan[0].load();
mColorChan[2].load();
mColorChan[1].load();
@@ -360,7 +362,8 @@ void J3DColorBlockAmbientOn::load() {
loadMatColors(mMatColor);
loadAmbColors(mAmbColor);
mColorChanOffset = GDGetCurrOffset();
- J3DGDWriteXFCmdHdr(0x100e, 4);
+ J3DGDWriteXFCmdHdr(XF_REG_COLOR0CNTRL_ID, 4);
+
mColorChan[0].load();
mColorChan[2].load();
mColorChan[1].load();
@@ -374,11 +377,13 @@ void J3DColorBlockLightOn::load() {
loadMatColors(mMatColor);
loadAmbColors(mAmbColor);
mColorChanOffset = GDGetCurrOffset();
- J3DGDWriteXFCmdHdr(0x100e, 4);
+ J3DGDWriteXFCmdHdr(XF_REG_COLOR0CNTRL_ID, 4);
+
mColorChan[0].load();
mColorChan[2].load();
mColorChan[1].load();
mColorChan[3].load();
+
for (u32 i = 0; i < 8; i++) {
if (mLight[i] != NULL) {
mLight[i]->load(i);
@@ -399,7 +404,7 @@ void J3DColorBlockLightOff::patchMatColor() {
GDOverflowCheck(SizeOfLoadMatColors);
loadMatColors(mMatColor);
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 803190AC-803194E8 3139EC 043C+00 2/0 0/0 0/0 .text patchLight__21J3DColorBlockLightOffFv */
@@ -407,13 +412,15 @@ void J3DColorBlockLightOff::patchLight() {
GDSetCurrOffset(mColorChanOffset);
void* start = GDGetCurrPointer();
GDOverflowCheck(SizeOfLoadColorChans);
- J3DGDWriteXFCmdHdr(0x100e, 4);
+ J3DGDWriteXFCmdHdr(XF_REG_COLOR0CNTRL_ID, 4);
+
mColorChan[0].load();
mColorChan[2].load();
mColorChan[1].load();
mColorChan[3].load();
+
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 803194E8-80319534 313E28 004C+00 1/0 0/0 0/0 .text patch__20J3DColorBlockLightOnFv */
@@ -429,7 +436,7 @@ void J3DColorBlockLightOn::patchMatColor() {
GDOverflowCheck(SizeOfLoadMatColors);
loadMatColors(mMatColor);
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 803196E0-80319B4C 314020 046C+00 1/0 0/0 0/0 .text patchLight__20J3DColorBlockLightOnFv */
@@ -437,25 +444,29 @@ void J3DColorBlockLightOn::patchLight() {
GDSetCurrOffset(mColorChanOffset);
void* start = GDGetCurrPointer();
GDOverflowCheck(SizeOfLoadColorChans);
- J3DGDWriteXFCmdHdr(0x100e, 4);
+ J3DGDWriteXFCmdHdr(XF_REG_COLOR0CNTRL_ID, 4);
+
mColorChan[0].load();
mColorChan[2].load();
mColorChan[1].load();
mColorChan[3].load();
+
for (u32 i = 0; i < 8; i++) {
if (mLight[i] != NULL) {
mLight[i]->load(i);
}
}
+
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 80319B4C-80319BB4 31448C 0068+00 2/0 0/0 0/0 .text diff__21J3DColorBlockLightOffFUl */
-void J3DColorBlockLightOff::diff(u32 flag) {
- if (flag & 0x1)
+void J3DColorBlockLightOff::diff(u32 diffFlags) {
+ if (diffFlags & J3DDiffFlag_MatColor)
diffMatColor();
- if (flag & 0x2)
+
+ if (diffFlags & J3DDiffFlag_ColorChan)
diffColorChan();
}
@@ -468,7 +479,7 @@ void J3DColorBlockLightOff::diffMatColor() {
/* 80319D30-8031A13C 314670 040C+00 2/0 0/0 0/0 .text diffColorChan__21J3DColorBlockLightOffFv */
void J3DColorBlockLightOff::diffColorChan() {
GDOverflowCheck(SizeOfLoadColorChans);
- J3DGDWriteXFCmdHdr(0x100e, 4);
+ J3DGDWriteXFCmdHdr(XF_REG_COLOR0CNTRL_ID, 4);
mColorChan[0].load();
mColorChan[2].load();
mColorChan[1].load();
@@ -476,19 +487,19 @@ void J3DColorBlockLightOff::diffColorChan() {
}
/* 8031A13C-8031A1DC 314A7C 00A0+00 1/0 0/0 0/0 .text diff__20J3DColorBlockLightOnFUl */
-void J3DColorBlockLightOn::diff(u32 flag) {
- if (flag & 4)
+void J3DColorBlockLightOn::diff(u32 diffFlags) {
+ if (diffFlags & J3DDiffFlag_AmbColor)
diffAmbColor();
- if (flag & 1)
+ if (diffFlags & J3DDiffFlag_MatColor)
diffMatColor();
- if (flag & 2)
+ if (diffFlags & J3DDiffFlag_ColorChan)
diffColorChan();
- s32 lightObjNumFlag = getDiffFlag_LightObjNum(flag);
- if (lightObjNumFlag)
- diffLightObj(lightObjNumFlag);
+ s32 lightObjNum = getDiffFlag_LightObjNum(diffFlags);
+ if (lightObjNum != 0)
+ diffLightObj(lightObjNum);
}
/* 8031A1DC-8031A358 314B1C 017C+00 1/0 0/0 0/0 .text diffAmbColor__20J3DColorBlockLightOnFv */
@@ -506,7 +517,7 @@ void J3DColorBlockLightOn::diffMatColor() {
/* 8031A4D4-8031A8E0 314E14 040C+00 1/0 0/0 0/0 .text diffColorChan__20J3DColorBlockLightOnFv */
void J3DColorBlockLightOn::diffColorChan() {
GDOverflowCheck(SizeOfLoadColorChans);
- J3DGDWriteXFCmdHdr(0x100e, 4);
+ J3DGDWriteXFCmdHdr(XF_REG_COLOR0CNTRL_ID, 4);
mColorChan[0].load();
mColorChan[2].load();
mColorChan[1].load();
@@ -514,8 +525,8 @@ void J3DColorBlockLightOn::diffColorChan() {
}
/* 8031A8E0-8031A948 315220 0068+00 1/0 0/0 0/0 .text diffLightObj__20J3DColorBlockLightOnFUl */
-void J3DColorBlockLightOn::diffLightObj(u32 param_1) {
- for (u32 i = 0; i < param_1; i ++) {
+void J3DColorBlockLightOn::diffLightObj(u32 lightObjNum) {
+ for (u32 i = 0; i < lightObjNum; i ++) {
if (mLight[i] != NULL) {
mLight[i]->load(i);
}
@@ -530,6 +541,7 @@ void J3DTexGenBlock4::load() {
mTexMtx[i]->load(i);
}
}
+
if (mTexGenNum != 0) {
loadTexCoordGens(mTexGenNum, mTexCoord);
}
@@ -543,6 +555,7 @@ void J3DTexGenBlockBasic::load() {
mTexMtx[i]->load(i);
}
}
+
if (mTexGenNum != 0) {
loadTexCoordGens(mTexGenNum, mTexCoord);
}
@@ -552,46 +565,53 @@ void J3DTexGenBlockBasic::load() {
void J3DTexGenBlockPatched::patch() {
GDSetCurrOffset(mTexMtxOffset);
void* start = GDGetCurrPointer();
+
for (u32 i = 0; i < 8; i++) {
if (mTexMtx[i]) {
mTexMtx[i]->load(i);
}
}
+
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031AB18-8031ABC0 315458 00A8+00 1/0 0/0 0/0 .text patch__15J3DTexGenBlock4Fv */
void J3DTexGenBlock4::patch() {
GDSetCurrOffset(mTexMtxOffset);
void* start = GDGetCurrPointer();
+
for (u32 i = 0; i < 4; i++) {
if (mTexMtx[i] && mTexCoord[i].getTexGenMtx() != GX_IDENTITY) {
mTexMtx[i]->load(i);
}
}
+
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031ABC0-8031AC68 315500 00A8+00 1/0 0/0 0/0 .text patch__19J3DTexGenBlockBasicFv */
void J3DTexGenBlockBasic::patch() {
GDSetCurrOffset(mTexMtxOffset);
void* start = GDGetCurrPointer();
+
for (u32 i = 0; i < 8; i++) {
if (mTexMtx[i] && mTexCoord[i].getTexGenMtx() != GX_IDENTITY) {
mTexMtx[i]->load(i);
}
}
+
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031AC68-8031ACD0 3155A8 0068+00 3/0 0/0 0/0 .text diff__21J3DTexGenBlockPatchedFUl */
-void J3DTexGenBlockPatched::diff(u32 flag) {
- if (getDiffFlag_TexGenNum(flag)) {
+void J3DTexGenBlockPatched::diff(u32 diffFlags) {
+ if (getDiffFlag_TexGenNum(diffFlags)) {
diffTexMtx();
- if (flag & 0x1000) {
+
+ if (diffFlags & J3DDiffFlag_TexGen) {
diffTexGen();
}
}
@@ -599,7 +619,7 @@ void J3DTexGenBlockPatched::diff(u32 flag) {
/* 8031ACD0-8031AD30 315610 0060+00 3/0 0/0 0/0 .text diffTexMtx__21J3DTexGenBlockPatchedFv */
void J3DTexGenBlockPatched::diffTexMtx() {
- for (u32 i = 0; i < ARRAY_SIZE(mTexMtx); ++i) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTexMtx); ++i) {
if (mTexMtx[i] != NULL) {
mTexMtx[i]->load(i);
}
@@ -617,9 +637,11 @@ void J3DTexGenBlockPatched::diffTexGen() {
void J3DTevBlock1::load() {
mTexNoOffset = GDGetCurrOffset();
GDOverflowCheck(0x69);
+
if (mTexNo[0] != 0xffff) {
loadTexNo(0, mTexNo[0]);
}
+
J3DGDSetTevOrder(
GX_TEVSTAGE0,
GXTexCoordID(mTevOrder[0].getTevOrderInfo().mTexCoord),
@@ -629,10 +651,12 @@ void J3DTevBlock1::load() {
GX_TEXMAP_NULL,
GX_COLOR_NULL
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[0].getTevOrderInfo().mTexCoord),
J3DSys::sTexCoordScaleTable[mTevOrder[0].getTevOrderInfo().mTexMap & 7]
);
+
mTevStage[0].load(0);
mIndTevStage[0].load(0);
}
@@ -641,11 +665,13 @@ void J3DTevBlock1::load() {
void J3DTevBlock2::load() {
u32 tevStageNum = mTevStageNum;
mTexNoOffset = GDGetCurrOffset();
+
for (u32 i = 0; i < 2; i++) {
if (mTexNo[i] != 0xffff) {
loadTexNo(i, mTexNo[i]);
}
}
+
J3DGDSetTevOrder(
GX_TEVSTAGE0,
GXTexCoordID(mTevOrder[0].getTevOrderInfo().mTexCoord),
@@ -655,15 +681,19 @@ void J3DTevBlock2::load() {
GXTexMapID(mTevOrder[1].getTevOrderInfo().mTexMap),
GXChannelID(mTevOrder[1].getTevOrderInfo().mColorChan)
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[0].getTevOrderInfo().mTexCoord),
J3DSys::sTexCoordScaleTable[mTevOrder[0].getTevOrderInfo().mTexMap & 7]
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[1].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[1].getTevOrderInfo().mTexMap & 7]
);
+
mTevRegOffset = GDGetCurrOffset();
+
for (u32 i = 0; i < 3; i++) {
loadTevColor(i, mTevColor[i]);
}
@@ -674,6 +704,7 @@ void J3DTevBlock2::load() {
mTevStage[i].load(i);
mIndTevStage[i].load(i);
}
+
for (u32 i = 0; i < 16; i += 4) {
J3DGDSetTevKonstantSel_SwapModeTable(
GXTevStageID(i),
@@ -684,6 +715,7 @@ void J3DTevBlock2::load() {
GXTevColorChan(mTevSwapModeTable[i / 4].getR()),
GXTevColorChan(mTevSwapModeTable[i / 4].getG())
);
+
J3DGDSetTevKonstantSel_SwapModeTable(
GXTevStageID(i + 2),
GXTevKColorSel(mTevKColorSel[0]),
@@ -700,11 +732,13 @@ void J3DTevBlock2::load() {
void J3DTevBlock4::load() {
u32 tevStageNum = mTevStageNum;
mTexNoOffset = GDGetCurrOffset();
+
for (u32 i = 0; i < 4; i++) {
if (mTexNo[i] != 0xffff) {
loadTexNo(i, mTexNo[i]);
}
}
+
for (u32 i = 0; i < tevStageNum; i += 2) {
J3DGDSetTevOrder(
GXTevStageID(i),
@@ -715,16 +749,20 @@ void J3DTevBlock4::load() {
GXTexMapID(mTevOrder[i + 1].getTevOrderInfo().mTexMap),
GXChannelID(mTevOrder[i + 1].getTevOrderInfo().mColorChan)
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i].getTevOrderInfo().mTexMap & 7]
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i + 1].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i + 1].getTevOrderInfo().mTexMap & 7]
);
}
+
mTevRegOffset = GDGetCurrOffset();
+
for (u32 i = 0; i < 3; i++) {
loadTevColor(i, mTevColor[i]);
}
@@ -735,6 +773,7 @@ void J3DTevBlock4::load() {
mTevStage[i].load(i);
mIndTevStage[i].load(i);
}
+
for (u32 i = 0; i < 16; i += 4) {
J3DGDSetTevKonstantSel_SwapModeTable(
GXTevStageID(i),
@@ -745,6 +784,7 @@ void J3DTevBlock4::load() {
GXTevColorChan(mTevSwapModeTable[i / 4].getR()),
GXTevColorChan(mTevSwapModeTable[i / 4].getG())
);
+
J3DGDSetTevKonstantSel_SwapModeTable(
GXTevStageID(i + 2),
GXTevKColorSel(mTevKColorSel[2]),
@@ -761,11 +801,13 @@ void J3DTevBlock4::load() {
void J3DTevBlock16::load() {
u32 tevStageNum = mTevStageNum;
mTexNoOffset = GDGetCurrOffset();
+
for (u32 i = 0; i < 8; i++) {
if (mTexNo[i] != 0xffff) {
loadTexNo(i, mTexNo[i]);
}
}
+
for (u32 i = 0; i < tevStageNum; i += 2) {
J3DGDSetTevOrder(
GXTevStageID(i),
@@ -776,16 +818,20 @@ void J3DTevBlock16::load() {
GXTexMapID(mTevOrder[i + 1].getTevOrderInfo().mTexMap),
GXChannelID(mTevOrder[i + 1].getTevOrderInfo().mColorChan)
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i].getTevOrderInfo().mTexMap & 7]
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i + 1].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i + 1].getTevOrderInfo().mTexMap & 7]
);
}
+
mTevRegOffset = GDGetCurrOffset();
+
for (u32 i = 0; i < 3; i++) {
loadTevColor(i, mTevColor[i]);
}
@@ -796,6 +842,7 @@ void J3DTevBlock16::load() {
mTevStage[i].load(i);
mIndTevStage[i].load(i);
}
+
for (u32 i = 0; i < 16; i += 4) {
J3DGDSetTevKonstantSel_SwapModeTable(
GXTevStageID(i),
@@ -806,6 +853,7 @@ void J3DTevBlock16::load() {
GXTevColorChan(mTevSwapModeTable[i / 4].getR()),
GXTevColorChan(mTevSwapModeTable[i / 4].getG())
);
+
J3DGDSetTevKonstantSel_SwapModeTable(
GXTevStageID(i + 2),
GXTevKColorSel(mTevKColorSel[i + 2]),
@@ -832,7 +880,7 @@ void J3DTevBlockPatched::patchTexNo() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031BFE0-8031C0AC 316920 00CC+00 1/0 0/0 0/0 .text patchTevReg__18J3DTevBlockPatchedFv
@@ -841,15 +889,15 @@ void J3DTevBlockPatched::patchTevReg() {
GDSetCurrOffset(mTevRegOffset);
void* start = GDGetCurrPointer();
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C0AC-8031C228 3169EC 017C+00 1/0 0/0 0/0 .text
@@ -875,10 +923,12 @@ void J3DTevBlockPatched::patchTexNoAndTexCoordScale() {
GXTexMapID(mTevOrder[i + 1].getTevOrderInfo().mTexMap),
GXChannelID(mTevOrder[i + 1].getTevOrderInfo().mColorChan)
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i].getTevOrderInfo().mTexMap & 7]
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i + 1].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i + 1].getTevOrderInfo().mTexMap & 7]
@@ -886,7 +936,7 @@ void J3DTevBlockPatched::patchTexNoAndTexCoordScale() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C228-8031C274 316B68 004C+00 1/0 0/0 0/0 .text patch__18J3DTevBlockPatchedFv */
@@ -905,12 +955,11 @@ void J3DTevBlock1::patchTexNo() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C2E4-8031C2E8 316C24 0004+00 1/0 0/0 0/0 .text patchTevReg__12J3DTevBlock1Fv */
-void J3DTevBlock1::patchTevReg() {
-}
+void J3DTevBlock1::patchTevReg() {}
/* 8031C2E8-8031C3CC 316C28 00E4+00 1/0 0/0 0/0 .text patchTexNoAndTexCoordScale__12J3DTevBlock1Fv
*/
@@ -931,13 +980,14 @@ void J3DTevBlock1::patchTexNoAndTexCoordScale() {
GX_TEXMAP_NULL,
GX_COLOR_NULL
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[0].getTevOrderInfo().mTexCoord),
J3DSys::sTexCoordScaleTable[mTevOrder[0].getTevOrderInfo().mTexMap & 7]
);
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C3CC-8031C3F8 316D0C 002C+00 1/0 0/0 0/0 .text patch__12J3DTevBlock1Fv */
@@ -957,7 +1007,7 @@ void J3DTevBlock2::patchTexNo() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C48C-8031C558 316DCC 00CC+00 1/0 0/0 0/0 .text patchTevReg__12J3DTevBlock2Fv */
@@ -965,15 +1015,15 @@ void J3DTevBlock2::patchTevReg() {
GDSetCurrOffset(mTevRegOffset);
void* start = GDGetCurrPointer();
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C558-8031C6A8 316E98 0150+00 1/0 0/0 0/0 .text patchTexNoAndTexCoordScale__12J3DTevBlock2Fv
@@ -997,17 +1047,19 @@ void J3DTevBlock2::patchTexNoAndTexCoordScale() {
GXTexMapID(mTevOrder[1].getTevOrderInfo().mTexMap),
GXChannelID(mTevOrder[1].getTevOrderInfo().mColorChan)
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[0].getTevOrderInfo().mTexCoord),
J3DSys::sTexCoordScaleTable[mTevOrder[0].getTevOrderInfo().mTexMap & 7]
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[1].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[1].getTevOrderInfo().mTexMap & 7]
);
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C6A8-8031C6F4 316FE8 004C+00 1/0 0/0 0/0 .text patch__12J3DTevBlock2Fv */
@@ -1028,7 +1080,7 @@ void J3DTevBlock4::patchTexNo() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C788-8031C854 3170C8 00CC+00 1/0 0/0 0/0 .text patchTevReg__12J3DTevBlock4Fv */
@@ -1036,15 +1088,15 @@ void J3DTevBlock4::patchTevReg() {
GDSetCurrOffset(mTevRegOffset);
void* start = GDGetCurrPointer();
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C854-8031C9D0 317194 017C+00 1/0 0/0 0/0 .text patchTexNoAndTexCoordScale__12J3DTevBlock4Fv
@@ -1070,10 +1122,12 @@ void J3DTevBlock4::patchTexNoAndTexCoordScale() {
GXTexMapID(mTevOrder[i + 1].getTevOrderInfo().mTexMap),
GXChannelID(mTevOrder[i + 1].getTevOrderInfo().mColorChan)
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i].getTevOrderInfo().mTexMap & 7]
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i + 1].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i + 1].getTevOrderInfo().mTexMap & 7]
@@ -1081,7 +1135,7 @@ void J3DTevBlock4::patchTexNoAndTexCoordScale() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031C9D0-8031CA1C 317310 004C+00 1/0 0/0 0/0 .text patch__12J3DTevBlock4Fv */
void J3DTevBlock4::patch() {
@@ -1101,7 +1155,7 @@ void J3DTevBlock16::patchTexNo() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031CAB0-8031CB7C 3173F0 00CC+00 1/0 0/0 0/0 .text patchTevReg__13J3DTevBlock16Fv */
@@ -1109,15 +1163,15 @@ void J3DTevBlock16::patchTevReg() {
GDSetCurrOffset(mTevRegOffset);
void* start = GDGetCurrPointer();
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031CB7C-8031CCF8 3174BC 017C+00 1/0 0/0 0/0 .text
@@ -1143,10 +1197,12 @@ void J3DTevBlock16::patchTexNoAndTexCoordScale() {
GXTexMapID(mTevOrder[i + 1].getTevOrderInfo().mTexMap),
GXChannelID(mTevOrder[i + 1].getTevOrderInfo().mColorChan)
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i].getTevOrderInfo().mTexMap & 7]
);
+
loadTexCoordScale(
GXTexCoordID(mTevOrder[i + 1].getTevOrderInfo().mTexCoord & 7),
J3DSys::sTexCoordScaleTable[mTevOrder[i + 1].getTevOrderInfo().mTexMap & 7]
@@ -1154,7 +1210,7 @@ void J3DTevBlock16::patchTexNoAndTexCoordScale() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031CCF8-8031CD44 317638 004C+00 1/0 0/0 0/0 .text patch__13J3DTevBlock16Fv */
@@ -1164,20 +1220,24 @@ void J3DTevBlock16::patch() {
}
/* 8031CD44-8031CE00 317684 00BC+00 6/0 1/0 0/0 .text diff__11J3DTevBlockFUl */
-void J3DTevBlock::diff(u32 flag) {
- if (getDiffFlag_TexNoNum(flag)) {
+void J3DTevBlock::diff(u32 diffFlags) {
+ if (getDiffFlag_TexNoNum(diffFlags)) {
diffTexNo();
}
- if (flag & 0x4000000) {
+
+ if (diffFlags & J3DDiffFlag_TexCoordScale) {
diffTexCoordScale();
}
- if (getDiffFlag_TevStageNum(flag)) {
+
+ if (getDiffFlag_TevStageNum(diffFlags)) {
diffTevStage();
- if (flag & 0x8000000) {
+
+ if (diffFlags & J3DDiffFlag_TevStageIndirect) {
diffTevStageIndirect();
}
}
- if (flag & 0x01000000) {
+
+ if (diffFlags & J3DDiffFlag_TevReg) {
diffTevReg();
}
}
@@ -1185,7 +1245,7 @@ void J3DTevBlock::diff(u32 flag) {
/* 8031CE00-8031CE64 317740 0064+00 1/0 0/0 0/0 .text diffTexNo__18J3DTevBlockPatchedFv
*/
void J3DTevBlockPatched::diffTexNo() {
- for (u32 i = 0; i < ARRAY_SIZE(mTexNo); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTexNo); i++) {
if (mTexNo[i] != 0xFFFF) {
loadTexNo(i, mTexNo[i]);
}
@@ -1212,10 +1272,10 @@ void J3DTevBlockPatched::diffTevStageIndirect() {
/* 8031D028-8031D0C4 317968 009C+00 1/0 0/0 0/0 .text diffTevReg__18J3DTevBlockPatchedFv
*/
void J3DTevBlockPatched::diffTevReg() {
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
}
@@ -1243,8 +1303,7 @@ void J3DTevBlock1::diffTexNo() {
}
/* 8031D1F4-8031D1F8 317B34 0004+00 1/0 0/0 0/0 .text diffTevReg__12J3DTevBlock1Fv */
-void J3DTevBlock1::diffTevReg() {
-}
+void J3DTevBlock1::diffTevReg() {}
/* 8031D1F8-8031D2E8 317B38 00F0+00 1/0 0/0 0/0 .text diffTevStage__12J3DTevBlock1Fv */
void J3DTevBlock1::diffTevStage() {
@@ -1267,7 +1326,7 @@ void J3DTevBlock1::diffTexCoordScale() {
/* 8031D3D0-8031D434 317D10 0064+00 1/0 0/0 0/0 .text diffTexNo__12J3DTevBlock2Fv */
void J3DTevBlock2::diffTexNo() {
- for (u32 i = 0; i < ARRAY_SIZE(mTexNo); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTexNo); i++) {
if (mTexNo[i] != 0xFFFF) {
loadTexNo(i, mTexNo[i]);
}
@@ -1276,10 +1335,10 @@ void J3DTevBlock2::diffTexNo() {
/* 8031D434-8031D4D0 317D74 009C+00 1/0 0/0 0/0 .text diffTevReg__12J3DTevBlock2Fv */
void J3DTevBlock2::diffTevReg() {
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
}
@@ -1315,7 +1374,7 @@ void J3DTevBlock2::diffTexCoordScale() {
/* 8031D758-8031D7BC 318098 0064+00 1/0 0/0 0/0 .text diffTexNo__12J3DTevBlock4Fv */
void J3DTevBlock4::diffTexNo() {
- for (u32 i = 0; i < ARRAY_SIZE(mTexNo); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTexNo); i++) {
if (mTexNo[i] != 0xFFFF) {
loadTexNo(i, mTexNo[i]);
}
@@ -1324,10 +1383,10 @@ void J3DTevBlock4::diffTexNo() {
/* 8031D7BC-8031D858 3180FC 009C+00 1/0 0/0 0/0 .text diffTevReg__12J3DTevBlock4Fv */
void J3DTevBlock4::diffTevReg() {
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
}
@@ -1339,6 +1398,7 @@ void J3DTevBlock4::diffTevStage() {
mTevStage[i].load(i);
}
}
+
/* 8031D96C-8031DA1C 3182AC 00B0+00 1/0 0/0 0/0 .text diffTevStageIndirect__12J3DTevBlock4Fv */
void J3DTevBlock4::diffTevStageIndirect() {
u32 tevStageNum = mTevStageNum;
@@ -1364,7 +1424,7 @@ void J3DTevBlock4::diffTexCoordScale() {
}
/* 8031DB14-8031DB78 318454 0064+00 1/0 0/0 0/0 .text diffTexNo__13J3DTevBlock16Fv */
void J3DTevBlock16::diffTexNo() {
- for (u32 i = 0; i < ARRAY_SIZE(mTexNo); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTexNo); i++) {
if (mTexNo[i] != 0xFFFF) {
loadTexNo(i, mTexNo[i]);
}
@@ -1373,10 +1433,10 @@ void J3DTevBlock16::diffTexNo() {
/* 8031DB78-8031DC14 3184B8 009C+00 1/0 0/0 0/0 .text diffTevReg__13J3DTevBlock16Fv */
void J3DTevBlock16::diffTevReg() {
- for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevColor) - 1; i++) {
loadTevColor(i, mTevColor[i]);
}
- for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mTevKColor); i++) {
loadTevKColor(i, mTevKColor[i]);
}
}
@@ -1422,8 +1482,10 @@ void J3DTevBlock16::ptrToIndex() {
if (mTexNo[i] != 0xFFFF) {
GDSetCurrOffset(mTexNoOffset + offs);
patchTexNo_PtrToIdx(i, mTexNo[i]);
+
ResTIMG* img = j3dSys.getTexture()->getResTIMG(mTexNo[i]);
- J3D_ASSERT(0x828, img != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2088, img != NULL);
+
offs += 0x14;
if (img->indexTexture == 1) {
offs += 0x23;
@@ -1432,7 +1494,7 @@ void J3DTevBlock16::ptrToIndex() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031DFB4-8031E098 3188F4 00E4+00 1/0 0/0 0/0 .text ptrToIndex__18J3DTevBlockPatchedFv
@@ -1446,8 +1508,10 @@ void J3DTevBlockPatched::ptrToIndex() {
if (mTexNo[i] != 0xFFFF) {
GDSetCurrOffset(mTexNoOffset + offs);
patchTexNo_PtrToIdx(i, mTexNo[i]);
+
ResTIMG* img = j3dSys.getTexture()->getResTIMG(mTexNo[i]);
- J3D_ASSERT(0x851, img != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2129, img != NULL);
+
offs += 0x14;
if (img->indexTexture == 1) {
offs += 0x23;
@@ -1456,7 +1520,7 @@ void J3DTevBlockPatched::ptrToIndex() {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031E098-8031E12C 3189D8 0094+00 5/5 1/1 0/0 .text indexToPtr_private__11J3DTevBlockFUl */
@@ -1475,7 +1539,7 @@ void J3DTevBlock::indexToPtr_private(u32 offs) {
}
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031E12C-8031E328 318A6C 01FC+00 1/0 0/0 0/0 .text load__15J3DIndBlockFullFv */
@@ -1484,6 +1548,7 @@ void J3DIndBlockFull::load() {
for (u32 i = 0; i < indTexStageNum; i++) {
mIndTexMtx[i].load(i);
}
+
for (u32 i = 0; i < indTexStageNum; i += 2) {
J3DGDSetIndTexCoordScale(
GXIndTexStageID(i),
@@ -1493,10 +1558,12 @@ void J3DIndBlockFull::load() {
(GXIndTexScale)mIndTexCoordScale[i + 1].getScaleT()
);
}
+
loadTexCoordScale((GXTexCoordID)mIndTexOrder[0].getCoord(), J3DSys::sTexCoordScaleTable[mIndTexOrder[0].getMap() & 7]);
loadTexCoordScale((GXTexCoordID)mIndTexOrder[1].getCoord(), J3DSys::sTexCoordScaleTable[mIndTexOrder[1].getMap() & 7]);
loadTexCoordScale((GXTexCoordID)mIndTexOrder[2].getCoord(), J3DSys::sTexCoordScaleTable[mIndTexOrder[2].getMap() & 7]);
loadTexCoordScale((GXTexCoordID)mIndTexOrder[3].getCoord(), J3DSys::sTexCoordScaleTable[mIndTexOrder[3].getMap() & 7]);
+
J3DGDSetIndTexOrder(
indTexStageNum,
(GXTexCoordID)mIndTexOrder[0].getCoord(),
@@ -1511,31 +1578,33 @@ void J3DIndBlockFull::load() {
}
/* 8031E328-8031E408 318C68 00E0+00 1/0 0/0 0/0 .text diff__15J3DIndBlockFullFUl */
-void J3DIndBlockFull::diff(u32 flag) {
- if ((flag & 0x08000000) == 0) {
- return;
- }
- u32 indTexStageNum = mIndTexStageNum;
- mIndTexMtx[0].load(0);
- J3DGDSetIndTexCoordScale(
- GX_INDTEXSTAGE0,
- (GXIndTexScale)mIndTexCoordScale[0].getScaleS(),
- (GXIndTexScale)mIndTexCoordScale[0].getScaleT(),
- (GXIndTexScale)mIndTexCoordScale[1].getScaleS(),
- (GXIndTexScale)mIndTexCoordScale[1].getScaleT()
- );
- loadTexCoordScale((GXTexCoordID)mIndTexOrder[0].getCoord(), J3DSys::sTexCoordScaleTable[mIndTexOrder[0].getMap() & 7]);
- J3DGDSetIndTexOrder(
- indTexStageNum,
- (GXTexCoordID)mIndTexOrder[0].getCoord(),
- (GXTexMapID)mIndTexOrder[0].getMap(),
- (GXTexCoordID)mIndTexOrder[1].getCoord(),
- (GXTexMapID)mIndTexOrder[1].getMap(),
- (GXTexCoordID)mIndTexOrder[2].getCoord(),
- (GXTexMapID)mIndTexOrder[2].getMap(),
- (GXTexCoordID)mIndTexOrder[3].getCoord(),
- (GXTexMapID)mIndTexOrder[3].getMap()
- );
+void J3DIndBlockFull::diff(u32 diffFlags) {
+ if (diffFlags & J3DDiffFlag_TevStageIndirect) {
+ u32 indTexStageNum = mIndTexStageNum;
+ mIndTexMtx[0].load(0);
+
+ J3DGDSetIndTexCoordScale(
+ GX_INDTEXSTAGE0,
+ (GXIndTexScale)mIndTexCoordScale[0].getScaleS(),
+ (GXIndTexScale)mIndTexCoordScale[0].getScaleT(),
+ (GXIndTexScale)mIndTexCoordScale[1].getScaleS(),
+ (GXIndTexScale)mIndTexCoordScale[1].getScaleT()
+ );
+
+ loadTexCoordScale((GXTexCoordID)mIndTexOrder[0].getCoord(), J3DSys::sTexCoordScaleTable[mIndTexOrder[0].getMap() & 7]);
+
+ J3DGDSetIndTexOrder(
+ indTexStageNum,
+ (GXTexCoordID)mIndTexOrder[0].getCoord(),
+ (GXTexMapID)mIndTexOrder[0].getMap(),
+ (GXTexCoordID)mIndTexOrder[1].getCoord(),
+ (GXTexMapID)mIndTexOrder[1].getMap(),
+ (GXTexCoordID)mIndTexOrder[2].getCoord(),
+ (GXTexMapID)mIndTexOrder[2].getMap(),
+ (GXTexCoordID)mIndTexOrder[3].getCoord(),
+ (GXTexMapID)mIndTexOrder[3].getMap()
+ );
+ }
}
/* 8031E408-8031E6C8 318D48 02C0+00 1/0 0/0 0/0 .text load__13J3DPEBlockOpaFv */
@@ -1585,7 +1654,6 @@ void J3DPEBlockFogOff::diffBlend() {
mZMode.load();
}
-
/* 8031F3C0-8031F890 319D00 04D0+00 1/0 0/0 0/0 .text load__14J3DPEBlockFullFv */
void J3DPEBlockFull::load() {
mFogOffset = GDGetCurrOffset();
@@ -1604,7 +1672,7 @@ void J3DPEBlockFull::patch() {
void* start = GDGetCurrPointer();
mFog.load();
void* end = GDGetCurrPointer();
- DCStoreRange(start, (u32)end - (u32)start);
+ DCStoreRange(start, (uintptr_t)end - (uintptr_t)start);
}
/* 8031F940-8031F9B8 31A280 0078+00 1/0 0/0 0/0 .text diffFog__14J3DPEBlockFullFv */
@@ -1621,11 +1689,12 @@ void J3DPEBlockFull::diffBlend() {
}
/* 8031FCA0-8031FD08 31A5E0 0068+00 1/0 0/0 0/0 .text diff__14J3DPEBlockFullFUl */
-void J3DPEBlockFull::diff(u32 flag) {
- if ((flag & 0x10000000)) {
+void J3DPEBlockFull::diff(u32 diffFlags) {
+ if ((diffFlags & J3DDiffFlag_Fog)) {
diffFog();
}
- if ((flag & 0x20000000)) {
+
+ if ((diffFlags & J3DDiffFlag_Blend)) {
diffBlend();
}
}
@@ -1633,14 +1702,13 @@ void J3DPEBlockFull::diff(u32 flag) {
/* 8031FD08-8031FDE4 31A648 00DC+00 1/0 0/0 0/0 .text
* reset__21J3DColorBlockLightOffFP13J3DColorBlock */
void J3DColorBlockLightOff::reset(J3DColorBlock* pBlock) {
- J3D_ASSERT(0x982, pBlock != 0, "Error : null pointer.");
-
+ J3D_ASSERT_NULLPTR(2434, pBlock != NULL);
mColorChanNum = pBlock->getColorChanNum();
- for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mMatColor); i++) {
mMatColor[i] = *pBlock->getMatColor(i);
}
- for (u32 i = 0; i < ARRAY_SIZE(mColorChan); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mColorChan); i++) {
mColorChan[i] = *pBlock->getColorChan(i);
}
}
@@ -1648,17 +1716,16 @@ void J3DColorBlockLightOff::reset(J3DColorBlock* pBlock) {
/* 8031FDE4-8031FF34 31A724 0150+00 1/0 0/0 0/0 .text
* reset__22J3DColorBlockAmbientOnFP13J3DColorBlock */
void J3DColorBlockAmbientOn::reset(J3DColorBlock* pBlock) {
- J3D_ASSERT(0x993, pBlock != 0, "Error : null pointer.");
-
+ J3D_ASSERT_NULLPTR(2451, pBlock != NULL);
mColorChanNum = pBlock->getColorChanNum();
- for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mMatColor); i++) {
mMatColor[i] = *pBlock->getMatColor(i);
}
- for (u32 i = 0; i < ARRAY_SIZE(mColorChan); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mColorChan); i++) {
mColorChan[i] = *pBlock->getColorChan(i);
}
- for (u32 i = 0; i < ARRAY_SIZE(mAmbColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mAmbColor); i++) {
if (pBlock->getAmbColor(i) != NULL) {
mAmbColor[i] = *pBlock->getAmbColor(i);
}
@@ -1668,17 +1735,16 @@ void J3DColorBlockAmbientOn::reset(J3DColorBlock* pBlock) {
/* 8031FF34-80320084 31A874 0150+00 1/0 0/0 0/0 .text
* reset__20J3DColorBlockLightOnFP13J3DColorBlock */
void J3DColorBlockLightOn::reset(J3DColorBlock* pBlock) {
- J3D_ASSERT(0x9ac, pBlock != 0, "Error : null pointer.");
-
+ J3D_ASSERT_NULLPTR(2476, pBlock != NULL);
mColorChanNum = pBlock->getColorChanNum();
- for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mMatColor); i++) {
mMatColor[i] = *pBlock->getMatColor(i);
}
- for (u32 i = 0; i < ARRAY_SIZE(mColorChan); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mColorChan); i++) {
mColorChan[i] = *pBlock->getColorChan(i);
}
- for (u32 i = 0; i < ARRAY_SIZE(mAmbColor); i++) {
+ for (u32 i = 0; i < ARRAY_SIZEU(mAmbColor); i++) {
if (pBlock->getAmbColor(i) != NULL) {
mAmbColor[i] = *pBlock->getAmbColor(i);
}
@@ -1688,12 +1754,13 @@ void J3DColorBlockLightOn::reset(J3DColorBlock* pBlock) {
/* 80320084-803201A0 31A9C4 011C+00 1/0 0/0 0/0 .text
* reset__21J3DTexGenBlockPatchedFP14J3DTexGenBlock */
void J3DTexGenBlockPatched::reset(J3DTexGenBlock* pBlock) {
- J3D_ASSERT(0x9c8, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2504, pBlock != NULL);
mTexGenNum = pBlock->getTexGenNum();
for (u32 i = 0; i < 8; i++) {
mTexCoord[i] = *pBlock->getTexCoord(i);
}
+
for (u32 i = 0; i < 8; i++) {
if (pBlock->getTexMtx(i) != NULL) {
if (mTexMtx[i] != NULL) {
@@ -1709,12 +1776,13 @@ void J3DTexGenBlockPatched::reset(J3DTexGenBlock* pBlock) {
/* 803201A0-803202DC 31AAE0 013C+00 1/0 0/0 0/0 .text reset__15J3DTexGenBlock4FP14J3DTexGenBlock
*/
void J3DTexGenBlock4::reset(J3DTexGenBlock* pBlock) {
- J3D_ASSERT(0x9e9, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2537, pBlock != NULL);
mTexGenNum = pBlock->getTexGenNum();
for (u32 i = 0; i < 4; i++) {
mTexCoord[i] = *pBlock->getTexCoord(i);
}
+
for (u32 i = 0; i < 4; i++) {
if (pBlock->getTexMtx(i) != NULL) {
if (mTexMtx[i] != NULL) {
@@ -1732,12 +1800,13 @@ void J3DTexGenBlock4::reset(J3DTexGenBlock* pBlock) {
/* 803202DC-80320418 31AC1C 013C+00 1/0 0/0 0/0 .text
* reset__19J3DTexGenBlockBasicFP14J3DTexGenBlock */
void J3DTexGenBlockBasic::reset(J3DTexGenBlock* pBlock) {
- J3D_ASSERT(0xa0c, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2572, pBlock != NULL);
mTexGenNum = pBlock->getTexGenNum();
for (u32 i = 0; i < 8; i++) {
mTexCoord[i] = *pBlock->getTexCoord(i);
}
+
for (u32 i = 0; i < 8; i++) {
if (pBlock->getTexMtx(i) != NULL) {
if (mTexMtx[i] != NULL) {
@@ -1755,7 +1824,7 @@ void J3DTexGenBlockBasic::reset(J3DTexGenBlock* pBlock) {
/* 80320418-803205D4 31AD58 01BC+00 1/0 0/0 0/0 .text reset__18J3DTevBlockPatchedFP11J3DTevBlock
*/
void J3DTevBlockPatched::reset(J3DTevBlock* pBlock) {
- J3D_ASSERT(0xa30, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2608, pBlock != NULL);
mTevStageNum = pBlock->getTevStageNum();
for (u32 i = 0; i < 8; i++) {
@@ -1775,7 +1844,7 @@ void J3DTevBlockPatched::reset(J3DTevBlock* pBlock) {
/* 803205D4-803206AC 31AF14 00D8+00 1/0 0/0 0/0 .text reset__12J3DTevBlock1FP11J3DTevBlock */
void J3DTevBlock1::reset(J3DTevBlock* pBlock) {
- J3D_ASSERT(0xa49, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2633, pBlock != NULL);
mTexNo[0] = pBlock->getTexNo(0);
mTevOrder[0] = *pBlock->getTevOrder(0);
@@ -1785,7 +1854,7 @@ void J3DTevBlock1::reset(J3DTevBlock* pBlock) {
/* 803206AC-8032098C 31AFEC 02E0+00 1/0 0/0 0/0 .text reset__12J3DTevBlock2FP11J3DTevBlock */
void J3DTevBlock2::reset(J3DTevBlock* pBlock) {
- J3D_ASSERT(0xa59, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2649, pBlock != NULL);
mTevStageNum = pBlock->getTevStageNum();
mTexNo[0] = pBlock->getTexNo(0);
@@ -1800,6 +1869,7 @@ void J3DTevBlock2::reset(J3DTevBlock* pBlock) {
mTevKColorSel[1] = pBlock->getTevKColorSel(1);
mTevKAlphaSel[0] = pBlock->getTevKAlphaSel(0);
mTevKAlphaSel[1] = pBlock->getTevKAlphaSel(1);
+
for (u32 i = 0; i < 4; i++) {
mTevColor[i] = *pBlock->getTevColor(i);
}
@@ -1813,7 +1883,7 @@ void J3DTevBlock2::reset(J3DTevBlock* pBlock) {
/* 8032098C-80320E24 31B2CC 0498+00 1/0 0/0 0/0 .text reset__12J3DTevBlock4FP11J3DTevBlock */
void J3DTevBlock4::reset(J3DTevBlock* pBlock) {
- J3D_ASSERT(0xa7a, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2682, pBlock != NULL);
mTevStageNum = pBlock->getTevStageNum();
mTexNo[0] = pBlock->getTexNo(0);
@@ -1840,6 +1910,7 @@ void J3DTevBlock4::reset(J3DTevBlock* pBlock) {
mTevKAlphaSel[1] = pBlock->getTevKAlphaSel(1);
mTevKAlphaSel[2] = pBlock->getTevKAlphaSel(2);
mTevKAlphaSel[3] = pBlock->getTevKAlphaSel(3);
+
for (u32 i = 0; i < 4; i++)
mTevColor[i] = *pBlock->getTevColor(i);
for (u32 i = 0; i < 4; i++)
@@ -1850,7 +1921,7 @@ void J3DTevBlock4::reset(J3DTevBlock* pBlock) {
/* 80320E24-803210B0 31B764 028C+00 1/0 0/0 0/0 .text reset__13J3DTevBlock16FP11J3DTevBlock */
void J3DTevBlock16::reset(J3DTevBlock* pBlock) {
- J3D_ASSERT(0xaa8, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2728, pBlock != NULL);
mTevStageNum = pBlock->getTevStageNum();
for (u32 i = 0; i < 8; i++) {
@@ -1882,7 +1953,7 @@ void J3DTevBlock16::reset(J3DTevBlock* pBlock) {
/* 803210B0-803211B4 31B9F0 0104+00 1/0 0/0 0/0 .text reset__15J3DIndBlockFullFP11J3DIndBlock */
void J3DIndBlockFull::reset(J3DIndBlock* pBlock) {
- J3D_ASSERT(0xaca, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2762, pBlock != NULL);
mIndTexStageNum = pBlock->getIndTexStageNum();
for (u32 i = 0; i < 4; i++) {
@@ -1898,7 +1969,7 @@ void J3DIndBlockFull::reset(J3DIndBlock* pBlock) {
/* 803211B4-8032129C 31BAF4 00E8+00 1/0 0/0 0/0 .text reset__16J3DPEBlockFogOffFP10J3DPEBlock */
void J3DPEBlockFogOff::reset(J3DPEBlock* pBlock) {
- J3D_ASSERT(0xadf, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2783, pBlock != NULL);
switch (pBlock->getType()) {
case 'PEFL':
@@ -1913,10 +1984,10 @@ void J3DPEBlockFogOff::reset(J3DPEBlock* pBlock) {
/* 8032129C-803213C0 31BBDC 0124+00 1/0 0/0 0/0 .text reset__14J3DPEBlockFullFP10J3DPEBlock */
void J3DPEBlockFull::reset(J3DPEBlock* pBlock) {
- J3D_ASSERT(0xaf7, pBlock != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(2807, pBlock != NULL);
if (pBlock->getFog() != NULL) {
- this->mFog.setFogInfo(pBlock->getFog()->getFogInfo());
+ mFog.setFogInfo(pBlock->getFog()->getFogInfo());
}
switch (pBlock->getType()) {
@@ -2121,21 +2192,12 @@ void J3DTexGenBlockPatched::calcPostTexMtxWithoutViewMtx(f32 const (*param_0)[4]
}
}
-void J3DTevBlock::diffTevReg() {
- // empty function
-}
+void J3DTevBlock::diffTevReg() {}
-void J3DTevBlock::diffTevStageIndirect() {
- // empty function
-}
+void J3DTevBlock::diffTevStageIndirect() {}
-void J3DTevBlock::diffTevStage() {
- // empty function
-}
+void J3DTevBlock::diffTevStage() {}
-void J3DTevBlock::diffTexCoordScale() {
- // empty function
-}
+void J3DTevBlock::diffTexCoordScale() {}
-void J3DTevBlock::diffTexNo() {
-}
+void J3DTevBlock::diffTexNo() {}
diff --git a/src/JSystem/J3DGraphBase/J3DMaterial.cpp b/src/JSystem/J3DGraphBase/J3DMaterial.cpp
index c2c7674766..3f21adae5a 100644
--- a/src/JSystem/J3DGraphBase/J3DMaterial.cpp
+++ b/src/JSystem/J3DGraphBase/J3DMaterial.cpp
@@ -1,166 +1,184 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DMaterial
-//
-
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "JSystem/J3DGraphBase/J3DGD.h"
/* 803157A0-803159A0 3100E0 0200+00 0/0 3/3 0/0 .text createColorBlock__11J3DMaterialFUl
*/
-J3DColorBlock* J3DMaterial::createColorBlock(u32 param_0) {
+J3DColorBlock* J3DMaterial::createColorBlock(u32 flags) {
J3DColorBlock* rv = NULL;
- switch (param_0) {
- case 0:
- rv = new J3DColorBlockLightOff();
- break;
- case 0x40000000:
- rv = new J3DColorBlockLightOn();
- break;
- case 0x80000000:
- rv = new J3DColorBlockAmbientOn();
- break;
+ switch (flags) {
+ case 0:
+ rv = new J3DColorBlockLightOff();
+ break;
+ case 0x40000000:
+ rv = new J3DColorBlockLightOn();
+ break;
+ case 0x80000000:
+ rv = new J3DColorBlockAmbientOn();
+ break;
}
+ J3D_ASSERT_ALLOCMEM(55, rv != NULL);
return rv;
}
/* 803159A0-80315B04 3102E0 0164+00 0/0 2/2 0/0 .text createTexGenBlock__11J3DMaterialFUl
*/
-J3DTexGenBlock* J3DMaterial::createTexGenBlock(u32 param_0) {
- switch (param_0) {
- case 0x8000000:
- return new J3DTexGenBlock4();
- case 0:
- default:
- return new J3DTexGenBlockBasic();
+J3DTexGenBlock* J3DMaterial::createTexGenBlock(u32 flags) {
+ J3DTexGenBlock* rv = NULL;
+ switch (flags) {
+ case 0x8000000:
+ rv = new J3DTexGenBlock4();
+ break;
+ case 0:
+ default:
+ rv = new J3DTexGenBlockBasic();
}
+
+ J3D_ASSERT_ALLOCMEM(83, rv != NULL);
+ return rv;
}
/* 80315B04-80315E78 310444 0374+00 0/0 2/2 0/0 .text createTevBlock__11J3DMaterialFi */
-J3DTevBlock* J3DMaterial::createTevBlock(int param_0) {
+J3DTevBlock* J3DMaterial::createTevBlock(int tevStageNum) {
J3DTevBlock* rv = NULL;
- if (param_0 <= 1) {
+ if (tevStageNum <= 1) {
rv = new J3DTevBlock1();
- } else if (param_0 == 2) {
+ } else if (tevStageNum == 2) {
rv = new J3DTevBlock2();
- } else if (param_0 <= 4) {
+ } else if (tevStageNum <= 4) {
rv = new J3DTevBlock4();
- } else if (param_0 <= 16) {
+ } else if (tevStageNum <= 16) {
rv = new J3DTevBlock16();
}
+
+ J3D_ASSERT_ALLOCMEM(116, rv != NULL);
return rv;
}
/* 80315E78-80315F60 3107B8 00E8+00 0/0 3/3 0/0 .text createIndBlock__11J3DMaterialFi */
-J3DIndBlock* J3DMaterial::createIndBlock(int param_0) {
- if (param_0 != 0) {
- return new J3DIndBlockFull();
+J3DIndBlock* J3DMaterial::createIndBlock(int flags) {
+ J3DIndBlock* rv = NULL;
+ if (flags != 0) {
+ rv = new J3DIndBlockFull();
+ } else {
+ rv = new J3DIndBlockNull();
}
- return new J3DIndBlockNull();
+ J3D_ASSERT_ALLOCMEM(139, rv != NULL);
+ return rv;
}
/* 80315F60-80316100 3108A0 01A0+00 0/0 3/3 0/0 .text createPEBlock__11J3DMaterialFUlUl
*/
-J3DPEBlock* J3DMaterial::createPEBlock(u32 createFlag, u32 materialMode) {
+J3DPEBlock* J3DMaterial::createPEBlock(u32 flags, u32 materialMode) {
J3DPEBlock* rv = NULL;
-
- if (createFlag == 0) {
+ if (flags == 0) {
if (materialMode & 1) {
rv = new J3DPEBlockOpa();
+ J3D_ASSERT_ALLOCMEM(166, rv != NULL);
return rv;
} else if (materialMode & 2) {
rv = new J3DPEBlockTexEdge();
+ J3D_ASSERT_ALLOCMEM(172, rv != NULL);
return rv;
} else if (materialMode & 4) {
rv = new J3DPEBlockXlu();
+ J3D_ASSERT_ALLOCMEM(178, rv != NULL);
return rv;
}
}
- if (createFlag == 0x10000000) {
+ if (flags == 0x10000000) {
rv = new J3DPEBlockFull();
- } else if (createFlag == 0x20000000) {
+ } else if (flags == 0x20000000) {
rv = new J3DPEBlockFogOff();
}
+ J3D_ASSERT_ALLOCMEM(188, rv != NULL);
return rv;
}
/* 80316100-80316150 310A40 0050+00 0/0 2/2 0/0 .text calcSizeColorBlock__11J3DMaterialFUl */
-u32 J3DMaterial::calcSizeColorBlock(u32 param_0) {
+u32 J3DMaterial::calcSizeColorBlock(u32 flags) {
u32 rv = 0;
- switch (param_0) {
- case 0:
- rv = sizeof(J3DColorBlockLightOff);
- break;
- case 0x40000000:
- rv = sizeof(J3DColorBlockLightOn);
- break;
- case 0x80000000:
- rv = sizeof(J3DColorBlockAmbientOn);
- break;
+ switch (flags) {
+ case 0:
+ rv += sizeof(J3DColorBlockLightOff);
+ break;
+ case 0x40000000:
+ rv += sizeof(J3DColorBlockLightOn);
+ break;
+ case 0x80000000:
+ rv += sizeof(J3DColorBlockAmbientOn);
+ break;
}
return rv;
}
/* 80316150-8031617C 310A90 002C+00 0/0 1/1 0/0 .text calcSizeTexGenBlock__11J3DMaterialFUl */
-u32 J3DMaterial::calcSizeTexGenBlock(u32 param_0) {
- switch (param_0) {
- case 0x8000000:
- return sizeof(J3DTexGenBlock4);
- case 0:
- default:
- return sizeof(J3DTexGenBlockBasic);
+u32 J3DMaterial::calcSizeTexGenBlock(u32 flags) {
+ u32 rv = 0;
+ switch (flags) {
+ case 0x8000000:
+ rv += sizeof(J3DTexGenBlock4);
+ break;
+ case 0:
+ default:
+ rv += sizeof(J3DTexGenBlockBasic);
}
+
+ return rv;
}
/* 8031617C-803161C4 310ABC 0048+00 0/0 1/1 0/0 .text calcSizeTevBlock__11J3DMaterialFi
*/
-u32 J3DMaterial::calcSizeTevBlock(int param_0) {
+u32 J3DMaterial::calcSizeTevBlock(int tevStageNum) {
u32 rv = 0;
- if (param_0 <= 1) {
- rv = sizeof(J3DTevBlock1);
- } else if (param_0 == 2) {
- rv = sizeof(J3DTevBlock2);
- } else if (param_0 <= 4) {
- rv = sizeof(J3DTevBlock4);
- } else if (param_0 <= 16) {
- rv = sizeof(J3DTevBlock16);
+ if (tevStageNum <= 1) {
+ rv += sizeof(J3DTevBlock1);
+ } else if (tevStageNum == 2) {
+ rv += sizeof(J3DTevBlock2);
+ } else if (tevStageNum <= 4) {
+ rv += sizeof(J3DTevBlock4);
+ } else if (tevStageNum <= 16) {
+ rv += sizeof(J3DTevBlock16);
}
+
return rv;
}
/* 803161C4-803161D8 310B04 0014+00 0/0 2/2 0/0 .text calcSizeIndBlock__11J3DMaterialFi
*/
-u32 J3DMaterial::calcSizeIndBlock(int param_0) {
- if (param_0 != 0) {
- return sizeof(J3DIndBlockFull);
+u32 J3DMaterial::calcSizeIndBlock(int flags) {
+ u32 rv = 0;
+ if (flags != 0) {
+ rv += sizeof(J3DIndBlockFull);
+ } else {
+ rv += sizeof(J3DIndBlockNull);
}
- return sizeof(J3DIndBlockNull);
+ return rv;
}
/* 803161D8-80316240 310B18 0068+00 0/0 2/2 0/0 .text calcSizePEBlock__11J3DMaterialFUlUl
*/
-u32 J3DMaterial::calcSizePEBlock(u32 param_0, u32 param_1) {
+u32 J3DMaterial::calcSizePEBlock(u32 flags, u32 materialMode) {
u32 rv = 0;
- if (param_0 == 0) {
- if (param_1 & 1) {
- rv = sizeof(J3DPEBlockOpa);
- } else if (param_1 & 2) {
- rv = sizeof(J3DPEBlockTexEdge);
- } else if (param_1 & 4) {
- rv = sizeof(J3DPEBlockXlu);
+ if (flags == 0) {
+ if (materialMode & 1) {
+ rv += sizeof(J3DPEBlockOpa);
+ } else if (materialMode & 2) {
+ rv += sizeof(J3DPEBlockTexEdge);
+ } else if (materialMode & 4) {
+ rv += sizeof(J3DPEBlockXlu);
}
+ } else if (flags == 0x10000000) {
+ rv += sizeof(J3DPEBlockFull);
+ } else if (flags == 0x20000000) {
+ rv += sizeof(J3DPEBlockFogOff);
}
- else if (param_0 == 0x10000000) {
- rv = sizeof(J3DPEBlockFull);
- } else if (param_0 == 0x20000000) {
- rv = sizeof(J3DPEBlockFogOff);
- }
+
return rv;
}
@@ -191,8 +209,8 @@ u32 J3DMaterial::countDLSize() {
/* 80316344-80316620 310C84 02DC+00 2/2 0/0 0/0 .text
* makeDisplayList_private__11J3DMaterialFP17J3DDisplayListObj */
-void J3DMaterial::makeDisplayList_private(J3DDisplayListObj* param_0) {
- param_0->beginDL();
+void J3DMaterial::makeDisplayList_private(J3DDisplayListObj* pDLObj) {
+ pDLObj->beginDL();
mTevBlock->load();
mIndBlock->load();
mPEBlock->load();
@@ -201,7 +219,7 @@ void J3DMaterial::makeDisplayList_private(J3DDisplayListObj* param_0) {
mColorBlock->load();
J3DGDSetNumChans(mColorBlock->getColorChanNum());
J3DGDSetNumTexGens(mTexGenBlock->getTexGenNum());
- param_0->endDL();
+ pDLObj->endDL();
}
/* 80316620-80316668 310F60 0048+00 1/0 0/0 0/0 .text makeDisplayList__11J3DMaterialFv */
@@ -245,18 +263,20 @@ void J3DMaterial::patch() {
}
/* 803167D8-803169DC 311118 0204+00 2/0 0/0 0/0 .text diff__11J3DMaterialFUl */
-void J3DMaterial::diff(u32 param_0) {
+void J3DMaterial::diff(u32 diffFlags) {
if (j3dSys.getMatPacket()->isEnabled_Diff()) {
j3dSys.getMatPacket()->beginDiff();
- mTevBlock->diff(param_0);
- mIndBlock->diff(param_0);
- mPEBlock->diff(param_0);
- if (param_0 & 0x2000000) {
+
+ mTevBlock->diff(diffFlags);
+ mIndBlock->diff(diffFlags);
+ mPEBlock->diff(diffFlags);
+ if (diffFlags & J3DDiffFlag_KonstColor) {
J3DGDSetGenMode_3Param(mTexGenBlock->getTexGenNum(), mTevBlock->getTevStageNum(), mIndBlock->getIndTexStageNum());
J3DGDSetNumTexGens(mTexGenBlock->getTexGenNum());
}
- mTexGenBlock->diff(param_0);
- mColorBlock->diff(param_0);
+ mTexGenBlock->diff(diffFlags);
+ mColorBlock->diff(diffFlags);
+
j3dSys.getMatPacket()->endDiff();
}
}
@@ -291,43 +311,44 @@ void J3DMaterial::setCurrentMtx() {
void J3DMaterial::calcCurrentMtx() {
if (!j3dSys.checkFlag(0x40000000)) {
mCurrentMtx.setCurrentTexMtx(
- mTexGenBlock->getTexCoord(0)->getTexGenMtx(),
- mTexGenBlock->getTexCoord(1)->getTexGenMtx(),
- mTexGenBlock->getTexCoord(2)->getTexGenMtx(),
- mTexGenBlock->getTexCoord(3)->getTexGenMtx(),
- mTexGenBlock->getTexCoord(4)->getTexGenMtx(),
- mTexGenBlock->getTexCoord(5)->getTexGenMtx(),
- mTexGenBlock->getTexCoord(6)->getTexGenMtx(),
- mTexGenBlock->getTexCoord(7)->getTexGenMtx()
+ getTexCoord(0)->getTexGenMtx(),
+ getTexCoord(1)->getTexGenMtx(),
+ getTexCoord(2)->getTexGenMtx(),
+ getTexCoord(3)->getTexGenMtx(),
+ getTexCoord(4)->getTexGenMtx(),
+ getTexCoord(5)->getTexGenMtx(),
+ getTexCoord(6)->getTexGenMtx(),
+ getTexCoord(7)->getTexGenMtx()
);
} else {
mCurrentMtx.setCurrentTexMtx(
- mTexGenBlock->getTexCoord(0)->getTexMtxReg(),
- mTexGenBlock->getTexCoord(1)->getTexMtxReg(),
- mTexGenBlock->getTexCoord(2)->getTexMtxReg(),
- mTexGenBlock->getTexCoord(3)->getTexMtxReg(),
- mTexGenBlock->getTexCoord(4)->getTexMtxReg(),
- mTexGenBlock->getTexCoord(5)->getTexMtxReg(),
- mTexGenBlock->getTexCoord(6)->getTexMtxReg(),
- mTexGenBlock->getTexCoord(7)->getTexMtxReg()
+ getTexCoord(0)->getTexMtxReg(),
+ getTexCoord(1)->getTexMtxReg(),
+ getTexCoord(2)->getTexMtxReg(),
+ getTexCoord(3)->getTexMtxReg(),
+ getTexCoord(4)->getTexMtxReg(),
+ getTexCoord(5)->getTexMtxReg(),
+ getTexCoord(6)->getTexMtxReg(),
+ getTexCoord(7)->getTexMtxReg()
);
}
}
/* 80316D68-80316E14 3116A8 00AC+00 1/1 0/0 0/0 .text copy__11J3DMaterialFP11J3DMaterial
*/
-void J3DMaterial::copy(J3DMaterial* param_0) {
- mColorBlock->reset(param_0->mColorBlock);
- mTexGenBlock->reset(param_0->mTexGenBlock);
- mTevBlock->reset(param_0->mTevBlock);
- mIndBlock->reset(param_0->mIndBlock);
- mPEBlock->reset(param_0->mPEBlock);
+void J3DMaterial::copy(J3DMaterial* pOther) {
+ J3D_ASSERT_NULLPTR(620, pOther != NULL);
+ mColorBlock->reset(pOther->mColorBlock);
+ mTexGenBlock->reset(pOther->mTexGenBlock);
+ mTevBlock->reset(pOther->mTevBlock);
+ mIndBlock->reset(pOther->mIndBlock);
+ mPEBlock->reset(pOther->mPEBlock);
}
/* 80316E14-80316E70 311754 005C+00 1/0 0/0 0/0 .text reset__11J3DMaterialFv */
void J3DMaterial::reset() {
- if ((~mDiffFlag & 0x80000000) == 0) {
- mDiffFlag &= ~0x80000000;
+ if ((~mDiffFlag & J3DDiffFlag_Changed) == 0) {
+ mDiffFlag &= ~J3DDiffFlag_Changed;
mMaterialMode = mpOrigMaterial->mMaterialMode;
mInvalid = mpOrigMaterial->mInvalid;
mMaterialAnm = NULL;
@@ -337,47 +358,45 @@ void J3DMaterial::reset() {
/* 80316E70-80316E90 3117B0 0020+00 1/0 0/0 0/0 .text change__11J3DMaterialFv */
void J3DMaterial::change() {
- if ((mDiffFlag & 0xc0000000) == 0) {
- mDiffFlag |= 0x80000000;
+ if ((mDiffFlag & (J3DDiffFlag_Changed | J3DDiffFlag_Unk40000000)) == 0) {
+ mDiffFlag |= J3DDiffFlag_Changed;
mMaterialAnm = NULL;
}
}
/* 80316E90-80316F24 3117D0 0094+00 0/0 2/2 0/0 .text newSharedDisplayList__11J3DMaterialFUl */
-s32 J3DMaterial::newSharedDisplayList(u32 param_0) {
+s32 J3DMaterial::newSharedDisplayList(u32 dlSize) {
if (mSharedDLObj == NULL) {
mSharedDLObj = new J3DDisplayListObj();
if (mSharedDLObj == NULL) {
- return 4;
+ return kJ3DError_Alloc;
}
- s32 res = mSharedDLObj->newDisplayList(param_0);
- switch (res) {
- case kJ3DError_Success:
- break;
- default:
- return res;
+
+ s32 ret = mSharedDLObj->newDisplayList(dlSize);
+ if (ret != kJ3DError_Success) {
+ return ret;
}
}
- return 0;
+
+ return kJ3DError_Success;
}
/* 80316F24-80316FB8 311864 0094+00 0/0 2/2 0/0 .text newSingleSharedDisplayList__11J3DMaterialFUl
*/
-s32 J3DMaterial::newSingleSharedDisplayList(u32 param_0) {
+s32 J3DMaterial::newSingleSharedDisplayList(u32 dlSize) {
if (mSharedDLObj == NULL) {
mSharedDLObj = new J3DDisplayListObj();
if (mSharedDLObj == NULL) {
- return 4;
+ return kJ3DError_Alloc;
}
- s32 res = mSharedDLObj->newSingleDisplayList(param_0);
- switch (res) {
- case kJ3DError_Success:
- break;
- default:
- return res;
+
+ s32 ret = mSharedDLObj->newSingleDisplayList(dlSize);
+ if (ret != kJ3DError_Success) {
+ return ret;
}
}
- return 0;
+
+ return kJ3DError_Success;
}
/* 80316FB8-80316FD8 3118F8 0020+00 0/0 1/1 0/0 .text initialize__18J3DPatchedMaterialFv
@@ -387,15 +406,11 @@ void J3DPatchedMaterial::initialize() {
}
/* 80316FD8-80316FDC 311918 0004+00 1/0 0/0 0/0 .text makeDisplayList__18J3DPatchedMaterialFv */
-void J3DPatchedMaterial::makeDisplayList() {
- /* empty function */
-}
+void J3DPatchedMaterial::makeDisplayList() {}
/* 80316FDC-80316FE0 31191C 0004+00 1/0 0/0 0/0 .text
* makeSharedDisplayList__18J3DPatchedMaterialFv */
-void J3DPatchedMaterial::makeSharedDisplayList() {
- /* empty function */
-}
+void J3DPatchedMaterial::makeSharedDisplayList() {}
/* 80316FE0-80316FFC 311920 001C+00 1/0 0/0 0/0 .text load__18J3DPatchedMaterialFv */
void J3DPatchedMaterial::load() {
@@ -413,14 +428,10 @@ void J3DPatchedMaterial::loadSharedDL() {
}
/* 8031703C-80317040 31197C 0004+00 1/0 0/0 0/0 .text reset__18J3DPatchedMaterialFv */
-void J3DPatchedMaterial::reset() {
- /* empty function */
-}
+void J3DPatchedMaterial::reset() {}
/* 80317040-80317044 311980 0004+00 1/0 0/0 0/0 .text change__18J3DPatchedMaterialFv */
-void J3DPatchedMaterial::change() {
- /* empty function */
-}
+void J3DPatchedMaterial::change() {}
/* 80317044-80317064 311984 0020+00 0/0 1/1 0/0 .text initialize__17J3DLockedMaterialFv
*/
@@ -429,15 +440,11 @@ void J3DLockedMaterial::initialize() {
}
/* 80317064-80317068 3119A4 0004+00 1/0 0/0 0/0 .text makeDisplayList__17J3DLockedMaterialFv */
-void J3DLockedMaterial::makeDisplayList() {
- /* empty function */
-}
+void J3DLockedMaterial::makeDisplayList() {}
/* 80317068-8031706C 3119A8 0004+00 1/0 0/0 0/0 .text makeSharedDisplayList__17J3DLockedMaterialFv
*/
-void J3DLockedMaterial::makeSharedDisplayList() {
- /* empty function */
-}
+void J3DLockedMaterial::makeSharedDisplayList() {}
/* 8031706C-80317088 3119AC 001C+00 1/0 0/0 0/0 .text load__17J3DLockedMaterialFv */
void J3DLockedMaterial::load() {
@@ -456,26 +463,16 @@ void J3DLockedMaterial::loadSharedDL() {
}
/* 803170C8-803170CC 311A08 0004+00 1/0 0/0 0/0 .text patch__17J3DLockedMaterialFv */
-void J3DLockedMaterial::patch() {
- /* empty function */
-}
+void J3DLockedMaterial::patch() {}
/* 803170CC-803170D0 311A0C 0004+00 1/0 0/0 0/0 .text diff__17J3DLockedMaterialFUl */
-void J3DLockedMaterial::diff(u32 param_0) {
- /* empty function */
-}
+void J3DLockedMaterial::diff(u32 diffFlags) {}
/* 803170D0-803170D4 311A10 0004+00 1/0 0/0 0/0 .text calc__17J3DLockedMaterialFPA4_Cf */
-void J3DLockedMaterial::calc(const Mtx param_0) {
- /* empty function */
-}
+void J3DLockedMaterial::calc(const Mtx param_0) {}
/* 803170D4-803170D8 311A14 0004+00 1/0 0/0 0/0 .text reset__17J3DLockedMaterialFv */
-void J3DLockedMaterial::reset() {
- /* empty function */
-}
+void J3DLockedMaterial::reset() {}
/* 803170D8-803170DC 311A18 0004+00 1/0 0/0 0/0 .text change__17J3DLockedMaterialFv */
-void J3DLockedMaterial::change() {
- /* empty function */
-}
+void J3DLockedMaterial::change() {}
diff --git a/src/JSystem/J3DGraphBase/J3DPacket.cpp b/src/JSystem/J3DGraphBase/J3DPacket.cpp
index b612d8ed64..88edce5636 100644
--- a/src/JSystem/J3DGraphBase/J3DPacket.cpp
+++ b/src/JSystem/J3DGraphBase/J3DPacket.cpp
@@ -9,63 +9,64 @@
#include "string.h"
#include "global.h"
-J3DError J3DDisplayListObj::newDisplayList(u32 capacity) {
- mCapacity = ALIGN_NEXT(capacity, 0x20);
- mpData[0] = new (0x20) char[mCapacity];
- mpData[1] = new (0x20) char[mCapacity];
+J3DError J3DDisplayListObj::newDisplayList(u32 maxSize) {
+ mMaxSize = ALIGN_NEXT(maxSize, 0x20);
+ mpDisplayList[0] = new (0x20) char[mMaxSize];
+ mpDisplayList[1] = new (0x20) char[mMaxSize];
mSize = 0;
- if (mpData[0] == NULL || mpData[1] == NULL)
+ if (mpDisplayList[0] == NULL || mpDisplayList[1] == NULL)
return kJ3DError_Alloc;
return kJ3DError_Success;
}
-J3DError J3DDisplayListObj::newSingleDisplayList(u32 capacity) {
- mCapacity = ALIGN_NEXT(capacity, 0x20);
- mpData[0] = new (0x20) char[mCapacity];
- mpData[1] = mpData[0];
+J3DError J3DDisplayListObj::newSingleDisplayList(u32 maxSize) {
+ mMaxSize = ALIGN_NEXT(maxSize, 0x20);
+ mpDisplayList[0] = new (0x20) char[mMaxSize];
+ mpDisplayList[1] = mpDisplayList[0];
mSize = 0;
- if (mpData[0] == NULL)
+ if (mpDisplayList[0] == NULL)
return kJ3DError_Alloc;
return kJ3DError_Success;
}
/* 8031256C-803125E4 30CEAC 0078+00 0/0 1/1 0/0 .text single_To_Double__17J3DDisplayListObjFv */
-J3DError J3DDisplayListObj::single_To_Double() {
- if (mpData[0] == mpData[1]) {
- mpData[1] = new (0x20) char[mCapacity];
+int J3DDisplayListObj::single_To_Double() {
+ if (mpDisplayList[0] == mpDisplayList[1]) {
+ mpDisplayList[1] = new (0x20) char[mMaxSize];
- if (mpData[1] == NULL)
+ if (mpDisplayList[1] == NULL)
return kJ3DError_Alloc;
- memcpy(mpData[1], mpData[0], mCapacity);
- DCStoreRange(mpData[1], mCapacity);
+ memcpy(mpDisplayList[1], mpDisplayList[0], mMaxSize);
+ DCStoreRange(mpDisplayList[1], mMaxSize);
}
return kJ3DError_Success;
}
void J3DDisplayListObj::setSingleDisplayList(void* pDLData, u32 size) {
- mCapacity = ALIGN_NEXT(size, 0x20);
- mpData[0] = pDLData;
- mpData[1] = mpData[0];
+ J3D_ASSERT_NULLPTR(148, pDLData != NULL);
+
+ mMaxSize = ALIGN_NEXT(size, 0x20);
+ mpDisplayList[0] = pDLData;
+ mpDisplayList[1] = mpDisplayList[0];
mSize = size;
}
void J3DDisplayListObj::swapBuffer() {
- void* pTmp = mpData[0];
- mpData[0] = mpData[1];
- mpData[1] = pTmp;
+ void* pTmp = mpDisplayList[0];
+ mpDisplayList[0] = mpDisplayList[1];
+ mpDisplayList[1] = pTmp;
}
void J3DDisplayListObj::callDL() const {
- GXCallDisplayList(mpData[0], mSize);
+ GXCallDisplayList(mpDisplayList[0], mSize);
}
-/* ############################################################################################## */
/* 80434C70-80434C80 061990 0010+00 2/2 3/3 0/0 .bss sGDLObj__17J3DDisplayListObj */
GDLObj J3DDisplayListObj::sGDLObj;
@@ -77,7 +78,7 @@ s32 J3DDisplayListObj::sInterruptFlag;
void J3DDisplayListObj::beginDL() {
swapBuffer();
sInterruptFlag = OSDisableInterrupts();
- GDInitGDLObj(&sGDLObj, (u8*)mpData[0], mCapacity);
+ GDInitGDLObj(&sGDLObj, (u8*)mpDisplayList[0], mMaxSize);
GDSetCurrent(&sGDLObj);
}
@@ -105,28 +106,44 @@ u32 J3DDisplayListObj::endPatch() {
}
/* 80312750-80312758 30D090 0008+00 3/0 16/0 10/0 .text entry__9J3DPacketFP13J3DDrawBuffer */
-int J3DPacket::entry(J3DDrawBuffer*) {
+int J3DPacket::entry(J3DDrawBuffer* pBuffer) {
+ J3D_ASSERT_NULLPTR(290, pBuffer != NULL);
return 1;
}
void J3DPacket::addChildPacket(J3DPacket* pPacket) {
+ J3D_ASSERT_NULLPTR(304, pPacket != NULL);
+
if (mpFirstChild == NULL) {
mpFirstChild = pPacket;
} else {
- pPacket->mpNextPacket = mpFirstChild;
+ pPacket->setNextPacket(mpFirstChild);
mpFirstChild = pPacket;
}
}
-/* ############################################################################################## */
/* 803CD900-803CD920 02AA20 0020+00 1/1 0/0 0/0 .data sDifferedRegister */
static u32 sDifferedRegister[8] = {
- 0x00000004, 0x00000001, 0x00000002, 0x01000000, 0x10000000, 0x20000000, 0x02000000, 0x08000000,
+ J3DDiffFlag_AmbColor,
+ J3DDiffFlag_MatColor,
+ J3DDiffFlag_ColorChan,
+ J3DDiffFlag_TevReg,
+ J3DDiffFlag_Fog,
+ J3DDiffFlag_Blend,
+ J3DDiffFlag_KonstColor,
+ J3DDiffFlag_TevStageIndirect,
};
/* 803CD920-803CD940 02AA40 0020+00 1/1 0/0 0/0 .data sSizeOfDiffered */
static s32 sSizeOfDiffered[8] = {
- 13, 13, 21, 120, 55, 15, 19, 45,
+ 13,
+ 13,
+ 21,
+ 120,
+ 55,
+ 15,
+ 19,
+ 45,
};
/* 80312778-803127B0 30D0B8 0038+00 2/2 0/0 0/0 .text __ct__13J3DDrawPacketFv */
@@ -169,7 +186,7 @@ J3DError J3DDrawPacket::newSingleDisplayList(u32 size) {
}
void J3DDrawPacket::draw() {
- mpDisplayListObj->callDL();
+ callDL();
}
/* 80312948-803129A4 30D288 005C+00 0/0 1/1 0/0 .text __ct__12J3DMatPacketFv */
@@ -177,7 +194,7 @@ J3DMatPacket::J3DMatPacket() {
mpInitShapePacket = NULL;
mpShapePacket = NULL;
mpMaterial = NULL;
- mDiffFlag = -1;
+ mDiffFlag = 0xFFFFFFFF;
mpTexture = NULL;
mpMaterialAnm = NULL;
}
@@ -189,37 +206,32 @@ void J3DMatPacket::addShapePacket(J3DShapePacket* pShape) {
if (mpShapePacket == NULL) {
mpShapePacket = pShape;
} else {
- pShape->mpNextPacket = mpShapePacket;
+ pShape->setNextPacket(mpShapePacket);
mpShapePacket = pShape;
}
}
void J3DMatPacket::beginDiff() {
- mpInitShapePacket->mpDisplayListObj->beginDL();
+ mpInitShapePacket->beginDL();
}
void J3DMatPacket::endDiff() {
- mpInitShapePacket->mpDisplayListObj->endDL();
+ mpInitShapePacket->endDL();
}
/* 80312A74-80312A9C 30D3B4 0028+00 0/0 1/1 0/0 .text isSame__12J3DMatPacketCFP12J3DMatPacket */
bool J3DMatPacket::isSame(J3DMatPacket* pOther) const {
- bool isSame = false;
-
- if (mDiffFlag == pOther->mDiffFlag && !(mDiffFlag >> 0x1F)) {
- isSame = true;
- }
- return isSame;
+ J3D_ASSERT_NULLPTR(521, pOther != NULL);
+ return mDiffFlag == pOther->mDiffFlag && (mDiffFlag >> 31) == 0;
}
/* 80312A9C-80312B20 30D3DC 0084+00 1/0 0/0 0/0 .text draw__12J3DMatPacketFv */
void J3DMatPacket::draw() {
mpMaterial->load();
callDL();
- J3DShapePacket* packet = getShapePacket();
- J3DShape* shape = packet->getShape();
- shape->loadPreDrawSetting();
+ J3DShapePacket* packet = getShapePacket();
+ packet->getShape()->loadPreDrawSetting();
while (packet != NULL) {
if (packet->getDisplayListObj() != NULL) {
@@ -230,7 +242,7 @@ void J3DMatPacket::draw() {
packet = (J3DShapePacket*)packet->getNextPacket();
}
- shape->resetVcdVatCache();
+ J3DShape::resetVcdVatCache();
}
/* 80312B20-80312B74 30D460 0054+00 0/0 1/1 0/0 .text __ct__14J3DShapePacketFv */
@@ -247,76 +259,83 @@ J3DShapePacket::~J3DShapePacket() {}
/* 80312BD4-80312DBC 30D514 01E8+00 1/1 0/0 0/0 .text calcDifferedBufferSize__14J3DShapePacketFUl
*/
-u32 J3DShapePacket::calcDifferedBufferSize(u32 flag) {
- int iVar5 = 0;
- for (int i = 0; i < 8; i++) {
- if ((flag & sDifferedRegister[i]) != 0) {
- iVar5 += sSizeOfDiffered[i];
+u32 J3DShapePacket::calcDifferedBufferSize(u32 diffFlags) {
+ u32 bufferSize = 0;
+
+ for (u32 i = 0; i < 8; i++) {
+ if ((diffFlags & sDifferedRegister[i]) != 0) {
+ bufferSize += sSizeOfDiffered[i];
}
}
- iVar5 += getDiffFlag_LightObjNum(flag) * 0x48;
- u32 uVar2 = getDiffFlag_TexGenNum(flag);
- if (uVar2 != 0) {
- u32 local_4c = mpShape->getMaterial()->getTexGenNum();
- if (uVar2 > local_4c) {
- local_4c = uVar2;
- }
- if ((flag & 0x1000)) {
- iVar5 += calcDifferedBufferSize_TexGenSize(local_4c);
+ u32 lightObjNum = getDiffFlag_LightObjNum(diffFlags);
+ bufferSize += lightObjNum * 0x48;
+
+ u32 texGenNum = getDiffFlag_TexGenNum(diffFlags);
+ if (texGenNum != 0) {
+ u32 mat_texGenNum = mpShape->getMaterial()->getTexGenNum();
+ u32 sp30 = texGenNum > mat_texGenNum ? texGenNum : mat_texGenNum;
+
+ if (diffFlags & J3DDiffFlag_TexGen) {
+ bufferSize += calcDifferedBufferSize_TexGenSize(sp30);
} else {
- iVar5 += calcDifferedBufferSize_TexMtxSize(local_4c);
+ bufferSize += calcDifferedBufferSize_TexMtxSize(sp30);
}
}
- uVar2 = getDiffFlag_TexNoNum(flag);
- if (uVar2 != 0) {
- u8 local_58;
+ u32 texNoNum = getDiffFlag_TexNoNum(diffFlags);
+ if (texNoNum != 0) {
+ u8 sp9;
if (mpShape->getMaterial()->getTevStageNum() > 8) {
- local_58 = 8;
+ sp9 = 8;
} else {
- local_58 = mpShape->getMaterial()->getTevStageNum();
+ sp9 = mpShape->getMaterial()->getTevStageNum();
}
- u32 local_50 = local_58;
- local_50 = uVar2 > local_50 ? uVar2 : local_50;
- if ((flag & 0x4000000)) {
- iVar5 += calcDifferedBufferSize_TexNoAndTexCoordScaleSize(local_50);
+
+ u32 mat_texNoNum = sp9;
+ u32 sp24 = texNoNum > mat_texNoNum ? texNoNum : mat_texNoNum;
+
+ if (diffFlags & J3DDiffFlag_TexCoordScale) {
+ bufferSize += calcDifferedBufferSize_TexNoAndTexCoordScaleSize(sp24);
} else {
- iVar5 += calcDifferedBufferSize_TexNoSize(local_50);
+ bufferSize += calcDifferedBufferSize_TexNoSize(sp24);
}
}
- uVar2 = getDiffFlag_TevStageNum(flag);
- if (uVar2 != 0) {
- u8 local_58;
+ u32 tevStageNum = getDiffFlag_TevStageNum(diffFlags);
+ if (tevStageNum != 0) {
+ u8 sp8;
if (mpShape->getMaterial()->getTevStageNum() > 8) {
- local_58 = 8;
+ sp8 = 8;
} else {
- local_58 = mpShape->getMaterial()->getTevStageNum();
+ sp8 = mpShape->getMaterial()->getTevStageNum();
}
- u32 local_50 = local_58;
- local_50 = uVar2 > local_50 ? uVar2 : local_50;
- iVar5 += calcDifferedBufferSize_TevStageSize(local_50);
- if (flag & 0x8000000) {
- iVar5 += calcDifferedBufferSize_TevStageDirectSize(local_50);
+
+ u32 mat_tevStageNum = sp8;
+ u32 sp18 = tevStageNum > mat_tevStageNum ? tevStageNum : mat_tevStageNum;
+
+ bufferSize += calcDifferedBufferSize_TevStageSize(sp18);
+ if (diffFlags & J3DDiffFlag_TevStageIndirect) {
+ bufferSize += calcDifferedBufferSize_TevStageDirectSize(sp18);
}
}
- return (iVar5 + 0x1f) & ~0x1f;
+ return OSRoundUp32B(bufferSize);
}
/* 80312DBC-80312E08 30D6FC 004C+00 0/0 1/1 0/0 .text newDifferedDisplayList__14J3DShapePacketFUl
*/
-J3DError J3DShapePacket::newDifferedDisplayList(u32 flag) {
- mDiffFlag = flag;
- u32 bufSize = calcDifferedBufferSize(flag);
- J3DError error = newDisplayList(bufSize);
+int J3DShapePacket::newDifferedDisplayList(u32 diffFlags) {
+ mDiffFlag = diffFlags;
- if (error != kJ3DError_Success) {
- return error;
+ u32 bufSize = calcDifferedBufferSize(diffFlags);
+ int ret = newDisplayList(bufSize);
+ if (ret != kJ3DError_Success) {
+ return ret;
}
- setDisplayListObj(getDisplayListObj());
+ J3DDisplayListObj* dlobj = getDisplayListObj();
+ setDisplayListObj(dlobj);
return kJ3DError_Success;
}
@@ -326,8 +345,7 @@ void J3DShapePacket::prepareDraw() const {
j3dSys.setModel(mpModel);
j3dSys.setShapePacket((J3DShapePacket*)this);
- // the way that the LOD flag is set seems to be wrong...
- J3DShapeMtx::setLODFlag(mpModel->checkFlag(0x10));
+ J3DShapeMtx::setLODFlag(mpModel->checkFlag(J3DMdlFlag_EnableLOD) != 0);
if (mpModel->checkFlag(J3DMdlFlag_SkinPosCpu)) {
mpShape->onFlag(J3DShpFlag_SkinPosCpu);
@@ -343,15 +361,14 @@ void J3DShapePacket::prepareDraw() const {
mpShape->offFlag(J3DShpFlag_SkinNrmCpu);
}
- J3DMtxBuffer* buffer = mpMtxBuffer;
- mpShape->setCurrentViewNoPtr(buffer->getCurrentViewNoPtr());
- mpShape->setScaleFlagArray(buffer->getScaleFlagArray());
- mpShape->setDrawMtx(buffer->getDrawMtxPtrPtr());
+ mpShape->setCurrentViewNoPtr(mpMtxBuffer->getCurrentViewNoPtr());
+ mpShape->setScaleFlagArray(mpMtxBuffer->getScaleFlagArray());
+ mpShape->setDrawMtx(mpMtxBuffer->getDrawMtxPtrPtr());
if (!mpShape->getNBTFlag()) {
- mpShape->setNrmMtx(buffer->getNrmMtxPtrPtr());
+ mpShape->setNrmMtx(mpMtxBuffer->getNrmMtxPtrPtr());
} else {
- mpShape->setNrmMtx(buffer->getBumpMtxPtrPtr()[mpShape->getBumpMtxOffset()]);
+ mpShape->setNrmMtx(mpMtxBuffer->mpBumpMtxArr[1][mpShape->getBumpMtxOffset()]);
}
mpModel->getModelData()->syncJ3DSysFlags();
@@ -363,8 +380,7 @@ void J3DShapePacket::draw() {
prepareDraw();
if (mpTexMtxObj != NULL) {
- J3DMaterial* material = mpShape->getMaterial();
- J3DDifferedTexMtx::sTexGenBlock = material->getTexGenBlock();
+ J3DDifferedTexMtx::sTexGenBlock = mpShape->getMaterial()->getTexGenBlock();
J3DDifferedTexMtx::sTexMtxObj = getTexMtxObj();
} else {
J3DDifferedTexMtx::sTexGenBlock = NULL;
@@ -384,8 +400,7 @@ void J3DShapePacket::drawFast() {
prepareDraw();
if (mpTexMtxObj != NULL) {
- J3DMaterial* material = mpShape->getMaterial();
- J3DDifferedTexMtx::sTexGenBlock = material->getTexGenBlock();
+ J3DDifferedTexMtx::sTexGenBlock = mpShape->getMaterial()->getTexGenBlock();
J3DDifferedTexMtx::sTexMtxObj = getTexMtxObj();
} else {
J3DDifferedTexMtx::sTexGenBlock = NULL;
@@ -399,7 +414,7 @@ void J3DShapePacket::drawFast() {
void J3DPacket::draw() {}
/* 80313048-803130A8 30D988 0060+00 1/0 0/0 0/0 .text entry__12J3DMatPacketFP13J3DDrawBuffer */
-int J3DMatPacket::entry(J3DDrawBuffer* i_buffer) {
- sortFunc func = J3DDrawBuffer::sortFuncTable[i_buffer->mSortType];
- return (i_buffer->*func)(this);
+int J3DMatPacket::entry(J3DDrawBuffer* pBuffer) {
+ J3DDrawBuffer::sortFunc func = J3DDrawBuffer::sortFuncTable[pBuffer->getSortMode()];
+ return (pBuffer->*func)(this);
}
diff --git a/src/JSystem/J3DGraphBase/J3DShape.cpp b/src/JSystem/J3DGraphBase/J3DShape.cpp
index fee08feb08..b825f095b1 100644
--- a/src/JSystem/J3DGraphBase/J3DShape.cpp
+++ b/src/JSystem/J3DGraphBase/J3DShape.cpp
@@ -1,18 +1,13 @@
#include "JSystem/J3DGraphBase/J3DShape.h"
#include "JSystem/J3DGraphBase/J3DPacket.h"
#include "JSystem/J3DGraphBase/J3DVertex.h"
-#include "dolphin/gd.h"
-#include "dolphin/os.h"
+#include "JSystem/J3DGraphBase/J3DFifo.h"
+#include <dolphin/gd.h>
void J3DGDSetVtxAttrFmtv(_GXVtxFmt, GXVtxAttrFmtList const*, bool);
void J3DFifoLoadPosMtxImm(Mtx, u32);
void J3DFifoLoadNrmMtxImm(Mtx, u32);
-
-enum {
- kVcdVatDLSize = 0xC0,
-};
-
void J3DShape::initialize() {
mMaterial = NULL;
mIndex = -1;
@@ -62,19 +57,24 @@ void J3DShape::addTexMtxIndexInDL(GXAttr attr, u32 valueBase) {
if (pnmtxidxOffs == -1)
return;
- for (u16 i = 0; i < getMtxGroupNum(); i++)
+ for (u16 i = 0; i < (u16)getMtxGroupNum(); i++)
getShapeDraw(i)->addTexMtxIndexInDL(stride, attrOffs, (s32)valueBase);
}
/* 80314CBC-80314DA8 30F5FC 00EC+00 0/0 1/1 0/0 .text addTexMtxIndexInVcd__8J3DShapeF7_GXAttr */
void J3DShape::addTexMtxIndexInVcd(GXAttr attr) {
+ u32 kSize[] = {0, 1, 1, 2}; // stripped data
+
s32 attrIdx = -1;
- GXVtxDescList* vtxDesc = mVtxDesc;
+ s32 attrOffs = -1;
+ s32 stride = 0;
+
+ GXVtxDescList* vtxDesc = getVtxDesc();
s32 attrCount = 0;
for (; vtxDesc->attr != GX_VA_NULL; attrCount++, vtxDesc++) {
if (vtxDesc->attr == GX_VA_PNMTXIDX)
- attrIdx = 0;
+ attrIdx = stride;
}
if (attrIdx == -1)
@@ -83,17 +83,21 @@ void J3DShape::addTexMtxIndexInVcd(GXAttr attr) {
GXVtxDescList* newVtxDesc = new GXVtxDescList[attrCount + 2];
bool inserted = false;
- vtxDesc = mVtxDesc;
+ vtxDesc = getVtxDesc();
GXVtxDescList* dst = newVtxDesc;
for (; vtxDesc->attr != GX_VA_NULL; dst++, vtxDesc++) {
if ((attr < vtxDesc->attr) && !inserted) {
dst->attr = attr;
dst->type = GX_DIRECT;
- inserted = true;
+ attrOffs = stride;
dst++;
+
+ inserted = true;
}
- *dst = *vtxDesc;
+ dst->attr = vtxDesc->attr;
+ dst->type = vtxDesc->type;
+ stride = stride + kSize[vtxDesc->type];
}
dst->attr = GX_VA_NULL;
@@ -104,7 +108,7 @@ void J3DShape::addTexMtxIndexInVcd(GXAttr attr) {
/* 80314DA8-80314E28 30F6E8 0080+00 0/0 1/1 0/0 .text
* calcNBTScale__8J3DShapeFRC3VecPA3_A3_fPA3_A3_f */
-void J3DShape::calcNBTScale(Vec const& param_0, f32 (*param_1)[3][3], f32 (*param_2)[3][3]) {
+void J3DShape::calcNBTScale(const Vec& param_0, f32 (*param_1)[3][3], f32 (*param_2)[3][3]) {
for (u16 i = 0; i < mMtxGroupNum; i++)
mShapeMtx[i]->calcNBTScale(param_0, param_1, param_2);
}
@@ -114,28 +118,31 @@ u16 J3DShape::countBumpMtxNum() const {
u16 num = 0;
for (u16 i = 0; i < mMtxGroupNum; i++)
num += mShapeMtx[i]->getUseMtxNum();
+
return num;
}
/* 80314E98-80314EB0 30F7D8 0018+00 1/1 0/0 0/0 .text J3DLoadCPCmd__FUcUl */
-void J3DLoadCPCmd(u8 cmd, u32 param) {
- GXWGFifo.u8 = GX_LOAD_CP_REG;
- GXWGFifo.u8 = cmd;
- GXWGFifo.u32 = param;
+void J3DLoadCPCmd(u8 addr, u32 val) {
+ GXCmd1u8(GX_LOAD_CP_REG);
+ GXCmd1u8(addr);
+ GXCmd1u32(val);
}
/* 80314EB0-80314EEC 30F7F0 003C+00 1/1 0/0 0/0 .text J3DLoadArrayBasePtr__F7_GXAttrPv */
-static void J3DLoadArrayBasePtr(_GXAttr attr, void* data) {
+static void J3DLoadArrayBasePtr(GXAttr attr, void* data) {
u32 idx = (attr == GX_VA_NBT) ? 1 : (attr - GX_VA_POS);
- J3DLoadCPCmd(0xA0 + idx, ((u32)data & 0x7FFFFFFF));
+ J3DLoadCPCmd(0xA0 + idx, ((uintptr_t)data & 0x7FFFFFFF));
}
/* 80314EEC-80314F5C 30F82C 0070+00 3/3 0/0 0/0 .text loadVtxArray__8J3DShapeCFv */
void J3DShape::loadVtxArray() const {
J3DLoadArrayBasePtr(GX_VA_POS, j3dSys.getVtxPos());
+
if (!mHasNBT) {
J3DLoadArrayBasePtr(GX_VA_NRM, j3dSys.getVtxNrm());
}
+
J3DLoadArrayBasePtr(GX_VA_CLR0, j3dSys.getVtxCol());
}
@@ -146,6 +153,7 @@ bool J3DShape::isSameVcdVatCmd(J3DShape* other) {
for (u32 i = 0; i < kVcdVatDLSize; i++)
if (a[i] != b[i])
return false;
+
return true;
}
@@ -153,9 +161,9 @@ bool J3DShape::isSameVcdVatCmd(J3DShape* other) {
void J3DShape::makeVtxArrayCmd() {
GXVtxAttrFmtList* vtxAttr = mVertexData->getVtxAttrFmtList();
- u8 stride[0x0C];
- void* array[0x0C];
- for (u32 i = 0; i < 0x0C; i++) {
+ u8 stride[12];
+ void* array[12];
+ for (u32 i = 0; i < 12; i++) {
stride[i] = 0;
array[i] = 0;
}
@@ -164,27 +172,28 @@ void J3DShape::makeVtxArrayCmd() {
switch (vtxAttr->attr) {
case GX_VA_POS: {
if (vtxAttr->type == GX_F32)
- stride[vtxAttr->attr - GX_VA_POS] = 0x0C;
+ stride[vtxAttr->attr - GX_VA_POS] = 12;
else
- stride[vtxAttr->attr - GX_VA_POS] = 0x06;
+ stride[vtxAttr->attr - GX_VA_POS] = 6;
+
array[vtxAttr->attr - GX_VA_POS] = mVertexData->getVtxPosArray();
- mVertexData->setVtxPosFrac(vtxAttr->frac);
+ mVertexData->setVtxPosFrac((u8)vtxAttr->frac);
mVertexData->setVtxPosType((GXCompType)vtxAttr->type);
} break;
case GX_VA_NRM: {
if (vtxAttr->type == GX_F32)
- stride[vtxAttr->attr - GX_VA_POS] = 0x0C;
+ stride[vtxAttr->attr - GX_VA_POS] = 12;
else
- stride[vtxAttr->attr - GX_VA_POS] = 0x06;
+ stride[vtxAttr->attr - GX_VA_POS] = 6;
+
array[vtxAttr->attr - GX_VA_POS] = mVertexData->getVtxNrmArray();
- mVertexData->setVtxNrmFrac(vtxAttr->frac);
+ mVertexData->setVtxNrmFrac((u8)vtxAttr->frac);
mVertexData->setVtxNrmType((GXCompType)vtxAttr->type);
} break;
case GX_VA_CLR0:
case GX_VA_CLR1: {
- stride[vtxAttr->attr - GX_VA_POS] = 0x04;
- array[vtxAttr->attr - GX_VA_POS] =
- mVertexData->getVtxColorArray(vtxAttr->attr - GX_VA_CLR0);
+ stride[vtxAttr->attr - GX_VA_POS] = 4;
+ array[vtxAttr->attr - GX_VA_POS] = mVertexData->getVtxColorArray(vtxAttr->attr - GX_VA_CLR0);
} break;
case GX_VA_TEX0:
case GX_VA_TEX1:
@@ -195,11 +204,11 @@ void J3DShape::makeVtxArrayCmd() {
case GX_VA_TEX6:
case GX_VA_TEX7: {
if (vtxAttr->type == GX_F32)
- stride[vtxAttr->attr - GX_VA_POS] = 0x08;
+ stride[vtxAttr->attr - GX_VA_POS] = 8;
else
- stride[vtxAttr->attr - GX_VA_POS] = 0x04;
- array[vtxAttr->attr - GX_VA_POS] =
- mVertexData->getVtxTexCoordArray(vtxAttr->attr - GX_VA_TEX0);
+ stride[vtxAttr->attr - GX_VA_POS] = 4;
+
+ array[vtxAttr->attr - GX_VA_POS] = mVertexData->getVtxTexCoordArray(vtxAttr->attr - GX_VA_TEX0);
} break;
default:
break;
@@ -218,7 +227,7 @@ void J3DShape::makeVtxArrayCmd() {
}
}
- for (u32 i = 0; i < 0x0C; i++) {
+ for (u32 i = 0; i < 12; i++) {
if (array[i] != 0)
GDSetArray((GXAttr)(i + GX_VA_POS), array[i], stride[i]);
else
@@ -226,19 +235,9 @@ void J3DShape::makeVtxArrayCmd() {
}
}
-/* ############################################################################################## */
-/* 804515C8-804515CC 000AC8 0004+00 1/1 0/0 0/0 .sbss sInterruptFlag$903 */
-static s32 sInterruptFlag;
-
-/* 804515CC-804515D0 000ACC 0004+00 1/1 0/0 0/0 .sbss None */
-static s8 sInitInterruptFlag;
-
/* 80315260-80315300 30FBA0 00A0+00 1/1 2/2 0/0 .text makeVcdVatCmd__8J3DShapeFv */
void J3DShape::makeVcdVatCmd() {
- if (!sInitInterruptFlag) {
- sInterruptFlag = OSDisableInterrupts();
- sInitInterruptFlag = true;
- }
+ static BOOL sInterruptFlag = OSDisableInterrupts();
OSDisableScheduler();
GDLObj gdl_obj;
@@ -254,10 +253,13 @@ void J3DShape::makeVcdVatCmd() {
OSRestoreInterrupts(sInterruptFlag);
}
-/* ############################################################################################## */
/* 804515D0-804515D4 000AD0 0004+00 5/5 25/25 9/9 .sbss sOldVcdVatCmd__8J3DShape */
void* J3DShape::sOldVcdVatCmd;
+void J3DShape::loadCurrentMtx() const {
+ mCurrentMtx.load();
+}
+
/* 80315300-80315398 30FC40 0098+00 2/2 6/6 3/3 .text loadPreDrawSetting__8J3DShapeCFv */
void J3DShape::loadPreDrawSetting() const {
if (sOldVcdVatCmd != mVcdVatCmd) {
@@ -268,9 +270,8 @@ void J3DShape::loadPreDrawSetting() const {
mCurrentMtx.load();
}
-/* ############################################################################################## */
/* 804515D4-804515D8 000AD4 0004+00 3/3 0/0 0/0 .sbss None */
-static u8 data_804515D4[4];
+bool J3DShape::sEnvelopeFlag;
/* 80315398-8031544C 30FCD8 00B4+00 1/1 0/0 0/0 .text setArrayAndBindPipeline__8J3DShapeCFv */
void J3DShape::setArrayAndBindPipeline() const {
@@ -279,10 +280,8 @@ void J3DShape::setArrayAndBindPipeline() const {
j3dSys.setModelDrawMtx(mDrawMtx[*mCurrentViewNo]);
j3dSys.setModelNrmMtx(mNrmMtx[*mCurrentViewNo]);
J3DShapeMtx::sCurrentScaleFlag = mScaleFlagArray;
- // The below struct_804515B0 is actually a continuation of sCurrentScaleFlag, I believe?
- // Also, there seems to be an extra entry in the array that's only there in DEBUG builds.
J3DShapeMtx::sNBTFlag = mHasNBT;
- data_804515D4[0] = mHasPNMTXIdx;
+ sEnvelopeFlag = mHasPNMTXIdx;
J3DShapeMtx::sTexMtxLoadType = getTexMtxLoadType();
}
@@ -293,13 +292,12 @@ void J3DShape::drawFast() const {
sOldVcdVatCmd = mVcdVatCmd;
}
- if (data_804515D4[0] != 0 && !mHasPNMTXIdx)
+ if (sEnvelopeFlag != 0 && !mHasPNMTXIdx)
mCurrentMtx.load();
setArrayAndBindPipeline();
if (!checkFlag(J3DShpFlag_NoMtx)) {
- // LOD flag shenanigans
- if (J3DShapeMtx::getLODFlag() != 0)
+ if (J3DShapeMtx::getLODFlag())
J3DShapeMtx::resetMtxLoadCache();
for (u16 n = mMtxGroupNum, i = 0; i < n; i++) {
@@ -344,7 +342,7 @@ void J3DShape::simpleDrawCache() const {
sOldVcdVatCmd = mVcdVatCmd;
}
- if (data_804515D4[0] != 0 && !mHasPNMTXIdx)
+ if (sEnvelopeFlag && !mHasPNMTXIdx)
mCurrentMtx.load();
loadVtxArray();
diff --git a/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp b/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp
index ee7ada7dee..a5f933cb95 100644
--- a/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp
+++ b/src/JSystem/J3DGraphBase/J3DShapeDraw.cpp
@@ -1,20 +1,15 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DShapeDraw
-//
-
#include "JSystem/J3DGraphBase/J3DShapeDraw.h"
#include "JSystem/JKernel/JKRHeap.h"
-#include "string.h"
-#include "dolphin/gx.h"
-#include <dolphin/os.h>
-#include "global.h"
+#include <string.h>
+#include <stdint.h>
+#include <dolphin/gx.h>
/* 80314924-80314974 30F264 0050+00 1/1 0/0 0/0 .text countVertex__12J3DShapeDrawFUl */
u32 J3DShapeDraw::countVertex(u32 stride) {
u32 count = 0;
- u32 dlStart = (u32)getDisplayList();
- for (u8* dl = (u8*)dlStart; ((u32)dl - dlStart) < getDisplayListSize();) {
+ uintptr_t dlStart = (uintptr_t)getDisplayList();
+
+ for (u8* dl = (u8*)dlStart; ((uintptr_t)dl - dlStart) < getDisplayListSize();) {
if (*dl != GX_TRIANGLEFAN && *dl != GX_TRIANGLESTRIP)
break;
u16 vtxNum = *((u16*)(dl + 1));
@@ -22,6 +17,7 @@ u32 J3DShapeDraw::countVertex(u32 stride) {
dl += stride * vtxNum;
dl += 3;
}
+
return count;
}
@@ -34,6 +30,7 @@ void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) {
u8* oldDLStart = getDisplayList();
u8* oldDL = oldDLStart;
u8* newDL = newDLStart;
+
for (; (oldDL - oldDLStart) < mDisplayListSize;) {
// Copy command
u8 h = *oldDL;
@@ -62,16 +59,17 @@ void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) {
oldDL += 3;
}
- u32 realSize = ALIGN_NEXT((u32)newDL - (u32)newDLStart, 0x20);
+ u32 realSize = ALIGN_NEXT((uintptr_t)newDL - (uintptr_t)newDLStart, 0x20);
for (; (newDL - newDLStart) < newSize; newDL++)
*newDL = 0;
+
mDisplayListSize = realSize;
mDisplayList = newDLStart;
DCStoreRange(newDLStart, mDisplayListSize);
}
/* 80314ABC-80314AD4 30F3FC 0018+00 0/0 1/1 0/0 .text __ct__12J3DShapeDrawFPCUcUl */
-J3DShapeDraw::J3DShapeDraw(u8 const* displayList, u32 displayListSize) {
+J3DShapeDraw::J3DShapeDraw(const u8* displayList, u32 displayListSize) {
mDisplayList = (void*)displayList;
mDisplayListSize = displayListSize;
}
diff --git a/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp b/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp
index e3fc9f2bc1..d2292e6f0c 100644
--- a/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp
+++ b/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp
@@ -1,14 +1,8 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DShapeMtx
-//
-
#include "JSystem/J3DGraphBase/J3DShapeMtx.h"
#include "JSystem/J3DGraphAnimator/J3DModel.h"
-#include "JSystem/J3DGraphBase/J3DGD.h"
+#include "JSystem/J3DGraphBase/J3DFifo.h"
#include "JSystem/J3DGraphBase/J3DMatBlock.h"
#include "JSystem/J3DGraphBase/J3DTexture.h"
-#include "dolphin/types.h"
/* 80434C80-80434C98 0619A0 0014+04 2/2 0/0 0/0 .bss sMtxLoadCache__11J3DShapeMtx */
u16 J3DShapeMtx::sMtxLoadCache[10];
@@ -16,24 +10,23 @@ u16 J3DShapeMtx::sMtxLoadCache[10];
/* 803130A8-803130E4 30D9E8 003C+00 0/0 1/1 0/0 .text resetMtxLoadCache__11J3DShapeMtxFv
*/
void J3DShapeMtx::resetMtxLoadCache() {
+ sMtxLoadCache[0] =
+ sMtxLoadCache[1] =
+ sMtxLoadCache[2] =
+ sMtxLoadCache[3] =
+ sMtxLoadCache[4] =
+ sMtxLoadCache[5] =
+ sMtxLoadCache[6] =
+ sMtxLoadCache[7] =
+ sMtxLoadCache[8] =
sMtxLoadCache[9] = 0xFFFF;
- sMtxLoadCache[8] = 0xFFFF;
- sMtxLoadCache[7] = 0xFFFF;
- sMtxLoadCache[6] = 0xFFFF;
- sMtxLoadCache[5] = 0xFFFF;
- sMtxLoadCache[4] = 0xFFFF;
- sMtxLoadCache[3] = 0xFFFF;
- sMtxLoadCache[2] = 0xFFFF;
- sMtxLoadCache[1] = 0xFFFF;
- sMtxLoadCache[0] = 0xFFFF;
}
/* 803130E4-80313128 30DA24 0044+00 1/0 0/0 0/0 .text loadMtxIndx_PNGP__11J3DShapeMtxCFiUs */
void J3DShapeMtx::loadMtxIndx_PNGP(int slot, u16 indx) const {
- // inlined J3DFifoLoadPosMtxIndx
+ // J3DFifoLoadPosMtxIndx(indx, slot * 3); // matches debug, but not retail
J3DFifoLoadIndx(GX_LOAD_INDX_A, indx, 0xB000 | ((u16)(slot * 0x0C)));
- // inlined J3DFifoLoadNrmMtxIndx3x3
- J3DFifoLoadIndx(GX_LOAD_INDX_B, indx, 0x8000 | ((u16)((slot * 0x09) + 0x400)));
+ J3DFifoLoadNrmMtxIndx3x3(indx, slot * 3);
}
/* 80313128-80313188 30DA68 0060+00 1/0 0/0 0/0 .text loadMtxIndx_PCPU__11J3DShapeMtxCFiUs */
@@ -56,27 +49,27 @@ void J3DShapeMtx::loadMtxIndx_PNCPU(int slot, u16 indx) const {
/* 803CD9C0-803CD9F0 02AAE0 0030+00 2/3 0/0 0/0 .data sMtxLoadPipeline__11J3DShapeMtx */
J3DShapeMtx_LoadFunc J3DShapeMtx::sMtxLoadPipeline[4] = {
- &loadMtxIndx_PNGP,
- &loadMtxIndx_PCPU,
- &loadMtxIndx_NCPU,
- &loadMtxIndx_PNCPU,
+ &J3DShapeMtx::loadMtxIndx_PNGP,
+ &J3DShapeMtx::loadMtxIndx_PCPU,
+ &J3DShapeMtx::loadMtxIndx_NCPU,
+ &J3DShapeMtx::loadMtxIndx_PNCPU,
};
/* 803CDA20-803CDA50 02AB40 0030+00 2/3 0/0 0/0 .data sMtxLoadPipeline__21J3DShapeMtxConcatView */
J3DShapeMtxConcatView_LoadFunc J3DShapeMtxConcatView::sMtxLoadPipeline[4] = {
- &loadMtxConcatView_PNGP,
- &loadMtxConcatView_PCPU,
- &loadMtxConcatView_NCPU,
- &loadMtxConcatView_PNCPU,
+ &J3DShapeMtxConcatView::loadMtxConcatView_PNGP,
+ &J3DShapeMtxConcatView::loadMtxConcatView_PCPU,
+ &J3DShapeMtxConcatView::loadMtxConcatView_NCPU,
+ &J3DShapeMtxConcatView::loadMtxConcatView_PNCPU,
};
/* 803CDA80-803CDAB0 02ABA0 0030+00 1/2 0/0 0/0 .data sMtxLoadLODPipeline__21J3DShapeMtxConcatView
*/
J3DShapeMtxConcatView_LoadFunc J3DShapeMtxConcatView::sMtxLoadLODPipeline[4] = {
- &loadMtxConcatView_PNGP_LOD,
- &loadMtxConcatView_PCPU,
- &loadMtxConcatView_NCPU,
- &loadMtxConcatView_PNCPU,
+ &J3DShapeMtxConcatView::loadMtxConcatView_PNGP_LOD,
+ &J3DShapeMtxConcatView::loadMtxConcatView_PCPU,
+ &J3DShapeMtxConcatView::loadMtxConcatView_NCPU,
+ &J3DShapeMtxConcatView::loadMtxConcatView_PNCPU,
};
/* 804515A8-804515AC 000AA8 0004+00 4/4 2/2 0/0 .sbss sCurrentPipeline__11J3DShapeMtx */
@@ -86,13 +79,11 @@ u32 J3DShapeMtx::sCurrentPipeline;
u8* J3DShapeMtx::sCurrentScaleFlag;
// This below is technically part of J3DScaleFlag.
-
-/* 804515B0-804515B4 -00001 0004+00 5/5 3/3 0/0 .sbss None */
/* 804515B0 0001+00 data_804515B0 None */
+bool J3DShapeMtx::sNBTFlag;
+
/* 804515B1 0003+00 data_804515B1 None */
-extern u8 struct_804515B0; // temporary
-u8 J3DShapeMtx::sNBTFlag;
-u8 J3DShapeMtx::sLODFlag;
+bool J3DShapeMtx::sLODFlag;
/* 804515B4-804515B8 000AB4 0004+00 4/4 1/1 0/0 .sbss sTexMtxLoadType__11J3DShapeMtx */
u32 J3DShapeMtx::sTexMtxLoadType;
@@ -115,6 +106,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
{0.0f, -0.5f, 0.5f, 0.0f},
{0.0f, 0.0f, 1.0f, 0.0f},
};
+
static Mtx qMtx2 = {
{0.5f, 0.0f, 0.0f, 0.5f},
{0.0f, -0.5f, 0.0f, 0.5f},
@@ -126,10 +118,10 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
Mtx44 sp_a8, sp_68;
J3DTexGenBlock* tex_gen_block = sTexGenBlock; // sp_60
- JUT_ASSERT_MSG(0xc3, tex_gen_block != NULL, "Error : null pointer");
+ J3D_ASSERT_NULLPTR(195, tex_gen_block != NULL);
J3DTexMtxObj* tex_mtx_obj = sTexMtxObj; // sp_5c
- JUT_ASSERT_MSG(0xc6, tex_mtx_obj != NULL, "Error : null pointer");
+ J3D_ASSERT_NULLPTR(198, tex_mtx_obj != NULL);
J3DTexMtxInfo* tex_mtx_info_1; // sp_58
int tex_gen_type; // sp_54
@@ -142,8 +134,9 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
tex_gen_type = tex_gen_block->getTexCoord(i)->getTexGenType();
if (tex_gen_type == 1 || tex_gen_type == 0) {
tex_mtx_2 = tex_gen_block->getTexMtx(i);
- JUT_ASSERT_MSG(0xd7, tex_mtx_2 != NULL, "Error : null pointer");
+ J3D_ASSERT_NULLPTR(215, tex_mtx_2 != NULL);
tex_mtx_info_1 = &tex_mtx_2->getTexMtxInfo();
+
u32 sp_4c = tex_mtx_info_1->mInfo & 0x3f;
switch (sp_4c) {
case 3:
@@ -187,6 +180,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
} else if (sp_3c == 1) {
J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68);
}
+
MTXConcat(sp_68, qMtx, sp_68);
J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8);
MTXInverse(j3dSys.getViewMtx(), sp_a8);
@@ -203,6 +197,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
} else if (sp_34 == 1) {
J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68);
}
+
MTXConcat(sp_68, qMtx2, sp_68);
J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8);
MTXInverse(j3dSys.getViewMtx(), sp_a8);
@@ -225,8 +220,9 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
int tex_gen_type = tex_gen_block->getTexCoord(i)->getTexGenType();
if (tex_gen_type == 1 || tex_gen_type == 0) {
J3DTexMtx* tex_mtx = tex_gen_block->getTexMtx(i); // sp_2c
- JUT_ASSERT_MSG(0x145, tex_mtx != NULL, "Error : null pointer");
+ J3D_ASSERT_NULLPTR(325, tex_mtx != NULL);
tex_mtx_info_1 = &tex_mtx->getTexMtxInfo();
+
u32 tex_gen_src = tex_mtx_info_1->mInfo & 0x3f; // sp_28
switch (tex_gen_src) {
case 3:
@@ -254,6 +250,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
} else if (sp_24 == 1) {
J3DGetTextureMtxMayaOld(tex_mtx_info_2->mSRT, sp_68);
}
+
J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8);
MTXInverse(j3dSys.getViewMtx(), sp_a8);
MTXConcat(sp_e8, sp_a8, sp_e8);
@@ -270,6 +267,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
} else if (sp_18 == 1) {
J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68);
}
+
MTXConcat(sp_68, qMtx, sp_68);
J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8);
MTXInverse(j3dSys.getViewMtx(), sp_a8);
@@ -287,6 +285,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
} else if (sp_10 == 1) {
J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68);
}
+
MTXConcat(sp_68, qMtx2, sp_68);
J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8);
MTXInverse(j3dSys.getViewMtx(), sp_a8);
@@ -305,8 +304,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
break;
}
}
- GXLoadTexMtxImm(*mtx, i * 3 + 30,
- (GXTexMtxType)tex_mtx_info_1->mProjection);
+ GXLoadTexMtxImm(*mtx, i * 3 + 30, (GXTexMtxType)tex_mtx_info_1->mProjection);
}
}
}
@@ -340,6 +338,7 @@ void J3DShapeMtxConcatView::loadMtxConcatView_NCPU(int slot, u16 drw) const {
J3DDifferedTexMtx::load(m);
J3DFifoLoadPosMtxImm(m, slot * 3);
J3DFifoLoadNrmMtxImm(*j3dSys.getShapePacket()->getBaseMtxPtr(), slot * 3);
+
if (J3DShapeMtx::sTexMtxLoadType == 0x2000)
J3DFifoLoadNrmMtxToTexMtx(*j3dSys.getShapePacket()->getBaseMtxPtr(), slot * 3 + GX_TEXMTX0);
}
@@ -347,13 +346,15 @@ void J3DShapeMtxConcatView::loadMtxConcatView_NCPU(int slot, u16 drw) const {
/* 80313A14-80313AC8 30E354 00B4+00 2/0 0/0 0/0 .text
* loadMtxConcatView_PNCPU__21J3DShapeMtxConcatViewCFiUs */
void J3DShapeMtxConcatView::loadMtxConcatView_PNCPU(int slot, u16 drw) const {
- Mtx m;
if (J3DDifferedTexMtx::sTexGenBlock != NULL) {
+ Mtx m;
MTXConcat(*j3dSys.getShapePacket()->getBaseMtxPtr(), j3dSys.getModelDrawMtx(drw), m);
J3DDifferedTexMtx::loadExecute(m);
}
+
J3DFifoLoadPosMtxImm(*j3dSys.getShapePacket()->getBaseMtxPtr(), slot * 3);
J3DFifoLoadNrmMtxImm(*j3dSys.getShapePacket()->getBaseMtxPtr(), slot * 3);
+
if (J3DShapeMtx::sTexMtxLoadType == 0x2000)
J3DFifoLoadNrmMtxToTexMtx(*j3dSys.getShapePacket()->getBaseMtxPtr(), slot * 3 + GX_TEXMTX0);
}
@@ -363,7 +364,7 @@ void J3DShapeMtxConcatView::loadMtxConcatView_PNCPU(int slot, u16 drw) const {
void J3DShapeMtxConcatView::loadMtxConcatView_PNGP_LOD(int slot, u16 drw) const {
Mtx m;
MTXConcat(*j3dSys.getShapePacket()->getBaseMtxPtr(), j3dSys.getModelDrawMtx(drw), m);
- MTXConcat(m, j3dSys.mModel->getModelData()->getInvJointMtx(drw), m);
+ MTXConcat(m, j3dSys.getModel()->getModelData()->getInvJointMtx(drw), m);
J3DDifferedTexMtx::load(m);
J3DFifoLoadPosMtxImm(m, slot * 3);
loadNrmMtx(slot, drw, m);
@@ -385,10 +386,11 @@ void J3DShapeMtx::calcNBTScale(Vec const& param_0, Mtx33* param_1, Mtx33* param_
/* 80313C54-80313D28 30E594 00D4+00 1/0 0/0 0/0 .text load__21J3DShapeMtxConcatViewCFv */
void J3DShapeMtxConcatView::load() const {
sMtxPtrTbl[0] = j3dSys.getModel()->getMtxBuffer()->getUserAnmMtx(0);
- sMtxPtrTbl[1] = j3dSys.getModel()->getMtxBuffer()->getWeightAnmMtx(0);
+ sMtxPtrTbl[1] = j3dSys.getModel()->getWeightAnmMtx(0);
J3DShapeMtxConcatView_LoadFunc func = sMtxLoadPipeline[sCurrentPipeline];
- u32 draw_mtx_flag = j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndex);
- j3dSys.setModelDrawMtx((Mtx*)sMtxPtrTbl[draw_mtx_flag]);
+
+ j3dSys.setModelDrawMtx((Mtx*)sMtxPtrTbl[j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndex)]);
+
u16 draw_mtx_index = j3dSys.getModel()->getModelData()->getDrawMtxIndex(mUseMtxIndex);
(this->*func)(0, draw_mtx_index);
}
@@ -400,6 +402,7 @@ void J3DShapeMtxConcatView::loadNrmMtx(int param_0, u16 param_1, MtxP param_2) c
if (sTexMtxLoadType == 0x2000) {
J3DFifoLoadNrmMtxToTexMtx(param_2, 0x1e);
}
+
if (!sNBTFlag) {
J3DFifoLoadNrmMtxImm(param_2, 0);
} else {
@@ -415,6 +418,7 @@ void J3DShapeMtxConcatView::loadNrmMtx(int param_0, u16 param_1, MtxP param_2) c
if (sTexMtxLoadType == 0x2000) {
J3DFifoLoadNrmMtxToTexMtx3x3(mtx, 0x1e);
}
+
if (!sNBTFlag) {
J3DFifoLoadNrmMtxImm3x3(mtx, 0);
} else {
@@ -428,11 +432,11 @@ void J3DShapeMtxConcatView::loadNrmMtx(int param_0, u16 param_1, MtxP param_2) c
/* 80313E4C-80313EEC 30E78C 00A0+00 1/0 0/0 0/0 .text load__16J3DShapeMtxMultiCFv */
void J3DShapeMtxMulti::load() const {
J3DShapeMtx_LoadFunc func = sMtxLoadPipeline[sCurrentPipeline];
+
int use_mtx_num = mUseMtxNum;
for (int i = 0; i < use_mtx_num; i++) {
- u16 use_mtx_index = mUseMtxIndexTable[i];
- if (use_mtx_index != 0xffff) {
- (this->*func)(i, use_mtx_index);
+ if (mUseMtxIndexTable[i] != 0xffff) {
+ (this->*func)(i, mUseMtxIndexTable[i]);
}
}
}
@@ -442,9 +446,8 @@ void J3DShapeMtxMulti::load() const {
void J3DShapeMtxMulti::calcNBTScale(Vec const& param_0, Mtx33* param_1, Mtx33* param_2) {
int use_mtx_num = mUseMtxNum;
for (int i = 0; i < use_mtx_num; i++) {
- u16 use_mtx_index = mUseMtxIndexTable[i];
- if (use_mtx_index != 0xffff) {
- J3DPSMtx33Copy(param_1[use_mtx_index], param_2[use_mtx_index]);
+ if (mUseMtxIndexTable[i] != 0xffff) {
+ J3DPSMtx33Copy(param_1[mUseMtxIndexTable[i]], param_2[mUseMtxIndexTable[i]]);
J3DScaleNrmMtx33(param_2[mUseMtxIndexTable[i]], param_0);
}
}
@@ -453,36 +456,34 @@ void J3DShapeMtxMulti::calcNBTScale(Vec const& param_0, Mtx33* param_1, Mtx33* p
/* 80313FA4-8031419C 30E8E4 01F8+00 1/0 0/0 0/0 .text load__26J3DShapeMtxMultiConcatViewCFv */
void J3DShapeMtxMultiConcatView::load() const {
sMtxPtrTbl[0] = j3dSys.getModel()->getMtxBuffer()->getUserAnmMtx(0);
- sMtxPtrTbl[1] = j3dSys.getModel()->getMtxBuffer()->getWeightAnmMtx(0);
+ sMtxPtrTbl[1] = j3dSys.getModel()->getWeightAnmMtx(0);
+
if (!sLODFlag) {
J3DShapeMtxConcatView_LoadFunc func = sMtxLoadPipeline[sCurrentPipeline];
int use_mtx_num = mUseMtxNum;
for (int i = 0; i < use_mtx_num; i++) {
- u16 use_mtx_index = mUseMtxIndexTable[i];
- if (use_mtx_index != 0xffff) {
- u16 draw_mtx_index =
- j3dSys.getModel()->getModelData()->getDrawMtxIndex(use_mtx_index);
- u8 draw_mtx_flag = j3dSys.getModel()->getModelData()->getDrawMtxFlag(use_mtx_index);
- j3dSys.setModelDrawMtx((Mtx*)sMtxPtrTbl[draw_mtx_flag]);
+ if (mUseMtxIndexTable[i] != 0xffff) {
+ u16 draw_mtx_index = j3dSys.getModel()->getModelData()->getDrawMtxIndex(mUseMtxIndexTable[i]);
+ j3dSys.setModelDrawMtx((Mtx*)sMtxPtrTbl[j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndexTable[i])]);
(this->*func)(i, draw_mtx_index);
}
}
} else {
u16* important_mtx_indices = j3dSys.getModel()->getModelData()->getWEvlpImportantMtxIndex();
j3dSys.setModelDrawMtx((Mtx*)sMtxPtrTbl[0]);
+
int use_mtx_num = mUseMtxNum;
for (int i = 0; i < use_mtx_num; i++) {
u32 current_pipeline = sCurrentPipeline;
J3DShapeMtxConcatView_LoadFunc func = sMtxLoadLODPipeline[current_pipeline];
- u16 use_mtx_index = mUseMtxIndexTable[i];
- if (use_mtx_index != 0xffff) {
- u16 important_mtx_index = important_mtx_indices[use_mtx_index];
+
+ if (mUseMtxIndexTable[i] != 0xffff) {
+ u16 important_mtx_index = important_mtx_indices[mUseMtxIndexTable[i]];
if (important_mtx_index != sMtxLoadCache[i]) {
- u8 draw_mtx_flag =
- j3dSys.getModel()->getModelData()->getDrawMtxFlag(use_mtx_index);
- if (draw_mtx_flag == 0) {
- func = sMtxLoadPipeline[current_pipeline];
+ if (j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndexTable[i]) == 0) {
+ func = sMtxLoadPipeline[sCurrentPipeline];
}
+
(this->*func)(i, important_mtx_index);
sMtxLoadCache[i] = important_mtx_index;
}
@@ -526,22 +527,24 @@ void J3DShapeMtxMultiConcatView::loadNrmMtx(int param_0, u16 param_1, MtxP param
void J3DShapeMtxBBoardConcatView::load() const {
Mtx mtx;
u16 draw_mtx_index = j3dSys.getModel()->getModelData()->getDrawMtxIndex(mUseMtxIndex);
- u8 draw_mtx_flag = j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndex);
- if (draw_mtx_flag == 0) {
- MtxP user_anm_mtx = j3dSys.getModel()->getMtxBuffer()->getUserAnmMtx(draw_mtx_index);
- PSMTXConcat(j3dSys.getViewMtx(), user_anm_mtx, mtx);
+
+ if (j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndex) == 0) {
+ MTXConcat(j3dSys.getViewMtx(), j3dSys.getModel()->getMtxBuffer()->getUserAnmMtx(draw_mtx_index), mtx);
} else {
- MtxP weight_anm_mtx = j3dSys.getModel()->getMtxBuffer()->getWeightAnmMtx(draw_mtx_index);
- PSMTXConcat(j3dSys.getViewMtx(), weight_anm_mtx, mtx);
+ MTXConcat(j3dSys.getViewMtx(), j3dSys.getModel()->getWeightAnmMtx(draw_mtx_index), mtx);
}
+
J3DCalcBBoardMtx(mtx);
J3DFifoLoadPosMtxImm(mtx, 0);
+
mtx[0][0] = 1.0f / mtx[0][0];
mtx[1][1] = 1.0f / mtx[1][1];
mtx[2][2] = 1.0f / mtx[2][2];
mtx[0][3] = 0.0f;
mtx[1][3] = 0.0f;
mtx[2][3] = 0.0f;
+
+
if (!sNBTFlag) {
J3DFifoLoadNrmMtxImm(mtx, 0);
} else {
@@ -556,16 +559,16 @@ void J3DShapeMtxYBBoardConcatView::load() const {
Mtx mtx1;
Mtx33 mtx2;
u16 draw_mtx_index = j3dSys.getModel()->getModelData()->getDrawMtxIndex(mUseMtxIndex);
- u8 draw_mtx_flag = j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndex);
- if (draw_mtx_flag == 0) {
- MtxP user_anm_mtx = j3dSys.getModel()->getMtxBuffer()->getUserAnmMtx(draw_mtx_index);
- PSMTXConcat(j3dSys.getViewMtx(), user_anm_mtx, mtx1);
+
+ if (j3dSys.getModel()->getModelData()->getDrawMtxFlag(mUseMtxIndex) == 0) {
+ MTXConcat(j3dSys.getViewMtx(), j3dSys.getModel()->getMtxBuffer()->getUserAnmMtx(draw_mtx_index), mtx1);
} else {
- MtxP weight_anm_mtx = j3dSys.getModel()->getMtxBuffer()->getWeightAnmMtx(draw_mtx_index);
- PSMTXConcat(j3dSys.getViewMtx(), weight_anm_mtx, mtx1);
+ MTXConcat(j3dSys.getViewMtx(), j3dSys.getModel()->getWeightAnmMtx(draw_mtx_index), mtx1);
}
+
J3DCalcYBBoardMtx(mtx1);
J3DFifoLoadPosMtxImm(mtx1, 0);
+
if (sCurrentScaleFlag[mUseMtxIndex] == 1) {
if (!sNBTFlag) {
J3DFifoLoadNrmMtxImm(mtx1, 0);
diff --git a/src/JSystem/J3DGraphBase/J3DSys.cpp b/src/JSystem/J3DGraphBase/J3DSys.cpp
index ff92ce2e8b..d231ece3a4 100644
--- a/src/JSystem/J3DGraphBase/J3DSys.cpp
+++ b/src/JSystem/J3DGraphBase/J3DSys.cpp
@@ -1,40 +1,9 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DSys
-//
-
#include "JSystem/J3DGraphBase/J3DSys.h"
-
-#include "dol2asm.h"
-#include <dolphin/gx.h>
-#include "dolphin/os.h"
-#include "dolphin/types.h"
-#include "global.h"
-
#include "JSystem/J3DGraphBase/J3DTevs.h"
-
#include "JSystem/J3DGraphBase/J3DTexture.h"
-#include "JSystem/J3DGraphBase/J3DGD.h"
-
-//
-// Forward References:
-//
-
-extern void J3DFifoLoadTexCached(GXTexMapID, u32, GXTexCacheSize, u32, GXTexCacheSize);
-extern void makeTexCoordTable();
-extern void makeAlphaCmpTable();
-extern void makeZModeTable();
-extern void makeTevSwapTable();
-extern "C" void GXInvalidateVtxCache();
-
-extern "C" extern const GXColor j3dDefaultColInfo;
-extern "C" extern u8 data_804563C8;
-
-//
-// Declarations:
-//
+#include "JSystem/J3DGraphBase/J3DFifo.h"
+#include "global.h"
-/* ############################################################################################## */
/* 80434AC8-80434BE4 0617E8 011C+00 1/1 151/151 486/486 .bss j3dSys */
J3DSys j3dSys;
@@ -50,6 +19,31 @@ Vec J3DSys::mParentS;
/* 80434C2C-80434C70 06194C 0040+04 1/1 17/17 0/0 .bss sTexCoordScaleTable__6J3DSys */
J3DTexCoordScaleInfo J3DSys::sTexCoordScaleTable[8];
+/* 803CD8A0-803CD8B0 02A9C0 0010+00 1/1 0/0 0/0 .data NullTexData */
+static u8 NullTexData[0x10] ALIGN_DECL(32) = {0};
+
+/* 803CD8B0-803CD8E0 02A9D0 0030+00 1/1 0/0 0/0 .data j3dIdentityMtx */
+static Mtx j3dIdentityMtx = {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+};
+
+/* 803CD8E0-803CD8F8 02AA00 0018+00 1/1 0/0 0/0 .data IndMtx */
+static Mtx23 IndMtx = {
+ 0.5f, 0.0f, 0.0f,
+ 0.0f, 0.5f, 0.0f,
+};
+
+/* 80451598-804515A0 000A98 0004+04 0/0 1/1 0/0 .sbss j3dDefaultViewNo */
+u32 j3dDefaultViewNo;
+
+/* 80450950-80450954 0003D0 0004+00 2/2 0/0 0/0 .sdata ColorBlack */
+static GXColor ColorBlack = {0x00, 0x00, 0x00, 0x00};
+
+/* 80450954-80450958 0003D4 0004+00 2/2 0/0 0/0 .sdata ColorWhite */
+static GXColor ColorWhite = {0xFF, 0xFF, 0xFF, 0xFF};
+
/* 8030FDE8-8030FEC0 30A728 00D8+00 1/1 0/0 0/0 .text __ct__6J3DSysFv */
J3DSys::J3DSys() {
makeTexCoordTable();
@@ -63,8 +57,10 @@ J3DSys::J3DSys() {
mMaterialMode = 0;
mModel = NULL;
mShape = NULL;
- for (u32 i = 0; i < ARRAY_SIZE(mDrawBuffer); i++)
+
+ for (int i = 0; i < 2; i++)
mDrawBuffer[i] = NULL;
+
mTexture = NULL;
mMatPacket = NULL;
mShapePacket = NULL;
@@ -74,7 +70,7 @@ J3DSys::J3DSys() {
mVtxNrm = NULL;
mVtxCol = NULL;
- for (u32 i = 0; i < 8; i++) {
+ for (int i = 0; i < 8; i++) {
sTexCoordScaleTable[i].field_0x00 = 1;
sTexCoordScaleTable[i].field_0x02 = 1;
sTexCoordScaleTable[i].field_0x04 = 0;
@@ -84,31 +80,34 @@ J3DSys::J3DSys() {
/* 8030FEC0-8030FEE4 30A800 0024+00 0/0 1/1 0/0 .text loadPosMtxIndx__6J3DSysCFiUs */
void J3DSys::loadPosMtxIndx(int addr, u16 indx) const {
+ // J3DFifoLoadPosMtxIndx(indx, addr * 3); // matches debug, not retail
J3DFifoLoadIndx(GX_LOAD_INDX_A, indx, 0xB000 | ((u16)(addr * 0x0C)));
}
/* 8030FEE4-8030FF0C 30A824 0028+00 0/0 1/1 0/0 .text loadNrmMtxIndx__6J3DSysCFiUs */
void J3DSys::loadNrmMtxIndx(int addr, u16 indx) const {
- J3DFifoLoadIndx(GX_LOAD_INDX_B, indx, 0x8000 | ((u16)((addr * 0x09) + 0x400)));
+ J3DFifoLoadNrmMtxIndx3x3(indx, addr * 3);
}
/* 8030FF0C-803100BC 30A84C 01B0+00 1/1 0/0 0/0 .text setTexCacheRegion__6J3DSysF15_GXTexCacheSize
*/
void J3DSys::setTexCacheRegion(GXTexCacheSize size) {
+ J3D_ASSERT_RANGE(173, size >= 0 && size < 3);
+
const u32 kSize[] = {
0x00008000,
0x00020000,
0x00080000,
0x00000000,
};
+
const u32 kRegionNum[] = {8, 4, 1, 0};
- u32 regionNum = kRegionNum[size];
- mTexCacheRegionNum = regionNum;
+ mTexCacheRegionNum = kRegionNum[size];
- if (!!(mFlags & 0x80000000)) {
- for (u32 i = 0; i < regionNum; i++) {
- if (!!(i & 1)) {
+ if (checkFlag(0x80000000)) {
+ for (u32 i = 0; i < kRegionNum[size]; i++) {
+ if (i & 1) {
GXInitTexCacheRegion(&mTexCacheRegion[i], GX_FALSE, i * kSize[size] + 0x80000, size,
i * kSize[size], size);
J3DFifoLoadTexCached((GXTexMapID)i, i * kSize[size] + 0x80000, size,
@@ -121,7 +120,7 @@ void J3DSys::setTexCacheRegion(GXTexCacheSize size) {
}
}
} else {
- for (u32 i = 0; i < regionNum; i++) {
+ for (u32 i = 0; i < kRegionNum[size]; i++) {
GXInitTexCacheRegion(&mTexCacheRegion[i], GX_FALSE, i * kSize[size], size,
i * kSize[size] + 0x80000, size);
J3DFifoLoadTexCached((GXTexMapID)i, i * kSize[size], size, i * kSize[size] + 0x80000,
@@ -130,16 +129,6 @@ void J3DSys::setTexCacheRegion(GXTexCacheSize size) {
}
}
-/* 803CD8A0-803CD8B0 02A9C0 0010+00 1/1 0/0 0/0 .data NullTexData */
-SECTION_DATA static u8 NullTexData[16] ALIGN_DECL(32) = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-/* 803CD8B0-803CD8E0 02A9D0 0030+00 1/1 0/0 0/0 .data j3dIdentityMtx */
-SECTION_DATA static Mtx j3dIdentityMtx = {
- 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-};
-
/* 803100BC-8031073C 30A9FC 0680+00 0/0 3/3 0/0 .text drawInit__6J3DSysFv */
void J3DSys::drawInit() {
GXInvalidateVtxCache();
@@ -201,16 +190,16 @@ void J3DSys::drawInit() {
GXSetChanMatColor(GX_COLOR0A0, j3dDefaultColInfo);
GXSetChanMatColor(GX_COLOR1A1, j3dDefaultColInfo);
- GXSetNumChans(data_804563C8);
+ GXSetNumChans(j3dDefaultNumChans);
GXSetNumTexGens(1);
GXSetNumTevStages(1);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_REG, 0, GX_DF_CLAMP, GX_AF_NONE);
GXSetChanCtrl(GX_COLOR1A1, GX_FALSE, GX_SRC_REG, GX_SRC_REG, 0, GX_DF_CLAMP, GX_AF_NONE);
for (i = 0; i < GX_MAX_TEXMAP; i++)
- GXSetTexCoordGen2((GXTexCoordID)i, (GXTexGenType)j3dDefaultTexCoordInfo[i].mTexGenType,
+ GXSetTexCoordGen((GXTexCoordID)i, (GXTexGenType)j3dDefaultTexCoordInfo[i].mTexGenType,
(GXTexGenSrc)j3dDefaultTexCoordInfo[i].mTexGenSrc,
- j3dDefaultTexCoordInfo[i].mTexGenMtx, GX_FALSE, GX_PTIDENTITY);
+ j3dDefaultTexCoordInfo[i].mTexGenMtx);
for (i = 0; i < GX_MAX_INDTEXSTAGE; i++)
GXSetIndTexCoordScale((GXIndTexStageID)i, GX_ITS_1, GX_ITS_1);
@@ -268,13 +257,6 @@ void J3DSys::reinitGenMode() {
GXSetCoPlanar(GX_FALSE);
}
-/* ############################################################################################## */
-/* 80450950-80450954 0003D0 0004+00 2/2 0/0 0/0 .sdata ColorBlack */
-SECTION_SDATA static GXColor ColorBlack = {0x00, 0x00, 0x00, 0x00};
-
-/* 80450954-80450958 0003D4 0004+00 2/2 0/0 0/0 .sdata ColorWhite */
-SECTION_SDATA static GXColor ColorWhite = {0xFF, 0xFF, 0xFF, 0xFF};
-
/* 803107E8-80310894 30B128 00AC+00 1/1 0/0 0/0 .text reinitLighting__6J3DSysFv */
void J3DSys::reinitLighting() {
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE,
@@ -290,14 +272,14 @@ void J3DSys::reinitLighting() {
/* 80310894-80310998 30B1D4 0104+00 1/1 0/0 0/0 .text reinitTransform__6J3DSysFv */
void J3DSys::reinitTransform() {
GXSetCurrentMtx(GX_PNMTX0);
- GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
- GXSetTexCoordGen2(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX1, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
- GXSetTexCoordGen2(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_TEX2, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
- GXSetTexCoordGen2(GX_TEXCOORD3, GX_TG_MTX2x4, GX_TG_TEX3, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
- GXSetTexCoordGen2(GX_TEXCOORD4, GX_TG_MTX2x4, GX_TG_TEX4, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
- GXSetTexCoordGen2(GX_TEXCOORD5, GX_TG_MTX2x4, GX_TG_TEX5, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
- GXSetTexCoordGen2(GX_TEXCOORD6, GX_TG_MTX2x4, GX_TG_TEX6, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
- GXSetTexCoordGen2(GX_TEXCOORD7, GX_TG_MTX2x4, GX_TG_TEX7, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD1, GX_TG_MTX2x4, GX_TG_TEX1, GX_IDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD2, GX_TG_MTX2x4, GX_TG_TEX2, GX_IDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD3, GX_TG_MTX2x4, GX_TG_TEX3, GX_IDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD4, GX_TG_MTX2x4, GX_TG_TEX4, GX_IDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD5, GX_TG_MTX2x4, GX_TG_TEX5, GX_IDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD6, GX_TG_MTX2x4, GX_TG_TEX6, GX_IDENTITY);
+ GXSetTexCoordGen(GX_TEXCOORD7, GX_TG_MTX2x4, GX_TG_TEX7, GX_IDENTITY);
}
/* 80310998-80310A3C 30B2D8 00A4+00 2/2 0/0 0/0 .text reinitTexture__6J3DSysFv */
@@ -341,7 +323,9 @@ void J3DSys::reinitTevStages() {
GXSetTevKColor(GX_KCOLOR2, ColorWhite);
GXSetTevKColor(GX_KCOLOR3, ColorWhite);
- for (u32 i = 0; i < GX_MAX_TEVSTAGE; i++) {
+ u32 i;
+ u32 numStages = GX_MAX_TEVSTAGE;
+ for (i = 0; i < numStages; i++) {
GXSetTevColorIn((GXTevStageID)i, GX_CC_RASC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO);
GXSetTevColorOp((GXTevStageID)i, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE,
GX_TEVPREV);
@@ -360,13 +344,10 @@ void J3DSys::reinitTevStages() {
GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
}
-/* ############################################################################################## */
-/* 803CD8E0-803CD8F8 02AA00 0018+00 1/1 0/0 0/0 .data IndMtx */
-SECTION_DATA static Mtx23 IndMtx = {0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f};
-
/* 80310D44-80310E3C 30B684 00F8+00 1/1 0/0 0/0 .text reinitIndStages__6J3DSysFv */
void J3DSys::reinitIndStages() {
- for (u32 i = 0; i < GX_MAX_TEVSTAGE; i++) {
+ u32 i;
+ for (i = 0; i < GX_MAX_TEVSTAGE; i++) {
GXSetTevDirect((GXTevStageID)i);
}
@@ -394,7 +375,3 @@ void J3DSys::reinitPixelProc() {
GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GXSetZCompLoc(GX_TRUE);
}
-
-/* ############################################################################################## */
-/* 80451598-804515A0 000A98 0004+04 0/0 1/1 0/0 .sbss j3dDefaultViewNo */
-u32 j3dDefaultViewNo;
diff --git a/src/JSystem/J3DGraphBase/J3DTevs.cpp b/src/JSystem/J3DGraphBase/J3DTevs.cpp
index da4bdc4b44..338198883a 100644
--- a/src/JSystem/J3DGraphBase/J3DTevs.cpp
+++ b/src/JSystem/J3DGraphBase/J3DTevs.cpp
@@ -9,7 +9,7 @@
#include "JSystem/J3DGraphBase/J3DTransform.h"
#include "global.h"
-static void J3DGDLoadTexMtxImm(f32 (*)[4], u32, _GXTexMtxType);
+static void J3DGDLoadTexMtxImm(f32 (*)[4], u32, GXTexMtxType);
static void J3DGDLoadPostTexMtxImm(f32 (*)[4], u32);
/* 80323590-80323644 31DED0 00B4+00 0/0 3/3 0/0 .text load__11J3DLightObjCFUl */
@@ -23,23 +23,33 @@ void J3DLightObj::load(u32 lightIdx) const {
/* 80323644-803238C4 31DF84 0280+00 0/0 3/3 0/0 .text loadTexCoordGens__FUlP11J3DTexCoord
*/
-void loadTexCoordGens(u32 param_0, J3DTexCoord* param_1) {
- GDOverflowCheck(param_0 * 8 + 10);
- J3DGDWriteXFCmdHdr(0x1040, param_0);
- for (int i = 0; i < param_0; i++) {
+void loadTexCoordGens(u32 texGenNum, J3DTexCoord* texCoords) {
+ u32 var_r28;
+ GDOverflowCheck(texGenNum * 4 * 2 + 10);
+ J3DGDWriteXFCmdHdr(GX_XF_REG_TEX0, texGenNum);
+
+ for (int i = 0; i < texGenNum; i++) {
J3DGDSetTexCoordGen(
- GXTexGenType(param_1[i].getTexGenType()),
- GXTexGenSrc(param_1[i].getTexGenSrc())
+ GXTexGenType(texCoords[i].getTexGenType()),
+ GXTexGenSrc(texCoords[i].getTexGenSrc())
);
}
- J3DGDWriteXFCmdHdr(0x1050, param_0);
+
+ var_r28 = 61;
+ J3DGDWriteXFCmdHdr(GX_XF_REG_DUALTEX0, texGenNum);
+
if (j3dSys.checkFlag(0x40000000)) {
- for (int i = 0; i < param_0; i++) {
- J3DGDWrite_u32(param_1[i].getTexGenMtx() == 60 ? 61 : i * 3);
+ for (int i = 0; i < texGenNum; i++) {
+ if (texCoords[i].getTexGenMtx() != 60) {
+ var_r28 = i * 3;
+ } else {
+ var_r28 = 61;
+ }
+ J3DGDWrite_u32(var_r28);
}
} else {
- for (int i = 0; i < param_0; i++) {
- J3DGDWrite_u32(61);
+ for (int i = 0; i < texGenNum; i++) {
+ J3DGDWrite_u32(var_r28);
}
}
}
@@ -74,7 +84,7 @@ void J3DTexMtx::calcTexMtx(const Mtx param_0) {
0.0f, 0.0f, 1.0f, 0.0f,
};
- u8 r28 = mTexMtxInfo.mInfo & 0x3f;
+ u32 r28 = mTexMtxInfo.mInfo & 0x3f;
u32 r30 = (mTexMtxInfo.mInfo >> 7) & 1;
switch (r28) {
case 8:
@@ -171,7 +181,7 @@ void J3DTexMtx::calcPostTexMtx(const Mtx param_0) {
0.0f, 0.0f, 1.0f, 0.0f,
};
- u8 r29 = mTexMtxInfo.mInfo & 0x3f;
+ u32 r29 = mTexMtxInfo.mInfo & 0x3f;
u32 r30 = (mTexMtxInfo.mInfo >> 7) & 1;
switch (r29) {
case 8:
@@ -264,8 +274,8 @@ void J3DTexMtx::calcPostTexMtx(const Mtx param_0) {
}
/* 80323F64-80323F88 31E8A4 0024+00 0/0 1/1 0/0 .text isTexNoReg__FPv */
-bool isTexNoReg(void* param_0) {
- u8 r31 = ((u8*)param_0)[1];
+bool isTexNoReg(void* pDL) {
+ u8 r31 = ((u8*)pDL)[1];
if (r31 >= 0x80 && r31 <= 0xbb) {
return true;
}
@@ -273,19 +283,24 @@ bool isTexNoReg(void* param_0) {
}
/* 80323F88-80323F94 31E8C8 000C+00 0/0 1/1 0/0 .text getTexNoReg__FPv */
-u16 getTexNoReg(void* param_0) {
- return *(u32*)((u8*)param_0 + 1);
+u16 getTexNoReg(void* pDL) {
+ u32 var_r31 = *(u32*)((u8*)pDL + 1);
+ return var_r31 & 0xFFFFFF;
}
/* 80323F94-8032413C 31E8D4 01A8+00 0/0 20/20 0/0 .text loadTexNo__FUlRCUs */
-void loadTexNo(u32 param_0, u16 const& param_1) {
- ResTIMG* resTIMG = j3dSys.getTexture()->getResTIMG(param_1);
- J3DSys::sTexCoordScaleTable[param_0].field_0x00 = resTIMG->width;
- J3DSys::sTexCoordScaleTable[param_0].field_0x02 = resTIMG->height;
+void loadTexNo(u32 param_0, const u16& texNo) {
+ ResTIMG* resTIMG = j3dSys.getTexture()->getResTIMG(texNo);
+ J3D_ASSERT_NULLPTR(462, resTIMG != NULL);
+
+ J3DSys::sTexCoordScaleTable[param_0].field_0x00 = (u16)resTIMG->width;
+ J3DSys::sTexCoordScaleTable[param_0].field_0x02 = (u16)resTIMG->height;
+
GDOverflowCheck(0x14);
J3DGDSetTexImgPtr(GXTexMapID(param_0), (u8*)resTIMG + resTIMG->imageOffset);
J3DGDSetTexImgAttr(GXTexMapID(param_0), resTIMG->width, resTIMG->height, GXTexFmt(resTIMG->format & 0x0f));
J3DGDSetTexLookupMode(GXTexMapID(param_0), GXTexWrapMode(resTIMG->wrapS), GXTexWrapMode(resTIMG->wrapT), GXTexFilter(resTIMG->minFilter), GXTexFilter(resTIMG->magFilter), resTIMG->minLOD * 0.125f, resTIMG->maxLOD * 0.125f, resTIMG->LODBias * 0.01f, resTIMG->biasClamp, resTIMG->doEdgeLOD, GXAnisotropy(resTIMG->maxAnisotropy));
+
if (resTIMG->indexTexture == true) {
GXTlutSize tlutSize = resTIMG->numColors > 16 ? GX_TLUT_256 : GX_TLUT_16;
GDOverflowCheck(0x14);
@@ -295,20 +310,22 @@ void loadTexNo(u32 param_0, u16 const& param_1) {
}
/* 8032413C-80324160 31EA7C 0024+00 0/0 2/2 0/0 .text patchTexNo_PtrToIdx__FUlRCUs */
-void patchTexNo_PtrToIdx(u32 texID, u16 const& idx) {
+void patchTexNo_PtrToIdx(u32 texID, const u16& idx) {
+ ResTIMG* timg = j3dSys.getTexture()->getResTIMG(idx);
+ J3D_ASSERT_NULLPTR(523, timg != NULL);
+
J3DGDSetTexImgPtrRaw(GXTexMapID(texID), idx);
}
/* 80324160-80324194 31EAA0 0034+00 0/0 2/2 0/0 .text loadNBTScale__FR11J3DNBTScale */
-void loadNBTScale(J3DNBTScale& param_0) {
- if (param_0.mbHasScale == true) {
- j3dSys.setNBTScale(&param_0.mScale);
+void loadNBTScale(J3DNBTScale& NBTScale) {
+ if (NBTScale.mbHasScale == true) {
+ j3dSys.setNBTScale(&NBTScale.mScale);
} else {
j3dSys.setNBTScale(NULL);
}
}
-/* ############################################################################################## */
/* 803A1EC8-803A1EFC 02E528 0034+00 0/0 9/9 24/24 .rodata j3dDefaultLightInfo */
extern const J3DLightInfo j3dDefaultLightInfo = {
0.0f, 0.0f, 0.0f,
@@ -399,7 +416,6 @@ void makeTexCoordTable() {
}
}
-/* ############################################################################################## */
/* 80436A60-80436E60 063780 0400+00 1/1 3/3 0/0 .bss j3dTevSwapTableTable */
u8 j3dTevSwapTableTable[1024];
@@ -421,7 +437,6 @@ void makeAlphaCmpTable() {
}
}
-/* ############################################################################################## */
/* 80437160-804371C0 063E80 0060+00 1/1 4/4 5/5 .bss j3dZModeTable */
extern u8 j3dZModeTable[96];
u8 j3dZModeTable[96];
@@ -472,7 +487,7 @@ void J3DTexMtx::loadPostTexMtx(u32 param_0) const {
static void J3DGDLoadTexMtxImm(f32 (*param_1)[4], u32 param_2, _GXTexMtxType param_3) {
u16 addr = param_2 << 2;
u8 len = param_3 == GX_MTX2x4 ? 8 : 12;
- J3DGDWriteXFCmdHdr(addr & 0xffff, len);
+ J3DGDWriteXFCmdHdr(addr, len);
J3DGDWrite_f32(param_1[0][0]);
J3DGDWrite_f32(param_1[0][1]);
J3DGDWrite_f32(param_1[0][2]);
@@ -492,7 +507,9 @@ static void J3DGDLoadTexMtxImm(f32 (*param_1)[4], u32 param_2, _GXTexMtxType par
/* 8032499C-80324F08 31F2DC 056C+00 1/1 0/0 0/0 .text J3DGDLoadPostTexMtxImm__FPA4_fUl */
static void J3DGDLoadPostTexMtxImm(f32 (*param_1)[4], u32 param_2) {
u16 addr = (param_2 - 0x40) * 4 + 0x500;
- J3DGDWriteXFCmdHdr(addr, 12);
+ int stride = 12;
+
+ J3DGDWriteXFCmdHdr(addr, stride);
J3DGDWrite_f32(param_1[0][0]);
J3DGDWrite_f32(param_1[0][1]);
J3DGDWrite_f32(param_1[0][2]);
@@ -507,7 +524,6 @@ static void J3DGDLoadPostTexMtxImm(f32 (*param_1)[4], u32 param_2) {
J3DGDWrite_f32(param_1[2][3]);
}
-/* ############################################################################################## */
/* 804563C0-804563C4 0049C0 0004+00 0/0 4/4 0/0 .sdata2 j3dDefaultColInfo */
extern const GXColor j3dDefaultColInfo = {0xFF, 0xFF, 0xFF, 0xFF};
@@ -515,7 +531,7 @@ extern const GXColor j3dDefaultColInfo = {0xFF, 0xFF, 0xFF, 0xFF};
extern const GXColor j3dDefaultAmbInfo = {0x32, 0x32, 0x32, 0x32};
/* 804563C8-804563CC 0049C8 0004+00 0/0 1/1 0/0 .sdata2 None */
-extern const u8 data_804563C8 = 0x01;
+extern const u8 j3dDefaultNumChans = 1;
/* 804563CC-804563D0 0049CC 0004+00 0/0 3/3 0/0 .sdata2 j3dDefaultTevOrderInfoNull */
extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull = {0xFF, 0xFF, 0xFF, 0x00};
diff --git a/src/JSystem/J3DGraphBase/J3DTexture.cpp b/src/JSystem/J3DGraphBase/J3DTexture.cpp
index e4ff174899..ce4256b31d 100644
--- a/src/JSystem/J3DGraphBase/J3DTexture.cpp
+++ b/src/JSystem/J3DGraphBase/J3DTexture.cpp
@@ -1,30 +1,22 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DTexture
-//
-
#include "JSystem/J3DGraphBase/J3DTexture.h"
-
-#include "dolphin/gx.h"
-#include "global.h"
+#include "JSystem/J3DAssert.h"
/* 8031204C-803121A4 30C98C 0158+00 0/0 1/1 0/0 .text loadGX__10J3DTextureCFUs11_GXTexMapID */
void J3DTexture::loadGX(u16 idx, GXTexMapID texMapID) const {
- J3D_ASSERT(0, idx < mNum, "Error : range over.");
+ J3D_ASSERT_RANGE(29, idx < mNum);
ResTIMG* timg = getResTIMG(idx);
GXTexObj texObj;
+ GXTlutObj tlutObj;
if (!timg->indexTexture) {
GXInitTexObj(&texObj, ((u8*)timg) + timg->imageOffset, timg->width, timg->height,
(GXTexFmt)timg->format, (GXTexWrapMode)timg->wrapS, (GXTexWrapMode)timg->wrapT,
- (GXBool)timg->mipmapEnabled);
+ timg->mipmapEnabled);
} else {
- GXTlutObj tlutObj;
-
GXInitTexObjCI(&texObj, ((u8*)timg) + timg->imageOffset, timg->width, timg->height,
(GXCITexFmt)timg->format, (GXTexWrapMode)timg->wrapS,
- (GXTexWrapMode)timg->wrapT, (GXBool)timg->mipmapEnabled, (u32)texMapID);
+ (GXTexWrapMode)timg->wrapT, timg->mipmapEnabled, (u32)texMapID);
GXInitTlutObj(&tlutObj, ((u8*)timg) + timg->paletteOffset, (GXTlutFmt)timg->colorFormat,
timg->numColors);
GXLoadTlut(&tlutObj, texMapID);
@@ -34,31 +26,31 @@ void J3DTexture::loadGX(u16 idx, GXTexMapID texMapID) const {
const f32 kLODBiasScale = 1.0f / 100.0f;
GXInitTexObjLOD(&texObj, (GXTexFilter)timg->minFilter, (GXTexFilter)timg->magFilter,
timg->minLOD * kLODClampScale, timg->maxLOD * kLODClampScale,
- timg->LODBias * kLODBiasScale, (GXBool)timg->biasClamp, (GXBool)timg->doEdgeLOD,
+ timg->LODBias * kLODBiasScale, timg->biasClamp, timg->doEdgeLOD,
(GXAnisotropy)timg->maxAnisotropy);
GXLoadTexObj(&texObj, texMapID);
}
/* 803121A4-8031221C 30CAE4 0078+00 1/1 0/0 0/0 .text entryNum__10J3DTextureFUs */
void J3DTexture::entryNum(u16 num) {
- J3D_ASSERT(79, num != 0, "Error : non-zero argument is specified 0.");
+ J3D_ASSERT_NONZEROARG(79, num != 0);
mNum = num;
- mpRes = new ResTIMG[num]();
- J3D_ASSERT(83, mpRes != 0, "Error : allocate memory.");
+ mpRes = new ResTIMG[num];
+ J3D_ASSERT_ALLOCMEM(83, mpRes != NULL);
- for (s32 i = 0; i < mNum; i++) {
+ for (int i = 0; i < mNum; i++) {
mpRes[i].paletteOffset = 0;
mpRes[i].imageOffset = 0;
}
}
/* 8031221C-80312488 30CB5C 026C+00 0/0 1/1 0/0 .text addResTIMG__10J3DTextureFUsPC7ResTIMG */
-void J3DTexture::addResTIMG(u16 newNum, ResTIMG const* newRes) {
+void J3DTexture::addResTIMG(u16 newNum, const ResTIMG* newRes) {
if (newNum == 0)
return;
- J3D_ASSERT(105, newRes != 0, "Error : null pointer.");
+ J3D_ASSERT_NULLPTR(105, newRes != 0);
u16 oldNum = mNum;
ResTIMG* oldRes = mpRes;
diff --git a/src/JSystem/J3DGraphBase/J3DTransform.cpp b/src/JSystem/J3DGraphBase/J3DTransform.cpp
index 127cfde23f..ee0d58f27f 100644
--- a/src/JSystem/J3DGraphBase/J3DTransform.cpp
+++ b/src/JSystem/J3DGraphBase/J3DTransform.cpp
@@ -1,12 +1,7 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DTransform
-//
-
#include "JSystem/J3DGraphBase/J3DTransform.h"
-#include "JSystem/JMath/JMATrigonometric.h"
#include "JSystem/J3DGraphBase/J3DStruct.h"
-#include "dolphin/base/PPCArch.h"
+#include "JSystem/JMath/JMATrigonometric.h"
+#include "JSystem/JMath/JMath.h"
/* 80311630-80311638 -00001 0008+00 0/0 0/0 0/0 .text __MTGQR7__FUl */
void __MTGQR7(register u32 v) {
@@ -19,12 +14,14 @@ void __MTGQR7(register u32 v) {
/* 80311638-80311670 30BF78 0038+00 0/0 2/2 0/0 .text J3DGQRSetup7__FUlUlUlUl */
void J3DGQRSetup7(u32 r0, u32 r1, u32 r2, u32 r3) {
- u32 v = (((r0 << 8) + r1) << 16) | ((r2 << 8) + r3);
+ u32 v = ((r0 << 8) + r1) << 16;
+ v |= (r2 << 8) + r3;
__MTGQR7(v);
}
/* 80311670-80311760 30BFB0 00F0+00 0/0 2/2 0/0 .text J3DCalcBBoardMtx__FPA4_f */
// this uses a non-standard sqrtf, not sure why or how its supposed to be setup
+#if !PLATFORM_SHIELD
inline f32 J3D_sqrtf(register f32 x) {
register f32 recip;
@@ -36,6 +33,9 @@ inline f32 J3D_sqrtf(register f32 x) {
}
return x;
}
+#else
+#define J3D_sqrtf sqrtf
+#endif
void J3DCalcBBoardMtx(register Mtx mtx) {
f32 x = (mtx[0][0] * mtx[0][0]) + (mtx[1][0] * mtx[1][0]) + (mtx[2][0] * mtx[2][0]);
@@ -86,10 +86,10 @@ void J3DCalcYBBoardMtx(Mtx mtx) {
f32 z = (mtx[0][2] * mtx[0][2]) + (mtx[1][2] * mtx[1][2]) + (mtx[2][2] * mtx[2][2]);
if (x > 0.0f) {
- x = J3D_sqrtf(x);
+ x = JMath::fastSqrt(x);
}
if (z > 0.0f) {
- z = J3D_sqrtf(z);
+ z = JMath::fastSqrt(z);
}
Vec vec = { 0.0f, -mtx[2][1], mtx[1][1] };
@@ -165,6 +165,9 @@ lbl_8005F118:
/* 80311964-80311A24 30C2A4 00C0+00 0/0 2/2 2/2 .text
* J3DGetTranslateRotateMtx__FRC16J3DTransformInfoPA4_f */
void J3DGetTranslateRotateMtx(const J3DTransformInfo& tx, Mtx dst) {
+ f32 cxsz;
+ f32 sxcz;
+
f32 sx = JMASSin(tx.mRotation.x), cx = JMASCos(tx.mRotation.x);
f32 sy = JMASSin(tx.mRotation.y), cy = JMASCos(tx.mRotation.y);
f32 sz = JMASSin(tx.mRotation.z), cz = JMASCos(tx.mRotation.z);
@@ -175,15 +178,15 @@ void J3DGetTranslateRotateMtx(const J3DTransformInfo& tx, Mtx dst) {
dst[2][1] = cy * sx;
dst[2][2] = cy * cx;
- f32 cxsz = cx * sz;
- f32 sxcz = sx * cz;
+ cxsz = cx * sz;
+ sxcz = sx * cz;
dst[0][1] = sxcz * sy - cxsz;
dst[1][2] = cxsz * sy - sxcz;
- f32 sxsz = sx * sz;
- f32 cxcz = cx * cz;
- dst[0][2] = cxcz * sy + sxsz;
- dst[1][1] = sxsz * sy + cxcz;
+ cxsz = sx * sz;
+ sxcz = cx * cz;
+ dst[0][2] = sxcz * sy + cxsz;
+ dst[1][1] = cxsz * sy + sxcz;
dst[0][3] = tx.mTranslate.x;
dst[1][3] = tx.mTranslate.y;
@@ -192,6 +195,9 @@ void J3DGetTranslateRotateMtx(const J3DTransformInfo& tx, Mtx dst) {
/* 80311A24-80311ACC 30C364 00A8+00 0/0 1/1 0/0 .text J3DGetTranslateRotateMtx__FsssfffPA4_f */
void J3DGetTranslateRotateMtx(s16 rx, s16 ry, s16 rz, f32 tx, f32 ty, f32 tz, Mtx dst) {
+ f32 cxsz;
+ f32 sxcz;
+
f32 sx = JMASSin(rx), cx = JMASCos(rx);
f32 sy = JMASSin(ry), cy = JMASCos(ry);
f32 sz = JMASSin(rz), cz = JMASCos(rz);
@@ -202,15 +208,15 @@ void J3DGetTranslateRotateMtx(s16 rx, s16 ry, s16 rz, f32 tx, f32 ty, f32 tz, Mt
dst[2][1] = cy * sx;
dst[2][2] = cy * cx;
- f32 cxsz = cx * sz;
- f32 sxcz = sx * cz;
+ cxsz = cx * sz;
+ sxcz = sx * cz;
dst[0][1] = sxcz * sy - cxsz;
dst[1][2] = cxsz * sy - sxcz;
- f32 sxsz = sx * sz;
- f32 cxcz = cx * cz;
- dst[0][2] = cxcz * sy + sxsz;
- dst[1][1] = sxsz * sy + cxcz;
+ cxsz = sx * sz;
+ sxcz = cx * cz;
+ dst[0][2] = sxcz * sy + cxsz;
+ dst[1][1] = cxsz * sy + sxcz;
dst[0][3] = tx;
dst[1][3] = ty;
@@ -235,15 +241,10 @@ void J3DGetTextureMtx(const J3DTextureSRTInfo& srt, const Vec& center, Mtx dst)
dst[1][1] = cy;
dst[1][2] = (-sy * center.x - cy * center.y) + center.y + srt.mTranslationY;
- dst[2][3] = 0.0f;
- dst[2][1] = 0.0f;
- dst[2][0] = 0.0f;
- dst[1][3] = 0.0f;
- dst[0][3] = 0.0f;
- dst[2][2] = 1.0f;
+ dst[0][3] = dst[1][3] = dst[2][0] = dst[2][1] = dst[2][3] = 0.0f;
+ dst[2][2] = 1.0f;
}
-
/* 80311B80-80311C34 30C4C0 00B4+00 0/0 3/3 0/0 .text
* J3DGetTextureMtxOld__FRC17J3DTextureSRTInfoRC3VecPA4_f */
void J3DGetTextureMtxOld(const J3DTextureSRTInfo& srt, const Vec& center, Mtx dst) {
@@ -262,12 +263,8 @@ void J3DGetTextureMtxOld(const J3DTextureSRTInfo& srt, const Vec& center, Mtx ds
dst[1][1] = cy;
dst[1][3] = (-sy * center.x - cy * center.y) + center.y + srt.mTranslationY;
- dst[2][3] = 0.0f;
- dst[2][1] = 0.0f;
- dst[2][0] = 0.0f;
- dst[1][2] = 0.0f;
- dst[0][2] = 0.0f;
- dst[2][2] = 1.0f;
+ dst[0][2] = dst[1][2] = dst[2][0] = dst[2][1] = dst[2][3] = 0.0f;
+ dst[2][2] = 1.0f;
}
/* 80311C34-80311CE4 30C574 00B0+00 0/0 3/3 0/0 .text
@@ -285,15 +282,10 @@ void J3DGetTextureMtxMaya(const J3DTextureSRTInfo& srt, Mtx dst) {
dst[1][1] = srt.mScaleY * cr;
dst[1][2] = -tx * sr - cr * (ty + srt.mScaleY) + 0.5f;
- dst[2][3] = 0.0f;
- dst[2][1] = 0.0f;
- dst[2][0] = 0.0f;
- dst[1][3] = 0.0f;
- dst[0][3] = 0.0f;
- dst[2][2] = 1.0f;
+ dst[0][3] = dst[1][3] = dst[2][0] = dst[2][1] = dst[2][3] = 0.0f;
+ dst[2][2] = 1.0f;
}
-
/* 80311CE4-80311D94 30C624 00B0+00 0/0 3/3 0/0 .text
* J3DGetTextureMtxMayaOld__FRC17J3DTextureSRTInfoPA4_f */
void J3DGetTextureMtxMayaOld(const J3DTextureSRTInfo& srt, Mtx dst) {
@@ -309,15 +301,10 @@ void J3DGetTextureMtxMayaOld(const J3DTextureSRTInfo& srt, Mtx dst) {
dst[1][1] = srt.mScaleY * cr;
dst[1][3] = -tx * sr - cr * (ty + srt.mScaleY) + 0.5f;
- dst[2][3] = 0.0f;
- dst[2][1] = 0.0f;
- dst[2][0] = 0.0f;
- dst[1][2] = 0.0f;
- dst[0][2] = 0.0f;
- dst[2][2] = 1.0f;
+ dst[0][2] = dst[1][2] = dst[2][0] = dst[2][1] = dst[2][3] = 0.0f;
+ dst[2][2] = 1.0f;
}
-
/* 80311D94-80311DF8 30C6D4 0064+00 0/0 2/2 0/0 .text J3DScaleNrmMtx__FPA4_fRC3Vec */
asm void J3DScaleNrmMtx(register Mtx mtx, const register Vec& scl) {
#ifdef __MWERKS__ // clang-format off
diff --git a/src/JSystem/J3DGraphBase/J3DVertex.cpp b/src/JSystem/J3DGraphBase/J3DVertex.cpp
index dfdfc48e73..481ab42fca 100644
--- a/src/JSystem/J3DGraphBase/J3DVertex.cpp
+++ b/src/JSystem/J3DGraphBase/J3DVertex.cpp
@@ -1,14 +1,8 @@
-//
-// Generated By: dol2asm
-// Translation Unit: J3DVertex
-//
-
#include "JSystem/J3DGraphBase/J3DVertex.h"
#include "JSystem/J3DGraphAnimator/J3DJointTree.h"
#include "JSystem/J3DGraphBase/J3DSys.h"
#include "JSystem/JKernel/JKRHeap.h"
-#include "string.h"
-#include <dolphin/os.h>
+#include <string.h>
#include "global.h"
/* 80310EF8-80310F78 30B838 0080+00 0/0 1/1 0/0 .text __ct__13J3DVertexDataFv */
@@ -24,10 +18,10 @@ J3DVertexData::J3DVertexData() {
mVtxNrmArray = NULL;
mVtxNBTArray = NULL;
- for (int i = 0; i < ARRAY_SIZE(mVtxColorArray); i++)
+ for (int i = 0; i < 2; i++)
mVtxColorArray[i] = NULL;
- for (int i = 0; i < ARRAY_SIZE(mVtxTexCoordArray); i++)
+ for (int i = 0; i < 8; i++)
mVtxTexCoordArray[i] = NULL;
mVtxPosFrac = 0;
@@ -39,6 +33,8 @@ J3DVertexData::J3DVertexData() {
/* 80310F78-80310FD8 30B8B8 0060+00 0/0 1/1 0/0 .text
* setVertexData__15J3DVertexBufferFP13J3DVertexData */
void J3DVertexBuffer::setVertexData(J3DVertexData* pVtxData) {
+ J3D_ASSERT_NULLPTR(175, pVtxData != NULL);
+
mVtxData = pVtxData;
mVtxPosArray[0] = pVtxData->getVtxPosArray();
mVtxNrmArray[0] = pVtxData->getVtxNrmArray();
@@ -59,20 +55,11 @@ void J3DVertexBuffer::setVertexData(J3DVertexData* pVtxData) {
void J3DVertexBuffer::init() {
mVtxData = NULL;
- mVtxPosArray[1] = NULL;
- mVtxPosArray[0] = NULL;
-
- mVtxNrmArray[1] = NULL;
- mVtxNrmArray[0] = NULL;
-
- mVtxColArray[1] = NULL;
- mVtxColArray[0] = NULL;
-
- mTransformedVtxPosArray[1] = NULL;
- mTransformedVtxPosArray[0] = NULL;
-
- mTransformedVtxNrmArray[1] = NULL;
- mTransformedVtxNrmArray[0] = NULL;
+ mVtxPosArray[0] = mVtxPosArray[1] = NULL;
+ mVtxNrmArray[0] = mVtxNrmArray[1] = NULL;
+ mVtxColArray[0] = mVtxColArray[1] = NULL;
+ mTransformedVtxPosArray[0] = mTransformedVtxPosArray[1] = NULL;
+ mTransformedVtxNrmArray[0] = mTransformedVtxNrmArray[1] = NULL;
mCurrentVtxPos = NULL;
mCurrentVtxNrm = NULL;
@@ -96,25 +83,26 @@ void J3DVertexBuffer::setArray() const {
s32 J3DVertexBuffer::copyLocalVtxPosArray(u32 flag) {
if (flag & 1) {
for (int i = 0; i < 2; i++) {
- mVtxPosArray[i] = new (0x20) Vec[mVtxData->getVtxNum()];
-
+ mVtxPosArray[i] = new (0x20) char[mVtxData->getVtxNum() * 3 * 4];
if (mVtxPosArray[i] == NULL) {
return kJ3DError_Alloc;
}
- memcpy(mVtxPosArray[i], mVtxData->getVtxPosArray(), mVtxData->getVtxNum() * 12);
- DCStoreRange(mVtxPosArray[i], mVtxData->getVtxNum() * 12);
+
+ memcpy(mVtxPosArray[i], mVtxData->getVtxPosArray(), mVtxData->getVtxNum() * 3 * 4);
+ DCStoreRange(mVtxPosArray[i], mVtxData->getVtxNum() * 3 * 4);
}
} else {
mVtxPosArray[0] = mVtxData->getVtxPosArray();
if (mVtxPosArray[1] == NULL) {
- mVtxPosArray[1] = new (0x20) Vec[mVtxData->getVtxNum()];
+ mVtxPosArray[1] = new (0x20) char[mVtxData->getVtxNum() * 3 * 4];
if (mVtxPosArray[1] == NULL) {
return kJ3DError_Alloc;
}
}
- memcpy(mVtxPosArray[1], mVtxData->getVtxPosArray(), mVtxData->getVtxNum() * 12);
- DCStoreRange(mVtxPosArray[1], mVtxData->getVtxNum() * 12);
+
+ memcpy(mVtxPosArray[1], mVtxData->getVtxPosArray(), mVtxData->getVtxNum() * 3 * 4);
+ DCStoreRange(mVtxPosArray[1], mVtxData->getVtxNum() * 3 * 4);
}
return kJ3DError_Success;
@@ -125,25 +113,26 @@ s32 J3DVertexBuffer::copyLocalVtxPosArray(u32 flag) {
s32 J3DVertexBuffer::copyLocalVtxNrmArray(u32 flag) {
if (flag & 1) {
for (int i = 0; i < 2; i++) {
- mVtxNrmArray[i] = new (0x20) VertexNormal[mVtxData->getNrmNum()];
-
+ mVtxNrmArray[i] = new (0x20) char[mVtxData->getNrmNum() * 3 * 4];
if (mVtxNrmArray[i] == NULL) {
return kJ3DError_Alloc;
}
- memcpy(mVtxNrmArray[i], mVtxData->getVtxNrmArray(), mVtxData->getNrmNum() * 12);
- DCStoreRange(mVtxNrmArray[i], mVtxData->getNrmNum() * 12);
+
+ memcpy(mVtxNrmArray[i], mVtxData->getVtxNrmArray(), mVtxData->getNrmNum() * 3 * 4);
+ DCStoreRange(mVtxNrmArray[i], mVtxData->getNrmNum() * 3 * 4);
}
} else {
mVtxNrmArray[0] = mVtxData->getVtxNrmArray();
if (mVtxNrmArray[1] == NULL) {
- mVtxNrmArray[1] = new (0x20) VertexNormal[mVtxData->getNrmNum()];
+ mVtxNrmArray[1] = new (0x20) char[mVtxData->getNrmNum() * 3 * 4];
if (mVtxNrmArray[1] == NULL) {
return kJ3DError_Alloc;
}
}
- memcpy(mVtxNrmArray[1], mVtxData->getVtxNrmArray(), mVtxData->getNrmNum() * 12);
- DCStoreRange(mVtxNrmArray[1], mVtxData->getNrmNum() * 12);
+
+ memcpy(mVtxNrmArray[1], mVtxData->getVtxNrmArray(), mVtxData->getNrmNum() * 3 * 4);
+ DCStoreRange(mVtxNrmArray[1], mVtxData->getNrmNum() * 3 * 4);
}
return kJ3DError_Success;
@@ -185,6 +174,7 @@ s32 J3DVertexBuffer::copyLocalVtxArray(u32 flag) {
delete mVtxPosArray[i];
mVtxPosArray[i] = oldPosArray[i];
}
+
if (oldNrmArray[i] != mVtxNrmArray[i]) {
if (mVtxNrmArray[i] != mVtxData->getVtxNrmArray())
delete mVtxNrmArray[i];
@@ -208,7 +198,7 @@ s32 J3DVertexBuffer::allocTransformedVtxPosArray() {
for (int i = 0; i < 2; i++) {
if (i == 0 || mTransformedVtxPosArray[i] == NULL) {
- mTransformedVtxPosArray[i] = new (0x20) Vec[mVtxData->getVtxNum()];
+ mTransformedVtxPosArray[i] = new (0x20) char[mVtxData->getVtxNum() * 3 * 4];
if (mTransformedVtxPosArray[i] == NULL)
return kJ3DError_Alloc;
}
@@ -225,7 +215,7 @@ s32 J3DVertexBuffer::allocTransformedVtxNrmArray() {
for (int i = 0; i < 2; i++) {
if (i == 0 || mTransformedVtxNrmArray[i] == NULL) {
- mTransformedVtxNrmArray[i] = new (0x20) VertexNormal[mVtxData->getNrmNum()];
+ mTransformedVtxNrmArray[i] = new (0x20) char[mVtxData->getNrmNum() * 3 * 4];
if (mTransformedVtxNrmArray[i] == NULL)
return kJ3DError_Alloc;
}