Switch.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using Ryujinx.Audio;
  2. using Ryujinx.Graphics.Gal;
  3. using Ryujinx.HLE.Gpu;
  4. using Ryujinx.HLE.Input;
  5. using Ryujinx.HLE.Logging;
  6. using Ryujinx.HLE.OsHle;
  7. using Ryujinx.HLE.Settings;
  8. using System;
  9. namespace Ryujinx.HLE
  10. {
  11. public class Switch : IDisposable
  12. {
  13. internal IAalOutput AudioOut { get; private set; }
  14. public Logger Log { get; private set; }
  15. internal NvGpu Gpu { get; private set; }
  16. internal VirtualFileSystem VFs { get; private set; }
  17. public Horizon Os { get; private set; }
  18. public SystemSettings Settings { get; private set; }
  19. public PerformanceStatistics Statistics { get; private set; }
  20. public Hid Hid { get; private set; }
  21. public event EventHandler Finish;
  22. public Switch(IGalRenderer Renderer, IAalOutput AudioOut)
  23. {
  24. if (Renderer == null)
  25. {
  26. throw new ArgumentNullException(nameof(Renderer));
  27. }
  28. if (AudioOut == null)
  29. {
  30. throw new ArgumentNullException(nameof(AudioOut));
  31. }
  32. this.AudioOut = AudioOut;
  33. Log = new Logger();
  34. Gpu = new NvGpu(Renderer);
  35. VFs = new VirtualFileSystem();
  36. Os = new Horizon(this);
  37. Settings = new SystemSettings();
  38. Statistics = new PerformanceStatistics();
  39. Hid = new Hid(Log);
  40. Os.HidSharedMem.MemoryMapped += Hid.ShMemMap;
  41. Os.HidSharedMem.MemoryUnmapped += Hid.ShMemUnmap;
  42. }
  43. public void LoadCart(string ExeFsDir, string RomFsFile = null)
  44. {
  45. Os.LoadCart(ExeFsDir, RomFsFile);
  46. }
  47. public void LoadProgram(string FileName)
  48. {
  49. Os.LoadProgram(FileName);
  50. }
  51. public void ProcessFrame()
  52. {
  53. Gpu.Fifo.DispatchCalls();
  54. }
  55. internal virtual void OnFinish(EventArgs e)
  56. {
  57. Finish?.Invoke(this, e);
  58. }
  59. public void Dispose()
  60. {
  61. Dispose(true);
  62. }
  63. protected virtual void Dispose(bool Disposing)
  64. {
  65. if (Disposing)
  66. {
  67. Os.Dispose();
  68. VFs.Dispose();
  69. }
  70. }
  71. }
  72. }