Switch.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using ChocolArm64.Memory;
  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 AMemory Memory { get; private set; }
  13. internal NsGpu Gpu { get; private set; }
  14. internal Horizon Os { get; private set; }
  15. internal VirtualFs VFs { get; private set; }
  16. public Hid Hid { get; private set; }
  17. public SetSys Settings { get; private set; }
  18. public PerformanceStatistics Statistics { get; private set; }
  19. public event EventHandler Finish;
  20. public Switch(IGalRenderer Renderer)
  21. {
  22. Memory = new AMemory();
  23. Gpu = new NsGpu(Renderer);
  24. VFs = new VirtualFs();
  25. Hid = new Hid(this);
  26. Statistics = new PerformanceStatistics();
  27. Os = new Horizon(this);
  28. Os.HidSharedMem.MemoryMapped += Hid.ShMemMap;
  29. Os.HidSharedMem.MemoryUnmapped += Hid.ShMemUnmap;
  30. Settings = new SetSys();
  31. }
  32. public void FinalizeAllProcesses()
  33. {
  34. Os.FinalizeAllProcesses();
  35. }
  36. public void LoadCart(string ExeFsDir, string RomFsFile = null)
  37. {
  38. Os.LoadCart(ExeFsDir, RomFsFile);
  39. }
  40. public void LoadProgram(string FileName)
  41. {
  42. Os.LoadProgram(FileName);
  43. }
  44. internal virtual void OnFinish(EventArgs e)
  45. {
  46. Finish?.Invoke(this, e);
  47. }
  48. public void Dispose()
  49. {
  50. Dispose(true);
  51. }
  52. protected virtual void Dispose(bool disposing)
  53. {
  54. if (disposing)
  55. {
  56. Memory.Dispose();
  57. VFs.Dispose();
  58. }
  59. }
  60. }
  61. }