Skip to content

Commit

Permalink
removed interrupt handling code
Browse files Browse the repository at this point in the history
  • Loading branch information
thrust26 committed Jul 30, 2024
1 parent 5d1f4a2 commit 1a16d36
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 55 deletions.
37 changes: 0 additions & 37 deletions src/emucore/M6502.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,6 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
#endif
}

// JTZ, TODO: This code seems to be superfluous for a 6507:
// See if we need to handle an interrupt
if((myExecutionStatus & MaskableInterruptBit) ||
(myExecutionStatus & NonmaskableInterruptBit))
{
// Yes, so handle the interrupt
interruptHandler();
}

// See if a fatal error has occurred
if(myExecutionStatus & FatalErrorBit)
{
Expand All @@ -450,34 +441,6 @@ inline void M6502::_execute(uInt64 cycles, DispatchResult& result)
}
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::interruptHandler()
{
// Handle the interrupt
if((myExecutionStatus & MaskableInterruptBit) && !I)
{
mySystem->incrementCycles(7 * SYSTEM_CYCLES_PER_CPU);
mySystem->poke(0x0100 + SP--, (PC - 1) >> 8);
mySystem->poke(0x0100 + SP--, (PC - 1) & 0x00ff);
mySystem->poke(0x0100 + SP--, PS() & (~0x10));
D = false;
I = true;
PC = static_cast<uInt16>(mySystem->peek(0xFFFE)) | (static_cast<uInt16>(mySystem->peek(0xFFFF)) << 8);
}
else if(myExecutionStatus & NonmaskableInterruptBit)
{
mySystem->incrementCycles(7 * SYSTEM_CYCLES_PER_CPU);
mySystem->poke(0x0100 + SP--, (PC - 1) >> 8);
mySystem->poke(0x0100 + SP--, (PC - 1) & 0x00ff);
mySystem->poke(0x0100 + SP--, PS() & (~0x10));
D = false;
PC = static_cast<uInt16>(mySystem->peek(0xFFFA)) | (static_cast<uInt16>(mySystem->peek(0xFFFB)) << 8);
}

// Clear the interrupt bits in myExecutionStatus
myExecutionStatus &= ~(MaskableInterruptBit | NonmaskableInterruptBit);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool M6502::save(Serializer& out) const
{
Expand Down
19 changes: 1 addition & 18 deletions src/emucore/M6502.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ class M6502 : public Serializable
*/
void reset();

/**
Request a maskable interrupt
*/
void irq() { myExecutionStatus |= MaskableInterruptBit; }

/**
Request a non-maskable interrupt
*/
void nmi() { myExecutionStatus |= NonmaskableInterruptBit; }

/**
Set the callback for handling a halt condition
*/
Expand Down Expand Up @@ -330,11 +320,6 @@ class M6502 : public Serializable
C = ps & 0x01;
}

/**
Called after an interrupt has be requested using irq() or nmi()
*/
void interruptHandler();

/**
Check whether halt was requested (RDY low) and notify
*/
Expand Down Expand Up @@ -362,9 +347,7 @@ class M6502 : public Serializable
*/
static constexpr uInt8
StopExecutionBit = 0x01,
FatalErrorBit = 0x02,
MaskableInterruptBit = 0x04,
NonmaskableInterruptBit = 0x08
FatalErrorBit = 0x02
;
uInt8 myExecutionStatus{0};

Expand Down

0 comments on commit 1a16d36

Please sign in to comment.