summaryrefslogtreecommitdiffstats
path: root/src/core/tools
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-26 20:10:49 +0100
committerLioncash <mathew1800@gmail.com>2019-11-27 03:55:37 +0100
commit536fc7f0ea77e08d68c760f387c307d258804e3b (patch)
treee979df531bf1222788cc26144531c6e6f5cca1d1 /src/core/tools
parentcore/memory: Move memory read/write implementation functions into an anonymous namespace (diff)
downloadyuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.gz
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.bz2
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.lz
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.xz
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.tar.zst
yuzu-536fc7f0ea77e08d68c760f387c307d258804e3b.zip
Diffstat (limited to 'src/core/tools')
-rw-r--r--src/core/tools/freezer.cpp14
-rw-r--r--src/core/tools/freezer.h7
2 files changed, 13 insertions, 8 deletions
diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp
index 19b531ecb..c7f42388f 100644
--- a/src/core/tools/freezer.cpp
+++ b/src/core/tools/freezer.cpp
@@ -11,12 +11,11 @@
#include "core/tools/freezer.h"
namespace Tools {
-
namespace {
constexpr s64 MEMORY_FREEZER_TICKS = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 60);
-u64 MemoryReadWidth(u32 width, VAddr addr) {
+u64 MemoryReadWidth(Memory::Memory& memory, u32 width, VAddr addr) {
switch (width) {
case 1:
return Memory::Read8(addr);
@@ -32,7 +31,7 @@ u64 MemoryReadWidth(u32 width, VAddr addr) {
}
}
-void MemoryWriteWidth(u32 width, VAddr addr, u64 value) {
+void MemoryWriteWidth(Memory::Memory& memory, u32 width, VAddr addr, u64 value) {
switch (width) {
case 1:
Memory::Write8(addr, static_cast<u8>(value));
@@ -53,7 +52,8 @@ void MemoryWriteWidth(u32 width, VAddr addr, u64 value) {
} // Anonymous namespace
-Freezer::Freezer(Core::Timing::CoreTiming& core_timing) : core_timing(core_timing) {
+Freezer::Freezer(Core::Timing::CoreTiming& core_timing_, Memory::Memory& memory_)
+ : core_timing{core_timing_}, memory{memory_} {
event = Core::Timing::CreateEvent(
"MemoryFreezer::FrameCallback",
[this](u64 userdata, s64 cycles_late) { FrameCallback(userdata, cycles_late); });
@@ -89,7 +89,7 @@ void Freezer::Clear() {
u64 Freezer::Freeze(VAddr address, u32 width) {
std::lock_guard lock{entries_mutex};
- const auto current_value = MemoryReadWidth(width, address);
+ const auto current_value = MemoryReadWidth(memory, width, address);
entries.push_back({address, width, current_value});
LOG_DEBUG(Common_Memory,
@@ -169,7 +169,7 @@ void Freezer::FrameCallback(u64 userdata, s64 cycles_late) {
LOG_DEBUG(Common_Memory,
"Enforcing memory freeze at address={:016X}, value={:016X}, width={:02X}",
entry.address, entry.value, entry.width);
- MemoryWriteWidth(entry.width, entry.address, entry.value);
+ MemoryWriteWidth(memory, entry.width, entry.address, entry.value);
}
core_timing.ScheduleEvent(MEMORY_FREEZER_TICKS - cycles_late, event);
@@ -181,7 +181,7 @@ void Freezer::FillEntryReads() {
LOG_DEBUG(Common_Memory, "Updating memory freeze entries to current values.");
for (auto& entry : entries) {
- entry.value = MemoryReadWidth(entry.width, entry.address);
+ entry.value = MemoryReadWidth(memory, entry.width, entry.address);
}
}
diff --git a/src/core/tools/freezer.h b/src/core/tools/freezer.h
index 90b1a885c..916339c6c 100644
--- a/src/core/tools/freezer.h
+++ b/src/core/tools/freezer.h
@@ -16,6 +16,10 @@ class CoreTiming;
struct EventType;
} // namespace Core::Timing
+namespace Memory {
+class Memory;
+}
+
namespace Tools {
/**
@@ -34,7 +38,7 @@ public:
u64 value;
};
- explicit Freezer(Core::Timing::CoreTiming& core_timing);
+ explicit Freezer(Core::Timing::CoreTiming& core_timing_, Memory::Memory& memory_);
~Freezer();
// Enables or disables the entire memory freezer.
@@ -78,6 +82,7 @@ private:
std::shared_ptr<Core::Timing::EventType> event;
Core::Timing::CoreTiming& core_timing;
+ Memory::Memory& memory;
};
} // namespace Tools