Program.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. Console.WriteLine("Loading as NSP.");
  54. device.LoadNsp(args[0]);
  55. break;
  56. default:
  57. Console.WriteLine("Loading as homebrew.");
  58. device.LoadProgram(args[0]);
  59. break;
  60. }
  61. }
  62. }
  63. else
  64. {
  65. Console.WriteLine("Please specify the folder with the NSOs/IStorage or a NSO/NRO.");
  66. }
  67. using (GlScreen screen = new GlScreen(device, renderer))
  68. {
  69. screen.MainLoop();
  70. device.Dispose();
  71. }
  72. audioOut.Dispose();
  73. }
  74. /// <summary>
  75. /// Picks an <see cref="IAalOutput"/> audio output renderer supported on this machine
  76. /// </summary>
  77. /// <returns>An <see cref="IAalOutput"/> supported by this machine</returns>
  78. private static IAalOutput InitializeAudioEngine()
  79. {
  80. if (SoundIoAudioOut.IsSupported)
  81. {
  82. return new SoundIoAudioOut();
  83. }
  84. else if (OpenALAudioOut.IsSupported)
  85. {
  86. return new OpenALAudioOut();
  87. }
  88. else
  89. {
  90. return new DummyAudioOut();
  91. }
  92. }
  93. }
  94. }