Switch.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using Ryujinx.Audio;
  2. using Ryujinx.Core.Input;
  3. using Ryujinx.Core.Logging;
  4. using Ryujinx.Core.OsHle;
  5. using Ryujinx.Core.Settings;
  6. using Ryujinx.Graphics.Gal;
  7. using Ryujinx.Graphics.Gpu;
  8. using System;
  9. namespace Ryujinx.Core
  10. {
  11. public class Switch : IDisposable
  12. {
  13. internal IAalOutput AudioOut { get; private set; }
  14. public Logger Log { get; private set; }
  15. internal NsGpu 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 NsGpu(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. internal virtual void OnFinish(EventArgs e)
  52. {
  53. Finish?.Invoke(this, e);
  54. }
  55. public void Dispose()
  56. {
  57. Dispose(true);
  58. }
  59. protected virtual void Dispose(bool Disposing)
  60. {
  61. if (Disposing)
  62. {
  63. Os.Dispose();
  64. VFs.Dispose();
  65. }
  66. }
  67. }
  68. }