port: make matrices work with GBI_FLOATS

add GBI_FLOATS=1 to DEFINES to enable it

not enabling by default yet because not sure if it'll break anything
This commit is contained in:
fgsfds committed 2023-08-26 13:49:23 +02:00
1 parent 85e914c129
commit 2b27c2dc6a
3 files changed
+14 -1

No files matched your search

+5
View File
@@ -1049,7 +1049,12 @@ typedef struct {
* First 8 words are integer portion of the 4x4 matrix * First 8 words are integer portion of the 4x4 matrix
* Last 8 words are the fraction portion of the 4x4 matrix * Last 8 words are the fraction portion of the 4x4 matrix
*/ */
#ifdef GBI_FLOATS
// 4x4 float matrix
typedef float Mtx_t[4][4];
#else
typedef long Mtx_t[4][4]; typedef long Mtx_t[4][4];
#endif
typedef union { typedef union {
Mtx_t m; Mtx_t m;
+3 -1
View File
@@ -366,6 +366,8 @@ void mtxF2L(Mtxf *src, Mtxf *dst)
dst->l[3][2] = src30 << 16 | (src31 & 0xffff); dst->l[3][2] = src30 << 16 | (src31 & 0xffff);
dst->l[3][3] = src32 << 16 | (src33 & 0xffff); dst->l[3][3] = src32 << 16 | (src33 & 0xffff);
#else #else
bcopy(src, dst, sizeof(*dst)); if (src != dst) {
bcopy(src, dst, sizeof(*dst));
}
#endif #endif
} }
+6
View File
@@ -2,6 +2,11 @@
void guMtxF2L(f32 mf[4][4], Mtx *m) void guMtxF2L(f32 mf[4][4], Mtx *m)
{ {
#ifdef GBI_FLOATS
if ((Mtx *)mf != m) {
bcopy(mf, m, sizeof(*m));
}
#else
int i, j; int i, j;
int e1, e2; int e1, e2;
int *ai, *af; int *ai, *af;
@@ -18,6 +23,7 @@ void guMtxF2L(f32 mf[4][4], Mtx *m)
*(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff); *(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff);
} }
} }
#endif
} }
void guMtxIdentF(float mf[4][4]) void guMtxIdentF(float mf[4][4])