Switch.cs 1.7 KB

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