mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-28 13:20:33 +00:00
71 lines
1.5 KiB
C#
71 lines
1.5 KiB
C#
|
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;
|
|||
|
private bool IsPaused = false;
|
|||
|
|
|||
|
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) =>
|
|||
|
{
|
|||
|
Stop();
|
|||
|
};
|
|||
|
|
|||
|
Screen.Run(60.0);
|
|||
|
}
|
|||
|
}));
|
|||
|
|
|||
|
EmulationThread.Start();
|
|||
|
}
|
|||
|
|
|||
|
public void Stop()
|
|||
|
{
|
|||
|
IsPaused = false;
|
|||
|
Ns.Os.ShutDown();
|
|||
|
}
|
|||
|
|
|||
|
public async void Pause()
|
|||
|
{
|
|||
|
IsPaused = true;
|
|||
|
lock (Ns)
|
|||
|
{
|
|||
|
while (IsPaused)
|
|||
|
{
|
|||
|
Thread.Sleep(1000);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void Continue()
|
|||
|
{
|
|||
|
IsPaused = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|