diff options
| author | 2016-11-04 23:14:38 -0400 | |
|---|---|---|
| committer | 2016-12-21 23:29:04 -0500 | |
| commit | 198b6c9bdd58d76303f75a8577303907967a143e (patch) | |
| tree | 0dba084e5c3418f917880fd4fc1efad37f127e9b /src/citra/citra.cpp | |
| parent | loader: Remove duplicate docstrings. (diff) | |
| download | yuzu-198b6c9bdd58d76303f75a8577303907967a143e.tar.gz yuzu-198b6c9bdd58d76303f75a8577303907967a143e.tar.xz yuzu-198b6c9bdd58d76303f75a8577303907967a143e.zip | |
core: Consolidate top-level system state into a singleton.
Diffstat (limited to 'src/citra/citra.cpp')
| -rw-r--r-- | src/citra/citra.cpp | 35 |
1 files changed, 14 insertions, 21 deletions
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) { | |||
| 64 | return -1; | 64 | return -1; |
| 65 | } | 65 | } |
| 66 | #endif | 66 | #endif |
| 67 | std::string boot_filename; | 67 | std::string filepath; |
| 68 | 68 | ||
| 69 | static struct option long_options[] = { | 69 | static struct option long_options[] = { |
| 70 | {"gdbport", required_argument, 0, 'g'}, | 70 | {"gdbport", required_argument, 0, 'g'}, |
| @@ -97,9 +97,9 @@ int main(int argc, char** argv) { | |||
| 97 | } | 97 | } |
| 98 | } else { | 98 | } else { |
| 99 | #ifdef _WIN32 | 99 | #ifdef _WIN32 |
| 100 | boot_filename = Common::UTF16ToUTF8(argv_w[optind]); | 100 | filepath = Common::UTF16ToUTF8(argv_w[optind]); |
| 101 | #else | 101 | #else |
| 102 | boot_filename = argv[optind]; | 102 | filepath = argv[optind]; |
| 103 | #endif | 103 | #endif |
| 104 | optind++; | 104 | optind++; |
| 105 | } | 105 | } |
| @@ -115,7 +115,7 @@ int main(int argc, char** argv) { | |||
| 115 | MicroProfileOnThreadCreate("EmuThread"); | 115 | MicroProfileOnThreadCreate("EmuThread"); |
| 116 | SCOPE_EXIT({ MicroProfileShutdown(); }); | 116 | SCOPE_EXIT({ MicroProfileShutdown(); }); |
| 117 | 117 | ||
| 118 | if (boot_filename.empty()) { | 118 | if (filepath.empty()) { |
| 119 | LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); | 119 | LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); |
| 120 | return -1; | 120 | return -1; |
| 121 | } | 121 | } |
| @@ -127,27 +127,20 @@ int main(int argc, char** argv) { | |||
| 127 | Settings::values.use_gdbstub = use_gdbstub; | 127 | Settings::values.use_gdbstub = use_gdbstub; |
| 128 | Settings::Apply(); | 128 | Settings::Apply(); |
| 129 | 129 | ||
| 130 | std::unique_ptr<EmuWindow_SDL2> emu_window = std::make_unique<EmuWindow_SDL2>(); | 130 | std::unique_ptr<EmuWindow_SDL2> emu_window{ std::make_unique<EmuWindow_SDL2>() }; |
| 131 | 131 | ||
| 132 | std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(boot_filename); | 132 | Core::System& system{ Core::System::GetInstance() }; |
| 133 | if (!loader) { | ||
| 134 | LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", boot_filename.c_str()); | ||
| 135 | return -1; | ||
| 136 | } | ||
| 137 | |||
| 138 | boost::optional<u32> system_mode = loader->LoadKernelSystemMode(); | ||
| 139 | 133 | ||
| 140 | if (!system_mode) { | 134 | SCOPE_EXIT({ system.Shutdown(); }); |
| 141 | LOG_CRITICAL(Frontend, "Failed to load ROM (Could not determine system mode)!"); | ||
| 142 | return -1; | ||
| 143 | } | ||
| 144 | 135 | ||
| 145 | System::Init(emu_window.get(), system_mode.get()); | 136 | const Core::System::ResultStatus load_result{ system.Load(emu_window.get(), filepath) }; |
| 146 | SCOPE_EXIT({ System::Shutdown(); }); | ||
| 147 | 137 | ||
| 148 | Loader::ResultStatus load_result = loader->Load(); | 138 | switch (load_result) { |
| 149 | if (Loader::ResultStatus::Success != load_result) { | 139 | case Core::System::ResultStatus::ErrorGetLoader: |
| 150 | LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); | 140 | LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filepath.c_str()); |
| 141 | return -1; | ||
| 142 | case Core::System::ResultStatus::ErrorLoader: | ||
| 143 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); | ||
| 151 | return -1; | 144 | return -1; |
| 152 | } | 145 | } |
| 153 | 146 | ||