From a1677d34e15c081c403c0b5fef3df8dc35c2c87f Mon Sep 17 00:00:00 2001 From: DrChat Date: Fri, 9 Feb 2018 19:23:24 -0600 Subject: [PATCH] [CPU] MMIOHandler IsRangeWatched now returns true if the entire range is watched. --- src/xenia/cpu/mmio_handler.cc | 16 ++++++++++++---- src/xenia/cpu/mmio_handler.h | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/xenia/cpu/mmio_handler.cc b/src/xenia/cpu/mmio_handler.cc index f12cb65d9..33bdaf889 100644 --- a/src/xenia/cpu/mmio_handler.cc +++ b/src/xenia/cpu/mmio_handler.cc @@ -240,12 +240,20 @@ bool MMIOHandler::IsRangeWatched(uint32_t physical_address, size_t length) { for (auto it = access_watches_.begin(); it != access_watches_.end(); ++it) { auto entry = *it; if ((entry->address <= physical_address && - entry->address + entry->length > physical_address) || - (entry->address >= physical_address && - entry->address < physical_address + length)) { - // This watch lies within the range. + entry->address + entry->length > physical_address + length)) { + // This range lies entirely within this watch. return true; } + + // TODO(DrChat): Check if the range is partially covered, and subtract the + // covered portion if it is. + if ((entry->address <= physical_address && + entry->address + entry->length > physical_address)) { + // The beginning of range lies partially within this watch. + } else if ((entry->address < physical_address + length && + entry->address + entry->length > physical_address + length)) { + // The ending of this range lies partially within this watch. + } } return false; diff --git a/src/xenia/cpu/mmio_handler.h b/src/xenia/cpu/mmio_handler.h index e68a2e276..e61cd1c20 100644 --- a/src/xenia/cpu/mmio_handler.h +++ b/src/xenia/cpu/mmio_handler.h @@ -77,7 +77,7 @@ class MMIOHandler { // Fires and clears any access watches that overlap this range. void InvalidateRange(uint32_t physical_address, size_t length); - // Returns true if /any/ part of this range is watched. + // Returns true if /all/ of this range is watched. bool IsRangeWatched(uint32_t physical_address, size_t length); protected: