Switch.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using Ryujinx.Audio;
  2. using Ryujinx.Graphics.Gal;
  3. using Ryujinx.HLE.Gpu;
  4. using Ryujinx.HLE.Input;
  5. using Ryujinx.HLE.Logging;
  6. using Ryujinx.HLE.Memory;
  7. using Ryujinx.HLE.OsHle;
  8. using System;
  9. namespace Ryujinx.HLE
  10. {
  11. public class Switch : IDisposable
  12. {
  13. internal IAalOutput AudioOut { get; private set; }
  14. public Logger Log { get; private set; }
  15. internal DeviceMemory Memory { get; private set; }
  16. internal NvGpu Gpu { get; private set; }
  17. internal VirtualFileSystem VFs { get; private set; }
  18. public Horizon Os { get; private set; }
  19. public PerformanceStatistics Statistics { get; private set; }
  20. public Hid Hid { get; private set; }
  21. public event EventHandler Finish;
  22. public Switch(IGalRenderer Renderer, IAalOutput AudioOut)
  23. {
  24. if (Renderer == null)
  25. {
  26. throw new ArgumentNullException(nameof(Renderer));
  27. }
  28. if (AudioOut == null)
  29. {
  30. throw new ArgumentNullException(nameof(AudioOut));
  31. }
  32. this.AudioOut = AudioOut;
  33. Log = new Logger();
  34. Memory = new DeviceMemory();
  35. Gpu = new NvGpu(Renderer);
  36. VFs = new VirtualFileSystem();
  37. Os = new Horizon(this);
  38. Statistics = new PerformanceStatistics();
  39. Hid = new Hid(this, Os.HidSharedMem.PA);
  40. }
  41. public void LoadCart(string ExeFsDir, string RomFsFile = null)
  42. {
  43. Os.LoadCart(ExeFsDir, RomFsFile);
  44. }
  45. public void LoadProgram(string FileName)
  46. {
  47. Os.LoadProgram(FileName);
  48. }
  49. public bool WaitFifo()
  50. {
  51. return Gpu.Fifo.Event.WaitOne(8);
  52. }
  53. public void ProcessFrame()
  54. {
  55. Gpu.Fifo.DispatchCalls();
  56. }
  57. public virtual void OnFinish(EventArgs e)
  58. {
  59. Os.Dispose();
  60. Finish?.Invoke(this, e);
  61. }
  62. public void Dispose()
  63. {
  64. Dispose(true);
  65. }
  66. protected virtual void Dispose(bool Disposing)
  67. {
  68. if (Disposing)
  69. {
  70. Os.Dispose();
  71. VFs.Dispose();
  72. }
  73. }
  74. }
  75. }