2018-04-19 18:21:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Ryujinx.Graphics.Gal;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Core
|
|
|
|
|
{
|
|
|
|
|
public class EmutionController
|
|
|
|
|
{
|
|
|
|
|
private Thread EmulationThread;
|
|
|
|
|
private Switch Ns;
|
|
|
|
|
private IGalRenderer Renderer;
|
2018-04-25 22:03:11 +00:00
|
|
|
|
private bool IsPaused = false;
|
|
|
|
|
private bool IsShutDown = false;
|
2018-04-19 18:21:16 +00:00
|
|
|
|
|
|
|
|
|
public EmutionController(Switch Ns, IGalRenderer Renderer)
|
|
|
|
|
{
|
|
|
|
|
this.Ns = Ns;
|
|
|
|
|
this.Renderer = Renderer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
EmulationThread = new Thread(new ThreadStart(() =>
|
|
|
|
|
{
|
|
|
|
|
using (GLScreen Screen = new GLScreen(Ns, Renderer))
|
|
|
|
|
{
|
|
|
|
|
Ns.Finish += (Sender, Args) =>
|
|
|
|
|
{
|
|
|
|
|
Screen?.Exit();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Screen.Closed += (Sender, Args) =>
|
|
|
|
|
{
|
2018-04-25 22:03:11 +00:00
|
|
|
|
if(!IsShutDown)
|
2018-04-19 18:21:16 +00:00
|
|
|
|
Stop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Screen.Run(60.0);
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
EmulationThread.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
|
|
|
|
IsPaused = false;
|
2018-04-25 22:03:11 +00:00
|
|
|
|
IsShutDown = true;
|
2018-04-19 18:21:16 +00:00
|
|
|
|
Ns.Os.ShutDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async void Pause()
|
|
|
|
|
{
|
|
|
|
|
IsPaused = true;
|
|
|
|
|
lock (Ns)
|
|
|
|
|
{
|
|
|
|
|
while (IsPaused)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Continue()
|
|
|
|
|
{
|
|
|
|
|
IsPaused = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|