Switch.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using ChocolArm64.Memory;
  2. using Ryujinx.Core.Input;
  3. using Ryujinx.Core.OsHle;
  4. using Ryujinx.Graphics.Gal;
  5. using Ryujinx.Graphics.Gpu;
  6. using System;
  7. using System.Runtime.InteropServices;
  8. namespace Ryujinx.Core
  9. {
  10. public class Switch : IDisposable
  11. {
  12. public IntPtr Ram {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 event EventHandler Finish;
  18. public Switch(IGalRenderer Renderer)
  19. {
  20. Ram = Marshal.AllocHGlobal((IntPtr)AMemoryMgr.RamSize);
  21. Gpu = new NsGpu(Renderer);
  22. Os = new Horizon(this);
  23. VFs = new VirtualFs();
  24. Hid = new Hid(this);
  25. }
  26. public void FinalizeAllProcesses()
  27. {
  28. Os.FinalizeAllProcesses();
  29. }
  30. public void LoadCart(string ExeFsDir, string RomFsFile = null)
  31. {
  32. Os.LoadCart(ExeFsDir, RomFsFile);
  33. }
  34. public void LoadProgram(string FileName)
  35. {
  36. Os.LoadProgram(FileName);
  37. }
  38. internal virtual void OnFinish(EventArgs e)
  39. {
  40. Finish?.Invoke(this, e);
  41. }
  42. public void Dispose()
  43. {
  44. Dispose(true);
  45. }
  46. protected virtual void Dispose(bool disposing)
  47. {
  48. if (disposing)
  49. {
  50. VFs.Dispose();
  51. }
  52. Marshal.FreeHGlobal(Ram);
  53. }
  54. }
  55. }