citra.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <string>
  5. #include <thread>
  6. #include <iostream>
  7. #ifdef _MSC_VER
  8. #include <getopt.h>
  9. #else
  10. #include <unistd.h>
  11. #include <getopt.h>
  12. #endif
  13. #include "common/logging/log.h"
  14. #include "common/logging/backend.h"
  15. #include "common/logging/filter.h"
  16. #include "core/settings.h"
  17. #include "core/system.h"
  18. #include "core/core.h"
  19. #include "core/loader/loader.h"
  20. #include "citra/config.h"
  21. #include "citra/emu_window/emu_window_glfw.h"
  22. #include "video_core/video_core.h"
  23. static void PrintHelp()
  24. {
  25. std::cout << "Usage: citra <filename>" << std::endl;
  26. }
  27. /// Application entry point
  28. int main(int argc, char **argv) {
  29. int option_index = 0;
  30. std::string boot_filename;
  31. static struct option long_options[] = {
  32. { "help", no_argument, 0, 'h' },
  33. { 0, 0, 0, 0 }
  34. };
  35. while (optind < argc) {
  36. char arg = getopt_long(argc, argv, ":h", long_options, &option_index);
  37. if (arg != -1) {
  38. switch (arg) {
  39. case 'h':
  40. PrintHelp();
  41. return 0;
  42. }
  43. } else {
  44. boot_filename = argv[optind];
  45. optind++;
  46. }
  47. }
  48. Log::Filter log_filter(Log::Level::Debug);
  49. Log::SetFilter(&log_filter);
  50. if (boot_filename.empty()) {
  51. LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
  52. return -1;
  53. }
  54. Config config;
  55. log_filter.ParseFilterString(Settings::values.log_filter);
  56. EmuWindow_GLFW* emu_window = new EmuWindow_GLFW;
  57. VideoCore::g_hw_renderer_enabled = Settings::values.use_hw_renderer;
  58. System::Init(emu_window);
  59. Loader::ResultStatus load_result = Loader::LoadFile(boot_filename);
  60. if (Loader::ResultStatus::Success != load_result) {
  61. LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result);
  62. return -1;
  63. }
  64. while (emu_window->IsOpen()) {
  65. Core::RunLoop();
  66. }
  67. System::Shutdown();
  68. delete emu_window;
  69. return 0;
  70. }