diff --git a/Source/Core/Core/HW/AddressSpace.cpp b/Source/Core/Core/HW/AddressSpace.cpp index 3ec9220d43..8bb2c4cee8 100644 --- a/Source/Core/Core/HW/AddressSpace.cpp +++ b/Source/Core/Core/HW/AddressSpace.cpp @@ -246,22 +246,22 @@ struct CompositeAddressSpaceAccessors : Accessors u8 ReadU8(u32 address) const override { - auto it = FindAppropriateAccessor(address); - if (it == m_accessor_mappings.end()) + auto mapping = FindAppropriateAccessor(address); + if (mapping == m_accessor_mappings.end()) { return 0; } - return it->accessors->ReadU8(address); + return mapping->accessors->ReadU8(address - mapping->base); } void WriteU8(u32 address, u8 value) override { - auto it = FindAppropriateAccessor(address); - if (it == m_accessor_mappings.end()) + auto mapping = FindAppropriateAccessor(address); + if (mapping == m_accessor_mappings.end()) { return; } - return it->accessors->WriteU8(address, value); + return mapping->accessors->WriteU8(address - mapping->base, value); } std::optional Search(u32 haystack_offset, const u8* needle_start, std::size_t needle_size,