Switch.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using ChocolArm64.Memory;
  2. using Gal;
  3. using Ryujinx.Gpu;
  4. using Ryujinx.OsHle;
  5. using System;
  6. using System.Runtime.InteropServices;
  7. namespace Ryujinx
  8. {
  9. public class Switch : IDisposable
  10. {
  11. public IntPtr Ram {get; private set; }
  12. internal NsGpu Gpu { get; private set; }
  13. internal Horizon Os { get; private set; }
  14. internal VirtualFs VFs { get; private set; }
  15. public event EventHandler Finish;
  16. public Switch(IGalRenderer Renderer)
  17. {
  18. Ram = Marshal.AllocHGlobal((IntPtr)AMemoryMgr.RamSize);
  19. Gpu = new NsGpu(Renderer);
  20. Os = new Horizon(this);
  21. VFs = new VirtualFs();
  22. }
  23. internal virtual void OnFinish(EventArgs e)
  24. {
  25. if (Finish != null)
  26. {
  27. Finish(this, e);
  28. }
  29. }
  30. public void Dispose()
  31. {
  32. Dispose(true);
  33. }
  34. protected virtual void Dispose(bool disposing)
  35. {
  36. if (disposing)
  37. {
  38. VFs.Dispose();
  39. }
  40. Marshal.FreeHGlobal(Ram);
  41. }
  42. }
  43. }