From 86eeb90868435fb43dd4a8708cefb62345a1bb51 Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Wed, 30 Aug 2023 22:17:17 +0200 Subject: [PATCH] tests - Add test for memory register --- tests/test_memory_register.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/test_memory_register.cpp diff --git a/tests/test_memory_register.cpp b/tests/test_memory_register.cpp new file mode 100644 index 0000000..364bbf1 --- /dev/null +++ b/tests/test_memory_register.cpp @@ -0,0 +1,25 @@ +#include "doctest.h" + +#include +#include +#include +#include + +TEST_CASE("IE controllable via bus") +{ + u8 test_ram[] = { + 0x3E, 0xFF, // LD A, $0xFF + 0xE0, 0xFF, // LDH [FF:FF], A + }; + + Bus b; + Cpu cpu(&b); + + b.map_device(0x0000, 0x0004, new RAM(test_ram, 0x4, true)); + b.map_device(0xFFFF, 0xFFFF, new BoundRegister(cpu.state.IE)); + + cpu.step(); + cpu.step(); + + CHECK(cpu.state.IE == 0xFF); +}