summaryrefslogtreecommitdiffstats
path: root/src/core/loader/ncch.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2016-12-30 04:09:01 +0100
committerGitHub <noreply@github.com>2016-12-30 04:09:01 +0100
commitf556d6ee90aae2d81cd9770c0b3259ac88ae8fe4 (patch)
tree63472a7c6dbd7bc9f77ba503800afdaf36982da5 /src/core/loader/ncch.cpp
parentMerge pull request #2367 from JayFoxRox/lighting-lut-quickfix (diff)
parentConfig: auto-select region and language (diff)
downloadyuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar
yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar.gz
yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar.bz2
yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar.lz
yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar.xz
yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar.zst
yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.zip
Diffstat (limited to 'src/core/loader/ncch.cpp')
-rw-r--r--src/core/loader/ncch.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 6f2164428..a204dc336 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;
}