Switch.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using Ryujinx.Audio;
  2. using Ryujinx.Graphics.Gal;
  3. using Ryujinx.HLE.Gpu;
  4. using Ryujinx.HLE.HOS;
  5. using Ryujinx.HLE.Input;
  6. using Ryujinx.HLE.Logging;
  7. using Ryujinx.HLE.Memory;
  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 FileSystem { get; private set; }
  18. public Horizon System { get; private set; }
  19. public PerformanceStatistics Statistics { get; private set; }
  20. public Hid Hid { get; private set; }
  21. public Switch(IGalRenderer Renderer, IAalOutput AudioOut)
  22. {
  23. if (Renderer == null)
  24. {
  25. throw new ArgumentNullException(nameof(Renderer));
  26. }
  27. if (AudioOut == null)
  28. {
  29. throw new ArgumentNullException(nameof(AudioOut));
  30. }
  31. this.AudioOut = AudioOut;
  32. Log = new Logger();
  33. Memory = new DeviceMemory();
  34. Gpu = new NvGpu(Renderer);
  35. FileSystem = new VirtualFileSystem();
  36. System = new Horizon(this);
  37. Statistics = new PerformanceStatistics();
  38. Hid = new Hid(this, System.HidSharedMem.PA);
  39. }
  40. public void LoadCart(string ExeFsDir, string RomFsFile = null)
  41. {
  42. System.LoadCart(ExeFsDir, RomFsFile);
  43. }
  44. public void LoadProgram(string FileName)
  45. {
  46. System.LoadProgram(FileName);
  47. }
  48. public bool WaitFifo()
  49. {
  50. return Gpu.Fifo.Event.WaitOne(8);
  51. }
  52. public void ProcessFrame()
  53. {
  54. Gpu.Fifo.DispatchCalls();
  55. }
  56. internal void Unload()
  57. {
  58. FileSystem.Dispose();
  59. Memory.Dispose();
  60. }
  61. public void Dispose()
  62. {
  63. Dispose(true);
  64. }
  65. protected virtual void Dispose(bool Disposing)
  66. {
  67. if (Disposing)
  68. {
  69. System.Dispose();
  70. }
  71. }
  72. }
  73. }