Mesen-SX/UI/Emulation/EmuRunner.cs

49 lines
1 KiB
C#
Raw Normal View History

2019-03-12 09:15:57 -04:00
using Mesen.GUI.Config;
using Mesen.GUI.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesen.GUI.Emulation
{
public static class EmuRunner
{
private static Thread _emuThread = null;
public static void LoadRom(ResourcePath romPath, ResourcePath? patchPath = null)
{
if(!frmSelectRom.SelectRom(ref romPath)) {
return;
}
EmuApi.LoadRom(romPath, patchPath);
ConfigManager.Config.RecentFiles.AddRecentFile(romPath, patchPath);
2019-03-14 18:07:25 -04:00
StartEmulation();
}
public static void LoadRecentGame(string recentGameArchivePath)
{
EmuApi.LoadRecentGame(recentGameArchivePath, false /* TODO , ConfigManager.Config.Preferences.GameSelectionScreenResetGame */);
StartEmulation();
}
2019-03-12 09:15:57 -04:00
2019-03-14 18:07:25 -04:00
private static void StartEmulation()
{
2019-03-12 09:15:57 -04:00
_emuThread = new Thread(() => {
EmuApi.Run();
2019-03-14 18:07:25 -04:00
_emuThread = null;
2019-03-12 09:15:57 -04:00
});
_emuThread.Start();
}
public static bool IsRunning()
{
return _emuThread != null;
}
}
}