test_cpu_simple - Add test for HALT with IME=1

This commit is contained in:
madmaurice 2023-08-30 22:46:25 +02:00
parent ed202b107e
commit 1cd7d0c2f2

View file

@ -249,3 +249,44 @@ TEST_CASE("DAA")
CHECK(cpu.state.A == 0x45);
}
TEST_CASE("HALT exits on interrupt")
{
u8 test_ram[] = {
0x76,
0x00,
0x00,
};
RAM r(test_ram, 0x3, true);
Cpu cpu(&r);
cpu.state.IE = INT_MASK;
cpu.state.IF = 0;
cpu.state.IME = IME_ON;
CHECK(cpu.state.halted == false);
cpu.step();
CHECK(cpu.state.halted == true);
CHECK(cpu.state.PC == 0x01);
cpu.step();
CHECK(cpu.state.halted == true);
CHECK(cpu.state.PC == 0x01);
cpu.step();
CHECK(cpu.state.halted == true);
CHECK(cpu.state.PC == 0x01);
cpu.signalInterrupt(INT_LCDSTAT);
CHECK(cpu.state.IF == INT_LCDSTAT);
cpu.step();
CHECK(cpu.state.halted == false);
CHECK(cpu.state.IF == 0);
CHECK(cpu.state.IME == IME_OFF);
CHECK(cpu.state.PC == 0x48);
}