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
This commit is contained in:
sl1nk3.s 2009-08-08 05:47:08 +00:00
parent 51ddedf512
commit 69f32a76c6
7 changed files with 56 additions and 33 deletions

View File

@ -604,9 +604,9 @@ void Callback_VideoCopiedToXFB(bool video_update)
static u32 videoupd = 0; static u32 videoupd = 0;
if (video_update) if (video_update)
videoupd += Frame::FrameSkippingFactor() + 1; videoupd++;
else else
frames += Frame::FrameSkippingFactor() + 1; frames++;
// Custom frame limiter // Custom frame limiter
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

View File

@ -19,6 +19,9 @@
#include "Core.h" #include "Core.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "Thread.h"
Common::CriticalSection cs_frameSkip;
namespace Frame { namespace Frame {
@ -27,7 +30,7 @@ bool g_bAutoFire = false;
u32 g_autoFirstKey = 0, g_autoSecondKey = 0; u32 g_autoFirstKey = 0, g_autoSecondKey = 0;
bool g_bFirstKey = true; bool g_bFirstKey = true;
int g_framesToSkip = 1, g_frameSkipCounter = 0; int g_framesToSkip = 0, g_frameSkipCounter = 0;
void FrameUpdate() { void FrameUpdate() {
if (g_bFrameStep) if (g_bFrameStep)
@ -38,19 +41,26 @@ void FrameUpdate() {
if (g_framesToSkip) if (g_framesToSkip)
FrameSkipping(); FrameSkipping();
else
CPluginManager::GetInstance().GetVideo()->Video_SetRendering(true);
} }
void SetFrameSkipping(unsigned int framesToSkip) { void SetFrameSkipping(unsigned int framesToSkip) {
cs_frameSkip.Enter();
g_framesToSkip = (int)framesToSkip; g_framesToSkip = (int)framesToSkip;
g_frameSkipCounter = 0; g_frameSkipCounter = 0;
cs_frameSkip.Leave();
} }
int FrameSkippingFactor() { int FrameSkippingFactor() {
return g_framesToSkip; return g_framesToSkip;
} }
void SetAutoHold(bool bEnabled, u32 keyToHold) { void SetAutoHold(bool bEnabled, u32 keyToHold)
{
g_bAutoFire = bEnabled; g_bAutoFire = bEnabled;
if (bEnabled) if (bEnabled)
g_autoFirstKey = g_autoSecondKey = keyToHold; g_autoFirstKey = g_autoSecondKey = keyToHold;
@ -58,7 +68,8 @@ void SetAutoHold(bool bEnabled, u32 keyToHold) {
g_autoFirstKey = g_autoSecondKey = 0; g_autoFirstKey = g_autoSecondKey = 0;
} }
void SetAutoFire(bool bEnabled, u32 keyOne, u32 keyTwo) { void SetAutoFire(bool bEnabled, u32 keyOne, u32 keyTwo)
{
g_bAutoFire = bEnabled; g_bAutoFire = bEnabled;
if (bEnabled) { if (bEnabled) {
g_autoFirstKey = keyOne; g_autoFirstKey = keyOne;
@ -77,7 +88,8 @@ void SetFrameStepping(bool bEnabled) {
g_bFrameStep = bEnabled; g_bFrameStep = bEnabled;
} }
void ModifyController(SPADStatus *PadStatus) { void ModifyController(SPADStatus *PadStatus)
{
u32 keyToPress = (g_bFirstKey) ? g_autoFirstKey : g_autoSecondKey; u32 keyToPress = (g_bFirstKey) ? g_autoFirstKey : g_autoSecondKey;
if (!keyToPress) if (!keyToPress)
@ -106,12 +118,17 @@ void ModifyController(SPADStatus *PadStatus) {
} }
void FrameSkipping() { void FrameSkipping()
{
cs_frameSkip.Enter();
g_frameSkipCounter++; g_frameSkipCounter++;
if (g_frameSkipCounter > g_framesToSkip) if (g_frameSkipCounter > g_framesToSkip)
g_frameSkipCounter = 0; g_frameSkipCounter = 0;
CPluginManager::GetInstance().GetVideo()->Video_SetRendering(!g_frameSkipCounter); CPluginManager::GetInstance().GetVideo()->Video_SetRendering(!g_frameSkipCounter);
cs_frameSkip.Leave();
} }
}; };

View File

@ -831,7 +831,9 @@ void CFrame::UpdateGUI()
GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(running || paused); GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(running || paused);
m_pSubMenuLoad->Enable(initialized); m_pSubMenuLoad->Enable(initialized);
m_pSubMenuSave->Enable(initialized); m_pSubMenuSave->Enable(initialized);
m_pSubMenuFrameSkipping->Enable(initialized);
// Let's enable it by default.
//m_pSubMenuFrameSkipping->Enable(initialized);
// Misc // Misc
GetMenuBar()->FindItem(IDM_CHANGEDISC)->Enable(initialized); GetMenuBar()->FindItem(IDM_CHANGEDISC)->Enable(initialized);

View File

@ -49,9 +49,9 @@ void CUCode_Zelda::AFCdecodebuffer(const s16 *coef, const char *input, signed sh
} }
else else
{ {
// untested !!! i havnt seen such a sample yet :) // 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
ERROR_LOG(DSPHLE, "Untested AFC sample"); DEBUG_LOG(DSPHLE, "5 bits AFC sample");
for (int i = 0; i < 16; i += 4) for (int i = 0; i < 16; i += 4)
{ {

View File

@ -473,9 +473,7 @@ void CUCode_Zelda::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _Righ
// First jump table at ZWW: 2a6 // First jump table at ZWW: 2a6
switch (PB.Format) switch (PB.Format)
{ {
case 0x0005: // AFC with extra low bitrate (32:5 compression). Not yet seen. case 0x0005: // AFC with extra low bitrate (32:5 compression).
WARN_LOG(DSPHLE, "5 byte AFC - does it work?");
case 0x0009: // AFC with normal bitrate (32:9 compression). case 0x0009: // AFC with normal bitrate (32:9 compression).
RenderVoice_AFC(PB, m_ResampleBuffer + 4, _Size); RenderVoice_AFC(PB, m_ResampleBuffer + 4, _Size);
Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true); Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true);

View File

@ -795,23 +795,18 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
{ {
s_skipSwap = g_bSkipCurrentFrame; 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 // If we're about to write to a requested XFB, make sure the previous
// contents make it to the screen first. // contents make it to the screen first.
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight); VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
s_framebufferManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
#else
s_framebufferManager.CopyToXFB(xfbAddr, fbWidth, fbHeight, sourceRc); 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 // XXX: Without the VI, how would we know what kind of field this is? So
// just use progressive. // just use progressive.
Renderer::Swap(xfbAddr, FIELD_PROGRESSIVE, fbWidth, fbHeight); 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 #endif
} }

View File

@ -106,6 +106,7 @@ static bool s_PluginInitialized = false;
static u32 s_swapRequested = FALSE; static u32 s_swapRequested = FALSE;
static u32 s_efbAccessRequested = FALSE; static u32 s_efbAccessRequested = FALSE;
static bool ForceSwap = true;
void GetDllInfo (PLUGIN_INFO* _PluginInfo) void GetDllInfo (PLUGIN_INFO* _PluginInfo)
{ {
@ -467,11 +468,17 @@ void VideoFifo_CheckSwapRequest()
{ {
#ifdef XXX_ENABLE_CPU_CONTROLLED_SWAPPING #ifdef XXX_ENABLE_CPU_CONTROLLED_SWAPPING
Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight); Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight);
#else
// TODO: Find better name for this because I don't know if it means what it says. if (ForceSwap)
g_VideoInitialize.pCopiedToXFB(true); {
Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight);
g_VideoInitialize.pCopiedToXFB(false);
}
#endif #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); 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) // Run from the graphics thread (from Fifo.cpp)
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight) void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
{ {
#ifdef XXX_ENABLE_CPU_CONTROLLED_SWAPPING
if (Common::AtomicLoadAcquire(s_swapRequested)) if (Common::AtomicLoadAcquire(s_swapRequested))
{ {
u32 aLower = xfbAddr; u32 aLower = xfbAddr;
@ -494,6 +502,9 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
if (addrRangesOverlap(aLower, aUpper, bLower, bUpper)) if (addrRangesOverlap(aLower, aUpper, bLower, bUpper))
VideoFifo_CheckSwapRequest(); VideoFifo_CheckSwapRequest();
} }
#else
ForceSwap = false;
#endif
} }
// Run from the CPU thread (from VideoInterface.cpp) // Run from the CPU thread (from VideoInterface.cpp)