diff options
author | wwylele <wwylele@gmail.com> | 2016-11-30 10:32:09 +0100 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2016-12-07 19:52:42 +0100 |
commit | 84e78790ab3f3e8883493b18946e97328d921774 (patch) | |
tree | 31b000e21876310ccd91e1746c86b643908b5a27 /src/core/loader | |
parent | Merge pull request #2232 from wwylele/other-save (diff) | |
download | yuzu-84e78790ab3f3e8883493b18946e97328d921774.tar yuzu-84e78790ab3f3e8883493b18946e97328d921774.tar.gz yuzu-84e78790ab3f3e8883493b18946e97328d921774.tar.bz2 yuzu-84e78790ab3f3e8883493b18946e97328d921774.tar.lz yuzu-84e78790ab3f3e8883493b18946e97328d921774.tar.xz yuzu-84e78790ab3f3e8883493b18946e97328d921774.tar.zst yuzu-84e78790ab3f3e8883493b18946e97328d921774.zip |
Diffstat (limited to 'src/core/loader')
-rw-r--r-- | src/core/loader/ncch.cpp | 22 | ||||
-rw-r--r-- | src/core/loader/ncch.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index d4be61e0e..dce7f50f9 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -11,8 +11,10 @@ #include "core/file_sys/archive_romfs.h" #include "core/hle/kernel/process.h" #include "core/hle/kernel/resource_limit.h" +#include "core/hle/service/cfg/cfg.h" #include "core/hle/service/fs/archive.h" #include "core/loader/ncch.h" +#include "core/loader/smdh.h" #include "core/memory.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -309,6 +311,23 @@ ResultStatus AppLoader_NCCH::LoadExeFS() { return ResultStatus::Success; } +void AppLoader_NCCH::ParseRegionLockoutInfo() { + std::vector<u8> smdh_buffer; + if (ReadIcon(smdh_buffer) == ResultStatus::Success && smdh_buffer.size() >= sizeof(SMDH)) { + SMDH smdh; + memcpy(&smdh, smdh_buffer.data(), sizeof(SMDH)); + u32 region_lockout = smdh.region_lockout; + constexpr u32 REGION_COUNT = 7; + for (u32 region = 0; region < REGION_COUNT; ++region) { + if (region_lockout & 1) { + Service::CFG::SetPreferredRegionCode(region); + break; + } + region_lockout >>= 1; + } + } +} + ResultStatus AppLoader_NCCH::Load() { if (is_loaded) return ResultStatus::ErrorAlreadyLoaded; @@ -325,6 +344,9 @@ ResultStatus AppLoader_NCCH::Load() { Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*this), Service::FS::ArchiveIdCode::RomFS); + + ParseRegionLockoutInfo(); + return ResultStatus::Success; } diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index bcf3ae6e3..e9e11727b 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -250,6 +250,9 @@ private: */ ResultStatus LoadExeFS(); + /// Reads the region lockout info in the SMDH and send it to CFG service + void ParseRegionLockoutInfo(); + bool is_exefs_loaded = false; bool is_compressed = false; |