Attempt guPerspectiveF, not matching yet

This commit is contained in:
Ryan Myers
2021-09-24 09:30:59 -04:00
parent 6476c60f4e
commit 838abdadf3
3 changed files with 38 additions and 1 deletions
+1
View File
@@ -257,6 +257,7 @@ ALL_ASSETS_BUILT += $(patsubst $(UCODE_IN_DIR)/%.bin,$(UCODE_OUT_DIR)/%.bin,$(UC
$(BUILD_DIR)/lib/%.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/al/%.o: OPT_FLAGS := -O3
$(BUILD_DIR)/lib/src/gu/guPerspectiveF.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/os/%.o: OPT_FLAGS := -O1
$(BUILD_DIR)/lib/src/os/osViMgr.o: OPT_FLAGS := -O2
$(BUILD_DIR)/lib/src/os/osCreatePiManager.o: OPT_FLAGS := -O2
+1 -1
View File
@@ -61,4 +61,4 @@ void guMtxL2F(float mf[4][4], Mtx *m) {
mf[r][c * 2 + 1] = stmp2 / 65536.0f;
}
}
}
}
+36
View File
@@ -3,5 +3,41 @@
#include "types.h"
#include "macros.h"
#include "libc/math.h"
#include "PR/gu.h"
#if 0
void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale)
{
float cot;
int i, j;
guMtxIdentF(mf);
fovy *= 3.1415926 / 180.0;
cot = cosf (fovy/2) / sinf (fovy/2);
mf[0][0] = cot / aspect;
mf[1][1] = cot;
mf[2][2] = (near + far) / (near - far);
mf[2][3] = -1;
mf[3][2] = (2 * near * far) / (near - far);
mf[3][3] = 0;
for (i=0; i<4; i++)
for (j=0; j<4; j++)
mf[i][j] *= scale;
if (perspNorm != (u16 *) NULL) {
if (near+far<=2.0) {
*perspNorm = (u16) 0xFFFF;
} else {
*perspNorm = (u16) ((2.0*65536.0)/(near+far));
if (*perspNorm<=0)
*perspNorm = (u16) 0x0001;
}
}
}
#else
GLOBAL_ASM("lib/asm/non_matchings/unknown_0CCF90/guPerspectiveF.s")
#endif