Conditionally compile Windows code, make Throttle class portable, and add dummy input/audio implementations for non-Windows
This is (almost, bar some local resource hacks) enough to start the emulator on Linux/Mono, load a ROM and watch the demo (input and audio don't work yet).
This commit is contained in:
parent
1d111ce0ff
commit
e310e90d9f
|
@ -344,4 +344,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -35,13 +35,14 @@
|
|||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
<DefineConstants Condition=" '$(OS)' == 'Windows_NT' ">WINDOWS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>output\</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
|
@ -53,8 +54,6 @@
|
|||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>output\</OutputPath>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
|
@ -66,11 +65,11 @@
|
|||
<NoWin32Manifest>true</NoWin32Manifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86">
|
||||
<Reference Include="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\LuaInterface.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="Microsoft.VisualBasic" Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
<Reference Include="Newtonsoft.Json, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Newtonsoft.Json.dll</HintPath>
|
||||
|
@ -86,11 +85,11 @@
|
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Deployment" Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="SlimDX, Version=2.0.10.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9">
|
||||
<Reference Include="SlimDX, Version=2.0.10.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\SlimDX.dll</HintPath>
|
||||
</Reference>
|
||||
|
@ -166,7 +165,7 @@
|
|||
<Compile Include="Global.cs" />
|
||||
<Compile Include="HawkFile.cs" />
|
||||
<Compile Include="Input\ControllerBinding.cs" />
|
||||
<Compile Include="Input\GamePad.cs" />
|
||||
<Compile Include="Input\GamePad.cs" Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
<Compile Include="Input\Input.cs" />
|
||||
<Compile Include="LogConsole.cs" />
|
||||
<Compile Include="LogWindow.cs">
|
||||
|
@ -185,8 +184,8 @@
|
|||
<DependentUpon>EditCommentsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="movie\InputAdapters.cs" />
|
||||
<Compile Include="Input\Keyboard.cs" />
|
||||
<Compile Include="LuaImplementation.cs" />
|
||||
<Compile Include="Input\Keyboard.cs" Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
<Compile Include="LuaImplementation.cs" Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -373,18 +372,18 @@
|
|||
<Compile Include="tools\HexEditor.Designer.cs">
|
||||
<DependentUpon>HexEditor.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="tools\LuaConsole.cs">
|
||||
<Compile Include="tools\LuaConsole.cs" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tools\LuaConsole.Designer.cs">
|
||||
<Compile Include="tools\LuaConsole.Designer.cs" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<DependentUpon>LuaConsole.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="tools\LuaFiles.cs" />
|
||||
<Compile Include="tools\LuaText.cs" />
|
||||
<Compile Include="tools\LuaWindow.cs">
|
||||
<Compile Include="tools\LuaFiles.cs" Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
<Compile Include="tools\LuaText.cs" Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
<Compile Include="tools\LuaWindow.cs" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tools\LuaWindow.Designer.cs">
|
||||
<Compile Include="tools\LuaWindow.Designer.cs" Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<DependentUpon>LuaWindow.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="tools\MemoryViewer.cs">
|
||||
|
@ -760,4 +759,4 @@
|
|||
<PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">"$(SolutionDir)subwcrev.bat" "$(ProjectDir)"</PreBuildEvent>
|
||||
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)subwcrev.sh" "$(ProjectDir)"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
using BizHawk.DiscSystem;
|
||||
using System.Collections.Generic;
|
||||
#if WINDOWS
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX.DirectSound;
|
||||
#endif
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static MainForm MainForm;
|
||||
#if WINDOWS
|
||||
public static DirectSound DSound;
|
||||
public static Direct3D Direct3D;
|
||||
#endif
|
||||
public static Sound Sound;
|
||||
public static IRenderer RenderPanel;
|
||||
public static Config Config;
|
||||
|
@ -173,4 +177,4 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public static DiscHopper DiscHopper = new DiscHopper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ using System.Linq;
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
#if WINDOWS
|
||||
using SlimDX.DirectInput;
|
||||
#endif
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -54,15 +56,19 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private Input()
|
||||
{
|
||||
#if WINDOWS
|
||||
UpdateThread = new Thread(UpdateThreadProc);
|
||||
UpdateThread.IsBackground = true;
|
||||
UpdateThread.Start();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
#if WINDOWS
|
||||
KeyInput.Initialize();
|
||||
GamePad.Initialize();
|
||||
#endif
|
||||
Instance = new Input();
|
||||
}
|
||||
|
||||
|
@ -192,6 +198,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
#if WINDOWS
|
||||
void UpdateThreadProc()
|
||||
{
|
||||
for (; ; )
|
||||
|
@ -241,7 +248,7 @@ namespace BizHawk.MultiClient
|
|||
Thread.Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
|
|
@ -105,4 +105,4 @@ namespace BizHawk.MultiClient
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,9 @@ namespace BizHawk.MultiClient
|
|||
public ToolBox ToolBox1 = new ToolBox();
|
||||
public TI83KeyPad TI83KeyPad1 = new TI83KeyPad();
|
||||
public TAStudio TAStudio1 = new TAStudio();
|
||||
#if WINDOWS
|
||||
public LuaConsole LuaConsole1 = new LuaConsole();
|
||||
#endif
|
||||
|
||||
public MainForm(string[] args)
|
||||
{
|
||||
|
@ -139,7 +141,11 @@ namespace BizHawk.MultiClient
|
|||
Global.Emulator = new NullEmulator();
|
||||
Global.ActiveController = Global.NullControls;
|
||||
Global.AutoFireController = Global.AutofireNullControls;
|
||||
#if WINDOWS
|
||||
Global.Sound = new Sound(Handle, Global.DSound);
|
||||
#else
|
||||
Global.Sound = new Sound();
|
||||
#endif
|
||||
Global.Sound.StartSound();
|
||||
RewireInputChain();
|
||||
//TODO - replace this with some kind of standard dictionary-yielding parser in a separate component
|
||||
|
@ -262,10 +268,12 @@ namespace BizHawk.MultiClient
|
|||
|
||||
void SyncPresentationMode()
|
||||
{
|
||||
#if WINDOWS
|
||||
bool gdi = Global.Config.DisplayGDI;
|
||||
|
||||
if (Global.Direct3D == null)
|
||||
gdi = true;
|
||||
#endif
|
||||
|
||||
if (renderTarget != null)
|
||||
{
|
||||
|
@ -276,19 +284,26 @@ namespace BizHawk.MultiClient
|
|||
if (retainedPanel != null) retainedPanel.Dispose();
|
||||
if (Global.RenderPanel != null) Global.RenderPanel.Dispose();
|
||||
|
||||
#if WINDOWS
|
||||
if (gdi)
|
||||
#endif
|
||||
renderTarget = retainedPanel = new RetainedViewportPanel();
|
||||
#if WINDOWS
|
||||
else renderTarget = new ViewportPanel();
|
||||
#endif
|
||||
Controls.Add(renderTarget);
|
||||
Controls.SetChildIndex(renderTarget, 0);
|
||||
|
||||
renderTarget.Dock = DockStyle.Fill;
|
||||
renderTarget.BackColor = Color.Black;
|
||||
|
||||
#if WINDOWS
|
||||
if (gdi)
|
||||
{
|
||||
#endif
|
||||
Global.RenderPanel = new SysdrawingRenderPanel(retainedPanel);
|
||||
retainedPanel.ActivateThreaded();
|
||||
#if WINDOWS
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -306,6 +321,7 @@ namespace BizHawk.MultiClient
|
|||
SyncPresentationMode();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SyncThrottle()
|
||||
|
@ -1163,7 +1179,9 @@ namespace BizHawk.MultiClient
|
|||
TAStudio1.Restart();
|
||||
Cheats1.Restart();
|
||||
ToolBox1.Restart();
|
||||
#if WINDOWS
|
||||
LuaConsole1.Restart();
|
||||
#endif
|
||||
|
||||
if (Global.Config.LoadCheatFileByGame)
|
||||
{
|
||||
|
@ -1648,6 +1666,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
Global.RenderPanel.ClearGUIText();
|
||||
//client input-related duties
|
||||
#if WINDOWS
|
||||
if (LuaConsole1.IsRunning())
|
||||
{
|
||||
LuaConsole1.WaitOne();
|
||||
|
@ -1657,6 +1676,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
Global.MainForm.MainWait.Set();
|
||||
}
|
||||
#endif
|
||||
|
||||
runloop_fps++;
|
||||
bool ff = Global.ClientControls["Fast Forward"];
|
||||
|
@ -2255,7 +2275,9 @@ namespace BizHawk.MultiClient
|
|||
TI83KeyPad1.Restart();
|
||||
Cheats1.Restart();
|
||||
ToolBox1.Restart();
|
||||
#if WINDOWS
|
||||
LuaConsole1.Restart();
|
||||
#endif
|
||||
Text = "BizHawk" + (INTERIM ? " (interim) " : "");
|
||||
HandlePlatformMenus();
|
||||
StateSlots.Clear();
|
||||
|
@ -2283,7 +2305,9 @@ namespace BizHawk.MultiClient
|
|||
CloseForm(Cheats1);
|
||||
CloseForm(TI83KeyPad1);
|
||||
CloseForm(TAStudio1);
|
||||
#if WINDOWS
|
||||
CloseForm(LuaConsole1);
|
||||
#endif
|
||||
if (Global.Config.ShowLogWindow) LogConsole.SaveConfigSettings();
|
||||
ConfigService.Save(PathManager.DefaultIniPath, Global.Config);
|
||||
}
|
||||
|
@ -2537,6 +2561,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void OpenLuaConsole()
|
||||
{
|
||||
#if WINDOWS
|
||||
if (!LuaConsole1.IsHandleCreated || LuaConsole1.IsDisposed)
|
||||
{
|
||||
LuaConsole1 = new LuaConsole();
|
||||
|
@ -2544,6 +2569,9 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else
|
||||
LuaConsole1.Focus();
|
||||
#else
|
||||
MessageBox.Show("Sorry, Lua is not supported on this platform.", "Lua not supported", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OpenGameboyDebugger()
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
#if WINDOWS
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX.DirectSound;
|
||||
using Microsoft.VisualBasic.ApplicationServices;
|
||||
#endif
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -16,6 +18,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
Global.Config = ConfigService.Load<Config>(PathManager.DefaultIniPath);
|
||||
|
||||
#if WINDOWS
|
||||
try { Global.DSound = new DirectSound(); }
|
||||
catch
|
||||
{
|
||||
|
@ -29,9 +32,11 @@ namespace BizHawk.MultiClient
|
|||
if (!Global.Config.DisplayGDI)
|
||||
DisplayDirect3DError();
|
||||
}
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
#if WINDOWS
|
||||
if (Global.Config.SingleInstanceMode)
|
||||
{
|
||||
SingleInstanceController controller = new SingleInstanceController(args);
|
||||
|
@ -39,17 +44,21 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
var mf = new MainForm(args);
|
||||
var title = mf.Text;
|
||||
mf.Show();
|
||||
mf.Text = title;
|
||||
mf.ProgramRunLoop();
|
||||
#if WINDOWS
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), "Oh, no, a terrible thing happened!\n\n" + e.ToString());
|
||||
}
|
||||
#if WINDOWS
|
||||
finally
|
||||
{
|
||||
if (Global.DSound != null && Global.DSound.Disposed == false)
|
||||
|
@ -57,9 +66,10 @@ namespace BizHawk.MultiClient
|
|||
if (Global.Direct3D != null && Global.Direct3D.Disposed == false)
|
||||
Global.Direct3D.Dispose();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WINDOWS
|
||||
public class SingleInstanceController : WindowsFormsApplicationBase
|
||||
{
|
||||
MainForm mf;
|
||||
|
@ -92,5 +102,6 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
MessageBox.Show("Failure to initialize Direct3D, reverting to GDI+ display method. Change the option in Config > GUI or install DirectX web update.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -816,4 +816,4 @@
|
|||
<data name="atari_controller" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\images\atari_controller.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
</root>
|
||||
|
|
|
@ -7,13 +7,16 @@ using System.IO;
|
|||
using System.Threading;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
#if WINDOWS
|
||||
using SlimDX;
|
||||
using SlimDX.Direct3D9;
|
||||
using Font = SlimDX.Direct3D9.Font;
|
||||
#endif
|
||||
using BizHawk.Core;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
#if WINDOWS
|
||||
public class ImageTexture : IDisposable
|
||||
{
|
||||
public Device GraphicsDevice;
|
||||
|
@ -105,6 +108,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public interface IRenderer : IDisposable
|
||||
{
|
||||
|
@ -148,7 +152,7 @@ namespace BizHawk.MultiClient
|
|||
public void ClearGUIText() { }
|
||||
}
|
||||
|
||||
|
||||
#if WINDOWS
|
||||
public class Direct3DRenderPanel : IRenderer
|
||||
{
|
||||
public Color BackgroundColor { get; set; }
|
||||
|
@ -546,6 +550,7 @@ namespace BizHawk.MultiClient
|
|||
return "";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class UIMessage
|
||||
{
|
||||
|
@ -561,4 +566,4 @@ namespace BizHawk.MultiClient
|
|||
public int Y;
|
||||
public bool Alert;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
using System;
|
||||
using BizHawk.Emulation.Sound;
|
||||
#if WINDOWS
|
||||
using SlimDX.DirectSound;
|
||||
using SlimDX.Multimedia;
|
||||
#endif
|
||||
|
||||
using BizHawk.Emulation.Consoles.Nintendo;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
#if WINDOWS
|
||||
public class Sound : IDisposable
|
||||
{
|
||||
public bool Muted = false;
|
||||
|
@ -192,4 +195,65 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Dummy implementation for non-Windows platforms for now.
|
||||
public class Sound
|
||||
{
|
||||
public bool Muted = false;
|
||||
public bool needDiscard;
|
||||
|
||||
public Sound()
|
||||
{
|
||||
}
|
||||
|
||||
public void StartSound()
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsPlaying = false;
|
||||
|
||||
public void StopSound()
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
int SNDDXGetAudioSpace()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void UpdateSound(ISoundProvider soundProvider)
|
||||
{
|
||||
soundProvider.DiscardSamples();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Range: 0-100
|
||||
/// </summary>
|
||||
/// <param name="vol"></param>
|
||||
public void ChangeVolume(int vol)
|
||||
{
|
||||
Global.Config.SoundVolume = vol;
|
||||
UpdateSoundSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses Global.Config.SoundEnabled, this just notifies the object to read it
|
||||
/// </summary>
|
||||
public void UpdateSoundSettings()
|
||||
{
|
||||
if (Global.Emulator is NES)
|
||||
{
|
||||
NES n = Global.Emulator as NES;
|
||||
if (Global.Config.SoundEnabled == false)
|
||||
n.SoundOn = false;
|
||||
else
|
||||
n.SoundOn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
static ulong GetCurTime()
|
||||
{
|
||||
#if WINDOWS
|
||||
if (tmethod == 1)
|
||||
{
|
||||
ulong tmp;
|
||||
|
@ -110,13 +111,15 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else
|
||||
{
|
||||
return (ulong)GetTickCount();
|
||||
#endif
|
||||
return (ulong)Environment.TickCount;
|
||||
#if WINDOWS
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern uint GetTickCount();
|
||||
|
||||
#if WINDOWS
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
static extern bool QueryPerformanceCounter(out ulong lpPerformanceCount);
|
||||
|
||||
|
@ -129,15 +132,15 @@ namespace BizHawk.MultiClient
|
|||
[DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")]
|
||||
static extern uint timeBeginPeriod(uint uMilliseconds);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern bool SwitchToThread();
|
||||
|
||||
static int tmethod;
|
||||
#endif
|
||||
|
||||
static ulong afsfreq;
|
||||
static ulong tfreq;
|
||||
|
||||
static Throttle()
|
||||
{
|
||||
#if WINDOWS
|
||||
timeBeginPeriod(1);
|
||||
tmethod = 0;
|
||||
if (QueryPerformanceFrequency(out afsfreq))
|
||||
|
@ -145,6 +148,9 @@ namespace BizHawk.MultiClient
|
|||
else
|
||||
afsfreq = 1000;
|
||||
Console.WriteLine("throttle method: {0}; resolution: {1}", tmethod, afsfreq);
|
||||
#else
|
||||
afsfreq = 1000;
|
||||
#endif
|
||||
tfreq = afsfreq << 16;
|
||||
}
|
||||
|
||||
|
@ -323,7 +329,7 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else if (sleepy > 0) // spin for <1 millisecond waits
|
||||
{
|
||||
SwitchToThread(); // limit to other threads on the same CPU core for other short waits
|
||||
Thread.Yield(); // limit to other threads on the same CPU core for other short waits
|
||||
}
|
||||
goto waiter;
|
||||
}
|
||||
|
@ -333,4 +339,4 @@ namespace BizHawk.MultiClient
|
|||
ltime += tfreq / desiredfps;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,4 +185,4 @@
|
|||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue