From 60f2b411b69642d187200724465670e2c88f7ef0 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 4 Sep 2011 05:18:38 +0000 Subject: [PATCH] dont vsync when fastforwarding or unthrottling --- BizHawk.MultiClient/Global.cs | 5 +++++ BizHawk.MultiClient/MainForm.cs | 5 ++++- BizHawk.MultiClient/RenderPanel.cs | 18 +++++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/BizHawk.MultiClient/Global.cs b/BizHawk.MultiClient/Global.cs index ab234964fc..2847bb1615 100644 --- a/BizHawk.MultiClient/Global.cs +++ b/BizHawk.MultiClient/Global.cs @@ -31,6 +31,11 @@ namespace BizHawk.MultiClient public static AutofireController AutofireGBControls; public static AutofireController AutofireGenControls; + /// + /// whether vsync is force-disabled by use of fast forward + /// + public static bool ForceNoVsync; + //the movie will be spliced inbetween these if it is present public static CopyControllerAdapter MovieInputSourceAdapter = new CopyControllerAdapter(); public static CopyControllerAdapter MovieOutputHardpoint = new CopyControllerAdapter(); diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index b446a64e7d..eb89715789 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -291,8 +291,11 @@ namespace BizHawk.MultiClient void SyncThrottle() { + bool fastforward = Global.ClientControls["Fast Forward"]; + Global.ForceNoVsync = unthrottled || fastforward; + throttle.signal_unthrottle = unthrottled; - if (Global.ClientControls["Fast Forward"]) + if (fastforward) throttle.SetSpeedPercent(Global.Config.SpeedPercentAlternate); else throttle.SetSpeedPercent(Global.Config.SpeedPercent); diff --git a/BizHawk.MultiClient/RenderPanel.cs b/BizHawk.MultiClient/RenderPanel.cs index 3c521da9d7..fce914b46c 100644 --- a/BizHawk.MultiClient/RenderPanel.cs +++ b/BizHawk.MultiClient/RenderPanel.cs @@ -158,6 +158,8 @@ namespace BizHawk.MultiClient private Sprite Sprite; private Font MessageFont; private Font AlertFont; + private bool Vsync; + public Direct3DRenderPanel(Direct3D direct3D, Control control) { @@ -202,15 +204,25 @@ namespace BizHawk.MultiClient } } + private bool VsyncRequested + { + get + { + if (Global.ForceNoVsync) return false; + return Global.Config.DisplayVSync; + } + } + public void CreateDevice() { DestroyDevice(); + Vsync = VsyncRequested; var pp = new PresentParameters { BackBufferWidth = Math.Max(1, backingControl.ClientSize.Width), BackBufferHeight = Math.Max(1, backingControl.ClientSize.Height), DeviceWindowHandle = backingControl.Handle, - PresentationInterval = Global.Config.DisplayVSync ? PresentInterval.One : PresentInterval.Immediate + PresentationInterval = Vsync ? PresentInterval.One : PresentInterval.Immediate }; var flags = CreateFlags.SoftwareVertexProcessing; @@ -229,7 +241,7 @@ namespace BizHawk.MultiClient public void Render() { - if (Device == null || Resized) + if (Device == null || Resized || Vsync != VsyncRequested) CreateDevice(); Resized = false; @@ -268,7 +280,7 @@ namespace BizHawk.MultiClient return; } - if (Device == null || Resized) + if (Device == null || Resized || Vsync != VsyncRequested) CreateDevice(); Resized = false;