Second stage halt implementation: allow halt state to be exited by an interrupt.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-08-20 20:09:21 +01:00
parent 57e48e389f
commit 8716035396
2 changed files with 9 additions and 2 deletions

View File

@ -338,8 +338,14 @@ int EightBit::LR35902::run(int limit) {
auto ime = IME();
auto masked = interruptEnable & interruptFlags;
if (ime && masked)
m_bus.writeRegister(Bus::IF, 0);
if (masked) {
if (ime) {
m_bus.writeRegister(Bus::IF, 0);
} else {
if (isHalted())
proceed();
}
}
if (ime && (masked & Bus::Interrupts::VerticalBlank)) {
current += interrupt(0x40);

View File

@ -50,6 +50,7 @@ namespace EightBit {
bool isHalted() const { return m_halted; }
void halt() { --PC().word; m_halted = true; }
void proceed() { ++PC().word; m_halted = false; }
virtual void initialise();