From 068f07d919a66bac3e1989a4f7c339ea38676ef1 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 23 Nov 2014 18:53:11 +0000 Subject: [PATCH] A few optimizations, and removal of some dead code. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3101 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/emucore/CartAR.cxx | 20 +++++++------------- src/emucore/CartAR.hxx | 4 ---- src/emucore/CartDPC.cxx | 5 +---- src/emucore/CartDPCPlus.cxx | 5 +---- src/emucore/M6502.cxx | 4 ---- src/emucore/M6502.hxx | 10 ---------- 6 files changed, 9 insertions(+), 39 deletions(-) diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index 1e1099b77..c1bfc56fd 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -27,7 +27,6 @@ CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size, const Settings& settings) : Cartridge(settings), - my6502(0), mySize(BSPF_max(size, 8448u)), myLoadImages(nullptr) { @@ -85,11 +84,8 @@ void CartridgeAR::reset() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeAR::systemCyclesReset() { - // Get the current system cycle - uInt32 cycles = mySystem->cycles(); - // Adjust cycle values - myPowerRomCycle -= cycles; + myPowerRomCycle -= mySystem->cycles(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -97,8 +93,6 @@ void CartridgeAR::install(System& system) { mySystem = &system; - my6502 = &(mySystem->m6502()); - // Map all of the accesses to call peek and poke (we don't yet indicate RAM areas) System::PageAccess access(this, System::PA_READ); for(uInt32 i = 0x1000; i < 0x2000; i += (1 << System::PAGE_SHIFT)) @@ -130,7 +124,7 @@ uInt8 CartridgeAR::peek(uInt16 addr) // Cancel any pending write if more than 5 distinct accesses have occurred // TODO: Modify to handle when the distinct counter wraps around... if(myWritePending && - (my6502->distinctAccesses() > myNumberOfDistinctAccesses + 5)) + (mySystem->m6502().distinctAccesses() > myNumberOfDistinctAccesses + 5)) { myWritePending = false; } @@ -139,7 +133,7 @@ uInt8 CartridgeAR::peek(uInt16 addr) if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending)) { myDataHoldRegister = addr; - myNumberOfDistinctAccesses = my6502->distinctAccesses(); + myNumberOfDistinctAccesses = mySystem->m6502().distinctAccesses(); myWritePending = true; } // Is the bank configuration hotspot being accessed? @@ -151,7 +145,7 @@ uInt8 CartridgeAR::peek(uInt16 addr) } // Handle poke if writing enabled else if(myWriteEnabled && myWritePending && - (my6502->distinctAccesses() == (myNumberOfDistinctAccesses + 5))) + (mySystem->m6502().distinctAccesses() == (myNumberOfDistinctAccesses + 5))) { if((addr & 0x0800) == 0) { @@ -177,7 +171,7 @@ bool CartridgeAR::poke(uInt16 addr, uInt8) // Cancel any pending write if more than 5 distinct accesses have occurred // TODO: Modify to handle when the distinct counter wraps around... if(myWritePending && - (my6502->distinctAccesses() > myNumberOfDistinctAccesses + 5)) + (mySystem->m6502().distinctAccesses() > myNumberOfDistinctAccesses + 5)) { myWritePending = false; } @@ -186,7 +180,7 @@ bool CartridgeAR::poke(uInt16 addr, uInt8) if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending)) { myDataHoldRegister = addr; - myNumberOfDistinctAccesses = my6502->distinctAccesses(); + myNumberOfDistinctAccesses = mySystem->m6502().distinctAccesses(); myWritePending = true; } // Is the bank configuration hotspot being accessed? @@ -198,7 +192,7 @@ bool CartridgeAR::poke(uInt16 addr, uInt8) } // Handle poke if writing enabled else if(myWriteEnabled && myWritePending && - (my6502->distinctAccesses() == (myNumberOfDistinctAccesses + 5))) + (mySystem->m6502().distinctAccesses() == (myNumberOfDistinctAccesses + 5))) { if((addr & 0x0800) == 0) { diff --git a/src/emucore/CartAR.hxx b/src/emucore/CartAR.hxx index 3ee230a3d..646d07f53 100644 --- a/src/emucore/CartAR.hxx +++ b/src/emucore/CartAR.hxx @@ -20,7 +20,6 @@ #ifndef CARTRIDGEAR_HXX #define CARTRIDGEAR_HXX -class M6502; class System; #include "bspf.hxx" @@ -190,9 +189,6 @@ class CartridgeAR : public Cartridge void initializeROM(); private: - // Pointer to the 6502 processor in the system - M6502* my6502; - // Indicates the offset within the image for the corresponding bank uInt32 myImageOffset[2]; diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index 454c7f7de..e00699f23 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -73,11 +73,8 @@ void CartridgeDPC::reset() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeDPC::systemCyclesReset() { - // Get the current system cycle - uInt32 cycles = mySystem->cycles(); - // Adjust the cycle counter so that it reflects the new value - mySystemCycles -= cycles; + mySystemCycles -= mySystem->cycles(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index ce25b34a3..9f7e8c155 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -113,11 +113,8 @@ void CartridgeDPCPlus::setInitialState() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeDPCPlus::systemCyclesReset() { - // Get the current system cycle - uInt32 cycles = mySystem->cycles(); - // Adjust the cycle counter so that it reflects the new value - mySystemCycles -= cycles; + mySystemCycles -= mySystem->cycles(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index cc53d55da..d4c2385e6 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -50,7 +50,6 @@ M6502::M6502(const Settings& settings) mySystem(nullptr), mySettings(settings), myLastAccessWasRead(true), - myTotalInstructionCount(0), myNumberOfDistinctAccesses(0), myLastAddress(0), myLastPeekAddress(0), @@ -104,8 +103,6 @@ void M6502::reset() // Load PC from the reset vector PC = (uInt16)mySystem->peek(0xfffc) | ((uInt16)mySystem->peek(0xfffd) << 8); - myTotalInstructionCount = 0; - myLastAddress = myLastPeekAddress = myLastPokeAddress = 0; myLastSrcAddressS = myLastSrcAddressA = myLastSrcAddressX = myLastSrcAddressY = -1; @@ -220,7 +217,6 @@ bool M6502::execute(uInt32 number) // Oops, illegal instruction executed so set fatal error flag myExecutionStatus |= FatalErrorBit; } - myTotalInstructionCount++; } // See if we need to handle an interrupt diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index 266004178..fae76ee62 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -164,13 +164,6 @@ class M6502 : public Serializable Int32 lastSrcAddressX() const { return myLastSrcAddressX; } Int32 lastSrcAddressY() const { return myLastSrcAddressY; } - /** - Get the total number of instructions executed so far. - - @return The number of executed instructions - */ - int totalInstructionCount() const { return myTotalInstructionCount; } - /** Get the number of memory accesses to distinct memory locations @@ -318,9 +311,6 @@ class M6502 : public Serializable /// Indicates if the last memory access was a read or not bool myLastAccessWasRead; - /// The total number of instructions executed so far - int myTotalInstructionCount; - /// Indicates the numer of distinct memory accesses uInt32 myNumberOfDistinctAccesses;