summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/common_funcs.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-12-15 20:07:03 +0100
committerGitHub <noreply@github.com>2020-12-15 20:07:03 +0100
commit2e1b998d5ed676f7d637916a40118450cf0599a1 (patch)
tree77e254b90270dcf28052d79bd6fdddfa9c77783c /src/core/file_sys/common_funcs.h
parentMerge pull request #5157 from lioncash/array-dirty (diff)
parentfsp_srv: Implement OpenDataStorageWithProgramIndex (diff)
downloadyuzu-2e1b998d5ed676f7d637916a40118450cf0599a1.tar
yuzu-2e1b998d5ed676f7d637916a40118450cf0599a1.tar.gz
yuzu-2e1b998d5ed676f7d637916a40118450cf0599a1.tar.bz2
yuzu-2e1b998d5ed676f7d637916a40118450cf0599a1.tar.lz
yuzu-2e1b998d5ed676f7d637916a40118450cf0599a1.tar.xz
yuzu-2e1b998d5ed676f7d637916a40118450cf0599a1.tar.zst
yuzu-2e1b998d5ed676f7d637916a40118450cf0599a1.zip
Diffstat (limited to 'src/core/file_sys/common_funcs.h')
-rw-r--r--src/core/file_sys/common_funcs.h56
1 files changed, 56 insertions, 0 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 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include "common/common_types.h"
+
+namespace FileSys {
+
+constexpr u64 AOC_TITLE_ID_MASK = 0x7FF;
+constexpr u64 AOC_TITLE_ID_OFFSET = 0x1000;
+constexpr u64 BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000;
+
+/**
+ * Gets the base title ID from a given title ID.
+ *
+ * @param title_id The title ID.
+ * @returns The base title ID.
+ */
+[[nodiscard]] constexpr u64 GetBaseTitleID(u64 title_id) {
+ return title_id & BASE_TITLE_ID_MASK;
+}
+
+/**
+ * Gets the base title ID with a program index offset from a given title ID.
+ *
+ * @param title_id The title ID.
+ * @param program_index The program index.
+ * @returns The base title ID with a program index offset.
+ */
+[[nodiscard]] constexpr u64 GetBaseTitleIDWithProgramIndex(u64 title_id, u64 program_index) {
+ return GetBaseTitleID(title_id) + program_index;
+}
+
+/**
+ * Gets the AOC (Add-On Content) base title ID from a given title ID.
+ *
+ * @param title_id The title ID.
+ * @returns The AOC base title ID.
+ */
+[[nodiscard]] constexpr u64 GetAOCBaseTitleID(u64 title_id) {
+ return GetBaseTitleID(title_id) + AOC_TITLE_ID_OFFSET;
+}
+
+/**
+ * Gets the AOC (Add-On Content) ID from a given AOC title ID.
+ *
+ * @param aoc_title_id The AOC title ID.
+ * @returns The AOC ID.
+ */
+[[nodiscard]] constexpr u64 GetAOCID(u64 aoc_title_id) {
+ return aoc_title_id & AOC_TITLE_ID_MASK;
+}
+
+} // namespace FileSys