From 3d55b086ee9d272888e7bf9cd1d2fcf443302f7a Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Wed, 8 Apr 2015 19:11:32 +0600 Subject: [PATCH] Add new fb validity check method: by checksum. It is more safe than filling RDRAM with fillcolor, but not compatible with Mario Tennis. Thus it is made optional. Fixed Perfect Dark - Crash often #323 --- Config.cpp | 2 ++ Config.h | 1 + FrameBuffer.cpp | 10 ++++++++-- mupenplus/Config_mupenplus.cpp | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Config.cpp b/Config.cpp index 9ef2941d..02739181 100644 --- a/Config.cpp +++ b/Config.cpp @@ -36,6 +36,8 @@ void Config::resetToDefaults() frameBufferEmulation.copyToRDRAM = 1; frameBufferEmulation.detectCFB = 0; frameBufferEmulation.N64DepthCompare = 0; + frameBufferEmulation.aspect = 1; + frameBufferEmulation.validityCheckMethod = 0; textureFilter.txCacheSize = 100 * gc_uMegabyte; textureFilter.txDump = 0; diff --git a/Config.h b/Config.h index 69dc324c..d40937e3 100644 --- a/Config.h +++ b/Config.h @@ -53,6 +53,7 @@ struct Config u32 detectCFB; u32 N64DepthCompare; u32 aspect; // 0: stretch ; 1: 4/3 ; 2: 16/9 + u32 validityCheckMethod; // 0: checksum; 1: fill RDRAM } frameBufferEmulation; struct diff --git a/FrameBuffer.cpp b/FrameBuffer.cpp index 2de1f6f4..0f88a0d0 100644 --- a/FrameBuffer.cpp +++ b/FrameBuffer.cpp @@ -364,8 +364,12 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt if (m_pCurrent->m_width == VI.width) gDP.colorImage.height = min(gDP.colorImage.height, VI.height); m_pCurrent->m_endAddress = min(RDRAMSize, m_pCurrent->m_startAddress + (((m_pCurrent->m_width * gDP.colorImage.height) << m_pCurrent->m_size >> 1) - 1)); - if (!config.frameBufferEmulation.copyFromRDRAM && !bMarioTennisScoreboard && !m_pCurrent->m_isDepthBuffer && m_pCurrent->m_RdramCrc == 0 && !m_pCurrent->m_cfb && !m_pCurrent->m_cleared && gDP.colorImage.height > 1) - gDPFillRDRAM(m_pCurrent->m_startAddress, 0, 0, m_pCurrent->m_width, gDP.colorImage.height, m_pCurrent->m_width, m_pCurrent->m_size, m_pCurrent->m_fillcolor, false); + if (!config.frameBufferEmulation.copyFromRDRAM && !bMarioTennisScoreboard && !m_pCurrent->m_isDepthBuffer && m_pCurrent->m_RdramCrc == 0 && !m_pCurrent->m_cfb && !m_pCurrent->m_cleared && gDP.colorImage.height > 1) { + if (config.frameBufferEmulation.validityCheckMethod == 0) + m_pCurrent->m_RdramCrc = textureCRC(RDRAM + m_pCurrent->m_startAddress, m_pCurrent->m_height, m_pCurrent->m_width << m_pCurrent->m_size >> 1); + else + gDPFillRDRAM(m_pCurrent->m_startAddress, 0, 0, m_pCurrent->m_width, gDP.colorImage.height, m_pCurrent->m_width, m_pCurrent->m_size, m_pCurrent->m_fillcolor, false); + } } m_pCurrent = _findBuffer(m_pCurrent->m_startAddress, m_pCurrent->m_endAddress, m_pCurrent->m_width); } @@ -397,6 +401,8 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt m_pCurrent->m_pResolveTexture->format = _format; m_pCurrent->m_pResolveTexture->size = _size; } + if (m_pCurrent->m_RdramCrc != 0) + m_pCurrent->m_RdramCrc = textureCRC(RDRAM + m_pCurrent->m_startAddress, m_pCurrent->m_height, m_pCurrent->m_width << m_pCurrent->m_size >> 1); } } } diff --git a/mupenplus/Config_mupenplus.cpp b/mupenplus/Config_mupenplus.cpp index c724a1a4..8cac75c8 100644 --- a/mupenplus/Config_mupenplus.cpp +++ b/mupenplus/Config_mupenplus.cpp @@ -76,6 +76,8 @@ bool Config_SetDefault() assert(res == M64ERR_SUCCESS); res = ConfigSetDefaultBool(g_configVideoGliden64, "EnableN64DepthCompare", 0, "Enable N64 depth compare instead of OpenGL standard one. Experimental."); assert(res == M64ERR_SUCCESS); + res = ConfigSetDefaultBool(g_configVideoGliden64, "ValidityCheckMethod", 0, "Method to check validity of texture frame buffer (0=by checksum, 1=fill RDRAM."); + assert(res == M64ERR_SUCCESS); //#Texture filter settings res = ConfigSetDefaultInt(g_configVideoGliden64, "txFilterMode", 0, "Texture filter (0=none, 1=Smooth filtering 1, 2=Smooth filtering 2, 3=Smooth filtering 3, 4=Smooth filtering 4, 5=Sharp filtering 1, 6=Sharp filtering 2)"); assert(res == M64ERR_SUCCESS); @@ -161,6 +163,7 @@ void Config_LoadConfig() config.frameBufferEmulation.copyFromRDRAM = ConfigGetParamBool(g_configVideoGliden64, "EnableCopyColorFromRDRAM"); config.frameBufferEmulation.detectCFB = ConfigGetParamBool(g_configVideoGliden64, "EnableDetectCFB"); config.frameBufferEmulation.N64DepthCompare = ConfigGetParamBool(g_configVideoGliden64, "EnableN64DepthCompare"); + config.frameBufferEmulation.validityCheckMethod = ConfigGetParamBool(g_configVideoGliden64, "ValidityCheckMethod"); config.generalEmulation.hacks = 0; //#Texture filter settings config.textureFilter.txFilterMode = ConfigGetParamInt(g_configVideoGliden64, "txFilterMode");