diff --git a/Config.cpp b/Config.cpp index 8d05510c..36823dea 100644 --- a/Config.cpp +++ b/Config.cpp @@ -109,6 +109,13 @@ void Config_LoadConfig() config.texture.textureBitDepth = 1; config.enableHWLighting = FALSE; } + + // manually set frame bufer emulation options + config.frameBufferEmulation.copyToRDRAM = FALSE; + config.frameBufferEmulation.copyDepthToRDRAM = FALSE; + config.frameBufferEmulation.copyFromRDRAM = FALSE; + config.frameBufferEmulation.ignoreCFB = TRUE; + config.frameBufferEmulation.N64DepthCompare = FALSE; } void Config_SaveConfig() diff --git a/Config.h b/Config.h index 05d941ef..f62ea2d8 100644 --- a/Config.h +++ b/Config.h @@ -25,6 +25,11 @@ struct Config struct { u32 enable; + u32 copyToRDRAM; + u32 copyDepthToRDRAM; + u32 copyFromRDRAM; + u32 ignoreCFB; + u32 N64DepthCompare; } frameBufferEmulation; u32 enableFog; diff --git a/Config_linux.cpp b/Config_linux.cpp index 4c209ed7..7f98a8be 100644 --- a/Config_linux.cpp +++ b/Config_linux.cpp @@ -467,6 +467,13 @@ void Config_LoadConfig() } fclose( f ); + + // manually set frame bufer emulation options + config.frameBufferEmulation.copyToRDRAM = FALSE; + config.frameBufferEmulation.copyDepthToRDRAM = FALSE; + config.frameBufferEmulation.copyFromRDRAM = FALSE; + config.frameBufferEmulation.ignoreCFB = TRUE; + config.frameBufferEmulation.N64DepthCompare = FALSE; } void Config_DoConfig() diff --git a/DepthBuffer.cpp b/DepthBuffer.cpp index 7f93e430..666608a0 100644 --- a/DepthBuffer.cpp +++ b/DepthBuffer.cpp @@ -13,9 +13,7 @@ const GLuint ZlutImageUnit = 0; const GLuint TlutImageUnit = 1; const GLuint depthImageUnit = 2; -bool g_bN64DepthCompare = false; - - void DepthBuffer_Init() +void DepthBuffer_Init() { depthBuffer.current = NULL; depthBuffer.top = NULL; diff --git a/DepthBuffer.h b/DepthBuffer.h index 0a1201fb..0de74eb7 100644 --- a/DepthBuffer.h +++ b/DepthBuffer.h @@ -26,8 +26,6 @@ extern const GLuint ZlutImageUnit; extern const GLuint TlutImageUnit; extern const GLuint depthImageUnit; -extern bool g_bN64DepthCompare; - void DepthBuffer_Init(); void DepthBuffer_Destroy(); void DepthBuffer_SetBuffer( u32 address ); diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index 99c4cd41..d90a91d4 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -13,11 +13,6 @@ #include "Config.h" #include "Debug.h" -bool g_bCopyToRDRAM = false; -bool g_bCopyFromRDRAM = false; -bool g_bCopyDepthToRDRAM = false; -bool g_bIgnoreCFB = true; - #ifndef GLES2 const GLint monohromeInternalformat = GL_R8; const GLenum monohromeformat = GL_RED; @@ -279,7 +274,7 @@ void FrameBuffer_SaveBuffer( u32 address, u16 format, u16 size, u16 width, u16 h FrameBuffer *current = frameBuffer.top; if (current != NULL && gDP.colorImage.height > 1) { current->endAddress = current->startAddress + (((current->width * gDP.colorImage.height) << current->size >> 1) - 1); - if (!g_bCopyToRDRAM && !current->cleared) + if (!config.frameBufferEmulation.copyToRDRAM && !current->cleared) gDPFillRDRAM(current->startAddress, 0, 0, current->width, gDP.colorImage.height, current->width, current->size, frameBuffer.top->fillcolor); } diff --git a/FrameBuffer.h b/FrameBuffer.h index a96b202c..26ac29f6 100644 --- a/FrameBuffer.h +++ b/FrameBuffer.h @@ -29,10 +29,6 @@ struct FrameBufferList }; extern FrameBufferList frameBuffer; -extern bool g_bCopyToRDRAM; -extern bool g_bCopyDepthToRDRAM; -extern bool g_bCopyFromRDRAM; -extern bool g_bIgnoreCFB; void FrameBuffer_Init(); void FrameBuffer_Destroy(); diff --git a/GLSLCombiner.cpp b/GLSLCombiner.cpp index d01a8c28..28c56b94 100644 --- a/GLSLCombiner.cpp +++ b/GLSLCombiner.cpp @@ -410,7 +410,7 @@ GLSLCombiner::GLSLCombiner(Combiner *_color, Combiner *_alpha) { strcat(fragment_shader, " if (!alpha_test(gl_FragColor.a)) discard; \n"); if (OGL.bImageTexture) { - if (g_bN64DepthCompare) + if (config.frameBufferEmulation.N64DepthCompare) strcat(fragment_shader, " if (!depth_compare()) discard; \n"); else strcat(fragment_shader, " depth_compare(); \n"); diff --git a/OpenGL.cpp b/OpenGL.cpp index 59b27e7b..1999f563 100644 --- a/OpenGL.cpp +++ b/OpenGL.cpp @@ -192,7 +192,7 @@ void OGL_InitStates() glDepthMask( GL_FALSE ); glEnable( GL_SCISSOR_TEST ); - if (g_bN64DepthCompare) { + if (config.frameBufferEmulation.N64DepthCompare) { glDisable( GL_DEPTH_TEST ); glDisable( GL_POLYGON_OFFSET_FILL ); glDepthFunc( GL_ALWAYS ); @@ -608,7 +608,7 @@ void OGL_UpdateStates() else Combiner_SetCombine(gDP.combine.mux); - if (!g_bN64DepthCompare && (gDP.changed & CHANGED_RENDERMODE) != 0) { + if (!config.frameBufferEmulation.N64DepthCompare && (gDP.changed & CHANGED_RENDERMODE) != 0) { if (gDP.otherMode.depthCompare) { glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); diff --git a/RSP.cpp b/RSP.cpp index 4b325756..79fc6a13 100644 --- a/RSP.cpp +++ b/RSP.cpp @@ -8,6 +8,7 @@ #include "FrameBuffer.h" #include "DepthBuffer.h" #include "GBI.h" +#include "Config.h" RSPInfo RSP; @@ -211,9 +212,9 @@ void RSP_ProcessDList() GBI.cmd[RSP.cmd]( w0, w1 ); } - if (g_bCopyToRDRAM) + if (config.frameBufferEmulation.copyToRDRAM) FrameBuffer_CopyToRDRAM( gDP.colorImage.address, false ); - if (g_bCopyDepthToRDRAM) + if (config.frameBufferEmulation.copyDepthToRDRAM) FrameBuffer_CopyDepthBuffer( gDP.colorImage.address ); RSP.busy = FALSE; diff --git a/VI.cpp b/VI.cpp index d6690cd3..3e85c080 100644 --- a/VI.cpp +++ b/VI.cpp @@ -57,7 +57,7 @@ void VI_UpdateScreen() VI.vStart = VI.vEnd = 0; if (config.frameBufferEmulation.enable) { - const bool bCFB = !g_bIgnoreCFB && (gSP.changed&CHANGED_CPU_FB_WRITE) == CHANGED_CPU_FB_WRITE; + const bool bCFB = !config.frameBufferEmulation.ignoreCFB && (gSP.changed&CHANGED_CPU_FB_WRITE) == CHANGED_CPU_FB_WRITE; const bool bNeedUpdate = bCFB ? true : (*REG.VI_ORIGIN != VI.lastOrigin);// && gDP.colorImage.changed; if (bNeedUpdate) { @@ -69,9 +69,9 @@ void VI_UpdateScreen() if (VI.height > 0 && size > G_IM_SIZ_8b) FrameBuffer_SaveBuffer( *REG.VI_ORIGIN, G_IM_FMT_RGBA, size, *REG.VI_WIDTH, VI.height ); } - if ((((*REG.VI_STATUS)&3) > 0) && (g_bCopyFromRDRAM || bCFB)) { + if ((((*REG.VI_STATUS)&3) > 0) && (config.frameBufferEmulation.copyFromRDRAM || bCFB)) { VI_UpdateSize(); - FrameBuffer_CopyFromRDRAM( *REG.VI_ORIGIN, g_bCopyFromRDRAM && !bCFB ); + FrameBuffer_CopyFromRDRAM( *REG.VI_ORIGIN, config.frameBufferEmulation.copyFromRDRAM && !bCFB ); } FrameBuffer_RenderBuffer( *REG.VI_ORIGIN );