1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 23:14:37 +00:00

En_Attack_Niw, En_Insect, z_skin_matrix, and z_skelanime matched (#493)

* Darkmeiro decompilation

Bg_Gnd_Darkmeiro decompiled, matched, and documented.

* give this a shot

* fix conflict

* one more try

* could be useful

* whoops

* ZAP2 stuff

* ZAP why

* ZAP again

* marginal improvement

* matched functions. Also fixed a serious lack of static

* format

* more static

* fixing a function prototype

* skelanime OK

* forgot .s

* skin matrix matched

* format
This commit is contained in:
petrie911 2020-11-23 20:34:32 -06:00 committed by GitHub
parent 89f89ac5ea
commit 3aa76152c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 209 additions and 1264 deletions

View file

@ -308,6 +308,7 @@ void EffectBlure_UpdateFlags(EffectBlureElement* elem) {
void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3s* vec1, Vec3s* vec2,
Color_RGBA8* color1, Color_RGBA8* color2) {
Vec3s sp30;
s32 pad;
EffectBlureElement* elem;
f32 mode4Param;
@ -333,14 +334,14 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3
break;
case 3:
ratio = ratio * 0.5f;
ratio /= 2.0f;
vec1->x = func_80027E34(elem->p1.x, elem->p2.x, ratio);
vec1->y = func_80027E34(elem->p1.y, elem->p2.y, ratio);
vec1->z = func_80027E34(elem->p1.z, elem->p2.z, ratio);
vec2->x = func_80027E34(elem->p2.x, elem->p1.x, ratio);
vec2->y = func_80027E34(elem->p2.y, elem->p1.y, ratio);
vec2->z = func_80027E34(elem->p2.z, elem->p1.z, ratio);
ratio = ratio + ratio;
ratio *= 2.0f;
break;
case 4:
@ -352,9 +353,9 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3
vec1->x = (sp30.x * 0.5f * (mode4Param - 1.0f) * ratio) + elem->p1.x;
vec1->y = (sp30.y * 0.5f * (mode4Param - 1.0f) * ratio) + elem->p1.y;
vec1->z = (sp30.z * 0.5f * (mode4Param - 1.0f) * ratio) + elem->p1.z;
vec2->x = -(sp30.x * 0.5f * (mode4Param - 1.0f) * ratio) + elem->p2.x;
vec2->y = -(sp30.y * 0.5f * (mode4Param - 1.0f) * ratio) + elem->p2.y;
vec2->z = -(sp30.z * 0.5f * (mode4Param - 1.0f) * ratio) + elem->p2.z;
vec2->x = elem->p2.x - (sp30.x * 0.5f * (mode4Param - 1.0f) * ratio);
vec2->y = elem->p2.y - (sp30.y * 0.5f * (mode4Param - 1.0f) * ratio);
vec2->z = elem->p2.z - (sp30.z * 0.5f * (mode4Param - 1.0f) * ratio);
break;
case 0:
@ -367,18 +368,10 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3
vec2->z = elem->p2.z;
break;
}
sp30 = sp30; // Optimized out but seems necessary to match stack usage
if (this->flags & 0x10) {
color1->a = 255;
color1->b = 255;
color1->g = 255;
color1->r = 255;
color2->r = 255;
color2->g = 255;
color2->b = 255;
color2->a = 255;
color1->r = color1->g = color1->b = color1->a = color2->r = color2->g = color2->b = color2->a = 255;
} else {
color1->r = func_80027E84(this->p1StartColor.r, this->p1EndColor.r, ratio);
color1->g = func_80027E84(this->p1StartColor.g, this->p1EndColor.g, ratio);

View file

@ -730,8 +730,6 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* limb
return gfx;
}
#ifdef NON_MATCHING
// Function is unused. This is functionally equivilent, misplace andi which caused regalloc
s32 func_800A29BC(s32 arg0, s32 arg1, Vec3s* arg2) {
s16* temp_t1;
s16* temp_a3;
@ -752,6 +750,8 @@ s32 func_800A29BC(s32 arg0, s32 arg1, Vec3s* arg2) {
arg2++;
temp_a3 += 6;
if (t & 1) {}
if (t > 0) {
if (t & 1) {
phi_v0++;
@ -781,9 +781,6 @@ s32 func_800A29BC(s32 arg0, s32 arg1, Vec3s* arg2) {
ret:
return t;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s")
#endif
s16 func_800A2DBC(GenericAnimationHeader* animationSeg) {
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);

View file

@ -238,75 +238,62 @@ void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest) {
* returns 0 if successfully inverted
* returns 2 if matrix non-invertible (0 determinant)
*/
#ifdef NON_MATCHING
// Saved register usage differences and probably regalloc
s32 SkinMatrix_Invert(MtxF* src, MtxF* dest) {
MtxF mfCopy;
s32 i;
s32 k;
f32 temp1;
s32 pad;
f32 temp2;
f32 diagElement;
f32 temp1;
s32 thisRow;
s32 thisCol;
u32 pad;
SkinMatrix_MtxFCopy(src, &mfCopy);
SkinMatrix_Clear(dest);
for (thisRow = 0; thisRow != 4; thisRow++) {
for (thisCol = thisRow; (thisCol < 4) && (fabsf(mfCopy.mf[thisRow][thisCol]) < 0.0005f); thisCol++) {}
for (thisRow = 0; thisRow < 4; thisRow++) {
thisCol = thisRow;
while ((thisCol < 4) && (fabsf(mfCopy.mf[thisRow][thisCol]) < 0.0005f)) {
thisCol++;
}
if (thisCol == 4) {
// reaching col = 4 means the row is either all 0 or a duplicate row.
// therefore singular matrix (0 determinant).
osSyncPrintf(VT_COL(YELLOW, BLACK));
osSyncPrintf("Skin_Matrix_InverseMatrix():逆行列つくれません\n");
osSyncPrintf(VT_RST);
return 2;
}
if (thisCol != thisRow) { // responsible for swapping columns if zero on diagonal
for (i = 0; i != 4; i++) {
for (i = 0; i < 4; i++) {
temp1 = mfCopy.mf[i][thisCol];
mfCopy.mf[i][thisCol] = mfCopy.mf[i][thisRow];
mfCopy.mf[i][thisRow] = temp1;
temp1 = dest->mf[i][thisCol];
temp2 = dest->mf[i][thisCol];
dest->mf[i][thisCol] = dest->mf[i][thisRow];
dest->mf[i][thisRow] = temp1;
dest->mf[i][thisRow] = temp2;
}
}
diagElement = mfCopy.mf[thisRow][thisRow];
// Scale this whole column s.t. the diag element = 1
mfCopy.mf[0][thisRow] = mfCopy.mf[0][thisRow] / diagElement;
dest->mf[0][thisRow] = dest->mf[0][thisRow] / diagElement;
mfCopy.mf[1][thisRow] = mfCopy.mf[1][thisRow] / diagElement;
dest->mf[1][thisRow] = dest->mf[1][thisRow] / diagElement;
mfCopy.mf[2][thisRow] = mfCopy.mf[2][thisRow] / diagElement;
dest->mf[2][thisRow] = dest->mf[2][thisRow] / diagElement;
mfCopy.mf[3][thisRow] = mfCopy.mf[3][thisRow] / diagElement;
dest->mf[3][thisRow] = dest->mf[3][thisRow] / diagElement;
temp1 = mfCopy.mf[thisRow][thisRow];
for (i = 0; i < 4; i++) {
mfCopy.mf[i][thisRow] /= temp1;
dest->mf[i][thisRow] /= temp1;
}
// col i = col i - a * col j
for (k = 0; k != 4; k++) {
if (k != thisRow) {
temp2 = mfCopy.mf[thisRow][k];
mfCopy.mf[0][k] = mfCopy.mf[0][k] - (mfCopy.mf[0][thisRow] * temp2);
dest->mf[0][k] = dest->mf[0][k] - (dest->mf[0][thisRow] * temp2);
mfCopy.mf[1][k] = mfCopy.mf[1][k] - (mfCopy.mf[1][thisRow] * temp2);
dest->mf[1][k] = dest->mf[1][k] - (dest->mf[1][thisRow] * temp2);
mfCopy.mf[2][k] = mfCopy.mf[2][k] - (mfCopy.mf[2][thisRow] * temp2);
dest->mf[2][k] = dest->mf[2][k] - (dest->mf[2][thisRow] * temp2);
mfCopy.mf[3][k] = mfCopy.mf[3][k] - (mfCopy.mf[3][thisRow] * temp2);
dest->mf[3][k] = dest->mf[3][k] - (dest->mf[3][thisRow] * temp2);
for (thisCol = 0; thisCol < 4; thisCol++) {
if (thisCol != thisRow) {
temp1 = mfCopy.mf[thisRow][thisCol];
for (i = 0; i < 4; i++) {
mfCopy.mf[i][thisCol] -= mfCopy.mf[i][thisRow] * temp1;
dest->mf[i][thisCol] -= dest->mf[i][thisRow] * temp1;
}
}
}
}
return 0;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_matrix/SkinMatrix_Invert.s")
#endif
/**
* Produces a matrix which scales x,y,z components of vectors or x,y,z rows of matrices (when applied on LHS)
@ -620,63 +607,47 @@ Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src) {
}
/**
* Produces a matrix which rotates vectors by angle a around the vector with components (x,y,z)
* Produces a matrix which rotates vectors by angle a around a unit vector with components (x,y,z)
*/
#ifdef NON_EQUIVALENT
// I think this is functionally correct but I cannot be 100% sure of equivalence because diff output is not very close
void func_800A7EC0(MtxF* mf, s16 a, f32 x, f32 y, f32 z) {
f32 sin;
f32 cos;
f32 ct;
f32 sinA;
f32 cosA;
f32 xx;
f32 yy;
f32 zz;
f32 xy;
f32 xz;
f32 yz;
f32 sx;
f32 sy;
f32 sz;
f32 xz;
f32 pad;
sin = Math_Sins(a);
cos = Math_Coss(a);
ct = 1.0f - cos;
sx = sin * x;
sy = sin * y;
sz = sin * z;
sinA = Math_Sins(a);
cosA = Math_Coss(a);
xx = x * x;
xy = x * y;
xz = x * z;
yy = y * y;
yz = y * z;
zz = z * z;
xy = x * y;
yz = y * z;
xz = x * z;
mf->xx = (f32)ct * xx + cos;
mf->xy = (f32)((ct * xy) + sz);
mf->xz = (f32)((ct * xz) - sy);
mf->xx = (1.0f - xx) * cosA + xx;
mf->xy = (1.0f - cosA) * xy + z * sinA;
mf->xz = (1.0f - cosA) * xz - y * sinA;
mf->xw = 0.0f;
mf->yx = (f32)((ct * (xy)) - sz);
mf->yy = (f32)ct * yy + cos;
mf->yz = (f32)((ct * (yz)) + sx);
mf->yx = (1.0f - cosA) * xy - z * sinA;
mf->yy = (1.0f - yy) * cosA + yy;
mf->yz = (1.0f - cosA) * yz + x * sinA;
mf->yw = 0.0f;
mf->zx = (f32)((ct * (xz)) + sy);
mf->zy = (f32)((ct * (yz)) - sx);
mf->zz = (f32)ct * zz + cos;
mf->zx = (1.0f - cosA) * xz + y * sinA;
mf->zy = (1.0f - cosA) * yz - x * sinA;
mf->zz = (1.0f - zz) * cosA + zz;
mf->zw = 0.0f;
mf->wx = 0.0f;
mf->wy = 0.0f;
mf->wz = 0.0f;
mf->wx = mf->wy = mf->wz = 0.0f;
mf->ww = 1.0f;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_matrix/func_800A7EC0.s")
#endif
void func_800A8030(MtxF* mf, f32* arg1) {
f32 n;