Allow clock throttle to take over for audio / vsync throttles during fast forward or rewind for proper speed control.

This commit is contained in:
jdpurcell 2015-01-13 04:21:32 +00:00
parent f9da63d71d
commit 28f1ad1c0e
6 changed files with 60 additions and 88 deletions

View File

@ -18,9 +18,9 @@ namespace BizHawk.Client.Common
public static MovieSession MovieSession = new MovieSession(); public static MovieSession MovieSession = new MovieSession();
/// <summary> /// <summary>
/// whether throttling is force-disabled by use of fast forward /// Used to disable secondary throttling (e.g. vsync, audio) for unthrottled modes or when the primary (clock) throttle is taking over (e.g. during fast forward/rewind).
/// </summary> /// </summary>
public static bool ForceNoThrottle; public static bool DisableSecondaryThrottling;
public static Controller NullControls; public static Controller NullControls;
public static AutofireController AutofireNullControls; public static AutofireController AutofireNullControls;

View File

@ -633,7 +633,7 @@ TESTEROO:
//maybe the user wants vsync, but not vsync throttle. //maybe the user wants vsync, but not vsync throttle.
//this makes sense... but we dont have the infrastructure to support it now (we'd have to enable triple buffering or something like that) //this makes sense... but we dont have the infrastructure to support it now (we'd have to enable triple buffering or something like that)
//so what we're gonna do is disable vsync no matter what if throttling is off, and maybe nobody will notice. //so what we're gonna do is disable vsync no matter what if throttling is off, and maybe nobody will notice.
if (Global.ForceNoThrottle) if (Global.DisableSecondaryThrottling)
vsync = false; vsync = false;
if (LastVsyncSetting != vsync || LastVsyncSettingGraphicsControl != presentationPanel.GraphicsControl) if (LastVsyncSetting != vsync || LastVsyncSettingGraphicsControl != presentationPanel.GraphicsControl)

View File

@ -158,8 +158,6 @@ namespace BizHawk.Client.EmuHawk
} }
public void DrawMessages(IBlitter g) public void DrawMessages(IBlitter g)
{
if (!Global.ClientControls["MaxTurbo"])
{ {
messages.RemoveAll(m => DateTime.Now > m.ExpireAt); messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
int line = 1; int line = 1;
@ -220,7 +218,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
} }
}
public string InputStrMovie() public string InputStrMovie()
{ {

View File

@ -1651,30 +1651,26 @@ namespace BizHawk.Client.EmuHawk
private void SyncThrottle() private void SyncThrottle()
{ {
//TODO - this is a bit confusing. theres a difference between signal_unthrottle and Global.ForceNoThrottle. Isn't that kind of weird?
//someone should evaluate these different modes and clean that up.
//TODO - did we change 'unthrottled' nomenclature to turbo? is turbo defined as 'temporarily disable throttle entirely'? //TODO - did we change 'unthrottled' nomenclature to turbo? is turbo defined as 'temporarily disable throttle entirely'?
var rewind = Global.Rewinder.RewindActive && (Global.ClientControls["Rewind"] || PressRewind); var rewind = Global.Rewinder.RewindActive && (Global.ClientControls["Rewind"] || PressRewind);
var fastforward = Global.ClientControls["Fast Forward"] || FastForward; var fastForward = Global.ClientControls["Fast Forward"] || FastForward;
var superfastforward = IsTurboing; var superFastForward = IsTurboing;
int speedPercent = fastforward ? Global.Config.SpeedPercentAlternate : Global.Config.SpeedPercent; int speedPercent = fastForward ? Global.Config.SpeedPercentAlternate : Global.Config.SpeedPercent;
if (rewind) if (rewind)
{ {
speedPercent = Math.Max(speedPercent / Global.Rewinder.RewindFrequency, 5); speedPercent = Math.Max(speedPercent / Global.Rewinder.RewindFrequency, 5);
} }
//zero 11-oct-2014 - i think this is more correct.. Global.DisableSecondaryThrottling = _unthrottled || fastForward || superFastForward || rewind;
//Global.ForceNoThrottle = _unthrottled || fastforward;
Global.ForceNoThrottle = _unthrottled || fastforward || superfastforward;
// realtime throttle is never going to be so exact that using a double here is wrong // realtime throttle is never going to be so exact that using a double here is wrong
_throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate); _throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate);
_throttle.signal_paused = EmulatorPaused; _throttle.signal_paused = EmulatorPaused;
_throttle.signal_unthrottle = _unthrottled || superfastforward; _throttle.signal_unthrottle = _unthrottled || superFastForward;
_throttle.signal_overrideSecondaryThrottle = (fastForward || rewind) && (Global.Config.SoundThrottle || Global.Config.VSyncThrottle || Global.Config.VSync);
_throttle.SetSpeedPercent(speedPercent); _throttle.SetSpeedPercent(speedPercent);
} }

