summaryrefslogtreecommitdiff
path: root/lib/nes/util/snapshot.hh
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-01-23 22:02:11 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-01-23 22:02:11 +0100
commitb1d1573702f21e3104606d6ade5f5d39ec86a33a (patch)
treed703be130a5d6f9ff2626313d3380ed34de44dd7 /lib/nes/util/snapshot.hh
parent6512dd599d13035f6a90b2009344e02c488f5aae (diff)
restructure project
Diffstat (limited to 'lib/nes/util/snapshot.hh')
-rw-r--r--lib/nes/util/snapshot.hh63
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/nes/util/snapshot.hh b/lib/nes/util/snapshot.hh
new file mode 100644
index 0000000..de23a46
--- /dev/null
+++ b/lib/nes/util/snapshot.hh
@@ -0,0 +1,63 @@
+#pragma once
+
+#include "nes/util/cycle-count.hh"
+#include <vector>
+#include <cstdint>
+
+namespace nes
+{
+ /// System snapshot used for comparison with a reference implementation.
+ struct snapshot
+ {
+ explicit snapshot() = default;
+
+ cycle_count cpu_cycle;
+ cycle_count ppu_cycle;
+ std::vector<std::uint8_t> ram;
+ std::vector<std::uint8_t> sram;
+ std::vector<std::uint8_t> vram;
+ std::vector<std::uint8_t> oam;
+ struct
+ {
+ std::uint16_t pc{};
+ std::uint8_t sp{};
+ std::uint8_t a{};
+ std::uint8_t x{};
+ std::uint8_t y{};
+ std::uint8_t p{};
+ bool c{};
+ bool z{};
+ bool i{};
+ bool d{};
+ bool b{};
+ bool v{};
+ bool n{};
+ } registers{};
+ };
+
+ inline auto operator==(snapshot const& a, snapshot const& b) -> bool
+ {
+ if (a.cpu_cycle != b.cpu_cycle) { return false; }
+ if (a.ppu_cycle != b.ppu_cycle) { return false; }
+ if (a.ram != b.ram) { return false; }
+ if (a.sram != b.sram) { return false; }
+ if (a.vram != b.vram) { return false; }
+ if (a.oam != b.oam) { return false; }
+ if (a.registers.pc != b.registers.pc) { return false; }
+ if (a.registers.sp != b.registers.sp) { return false; }
+ if (a.registers.a != b.registers.a) { return false; }
+ if (a.registers.x != b.registers.x) { return false; }
+ if (a.registers.y != b.registers.y) { return false; }
+ if (a.registers.p != b.registers.p) { return false; }
+ if (a.registers.c != b.registers.c) { return false; }
+ if (a.registers.z != b.registers.z) { return false; }
+ if (a.registers.i != b.registers.i) { return false; }
+ if (a.registers.d != b.registers.d) { return false; }
+ if (a.registers.b != b.registers.b) { return false; }
+ if (a.registers.v != b.registers.v) { return false; }
+ if (a.registers.n != b.registers.n) { return false; }
+ return true;
+ }
+
+ inline auto operator!=(snapshot const& a, snapshot const& b) -> bool { return !(a == b); }
+} // namespace nes \ No newline at end of file