citra.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <thread>
  5. #include "common/common.h"
  6. #include "common/logging/text_formatter.h"
  7. #include "common/logging/backend.h"
  8. #include "common/logging/filter.h"
  9. #include "common/scope_exit.h"
  10. #include "core/settings.h"
  11. #include "core/system.h"
  12. #include "core/core.h"
  13. #include "core/loader/loader.h"
  14. #include "citra/config.h"
  15. #include "citra/emu_window/emu_window_glfw.h"
  16. /// Application entry point
  17. int __cdecl main(int argc, char **argv) {
  18. std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();
  19. Log::Filter log_filter(Log::Level::Debug);
  20. std::thread logging_thread(Log::TextLoggingLoop, logger, &log_filter);
  21. SCOPE_EXIT({
  22. logger->Close();
  23. logging_thread.join();
  24. });
  25. if (argc < 2) {
  26. LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
  27. return -1;
  28. }
  29. Config config;
  30. log_filter.ParseFilterString(Settings::values.log_filter);
  31. std::string boot_filename = argv[1];
  32. EmuWindow_GLFW* emu_window = new EmuWindow_GLFW;
  33. System::Init(emu_window);
  34. Loader::ResultStatus load_result = Loader::LoadFile(boot_filename);
  35. if (Loader::ResultStatus::Success != load_result) {
  36. LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result);
  37. return -1;
  38. }
  39. while (emu_window->IsOpen()) {
  40. Core::RunLoop();
  41. }
  42. delete emu_window;
  43. return 0;
  44. }