Skip to content

Commit

Permalink
if EI is pending interrupts are triggered before halt
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Oct 5, 2012
1 parent d8c9962 commit 2a37e94
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/opcodes.cpp
Expand Up @@ -837,22 +837,25 @@ void Processor::OPCode0x75()
void Processor::OPCode0x76()
{
// HALT

if (m_iIMECycles > 0)
{
// If EI is pending interrupts are triggered before Halt
m_iIMECycles = 0;
m_bIME = true;
PC.Decrement();
}
else
{
u8 if_reg = m_pMemory->Retrieve(0xFF0F);
u8 ie_reg = m_pMemory->Retrieve(0xFFFF);

u8 if_reg = m_pMemory->Retrieve(0xFF0F);
u8 ie_reg = m_pMemory->Retrieve(0xFFFF);

m_bHalt = true;
m_HaltCachedIFRegister = if_reg;
m_bHalt = true;
m_HaltCachedIFRegister = if_reg;

if (!m_bCGB && !m_bIME && (if_reg & ie_reg & 0x1F))
{
m_bSkipPCBug = true;
if (!m_bCGB && !m_bIME && (if_reg & ie_reg & 0x1F))
{
m_bSkipPCBug = true;
}
}
}

Expand Down

0 comments on commit 2a37e94

Please sign in to comment.