From 1d3f262eda1bd3f1c642c0ec76150c88a50536a1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Apr 2023 06:57:42 -0700 Subject: [PATCH] Debugger: Trigger mem breakpoints for mirrors. --- Core/Debugger/Breakpoints.cpp | 44 +++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index edfa7bf20d..08ea9dbe02 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -489,9 +489,10 @@ bool CBreakPoints::GetMemCheck(u32 start, u32 end, MemCheck *check) { return false; } -static inline u32 NotCached(u32 val) -{ - // Remove the cached part of the address. +static inline u32 NotCached(u32 val) { + // Remove the cached part of the address as well as any mirror. + if ((val & 0x3F800000) == 0x04000000) + return val & ~0x40600000; return val & ~0x40000000; } @@ -614,6 +615,26 @@ u32 CBreakPoints::CheckSkipFirst() return 0; } +static MemCheck NotCached(MemCheck mc) { + // Toggle the cached part of the address. + mc.start ^= 0x40000000; + if (mc.end != 0) + mc.end ^= 0x40000000; + return mc; +} + +static MemCheck VRAMMirror(uint8_t mirror, MemCheck mc) { + mc.start &= ~0x00600000; + mc.start += 0x00200000 * mirror; + if (mc.end != 0) { + mc.end &= ~0x00600000; + mc.end += 0x00200000 * mirror; + if (mc.end < mc.start) + mc.end += 0x00200000; + } + return mc; +} + const std::vector CBreakPoints::GetMemCheckRanges(bool write) { std::lock_guard guard(memCheckMutex_); std::vector ranges; @@ -623,13 +644,16 @@ const std::vector CBreakPoints::GetMemCheckRanges(bool write) { if (!(check.cond & MEMCHECK_WRITE) && write) continue; - MemCheck copy = check; - // Toggle the cached part of the address. - copy.start ^= 0x40000000; - if (copy.end != 0) - copy.end ^= 0x40000000; - ranges.push_back(check); - ranges.push_back(copy); + if (Memory::IsVRAMAddress(check.start) && (check.end == 0 || Memory::IsVRAMAddress(check.end))) { + for (uint8_t mirror = 0; mirror < 4; ++mirror) { + MemCheck copy = VRAMMirror(mirror, check); + ranges.push_back(copy); + ranges.push_back(NotCached(copy)); + } + } else { + ranges.push_back(check); + ranges.push_back(NotCached(check)); + } } return ranges;