From d6b86232e09c9ea334c685934598388b060a306b Mon Sep 17 00:00:00 2001 From: death2droid Date: Sat, 23 May 2009 02:47:11 +0000 Subject: [PATCH] Add's a little hack to try and reduce flicking in some games. Can also break some games or cause them to have flickering so I made it so it can be turned on and off :P Original fix by orbb then modified by LuisR14 and me. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3274 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Plugins/Plugin_VideoOGL/Src/Config.cpp | 4 ++- Source/Plugins/Plugin_VideoOGL/Src/Config.h | 1 + .../Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp | 15 ++++++--- .../Plugin_VideoOGL/Src/GUI/ConfigDlg.h | 2 ++ Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 32 ++++++++++++++++++- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp index 08620be4b5..aa2a23c3a0 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp @@ -81,6 +81,7 @@ void Config::Load() iniFile.Get("Hacks", "EFBCopyDisable", &bEFBCopyDisable, 0); iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0); iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToRAM, 0); + iniFile.Get("Hacks", "RemoveFlicker", &bRemoveFlicker, 0); } void Config::GameIniLoad() { @@ -117,7 +118,6 @@ void Config::GameIniLoad() { if (iniFile->Exists("Video", "Hack")) iniFile->Get("Video", "Hack", &iPhackvalue, 0); - } void Config::Save() @@ -167,6 +167,8 @@ void Config::Save() iniFile.Set("Hacks", "EFBCopyDisableHotKey", bEFBCopyDisableHotKey); iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToRAM); + iniFile.Set("Hacks", "RemoveFlicker", bRemoveFlicker); + iniFile.Save(FULL_CONFIG_DIR "gfx_opengl.ini"); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.h b/Source/Plugins/Plugin_VideoOGL/Src/Config.h index 37ebb0a2e9..3150655666 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.h @@ -100,6 +100,7 @@ struct Config bool bPhackvalue1, bPhackvalue2; float fhackvalue1, fhackvalue2; bool bProjHack1; + bool bRemoveFlicker; int iLog; // CONF_ bits int iSaveTargetId; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index 1e817a0ac4..fe978cf061 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -62,7 +62,7 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_CHECKBOX(ID_DISABLETEXTURING, ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_DISABLEFOG, ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_EFBCOPYDISABLEHOTKEY, ConfigDialog::AdvancedSettingsChanged) - //EVT_CHECKBOX(ID_PROJECTIONHACK1,ConfigDialog::AdvancedSettingsChanged) + EVT_CHECKBOX(ID_REMOVEFLICKER, ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_HACK, ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_SAFETEXTURECACHE,ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_DSTALPHAPASS,ConfigDialog::AdvancedSettingsChanged) @@ -364,7 +364,7 @@ void ConfigDialog::CreateGUIControls() // Hacks controls m_SafeTextureCache = new wxCheckBox(m_PageAdvanced, ID_SAFETEXTURECACHE, wxT("Use Safe texture cache"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - + m_RemoveFlicker = new wxCheckBox(m_PageAdvanced, ID_REMOVEFLICKER, wxT("Remove Flicker"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_PhackvalueCB = new wxChoice(m_PageAdvanced, ID_PHACKVALUE, wxDefaultPosition, wxDefaultSize, arrayStringFor_PhackvalueCB, 0, wxDefaultValidator); m_PhackvalueCB->Append(wxT("None")); m_PhackvalueCB->Append(wxT("Zelda Twilight Princess Bloom hack")); @@ -377,19 +377,23 @@ void ConfigDialog::CreateGUIControls() // Default values m_SafeTextureCache->SetValue(g_Config.bSafeTextureCache); + m_RemoveFlicker->SetValue(g_Config.bRemoveFlicker); // Tool tips m_SafeTextureCache->SetToolTip(wxT("This is useful to prevent Metroid Prime from crashing, but can cause problems in other games." "\n[This option will apply immediately and does not require a restart. However it may not" " be entirely safe to change it midgames.]")); - m_DstAlphaPass->SetToolTip(wxT("This renders a second time to set alpha to a constant value," + m_RemoveFlicker->SetToolTip(wxT("This is used to try and removing flickering in some games.")); + + m_DstAlphaPass->SetToolTip(wxT("This renders a second time to set alpha to a constant value," "\nDisabling it may speed up some games, but could also cause glitches.")); m_DisableFog->SetToolTip(wxT("This option should not require a restart.")); // Sizers sHacks = new wxGridBagSizer(0, 0); sHacks->Add(m_SafeTextureCache, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALL, 5); + sHacks->Add(m_RemoveFlicker,wxGBPosition(1, 1),wxGBSpan(1, 1), wxALL, 5); sHacks->Add(m_PhackvalueCB, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5); sbHacks = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Hacks")); @@ -520,7 +524,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) g_Config.iPhackvalue = m_PhackvalueCB->GetSelection(); if (g_Config.iPhackvalue >= 0) { - g_Config.UpdateHack(); + g_Config.UpdateHack(); } break; } @@ -596,6 +600,9 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event) case ID_SAFETEXTURECACHE: g_Config.bSafeTextureCache = m_SafeTextureCache->IsChecked(); break; + case ID_REMOVEFLICKER: + g_Config.bRemoveFlicker = m_RemoveFlicker->IsChecked(); + break; case ID_HACK: g_Config.bHack = m_Hack->IsChecked(); break; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h index e77dd4ada6..1d1cb90050 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h @@ -119,6 +119,7 @@ class ConfigDialog : public wxDialog wxCheckBox *m_DumpTextures; wxCheckBox *m_HiresTextures; wxCheckBox *m_DumpEFBTarget; + wxCheckBox *m_RemoveFlicker; wxCheckBox *m_DumpFrames; wxCheckBox *m_FreeLook; wxStaticBox * m_StaticBox_EFB; @@ -184,6 +185,7 @@ class ConfigDialog : public wxDialog ID_DUMPFRAMES, ID_FREELOOK, ID_TEXTUREPATH, + ID_REMOVEFLICKER, ID_CHECKBOX_DISABLECOPYEFB, ID_EFBCOPYDISABLEHOTKEY, diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 82327c6086..8b151ffc5c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1218,7 +1218,37 @@ void Renderer::SwapBuffers() } #endif // Copy the rendered frame to the real window - OpenGL_SwapBuffers(); + // [ fix for Fragile by kamui_kun ... + // TODO get the fix to read the whole screen not just 5 pixels + if (g_Config.bRemoveFlicker) + { + BOOL pass = FALSE; + char pixels [15]; + short color[] = {GL_RED, GL_GREEN, GL_BLUE}; + + for( int i = 0; i < 14; i) + { + for( int c = 0; c < 3; c++,i+=5) + { + glReadPixels(300, 200, 1, 1, color[c], GL_BYTE, &pixels[i]); + glReadPixels(300, 400, 1, 1, color[c], GL_BYTE, &pixels[i+1]); + glReadPixels(700, 200, 1, 1, color[c], GL_BYTE, &pixels[i+2]); + glReadPixels(700, 400, 1, 1, color[c], GL_BYTE, &pixels[i+3]); + glReadPixels(500, 300, 1, 1, color[c], GL_BYTE, &pixels[i+4]); + } + } + for( int p = 0; p < 14; p++ ) + { + if( pixels[p] != 0 ) + pass = TRUE; + } + if( pass ) + OpenGL_SwapBuffers(); + } + else + { + OpenGL_SwapBuffers(); + } glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT);