2023-08-30 22:17:17 +02:00
|
|
|
#include "doctest.h"
|
|
|
|
|
|
|
|
#include <cpu/cpu.h>
|
|
|
|
#include <memory/bus.h>
|
|
|
|
#include <memory/ram.h>
|
|
|
|
#include <memory/register.h>
|
|
|
|
|
|
|
|
TEST_CASE("IE controllable via bus")
|
|
|
|
{
|
|
|
|
u8 test_ram[] = {
|
2023-08-30 22:49:36 +02:00
|
|
|
0x3E, 0xA5, // LD A, $0xA5
|
2023-08-30 22:17:17 +02:00
|
|
|
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();
|
|
|
|
|
2023-08-30 22:49:36 +02:00
|
|
|
CHECK(cpu.state.IE == 0xA5);
|
2023-08-30 22:17:17 +02:00
|
|
|
}
|