Make sure that pending RDY is handled after stepping the CPU. Closes #155.

This commit is contained in:
Christian Speckner 2017-06-24 00:35:17 +02:00
parent 4515e79b4e
commit fa76042790
2 changed files with 24 additions and 4 deletions

View File

@ -111,10 +111,7 @@ void M6502::reset()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline uInt8 M6502::peek(uInt16 address, uInt8 flags)
{
if (myHaltRequested) {
myOnHaltCallback();
myHaltRequested = false;
}
handleHalt();
////////////////////////////////////////////////
// TODO - move this logic directly into CartAR
@ -175,6 +172,15 @@ void M6502::requestHalt()
myHaltRequested = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void M6502::handleHalt()
{
if (myHaltRequested) {
myOnHaltCallback();
myHaltRequested = false;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool M6502::execute(uInt32 number)
{
@ -241,6 +247,12 @@ bool M6502::execute(uInt32 number)
// See if execution has been stopped
if(myExecutionStatus & StopExecutionBit)
{
// Debugger hack: this ensures that stepping a "STA WSYNC" will actually end at the
// beginning of the next line (otherwise, the next instruction would be stepped in order for
// the halt to take effect). This is safe because as we know that the next cycle will be a read
// cycle anyway.
handleHalt();
// Yes, so answer that everything finished fine
return true;
}
@ -255,6 +267,9 @@ bool M6502::execute(uInt32 number)
// See if we've executed the specified number of instructions
if(number == 0)
{
// See above
handleHalt();
// Yes, so answer that everything finished fine
return true;
}

View File

@ -286,6 +286,11 @@ class M6502 : public Serializable
*/
void interruptHandler();
/**
Check whether halt was requested (RDY low) and notify
*/
void handleHalt();
private:
/**
Bit fields used to indicate that certain conditions need to be