From 3e4b6c81c6ef2bb256cabc6c446cc4ea3dcf9d10 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 27 May 2024 10:50:00 -0500 Subject: [PATCH] Add geometry mode for forcing branch execution (#605) --- include/libultraship/libultra/gbi.h | 1 + src/graphic/Fast3D/gfx_pc.cpp | 2 +- src/graphic/Fast3D/lus_gbi.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/libultraship/libultra/gbi.h b/include/libultraship/libultra/gbi.h index 73a92f1..fc1e8dd 100644 --- a/include/libultraship/libultra/gbi.h +++ b/include/libultraship/libultra/gbi.h @@ -368,6 +368,7 @@ * G_EXTRAGEOMETRY flags: set extra custom geometry modes */ #define G_EX_INVERT_CULLING 0x00000001 +#define G_EX_ALWAYS_EXECUTE_BRANCH 0x00000002 /* Need these defined for Sprite Microcode */ #ifdef _LANGUAGE_ASSEMBLY diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index 05ff7e8..eb6ea5c 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -3035,7 +3035,7 @@ bool gfx_branch_z_otr_handler_f3dex2(F3DGfx** cmd0) { (*cmd0)++; - if (g_rsp.loaded_vertices[vbidx].z <= zval) { + if (g_rsp.loaded_vertices[vbidx].z <= zval || (g_rsp.extra_geometry_mode & G_EX_ALWAYS_EXECUTE_BRANCH) != 0) { uint64_t hash = ((uint64_t)(*cmd0)->words.w0 << 32) + (*cmd0)->words.w1; F3DGfx* gfx = (F3DGfx*)ResourceGetDataByCrc(hash); diff --git a/src/graphic/Fast3D/lus_gbi.h b/src/graphic/Fast3D/lus_gbi.h index 6c3ced1..8b1db9d 100644 --- a/src/graphic/Fast3D/lus_gbi.h +++ b/src/graphic/Fast3D/lus_gbi.h @@ -196,6 +196,7 @@ constexpr int8_t OTR_G_SETINTENSITY = OPCODE(0x40); * G_EXTRAGEOMETRY flags: set extra custom geometry modes */ #define G_EX_INVERT_CULLING 0x00000001 +#define G_EX_ALWAYS_EXECUTE_BRANCH 0x00000002 /* * G_SETIMG fmt: set image formats