diff options
| author | AdamKiddle <54328813+AdamKiddle@users.noreply.github.com> | 2020-08-08 16:23:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-08 11:23:16 -0400 |
| commit | 54f762b419353090d81e7d028a14947d64a311c8 (patch) | |
| tree | 303da5544f131bd46c48d39f514ef5d28cbd6f6e /src/code/sys_matrix.c | |
| parent | 34c73dda62f973aaa940ffc7c8165cc645324c28 (diff) | |
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
Diffstat (limited to 'src/code/sys_matrix.c')
| -rw-r--r-- | src/code/sys_matrix.c | 100 |
1 files changed, 47 insertions, 53 deletions
diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 46a2944c8..87a1708f4 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -53,7 +53,7 @@ void Matrix_Mult(MtxF* mf, u8 mode) { MtxF* cmf = Matrix_GetCurrent(); if (mode == MTXMODE_APPLY) { - func_800A6FA0(cmf, mf, cmf); + SkinMatrix_MtxFMtxFMult(cmf, mf, cmf); } else { Matrix_MtxFCopy(sCurrentMatrix, mf); } @@ -78,7 +78,7 @@ void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode) { ty = cmf->yw; cmf->ww += tx * x + ty * y + cmf->zw * z; } else { - func_800A7A24(cmf, x, y, z); + SkinMatrix_SetTranslate(cmf, x, y, z); } } @@ -99,7 +99,7 @@ void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) { cmf->yw *= y; cmf->zw *= z; } else { - func_800A76A4(cmf, x, y, z); + SkinMatrix_SetScale(cmf, x, y, z); } } @@ -382,7 +382,7 @@ void Matrix_RotateRPY(s16 x, s16 y, s16 z, u8 mode) { cmf->zw = temp2 * cos - temp1 * sin; } } else { - func_800A7704(cmf, x, y, z); + SkinMatrix_SetRotateRPY(cmf, x, y, z); } } @@ -540,82 +540,76 @@ void func_800D1694(f32 x, f32 y, f32 z, Vec3s* vec) { #pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_800D1694.s") #endif -#ifdef NON_MATCHING -// mostly regalloc differences Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) { + s32 temp; u16* m1 = (u16*)&dest->m[0][0]; u16* m2 = (u16*)&dest->m[2][0]; - s32 temp; - temp = src->xx * 65536.0f; - m1[0] = (temp >> 0x10) & 0xFFFF; - m2[0] = temp & 0xFFFF; + temp = src->xx * 0x10000; + m1[0] = (temp >> 0x10); + m1[16 + 0] = temp & 0xFFFF; - temp = src->xy * 65536.0f; - m1[1] = (temp >> 0x10) & 0xFFFF; - m2[1] = temp & 0xFFFF; + temp = src->xy * 0x10000; + m1[1] = (temp >> 0x10); + m1[16 + 1] = temp & 0xFFFF; - temp = src->xz * 65536.0f; - m1[2] = (temp >> 0x10) & 0xFFFF; - m2[2] = temp & 0xFFFF; + temp = src->xz * 0x10000; + m1[2] = (temp >> 0x10); + m1[16 + 2] = temp & 0xFFFF; - temp = src->xw * 65536.0f; - m1[3] = (temp >> 0x10) & 0xFFFF; - m2[3] = temp & 0xFFFF; + temp = src->xw * 0x10000; + m1[3] = (temp >> 0x10); + m1[16 + 3] = temp & 0xFFFF; - temp = src->yx * 65536.0f; - m1[4] = (temp >> 0x10) & 0xFFFF; - m2[4] = temp & 0xFFFF; + temp = src->yx * 0x10000; + m1[4] = (temp >> 0x10); + m1[16 + 4] = temp & 0xFFFF; - temp = src->yy * 65536.0f; - m1[5] = (temp >> 0x10) & 0xFFFF; - m2[5] = temp & 0xFFFF; + temp = src->yy * 0x10000; + m1[5] = (temp >> 0x10); + m1[16 + 5] = temp & 0xFFFF; - temp = src->yz * 65536.0f; - m1[6] = (temp >> 0x10) & 0xFFFF; - m2[6] = temp & 0xFFFF; + temp = src->yz * 0x10000; + m1[6] = (temp >> 0x10); + m1[16 + 6] = temp & 0xFFFF; - temp = src->yw * 65536.0f; - m1[7] = (temp >> 0x10) & 0xFFFF; - m2[7] = temp & 0xFFFF; + temp = src->yw * 0x10000; + m1[7] = (temp >> 0x10); + m1[16 + 7] = temp & 0xFFFF; - temp = src->zx * 65536.0f; - m1[8] = (temp >> 0x10) & 0xFFFF; - m2[8] = temp & 0xFFFF; + temp = src->zx * 0x10000; + m1[8] = (temp >> 0x10); + m1[16 + 8] = temp & 0xFFFF; - temp = src->zy * 65536.0f; - m1[9] = (temp >> 0x10) & 0xFFFF; + temp = src->zy * 0x10000; + m1[9] = (temp >> 0x10); m2[9] = temp & 0xFFFF; - temp = src->zz * 65536.0f; - m1[10] = (temp >> 0x10) & 0xFFFF; + temp = src->zz * 0x10000; + m1[10] = (temp >> 0x10); m2[10] = temp & 0xFFFF; - temp = src->zw * 65536.0f; - m1[11] = (temp >> 0x10) & 0xFFFF; + temp = src->zw * 0x10000; + m1[11] = (temp >> 0x10); m2[11] = temp & 0xFFFF; - temp = src->wx * 65536.0f; - m1[12] = (temp >> 0x10) & 0xFFFF; + temp = src->wx * 0x10000; + m1[12] = (temp >> 0x10); m2[12] = temp & 0xFFFF; - temp = src->wy * 65536.0f; - m1[13] = (temp >> 0x10) & 0xFFFF; + temp = src->wy * 0x10000; + m1[13] = (temp >> 0x10); m2[13] = temp & 0xFFFF; - temp = src->wz * 65536.0f; - m1[14] = (temp >> 0x10) & 0xFFFF; + temp = src->wz * 0x10000; + m1[14] = (temp >> 0x10); m2[14] = temp & 0xFFFF; - temp = src->ww * 65536.0f; - m1[15] = (temp >> 0x10) & 0xFFFF; + temp = src->ww * 0x10000; + m1[15] = (temp >> 0x10); m2[15] = temp & 0xFFFF; - return dest; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MtxFToMtx.s") -#endif Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line) { return Matrix_MtxFToMtx(Matrix_CheckFloats(sCurrentMatrix, file, line), dest); @@ -625,7 +619,7 @@ Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line) { return Matrix_ToMtx(Graph_Alloc(gfxCtx, sizeof(Mtx)), file, line); } -Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) { +Mtx* Matrix_SkinMatrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) { return Matrix_MtxFToMtx(src, Graph_Alloc(gfxCtx, sizeof(Mtx))); } |
