diff options
| -rw-r--r-- | src/citra_qt/main.cpp | 50 | ||||
| -rw-r--r-- | src/citra_qt/main.h | 2 | ||||
| -rw-r--r-- | src/core/core.cpp | 3 | ||||
| -rw-r--r-- | src/core/core.h | 2 | ||||
| -rw-r--r-- | src/core/loader/loader.cpp | 1 | ||||
| -rw-r--r-- | src/core/system.cpp | 6 | ||||
| -rw-r--r-- | src/core/system.h | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_base.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 2 | ||||
| -rw-r--r-- | src/video_core/video_core.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/video_core.h | 2 |
12 files changed, 72 insertions, 27 deletions
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index d2ba3f9db..21f4e3a80 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -248,17 +248,32 @@ void GMainWindow::OnDisplayTitleBars(bool show) | |||
| 248 | } | 248 | } |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | void GMainWindow::BootGame(const std::string& filename) { | 251 | bool GMainWindow::InitializeSystem() { |
| 252 | LOG_INFO(Frontend, "Citra starting..."); | ||
| 253 | |||
| 254 | // Shutdown previous session if the emu thread is still active... | 252 | // Shutdown previous session if the emu thread is still active... |
| 255 | if (emu_thread != nullptr) | 253 | if (emu_thread != nullptr) |
| 256 | ShutdownGame(); | 254 | ShutdownGame(); |
| 257 | 255 | ||
| 258 | // Initialize the core emulation | 256 | // Initialize the core emulation |
| 259 | System::Init(render_window); | 257 | System::Result system_result = System::Init(render_window); |
| 258 | if (System::Result::Success != system_result) { | ||
| 259 | switch (system_result) { | ||
| 260 | case System::Result::ErrorInitVideoCore: | ||
| 261 | QMessageBox::critical(this, tr("Error while starting Citra!"), | ||
| 262 | tr("Failed to initialize the video core!\n\n" | ||
| 263 | "Please ensure that your GPU supports OpenGL 3.3 and that you have the latest graphics driver.")); | ||
| 264 | break; | ||
| 265 | |||
| 266 | default: | ||
| 267 | QMessageBox::critical(this, tr("Error while starting Citra!"), | ||
| 268 | tr("Unknown error (please check the log)!")); | ||
| 269 | break; | ||
| 270 | } | ||
| 271 | return false; | ||
| 272 | } | ||
| 273 | return true; | ||
| 274 | } | ||
| 260 | 275 | ||
| 261 | // Load the game | 276 | bool GMainWindow::LoadROM(const std::string& filename) { |
| 262 | Loader::ResultStatus result = Loader::LoadFile(filename); | 277 | Loader::ResultStatus result = Loader::LoadFile(filename); |
| 263 | if (Loader::ResultStatus::Success != result) { | 278 | if (Loader::ResultStatus::Success != result) { |
| 264 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); | 279 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); |
| @@ -269,26 +284,37 @@ void GMainWindow::BootGame(const std::string& filename) { | |||
| 269 | // Build the MessageBox ourselves to have clickable link | 284 | // Build the MessageBox ourselves to have clickable link |
| 270 | QMessageBox popup_error; | 285 | QMessageBox popup_error; |
| 271 | popup_error.setTextFormat(Qt::RichText); | 286 | popup_error.setTextFormat(Qt::RichText); |
| 272 | popup_error.setWindowTitle(tr("Error while loading ROM !")); | 287 | popup_error.setWindowTitle(tr("Error while loading ROM!")); |
| 273 | popup_error.setText(tr("The ROM is probably encrypted !<br/><br/>" | 288 | popup_error.setText(tr("The game that you are trying to load must be decrypted before being used with Citra.<br/><br/>" |
| 274 | "Please check: <a href='https://github.com/citra-emu/citra/wiki/Dumping-Game-Cartridges'>https://github.com/citra-emu/citra/wiki/Dumping-Game-Cartridges</a>")); | 289 | "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>")); |
| 275 | popup_error.setIcon(QMessageBox::Critical); | 290 | popup_error.setIcon(QMessageBox::Critical); |
| 276 | popup_error.exec(); | 291 | popup_error.exec(); |
| 277 | break; | 292 | break; |
| 278 | } | 293 | } |
| 279 | case Loader::ResultStatus::ErrorInvalidFormat: | 294 | case Loader::ResultStatus::ErrorInvalidFormat: |
| 280 | QMessageBox::critical(this, tr("Error while loading ROM !"), | 295 | QMessageBox::critical(this, tr("Error while loading ROM!"), |
| 281 | tr("The ROM format is not supported.")); | 296 | tr("The ROM format is not supported.")); |
| 282 | break; | 297 | break; |
| 283 | case Loader::ResultStatus::Error: | 298 | case Loader::ResultStatus::Error: |
| 284 | 299 | ||
| 285 | default: | 300 | default: |
| 286 | QMessageBox::critical(this, tr("Error while loading ROM !"), | 301 | QMessageBox::critical(this, tr("Error while loading ROM!"), |
| 287 | tr("Unknown error !")); | 302 | tr("Unknown error!")); |
| 288 | break; | 303 | break; |
| 289 | } | 304 | } |
| 290 | return; | 305 | return false; |
| 291 | } | 306 | } |
| 307 | return true; | ||
| 308 | } | ||
| 309 | |||
| 310 | void GMainWindow::BootGame(const std::string& filename) { | ||
| 311 | LOG_INFO(Frontend, "Citra starting..."); | ||
| 312 | |||
| 313 | if (!InitializeSystem()) | ||
| 314 | return; | ||
| 315 | |||
| 316 | if (!LoadROM(filename)) | ||
| 317 | return; | ||
| 292 | 318 | ||
| 293 | // Create and start the emulation thread | 319 | // Create and start the emulation thread |
| 294 | emu_thread = Common::make_unique<EmuThread>(render_window); | 320 | 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 | ||
| 61 | private: | 61 | private: |
| 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 |
| 76 | int Init() { | 76 | void 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 | ||
| 84 | void Shutdown() { | 83 | void 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); | |||
| 52 | void Stop(); | 52 | void Stop(); |
| 53 | 53 | ||
| 54 | /// Initialize the core | 54 | /// Initialize the core |
| 55 | int Init(); | 55 | void Init(); |
| 56 | 56 | ||
| 57 | /// Shutdown the core | 57 | /// Shutdown the core |
| 58 | void Shutdown(); | 58 | void Shutdown(); |
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 99f1183ca..b1907cd55 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -140,7 +140,6 @@ ResultStatus LoadFile(const std::string& filename) { | |||
| 140 | ResultStatus result = app_loader.Load(); | 140 | ResultStatus result = app_loader.Load(); |
| 141 | if (ResultStatus::Success == result) { | 141 | if (ResultStatus::Success == result) { |
| 142 | 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); |
| 143 | return ResultStatus::Success; | ||
| 144 | } | 143 | } |
| 145 | return result; | 144 | return result; |
| 146 | } | 145 | } |
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 | ||
| 18 | namespace System { | 18 | namespace System { |
| 19 | 19 | ||
| 20 | void Init(EmuWindow* emu_window) { | 20 | Result 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 | ||
| 9 | namespace System { | 9 | namespace System { |
| 10 | 10 | ||
| 11 | void Init(EmuWindow* emu_window); | 11 | enum 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 | |||
| 18 | Result Init(EmuWindow* emu_window); | ||
| 12 | void Shutdown(); | 19 | void 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 |
| 448 | void RendererOpenGL::Init() { | 448 | bool 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; | |||
| 28 | std::atomic<bool> g_shader_jit_enabled; | 28 | std::atomic<bool> g_shader_jit_enabled; |
| 29 | 29 | ||
| 30 | /// Initialize the video core | 30 | /// Initialize the video core |
| 31 | void Init(EmuWindow* emu_window) { | 31 | bool 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; | |||
| 41 | void Start(); | 41 | void Start(); |
| 42 | 42 | ||
| 43 | /// Initialize the video core | 43 | /// Initialize the video core |
| 44 | void Init(EmuWindow* emu_window); | 44 | bool Init(EmuWindow* emu_window); |
| 45 | 45 | ||
| 46 | /// Shutdown the video core | 46 | /// Shutdown the video core |
| 47 | void Shutdown(); | 47 | void Shutdown(); |