diff options
| author | 2020-12-04 01:41:21 -0500 | |
|---|---|---|
| committer | 2020-12-08 08:19:05 -0500 | |
| commit | 0eb6c6cd836028a94260321e460871c228deee50 (patch) | |
| tree | 1f32afb694eae681c5d5936efe751f0f0d3cb972 /src/core/file_sys | |
| parent | Merge pull request #5165 from lioncash/copy-controller (diff) | |
| download | yuzu-0eb6c6cd836028a94260321e460871c228deee50.tar.gz yuzu-0eb6c6cd836028a94260321e460871c228deee50.tar.xz yuzu-0eb6c6cd836028a94260321e460871c228deee50.zip | |
file_sys: Consolidate common Title ID operations
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/common_funcs.h | 56 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 4 |
2 files changed, 58 insertions, 2 deletions
diff --git a/src/core/file_sys/common_funcs.h b/src/core/file_sys/common_funcs.h new file mode 100644 index 000000000..7ed97aa50 --- /dev/null +++ b/src/core/file_sys/common_funcs.h | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | // Copyright 2020 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace FileSys { | ||
| 10 | |||
| 11 | constexpr u64 AOC_TITLE_ID_MASK = 0x7FF; | ||
| 12 | constexpr u64 AOC_TITLE_ID_OFFSET = 0x1000; | ||
| 13 | constexpr u64 BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * Gets the base title ID from a given title ID. | ||
| 17 | * | ||
| 18 | * @param title_id The title ID. | ||
| 19 | * @returns The base title ID. | ||
| 20 | */ | ||
| 21 | [[nodiscard]] constexpr u64 GetBaseTitleID(u64 title_id) { | ||
| 22 | return title_id & BASE_TITLE_ID_MASK; | ||
| 23 | } | ||
| 24 | |||
| 25 | /** | ||
| 26 | * Gets the base title ID with a program index offset from a given title ID. | ||
| 27 | * | ||
| 28 | * @param title_id The title ID. | ||
| 29 | * @param program_index The program index. | ||
| 30 | * @returns The base title ID with a program index offset. | ||
| 31 | */ | ||
| 32 | [[nodiscard]] constexpr u64 GetBaseTitleIDWithProgramIndex(u64 title_id, u64 program_index) { | ||
| 33 | return GetBaseTitleID(title_id) + program_index; | ||
| 34 | } | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Gets the AOC (Add-On Content) base title ID from a given title ID. | ||
| 38 | * | ||
| 39 | * @param title_id The title ID. | ||
| 40 | * @returns The AOC base title ID. | ||
| 41 | */ | ||
| 42 | [[nodiscard]] constexpr u64 GetAOCBaseTitleID(u64 title_id) { | ||
| 43 | return GetBaseTitleID(title_id) + AOC_TITLE_ID_OFFSET; | ||
| 44 | } | ||
| 45 | |||
| 46 | /** | ||
| 47 | * Gets the AOC (Add-On Content) ID from a given AOC title ID. | ||
| 48 | * | ||
| 49 | * @param aoc_title_id The AOC title ID. | ||
| 50 | * @returns The AOC ID. | ||
| 51 | */ | ||
| 52 | [[nodiscard]] constexpr u64 GetAOCID(u64 aoc_title_id) { | ||
| 53 | return aoc_title_id & AOC_TITLE_ID_MASK; | ||
| 54 | } | ||
| 55 | |||
| 56 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index e9d1607d0..7c3284df8 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "common/string_util.h" | 13 | #include "common/string_util.h" |
| 14 | #include "core/core.h" | 14 | #include "core/core.h" |
| 15 | #include "core/file_sys/common_funcs.h" | ||
| 15 | #include "core/file_sys/content_archive.h" | 16 | #include "core/file_sys/content_archive.h" |
| 16 | #include "core/file_sys/control_metadata.h" | 17 | #include "core/file_sys/control_metadata.h" |
| 17 | #include "core/file_sys/ips_layer.h" | 18 | #include "core/file_sys/ips_layer.h" |
| @@ -30,7 +31,6 @@ namespace FileSys { | |||
| 30 | namespace { | 31 | namespace { |
| 31 | 32 | ||
| 32 | constexpr u32 SINGLE_BYTE_MODULUS = 0x100; | 33 | constexpr u32 SINGLE_BYTE_MODULUS = 0x100; |
| 33 | constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; | ||
| 34 | 34 | ||
| 35 | constexpr std::array<const char*, 14> EXEFS_FILE_NAMES{ | 35 | constexpr std::array<const char*, 14> EXEFS_FILE_NAMES{ |
| 36 | "main", "main.npdm", "rtld", "sdk", "subsdk0", "subsdk1", "subsdk2", | 36 | "main", "main.npdm", "rtld", "sdk", "subsdk0", "subsdk1", "subsdk2", |
| @@ -532,7 +532,7 @@ PatchManager::PatchVersionNames PatchManager::GetPatchVersionNames(VirtualFile u | |||
| 532 | dlc_match.reserve(dlc_entries.size()); | 532 | dlc_match.reserve(dlc_entries.size()); |
| 533 | std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), | 533 | std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), |
| 534 | [this](const ContentProviderEntry& entry) { | 534 | [this](const ContentProviderEntry& entry) { |
| 535 | return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && | 535 | return GetBaseTitleID(entry.title_id) == title_id && |
| 536 | content_provider.GetEntry(entry)->GetStatus() == | 536 | content_provider.GetEntry(entry)->GetStatus() == |
| 537 | Loader::ResultStatus::Success; | 537 | Loader::ResultStatus::Success; |
| 538 | }); | 538 | }); |