diff options
| author | 2016-12-29 22:09:01 -0500 | |
|---|---|---|
| committer | 2016-12-29 22:09:01 -0500 | |
| commit | f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4 (patch) | |
| tree | 63472a7c6dbd7bc9f77ba503800afdaf36982da5 /src/core/loader/ncch.cpp | |
| parent | Merge pull request #2367 from JayFoxRox/lighting-lut-quickfix (diff) | |
| parent | Config: auto-select region and language (diff) | |
| download | yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar.gz yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.tar.xz yuzu-f556d6ee90aae2d81cd9770c0b3259ac88ae8fe4.zip | |
Merge pull request #2240 from wwylele/auto-region
Config: auto-select region and language
Diffstat (limited to 'src/core/loader/ncch.cpp')
| -rw-r--r-- | src/core/loader/ncch.cpp | 22 |
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 @@ | |||
| 11 | #include "core/file_sys/archive_romfs.h" | 11 | #include "core/file_sys/archive_romfs.h" |
| 12 | #include "core/hle/kernel/process.h" | 12 | #include "core/hle/kernel/process.h" |
| 13 | #include "core/hle/kernel/resource_limit.h" | 13 | #include "core/hle/kernel/resource_limit.h" |
| 14 | #include "core/hle/service/cfg/cfg.h" | ||
| 14 | #include "core/hle/service/fs/archive.h" | 15 | #include "core/hle/service/fs/archive.h" |
| 15 | #include "core/loader/ncch.h" | 16 | #include "core/loader/ncch.h" |
| 17 | #include "core/loader/smdh.h" | ||
| 16 | #include "core/memory.h" | 18 | #include "core/memory.h" |
| 17 | 19 | ||
| 18 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 20 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| @@ -309,6 +311,23 @@ ResultStatus AppLoader_NCCH::LoadExeFS() { | |||
| 309 | return ResultStatus::Success; | 311 | return ResultStatus::Success; |
| 310 | } | 312 | } |
| 311 | 313 | ||
| 314 | void AppLoader_NCCH::ParseRegionLockoutInfo() { | ||
| 315 | std::vector<u8> smdh_buffer; | ||
| 316 | if (ReadIcon(smdh_buffer) == ResultStatus::Success && smdh_buffer.size() >= sizeof(SMDH)) { | ||
| 317 | SMDH smdh; | ||
| 318 | memcpy(&smdh, smdh_buffer.data(), sizeof(SMDH)); | ||
| 319 | u32 region_lockout = smdh.region_lockout; | ||
| 320 | constexpr u32 REGION_COUNT = 7; | ||
| 321 | for (u32 region = 0; region < REGION_COUNT; ++region) { | ||
| 322 | if (region_lockout & 1) { | ||
| 323 | Service::CFG::SetPreferredRegionCode(region); | ||
| 324 | break; | ||
| 325 | } | ||
| 326 | region_lockout >>= 1; | ||
| 327 | } | ||
| 328 | } | ||
| 329 | } | ||
| 330 | |||
| 312 | ResultStatus AppLoader_NCCH::Load() { | 331 | ResultStatus AppLoader_NCCH::Load() { |
| 313 | if (is_loaded) | 332 | if (is_loaded) |
| 314 | return ResultStatus::ErrorAlreadyLoaded; | 333 | return ResultStatus::ErrorAlreadyLoaded; |
| @@ -325,6 +344,9 @@ ResultStatus AppLoader_NCCH::Load() { | |||
| 325 | 344 | ||
| 326 | Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*this), | 345 | Service::FS::RegisterArchiveType(std::make_unique<FileSys::ArchiveFactory_RomFS>(*this), |
| 327 | Service::FS::ArchiveIdCode::RomFS); | 346 | Service::FS::ArchiveIdCode::RomFS); |
| 347 | |||
| 348 | ParseRegionLockoutInfo(); | ||
| 349 | |||
| 328 | return ResultStatus::Success; | 350 | return ResultStatus::Success; |
| 329 | } | 351 | } |
| 330 | 352 | ||