From 198b6c9bdd58d76303f75a8577303907967a143e Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 4 Nov 2016 23:14:38 -0400 Subject: core: Consolidate top-level system state into a singleton. --- src/citra/citra.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'src/citra/citra.cpp') diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 3114a71db..5e2829b54 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -64,7 +64,7 @@ int main(int argc, char** argv) { return -1; } #endif - std::string boot_filename; + std::string filepath; static struct option long_options[] = { {"gdbport", required_argument, 0, 'g'}, @@ -97,9 +97,9 @@ int main(int argc, char** argv) { } } else { #ifdef _WIN32 - boot_filename = Common::UTF16ToUTF8(argv_w[optind]); + filepath = Common::UTF16ToUTF8(argv_w[optind]); #else - boot_filename = argv[optind]; + filepath = argv[optind]; #endif optind++; } @@ -115,7 +115,7 @@ int main(int argc, char** argv) { MicroProfileOnThreadCreate("EmuThread"); SCOPE_EXIT({ MicroProfileShutdown(); }); - if (boot_filename.empty()) { + if (filepath.empty()) { LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); return -1; } @@ -127,27 +127,20 @@ int main(int argc, char** argv) { Settings::values.use_gdbstub = use_gdbstub; Settings::Apply(); - std::unique_ptr emu_window = std::make_unique(); + std::unique_ptr emu_window{ std::make_unique() }; - std::unique_ptr loader = Loader::GetLoader(boot_filename); - if (!loader) { - LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", boot_filename.c_str()); - return -1; - } - - boost::optional system_mode = loader->LoadKernelSystemMode(); + Core::System& system{ Core::System::GetInstance() }; - if (!system_mode) { - LOG_CRITICAL(Frontend, "Failed to load ROM (Could not determine system mode)!"); - return -1; - } + SCOPE_EXIT({ system.Shutdown(); }); - System::Init(emu_window.get(), system_mode.get()); - SCOPE_EXIT({ System::Shutdown(); }); + const Core::System::ResultStatus load_result{ system.Load(emu_window.get(), filepath) }; - Loader::ResultStatus load_result = loader->Load(); - if (Loader::ResultStatus::Success != load_result) { - LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); + switch (load_result) { + case Core::System::ResultStatus::ErrorGetLoader: + LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filepath.c_str()); + return -1; + case Core::System::ResultStatus::ErrorLoader: + LOG_CRITICAL(Frontend, "Failed to load ROM!"); return -1; } -- cgit v1.2.3