diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/citra/citra.cpp | 12 | ||||
| -rw-r--r-- | src/citra_qt/main.cpp | 9 | ||||
| -rw-r--r-- | src/core/loader/loader.h | 13 | ||||
| -rw-r--r-- | src/core/loader/ncch.cpp | 15 | ||||
| -rw-r--r-- | src/core/loader/ncch.h | 5 |
5 files changed, 27 insertions, 27 deletions
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index c742be231..f9387e61c 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp | |||
| @@ -135,17 +135,17 @@ int main(int argc, char** argv) { | |||
| 135 | return -1; | 135 | return -1; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | u32 system_mode; | 138 | boost::optional<u32> system_mode = loader->LoadKernelSystemMode(); |
| 139 | Loader::ResultStatus load_result = loader->LoadKernelSystemMode(system_mode); | 139 | |
| 140 | if (Loader::ResultStatus::Success != load_result) { | 140 | if (!system_mode) { |
| 141 | LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); | 141 | LOG_CRITICAL(Frontend, "Failed to load ROM (Could not determine system mode)!"); |
| 142 | return -1; | 142 | return -1; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | System::Init(emu_window.get(), system_mode); | 145 | System::Init(emu_window.get(), system_mode.get()); |
| 146 | SCOPE_EXIT({ System::Shutdown(); }); | 146 | SCOPE_EXIT({ System::Shutdown(); }); |
| 147 | 147 | ||
| 148 | load_result = loader->Load(); | 148 | Loader::ResultStatus load_result = loader->Load(); |
| 149 | if (Loader::ResultStatus::Success != load_result) { | 149 | if (Loader::ResultStatus::Success != load_result) { |
| 150 | LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); | 150 | LOG_CRITICAL(Frontend, "Failed to load ROM (Error %i)!", load_result); |
| 151 | return -1; | 151 | return -1; |
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 9589da4ba..a3887f9ab 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp | |||
| @@ -299,16 +299,15 @@ bool GMainWindow::LoadROM(const std::string& filename) { | |||
| 299 | return false; | 299 | return false; |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | u32 system_mode; | 302 | boost::optional<u32> system_mode = app_loader->LoadKernelSystemMode(); |
| 303 | Loader::ResultStatus load_result = app_loader->LoadKernelSystemMode(system_mode); | 303 | if (!system_mode) { |
| 304 | if (Loader::ResultStatus::Success != load_result) { | 304 | LOG_CRITICAL(Frontend, "Failed to load ROM!"); |
| 305 | LOG_CRITICAL(Frontend, "Failed to load ROM!", load_result); | ||
| 306 | QMessageBox::critical(this, tr("Error while loading ROM!"), | 305 | QMessageBox::critical(this, tr("Error while loading ROM!"), |
| 307 | tr("Could not determine the system mode.")); | 306 | tr("Could not determine the system mode.")); |
| 308 | return false; | 307 | return false; |
| 309 | } | 308 | } |
| 310 | 309 | ||
| 311 | if (!InitializeSystem(system_mode)) | 310 | if (!InitializeSystem(system_mode.get())) |
| 312 | return false; | 311 | return false; |
| 313 | 312 | ||
| 314 | Loader::ResultStatus result = app_loader->Load(); | 313 | Loader::ResultStatus result = app_loader->Load(); |
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index e62f77b9c..5e3d46638 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <memory> | 9 | #include <memory> |
| 10 | #include <string> | 10 | #include <string> |
| 11 | #include <vector> | 11 | #include <vector> |
| 12 | #include <boost/optional.hpp> | ||
| 12 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 13 | #include "common/file_util.h" | 14 | #include "common/file_util.h" |
| 14 | 15 | ||
| @@ -97,13 +98,13 @@ public: | |||
| 97 | 98 | ||
| 98 | /** | 99 | /** |
| 99 | * Loads the system mode that this application needs. | 100 | * Loads the system mode that this application needs. |
| 100 | * This function defaults to 2 (96MB allocated to the application) if it can't read the information. | 101 | * This function defaults to 2 (96MB allocated to the application) if it can't read the |
| 101 | * @param system_mode Out variable where the system mode will be stored. | 102 | * information. |
| 102 | * @returns ResultStatus result of the operation | 103 | * @returns Optional with the kernel system mode |
| 103 | */ | 104 | */ |
| 104 | virtual ResultStatus LoadKernelSystemMode(u32& system_mode) { | 105 | virtual boost::optional<u32> LoadKernelSystemMode() { |
| 105 | system_mode = 2; // 96MB allocated to the application. | 106 | // 96MB allocated to the application. |
| 106 | return ResultStatus::Success; | 107 | return 2; |
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | /** | 110 | /** |
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index 6fbaf4036..d4be61e0e 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp | |||
| @@ -117,12 +117,12 @@ FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) { | |||
| 117 | return FileType::Error; | 117 | return FileType::Error; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | ResultStatus AppLoader_NCCH::LoadKernelSystemMode(u32& memory_type) { | 120 | boost::optional<u32> AppLoader_NCCH::LoadKernelSystemMode() { |
| 121 | ResultStatus result = LoadExeFS(); | 121 | if (!is_loaded) { |
| 122 | if (result != ResultStatus::Success) | 122 | if (LoadExeFS() != ResultStatus::Success) |
| 123 | return result; | 123 | return boost::none; |
| 124 | memory_type = exheader_header.arm11_system_local_caps.system_mode; | 124 | } |
| 125 | return ResultStatus::Success; | 125 | return exheader_header.arm11_system_local_caps.system_mode.Value(); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | ResultStatus AppLoader_NCCH::LoadExec() { | 128 | ResultStatus AppLoader_NCCH::LoadExec() { |
| @@ -285,7 +285,8 @@ ResultStatus AppLoader_NCCH::LoadExeFS() { | |||
| 285 | LOG_DEBUG(Loader, "Core version: %d", core_version); | 285 | LOG_DEBUG(Loader, "Core version: %d", core_version); |
| 286 | LOG_DEBUG(Loader, "Thread priority: 0x%X", priority); | 286 | LOG_DEBUG(Loader, "Thread priority: 0x%X", priority); |
| 287 | LOG_DEBUG(Loader, "Resource limit category: %d", resource_limit_category); | 287 | LOG_DEBUG(Loader, "Resource limit category: %d", resource_limit_category); |
| 288 | LOG_DEBUG(Loader, "System Mode: %d", exheader_header.arm11_system_local_caps.system_mode); | 288 | LOG_DEBUG(Loader, "System Mode: %d", |
| 289 | exheader_header.arm11_system_local_caps.system_mode); | ||
| 289 | 290 | ||
| 290 | if (exheader_header.arm11_system_local_caps.program_id != ncch_header.program_id) { | 291 | if (exheader_header.arm11_system_local_caps.program_id != ncch_header.program_id) { |
| 291 | LOG_ERROR(Loader, "ExHeader Program ID mismatch: the ROM is probably encrypted."); | 292 | LOG_ERROR(Loader, "ExHeader Program ID mismatch: the ROM is probably encrypted."); |
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index 63947c28e..bcf3ae6e3 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h | |||
| @@ -187,10 +187,9 @@ public: | |||
| 187 | 187 | ||
| 188 | /** | 188 | /** |
| 189 | * Loads the Exheader and returns the system mode for this application. | 189 | * Loads the Exheader and returns the system mode for this application. |
| 190 | * @param system_mode Out variable where the system mode will be stored. | 190 | * @return Optional with the kernel system mode |
| 191 | * @return ResultStatus result of the operation | ||
| 192 | */ | 191 | */ |
| 193 | ResultStatus LoadKernelSystemMode(u32& system_mode); | 192 | boost::optional<u32> LoadKernelSystemMode(); |
| 194 | 193 | ||
| 195 | /** | 194 | /** |
| 196 | * Get the code (typically .code section) of the application | 195 | * Get the code (typically .code section) of the application |