Address reviews

This commit is contained in:
Luminyx 2026-02-08 03:37:59 -05:00
parent a3fa9f9939
commit 4a47e82a37
No known key found for this signature in database
GPG Key ID: C590EEF718016830
8 changed files with 48 additions and 27 deletions

View File

@ -1199,15 +1199,14 @@ std::vector<uint64> GraphicPack2::ParseTitleIds(IniParser& rules, const char* op
if (!option_text)
return result;
if (*option_text == "*")
{
m_universal = true;
return result;
}
for (auto& token : TokenizeView(*option_text, ','))
{
if (token == "*")
{
m_universal = true;
result.clear();
break;
}
try
{
result.emplace_back(ConvertString<uint64>(token, 16));

View File

@ -124,7 +124,7 @@ public:
bool HasCustomVSyncFrequency() const { return m_vsync_frequency >= 1; }
sint32 GetCustomVSyncFrequency() const { return m_vsync_frequency; }
const std::vector<MPTR>& GetCallbacks() const { return m_callbacks; }
const std::vector<std::pair<MPTR, GPCallbackType>>& GetCallbacks() const { return m_callbacks; }
// texture rules
const std::vector<TextureRule>& GetTextureRules() const { return m_texture_rules; }
@ -287,7 +287,7 @@ private:
std::vector<PatchGroup*> list_patchGroups;
std::vector<MPTR> m_callbacks;
std::vector<std::pair<MPTR, GPCallbackType>> m_callbacks;
static std::recursive_mutex mtx_patches;
static std::vector<const RPLModule*> list_modules;

View File

@ -172,7 +172,7 @@ void GraphicPack2::ApplyPatchesForModule(const RPLModule* rpl)
std::vector<PatchGroup*> list_groups;
for (auto itr : list_patchGroups)
{
if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->fileInfo.flags & 2))
if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->IsRPX()))
list_groups.emplace_back(itr);
}
// apply all groups at once
@ -188,7 +188,7 @@ void GraphicPack2::RevertPatchesForModule(const RPLModule* rpl)
std::vector<PatchGroup*> list_groups;
for (auto itr : list_patchGroups)
{
if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->fileInfo.flags & 2))
if (itr->matchesCRC(rpl->patchCRC) || (itr->m_isRpxOnlyTarget && rpl->IsRPX()))
list_groups.emplace_back(itr);
}
// undo all groups at once

View File

@ -212,6 +212,10 @@ private:
bool m_addrRelocated{};
};
enum class GPCallbackType {
Entry
};
class PatchGroup
{
friend class GraphicPack2;
@ -256,7 +260,7 @@ private:
std::string name;
std::vector<uint32> list_moduleMatches;
std::vector<PatchEntry*> list_patches;
std::vector<std::string> list_callbacks;
std::vector<std::pair<std::string, GPCallbackType>> list_callbacks;
uint32 codeCaveSize;
MEMPTR<void> codeCaveMem;
bool m_isApplied{};

View File

@ -711,12 +711,12 @@ void GraphicPack2::ApplyPatchGroups(std::vector<PatchGroup*>& groups, const RPLM
patchInstruction->applyPatch();
}
for (const auto& name : patchGroup->list_callbacks)
for (const auto& [name, type] : patchGroup->list_callbacks)
{
auto it = patchContext.map_values.find(name);
if (it != patchContext.map_values.end())
{
m_callbacks.push_back(it->second);
m_callbacks.push_back(std::make_pair(it->second, type));
}
else
{

View File

@ -433,19 +433,28 @@ bool GraphicPack2::ParseCemuPatchesTxtInternal(MemStreamReader& patchesStream)
}
else if (parser.matchWordI(".callback"))
{
const char* symbolStr;
sint32 symbolLen;
if (parser.parseSymbolName(symbolStr, symbolLen))
{
currentGroup->list_callbacks.push_back({symbolStr, static_cast<size_t>(symbolLen)});
continue;
}
if (parser.matchWordI("entry"))
{
const char* symbolStr;
sint32 symbolLen;
if (parser.parseSymbolName(symbolStr, symbolLen))
{
currentGroup->list_callbacks.push_back(std::make_pair(std::string(symbolStr, static_cast<size_t>(symbolLen)), GPCallbackType::Entry));
continue;
}
else
{
LogPatchesSyntaxError(lineNumber, "'.callback' must reference a symbol after the type");
CancelParsingPatches();
return false;
}
}
else
{
LogPatchesSyntaxError(lineNumber, "'.callback' must be followed by a symbol");
CancelParsingPatches();
return false;
}
LogPatchesSyntaxError(lineNumber, "Unrecognized type for '.callback'");
CancelParsingPatches();
return false;
}
}
// next we attempt to parse symbol assignment

View File

@ -210,6 +210,11 @@ struct RPLModule
return 0;
return crcTable[sectionIndex];
}
bool IsRPX() const
{
return fileInfo.flags & 2;
}
// state
bool isLinked; // set to true if _linkModule was called on this module

View File

@ -212,11 +212,15 @@ void coreinit_start(PPCInterpreter_t* hCPU)
padscore::start();
vpad::start();
// call entry-type callbacks in graphic packs
for (const auto gp : GraphicPack2::GetActiveGraphicPacks())
{
for (MPTR callback : gp->GetCallbacks())
for (const auto [callback, type] : gp->GetCallbacks())
{
PPCCoreCallback(callback);
if (type == GPCallbackType::Entry)
{
PPCCoreCallback(callback);
}
}
}