diff --git a/stella/src/emucore/TIA.cxx b/stella/src/emucore/TIA.cxx index 92f591881..469c1b9d7 100644 --- a/stella/src/emucore/TIA.cxx +++ b/stella/src/emucore/TIA.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TIA.cxx,v 1.68 2006-08-12 02:42:09 bwmott Exp $ +// $Id: TIA.cxx,v 1.69 2006-08-31 02:31:28 bwmott Exp $ //============================================================================ #include @@ -2211,8 +2211,18 @@ void TIA::poke(uInt16 addr, uInt8 value) case 0x02: // Wait for leading edge of HBLANK { - // Tell the cpu to waste the necessary amount of time - waitHorizontalSync(); + // It appears that the 6507 only halts during a read cycle so + // we test here for follow-on writes which should be ignored as + // far as halting the processor is concerned. + // + // TODO - 08-30-2006: This halting isn't correct since it's + // still halting on the original write. The 6507 emulation + // should be expanded to include a READY line. + if(mySystem->m6502().lastAccessWasRead()) + { + // Tell the cpu to waste the necessary amount of time + waitHorizontalSync(); + } break; } diff --git a/stella/src/emucore/m6502/src/M6502.cxx b/stella/src/emucore/m6502/src/M6502.cxx index a7ca234a9..25f3f5094 100644 --- a/stella/src/emucore/m6502/src/M6502.cxx +++ b/stella/src/emucore/m6502/src/M6502.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: M6502.cxx,v 1.16 2006-06-09 02:45:11 urchlay Exp $ +// $Id: M6502.cxx,v 1.17 2006-08-31 02:31:29 bwmott Exp $ //============================================================================ #include "M6502.hxx" @@ -80,6 +80,9 @@ void M6502::reset() SP = 0xff; PS(0x20); + // Reset access flag + myLastAccessWasRead = true; + // Load PC from the reset vector PC = (uInt16)mySystem->peek(0xfffc) | ((uInt16)mySystem->peek(0xfffd) << 8); } diff --git a/stella/src/emucore/m6502/src/M6502.hxx b/stella/src/emucore/m6502/src/M6502.hxx index 570932049..ea580f741 100644 --- a/stella/src/emucore/m6502/src/M6502.hxx +++ b/stella/src/emucore/m6502/src/M6502.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: M6502.hxx,v 1.16 2005-12-09 01:16:13 stephena Exp $ +// $Id: M6502.hxx,v 1.17 2006-08-31 02:31:29 bwmott Exp $ //============================================================================ #ifndef M6502_HXX @@ -41,7 +41,7 @@ typedef Common::Array ExpressionList; has a 64K addressing space. @author Bradford W. Mott - @version $Id: M6502.hxx,v 1.16 2005-12-09 01:16:13 stephena Exp $ + @version $Id: M6502.hxx,v 1.17 2006-08-31 02:31:29 bwmott Exp $ */ class M6502 { @@ -171,6 +171,13 @@ class M6502 */ uInt16 getPC() const { return PC; } + /** + Answer true iff the last memory access was a read. + + @return true iff last access was a read. + */ + bool lastAccessWasRead() const { return myLastAccessWasRead; } + public: /** Overload the ostream output operator for addressing modes. @@ -279,6 +286,9 @@ class M6502 /// Table of system cycles for each instruction uInt32 myInstructionSystemCycleTable[256]; + /// Indicates if the last memory access was a read or not + bool myLastAccessWasRead; + protected: /// Addressing mode for each of the 256 opcodes static AddressingMode ourAddressingModeTable[256]; diff --git a/stella/src/emucore/m6502/src/M6502Hi.cxx b/stella/src/emucore/m6502/src/M6502Hi.cxx index c9456abbe..85d9d730b 100644 --- a/stella/src/emucore/m6502/src/M6502Hi.cxx +++ b/stella/src/emucore/m6502/src/M6502Hi.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: M6502Hi.cxx,v 1.15 2005-12-17 01:23:07 stephena Exp $ +// $Id: M6502Hi.cxx,v 1.16 2006-08-31 02:31:29 bwmott Exp $ //============================================================================ #include "M6502Hi.hxx" @@ -62,7 +62,10 @@ inline uInt8 M6502High::peek(uInt16 address) } #endif - return mySystem->peek(address); + + uInt8 result = mySystem->peek(address); + myLastAccessWasRead = true; + return result; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -85,6 +88,7 @@ inline void M6502High::poke(uInt16 address, uInt8 value) #endif mySystem->poke(address, value); + myLastAccessWasRead = false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/m6502/src/M6502Low.cxx b/stella/src/emucore/m6502/src/M6502Low.cxx index d9780ddc0..72308e38f 100644 --- a/stella/src/emucore/m6502/src/M6502Low.cxx +++ b/stella/src/emucore/m6502/src/M6502Low.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: M6502Low.cxx,v 1.8 2006-02-05 02:49:47 stephena Exp $ +// $Id: M6502Low.cxx,v 1.9 2006-08-31 02:31:29 bwmott Exp $ //============================================================================ #include "M6502Low.hxx" @@ -52,7 +52,9 @@ inline uInt8 M6502Low::peek(uInt16 address) } #endif - return mySystem->peek(address); + uInt8 result = mySystem->peek(address); + myLastAccessWasRead = true; + return result; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -68,6 +70,7 @@ inline void M6502Low::poke(uInt16 address, uInt8 value) #endif mySystem->poke(address, value); + myLastAccessWasRead = false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -