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);
if(myRWPortTriggersBreak &&
mySystem.m6502().lastReadAddress() &&
(mySystem.getPageAccessType(addr) & System::PA_WRITE) == System::PA_WRITE)
!mySystem.m6502().lastWasGhostPeek())
{
ostringstream msg;
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
// differentiates between reads that are normally part of a write cycle vs.
// ones that are illegal)
if(mySystem.m6502().lastReadAddress() &&
(mySystem.getPageAccessType(addr) & System::PA_WRITE) == System::PA_WRITE)
if(!mySystem.m6502().lastWasGhostPeek())
return addr;
else
return 0;

View File

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

View File

@ -143,18 +143,11 @@ class M6502 : public Serializable
uInt16 getPC() const { return PC; }
/**
Return the last address that was part of a read/peek. Note that
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.
Check the type of the last peek().
@return The address of the last read
@return true, if the last peek() was a ghost read.
*/
uInt16 lastReadAddress() const {
return myLastPokeAddress ?
(myLastPokeAddress != myLastPeekAddress ? myLastPeekAddress : 0) :
myLastPeekAddress;
}
bool lastWasGhostPeek() const { return myFlags == 0; } // DISASM_NONE
/**
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
/// accessed specifically by a peek or poke command
uInt16 myLastPeekBaseAddress, myLastPokeBaseAddress;
// Indicates the type of the last access
uInt8 myFlags;
/// Indicates the last address used to access data by a peek command
/// for the CPU registers (S/A/X/Y)