Switch.cs 1.7 KB

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