From 838abdadf330ae54d532c54ad3bdd4747c8432fa Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Fri, 24 Sep 2021 09:30:59 -0400 Subject: [PATCH] Attempt guPerspectiveF, not matching yet --- Makefile | 1 + lib/src/gu/guMtxUtil.c | 2 +- lib/src/gu/guPerspectiveF.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 32e5cb0a..d7e070d8 100755 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/lib/src/gu/guMtxUtil.c b/lib/src/gu/guMtxUtil.c index 5979d8e1..f2cc2377 100644 --- a/lib/src/gu/guMtxUtil.c +++ b/lib/src/gu/guMtxUtil.c @@ -61,4 +61,4 @@ void guMtxL2F(float mf[4][4], Mtx *m) { mf[r][c * 2 + 1] = stmp2 / 65536.0f; } } -} \ No newline at end of file +} diff --git a/lib/src/gu/guPerspectiveF.c b/lib/src/gu/guPerspectiveF.c index 2e62c7a5..2b871642 100644 --- a/lib/src/gu/guPerspectiveF.c +++ b/lib/src/gu/guPerspectiveF.c @@ -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