diff --git a/src/Cafe/GraphicPack/GraphicPack2.cpp b/src/Cafe/GraphicPack/GraphicPack2.cpp index 67ba6edc..aded9188 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2.cpp @@ -328,7 +328,7 @@ GraphicPack2::GraphicPack2(fs::path rulesPath, IniParser& rules) } m_title_ids = ParseTitleIds(rules, "titleIds"); - if(m_title_ids.empty() && !m_universal) + if(m_title_ids.empty()) throw std::exception(); auto option_fsPriority = rules.FindOption("fsPriority"); @@ -532,9 +532,6 @@ std::string GraphicPack2::GetNormalizedPathString() const bool GraphicPack2::ContainsTitleId(uint64_t title_id) const { - if (m_universal) - return true; - const auto it = std::find_if(m_title_ids.begin(), m_title_ids.end(), [title_id](uint64 id) { return id == title_id; }); return it != m_title_ids.end(); } @@ -1191,7 +1188,7 @@ std::vector GraphicPack2::GetActivePresets() const return result; } -std::vector GraphicPack2::ParseTitleIds(IniParser& rules, const char* option_name) +std::vector GraphicPack2::ParseTitleIds(IniParser& rules, const char* option_name) const { std::vector result; @@ -1201,13 +1198,6 @@ std::vector GraphicPack2::ParseTitleIds(IniParser& rules, const char* op for (auto& token : TokenizeView(*option_text, ',')) { - if (token == "*") - { - m_universal = true; - result.clear(); - break; - } - try { result.emplace_back(ConvertString(token, 16)); diff --git a/src/Cafe/GraphicPack/GraphicPack2.h b/src/Cafe/GraphicPack/GraphicPack2.h index 062ecb75..57573607 100644 --- a/src/Cafe/GraphicPack/GraphicPack2.h +++ b/src/Cafe/GraphicPack/GraphicPack2.h @@ -109,7 +109,6 @@ public: bool Reload(); bool HasName() const { return !m_name.empty(); } - bool IsUniversal() const { return m_universal; } const std::string& GetName() const { return m_name.empty() ? m_virtualPath : m_name; } const std::string& GetVirtualPath() const { return m_virtualPath; } // returns the path in the gfx tree hierarchy @@ -232,7 +231,6 @@ private: bool m_activated = false; // set if the graphic pack is currently used by the running game std::vector m_title_ids; bool m_patchedFilesLoaded = false; // set to true once patched files are loaded - bool m_universal = false; // set if this pack applies to every title id sint32 m_vsync_frequency = -1; sint32 m_fs_priority = 100; @@ -260,7 +258,7 @@ private: std::unordered_map ParsePresetVars(IniParser& rules) const; - std::vector ParseTitleIds(IniParser& rules, const char* option_name); + std::vector ParseTitleIds(IniParser& rules, const char* option_name) const; CustomShader LoadShader(const fs::path& path, uint64 shader_base_hash, uint64 shader_aux_hash, GP_SHADER_TYPE shader_type, bool isMetalShader) const; void ApplyShaderPresets(std::string& shader_source) const; diff --git a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp index db070025..4826e307 100644 --- a/src/Cafe/GraphicPack/GraphicPack2Patches.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2Patches.cpp @@ -135,13 +135,7 @@ void GraphicPack2::LoadPatchFiles() void GraphicPack2::EnablePatches() { - std::lock_guard lock(mtx_patches); - if (m_universal) // universal gp only applies to the rpx - { - ApplyPatchesForModule(list_modules[0]); - return; - } - + std::lock_guard lock(mtx_patches); for (auto& itr : list_modules) ApplyPatchesForModule(itr); } @@ -178,7 +172,7 @@ void GraphicPack2::ApplyPatchesForModule(const RPLModule* rpl) std::vector list_groups; for (auto itr : list_patchGroups) { - if (m_universal || itr->matchesCRC(rpl->patchCRC)) + if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->fileInfo.flags & 2)) list_groups.emplace_back(itr); } // apply all groups at once @@ -194,7 +188,7 @@ void GraphicPack2::RevertPatchesForModule(const RPLModule* rpl) std::vector list_groups; for (auto itr : list_patchGroups) { - if (m_universal || itr->matchesCRC(rpl->patchCRC)) + if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->fileInfo.flags & 2)) list_groups.emplace_back(itr); } // undo all groups at once diff --git a/src/Cafe/GraphicPack/GraphicPack2Patches.h b/src/Cafe/GraphicPack/GraphicPack2Patches.h index c5916d36..44a56673 100644 --- a/src/Cafe/GraphicPack/GraphicPack2Patches.h +++ b/src/Cafe/GraphicPack/GraphicPack2Patches.h @@ -260,4 +260,5 @@ private: uint32 codeCaveSize; MEMPTR codeCaveMem; bool m_isApplied{}; + bool m_isRpxOnlyTarget{}; }; \ No newline at end of file diff --git a/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp b/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp index f47f7cc8..be11f2c1 100644 --- a/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp +++ b/src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp @@ -41,7 +41,7 @@ void GraphicPack2::CancelParsingPatches() void GraphicPack2::AddPatchGroup(PatchGroup* group) { - if (group->list_moduleMatches.empty() && !m_universal) + if (group->list_moduleMatches.empty() && !group->m_isRpxOnlyTarget) { LogPatchesSyntaxError(-1, fmt::format("Group \"{}\" has no moduleMatches definition", group->name)); CancelParsingPatches(); @@ -347,6 +347,12 @@ bool GraphicPack2::ParseCemuPatchesTxtInternal(MemStreamReader& patchesStream) // read the checksums while (true) { + if (parser.matchWordI("rpx")) + { + currentGroup->m_isRpxOnlyTarget = true; + break; + } + uint32 checksum = 0; if (parser.parseU32(checksum) == false) { diff --git a/src/Cafe/OS/RPL/rpl.cpp b/src/Cafe/OS/RPL/rpl.cpp index f39d82be..d39ea95e 100644 --- a/src/Cafe/OS/RPL/rpl.cpp +++ b/src/Cafe/OS/RPL/rpl.cpp @@ -267,6 +267,7 @@ bool RPLLoader_ProcessHeaders(std::string_view moduleName, uint8* rplData, uint3 rplLoaderContext->fileInfo.tlsModuleIndex = fileInfoPtr->tlsModuleIndex; rplLoaderContext->fileInfo.sdataBase1 = fileInfoPtr->sdataBase1; rplLoaderContext->fileInfo.sdataBase2 = fileInfoPtr->sdataBase2; + rplLoaderContext->fileInfo.flags = fileInfoPtr->flags; // init section address table rplLoaderContext->sectionAddressTable2.resize(sectionCount); diff --git a/src/Cafe/OS/RPL/rpl_structs.h b/src/Cafe/OS/RPL/rpl_structs.h index 4b283f07..cdf6ec3e 100644 --- a/src/Cafe/OS/RPL/rpl_structs.h +++ b/src/Cafe/OS/RPL/rpl_structs.h @@ -113,7 +113,7 @@ typedef struct /* +0x28 */ uint32be sdataBase2; /* +0x2C */ uint32be ukn2C; /* +0x30 */ uint32be ukn30; - /* +0x34 */ uint32be ukn34; + /* +0x34 */ uint32be flags; /* +0x38 */ uint32be ukn38; /* +0x3C */ uint32be ukn3C; /* +0x40 */ uint32be minimumToolkitVersion; @@ -198,6 +198,8 @@ struct RPLModule uint32 sdataBase1; uint32 sdataBase2; + + uint32 flags; }fileInfo; // parsed CRC std::vector crcTable; diff --git a/src/gui/wxgui/GraphicPacksWindow2.cpp b/src/gui/wxgui/GraphicPacksWindow2.cpp index 90f5e17c..b6f016ff 100644 --- a/src/gui/wxgui/GraphicPacksWindow2.cpp +++ b/src/gui/wxgui/GraphicPacksWindow2.cpp @@ -43,47 +43,44 @@ void GraphicPacksWindow2::FillGraphicPackList() const for(auto& p : graphic_packs) { - if (!p->IsUniversal()) + // filter graphic packs by given title id + if (m_filter_installed_games && !m_installed_games.empty()) { - // filter graphic packs by given title id - if (m_filter_installed_games && !m_installed_games.empty()) + bool found = false; + for (uint64 titleId : p->GetTitleIds()) + { + if (std::find(m_installed_games.cbegin(), m_installed_games.cend(), titleId) != m_installed_games.cend()) + { + found = true; + break; + } + } + + if (!found) + continue; + } + + // filter graphic packs by given title id + if(has_filter) + { + bool found = false; + + if (boost::icontains(p->GetVirtualPath(), m_filter)) + found = true; + else { - bool found = false; for (uint64 titleId : p->GetTitleIds()) { - if (std::find(m_installed_games.cbegin(), m_installed_games.cend(), titleId) != m_installed_games.cend()) + if (boost::icontains(fmt::format("{:x}", titleId), m_filter)) { found = true; break; } } - - if (!found) - continue; - } - - // filter graphic packs by given title id - if(has_filter) - { - bool found = false; - - if (boost::icontains(p->GetVirtualPath(), m_filter)) - found = true; - else - { - for (uint64 titleId : p->GetTitleIds()) - { - if (boost::icontains(fmt::format("{:x}", titleId), m_filter)) - { - found = true; - break; - } - } - } - - if (!found) - continue; } + + if (!found) + continue; } const auto& path = p->GetVirtualPath();