From 69f32a76c6c1a12c3f0aa6b2007e3a98fc9a8a9f Mon Sep 17 00:00:00 2001 From: "sl1nk3.s" Date: Sat, 8 Aug 2009 05:47:08 +0000 Subject: [PATCH] Just a few fixes for the fps counter, also unbreak direct XFB homebrews. And a couple of fixes for the frameskip : disabled by default, can be set before launching a game, also safer to avoid lockup. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3950 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Core.cpp | 4 +- Source/Core/Core/Src/OnFrame.cpp | 41 +++++++++++++------ Source/Core/DolphinWX/Src/FrameTools.cpp | 4 +- .../Src/UCodes/UCode_Zelda_ADPCM.cpp | 6 +-- .../Src/UCodes/UCode_Zelda_Voice.cpp | 4 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 13 ++---- Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 17 ++++++-- 7 files changed, 56 insertions(+), 33 deletions(-) diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index d456c300b3..72831b4e0a 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -604,9 +604,9 @@ void Callback_VideoCopiedToXFB(bool video_update) static u32 videoupd = 0; if (video_update) - videoupd += Frame::FrameSkippingFactor() + 1; + videoupd++; else - frames += Frame::FrameSkippingFactor() + 1; + frames++; // Custom frame limiter // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ diff --git a/Source/Core/Core/Src/OnFrame.cpp b/Source/Core/Core/Src/OnFrame.cpp index 62a1225137..36c43123e8 100644 --- a/Source/Core/Core/Src/OnFrame.cpp +++ b/Source/Core/Core/Src/OnFrame.cpp @@ -19,6 +19,9 @@ #include "Core.h" #include "PluginManager.h" +#include "Thread.h" + +Common::CriticalSection cs_frameSkip; namespace Frame { @@ -27,40 +30,48 @@ bool g_bAutoFire = false; u32 g_autoFirstKey = 0, g_autoSecondKey = 0; bool g_bFirstKey = true; -int g_framesToSkip = 1, g_frameSkipCounter = 0; +int g_framesToSkip = 0, g_frameSkipCounter = 0; void FrameUpdate() { - if(g_bFrameStep) + if (g_bFrameStep) Core::SetState(Core::CORE_PAUSE); - if(g_bAutoFire) + if (g_bAutoFire) g_bFirstKey = !g_bFirstKey; - if(g_framesToSkip) + if (g_framesToSkip) FrameSkipping(); + else + CPluginManager::GetInstance().GetVideo()->Video_SetRendering(true); } void SetFrameSkipping(unsigned int framesToSkip) { + cs_frameSkip.Enter(); + g_framesToSkip = (int)framesToSkip; g_frameSkipCounter = 0; + + cs_frameSkip.Leave(); } int FrameSkippingFactor() { return g_framesToSkip; } -void SetAutoHold(bool bEnabled, u32 keyToHold) { +void SetAutoHold(bool bEnabled, u32 keyToHold) +{ g_bAutoFire = bEnabled; - if(bEnabled) + if (bEnabled) g_autoFirstKey = g_autoSecondKey = keyToHold; else g_autoFirstKey = g_autoSecondKey = 0; } -void SetAutoFire(bool bEnabled, u32 keyOne, u32 keyTwo) { +void SetAutoFire(bool bEnabled, u32 keyOne, u32 keyTwo) +{ g_bAutoFire = bEnabled; - if(bEnabled) { + if (bEnabled) { g_autoFirstKey = keyOne; g_autoSecondKey = keyTwo; } else @@ -77,10 +88,11 @@ void SetFrameStepping(bool bEnabled) { g_bFrameStep = bEnabled; } -void ModifyController(SPADStatus *PadStatus) { +void ModifyController(SPADStatus *PadStatus) +{ u32 keyToPress = (g_bFirstKey) ? g_autoFirstKey : g_autoSecondKey; - if(!keyToPress) + if (!keyToPress) return; PadStatus->button |= keyToPress; @@ -106,12 +118,17 @@ void ModifyController(SPADStatus *PadStatus) { } -void FrameSkipping() { +void FrameSkipping() +{ + cs_frameSkip.Enter(); + g_frameSkipCounter++; - if(g_frameSkipCounter > g_framesToSkip) + if (g_frameSkipCounter > g_framesToSkip) g_frameSkipCounter = 0; CPluginManager::GetInstance().GetVideo()->Video_SetRendering(!g_frameSkipCounter); + + cs_frameSkip.Leave(); } }; diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index f3d8880a9c..ec2c74aeae 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -831,7 +831,9 @@ void CFrame::UpdateGUI() GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(running || paused); m_pSubMenuLoad->Enable(initialized); m_pSubMenuSave->Enable(initialized); - m_pSubMenuFrameSkipping->Enable(initialized); + + // Let's enable it by default. + //m_pSubMenuFrameSkipping->Enable(initialized); // Misc GetMenuBar()->FindItem(IDM_CHANGEDISC)->Enable(initialized); diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_ADPCM.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_ADPCM.cpp index 5bba093aec..f5b6eff99c 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_ADPCM.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_ADPCM.cpp @@ -49,9 +49,9 @@ void CUCode_Zelda::AFCdecodebuffer(const s16 *coef, const char *input, signed sh } else { - // untested !!! i havnt seen such a sample yet :) - - ERROR_LOG(DSPHLE, "Untested AFC sample"); + // In Pikmin, Dolphin's engine sound is using AFC 5bits, even though such a sound is hard + // to compare, it seems like to sound exactly like a real GC + DEBUG_LOG(DSPHLE, "5 bits AFC sample"); for (int i = 0; i < 16; i += 4) { diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp index 3186e42f36..ca95943573 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_Zelda_Voice.cpp @@ -473,9 +473,7 @@ void CUCode_Zelda::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _Righ // First jump table at ZWW: 2a6 switch (PB.Format) { - case 0x0005: // AFC with extra low bitrate (32:5 compression). Not yet seen. - WARN_LOG(DSPHLE, "5 byte AFC - does it work?"); - + case 0x0005: // AFC with extra low bitrate (32:5 compression). case 0x0009: // AFC with normal bitrate (32:9 compression). RenderVoice_AFC(PB, m_ResampleBuffer + 4, _Size); Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 285ae6621c..8f01808c67 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -795,23 +795,18 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect { s_skipSwap = g_bSkipCurrentFrame; - g_VideoInitialize.pCopiedToXFB(false); - -#ifdef XXX_ENABLE_CPU_CONTROLLED_SWAPPING // If we're about to write to a requested XFB, make sure the previous // contents make it to the screen first. VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight); - - s_framebufferManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc); -#else s_framebufferManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc); + // TODO: Find better name for this because I don't know if it means what it says. + g_VideoInitialize.pCopiedToXFB(false); + +#ifndef XXX_ENABLE_CPU_CONTROLLED_SWAPPING // XXX: Without the VI, how would we know what kind of field this is? So // just use progressive. Renderer::Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight); - - // TODO: Find better name for this because I don't know if it means what it says. - g_VideoInitialize.pCopiedToXFB(true); #endif } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 1b149b5c24..29984b1a73 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -106,6 +106,7 @@ static bool s_PluginInitialized = false; static u32 s_swapRequested = FALSE; static u32 s_efbAccessRequested = FALSE; +static bool ForceSwap = true; void GetDllInfo (PLUGIN_INFO* _PluginInfo) { @@ -467,11 +468,17 @@ void VideoFifo_CheckSwapRequest() { #ifdef XXX_ENABLE_CPU_CONTROLLED_SWAPPING Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); - - // TODO: Find better name for this because I don't know if it means what it says. - g_VideoInitialize.pCopiedToXFB(true); +#else + if (ForceSwap) + { + Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); + g_VideoInitialize.pCopiedToXFB(false); + } #endif + // TODO : This just updates the frame counter, so we may change this func's name as well + g_VideoInitialize.pCopiedToXFB(true); + Common::AtomicStoreRelease(s_swapRequested, FALSE); } } @@ -484,6 +491,7 @@ inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper) // Run from the graphics thread (from Fifo.cpp) void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight) { +#ifdef XXX_ENABLE_CPU_CONTROLLED_SWAPPING if (Common::AtomicLoadAcquire(s_swapRequested)) { u32 aLower = xfbAddr; @@ -494,6 +502,9 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight) if (addrRangesOverlap(aLower, aUpper, bLower, bUpper)) VideoFifo_CheckSwapRequest(); } +#else + ForceSwap = false; +#endif } // Run from the CPU thread (from VideoInterface.cpp)