mirror of
https://github.com/PCSX2/pcsx2.git
synced 2025-12-16 04:08:48 +00:00
Patch: Restore place=0 behaviour, add PPT_ON_LOAD_OR_WHEN_ENABLED
This commit is contained in:
parent
5418ad4b3f
commit
a9ea0346cd
@ -51,7 +51,7 @@ namespace Patch
|
||||
BYTES_T
|
||||
};
|
||||
|
||||
static constexpr std::array<const char*, 3> s_place_to_string = {{"0", "1", "2"}};
|
||||
static constexpr std::array<const char*, 4> s_place_to_string = {{"0", "1", "2", "3"}};
|
||||
static constexpr std::array<const char*, 2> s_cpu_to_string = {{"EE", "IOP"}};
|
||||
static constexpr std::array<const char*, 9> s_type_to_string = {
|
||||
{"byte", "short", "word", "double", "extended", "beshort", "beword", "bedouble", "bytes"}};
|
||||
@ -672,7 +672,7 @@ u32 Patch::EnablePatches(const PatchList& patches, const EnablePatchList& enable
|
||||
DevCon.WriteLnFmt(" {}", ip.ToString());
|
||||
|
||||
s_active_patches.push_back(&ip);
|
||||
if (apply_immediately && ip.placetopatch == PPT_ONCE_ON_LOAD)
|
||||
if (apply_immediately && ip.placetopatch == PPT_ON_LOAD_OR_WHEN_ENABLED)
|
||||
patches_to_apply_immediately.push_back(&ip);
|
||||
}
|
||||
|
||||
@ -892,7 +892,7 @@ void Patch::PatchFunc::patch(PatchGroup* group, const std::string_view cmd, cons
|
||||
|
||||
if (!placetopatch.has_value())
|
||||
{
|
||||
PATCH_ERROR("Invalid 'place' value '{}' (0 - once on startup, 1: continuously)", pieces[0]);
|
||||
PATCH_ERROR("Invalid 'place' value '{}' (0: on boot only, 1: continuously, 2: on boot and continuously, 3: on boot and when enabled in the GUI)", pieces[0]);
|
||||
return;
|
||||
}
|
||||
if (!addr.has_value() || !addr_end.empty())
|
||||
@ -1083,6 +1083,19 @@ void Patch::PatchFunc::dpatch(PatchGroup* group, const std::string_view cmd, con
|
||||
group->dpatches.push_back(dpatch);
|
||||
}
|
||||
|
||||
void Patch::ApplyBootPatches()
|
||||
{
|
||||
ApplyLoadedPatches(PPT_ONCE_ON_LOAD);
|
||||
ApplyLoadedPatches(PPT_COMBINED_0_1);
|
||||
ApplyLoadedPatches(PPT_ON_LOAD_OR_WHEN_ENABLED);
|
||||
}
|
||||
|
||||
void Patch::ApplyVsyncPatches()
|
||||
{
|
||||
ApplyLoadedPatches(PPT_CONTINUOUSLY);
|
||||
ApplyLoadedPatches(PPT_COMBINED_0_1);
|
||||
}
|
||||
|
||||
// This is for applying patches directly to memory
|
||||
void Patch::ApplyLoadedPatches(patch_place_type place)
|
||||
{
|
||||
|
||||
@ -29,9 +29,10 @@ namespace Patch
|
||||
// In PCSX2 it indicates how/when/where the patch line should be applied. If
|
||||
// place is not one of the supported values then the patch line is never applied.
|
||||
// PCSX2 currently supports the following values:
|
||||
// 0 - apply the patch line once on game boot/startup
|
||||
// 0 - apply the patch line once on game boot only
|
||||
// 1 - apply the patch line continuously (technically - on every vsync)
|
||||
// 2 - effect of 0 and 1 combined, see below
|
||||
// 3 - apply the patch line once on game boot or when enabled in the GUI
|
||||
// Note:
|
||||
// - while it may seem that a value of 1 does the same as 0, but also later
|
||||
// continues to apply the patch on every vsync - it's not.
|
||||
@ -43,6 +44,7 @@ namespace Patch
|
||||
PPT_ONCE_ON_LOAD = 0,
|
||||
PPT_CONTINUOUSLY = 1,
|
||||
PPT_COMBINED_0_1 = 2,
|
||||
PPT_ON_LOAD_OR_WHEN_ENABLED = 3,
|
||||
|
||||
PPT_END_MARKER
|
||||
};
|
||||
@ -94,6 +96,13 @@ namespace Patch
|
||||
extern void LoadDynamicPatches(const std::vector<DynamicPatch>& patches);
|
||||
extern void ApplyDynamicPatches(u32 pc);
|
||||
|
||||
// Apply all loaded patches that should be applied when the entry point is
|
||||
// being recompiled.
|
||||
extern void ApplyBootPatches();
|
||||
|
||||
// Apply all loaded patches that should be applied during vsync.
|
||||
extern void ApplyVsyncPatches();
|
||||
|
||||
// Patches the emulation memory by applying all the loaded patches with a specific place value.
|
||||
// Note: unless you know better, there's no need to check whether or not different patch sources
|
||||
// are enabled (e.g. ws patches, auto game fixes, etc) before calling ApplyLoadedPatches,
|
||||
|
||||
@ -2816,8 +2816,8 @@ void VMManager::Internal::EntryPointCompilingOnCPUThread()
|
||||
|
||||
HandleELFChange(true);
|
||||
|
||||
Patch::ApplyLoadedPatches(Patch::PPT_ONCE_ON_LOAD);
|
||||
Patch::ApplyLoadedPatches(Patch::PPT_COMBINED_0_1);
|
||||
Patch::ApplyBootPatches();
|
||||
|
||||
// If the config changes at this point, it's a reset, so the game doesn't currently know about the memcard
|
||||
// so there's no need to leave the eject running.
|
||||
FileMcd_CancelEject();
|
||||
@ -2833,8 +2833,7 @@ void VMManager::Internal::VSyncOnCPUThread()
|
||||
{
|
||||
Pad::UpdateMacroButtons();
|
||||
|
||||
Patch::ApplyLoadedPatches(Patch::PPT_CONTINUOUSLY);
|
||||
Patch::ApplyLoadedPatches(Patch::PPT_COMBINED_0_1);
|
||||
Patch::ApplyVsyncPatches();
|
||||
|
||||
// Frame advance must be done *before* pumping messages, because otherwise
|
||||
// we'll immediately reduce the counter we just set.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user