diff options
| author | Max Roncace <me@caseif.net> | 2025-08-08 05:56:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-08 12:56:18 +0300 |
| commit | 156d2b24c36309f455e0284806ae9d2170775bdb (patch) | |
| tree | ce861916f208d60d0e75ca0f0417c06c9db377cf /src/JSystem/J3DGraphBase | |
| parent | 57c9d6430818186504cd0457313a0197e0f4b84c (diff) | |
Misc. J3D improvements (#2570)
Diffstat (limited to 'src/JSystem/J3DGraphBase')
| -rw-r--r-- | src/JSystem/J3DGraphBase/J3DMatBlock.cpp | 242 | ||||
| -rw-r--r-- | src/JSystem/J3DGraphBase/J3DShape.cpp | 4 | ||||
| -rw-r--r-- | src/JSystem/J3DGraphBase/J3DShapeMtx.cpp | 284 | ||||
| -rw-r--r-- | src/JSystem/J3DGraphBase/J3DTexture.cpp | 19 |
4 files changed, 298 insertions, 251 deletions
diff --git a/src/JSystem/J3DGraphBase/J3DMatBlock.cpp b/src/JSystem/J3DGraphBase/J3DMatBlock.cpp index fd6832381c..068f3b5bb1 100644 --- a/src/JSystem/J3DGraphBase/J3DMatBlock.cpp +++ b/src/JSystem/J3DGraphBase/J3DMatBlock.cpp @@ -4,12 +4,12 @@ // #include "JSystem/J3DGraphBase/J3DMatBlock.h" -#include "JSystem/J3DGraphBase/J3DGD.h" +#include "JSystem/J3DGraphBase/J3DPacket.h" #include "JSystem/J3DGraphBase/J3DSys.h" #include "JSystem/J3DGraphBase/J3DTransform.h" #include "dolphin/os.h" -#include "string.h" #include "global.h" +#include "string.h" inline void loadMatColors(const J3DGXColor* color) { J3DGDWriteXFCmdHdr(0x100C, 2); @@ -38,7 +38,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 (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mMatColor); i++) { mMatColor[i] = j3dDefaultColInfo; } mMatColorOffset = 0; @@ -48,10 +48,10 @@ void J3DColorBlockLightOff::initialize() { /* 803174DC-80317580 311E1C 00A4+00 0/0 1/1 0/0 .text initialize__22J3DColorBlockAmbientOnFv */ void J3DColorBlockAmbientOn::initialize() { mColorChanNum = 0; - for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mMatColor); i++) { mMatColor[i] = j3dDefaultColInfo; } - for (u32 i = 0; i < ARRAY_SIZE(mAmbColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mAmbColor); i++) { mAmbColor[i] = j3dDefaultAmbInfo; } mMatColorOffset = 0; @@ -61,13 +61,13 @@ void J3DColorBlockAmbientOn::initialize() { /* 80317580-80317644 311EC0 00C4+00 0/0 1/1 0/0 .text initialize__20J3DColorBlockLightOnFv */ void J3DColorBlockLightOn::initialize() { mColorChanNum = 0; - for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mMatColor); i++) { mMatColor[i] = j3dDefaultColInfo; } - for (u32 i = 0; i < ARRAY_SIZE(mAmbColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mAmbColor); i++) { mAmbColor[i] = j3dDefaultAmbInfo; } - for (u32 i = 0; i < ARRAY_SIZE(mLight); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mLight); i++) { mLight[i] = NULL; } mMatColorOffset = 0; @@ -77,7 +77,7 @@ void J3DColorBlockLightOn::initialize() { /* 80317644-80317674 311F84 0030+00 0/0 2/2 0/0 .text initialize__21J3DTexGenBlockPatchedFv */ void J3DTexGenBlockPatched::initialize() { mTexGenNum = 0; - for (u32 i = 0; i < 8; i++) + for (s32 i = 0; i < 8; i++) mTexMtx[i] = NULL; mTexMtxOffset = 0; } @@ -85,7 +85,7 @@ void J3DTexGenBlockPatched::initialize() { /* 80317674-803176A4 311FB4 0030+00 0/0 1/1 0/0 .text initialize__15J3DTexGenBlock4Fv */ void J3DTexGenBlock4::initialize() { mTexGenNum = 0; - for (u32 i = 0; i < 4; i++) + for (s32 i = 0; i < 4; i++) mTexMtx[i] = NULL; mTexMtxOffset = 0; } @@ -94,7 +94,7 @@ void J3DTexGenBlock4::initialize() { */ void J3DTexGenBlockBasic::initialize() { mTexGenNum = 0; - for (u32 i = 0; i < 8; i++) + for (s32 i = 0; i < 8; i++) mTexMtx[i] = NULL; mTexMtxOffset = 0; } @@ -107,20 +107,19 @@ void J3DTevBlockNull::initialize() { /* 803176E0-803177E8 312020 0108+00 0/0 1/1 0/0 .text initialize__18J3DTevBlockPatchedFv */ void J3DTevBlockPatched::initialize() { - for (u32 i = 0; i < ARRAY_SIZE(mTexNo); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTexNo); i++) { mTexNo[i] = 0xFFFF; } - for (u32 i = 0; i < ARRAY_SIZE(mTevStage); i++) { - mTevStage[i].field_0x0 = 0xC0 + i * 2; - mTevStage[i].field_0x4 = 0xC1 + i * 2; + for (s32 i = 0; i < ARRAY_SIZE(mTevStage); i++) { + mTevStage[i].setStageNo(i); } - for (u32 i = 0; i < 3; i++) { + for (s32 i = 0; i < 3; i++) { mTevColor[i] = j3dDefaultTevColor; } - for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) { mTevKColor[i] = j3dDefaultTevKColor; } - for (u32 i = 0; i < ARRAY_SIZE(mTevKColorSel); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColorSel); i++) { mTevKColorSel[i] = GX_TEV_KCSEL_K0; } mTevStageNum = 1; @@ -131,8 +130,7 @@ void J3DTevBlockPatched::initialize() { /* 803177E8-80317810 312128 0028+00 0/0 1/1 0/0 .text initialize__12J3DTevBlock1Fv */ void J3DTevBlock1::initialize() { mTexNo[0] = 0xFFFF; - mTevStage[0].field_0x0 = 0xC0; - mTevStage[0].field_0x4 = 0xC1; + mTevStage[0].setStageNo(0); mTexNoOffset = 0; } @@ -142,19 +140,17 @@ void J3DTevBlock2::initialize() { mTexNo[1] = 0xFFFF; mTevStageNum = 1; - mTevStage[0].field_0x0 = 0xC0; - mTevStage[0].field_0x4 = 0xC1; - mTevStage[1].field_0x0 = 0xC2; - mTevStage[1].field_0x4 = 0xC3; + mTevStage[0].setStageNo(0); + mTevStage[1].setStageNo(1); mTevKColorSel[0] = GX_TEV_KCSEL_K0; mTevKColorSel[1] = GX_TEV_KCSEL_K0; mTevKAlphaSel[0] = GX_TEV_KASEL_K0_A; mTevKAlphaSel[1] = GX_TEV_KASEL_K0_A; - for (u32 i = 0; i < 3; i++) { + for (s32 i = 0; i < 3; i++) { mTevColor[i] = j3dDefaultTevColor; } - for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) { mTevKColor[i] = j3dDefaultTevKColor; } mTexNoOffset = 0; @@ -169,14 +165,10 @@ void J3DTevBlock4::initialize() { mTexNo[3] = 0xFFFF; mTevStageNum = 1; - mTevStage[0].field_0x0 = 0xC0; - mTevStage[0].field_0x4 = 0xC1; - mTevStage[1].field_0x0 = 0xC2; - mTevStage[1].field_0x4 = 0xC3; - mTevStage[2].field_0x0 = 0xC4; - mTevStage[2].field_0x4 = 0xC5; - mTevStage[3].field_0x0 = 0xC6; - mTevStage[3].field_0x4 = 0xC7; + mTevStage[0].setStageNo(0); + 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; @@ -186,10 +178,10 @@ void J3DTevBlock4::initialize() { mTevKAlphaSel[2] = GX_TEV_KASEL_K0_A; mTevKAlphaSel[3] = GX_TEV_KASEL_K0_A; - for (u32 i = 0; i < 3; i++) { + for (s32 i = 0; i < 3; i++) { mTevColor[i] = j3dDefaultTevColor; } - for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) { mTevKColor[i] = j3dDefaultTevKColor; } mTexNoOffset = 0; @@ -198,25 +190,24 @@ void J3DTevBlock4::initialize() { /* 80317A00-80317B28 312340 0128+00 0/0 1/1 0/0 .text initialize__13J3DTevBlock16Fv */ void J3DTevBlock16::initialize() { - for (u32 i = 0; i < ARRAY_SIZE(mTexNo); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTexNo); i++) { mTexNo[i] = 0xFFFF; } mTevStageNum = 1; - for (u32 i = 0; i < 3; i++) { + for (s32 i = 0; i < 3; i++) { mTevColor[i] = j3dDefaultTevColor; } - for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColor); i++) { mTevKColor[i] = j3dDefaultTevKColor; } - for (u32 i = 0; i < ARRAY_SIZE(mTevKColorSel); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColorSel); i++) { mTevKColorSel[i] = GX_TEV_KCSEL_K0; } - for (u32 i = 0; i < ARRAY_SIZE(mTevKColorSel); i++) { + for (s32 i = 0; i < (s32)ARRAY_SIZE(mTevKColorSel); i++) { mTevKAlphaSel[i] = GX_TEV_KASEL_K0_A; } - for (u32 i = 0; i < ARRAY_SIZE(mTevStage); i++) { - mTevStage[i].field_0x0 = 0xC0 + i * 2; - mTevStage[i].field_0x4 = 0xC1 + i * 2; + for (s32 i = 0; i < ARRAY_SIZE(mTevStage); i++) { + mTevStage[i].setStageNo(i); } mTexNoOffset = 0; mTevRegOffset = 0; @@ -229,16 +220,16 @@ void J3DIndBlockFull::initialize() { /* 80317B34-80317B58 312474 0024+00 0/0 1/1 0/0 .text initialize__16J3DPEBlockFogOffFv */ void J3DPEBlockFogOff::initialize() { - mAlphaComp.mID = 0xFFFF; - mZMode.mZModeID = 0xFFFF; + mAlphaComp = 0xFFFF; + mZMode = 0xFFFF; mZCompLoc = 0xFF; mDither = 1; } /* 80317B58-80317B84 312498 002C+00 0/0 1/1 0/0 .text initialize__14J3DPEBlockFullFv */ void J3DPEBlockFull::initialize() { - mAlphaComp.mID = 0xFFFF; - mZMode.mZModeID = 0xFFFF; + mAlphaComp = 0xFFFF; + mZMode = 0xFFFF; mZCompLoc = 0xFF; mDither = 1; mFogOffset = 0; @@ -341,12 +332,14 @@ static u32 SizeOfLoadAmbColors = 0x0000000D; /* 80450968-80450970 0003E8 0004+04 5/5 0/0 0/0 .sdata SizeOfLoadColorChans */ static u32 SizeOfLoadColorChans = 21; +static u8 sdata_padding[4] = {}; + /* 804515D8-804515DC 000AD8 0004+00 2/2 0/0 0/0 .sbss SizeOfJ3DColorBlockLightOffLoad */ static u32 SizeOfJ3DColorBlockLightOffLoad = SizeOfLoadMatColors + SizeOfLoadColorChans; -u8 J3DColorChan::getAttnFn() const { +u8 J3DColorChan::getAttnFn() const { u8 AttnArr[] = {2,0,2,1}; - return AttnArr[(mColorChanID >> 9) & 3]; + return AttnArr[(u32)(mColorChanID & (3 << 9)) >> 9]; } /* 80317C0C-8031816C 31254C 0560+00 1/0 0/0 0/0 .text load__21J3DColorBlockLightOffFv */ @@ -498,8 +491,9 @@ void J3DColorBlockLightOn::diff(u32 flag) { if (flag & 2) diffColorChan(); - if ((flag >> 4) & 0x0f) - diffLightObj((flag >> 4) & 0x0f); + s32 lightObjNumFlag = getDiffFlag_LightObjNum(flag); + if (lightObjNumFlag) + diffLightObj(lightObjNumFlag); } /* 8031A1DC-8031A358 314B1C 017C+00 1/0 0/0 0/0 .text diffAmbColor__20J3DColorBlockLightOnFv */ @@ -600,7 +594,7 @@ void J3DTexGenBlockBasic::patch() { /* 8031AC68-8031ACD0 3155A8 0068+00 3/0 0/0 0/0 .text diff__21J3DTexGenBlockPatchedFUl */ void J3DTexGenBlockPatched::diff(u32 flag) { - if ((flag >> 8) & 0x0f) { + if (getDiffFlag_TexGenNum(flag)) { diffTexMtx(); if (flag & 0x1000) { diffTexGen(); @@ -650,7 +644,7 @@ void J3DTevBlock1::load() { /* 8031AFA4-8031B4C0 3158E4 051C+00 1/0 0/0 0/0 .text load__12J3DTevBlock2Fv */ void J3DTevBlock2::load() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; mTexNoOffset = GDGetCurrOffset(); for (u32 i = 0; i < 2; i++) { if (mTexNo[i] != 0xffff) { @@ -709,7 +703,7 @@ void J3DTevBlock2::load() { /* 8031B4C0-8031BA04 315E00 0544+00 1/0 0/0 0/0 .text load__12J3DTevBlock4Fv */ void J3DTevBlock4::load() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; mTexNoOffset = GDGetCurrOffset(); for (u32 i = 0; i < 4; i++) { if (mTexNo[i] != 0xffff) { @@ -770,7 +764,7 @@ void J3DTevBlock4::load() { /* 8031BA04-8031BF4C 316344 0548+00 1/0 0/0 0/0 .text load__13J3DTevBlock16Fv */ void J3DTevBlock16::load() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; mTexNoOffset = GDGetCurrOffset(); for (u32 i = 0; i < 8; i++) { if (mTexNo[i] != 0xffff) { @@ -853,10 +847,10 @@ void J3DTevBlockPatched::patchTevReg() { void* start = GDGetCurrPointer(); for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } void* end = GDGetCurrPointer(); @@ -869,7 +863,7 @@ void J3DTevBlockPatched::patchTexNoAndTexCoordScale() { GDSetCurrOffset(mTexNoOffset); void* start = GDGetCurrPointer(); - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < 8; i++) { if (mTexNo[i] != 0xffff) { loadTexNo(i, mTexNo[i]); @@ -977,10 +971,10 @@ void J3DTevBlock2::patchTevReg() { void* start = GDGetCurrPointer(); for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } void* end = GDGetCurrPointer(); @@ -1048,10 +1042,10 @@ void J3DTevBlock4::patchTevReg() { void* start = GDGetCurrPointer(); for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } void* end = GDGetCurrPointer(); @@ -1064,7 +1058,7 @@ void J3DTevBlock4::patchTexNoAndTexCoordScale() { GDSetCurrOffset(mTexNoOffset); void* start = GDGetCurrPointer(); - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < 4; i++) { if (mTexNo[i] != 0xffff) { loadTexNo(i, mTexNo[i]); @@ -1121,10 +1115,10 @@ void J3DTevBlock16::patchTevReg() { void* start = GDGetCurrPointer(); for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } void* end = GDGetCurrPointer(); @@ -1137,7 +1131,7 @@ void J3DTevBlock16::patchTexNoAndTexCoordScale() { GDSetCurrOffset(mTexNoOffset); void* start = GDGetCurrPointer(); - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < 8; i++) { if (mTexNo[i] != 0xffff) { loadTexNo(i, mTexNo[i]); @@ -1168,7 +1162,6 @@ void J3DTevBlock16::patchTexNoAndTexCoordScale() { DCStoreRange(start, (u32)end - (u32)start); } - /* 8031CCF8-8031CD44 317638 004C+00 1/0 0/0 0/0 .text patch__13J3DTevBlock16Fv */ void J3DTevBlock16::patch() { patchTexNo(); @@ -1177,13 +1170,13 @@ void J3DTevBlock16::patch() { /* 8031CD44-8031CE00 317684 00BC+00 6/0 1/0 0/0 .text diff__11J3DTevBlockFUl */ void J3DTevBlock::diff(u32 flag) { - if ((flag >> 16) & 0x0f) { + if (getDiffFlag_TexNoNum(flag)) { diffTexNo(); } if (flag & 0x4000000) { diffTexCoordScale(); } - if ((flag >> 20) & 0x0f) { + if (getDiffFlag_TevStageNum(flag)) { diffTevStage(); if (flag & 0x8000000) { diffTevStageIndirect(); @@ -1206,7 +1199,7 @@ void J3DTevBlockPatched::diffTexNo() { /* 8031CE64-8031CF78 3177A4 0114+00 1/0 0/0 0/0 .text diffTevStage__18J3DTevBlockPatchedFv */ void J3DTevBlockPatched::diffTevStage() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mTevStage[i].load(i); } @@ -1215,7 +1208,7 @@ void J3DTevBlockPatched::diffTevStage() { /* 8031CF78-8031D028 3178B8 00B0+00 1/0 0/0 0/0 .text diffTevStageIndirect__18J3DTevBlockPatchedFv */ void J3DTevBlockPatched::diffTevStageIndirect() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mIndTevStage[i].load(i); } @@ -1225,16 +1218,16 @@ void J3DTevBlockPatched::diffTevStageIndirect() { */ void J3DTevBlockPatched::diffTevReg() { for (u32 i = 0; i < ARRAY_SIZE(mTevColor) - 1; i++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } } /* 8031D0C4-8031D1BC 317A04 00F8+00 1/0 0/0 0/0 .text diffTexCoordScale__18J3DTevBlockPatchedFv */ void J3DTevBlockPatched::diffTexCoordScale() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i += 2) { loadTexCoordScale( GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7), @@ -1289,16 +1282,16 @@ 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++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } } /* 8031D4D0-8031D5E4 317E10 0114+00 1/0 0/0 0/0 .text diffTevStage__12J3DTevBlock2Fv */ void J3DTevBlock2::diffTevStage() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mTevStage[i].load(i); } @@ -1306,7 +1299,7 @@ void J3DTevBlock2::diffTevStage() { /* 8031D5E4-8031D694 317F24 00B0+00 1/0 0/0 0/0 .text diffTevStageIndirect__12J3DTevBlock2Fv */ void J3DTevBlock2::diffTevStageIndirect() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mIndTevStage[i].load(i); } @@ -1337,23 +1330,23 @@ 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++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } } /* 8031D858-8031D96C 318198 0114+00 1/0 0/0 0/0 .text diffTevStage__12J3DTevBlock4Fv */ void J3DTevBlock4::diffTevStage() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mTevStage[i].load(i); } } /* 8031D96C-8031DA1C 3182AC 00B0+00 1/0 0/0 0/0 .text diffTevStageIndirect__12J3DTevBlock4Fv */ void J3DTevBlock4::diffTevStageIndirect() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mIndTevStage[i].load(i); } @@ -1362,7 +1355,7 @@ void J3DTevBlock4::diffTevStageIndirect() { /* 8031DA1C-8031DB14 31835C 00F8+00 1/0 0/0 0/0 .text diffTexCoordScale__12J3DTevBlock4Fv */ void J3DTevBlock4::diffTexCoordScale() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i += 2) { loadTexCoordScale( GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7), @@ -1386,16 +1379,16 @@ 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++) { - J3DGDSetTevColorS10((GXTevRegID)(i + 1), mTevColor[i]); + loadTevColor(i, mTevColor[i]); } for (u32 i = 0; i < ARRAY_SIZE(mTevKColor); i++) { - J3DGDSetTevKColor((GXTevKColorID)i, mTevKColor[i]); + loadTevKColor(i, mTevKColor[i]); } } /* 8031DC14-8031DD28 318554 0114+00 1/0 0/0 0/0 .text diffTevStage__13J3DTevBlock16Fv */ void J3DTevBlock16::diffTevStage() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mTevStage[i].load(i); } @@ -1403,7 +1396,7 @@ void J3DTevBlock16::diffTevStage() { /* 8031DD28-8031DDD8 318668 00B0+00 1/0 0/0 0/0 .text diffTevStageIndirect__13J3DTevBlock16Fv */ void J3DTevBlock16::diffTevStageIndirect() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i++) { mIndTevStage[i].load(i); } @@ -1411,7 +1404,7 @@ void J3DTevBlock16::diffTevStageIndirect() { /* 8031DDD8-8031DED0 318718 00F8+00 1/0 0/0 0/0 .text diffTexCoordScale__13J3DTevBlock16Fv */ void J3DTevBlock16::diffTexCoordScale() { - u8 tevStageNum = mTevStageNum; + u32 tevStageNum = mTevStageNum; for (u32 i = 0; i < tevStageNum; i += 2) { loadTexCoordScale( GXTexCoordID(mTevOrder[i].getTevOrderInfo().mTexCoord & 7), @@ -1434,8 +1427,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."); offs += 0x14; - if (j3dSys.getTexture()->getResTIMG(mTexNo[i])->indexTexture == 1) { + if (img->indexTexture == 1) { offs += 0x23; } } @@ -1456,8 +1451,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."); offs += 0x14; - if (j3dSys.getTexture()->getResTIMG(mTexNo[i])->indexTexture == 1) { + if (img->indexTexture == 1) { offs += 0x23; } } @@ -1523,7 +1520,7 @@ void J3DIndBlockFull::diff(u32 flag) { if ((flag & 0x08000000) == 0) { return; } - u8 indTexStageNum = mIndTexStageNum; + u32 indTexStageNum = mIndTexStageNum; mIndTexMtx[0].load(0); J3DGDSetIndTexCoordScale( GX_INDTEXSTAGE0, @@ -1641,6 +1638,8 @@ 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."); + mColorChanNum = pBlock->getColorChanNum(); for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) { @@ -1654,6 +1653,8 @@ 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."); + mColorChanNum = pBlock->getColorChanNum(); for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) { @@ -1672,6 +1673,8 @@ 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."); + mColorChanNum = pBlock->getColorChanNum(); for (u32 i = 0; i < ARRAY_SIZE(mMatColor); i++) { @@ -1690,6 +1693,8 @@ 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."); + mTexGenNum = pBlock->getTexGenNum(); for (u32 i = 0; i < 8; i++) { mTexCoord[i] = *pBlock->getTexCoord(i); @@ -1709,6 +1714,8 @@ 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."); + mTexGenNum = pBlock->getTexGenNum(); for (u32 i = 0; i < 4; i++) { mTexCoord[i] = *pBlock->getTexCoord(i); @@ -1730,6 +1737,8 @@ 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."); + mTexGenNum = pBlock->getTexGenNum(); for (u32 i = 0; i < 8; i++) { mTexCoord[i] = *pBlock->getTexCoord(i); @@ -1751,6 +1760,8 @@ 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."); + mTevStageNum = pBlock->getTevStageNum(); for (u32 i = 0; i < 8; i++) { mTexNo[i] = pBlock->getTexNo(i); @@ -1769,6 +1780,8 @@ 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."); + mTexNo[0] = pBlock->getTexNo(0); mTevOrder[0] = *pBlock->getTevOrder(0); mTevStage[0] = *pBlock->getTevStage(0); @@ -1777,6 +1790,8 @@ 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."); + mTevStageNum = pBlock->getTevStageNum(); mTexNo[0] = pBlock->getTexNo(0); mTexNo[1] = pBlock->getTexNo(1); @@ -1803,6 +1818,8 @@ 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."); + mTevStageNum = pBlock->getTevStageNum(); mTexNo[0] = pBlock->getTexNo(0); mTexNo[1] = pBlock->getTexNo(1); @@ -1838,6 +1855,8 @@ 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."); + mTevStageNum = pBlock->getTevStageNum(); for (u32 i = 0; i < 8; i++) { mTexNo[i] = pBlock->getTexNo(i); @@ -1868,6 +1887,8 @@ 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."); + mIndTexStageNum = pBlock->getIndTexStageNum(); for (u32 i = 0; i < 4; i++) { mIndTexOrder[i] = *pBlock->getIndTexOrder(i); @@ -1882,6 +1903,8 @@ 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."); + switch (pBlock->getType()) { case 'PEFL': case 'PEFG': @@ -1895,8 +1918,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."); + if (pBlock->getFog() != NULL) { - mFog = *pBlock->getFog(); + this->mFog.setFogInfo(pBlock->getFog()->getFogInfo()); } switch (pBlock->getType()) { @@ -1915,7 +1940,7 @@ void J3DTexGenBlockPatched::calc(const Mtx modelMtx) { Mtx viewMtx; for (int i = 0; i < 8; i++) { if (mTexMtx[i] != NULL) { - u8 texMtxMode = mTexMtx[i]->getTexMtxInfo().mInfo & 0x3f; + u32 texMtxMode = mTexMtx[i]->getTexMtxInfo().mInfo & 0x3f; mTexCoord[i].resetTexMtxReg(); switch (texMtxMode) { case J3DTexMtxMode_EnvmapBasic: @@ -1976,7 +2001,7 @@ void J3DTexGenBlockPatched::calcWithoutViewMtx(const Mtx modelMtx) { Mtx mtx; for (int i = 0; i < 8; i++) { if (mTexMtx[i] != NULL) { - u8 texMtxMode = mTexMtx[i]->getTexMtxInfo().mInfo & 0x3f; + u32 texMtxMode = mTexMtx[i]->getTexMtxInfo().mInfo & 0x3f; mTexCoord[i].resetTexMtxReg(); switch (texMtxMode) { case J3DTexMtxMode_EnvmapBasic: @@ -2023,7 +2048,7 @@ void J3DTexGenBlockPatched::calcPostTexMtx(const Mtx modelMtx) { Mtx mtx1, mtx2; for (int i = 0; i < 8; i++) { if (mTexMtx[i] != NULL) { - u8 texMtxMode = mTexMtx[i]->getTexMtxInfo().mInfo & 0x3f; + u32 texMtxMode = mTexMtx[i]->getTexMtxInfo().mInfo & 0x3f; mTexCoord[i].resetTexMtxReg(); switch (texMtxMode) { case J3DTexMtxMode_EnvmapBasic: @@ -2034,7 +2059,7 @@ void J3DTexGenBlockPatched::calcPostTexMtx(const Mtx modelMtx) { break; case J3DTexMtxMode_ProjmapBasic: case J3DTexMtxMode_Projmap: - MTXInverse(j3dSys.getViewMtx(), mtx1); + PSMTXInverse(j3dSys.getViewMtx(), mtx1); mTexCoord[i].setTexMtxReg(0); mTexMtx[i]->calcPostTexMtx(mtx1); break; @@ -2046,7 +2071,7 @@ void J3DTexGenBlockPatched::calcPostTexMtx(const Mtx modelMtx) { case J3DTexMtxMode_Unknown5: case J3DTexMtxMode_EnvmapOldEffectMtx: case J3DTexMtxMode_EnvmapEffectMtx: - MTXInverse(j3dSys.getViewMtx(), mtx2); + PSMTXInverse(j3dSys.getViewMtx(), mtx2); mtx2[0][3] = 0.0f; mtx2[1][3] = 0.0f; mtx2[2][3] = 0.0f; @@ -2056,7 +2081,7 @@ void J3DTexGenBlockPatched::calcPostTexMtx(const Mtx modelMtx) { default: mTexCoord[i].setTexMtxReg(60); mTexMtx[i]->calcPostTexMtx(j3dDefaultMtx); - break; + continue; } } } @@ -2100,3 +2125,22 @@ void J3DTexGenBlockPatched::calcPostTexMtxWithoutViewMtx(f32 const (*param_0)[4] } } } + +void J3DTevBlock::diffTevReg() { + // empty function +} + +void J3DTevBlock::diffTevStageIndirect() { + // empty function +} + +void J3DTevBlock::diffTevStage() { + // empty function +} + +void J3DTevBlock::diffTexCoordScale() { + // empty function +} + +void J3DTevBlock::diffTexNo() { +} diff --git a/src/JSystem/J3DGraphBase/J3DShape.cpp b/src/JSystem/J3DGraphBase/J3DShape.cpp index dcccb4449d..fee08feb08 100644 --- a/src/JSystem/J3DGraphBase/J3DShape.cpp +++ b/src/JSystem/J3DGraphBase/J3DShape.cpp @@ -110,8 +110,8 @@ void J3DShape::calcNBTScale(Vec const& param_0, f32 (*param_1)[3][3], f32 (*para } /* 80314E28-80314E98 30F768 0070+00 0/0 1/1 0/0 .text countBumpMtxNum__8J3DShapeCFv */ -u32 J3DShape::countBumpMtxNum() const { - u32 num = 0; +u16 J3DShape::countBumpMtxNum() const { + u16 num = 0; for (u16 i = 0; i < mMtxGroupNum; i++) num += mShapeMtx[i]->getUseMtxNum(); return num; diff --git a/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp b/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp index 65caadad4b..e3fc9f2bc1 100644 --- a/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp +++ b/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp @@ -109,7 +109,6 @@ J3DTexGenBlock* J3DDifferedTexMtx::sTexGenBlock; J3DTexMtxObj* J3DDifferedTexMtx::sTexMtxObj; /* 8031322C-80313828 30DB6C 05FC+00 7/5 0/0 0/0 .text loadExecute__17J3DDifferedTexMtxFPA4_Cf */ -// NONMATCHING regalloc void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) { static Mtx qMtx = { {0.5f, 0.0f, 0.5f, 0.0f}, @@ -121,194 +120,193 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) { {0.0f, -0.5f, 0.0f, 0.5f}, {0.0f, 0.0f, 1.0f, 0.0f} }; - J3DTexCoord* tex_coord; - J3DTexMtx* tex_mtx; - Mtx* mtx; - Mtx44* eff_mtx; - Mtx tmp2; - Mtx44 tmp1, tmp0; - J3DTexMtxInfo* tex_mtx_info; - J3DTexGenBlock* tex_gen_block = sTexGenBlock; - J3DTexMtxObj* tex_mtx_obj = sTexMtxObj; + + Mtx* mtx; // sp_64 + Mtx sp_e8; + Mtx44 sp_a8, sp_68; + + J3DTexGenBlock* tex_gen_block = sTexGenBlock; // sp_60 + JUT_ASSERT_MSG(0xc3, tex_gen_block != NULL, "Error : null pointer"); + + J3DTexMtxObj* tex_mtx_obj = sTexMtxObj; // sp_5c + JUT_ASSERT_MSG(0xc6, tex_mtx_obj != NULL, "Error : null pointer"); + + J3DTexMtxInfo* tex_mtx_info_1; // sp_58 + int tex_gen_type; // sp_54 + J3DTexMtx* tex_mtx_2; // sp_50 + u16 tex_mtx_num = tex_mtx_obj->getNumTexMtx(); - if ((j3dSys.checkFlag(J3DSysFlag_PostTexMtx))) { - for (u16 i = 0; i < (u16)tex_mtx_num; i++) { - tex_coord = tex_gen_block->getTexCoord(i); - int tex_gen_type = tex_coord->getTexGenType(); + + if (j3dSys.checkFlag(J3DSysFlag_PostTexMtx)) { + for (u16 i = 0; i < tex_mtx_num; i++) { + tex_gen_type = tex_gen_block->getTexCoord(i)->getTexGenType(); if (tex_gen_type == 1 || tex_gen_type == 0) { - tex_mtx = tex_gen_block->getTexMtx(i); - u8 tex_gen_src = tex_mtx->getTexMtxInfo().mInfo; - u32 unk; - switch (tex_gen_src & 0x3f) { + tex_mtx_2 = tex_gen_block->getTexMtx(i); + JUT_ASSERT_MSG(0xd7, tex_mtx_2 != NULL, "Error : null pointer"); + tex_mtx_info_1 = &tex_mtx_2->getTexMtxInfo(); + u32 sp_4c = tex_mtx_info_1->mInfo & 0x3f; + switch (sp_4c) { case 3: case 9: { - Mtx& tmp5 = tex_mtx_obj->getMtx(i); - mtx = &tmp5; + mtx = &tex_mtx_obj->getMtx(i); break; } case 1: case 6: case 7: { - Mtx& tmp6 = tex_mtx_obj->getMtx(i); - mtx = &tmp6; + mtx = &tex_mtx_obj->getMtx(i); break; } case 2: - case 8: - PSMTXInverse(j3dSys.mViewMtx, tmp2); - PSMTXConcat(tex_mtx_obj->getMtx(i), tmp2, tmp2); - mtx = &tmp2; + case 8: { + MTXInverse(j3dSys.getViewMtx(), sp_e8); + MTXConcat(tex_mtx_obj->getMtx(i), sp_e8, sp_e8); + mtx = &sp_e8; break; - case 5: - tex_mtx_info = &tex_mtx->getTexMtxInfo(); - unk = (tex_gen_src & 0x80) >> 7; - if (unk == 0) { - J3DGetTextureMtxOld(tex_mtx_info->mSRT, tex_mtx_info->mCenter, tmp0); - } else if (unk == 1) { - J3DGetTextureMtxMayaOld(tex_mtx_info->mSRT, tmp0); + } + case 5: { + J3DTexMtxInfo* tex_mtx_info_2 = &tex_mtx_2->getTexMtxInfo(); // sp_48 + u32 sp_44 = (u32)(tex_mtx_info_2->mInfo & 0x80) >> 7; + if (sp_44 == 0) { + J3DGetTextureMtxOld(tex_mtx_info_2->mSRT, tex_mtx_info_2->mCenter, sp_68); + } else if (sp_44 == 1) { + J3DGetTextureMtxMayaOld(tex_mtx_info_2->mSRT, sp_68); } - eff_mtx = &tex_mtx_obj->getEffectMtx(i); - J3DMtxProjConcat(tmp0, *eff_mtx, tmp2); - PSMTXInverse(j3dSys.mViewMtx, tmp1); - PSMTXConcat(tmp2, tmp1, tmp2); - tmp2[2][3] = 0.0f; - tmp2[1][3] = 0.0f; - tmp2[0][3] = 0.0f; - mtx = &tmp2; + J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8); + MTXInverse(j3dSys.getViewMtx(), sp_a8); + MTXConcat(sp_e8, sp_a8, sp_e8); + sp_e8[0][3] = sp_e8[1][3] = sp_e8[2][3] = 0.0f; + mtx = &sp_e8; break; - case 10: - tex_mtx_info = &tex_mtx->getTexMtxInfo(); - unk = (tex_gen_src & 0x80) >> 7; - if (unk == 0) { - J3DGetTextureMtx(tex_mtx_info->mSRT, tex_mtx_info->mCenter, tmp0); - } else if (unk == 1) { - J3DGetTextureMtxMaya(tex_mtx_info->mSRT, tmp0); + } + case 11: { + J3DTexMtxInfo* tex_mtx_info_2 = &tex_mtx_2->getTexMtxInfo(); // sp_40 + u32 sp_3c = (u32)(tex_mtx_info_2->mInfo & 0x80) >> 7; + if (sp_3c == 0) { + J3DGetTextureMtx(tex_mtx_info_2->mSRT, tex_mtx_info_2->mCenter, sp_68); + } else if (sp_3c == 1) { + J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68); } - PSMTXConcat(tmp0, qMtx, tmp0); - eff_mtx = &tex_mtx_obj->getEffectMtx(i); - J3DMtxProjConcat(tmp0, *eff_mtx, tmp2); - PSMTXInverse(j3dSys.mViewMtx, tmp1); - PSMTXConcat(tmp2, tmp1, tmp2); - tmp2[2][3] = 0.0f; - tmp2[1][3] = 0.0f; - tmp2[0][3] = 0.0f; - mtx = &tmp2; + MTXConcat(sp_68, qMtx, sp_68); + J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8); + MTXInverse(j3dSys.getViewMtx(), sp_a8); + MTXConcat(sp_e8, sp_a8, sp_e8); + sp_e8[0][3] = sp_e8[1][3] = sp_e8[2][3] = 0.0f; + mtx = &sp_e8; break; - case 11: - tex_mtx_info = &tex_mtx->getTexMtxInfo(); - unk = (tex_gen_src & 0x80) >> 7; - if (unk == 0) { - J3DGetTextureMtx(tex_mtx_info->mSRT, tex_mtx_info->mCenter, tmp0); - } else if (unk == 1) { - J3DGetTextureMtxMaya(tex_mtx_info->mSRT, tmp0); + } + case 10: { + J3DTexMtxInfo* tex_mtx_info_2 = &tex_mtx_2->getTexMtxInfo(); // sp_38 + u32 sp_34 = (u32)(tex_mtx_info_2->mInfo & 0x80) >> 7; + if (sp_34 == 0) { + J3DGetTextureMtx(tex_mtx_info_2->mSRT, tex_mtx_info_2->mCenter, sp_68); + } else if (sp_34 == 1) { + J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68); } - PSMTXConcat(tmp0, qMtx2, tmp0); - eff_mtx = &tex_mtx_obj->getEffectMtx(i); - J3DMtxProjConcat(tmp0, *eff_mtx, tmp2); - PSMTXInverse(j3dSys.mViewMtx, tmp1); - PSMTXConcat(tmp2, tmp1, tmp2); - tmp2[2][3] = 0.0f; - tmp2[1][3] = 0.0f; - tmp2[0][3] = 0.0f; - mtx = &tmp2; - break; - default: - Mtx& tmp7 = tex_mtx_obj->getMtx(i); - mtx = &tmp7; + MTXConcat(sp_68, qMtx2, sp_68); + J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8); + MTXInverse(j3dSys.getViewMtx(), sp_a8); + MTXConcat(sp_e8, sp_a8, sp_e8); + sp_e8[0][3] = sp_e8[1][3] = sp_e8[2][3] = 0.0f; + mtx = &sp_e8; break; } + case 0: + case 4: + default: { + mtx = &tex_mtx_obj->getMtx(i); + } + } GXLoadTexMtxImm(*mtx, i * 3 + 0x40, GX_MTX3x4); } } } else { - for (u16 i = 0; i < (u16)tex_mtx_num; i++) { + for (u16 i = 0; i < tex_mtx_num; i++) { int tex_gen_type = tex_gen_block->getTexCoord(i)->getTexGenType(); if (tex_gen_type == 1 || tex_gen_type == 0) { - tex_mtx = tex_gen_block->getTexMtx(i); - u8 tex_gen_src = tex_mtx->getTexMtxInfo().mInfo; - u32 unk; - switch (tex_gen_src & 0x3f) { + J3DTexMtx* tex_mtx = tex_gen_block->getTexMtx(i); // sp_2c + JUT_ASSERT_MSG(0x145, tex_mtx != NULL, "Error : null pointer"); + 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: case 9: - PSMTXConcat(tex_mtx_obj->getMtx(i), param_0, tmp2); - mtx = &tmp2; + MTXConcat(tex_mtx_obj->getMtx(i), param_0, sp_e8); + mtx = &sp_e8; break; case 1: case 6: case 7: - PSMTXCopy(param_0, tmp1); - tmp1[2][3] = 0.0f; - tmp1[1][3] = 0.0f; - tmp1[0][3] = 0.0f; - PSMTXConcat(tex_mtx_obj->getMtx(i), tmp1, tmp2); - mtx = &tmp2; + MTXCopy(param_0, sp_a8); + sp_a8[0][3] = sp_a8[1][3] = sp_a8[2][3] = 0.0f; + MTXConcat(tex_mtx_obj->getMtx(i), sp_a8, sp_e8); + mtx = &sp_e8; break; case 2: case 8: mtx = &tex_mtx_obj->getMtx(i); break; - case 5: - tex_mtx_info = &tex_mtx->getTexMtxInfo(); - unk = (tex_gen_src & 0x80) >> 7; - if (unk == 0) { - J3DGetTextureMtxOld(tex_mtx_info->mSRT, tex_mtx_info->mCenter, tmp0); - } else if (unk == 1) { - J3DGetTextureMtxMayaOld(tex_mtx_info->mSRT, tmp0); + case 5: { + J3DTexMtxInfo* tex_mtx_info_2 = &tex_mtx->getTexMtxInfo(); // sp_24 + u32 sp_24 = (u32)(tex_mtx_info_2->mInfo & 0x80) >> 7; + if (sp_24 == 0) { + J3DGetTextureMtxOld(tex_mtx_info_2->mSRT, tex_mtx_info_2->mCenter, sp_68); + } else if (sp_24 == 1) { + J3DGetTextureMtxMayaOld(tex_mtx_info_2->mSRT, sp_68); } - eff_mtx = &tex_mtx_obj->getEffectMtx(i); - J3DMtxProjConcat(tmp0, *eff_mtx, tmp2); - PSMTXInverse(j3dSys.mViewMtx, tmp1); - PSMTXConcat(tmp2, tmp1, tmp2); - PSMTXConcat(tmp2, param_0, tmp2); - tmp2[2][3] = 0.0f; - tmp2[1][3] = 0.0f; - tmp2[0][3] = 0.0f; - mtx = &tmp2; + J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8); + MTXInverse(j3dSys.getViewMtx(), sp_a8); + MTXConcat(sp_e8, sp_a8, sp_e8); + MTXConcat(sp_e8, param_0, sp_e8); + sp_e8[0][3] = sp_e8[1][3] = sp_e8[2][3] = 0.0f; + mtx = &sp_e8; break; - case 10: - tex_mtx_info = &tex_mtx->getTexMtxInfo(); - unk = (tex_gen_src & 0x80) >> 7; - if (unk == 0) { - J3DGetTextureMtx(tex_mtx_info->mSRT, tex_mtx_info->mCenter, tmp0); - } else if (unk == 1) { - J3DGetTextureMtxMaya(tex_mtx_info->mSRT, tmp0); + } + case 11: { + J3DTexMtxInfo* tex_mtx_info_2 = &tex_mtx->getTexMtxInfo(); // sp_1c + u32 sp_18 = (u32)(tex_mtx_info_2->mInfo & 0x80) >> 7; + if (sp_18 == 0) { + J3DGetTextureMtx(tex_mtx_info_2->mSRT, tex_mtx_info_2->mCenter, sp_68); + } else if (sp_18 == 1) { + J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68); } - PSMTXConcat(tmp0, qMtx, tmp0); - eff_mtx = &tex_mtx_obj->getEffectMtx(i); - J3DMtxProjConcat(tmp0, *eff_mtx, tmp2); - PSMTXInverse(j3dSys.mViewMtx, tmp1); - PSMTXConcat(tmp2, tmp1, tmp2); - PSMTXConcat(tmp2, param_0, tmp2); - tmp2[2][3] = 0.0f; - tmp2[1][3] = 0.0f; - tmp2[0][3] = 0.0f; - mtx = &tmp2; + MTXConcat(sp_68, qMtx, sp_68); + J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8); + MTXInverse(j3dSys.getViewMtx(), sp_a8); + MTXConcat(sp_e8, sp_a8, sp_e8); + MTXConcat(sp_e8, param_0, sp_e8); + sp_e8[0][3] = sp_e8[1][3] = sp_e8[2][3] = 0.0f; + mtx = &sp_e8; break; - case 11: - tex_mtx_info = &tex_mtx->getTexMtxInfo(); - unk = (tex_gen_src & 0x80) >> 7; - if (unk == 0) { - J3DGetTextureMtx(tex_mtx_info->mSRT, tex_mtx_info->mCenter, tmp0); - } else if (unk == 1) { - J3DGetTextureMtxMaya(tex_mtx_info->mSRT, tmp0); + } + case 10: { + J3DTexMtxInfo* tex_mtx_info_2 = &tex_mtx->getTexMtxInfo(); // sp_14 + u32 sp_10 = (u32)(tex_mtx_info_2->mInfo & 0x80) >> 7; + if (sp_10 == 0) { + J3DGetTextureMtx(tex_mtx_info_2->mSRT, tex_mtx_info_2->mCenter, sp_68); + } else if (sp_10 == 1) { + J3DGetTextureMtxMaya(tex_mtx_info_2->mSRT, sp_68); } - PSMTXConcat(tmp0, qMtx2, tmp0); - eff_mtx = &tex_mtx_obj->getEffectMtx(i); - J3DMtxProjConcat(tmp0, *eff_mtx, tmp2); - PSMTXInverse(j3dSys.mViewMtx, tmp1); - PSMTXConcat(tmp2, tmp1, tmp2); - PSMTXConcat(tmp2, param_0, tmp2); - tmp2[2][3] = 0.0f; - tmp2[1][3] = 0.0f; - tmp2[0][3] = 0.0f; - mtx = &tmp2; + MTXConcat(sp_68, qMtx2, sp_68); + J3DMtxProjConcat(sp_68, tex_mtx_obj->getEffectMtx(i), sp_e8); + MTXInverse(j3dSys.getViewMtx(), sp_a8); + MTXConcat(sp_e8, sp_a8, sp_e8); + MTXConcat(sp_e8, param_0, sp_e8); + sp_e8[2][3] = 0.0f; + sp_e8[1][3] = 0.0f; + sp_e8[0][3] = 0.0f; + mtx = &sp_e8; break; - default: + } + case 0: + case 4: + default: { mtx = &tex_mtx_obj->getMtx(i); break; } - GXLoadTexMtxImm(*mtx, i * 3 + 0x1e, - (GXTexMtxType)tex_mtx->getTexMtxInfo().mProjection); + } + GXLoadTexMtxImm(*mtx, i * 3 + 30, + (GXTexMtxType)tex_mtx_info_1->mProjection); } } } diff --git a/src/JSystem/J3DGraphBase/J3DTexture.cpp b/src/JSystem/J3DGraphBase/J3DTexture.cpp index 0eb87b63e5..e4ff174899 100644 --- a/src/JSystem/J3DGraphBase/J3DTexture.cpp +++ b/src/JSystem/J3DGraphBase/J3DTexture.cpp @@ -4,10 +4,14 @@ // #include "JSystem/J3DGraphBase/J3DTexture.h" + #include "dolphin/gx.h" +#include "global.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."); + ResTIMG* timg = getResTIMG(idx); GXTexObj texObj; @@ -37,8 +41,11 @@ void J3DTexture::loadGX(u16 idx, GXTexMapID texMapID) const { /* 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."); + mNum = num; mpRes = new ResTIMG[num](); + J3D_ASSERT(83, mpRes != 0, "Error : allocate memory."); for (s32 i = 0; i < mNum; i++) { mpRes[i].paletteOffset = 0; @@ -51,20 +58,18 @@ void J3DTexture::addResTIMG(u16 newNum, ResTIMG const* newRes) { if (newNum == 0) return; + J3D_ASSERT(105, newRes != 0, "Error : null pointer."); + u16 oldNum = mNum; ResTIMG* oldRes = mpRes; entryNum(mNum + newNum); for (u16 i = 0; i < oldNum; i++) { - mpRes[i] = oldRes[i]; - mpRes[i].imageOffset = (u32)(&oldRes[i]) + mpRes[i].imageOffset - (u32)(&mpRes[i]); - mpRes[i].paletteOffset = (u32)(&oldRes[i]) + mpRes[i].paletteOffset - (u32)(&mpRes[i]); + setResTIMG(i, oldRes[i]); } for (u16 i = oldNum; i < mNum; i++) { - mpRes[i] = newRes[i]; - mpRes[i].imageOffset = (u32)(&newRes[i]) + mpRes[i].imageOffset - (u32)(&mpRes[i]); - mpRes[i].paletteOffset = (u32)(&newRes[i]) + mpRes[i].paletteOffset - (u32)(&mpRes[i]); + setResTIMG(i, newRes[i]); } -}
\ No newline at end of file +} |
