Program.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using Ryujinx.Audio;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.Graphics.Gal;
  4. using Ryujinx.Graphics.Gal.OpenGL;
  5. using Ryujinx.HLE;
  6. using System;
  7. using System.IO;
  8. namespace Ryujinx
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Console.Title = "Ryujinx Console";
  15. IGalRenderer renderer = new OGLRenderer();
  16. IAalOutput audioOut = InitializeAudioEngine();
  17. Switch device = new Switch(renderer, audioOut);
  18. Config.Read(device);
  19. Logger.Updated += ConsoleLog.Log;
  20. if (args.Length == 1)
  21. {
  22. if (Directory.Exists(args[0]))
  23. {
  24. string[] romFsFiles = Directory.GetFiles(args[0], "*.istorage");
  25. if (romFsFiles.Length == 0)
  26. {
  27. romFsFiles = Directory.GetFiles(args[0], "*.romfs");
  28. }
  29. if (romFsFiles.Length > 0)
  30. {
  31. Console.WriteLine("Loading as cart with RomFS.");
  32. device.LoadCart(args[0], romFsFiles[0]);
  33. }
  34. else
  35. {
  36. Console.WriteLine("Loading as cart WITHOUT RomFS.");
  37. device.LoadCart(args[0]);
  38. }
  39. }
  40. else if (File.Exists(args[0]))
  41. {
  42. switch (Path.GetExtension(args[0]).ToLowerInvariant())
  43. {
  44. case ".xci":
  45. Console.WriteLine("Loading as XCI.");
  46. device.LoadXci(args[0]);
  47. break;
  48. case ".nca":
  49. Console.WriteLine("Loading as NCA.");
  50. device.LoadNca(args[0]);
  51. break;
  52. case ".nsp":
  53. case ".pfs0":
  54. Console.WriteLine("Loading as NSP.");
  55. device.LoadNsp(args[0]);
  56. break;
  57. default:
  58. Console.WriteLine("Loading as homebrew.");
  59. device.LoadProgram(args[0]);
  60. break;
  61. }
  62. }
  63. }
  64. else
  65. {
  66. Console.WriteLine("Please specify the folder with the NSOs/IStorage or a NSO/NRO.");
  67. }
  68. using (GlScreen screen = new GlScreen(device, renderer))
  69. {
  70. screen.MainLoop();
  71. device.Dispose();
  72. }
  73. audioOut.Dispose();
  74. }
  75. /// <summary>
  76. /// Picks an <see cref="IAalOutput"/> audio output renderer supported on this machine
  77. /// </summary>
  78. /// <returns>An <see cref="IAalOutput"/> supported by this machine</returns>
  79. private static IAalOutput InitializeAudioEngine()
  80. {
  81. if (SoundIoAudioOut.IsSupported)
  82. {
  83. return new SoundIoAudioOut();
  84. }
  85. else if (OpenALAudioOut.IsSupported)
  86. {
  87. return new OpenALAudioOut();
  88. }
  89. else
  90. {
  91. return new DummyAudioOut();
  92. }
  93. }
  94. }
  95. }