summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/citra_qt/main.cpp65
-rw-r--r--src/citra_qt/main.h2
-rw-r--r--src/core/core.cpp3
-rw-r--r--src/core/core.h2
-rw-r--r--src/core/loader/loader.cpp6
-rw-r--r--src/core/system.cpp6
-rw-r--r--src/core/system.h9
-rw-r--r--src/video_core/renderer_base.h2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp8
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h2
-rw-r--r--src/video_core/video_core.cpp12
-rw-r--r--src/video_core/video_core.h2
12 files changed, 95 insertions, 24 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 1854f442a..57adbc136 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -249,22 +249,73 @@ void GMainWindow::OnDisplayTitleBars(bool show)
249 } 249 }
250} 250}
251 251
252void GMainWindow::BootGame(const std::string& filename) { 252bool GMainWindow::InitializeSystem() {
253 LOG_INFO(Frontend, "Citra starting...");
254
255 // Shutdown previous session if the emu thread is still active... 253 // Shutdown previous session if the emu thread is still active...
256 if (emu_thread != nullptr) 254 if (emu_thread != nullptr)
257 ShutdownGame(); 255 ShutdownGame();
258 256
259 // Initialize the core emulation 257 // Initialize the core emulation
260 System::Init(render_window); 258 System::Result system_result = System::Init(render_window);
259 if (System::Result::Success != system_result) {
260 switch (system_result) {
261 case System::Result::ErrorInitVideoCore:
262 QMessageBox::critical(this, tr("Error while starting Citra!"),
263 tr("Failed to initialize the video core!\n\n"
264 "Please ensure that your GPU supports OpenGL 3.3 and that you have the latest graphics driver."));
265 break;
266
267 default:
268 QMessageBox::critical(this, tr("Error while starting Citra!"),
269 tr("Unknown error (please check the log)!"));
270 break;
271 }
272 return false;
273 }
274 return true;
275}
261 276
262 // Load the game 277bool GMainWindow::LoadROM(const std::string& filename) {
263 if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) { 278 Loader::ResultStatus result = Loader::LoadFile(filename);
279 if (Loader::ResultStatus::Success != result) {
264 LOG_CRITICAL(Frontend, "Failed to load ROM!"); 280 LOG_CRITICAL(Frontend, "Failed to load ROM!");
265 System::Shutdown(); 281 System::Shutdown();
266 return; 282
283 switch (result) {
284 case Loader::ResultStatus::ErrorEncrypted: {
285 // Build the MessageBox ourselves to have clickable link
286 QMessageBox popup_error;
287 popup_error.setTextFormat(Qt::RichText);
288 popup_error.setWindowTitle(tr("Error while loading ROM!"));
289 popup_error.setText(tr("The game that you are trying to load must be decrypted before being used with Citra.<br/><br/>"
290 "For more information on dumping and decrypting games, please see: <a href='https://citra-emu.org/wiki/Dumping-Game-Cartridges'>https://citra-emu.org/wiki/Dumping-Game-Cartridges</a>"));
291 popup_error.setIcon(QMessageBox::Critical);
292 popup_error.exec();
293 break;
294 }
295 case Loader::ResultStatus::ErrorInvalidFormat:
296 QMessageBox::critical(this, tr("Error while loading ROM!"),
297 tr("The ROM format is not supported."));
298 break;
299 case Loader::ResultStatus::Error:
300
301 default:
302 QMessageBox::critical(this, tr("Error while loading ROM!"),
303 tr("Unknown error!"));
304 break;
305 }
306 return false;
267 } 307 }
308 return true;
309}
310
311void GMainWindow::BootGame(const std::string& filename) {
312 LOG_INFO(Frontend, "Citra starting...");
313
314 if (!InitializeSystem())
315 return;
316
317 if (!LoadROM(filename))
318 return;
268 319
269 // Create and start the emulation thread 320 // Create and start the emulation thread
270 emu_thread = Common::make_unique<EmuThread>(render_window); 321 emu_thread = Common::make_unique<EmuThread>(render_window);
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index 8c195f816..945aea0cd 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -59,6 +59,8 @@ signals:
59 void EmulationStopping(); 59 void EmulationStopping();
60 60
61private: 61private:
62 bool InitializeSystem();
63 bool LoadROM(const std::string& filename);
62 void BootGame(const std::string& filename); 64 void BootGame(const std::string& filename);
63 void ShutdownGame(); 65 void ShutdownGame();
64 66
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 453c7162d..84d6c392e 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -73,12 +73,11 @@ void Stop() {
73} 73}
74 74
75/// Initialize the core 75/// Initialize the core
76int Init() { 76void Init() {
77 g_sys_core = Common::make_unique<ARM_DynCom>(USER32MODE); 77 g_sys_core = Common::make_unique<ARM_DynCom>(USER32MODE);
78 g_app_core = Common::make_unique<ARM_DynCom>(USER32MODE); 78 g_app_core = Common::make_unique<ARM_DynCom>(USER32MODE);
79 79
80 LOG_DEBUG(Core, "Initialized OK"); 80 LOG_DEBUG(Core, "Initialized OK");
81 return 0;
82} 81}
83 82
84void Shutdown() { 83void Shutdown() {
diff --git a/src/core/core.h b/src/core/core.h
index 453e0a5f0..ad26dca3f 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -52,7 +52,7 @@ void Halt(const char *msg);
52void Stop(); 52void Stop();
53 53
54/// Initialize the core 54/// Initialize the core
55int Init(); 55void Init();
56 56
57/// Shutdown the core 57/// Shutdown the core
58void Shutdown(); 58void Shutdown();
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 6b88169e1..b1907cd55 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -137,11 +137,11 @@ ResultStatus LoadFile(const std::string& filename) {
137 AppLoader_NCCH app_loader(std::move(file), filename); 137 AppLoader_NCCH app_loader(std::move(file), filename);
138 138
139 // Load application and RomFS 139 // Load application and RomFS
140 if (ResultStatus::Success == app_loader.Load()) { 140 ResultStatus result = app_loader.Load();
141 if (ResultStatus::Success == result) {
141 Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS); 142 Service::FS::RegisterArchiveType(Common::make_unique<FileSys::ArchiveFactory_RomFS>(app_loader), Service::FS::ArchiveIdCode::RomFS);
142 return ResultStatus::Success;
143 } 143 }
144 break; 144 return result;
145 } 145 }
146 146
147 // CIA file format... 147 // CIA file format...
diff --git a/src/core/system.cpp b/src/core/system.cpp
index b62ebf69e..1e3b2783c 100644
--- a/src/core/system.cpp
+++ b/src/core/system.cpp
@@ -17,14 +17,16 @@
17 17
18namespace System { 18namespace System {
19 19
20void Init(EmuWindow* emu_window) { 20Result Init(EmuWindow* emu_window) {
21 Core::Init(); 21 Core::Init();
22 CoreTiming::Init(); 22 CoreTiming::Init();
23 Memory::Init(); 23 Memory::Init();
24 HW::Init(); 24 HW::Init();
25 Kernel::Init(); 25 Kernel::Init();
26 HLE::Init(); 26 HLE::Init();
27 VideoCore::Init(emu_window); 27 if (!VideoCore::Init(emu_window)) {
28 return Result::ErrorInitVideoCore;
29 }
28 AudioCore::Init(); 30 AudioCore::Init();
29 GDBStub::Init(); 31 GDBStub::Init();
30} 32}
diff --git a/src/core/system.h b/src/core/system.h
index 59a75ca12..a4a627ea9 100644
--- a/src/core/system.h
+++ b/src/core/system.h
@@ -8,7 +8,14 @@ class EmuWindow;
8 8
9namespace System { 9namespace System {
10 10
11void Init(EmuWindow* emu_window); 11enum class Result {
12 Success, ///< Everything is fine
13 Error, ///< Something went wrong (no module specified)
14 ErrorInitCore, ///< Something went wrong during core init
15 ErrorInitVideoCore, ///< Something went wrong during video core init
16};
17
18Result Init(EmuWindow* emu_window);
12void Shutdown(); 19void Shutdown();
13 20
14} 21}
diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h
index 506bff815..91a7b7f17 100644
--- a/src/video_core/renderer_base.h
+++ b/src/video_core/renderer_base.h
@@ -38,7 +38,7 @@ public:
38 virtual void SetWindow(EmuWindow* window) = 0; 38 virtual void SetWindow(EmuWindow* window) = 0;
39 39
40 /// Initialize the renderer 40 /// Initialize the renderer
41 virtual void Init() = 0; 41 virtual bool Init() = 0;
42 42
43 /// Shutdown the renderer 43 /// Shutdown the renderer
44 virtual void ShutDown() = 0; 44 virtual void ShutDown() = 0;
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index ca3a6a6b4..11c4d0daf 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -445,7 +445,7 @@ static void DebugHandler(GLenum source, GLenum type, GLuint id, GLenum severity,
445} 445}
446 446
447/// Initialize the renderer 447/// Initialize the renderer
448void RendererOpenGL::Init() { 448bool RendererOpenGL::Init() {
449 render_window->MakeCurrent(); 449 render_window->MakeCurrent();
450 450
451 // TODO: Make frontends initialize this, so they can use gladLoadGLLoader with their own loaders 451 // TODO: Make frontends initialize this, so they can use gladLoadGLLoader with their own loaders
@@ -462,9 +462,15 @@ void RendererOpenGL::Init() {
462 LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION)); 462 LOG_INFO(Render_OpenGL, "GL_VERSION: %s", glGetString(GL_VERSION));
463 LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR)); 463 LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR));
464 LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER)); 464 LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER));
465 if (!GLAD_GL_VERSION_3_3) {
466 return false;
467 }
468
465 InitOpenGLObjects(); 469 InitOpenGLObjects();
466 470
467 RefreshRasterizerSetting(); 471 RefreshRasterizerSetting();
472
473 return true;
468} 474}
469 475
470/// Shutdown the renderer 476/// Shutdown the renderer
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index b42df7654..fe4d142a5 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -31,7 +31,7 @@ public:
31 void SetWindow(EmuWindow* window) override; 31 void SetWindow(EmuWindow* window) override;
32 32
33 /// Initialize the renderer 33 /// Initialize the renderer
34 void Init() override; 34 bool Init() override;
35 35
36 /// Shutdown the renderer 36 /// Shutdown the renderer
37 void ShutDown() override; 37 void ShutDown() override;
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index 912db91a4..ee5e50df1 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -28,15 +28,19 @@ std::atomic<bool> g_hw_renderer_enabled;
28std::atomic<bool> g_shader_jit_enabled; 28std::atomic<bool> g_shader_jit_enabled;
29 29
30/// Initialize the video core 30/// Initialize the video core
31void Init(EmuWindow* emu_window) { 31bool Init(EmuWindow* emu_window) {
32 Pica::Init(); 32 Pica::Init();
33 33
34 g_emu_window = emu_window; 34 g_emu_window = emu_window;
35 g_renderer = Common::make_unique<RendererOpenGL>(); 35 g_renderer = Common::make_unique<RendererOpenGL>();
36 g_renderer->SetWindow(g_emu_window); 36 g_renderer->SetWindow(g_emu_window);
37 g_renderer->Init(); 37 if (g_renderer->Init()) {
38 38 LOG_DEBUG(Render, "initialized OK");
39 LOG_DEBUG(Render, "initialized OK"); 39 } else {
40 LOG_ERROR(Render, "initialization failed !");
41 return false;
42 }
43 return true;
40} 44}
41 45
42/// Shutdown the video core 46/// Shutdown the video core
diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h
index accb0a4eb..bca67fb8c 100644
--- a/src/video_core/video_core.h
+++ b/src/video_core/video_core.h
@@ -41,7 +41,7 @@ extern std::atomic<bool> g_shader_jit_enabled;
41void Start(); 41void Start();
42 42
43/// Initialize the video core 43/// Initialize the video core
44void Init(EmuWindow* emu_window); 44bool Init(EmuWindow* emu_window);
45 45
46/// Shutdown the video core 46/// Shutdown the video core
47void Shutdown(); 47void Shutdown();