View File

@ -209,7 +209,7 @@ namespace BizHawk.Client.EmuHawk
samplesProvided = 2 * nsampgot; samplesProvided = 2 * nsampgot;
if (!Global.ForceNoThrottle) if (!Global.DisableSecondaryThrottling)
while (samplesNeeded < samplesProvided) while (samplesNeeded < samplesProvided)
{ {
System.Threading.Thread.Sleep((samplesProvided - samplesNeeded) / 88); // let audio clock control sleep time System.Threading.Thread.Sleep((samplesProvided - samplesNeeded) / 88); // let audio clock control sleep time

View File

@ -21,50 +21,31 @@ namespace BizHawk.Client.EmuHawk
public bool signal_frameAdvance; public bool signal_frameAdvance;
public bool signal_unthrottle; public bool signal_unthrottle;
public bool signal_continuousframeAdvancing; //continuousframeAdvancing public bool signal_continuousframeAdvancing; //continuousframeAdvancing
public bool signal_overrideSecondaryThrottle;
public int cfg_frameskiprate public int cfg_frameskiprate
{ {
get get
{
if (Global.ClientControls["MaxTurbo"])
{
return 20;
}
else
{ {
return Global.Config.FrameSkip; return Global.Config.FrameSkip;
} }
} }
}
public bool cfg_frameLimit public bool cfg_frameLimit
{ {
get get
{
if (Global.ClientControls["MaxTurbo"])
{
return false;
}
else
{ {
return Global.Config.ClockThrottle; return Global.Config.ClockThrottle;
} }
} }
}
public bool cfg_autoframeskipenab public bool cfg_autoframeskipenab
{ {
get get
{
if (Global.ClientControls["MaxTurbo"])
{
return false;
}
else
{ {
return Global.Config.AutoMinimizeSkipping; return Global.Config.AutoMinimizeSkipping;
} }
} }
}
public bool cfg_lowcpumode public bool cfg_lowcpumode
{ {
@ -116,7 +97,7 @@ namespace BizHawk.Client.EmuHawk
if (framestoskip < 1) if (framestoskip < 1)
framestoskip += ffSkipRate; framestoskip += ffSkipRate;
} }
else if ((signal_paused || /*autoframeskipenab && frameskiprate ||*/ cfg_frameLimit) && allowSleep) else if ((signal_paused || /*autoframeskipenab && frameskiprate ||*/ cfg_frameLimit || signal_overrideSecondaryThrottle) && allowSleep)
{ {
SpeedThrottle(signal_paused); SpeedThrottle(signal_paused);
} }
@ -160,7 +141,6 @@ namespace BizHawk.Client.EmuHawk
return (ulong)Environment.TickCount; return (ulong)Environment.TickCount;
} }
#if WINDOWS #if WINDOWS
[DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")] [DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")]
static extern uint timeBeginPeriod(uint uMilliseconds); static extern uint timeBeginPeriod(uint uMilliseconds);
@ -333,7 +313,6 @@ namespace BizHawk.Client.EmuHawk
return rv; return rv;
} }
void SpeedThrottle(bool paused) void SpeedThrottle(bool paused)
{ {
AutoFrameSkip_BeforeThrottle(); AutoFrameSkip_BeforeThrottle();