Switch.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using Ryujinx.Audio;
  2. using Ryujinx.Graphics;
  3. using Ryujinx.Graphics.Gal;
  4. using Ryujinx.HLE.FileSystem;
  5. using Ryujinx.HLE.HOS;
  6. using Ryujinx.HLE.Input;
  7. using Ryujinx.HLE.Logging;
  8. using Ryujinx.HLE.Memory;
  9. using System;
  10. namespace Ryujinx.HLE
  11. {
  12. public class Switch : IDisposable
  13. {
  14. internal IAalOutput AudioOut { get; private set; }
  15. public Logger Log { get; private set; }
  16. internal DeviceMemory Memory { get; private set; }
  17. internal NvGpu Gpu { get; private set; }
  18. internal VirtualFileSystem FileSystem { get; private set; }
  19. public Horizon System { get; private set; }
  20. public PerformanceStatistics Statistics { get; private set; }
  21. public Hid Hid { get; private set; }
  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. FileSystem = new VirtualFileSystem();
  37. System = new Horizon(this);
  38. Statistics = new PerformanceStatistics();
  39. Hid = new Hid(this, System.HidSharedMem.PA);
  40. }
  41. public void LoadCart(string ExeFsDir, string RomFsFile = null)
  42. {
  43. System.LoadCart(ExeFsDir, RomFsFile);
  44. }
  45. public void LoadXci(string XciFile)
  46. {
  47. System.LoadXci(XciFile);
  48. }
  49. public void LoadNca(string NcaFile)
  50. {
  51. System.LoadNca(NcaFile);
  52. }
  53. public void LoadNsp(string NspFile)
  54. {
  55. System.LoadNsp(NspFile);
  56. }
  57. public void LoadProgram(string FileName)
  58. {
  59. System.LoadProgram(FileName);
  60. }
  61. public bool WaitFifo()
  62. {
  63. return Gpu.Fifo.Event.WaitOne(8);
  64. }
  65. public void ProcessFrame()
  66. {
  67. Gpu.Fifo.DispatchCalls();
  68. }
  69. internal void Unload()
  70. {
  71. FileSystem.Dispose();
  72. Memory.Dispose();
  73. }
  74. public void Dispose()
  75. {
  76. Dispose(true);
  77. }
  78. protected virtual void Dispose(bool Disposing)
  79. {
  80. if (Disposing)
  81. {
  82. System.Dispose();
  83. }
  84. }
  85. }
  86. }