1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-02 15:55:59 +00:00
oot/src/code/sys_matrix.c

1085 lines
27 KiB
C
Raw Normal View History

#include "global.h"
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
// clang-format off
Mtx gMtxClear = {
2020-03-17 04:31:30 +00:00
65536, 0, 1, 0,
0, 65536, 0, 1,
0, 0, 0, 0,
0, 0, 0, 0,
};
MtxF gMtxFClear = {
2020-03-17 04:31:30 +00:00
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
};
2020-03-22 21:19:43 +00:00
// clang-format on
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
MtxF* sMatrixStack; // "Matrix_stack"
2020-03-17 04:31:30 +00:00
MtxF* sCurrentMatrix; // "Matrix_now"
void Matrix_Init(GameState* gameState) {
sCurrentMatrix = GameState_Alloc(gameState, 20 * sizeof(MtxF), "../sys_matrix.c", 153);
2020-03-17 04:31:30 +00:00
sMatrixStack = sCurrentMatrix;
}
void Matrix_Push(void) {
2020-03-17 04:31:30 +00:00
Matrix_MtxFCopy(sCurrentMatrix + 1, sCurrentMatrix);
sCurrentMatrix++;
}
void Matrix_Pull(void) {
2020-03-17 04:31:30 +00:00
sCurrentMatrix--;
if (sCurrentMatrix < sMatrixStack) {
2020-03-17 04:31:30 +00:00
__assert("Matrix_now >= Matrix_stack", "../sys_matrix.c", 176);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
void Matrix_Get(MtxF* dest) {
2020-03-17 04:31:30 +00:00
Matrix_MtxFCopy(dest, sCurrentMatrix);
}
void Matrix_Put(MtxF* src) {
2020-03-17 04:31:30 +00:00
Matrix_MtxFCopy(sCurrentMatrix, src);
}
MtxF* Matrix_GetCurrent(void) {
2020-03-17 04:31:30 +00:00
return sCurrentMatrix;
}
void Matrix_Mult(MtxF* mf, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = Matrix_GetCurrent();
if (mode == MTXMODE_APPLY) {
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
SkinMatrix_MtxFMtxFMult(cmf, mf, cmf);
} else {
2020-03-17 04:31:30 +00:00
Matrix_MtxFCopy(sCurrentMatrix, mf);
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = sCurrentMatrix;
f32 tx;
f32 ty;
if (mode == MTXMODE_APPLY) {
tx = cmf->xx;
ty = cmf->yx;
cmf->wx += tx * x + ty * y + cmf->zx * z;
tx = cmf->xy;
ty = cmf->yy;
cmf->wy += tx * x + ty * y + cmf->zy * z;
tx = cmf->xz;
ty = cmf->yz;
cmf->wz += tx * x + ty * y + cmf->zz * z;
tx = cmf->xw;
ty = cmf->yw;
cmf->ww += tx * x + ty * y + cmf->zw * z;
} else {
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
SkinMatrix_SetTranslate(cmf, x, y, z);
2020-03-17 04:31:30 +00:00
}
}
void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = sCurrentMatrix;
if (mode == MTXMODE_APPLY) {
2020-03-17 04:31:30 +00:00
cmf->xx *= x;
cmf->xy *= x;
cmf->xz *= x;
cmf->yx *= y;
cmf->yy *= y;
cmf->yz *= y;
cmf->zx *= z;
cmf->zy *= z;
cmf->zz *= z;
cmf->xw *= x;
cmf->yw *= y;
cmf->zw *= z;
} else {
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
SkinMatrix_SetScale(cmf, x, y, z);
2020-03-17 04:31:30 +00:00
}
}
void Matrix_RotateX(f32 x, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf;
f32 sin;
f32 cos;
f32 temp1;
f32 temp2;
if (mode == MTXMODE_APPLY) {
if (x != 0) {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
sin = sinf(x);
cos = cosf(x);
temp1 = cmf->yx;
temp2 = cmf->zx;
cmf->yx = temp1 * cos + temp2 * sin;
cmf->zx = temp2 * cos - temp1 * sin;
temp1 = cmf->yy;
temp2 = cmf->zy;
cmf->yy = temp1 * cos + temp2 * sin;
cmf->zy = temp2 * cos - temp1 * sin;
temp1 = cmf->yz;
temp2 = cmf->zz;
cmf->yz = temp1 * cos + temp2 * sin;
cmf->zz = temp2 * cos - temp1 * sin;
temp1 = cmf->yw;
temp2 = cmf->zw;
cmf->yw = temp1 * cos + temp2 * sin;
cmf->zw = temp2 * cos - temp1 * sin;
}
} else {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
if (x != 0) {
2020-03-17 04:31:30 +00:00
sin = sinf(x);
cos = cosf(x);
} else {
2020-03-17 04:31:30 +00:00
sin = 0.0f;
cos = 1.0f;
}
cmf->xy = 0.0f;
cmf->xz = 0.0f;
cmf->xw = 0.0f;
cmf->yx = 0.0f;
cmf->yw = 0.0f;
cmf->zx = 0.0f;
cmf->zw = 0.0f;
cmf->wx = 0.0f;
cmf->wy = 0.0f;
cmf->wz = 0.0f;
cmf->xx = 1.0f;
cmf->ww = 1.0f;
cmf->yy = cos;
cmf->zz = cos;
cmf->yz = sin;
cmf->zy = -sin;
}
}
void Matrix_RotateY(f32 y, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf;
f32 sin;
f32 cos;
f32 temp1;
f32 temp2;
if (mode == MTXMODE_APPLY) {
if (y != 0) {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
sin = sinf(y);
cos = cosf(y);
temp1 = cmf->xx;
temp2 = cmf->zx;
cmf->xx = temp1 * cos - temp2 * sin;
cmf->zx = temp1 * sin + temp2 * cos;
temp1 = cmf->xy;
temp2 = cmf->zy;
cmf->xy = temp1 * cos - temp2 * sin;
cmf->zy = temp1 * sin + temp2 * cos;
temp1 = cmf->xz;
temp2 = cmf->zz;
cmf->xz = temp1 * cos - temp2 * sin;
cmf->zz = temp1 * sin + temp2 * cos;
temp1 = cmf->xw;
temp2 = cmf->zw;
cmf->xw = temp1 * cos - temp2 * sin;
cmf->zw = temp1 * sin + temp2 * cos;
}
} else {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
if (y != 0) {
2020-03-17 04:31:30 +00:00
sin = sinf(y);
cos = cosf(y);
} else {
2020-03-17 04:31:30 +00:00
sin = 0.0f;
cos = 1.0f;
}
cmf->xy = 0.0f;
cmf->xw = 0.0f;
cmf->yx = 0.0f;
cmf->yz = 0.0f;
cmf->yw = 0.0f;
cmf->zy = 0.0f;
cmf->zw = 0.0f;
cmf->wx = 0.0f;
cmf->wy = 0.0f;
cmf->wz = 0.0f;
cmf->yy = 1.0f;
cmf->ww = 1.0f;
cmf->xx = cos;
cmf->zz = cos;
cmf->xz = -sin;
cmf->zx = sin;
}
}
void Matrix_RotateZ(f32 z, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf;
f32 sin;
f32 cos;
f32 temp1;
f32 temp2;
if (mode == MTXMODE_APPLY) {
if (z != 0) {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
sin = sinf(z);
cos = cosf(z);
temp1 = cmf->xx;
temp2 = cmf->yx;
cmf->xx = temp1 * cos + temp2 * sin;
cmf->yx = temp2 * cos - temp1 * sin;
temp1 = cmf->xy;
temp2 = cmf->yy;
cmf->xy = temp1 * cos + temp2 * sin;
cmf->yy = temp2 * cos - temp1 * sin;
temp1 = cmf->xz;
temp2 = cmf->yz;
cmf->xz = temp1 * cos + temp2 * sin;
cmf->yz = temp2 * cos - temp1 * sin;
temp1 = cmf->xw;
temp2 = cmf->yw;
cmf->xw = temp1 * cos + temp2 * sin;
cmf->yw = temp2 * cos - temp1 * sin;
}
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
2020-03-22 21:19:43 +00:00
if (z != 0) {
2020-03-17 04:31:30 +00:00
sin = sinf(z);
cos = cosf(z);
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
sin = 0.0f;
cos = 1.0f;
}
cmf->xz = 0.0f;
cmf->xw = 0.0f;
cmf->yz = 0.0f;
cmf->yw = 0.0f;
cmf->zx = 0.0f;
cmf->zy = 0.0f;
cmf->zw = 0.0f;
cmf->wx = 0.0f;
cmf->wy = 0.0f;
cmf->wz = 0.0f;
cmf->zz = 1.0f;
cmf->ww = 1.0f;
cmf->xx = cos;
cmf->yy = cos;
cmf->xy = sin;
cmf->yx = -sin;
}
}
/*
* Rotates the top of the matrix stack by `z` degrees, then
* rotates that matrix by `y` degrees, then rotates that matrix
2020-03-30 22:53:26 +00:00
* by `x` degrees. (roll-pitch-yaw)
* Original Name: Matrix_RotateXYZ, changed to reflect rotation order.
*/
void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = sCurrentMatrix;
f32 temp1;
f32 temp2;
f32 sin;
f32 cos;
2020-03-22 21:19:43 +00:00
if (mode == MTXMODE_APPLY) {
2020-03-17 04:31:30 +00:00
sin = Math_Sins(z);
cos = Math_Coss(z);
temp1 = cmf->xx;
temp2 = cmf->yx;
cmf->xx = temp1 * cos + temp2 * sin;
cmf->yx = temp2 * cos - temp1 * sin;
temp1 = cmf->xy;
temp2 = cmf->yy;
cmf->xy = temp1 * cos + temp2 * sin;
cmf->yy = temp2 * cos - temp1 * sin;
temp1 = cmf->xz;
temp2 = cmf->yz;
cmf->xz = temp1 * cos + temp2 * sin;
cmf->yz = temp2 * cos - temp1 * sin;
temp1 = cmf->xw;
temp2 = cmf->yw;
cmf->xw = temp1 * cos + temp2 * sin;
cmf->yw = temp2 * cos - temp1 * sin;
2020-03-22 21:19:43 +00:00
if (y != 0) {
2020-03-17 04:31:30 +00:00
sin = Math_Sins(y);
cos = Math_Coss(y);
temp1 = cmf->xx;
temp2 = cmf->zx;
cmf->xx = temp1 * cos - temp2 * sin;
cmf->zx = temp1 * sin + temp2 * cos;
temp1 = cmf->xy;
temp2 = cmf->zy;
cmf->xy = temp1 * cos - temp2 * sin;
cmf->zy = temp1 * sin + temp2 * cos;
temp1 = cmf->xz;
temp2 = cmf->zz;
cmf->xz = temp1 * cos - temp2 * sin;
cmf->zz = temp1 * sin + temp2 * cos;
temp1 = cmf->xw;
temp2 = cmf->zw;
cmf->xw = temp1 * cos - temp2 * sin;
cmf->zw = temp1 * sin + temp2 * cos;
}
2020-03-22 21:19:43 +00:00
if (x != 0) {
2020-03-17 04:31:30 +00:00
sin = Math_Sins(x);
cos = Math_Coss(x);
temp1 = cmf->yx;
temp2 = cmf->zx;
cmf->yx = temp1 * cos + temp2 * sin;
cmf->zx = temp2 * cos - temp1 * sin;
temp1 = cmf->yy;
temp2 = cmf->zy;
cmf->yy = temp1 * cos + temp2 * sin;
cmf->zy = temp2 * cos - temp1 * sin;
temp1 = cmf->yz;
temp2 = cmf->zz;
cmf->yz = temp1 * cos + temp2 * sin;
cmf->zz = temp2 * cos - temp1 * sin;
temp1 = cmf->yw;
temp2 = cmf->zw;
cmf->yw = temp1 * cos + temp2 * sin;
cmf->zw = temp2 * cos - temp1 * sin;
}
2020-03-22 21:19:43 +00:00
} else {
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
SkinMatrix_SetRotateRPY(cmf, x, y, z);
2020-03-17 04:31:30 +00:00
}
}
/*
* Roll-pitch-yaw rotation and position
*/
void Matrix_JointPosition(Vec3f* position, Vec3s* rotation) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = sCurrentMatrix;
f32 sin;
f32 cos;
f32 temp1;
f32 temp2;
sin = Math_Sins(rotation->z);
cos = Math_Coss(rotation->z);
2020-03-17 04:31:30 +00:00
temp1 = cmf->xx;
temp2 = cmf->yx;
cmf->wx += temp1 * position->x + temp2 * position->y + cmf->zx * position->z;
2020-03-17 04:31:30 +00:00
cmf->xx = temp1 * cos + temp2 * sin;
cmf->yx = temp2 * cos - temp1 * sin;
temp1 = cmf->xy;
temp2 = cmf->yy;
cmf->wy += temp1 * position->x + temp2 * position->y + cmf->zy * position->z;
2020-03-17 04:31:30 +00:00
cmf->xy = temp1 * cos + temp2 * sin;
cmf->yy = temp2 * cos - temp1 * sin;
temp1 = cmf->xz;
temp2 = cmf->yz;
cmf->wz += temp1 * position->x + temp2 * position->y + cmf->zz * position->z;
2020-03-17 04:31:30 +00:00
cmf->xz = temp1 * cos + temp2 * sin;
cmf->yz = temp2 * cos - temp1 * sin;
temp1 = cmf->xw;
temp2 = cmf->yw;
cmf->ww += temp1 * position->x + temp2 * position->y + cmf->zw * position->z;
2020-03-17 04:31:30 +00:00
cmf->xw = temp1 * cos + temp2 * sin;
cmf->yw = temp2 * cos - temp1 * sin;
if (rotation->y != 0) {
sin = Math_Sins(rotation->y);
cos = Math_Coss(rotation->y);
2020-03-17 04:31:30 +00:00
temp1 = cmf->xx;
temp2 = cmf->zx;
cmf->xx = temp1 * cos - temp2 * sin;
cmf->zx = temp1 * sin + temp2 * cos;
temp1 = cmf->xy;
temp2 = cmf->zy;
cmf->xy = temp1 * cos - temp2 * sin;
cmf->zy = temp1 * sin + temp2 * cos;
temp1 = cmf->xz;
temp2 = cmf->zz;
cmf->xz = temp1 * cos - temp2 * sin;
cmf->zz = temp1 * sin + temp2 * cos;
temp1 = cmf->xw;
temp2 = cmf->zw;
cmf->xw = temp1 * cos - temp2 * sin;
cmf->zw = temp1 * sin + temp2 * cos;
}
if (rotation->x != 0) {
sin = Math_Sins(rotation->x);
cos = Math_Coss(rotation->x);
2020-03-17 04:31:30 +00:00
temp1 = cmf->yx;
temp2 = cmf->zx;
cmf->yx = temp1 * cos + temp2 * sin;
cmf->zx = temp2 * cos - temp1 * sin;
temp1 = cmf->yy;
temp2 = cmf->zy;
cmf->yy = temp1 * cos + temp2 * sin;
cmf->zy = temp2 * cos - temp1 * sin;
temp1 = cmf->yz;
temp2 = cmf->zz;
cmf->yz = temp1 * cos + temp2 * sin;
cmf->zz = temp2 * cos - temp1 * sin;
temp1 = cmf->yw;
temp2 = cmf->zw;
cmf->yw = temp1 * cos + temp2 * sin;
cmf->zw = temp2 * cos - temp1 * sin;
}
}
#ifdef NON_MATCHING
// regalloc differences
2020-03-22 21:19:43 +00:00
void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = sCurrentMatrix;
f32 sp30;
f32 sp2C;
f32 sp28;
f32 sp24;
sp30 = Math_Sins(vec->y);
sp2C = Math_Coss(vec->y);
cmf->xx = sp2C;
cmf->xz = -sp30;
cmf->wx = x;
cmf->wy = y;
cmf->wz = z;
cmf->xw = 0.0f;
cmf->yw = 0.0f;
cmf->zw = 0.0f;
cmf->ww = 1.0f;
2020-03-22 21:19:43 +00:00
if (vec->x != 0) {
2020-03-17 04:31:30 +00:00
sp24 = Math_Sins(vec->x);
sp28 = Math_Coss(vec->x);
cmf->zy = -sp24;
cmf->yy = sp28;
cmf->zz = sp2C * sp28;
cmf->yz = sp2C * sp24;
cmf->zx = sp30 * sp28;
cmf->yx = sp30 * sp24;
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
cmf->zz = sp2C;
cmf->zx = sp30;
cmf->zy = 0.0f;
cmf->yz = 0.0f;
cmf->yx = 0.0f;
cmf->yy = 1.0f;
}
2020-03-22 21:19:43 +00:00
if (vec->z != 0) {
2020-03-17 04:31:30 +00:00
sp24 = Math_Sins(vec->z);
sp28 = Math_Coss(vec->z);
sp30 = cmf->xx;
sp2C = cmf->yx;
cmf->xx = sp30 * sp28 + sp2C * sp24;
cmf->yx = sp2C * sp28 - sp30 * sp24;
sp30 = cmf->xz;
sp2C = cmf->yz;
cmf->xz = sp30 * sp28 + sp2C * sp24;
cmf->yz = sp2C * sp28 - sp30 * sp24;
sp2C = cmf->yy;
cmf->xy = sp2C * sp24;
cmf->yy = sp2C * sp28;
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
cmf->xy = 0.0f;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_800D1694.s")
#endif
2020-03-22 21:19:43 +00:00
Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) {
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
s32 temp;
2020-03-17 04:31:30 +00:00
u16* m1 = (u16*)&dest->m[0][0];
u16* m2 = (u16*)&dest->m[2][0];
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->xx * 0x10000;
m1[0] = (temp >> 0x10);
m1[16 + 0] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->xy * 0x10000;
m1[1] = (temp >> 0x10);
m1[16 + 1] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->xz * 0x10000;
m1[2] = (temp >> 0x10);
m1[16 + 2] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->xw * 0x10000;
m1[3] = (temp >> 0x10);
m1[16 + 3] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->yx * 0x10000;
m1[4] = (temp >> 0x10);
m1[16 + 4] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->yy * 0x10000;
m1[5] = (temp >> 0x10);
m1[16 + 5] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->yz * 0x10000;
m1[6] = (temp >> 0x10);
m1[16 + 6] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->yw * 0x10000;
m1[7] = (temp >> 0x10);
m1[16 + 7] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->zx * 0x10000;
m1[8] = (temp >> 0x10);
m1[16 + 8] = temp & 0xFFFF;
2020-03-17 04:31:30 +00:00
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->zy * 0x10000;
m1[9] = (temp >> 0x10);
2020-03-17 04:31:30 +00:00
m2[9] = temp & 0xFFFF;
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->zz * 0x10000;
m1[10] = (temp >> 0x10);
2020-03-17 04:31:30 +00:00
m2[10] = temp & 0xFFFF;
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->zw * 0x10000;
m1[11] = (temp >> 0x10);
2020-03-17 04:31:30 +00:00
m2[11] = temp & 0xFFFF;
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->wx * 0x10000;
m1[12] = (temp >> 0x10);
2020-03-17 04:31:30 +00:00
m2[12] = temp & 0xFFFF;
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->wy * 0x10000;
m1[13] = (temp >> 0x10);
2020-03-17 04:31:30 +00:00
m2[13] = temp & 0xFFFF;
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->wz * 0x10000;
m1[14] = (temp >> 0x10);
2020-03-17 04:31:30 +00:00
m2[14] = temp & 0xFFFF;
z_skin_matrix.c decompiled (1 non matching, 1 non equivalent) (#243) * func_800A7BE4 and func_800A7C20 done - func_800A7BE4 copy of "Math_Vec3f_ToVec3s" in z_lib.c - func_800A7C20 copy of "Math_Vec3s_ToVec3f" in z_lib.c * done func_800A7A24 * func_800A76A4 done * func_800A6E10 done * func_800A6EF4 done * func_800A6FA0 done * func_800A72FC done * Deleted z_skin_matrix.data.s and updated spec * func_800A730C done * func_800A735C done * func_800A7E70 done, func_800A7C60 matching but I'm not happy with it (weird types in function params) * Corrections. func_800A7C60 in skin_matrix done, Matrix_MtxFToMtx in sys_matrix done. * func_800A7EC0 nonmatching * func_800A8030 nonmatching but VERY close (two registers swapped) * func_800A8030 done * updating comments * func_800A7704 done * func_800A7894 done * halfway through deciphering mips_to_c for func_800A73E0 * func_800A73E0 functional but non-matching (saved register differences and probably regalloc) * Renaming some arguments and rewriting comments * Renamed files across whole project and deleted asm nonmatchings * ran format.sh * fixed function name * fixing multiplcation order in SkinMatrix_MtxFMtxFMult * Corrections in SkinMatrix_MtxFMtxFMult * Formatting changes after review * Changes as per code review * fixing rename error * fixing rename error * rename fixes * fixing function rename error * ran ./format.sh * last couple of changes as per code review * renamed SetScaling -> SetScale * Skin_Matrix_Invert -> SkinMatrix_Invert * Renaming and fixing debug message print * Renamed argument "mf" to more specific "clear" in SkinMatrix_GetClear * renamed again to "mfp" * snake case to camel case changes
2020-08-08 15:23:16 +00:00
temp = src->ww * 0x10000;
m1[15] = (temp >> 0x10);
2020-03-17 04:31:30 +00:00
m2[15] = temp & 0xFFFF;
return dest;
}
2020-03-22 21:19:43 +00:00
Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line) {
2020-03-17 04:31:30 +00:00
return Matrix_MtxFToMtx(Matrix_CheckFloats(sCurrentMatrix, file, line), dest);
}
2020-03-22 21:19:43 +00:00
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line) {
2020-03-17 04:31:30 +00:00
return Matrix_ToMtx(Graph_Alloc(gfxCtx, sizeof(Mtx)), file, line);
}
Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) {
2020-03-17 04:31:30 +00:00
return Matrix_MtxFToMtx(src, Graph_Alloc(gfxCtx, sizeof(Mtx)));
}
2020-03-22 21:19:43 +00:00
void Matrix_MultVec3f(Vec3f* src, Vec3f* dest) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = sCurrentMatrix;
dest->x = cmf->wx + (cmf->xx * src->x + cmf->yx * src->y + cmf->zx * src->z);
dest->y = cmf->wy + (cmf->xy * src->x + cmf->yy * src->y + cmf->zy * src->z);
dest->z = cmf->wz + (cmf->xz * src->x + cmf->yz * src->y + cmf->zz * src->z);
}
2020-03-22 21:19:43 +00:00
void Matrix_MtxFCopy(MtxF* dest, MtxF* src) {
2020-03-17 04:31:30 +00:00
dest->xx = src->xx;
dest->xy = src->xy;
dest->xz = src->xz;
dest->xw = src->xw;
dest->yx = src->yx;
dest->yy = src->yy;
dest->yz = src->yz;
dest->yw = src->yw;
dest->xx = src->xx;
dest->xy = src->xy;
dest->xz = src->xz;
dest->xw = src->xw;
dest->yx = src->yx;
dest->yy = src->yy;
dest->yz = src->yz;
dest->yw = src->yw;
dest->zx = src->zx;
dest->zy = src->zy;
dest->zz = src->zz;
dest->zw = src->zw;
dest->wx = src->wx;
dest->wy = src->wy;
dest->wz = src->wz;
dest->ww = src->ww;
dest->zx = src->zx;
dest->zy = src->zy;
dest->zz = src->zz;
dest->zw = src->zw;
dest->wx = src->wx;
dest->wy = src->wy;
dest->wz = src->wz;
dest->ww = src->ww;
}
2020-03-22 21:19:43 +00:00
void Matrix_MtxToMtxF(Mtx* src, MtxF* dest) {
2020-03-17 04:31:30 +00:00
u16* m1 = (u16*)&src->m[0][0];
u16* m2 = (u16*)&src->m[2][0];
dest->xx = ((m1[0] << 0x10) | m2[0]) * (1 / 65536.0f);
dest->xy = ((m1[1] << 0x10) | m2[1]) * (1 / 65536.0f);
dest->xz = ((m1[2] << 0x10) | m2[2]) * (1 / 65536.0f);
dest->xw = ((m1[3] << 0x10) | m2[3]) * (1 / 65536.0f);
dest->yx = ((m1[4] << 0x10) | m2[4]) * (1 / 65536.0f);
dest->yy = ((m1[5] << 0x10) | m2[5]) * (1 / 65536.0f);
dest->yz = ((m1[6] << 0x10) | m2[6]) * (1 / 65536.0f);
dest->yw = ((m1[7] << 0x10) | m2[7]) * (1 / 65536.0f);
dest->zx = ((m1[8] << 0x10) | m2[8]) * (1 / 65536.0f);
dest->zy = ((m1[9] << 0x10) | m2[9]) * (1 / 65536.0f);
dest->zz = ((m1[10] << 0x10) | m2[10]) * (1 / 65536.0f);
dest->zw = ((m1[11] << 0x10) | m2[11]) * (1 / 65536.0f);
dest->wx = ((m1[12] << 0x10) | m2[12]) * (1 / 65536.0f);
dest->wy = ((m1[13] << 0x10) | m2[13]) * (1 / 65536.0f);
dest->wz = ((m1[14] << 0x10) | m2[14]) * (1 / 65536.0f);
dest->ww = ((m1[15] << 0x10) | m2[15]) * (1 / 65536.0f);
}
2020-03-22 21:19:43 +00:00
void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf) {
2020-03-17 04:31:30 +00:00
dest->x = mf->wx + (mf->xx * src->x + mf->yx * src->y + mf->zx * src->z);
dest->y = mf->wy + (mf->xy * src->x + mf->yy * src->y + mf->zy * src->z);
dest->z = mf->wz + (mf->xz * src->x + mf->yz * src->y + mf->zz * src->z);
}
2020-03-22 21:19:43 +00:00
void Matrix_Reverse(MtxF* mf) {
2020-03-17 04:31:30 +00:00
f32 temp;
temp = mf->xy;
mf->xy = mf->yx;
mf->yx = temp;
temp = mf->xz;
mf->xz = mf->zx;
mf->zx = temp;
temp = mf->yz;
mf->yz = mf->zy;
mf->zy = temp;
}
#ifdef NON_MATCHING
2020-03-22 21:19:43 +00:00
void func_800D1FD4(MtxF* mf) {
2020-03-17 04:31:30 +00:00
MtxF* cmf = sCurrentMatrix;
f32 temp;
temp = sqrtf(SQ(cmf->xx) + SQ(cmf->xy) + SQ(cmf->xz));
cmf->xx = mf->xx * temp;
cmf->xy = mf->xy * temp;
cmf->xz = mf->xz * temp;
temp = sqrtf(SQ(cmf->yx) + SQ(cmf->yy) + SQ(cmf->yz));
cmf->yx = mf->yx * temp;
cmf->yy = mf->yy * temp;
cmf->yz = mf->yz * temp;
temp = sqrtf(SQ(cmf->zx) + SQ(cmf->zy) + SQ(cmf->zz));
cmf->zx = mf->zx * temp;
cmf->zy = mf->zy * temp;
cmf->zz = mf->zz * temp;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_800D1FD4.s")
#endif
#ifdef NON_MATCHING
// same differences as func_800D2264
2020-03-22 21:19:43 +00:00
void func_800D20CC(MtxF* mf, Vec3s* vec, s32 flag) {
2020-03-21 02:09:42 +00:00
vec->x = Math_atan2f(-mf->zy, sqrtf(SQ(mf->zx) + SQ(mf->zz))) * (32768 / M_PI);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if ((vec->x == 0x4000) || (vec->x == -0x4000)) {
2020-03-17 04:31:30 +00:00
vec->z = 0;
2020-03-21 02:09:42 +00:00
vec->y = Math_atan2f(-mf->xz, mf->xx) * (32768 / M_PI);
2020-03-17 04:31:30 +00:00
return;
}
2020-03-21 02:09:42 +00:00
vec->y = Math_atan2f(mf->zx, mf->zz) * (32768 / M_PI);
2020-03-17 04:31:30 +00:00
2020-03-23 23:11:21 +00:00
if (!flag) {
2020-03-21 02:09:42 +00:00
vec->z = Math_atan2f(mf->xy, mf->yy) * (32768 / M_PI);
2020-03-23 23:11:21 +00:00
} else {
2020-03-22 21:19:43 +00:00
vec->z = Math_atan2f(mf->xy / sqrtf(SQ(mf->xx) + SQ(mf->xz) + SQ(mf->xy)),
mf->yy / sqrtf(SQ(mf->yx) + SQ(mf->yz) + SQ(mf->yy))) *
(32768 / M_PI);
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_800D20CC.s")
#endif
#ifdef NON_MATCHING
// same differences as func_800D20CC
2020-03-22 21:19:43 +00:00
void func_800D2264(MtxF* mf, Vec3s* vec, s32 flag) {
2020-03-21 02:09:42 +00:00
vec->y = Math_atan2f(-mf->xz, sqrtf(SQ(mf->xx) + SQ(mf->xy))) * (32768 / M_PI);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if ((vec->y == 0x4000) || (vec->y == -0x4000)) {
2020-03-17 04:31:30 +00:00
vec->x = 0;
2020-03-21 02:09:42 +00:00
vec->z = Math_atan2f(-mf->yx, mf->yy) * (32768 / M_PI);
2020-03-17 04:31:30 +00:00
return;
}
2020-03-21 02:09:42 +00:00
vec->z = Math_atan2f(mf->xy, mf->xx) * (32768 / M_PI);
2020-03-17 04:31:30 +00:00
2020-03-23 23:11:21 +00:00
if (!flag) {
2020-03-21 02:09:42 +00:00
vec->x = Math_atan2f(mf->yz, mf->zz) * (32768 / M_PI);
2020-03-23 23:11:21 +00:00
} else {
2020-03-22 21:19:43 +00:00
vec->x = Math_atan2f(mf->yz / sqrtf(SQ(mf->yx) + SQ(mf->yy) + SQ(mf->yz)),
mf->zz / sqrtf(SQ(mf->zx) + SQ(mf->zy) + SQ(mf->zz))) *
(32768 / M_PI);
2020-03-23 23:11:21 +00:00
}
2020-03-17 04:31:30 +00:00
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_800D2264.s")
#endif
#ifdef NON_MATCHING
// regalloc differences
2020-03-22 21:19:43 +00:00
void func_800D23FC(f32 f, Vec3f* vec, u8 mode) {
2020-03-17 04:31:30 +00:00
MtxF* cmf;
f32 sin;
f32 cos;
f32 rCos;
f32 temp1;
f32 temp2;
f32 temp3;
f32 temp4;
2020-03-22 21:19:43 +00:00
if (mode == MTXMODE_APPLY) {
if (f != 0) {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
sin = sinf(f);
cos = cosf(f);
temp1 = cmf->xx;
temp2 = cmf->yx;
temp3 = cmf->zx;
temp4 = (vec->x * temp1 + vec->y * temp2 + vec->z * temp3) * (1.0f - cos);
cmf->xx = temp1 * cos + vec->x * temp4 + sin * (temp2 * vec->z - temp3 * vec->y);
cmf->yx = temp2 * cos + vec->y * temp4 + sin * (temp3 * vec->x - temp1 * vec->z);
cmf->zx = temp3 * cos + vec->z * temp4 + sin * (temp1 * vec->y - temp2 * vec->x);
temp1 = cmf->xy;
temp2 = cmf->yy;
temp3 = cmf->zy;
temp4 = (vec->x * temp1 + vec->y * temp2 + vec->z * temp3) * (1.0f - cos);
cmf->xy = temp1 * cos + vec->x * temp4 + sin * (temp2 * vec->z - temp3 * vec->y);
cmf->yy = temp2 * cos + vec->y * temp4 + sin * (temp3 * vec->x - temp1 * vec->z);
cmf->zy = temp3 * cos + vec->z * temp4 + sin * (temp1 * vec->y - temp2 * vec->x);
temp1 = cmf->xz;
temp2 = cmf->yz;
temp3 = cmf->zz;
temp4 = (vec->x * temp1 + vec->y * temp2 + vec->z * temp3) * (1.0f - cos);
cmf->xz = temp1 * cos + vec->x * temp4 + sin * (temp2 * vec->z - temp3 * vec->y);
cmf->yz = temp2 * cos + vec->y * temp4 + sin * (temp3 * vec->x - temp1 * vec->z);
cmf->zz = temp3 * cos + vec->z * temp4 + sin * (temp1 * vec->y - temp2 * vec->x);
}
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
cmf = sCurrentMatrix;
2020-03-22 21:19:43 +00:00
if (f != 0) {
2020-03-17 04:31:30 +00:00
sin = sinf(f);
cos = cosf(f);
rCos = 1.0f - cos;
cmf->xx = vec->x * vec->x * rCos + cos;
cmf->yy = vec->y * vec->y * rCos + cos;
cmf->zz = vec->z * vec->z * rCos + cos;
temp1 = vec->x * rCos * vec->y;
temp2 = vec->z * sin;
cmf->xy = temp1 + temp2;
cmf->yx = temp1 - temp2;
temp1 = vec->x * rCos * vec->z;
temp2 = vec->y * sin;
cmf->xz = temp1 - temp2;
cmf->zx = temp1 + temp2;
temp1 = vec->y * rCos * vec->z;
temp2 = vec->x * sin;
cmf->yz = temp1 + temp2;
cmf->zy = temp1 - temp2;
cmf->xw = 0.0f;
cmf->yw = 0.0f;
cmf->zw = 0.0f;
cmf->wx = 0.0f;
cmf->wy = 0.0f;
cmf->wz = 0.0f;
cmf->ww = 1.0f;
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
cmf->xy = 0.0f;
cmf->xz = 0.0f;
cmf->xw = 0.0f;
cmf->yx = 0.0f;
cmf->yz = 0.0f;
cmf->yw = 0.0f;
cmf->zx = 0.0f;
cmf->zy = 0.0f;
cmf->zw = 0.0f;
cmf->wx = 0.0f;
cmf->wy = 0.0f;
cmf->wz = 0.0f;
cmf->xx = 1.0f;
cmf->yy = 1.0f;
cmf->zz = 1.0f;
cmf->ww = 1.0f;
}
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_800D23FC.s")
#endif
2020-03-22 21:19:43 +00:00
MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line) {
2020-03-17 04:31:30 +00:00
s32 i, j;
2020-03-22 21:19:43 +00:00
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (!(-32768.0f <= mf->mf[i][j]) || !(mf->mf[i][j] < 32768.0f)) {
osSyncPrintf("%s %d: [%s] =\n"
"/ %12.6f %12.6f %12.6f %12.6f \\\n"
"| %12.6f %12.6f %12.6f %12.6f |\n"
"| %12.6f %12.6f %12.6f %12.6f |\n"
"\\ %12.6f %12.6f %12.6f %12.6f /\n",
2020-03-22 21:19:43 +00:00
file, line, "mf", mf->xx, mf->yx, mf->zx, mf->wx, mf->xy, mf->yy, mf->zy, mf->wy, mf->xz,
mf->yz, mf->zz, mf->wz, mf->xw, mf->yw, mf->zw, mf->ww);
2020-03-17 04:31:30 +00:00
Fault_AddHungupAndCrash(file, line);
}
}
}
return mf;
}
2020-03-22 21:19:43 +00:00
void func_800D2A34(MtxF* mf, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
2020-03-17 04:31:30 +00:00
mf->xy = 0.0f;
mf->xz = 0.0f;
mf->xw = 0.0f;
mf->yx = 0.0f;
mf->yz = 0.0f;
mf->yw = 0.0f;
mf->zx = 0.0f;
mf->zy = 0.0f;
mf->zw = 0.0f;
mf->xx = arg1;
mf->yy = arg1;
mf->zz = arg1;
mf->wx = arg2;
mf->wy = arg3;
mf->wz = arg4;
mf->ww = 1.0f;
}
2020-03-22 21:19:43 +00:00
void func_800D2A98(Mtx* mtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
2020-03-17 04:31:30 +00:00
MtxF mf;
func_800D2A34(&mf, arg1, arg2, arg3, arg4);
guMtxF2L(&mf, mtx);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
void func_800D2AE4(Mtx* mtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
2020-03-17 04:31:30 +00:00
u16* m1 = (u16*)&mtx->m[0][0];
u16* m2 = (u16*)&mtx->m[2][0];
u32 temp;
temp = (s32)(arg1 * 65536.0f);
m2[0] = temp & 0xFFFF;
m1[0] = (temp >> 16) & 0xFFFF;
temp = (s32)(arg1 * 65536.0f);
m1[5] = (temp >> 16) & 0xFFFF;
m2[5] = temp & 0xFFFF;
temp = (s32)(arg1 * 65536.0f);
m1[10] = (temp >> 16) & 0xFFFF;
m2[10] = temp & 0xFFFF;
temp = (s32)(arg2 * 65536.0f);
m1[12] = (temp >> 16) & 0xFFFF;
m2[12] = temp & 0xFFFF;
temp = (s32)(arg3 * 65536.0f);
m1[13] = (temp >> 16) & 0xFFFF;
m2[13] = temp & 0xFFFF;
temp = (s32)(arg4 * 65536.0f);
m1[14] = (temp >> 16) & 0xFFFF;
m2[14] = temp & 0xFFFF;
m1[1] = 0;
m1[2] = 0;
m1[3] = 0;
m1[4] = 0;
m1[6] = 0;
m1[7] = 0;
m1[8] = 0;
m1[9] = 0;
m1[11] = 0;
m1[15] = 1;
m2[1] = 0;
m2[2] = 0;
m2[3] = 0;
m2[4] = 0;
m2[6] = 0;
m2[7] = 0;
m2[8] = 0;
m2[9] = 0;
m2[11] = 0;
m2[15] = 0;
}
2020-03-22 21:19:43 +00:00
void func_800D2BD0(Mtx* mtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6) {
2020-03-17 04:31:30 +00:00
u16* m1 = (u16*)&mtx->m[0][0];
u16* m2 = (u16*)&mtx->m[2][0];
u32 temp;
temp = (s32)(arg1 * 65536.0f);
m1[0] = (temp >> 16) & 0xFFFF;
m2[0] = temp & 0xFFFF;
temp = (s32)(arg2 * 65536.0f);
m1[5] = (temp >> 16) & 0xFFFF;
m2[5] = temp & 0xFFFF;
temp = (s32)(arg3 * 65536.0f);
m1[10] = (temp >> 16) & 0xFFFF;
m2[10] = temp & 0xFFFF;
temp = (s32)(arg4 * 65536.0f);
m1[12] = (temp >> 16) & 0xFFFF;
m2[12] = temp & 0xFFFF;
temp = (s32)(arg5 * 65536.0f);
m1[13] = (temp >> 16) & 0xFFFF;
m2[13] = temp & 0xFFFF;
temp = (s32)(arg6 * 65536.0f);
m1[14] = (temp >> 16) & 0xFFFF;
m2[14] = temp & 0xFFFF;
m1[1] = 0;
m1[2] = 0;
m1[3] = 0;
m1[4] = 0;
m1[6] = 0;
m1[7] = 0;
m1[8] = 0;
m1[9] = 0;
m1[11] = 0;
m1[15] = 1;
m2[1] = 0;
m2[2] = 0;
m2[3] = 0;
m2[4] = 0;
m2[6] = 0;
m2[7] = 0;
m2[8] = 0;
m2[9] = 0;
m2[11] = 0;
m2[15] = 0;
}
#ifdef NON_MATCHING
// minor ordering and regalloc differences
2020-03-22 21:19:43 +00:00
void func_800D2CEC(Mtx* mtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6) {
2020-03-17 04:31:30 +00:00
u16* m1 = (u16*)&mtx->m[0][0];
u16* m2 = (u16*)&mtx->m[2][0];
u32 temp;
mtx->m[0][1] = 0;
mtx->m[2][1] = 0;
mtx->m[0][3] = 0;
mtx->m[2][3] = 0;
mtx->m[0][4] = 0;
temp = (s32)(arg1 * 65536.0f);
m1[0] = temp & 0xFFFF;
mtx->m[2][0] = temp << 16;
temp = (s32)(arg2 * 65536.0f);
mtx->m[0][2] = temp >> 16;
mtx->m[2][2] = temp & 0xFFFF;
m1[1] = 0;
mtx->m[2][4] = 0;
temp = (s32)(arg3 * 65536.0f);
mtx->m[1][1] = temp;
m1[11] = 0;
mtx->m[3][1] = temp << 16;
temp = (s32)(arg4 * 65536.0f);
m1[12] = (temp >> 16) & 0xFFFF;
m2[12] = temp & 0xFFFF;
temp = (s32)(arg5 * 65536.0f);
m1[13] = (temp >> 16) & 0xFFFF;
m2[13] = temp & 0xFFFF;
temp = (s32)(arg6 * 65536.0f);
m1[14] = (temp >> 16) & 0xFFFF;
mtx->m[3][3] = temp << 16;
m1[15] = 1;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_800D2CEC.s")
#endif