Allow clock throttle to take over for audio / vsync throttles during fast forward or rewind for proper speed control.
This commit is contained in:
parent
f9da63d71d
commit
28f1ad1c0e
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -159,65 +159,62 @@ 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);
|
||||||
|
int line = 1;
|
||||||
|
if (Global.Config.StackOSDMessages)
|
||||||
{
|
{
|
||||||
messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
|
for (int i = messages.Count - 1; i >= 0; i--, line++)
|
||||||
int line = 1;
|
|
||||||
if (Global.Config.StackOSDMessages)
|
|
||||||
{
|
{
|
||||||
for (int i = messages.Count - 1; i >= 0; i--, line++)
|
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, messages[i].Message);
|
||||||
|
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, messages[i].Message);
|
||||||
|
if (Global.Config.DispMessageanchor < 2)
|
||||||
{
|
{
|
||||||
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, messages[i].Message);
|
y += ((line - 1) * 18);
|
||||||
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, messages[i].Message);
|
|
||||||
if (Global.Config.DispMessageanchor < 2)
|
|
||||||
{
|
|
||||||
y += ((line - 1) * 18);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
y -= ((line - 1) * 18);
|
|
||||||
}
|
|
||||||
|
|
||||||
g.DrawString(messages[i].Message, MessageFont, Color.Black, x + 2, y + 2);
|
|
||||||
g.DrawString(messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
y -= ((line - 1) * 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.DrawString(messages[i].Message, MessageFont, Color.Black, x + 2, y + 2);
|
||||||
|
g.DrawString(messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (messages.Any())
|
||||||
{
|
{
|
||||||
if (messages.Any())
|
int i = messages.Count - 1;
|
||||||
|
|
||||||
|
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, messages[i].Message);
|
||||||
|
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, messages[i].Message);
|
||||||
|
if (Global.Config.DispMessageanchor < 2)
|
||||||
{
|
{
|
||||||
int i = messages.Count - 1;
|
y += ((line - 1) * 18);
|
||||||
|
|
||||||
float x = GetX(g, Global.Config.DispMessagex, Global.Config.DispMessageanchor, messages[i].Message);
|
|
||||||
float y = GetY(g, Global.Config.DispMessagey, Global.Config.DispMessageanchor, messages[i].Message);
|
|
||||||
if (Global.Config.DispMessageanchor < 2)
|
|
||||||
{
|
|
||||||
y += ((line - 1) * 18);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
y -= ((line - 1) * 18);
|
|
||||||
}
|
|
||||||
|
|
||||||
g.DrawString(messages[i].Message, MessageFont, Color.Black, x + 2, y + 2);
|
|
||||||
g.DrawString(messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
y -= ((line - 1) * 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.DrawString(messages[i].Message, MessageFont, Color.Black, x + 2, y + 2);
|
||||||
|
g.DrawString(messages[i].Message, MessageFont, FixedMessagesColor, x, y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var text in GUITextList)
|
foreach (var text in GUITextList)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
float posx = GetX(g, text.X, text.Anchor, text.Message);
|
||||||
{
|
float posy = GetY(g, text.Y, text.Anchor, text.Message);
|
||||||
float posx = GetX(g, text.X, text.Anchor, text.Message);
|
|
||||||
float posy = GetY(g, text.Y, text.Anchor, text.Message);
|
|
||||||
|
|
||||||
g.DrawString(text.Message, MessageFont, text.BackGround, posx + 2, posy + 2);
|
g.DrawString(text.Message, MessageFont, text.BackGround, posx + 2, posy + 2);
|
||||||
g.DrawString(text.Message, MessageFont, text.ForeColor, posx, posy);
|
g.DrawString(text.Message, MessageFont, text.ForeColor, posx, posy);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -21,33 +21,21 @@ 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 Global.Config.FrameSkip;
|
||||||
{
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Global.Config.FrameSkip;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool cfg_frameLimit
|
public bool cfg_frameLimit
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Global.ClientControls["MaxTurbo"])
|
return Global.Config.ClockThrottle;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Global.Config.ClockThrottle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +43,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (Global.ClientControls["MaxTurbo"])
|
return Global.Config.AutoMinimizeSkipping;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Global.Config.AutoMinimizeSkipping;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue