From a21f3be6e40c82b6684f40298f844264552483b5 Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 3 Nov 2014 13:22:57 +0000 Subject: [PATCH] Turned variable into static constant in M6502, since it has never changed since Stella was created. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3033 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/emucore/Console.cxx | 2 +- src/emucore/M6502.cxx | 13 ++++++------- src/emucore/M6502.hxx | 14 +++++--------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index f51fcc615..b5670b112 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -97,7 +97,7 @@ Console::Console(OSystem& osystem, Cartridge& cart, const Properties& props) myControllers[0] = new Joystick(Controller::Left, myEvent, *mySystem); myControllers[1] = new Joystick(Controller::Right, myEvent, *mySystem); - M6502* m6502 = new M6502(1, myOSystem.settings()); + M6502* m6502 = new M6502(myOSystem.settings()); myRiot = new M6532(*this, myOSystem.settings()); myTIA = new TIA(*this, myOSystem.sound(), myOSystem.settings()); diff --git a/src/emucore/M6502.cxx b/src/emucore/M6502.cxx index 06ce9c560..68f38d9d4 100644 --- a/src/emucore/M6502.cxx +++ b/src/emucore/M6502.cxx @@ -47,11 +47,10 @@ #include "M6502.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -M6502::M6502(uInt32 systemCyclesPerProcessorCycle, const Settings& settings) +M6502::M6502(const Settings& settings) : myExecutionStatus(0), mySystem(0), mySettings(settings), - mySystemCyclesPerProcessorCycle(systemCyclesPerProcessorCycle), myLastAccessWasRead(true), myTotalInstructionCount(0), myNumberOfDistinctAccesses(0), @@ -77,7 +76,7 @@ M6502::M6502(uInt32 systemCyclesPerProcessorCycle, const Settings& settings) for(uInt32 t = 0; t < 256; ++t) { myInstructionSystemCycleTable[t] = ourInstructionCycleTable[t] * - mySystemCyclesPerProcessorCycle; + SYSTEM_CYCLES_PER_CPU; } #ifdef DEBUG_OUTPUT @@ -147,7 +146,7 @@ inline uInt8 M6502::peek(uInt16 address, uInt8 flags) myLastAddress = address; } //////////////////////////////////////////////// - mySystem->incrementCycles(mySystemCyclesPerProcessorCycle); + mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU); #ifdef DEBUGGER_SUPPORT if(myReadTraps != NULL && myReadTraps->isSet(address)) @@ -176,7 +175,7 @@ inline void M6502::poke(uInt16 address, uInt8 value) myLastAddress = address; } //////////////////////////////////////////////// - mySystem->incrementCycles(mySystemCyclesPerProcessorCycle); + mySystem->incrementCycles(SYSTEM_CYCLES_PER_CPU); #ifdef DEBUGGER_SUPPORT if(myWriteTraps != NULL && myWriteTraps->isSet(address)) @@ -306,7 +305,7 @@ void M6502::interruptHandler() // Handle the interrupt if((myExecutionStatus & MaskableInterruptBit) && !I) { - mySystem->incrementCycles(7 * mySystemCyclesPerProcessorCycle); + mySystem->incrementCycles(7 * SYSTEM_CYCLES_PER_CPU); mySystem->poke(0x0100 + SP--, (PC - 1) >> 8); mySystem->poke(0x0100 + SP--, (PC - 1) & 0x00ff); mySystem->poke(0x0100 + SP--, PS() & (~0x10)); @@ -316,7 +315,7 @@ void M6502::interruptHandler() } else if(myExecutionStatus & NonmaskableInterruptBit) { - mySystem->incrementCycles(7 * mySystemCyclesPerProcessorCycle); + mySystem->incrementCycles(7 * SYSTEM_CYCLES_PER_CPU); mySystem->poke(0x0100 + SP--, (PC - 1) >> 8); mySystem->poke(0x0100 + SP--, (PC - 1) & 0x00ff); mySystem->poke(0x0100 + SP--, PS() & (~0x10)); diff --git a/src/emucore/M6502.hxx b/src/emucore/M6502.hxx index 0045f5e5b..86b13e73d 100644 --- a/src/emucore/M6502.hxx +++ b/src/emucore/M6502.hxx @@ -56,13 +56,9 @@ class M6502 : public Serializable public: /** - Create a new 6502 microprocessor with the specified cycle - multiplier. The cycle multiplier is the number of system cycles - per processor cycle. - - @param systemCyclesPerProcessorCycle The cycle multiplier + Create a new 6502 microprocessor. */ - M6502(uInt32 systemCyclesPerProcessorCycle, const Settings& settings); + M6502(const Settings& settings); /** Destructor @@ -324,9 +320,6 @@ class M6502 : public Serializable /// Reference to the settings const Settings& mySettings; - /// Indicates the number of system cycles per processor cycle - const uInt32 mySystemCyclesPerProcessorCycle; - /// Table of system cycles for each instruction uInt32 myInstructionSystemCycleTable[256]; @@ -357,6 +350,9 @@ class M6502 : public Serializable /// is set to zero uInt16 myDataAddressForPoke; + /// Indicates the number of system cycles per processor cycle + static const uInt32 SYSTEM_CYCLES_PER_CPU = 1; + #ifdef DEBUGGER_SUPPORT /// Pointer to the debugger for this processor or the null pointer Debugger* myDebugger;