diff --git a/src/Ryujinx.Memory/Range/IMultiRangeItem.cs b/src/Ryujinx.Memory/Range/IMultiRangeItem.cs
index 87fde2465..5f9611c75 100644
--- a/src/Ryujinx.Memory/Range/IMultiRangeItem.cs
+++ b/src/Ryujinx.Memory/Range/IMultiRangeItem.cs
@@ -4,6 +4,22 @@ namespace Ryujinx.Memory.Range
{
MultiRange Range { get; }
- ulong BaseAddress => Range.GetSubRange(0).Address;
+ ulong BaseAddress
+ {
+ get
+ {
+ for (int index = 0; index < Range.Count; index++)
+ {
+ MemoryRange subRange = Range.GetSubRange(index);
+
+ if (!MemoryRange.IsInvalid(ref subRange))
+ {
+ return subRange.Address;
+ }
+ }
+
+ return MemoryRange.InvalidAddress;
+ }
+ }
}
}
diff --git a/src/Ryujinx.Memory/Range/MemoryRange.cs b/src/Ryujinx.Memory/Range/MemoryRange.cs
index 46aca9ba0..20e9d00bb 100644
--- a/src/Ryujinx.Memory/Range/MemoryRange.cs
+++ b/src/Ryujinx.Memory/Range/MemoryRange.cs
@@ -5,6 +5,11 @@ namespace Ryujinx.Memory.Range
///
public readonly record struct MemoryRange
{
+ ///
+ /// Special address value used to indicate than an address is invalid.
+ ///
+ internal const ulong InvalidAddress = ulong.MaxValue;
+
///
/// An empty memory range, with a null address and zero size.
///
@@ -58,13 +63,24 @@ namespace Ryujinx.Memory.Range
return thisAddress < otherEndAddress && otherAddress < thisEndAddress;
}
+ ///
+ /// Checks if a given sub-range of memory is invalid.
+ /// Those are used to represent unmapped memory regions (holes in the region mapping).
+ ///
+ /// Memory range to check
+ /// True if the memory range is considered invalid, false otherwise
+ internal static bool IsInvalid(ref MemoryRange subRange)
+ {
+ return subRange.Address == InvalidAddress;
+ }
+
///
/// Returns a string summary of the memory range.
///
/// A string summary of the memory range
public override string ToString()
{
- if (Address == ulong.MaxValue)
+ if (Address == InvalidAddress)
{
return $"[Unmapped 0x{Size:X}]";
}
diff --git a/src/Ryujinx.Memory/Range/MultiRangeList.cs b/src/Ryujinx.Memory/Range/MultiRangeList.cs
index 1804ff5c8..c3c6ae797 100644
--- a/src/Ryujinx.Memory/Range/MultiRangeList.cs
+++ b/src/Ryujinx.Memory/Range/MultiRangeList.cs
@@ -30,7 +30,7 @@ namespace Ryujinx.Memory.Range
{
var subrange = range.GetSubRange(i);
- if (IsInvalid(ref subrange))
+ if (MemoryRange.IsInvalid(ref subrange))
{
continue;
}
@@ -56,7 +56,7 @@ namespace Ryujinx.Memory.Range
{
var subrange = range.GetSubRange(i);
- if (IsInvalid(ref subrange))
+ if (MemoryRange.IsInvalid(ref subrange))
{
continue;
}
@@ -99,7 +99,7 @@ namespace Ryujinx.Memory.Range
{
var subrange = range.GetSubRange(i);
- if (IsInvalid(ref subrange))
+ if (MemoryRange.IsInvalid(ref subrange))
{
continue;
}
@@ -142,17 +142,6 @@ namespace Ryujinx.Memory.Range
return overlapCount;
}
- ///
- /// Checks if a given sub-range of memory is invalid.
- /// Those are used to represent unmapped memory regions (holes in the region mapping).
- ///
- /// Memory range to checl
- /// True if the memory range is considered invalid, false otherwise
- private static bool IsInvalid(ref MemoryRange subRange)
- {
- return subRange.Address == ulong.MaxValue;
- }
-
///
/// Gets all items on the list starting at the specified memory address.
///