Switch.cs 2.0 KB

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