summaryrefslogtreecommitdiff
path: root/src/citra/citra.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2016-12-22 11:47:44 -0500
committerGravatar GitHub2016-12-22 11:47:44 -0500
commitaa47af7fb6efd0bda54cca2373ed978e538f6d61 (patch)
tree93d96872603f64925cd632f27bb5c7046cadeedf /src/citra/citra.cpp
parentMerge pull request #2285 from mailwl/csnd-format (diff)
parentThreadContext: Move from "core" to "arm_interface". (diff)
downloadyuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.tar.gz
yuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.tar.xz
yuzu-aa47af7fb6efd0bda54cca2373ed978e538f6d61.zip
Merge pull request #2343 from bunnei/core-cleanup
Core: Top-level consolidate & misc cleanup
Diffstat (limited to 'src/citra/citra.cpp')
-rw-r--r--src/citra/citra.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index 3114a71db..99c096ac7 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -33,7 +33,6 @@
33#include "core/gdbstub/gdbstub.h" 33#include "core/gdbstub/gdbstub.h"
34#include "core/loader/loader.h" 34#include "core/loader/loader.h"
35#include "core/settings.h" 35#include "core/settings.h"
36#include "core/system.h"
37#include "video_core/video_core.h" 36#include "video_core/video_core.h"
38 37
39static void PrintHelp(const char* argv0) { 38static void PrintHelp(const char* argv0) {
@@ -64,7 +63,7 @@ int main(int argc, char** argv) {
64 return -1; 63 return -1;
65 } 64 }
66#endif 65#endif
67 std::string boot_filename; 66 std::string filepath;
68 67
69 static struct option long_options[] = { 68 static struct option long_options[] = {
70 {"gdbport", required_argument, 0, 'g'}, 69 {"gdbport", required_argument, 0, 'g'},
@@ -97,9 +96,9 @@ int main(int argc, char** argv) {
97 } 96 }
98 } else { 97 } else {
99#ifdef _WIN32 98#ifdef _WIN32
100 boot_filename = Common::UTF16ToUTF8(argv_w[optind]); 99 filepath = Common::UTF16ToUTF8(argv_w[optind]);
101#else 100#else
102 boot_filename = argv[optind]; 101 filepath = argv[optind];
103#endif 102#endif
104 optind++; 103 optind++;
105 } 104 }
@@ -115,7 +114,7 @@ int main(int argc, char** argv) {
115 MicroProfileOnThreadCreate("EmuThread"); 114 MicroProfileOnThreadCreate("EmuThread");
116 SCOPE_EXIT({ MicroProfileShutdown(); }); 115 SCOPE_EXIT({ MicroProfileShutdown(); });
117 116
118 if (boot_filename.empty()) { 117 if (filepath.empty()) {
119 LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified"); 118 LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
120 return -1; 119 return -1;
121 } 120 }
@@ -127,32 +126,25 @@ int main(int argc, char** argv) {
127 Settings::values.use_gdbstub = use_gdbstub; 126 Settings::values.use_gdbstub = use_gdbstub;
128 Settings::Apply(); 127 Settings::Apply();
129 128
130 std::unique_ptr<EmuWindow_SDL2> emu_window = std::make_unique<EmuWindow_SDL2>(); 129 std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>()};
131 130
132 std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(boot_filename); 131 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 132
140 if (!system_mode) { 133 SCOPE_EXIT({ system.Shutdown(); });
141 LOG_CRITICAL(Frontend, "Failed to load ROM (Could not determine system mode)!");
142 return -1;
143 }
144 134
145 System::Init(emu_window.get(), system_mode.get()); 135 const Core::System::ResultStatus load_result{system.Load(emu_window.get(), filepath)};
146 SCOPE_EXIT({ System::Shutdown(); });
147 136
148 Loader::ResultStatus load_result = loader->Load(); 137 switch (load_result) {
149 if (Loader::ResultStatus::Success != load_result) { 138 case Core::System::ResultStatus::ErrorGetLoader:
150 LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); 139 LOG_CRITICAL(Frontend, "Failed to obtain loader for %s!", filepath.c_str());
140 return -1;
141 case Core::System::ResultStatus::ErrorLoader:
142 LOG_CRITICAL(Frontend, "Failed to load ROM!");
151 return -1; 143 return -1;
152 } 144 }
153 145
154 while (emu_window->IsOpen()) { 146 while (emu_window->IsOpen()) {
155 Core::RunLoop(); 147 system.RunLoop();
156 } 148 }
157 149
158 return 0; 150 return 0;