From 1edbbf7f8ca3c8e83d0ab38e448e2a2bbffec7c4 Mon Sep 17 00:00:00 2001 From: shinyquagsire23 Date: Tue, 14 Nov 2017 14:57:44 -0700 Subject: [PATCH] Services/AM: Add GetTitleMediaType --- src/core/hle/service/am/am.cpp | 18 ++++++++++++++++++ src/core/hle/service/am/am.h | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 30c4828b8..c3d6bf392 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -37,6 +37,10 @@ namespace Service { namespace AM { +constexpr u16 PLATFORM_CTR = 0x0004; +constexpr u16 CATEGORY_SYSTEM = 0x0010; +constexpr u16 CATEGORY_DLP = 0x0001; +constexpr u8 VARIATION_SYSTEM = 0x02; constexpr u32 TID_HIGH_UPDATE = 0x0004000E; constexpr u32 TID_HIGH_DLC = 0x0004008C; @@ -263,6 +267,20 @@ private: Service::FS::MediaType media_type; }; +Service::FS::MediaType GetTitleMediaType(u64 titleId) { + u16 platform = static_cast(titleId >> 48); + u16 category = static_cast((titleId >> 32) & 0xFFFF); + u8 variation = static_cast(titleId & 0xFF); + + if (platform != PLATFORM_CTR) + return Service::FS::MediaType::NAND; + + if (category & CATEGORY_SYSTEM || category & CATEGORY_DLP || variation & VARIATION_SYSTEM) + return Service::FS::MediaType::NAND; + + return Service::FS::MediaType::SDMC; +} + std::string GetTitleMetadataPath(Service::FS::MediaType media_type, u64 tid, bool update) { std::string content_path = GetTitlePath(media_type, tid) + "content/"; diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index 04493d943..4cbd090b5 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -38,6 +38,13 @@ enum class CIAInstallState : u32 { ContentWritten, }; +/** + * Get the mediatype for an installed title + * @param titleId the installed title ID + * @returns MediaType which the installed title will reside on + */ +Service::FS::MediaType GetTitleMediaType(u64 titleId); + /** * Get the .tmd path for a title * @param media_type the media the title exists on