From bfff9bf13119735d5812b97ea971759522dde30d Mon Sep 17 00:00:00 2001 From: Archez Date: Mon, 18 Nov 2024 20:28:29 -0500 Subject: [PATCH] Execute logic to reset rsp state on ucode load (#719) --- src/graphic/Fast3D/gfx_pc.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index 892f91a..f5f47c0 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -2739,12 +2739,6 @@ void gfx_copy_framebuffer(int fb_dst_id, int fb_src_id, bool copyOnce, bool* has // current opcode should be incremented after the handler ends. typedef bool (*GfxOpcodeHandlerFunc)(F3DGfx** gfx); -bool gfx_load_ucode_handler_f3dex2(F3DGfx** cmd) { - g_rsp.fog_mul = 0; - g_rsp.fog_offset = 0; - return false; -} - bool gfx_cull_dl_handler_f3dex2(F3DGfx** cmd) { // TODO: return false; @@ -3990,6 +3984,20 @@ static void gfx_set_ucode_handler(UcodeHandlers ucode) { // Loaded ucode must be in range of the supported ucode_handlers assert(ucode < ucode_max); ucode_handler_index = ucode; + + // Reset some RSP state values upon ucode load to deal with hardware quirks discovered by emulators + switch (ucode) { + case ucode_f3d: + case ucode_f3db: + case ucode_f3dex: + case ucode_f3dexb: + case ucode_f3dex2: + g_rsp.fog_mul = 0; + g_rsp.fog_offset = 0; + break; + default: + break; + } } static void gfx_step() {