mirror of
https://github.com/zeldaret/ss
synced 2026-07-09 06:13:17 -04:00
AnalizeDL mostly OK
This commit is contained in:
@@ -2179,6 +2179,8 @@ egg/gfx/eggTexture.cpp:
|
||||
|
||||
egg/gfx/eggAnalizeDL.cpp:
|
||||
.text start:0x8049CFF0 end:0x8049D7C0
|
||||
.data start:0x8056ED60 end:0x8056ED70
|
||||
.sdata2 start:0x8057F3E0 end:0x8057F408
|
||||
|
||||
egg/gfx/eggCapTexture.cpp:
|
||||
.text start:0x8049D7C0 end:0x8049D9C4
|
||||
|
||||
@@ -26425,9 +26425,9 @@ initTexObj__Q23EGG7TextureF7_GXTlut = .text:0x8049CE90; // type:function size:0x
|
||||
load__Q23EGG7TextureF11_GXTexMapID = .text:0x8049CF90; // type:function size:0x54
|
||||
__ct__Q23EGG9AnalizeDLFQ34nw4r3g3d6ResShp = .text:0x8049CFF0; // type:function size:0x12C
|
||||
step__Q23EGG9AnalizeDLFv = .text:0x8049D120; // type:function size:0x590
|
||||
FUN_8049d6b0 = .text:0x8049D6B0; // type:function size:0xB8
|
||||
init__Q23EGG9AnalizeDLFv = .text:0x8049D6B0; // type:function size:0xB8
|
||||
getVtxResult__Q23EGG9AnalizeDLCFv = .text:0x8049D770; // type:function size:0x8
|
||||
FUN_8049d780 = .text:0x8049D780; // type:function size:0x40
|
||||
__dt__Q23EGG9AnalizeDLFv = .text:0x8049D780; // type:function size:0x40
|
||||
configure__Q23EGG10CapTextureFv = .text:0x8049D7C0; // type:function size:0x7C
|
||||
capture__Q23EGG10CapTextureFUsUsbi = .text:0x8049D840; // type:function size:0x184
|
||||
FUN_8049d9d0 = .text:0x8049D9D0; // type:function size:0x58
|
||||
@@ -37354,7 +37354,7 @@ __vt__Q23EGG14CoreController = .data:0x8056EC50; // type:object size:0x38
|
||||
@3881 = .data:0x8056ECF0; // type:object size:0x10 scope:local data:string
|
||||
__vt__Q23EGG11OrthoCamera = .data:0x8056ED00; // type:object size:0x30
|
||||
__vt__Q23EGG12LookAtCamera = .data:0x8056ED30; // type:object size:0x30
|
||||
lbl_8056ED60 = .data:0x8056ED60; // type:object size:0x10
|
||||
__vt__Q23EGG9AnalizeDL = .data:0x8056ED60; // type:object size:0xC
|
||||
__vt__Q23EGG10CapTexture = .data:0x8056ED70; // type:object size:0x10
|
||||
__vt__Q23EGG10CpuTexture = .data:0x8056ED80; // type:object size:0x10
|
||||
DummyTexureData = .data:0x8056EDA0; // type:object size:0x40
|
||||
|
||||
+1
-1
@@ -868,7 +868,7 @@ config.libs = [
|
||||
Object(Matching, "egg/gfx/eggCamera.cpp"),
|
||||
Object(Matching, "egg/gfx/eggPalette.cpp"),
|
||||
Object(Matching, "egg/gfx/eggTexture.cpp"),
|
||||
Object(NonMatching, "egg/gfx/eggUnk1.cpp"), # Unknown
|
||||
Object(NonMatching, "egg/gfx/eggAnalizeDL.cpp"),
|
||||
Object(Matching, "egg/gfx/eggCapTexture.cpp"),
|
||||
Object(NonMatching, "egg/gfx/eggCpuTexture.cpp"),
|
||||
Object(NonMatching, "egg/gfx/eggDrawGX.cpp"),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define EGG_ANALIZE_DL_H
|
||||
|
||||
#include "nw4r/g3d/res/g3d_resshp.h"
|
||||
#include "rvl/GX/GXAttr.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
@@ -9,19 +10,42 @@ class AnalizeDL {
|
||||
public:
|
||||
enum Status {
|
||||
STATUS_NONE,
|
||||
|
||||
STATUS_1,
|
||||
STATUS_2,
|
||||
STATUS_3,
|
||||
STATUS_VTX = 4,
|
||||
STATUS_ERROR = 6,
|
||||
STATUS_5,
|
||||
STATUS_END = 6,
|
||||
};
|
||||
|
||||
struct VtxResult {
|
||||
/* 0x00 */ s32 mMtxIdx;
|
||||
/* 0x04 */ u8 _0x04[4];
|
||||
/* 0x04 */ s32 field_0x04;
|
||||
/* 0x08 */ Vec field_0x08;
|
||||
};
|
||||
|
||||
private:
|
||||
u8 _0x000[0x1E4 - 0x000];
|
||||
/* 0x000 */ u8 *mpData;
|
||||
/* 0x004 */ u32 mBufSize;
|
||||
/* 0x008 */ u32 mCursor;
|
||||
/* 0x00C */ u8 field_0x00C;
|
||||
/* 0x00D */ u8 field_0x00D;
|
||||
/* 0x00E */ u8 field_0x00E;
|
||||
/* 0x00F */ u8 field_0x00F;
|
||||
/* 0x010 */ u16 field_0x010;
|
||||
/* 0x014 */ GXVtxDescList mVtxDescList[22];
|
||||
/* 0x0C4 */ GXVtxAttrFmtList mAttrFmtList[13];
|
||||
/* 0x194 */ u8 mArrStride;
|
||||
/* 0x198 */ const void *mpArr;
|
||||
/* 0x19C */ Status mStatus;
|
||||
/* 0x1A0 */ s16 field_0x1A0[10];
|
||||
/* 0x1B4 */ s16 field_0x1B4[10];
|
||||
/* 0x1C8 */ u8 field_0x1C8;
|
||||
/* 0x1CA */ u16 field_0x1CA;
|
||||
/* 0x1CC */ u16 field_0x1CC;
|
||||
/* 0x1D0 */ VtxResult mVtxResult;
|
||||
|
||||
void init();
|
||||
|
||||
public:
|
||||
AnalizeDL(nw4r::g3d::ResShp shp);
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
#include "egg/gfx/eggAnalizeDL.h"
|
||||
|
||||
#include "nw4r/g3d/res/g3d_resshp.h"
|
||||
#include "nw4r/g3d/res/g3d_resvtx.h"
|
||||
|
||||
namespace EGG {
|
||||
|
||||
AnalizeDL::AnalizeDL(nw4r::g3d::ResShp shp) {
|
||||
mpData = shp.GetPrimDLTag().GetDL();
|
||||
mBufSize = shp.GetPrimDLTag().GetBufSize();
|
||||
mCursor = 0;
|
||||
field_0x00C = 0;
|
||||
shp.GXGetVtxDescv(mVtxDescList);
|
||||
shp.GXGetVtxAttrFmtv(mAttrFmtList);
|
||||
field_0x00E = 0;
|
||||
field_0x00F = 0;
|
||||
field_0x010 = 0;
|
||||
|
||||
init();
|
||||
nw4r::g3d::ResVtxPos pos = shp.GetResVtxPos();
|
||||
pos.GetArray(&mpArr, &mArrStride);
|
||||
mStatus = STATUS_NONE;
|
||||
field_0x1CC = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
field_0x1A0[i] = -1;
|
||||
field_0x1B4[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
AnalizeDL::Status AnalizeDL::step() {
|
||||
if (mBufSize <= mCursor) {
|
||||
mStatus = STATUS_END;
|
||||
} else if (field_0x1CC == 0) {
|
||||
u8 *pCommand = &mpData[mCursor];
|
||||
u8 command = pCommand[0];
|
||||
switch (command) {
|
||||
case 0x20:
|
||||
field_0x1A0[pCommand[4] / 12] = pCommand[2];
|
||||
mStatus = STATUS_1;
|
||||
mCursor += 5;
|
||||
break;
|
||||
case 0x28:
|
||||
field_0x1B4[pCommand[4] / 9] = pCommand[2];
|
||||
mStatus = STATUS_2;
|
||||
mCursor += 5;
|
||||
break;
|
||||
case 0x30: mCursor += 5; break;
|
||||
case 0x90:
|
||||
case 0xA8:
|
||||
case 0xB8:
|
||||
case 0xB0:
|
||||
case 0xA0:
|
||||
case 0x98:
|
||||
case 0x80:
|
||||
field_0x1C8 = command;
|
||||
field_0x1CA = *reinterpret_cast<const u16*>(pCommand + 1);
|
||||
field_0x1CC = field_0x1CA;
|
||||
mStatus = STATUS_3;
|
||||
mCursor += 3;
|
||||
break;
|
||||
case 0x0: mCursor += 1; break;
|
||||
default: mCursor += 1; break;
|
||||
}
|
||||
} else {
|
||||
u8 *pCommand = &mpData[mCursor];
|
||||
if ((field_0x010 & 1) != 0) {
|
||||
mVtxResult.mMtxIdx = field_0x1A0[*(pCommand++) / 3];
|
||||
} else {
|
||||
mVtxResult.mMtxIdx = -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if ((field_0x010 & (1 << (i + 1))) != 0) {
|
||||
pCommand++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((field_0x010 & 0x200) != 0) {
|
||||
if (field_0x00F == 1) {
|
||||
mVtxResult.field_0x04 = *pCommand;
|
||||
} else {
|
||||
mVtxResult.field_0x04 = *reinterpret_cast<const u16 *>(pCommand);
|
||||
}
|
||||
|
||||
GXCompType compType = mAttrFmtList[0].compType;
|
||||
u8 shift = mAttrFmtList[0].shift;
|
||||
// REGSWAP
|
||||
const void *pData = reinterpret_cast<const u8 *>(mpArr) + (mArrStride * mVtxResult.field_0x04);
|
||||
switch (compType) {
|
||||
case GX_U8: {
|
||||
int val = 1 << shift;
|
||||
const u8 *dat = reinterpret_cast<const u8 *>(pData);
|
||||
mVtxResult.field_0x08.x = dat[0] / (f32)val;
|
||||
mVtxResult.field_0x08.y = dat[1] / (f32)val;
|
||||
mVtxResult.field_0x08.z = dat[2] / (f32)val;
|
||||
break;
|
||||
}
|
||||
case GX_S8: {
|
||||
int val = 1 << shift;
|
||||
const s8 *dat = reinterpret_cast<const s8 *>(pData);
|
||||
mVtxResult.field_0x08.x = dat[0] / (f32)val;
|
||||
mVtxResult.field_0x08.y = dat[1] / (f32)val;
|
||||
mVtxResult.field_0x08.z = dat[2] / (f32)val;
|
||||
break;
|
||||
}
|
||||
case GX_U16: {
|
||||
int val = 1 << shift;
|
||||
const u16 *dat = reinterpret_cast<const u16 *>(pData);
|
||||
mVtxResult.field_0x08.x = dat[0] / (f32)val;
|
||||
mVtxResult.field_0x08.y = dat[1] / (f32)val;
|
||||
mVtxResult.field_0x08.z = dat[2] / (f32)val;
|
||||
break;
|
||||
}
|
||||
case GX_S16: {
|
||||
int val = 1 << shift;
|
||||
const s16 *dat = reinterpret_cast<const s16 *>(pData);
|
||||
mVtxResult.field_0x08.x = dat[0] / (f32)val;
|
||||
mVtxResult.field_0x08.y = dat[1] / (f32)val;
|
||||
mVtxResult.field_0x08.z = dat[2] / (f32)val;
|
||||
break;
|
||||
}
|
||||
case GX_F32: {
|
||||
const f32 *dat = reinterpret_cast<const f32 *>(pData);
|
||||
mVtxResult.field_0x08.x = dat[0];
|
||||
mVtxResult.field_0x08.y = dat[1];
|
||||
mVtxResult.field_0x08.z = dat[2];
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
} else {
|
||||
mVtxResult.field_0x04 = -1;
|
||||
mVtxResult.field_0x08.z = 0.0f;
|
||||
mVtxResult.field_0x08.y = 0.0f;
|
||||
mVtxResult.field_0x08.x = 0.0f;
|
||||
}
|
||||
field_0x1CC -= 1;
|
||||
mStatus = STATUS_VTX;
|
||||
mCursor += field_0x00E;
|
||||
}
|
||||
|
||||
return mStatus;
|
||||
}
|
||||
|
||||
static const s8 sArr1[] = {0, -1, 1, 2};
|
||||
static const u8 sArr2[] = {1, 1, 2, 2, 4, 0};
|
||||
|
||||
void AnalizeDL::init() {
|
||||
// TODO
|
||||
int k = 0;
|
||||
const u8 *pArr2 = sArr2;
|
||||
const s8 *pArr1 = sArr1;
|
||||
|
||||
for (int i = 0; mVtxDescList[i].attr != GX_VA_NULL; i++) {
|
||||
int x = pArr1[mVtxDescList[i].type];
|
||||
pArr1++;
|
||||
if (x == -1) {
|
||||
if (k >= 0 && k <= 8) {
|
||||
x = 1;
|
||||
}
|
||||
} else {
|
||||
int j = 1;
|
||||
for (; k != mAttrFmtList[j].attr; j++) {}
|
||||
x = pArr2[mAttrFmtList[j - 1].compType];
|
||||
}
|
||||
|
||||
if (k == 9) {
|
||||
field_0x00F = x;
|
||||
}
|
||||
|
||||
field_0x00E += x;
|
||||
if (x != 0) {
|
||||
field_0x010 |= (1 << k);
|
||||
}
|
||||
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
const AnalizeDL::VtxResult &AnalizeDL::getVtxResult() const {
|
||||
return mVtxResult;
|
||||
}
|
||||
|
||||
} // namespace EGG
|
||||
@@ -72,7 +72,7 @@ void ModelEx::getShapeMinMax(u16 shapeIndex, math::VEC3 *pMin, math::VEC3 *pMax,
|
||||
|
||||
bool firstIteration = true;
|
||||
AnalizeDL::Status status;
|
||||
while ((status = analyze.step()) != AnalizeDL::STATUS_ERROR) {
|
||||
while ((status = analyze.step()) != AnalizeDL::STATUS_END) {
|
||||
if (status != AnalizeDL::STATUS_VTX) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user