fixed RWP by using the last access type

This commit is contained in:
thrust26 2018-12-08 15:51:16 +01:00
parent 33e300b28c
commit 1dfc221a1a
3 changed files with 13 additions and 15 deletions

View File

@ -172,8 +172,7 @@ void CartDebug::triggerReadFromWritePort(uInt16 addr)
mySystem.setDirtyPage(addr); mySystem.setDirtyPage(addr);
if(myRWPortTriggersBreak && if(myRWPortTriggersBreak &&
mySystem.m6502().lastReadAddress() && !mySystem.m6502().lastWasGhostPeek())
(mySystem.getPageAccessType(addr) & System::PA_WRITE) == System::PA_WRITE)
{ {
ostringstream msg; ostringstream msg;
msg << "RWP[@ $" << Common::Base::HEX4 << addr << "]: "; msg << "RWP[@ $" << Common::Base::HEX4 << addr << "]: ";
@ -191,8 +190,7 @@ int CartDebug::readFromWritePort()
// port address space AND the last access was actually a read (the latter // port address space AND the last access was actually a read (the latter
// differentiates between reads that are normally part of a write cycle vs. // differentiates between reads that are normally part of a write cycle vs.
// ones that are illegal) // ones that are illegal)
if(mySystem.m6502().lastReadAddress() && if(!mySystem.m6502().lastWasGhostPeek())
(mySystem.getPageAccessType(addr) & System::PA_WRITE) == System::PA_WRITE)
return addr; return addr;
else else
return 0; return 0;

View File

@ -74,7 +74,8 @@ M6502::M6502(const Settings& settings)
myOnHaltCallback(nullptr), myOnHaltCallback(nullptr),
myHaltRequested(false), myHaltRequested(false),
myGhostReadsTrap(true), myGhostReadsTrap(true),
myStepStateByInstruction(false) myStepStateByInstruction(false),
myFlags(DISASM_NONE)
{ {
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
myDebugger = nullptr; myDebugger = nullptr;
@ -118,6 +119,7 @@ void M6502::reset()
myLastSrcAddressS = myLastSrcAddressA = myLastSrcAddressS = myLastSrcAddressA =
myLastSrcAddressX = myLastSrcAddressY = -1; myLastSrcAddressX = myLastSrcAddressY = -1;
myDataAddressForPoke = 0; myDataAddressForPoke = 0;
myFlags = DISASM_NONE;
myHaltRequested = false; myHaltRequested = false;
myGhostReadsTrap = mySettings.getBool("dbg.ghostreadstrap"); myGhostReadsTrap = mySettings.getBool("dbg.ghostreadstrap");
@ -140,6 +142,7 @@ inline uInt8 M6502::peek(uInt16 address, uInt8 flags)
//////////////////////////////////////////////// ////////////////////////////////////////////////
mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU); mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU);
icycles += SYSTEM_CYCLES_PER_CPU; icycles += SYSTEM_CYCLES_PER_CPU;
myFlags = flags;
uInt8 result = mySystem->peek(address, flags); uInt8 result = mySystem->peek(address, flags);
myLastPeekAddress = address; myLastPeekAddress = address;
@ -442,6 +445,7 @@ bool M6502::save(Serializer& out) const
out.putBool(myStepStateByInstruction); out.putBool(myStepStateByInstruction);
out.putBool(myGhostReadsTrap); out.putBool(myGhostReadsTrap);
out.putLong(myLastBreakCycle); out.putLong(myLastBreakCycle);
out.putShort(myFlags);
} }
catch(...) catch(...)
{ {
@ -490,6 +494,7 @@ bool M6502::load(Serializer& in)
myStepStateByInstruction = in.getBool(); myStepStateByInstruction = in.getBool();
myGhostReadsTrap = in.getBool(); myGhostReadsTrap = in.getBool();
myLastBreakCycle = in.getLong(); myLastBreakCycle = in.getLong();
myFlags = in.getShort();
} }
catch(...) catch(...)
{ {

View File

@ -143,18 +143,11 @@ class M6502 : public Serializable
uInt16 getPC() const { return PC; } uInt16 getPC() const { return PC; }
/** /**
Return the last address that was part of a read/peek. Note that Check the type of the last peek().
reads which are part of a write are not considered here, unless
they're not the same as the last write address. This eliminates
accesses that are part of a normal read/write cycle.
@return The address of the last read @return true, if the last peek() was a ghost read.
*/ */
uInt16 lastReadAddress() const { bool lastWasGhostPeek() const { return myFlags == 0; } // DISASM_NONE
return myLastPokeAddress ?
(myLastPokeAddress != myLastPeekAddress ? myLastPeekAddress : 0) :
myLastPeekAddress;
}
/** /**
Return the last address that was part of a read/peek. Return the last address that was part of a read/peek.
@ -379,6 +372,8 @@ class M6502 : public Serializable
/// Indicates the last base (= non-mirrored) address which was /// Indicates the last base (= non-mirrored) address which was
/// accessed specifically by a peek or poke command /// accessed specifically by a peek or poke command
uInt16 myLastPeekBaseAddress, myLastPokeBaseAddress; uInt16 myLastPeekBaseAddress, myLastPokeBaseAddress;
// Indicates the type of the last access
uInt8 myFlags;
/// Indicates the last address used to access data by a peek command /// Indicates the last address used to access data by a peek command
/// for the CPU registers (S/A/X/Y) /// for the CPU registers (S/A/X/Y)