Some performance improvements. Probably not noticable on current

systems, but seems to improve issues on slower computers.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2745 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2013-05-30 16:07:19 +00:00
parent 3eddecdd01
commit 4c6667f64d
6 changed files with 81 additions and 125 deletions

View File

@ -29,24 +29,25 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CpuDebug::CpuDebug(Debugger& dbg, Console& console)
: DebuggerSystem(dbg, console)
: DebuggerSystem(dbg, console),
my6502(mySystem.m6502())
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const DebuggerState& CpuDebug::getState()
{
myState.PC = mySystem.m6502().PC;
myState.SP = mySystem.m6502().SP;
myState.PS = mySystem.m6502().PS();
myState.A = mySystem.m6502().A;
myState.X = mySystem.m6502().X;
myState.Y = mySystem.m6502().Y;
myState.PC = my6502.PC;
myState.SP = my6502.SP;
myState.PS = my6502.PS();
myState.A = my6502.A;
myState.X = my6502.X;
myState.Y = my6502.Y;
myState.srcS = mySystem.m6502().lastSrcAddressS();
myState.srcA = mySystem.m6502().lastSrcAddressA();
myState.srcX = mySystem.m6502().lastSrcAddressX();
myState.srcY = mySystem.m6502().lastSrcAddressY();
myState.srcS = my6502.lastSrcAddressS();
myState.srcA = my6502.lastSrcAddressA();
myState.srcX = my6502.lastSrcAddressX();
myState.srcY = my6502.lastSrcAddressY();
Debugger::set_bits(myState.PS, myState.PSbits);
@ -56,17 +57,17 @@ const DebuggerState& CpuDebug::getState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::saveOldState()
{
myOldState.PC = mySystem.m6502().PC;
myOldState.SP = mySystem.m6502().SP;
myOldState.PS = mySystem.m6502().PS();
myOldState.A = mySystem.m6502().A;
myOldState.X = mySystem.m6502().X;
myOldState.Y = mySystem.m6502().Y;
myOldState.PC = my6502.PC;
myOldState.SP = my6502.SP;
myOldState.PS = my6502.PS();
myOldState.A = my6502.A;
myOldState.X = my6502.X;
myOldState.Y = my6502.Y;
myOldState.srcS = mySystem.m6502().lastSrcAddressS();
myOldState.srcA = mySystem.m6502().lastSrcAddressA();
myOldState.srcX = mySystem.m6502().lastSrcAddressX();
myOldState.srcY = mySystem.m6502().lastSrcAddressY();
myOldState.srcS = my6502.lastSrcAddressS();
myOldState.srcA = my6502.lastSrcAddressA();
myOldState.srcX = my6502.lastSrcAddressX();
myOldState.srcY = my6502.lastSrcAddressY();
Debugger::set_bits(myOldState.PS, myOldState.PSbits);
}
@ -74,119 +75,119 @@ void CpuDebug::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setPC(int pc)
{
mySystem.m6502().PC = pc;
my6502.PC = pc;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setSP(int sp)
{
mySystem.m6502().SP = sp;
my6502.SP = sp;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setPS(int ps)
{
mySystem.m6502().PS(ps);
my6502.PS(ps);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setA(int a)
{
mySystem.m6502().A = a;
my6502.A = a;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setX(int x)
{
mySystem.m6502().X = x;
my6502.X = x;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setY(int y)
{
mySystem.m6502().Y = y;
my6502.Y = y;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setN(bool on)
{
setPS( Debugger::set_bit(mySystem.m6502().PS(), 7, on) );
my6502.N = on;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setV(bool on)
{
setPS( Debugger::set_bit(mySystem.m6502().PS(), 6, on) );
my6502.V = on;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setB(bool on)
{
setPS( Debugger::set_bit(mySystem.m6502().PS(), 4, on) );
// nop - B is always true
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setD(bool on)
{
setPS( Debugger::set_bit(mySystem.m6502().PS(), 3, on) );
my6502.D = on;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setI(bool on)
{
setPS( Debugger::set_bit(mySystem.m6502().PS(), 2, on) );
my6502.I = on;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setZ(bool on)
{
setPS( Debugger::set_bit(mySystem.m6502().PS(), 1, on) );
my6502.notZ = !on;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setC(bool on)
{
setPS( Debugger::set_bit(mySystem.m6502().PS(), 0, on) );
my6502.C = on;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::toggleN()
{
setPS( mySystem.m6502().PS() ^ 0x80 );
my6502.N = !my6502.N;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::toggleV()
{
setPS( mySystem.m6502().PS() ^ 0x40 );
my6502.V = !my6502.V;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::toggleB()
{
setPS( mySystem.m6502().PS() ^ 0x10 );
// nop - B is always true
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::toggleD()
{
setPS( mySystem.m6502().PS() ^ 0x08 );
my6502.D = !my6502.D;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::toggleI()
{
setPS( mySystem.m6502().PS() ^ 0x04 );
my6502.I = !my6502.I;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::toggleZ()
{
setPS( mySystem.m6502().PS() ^ 0x02 );
my6502.notZ = !my6502.notZ;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::toggleC()
{
setPS( mySystem.m6502().PS() ^ 0x01 );
my6502.C = !my6502.C;
}

View File

@ -94,6 +94,8 @@ class CpuDebug : public DebuggerSystem
void toggleC();
private:
M6502& my6502;
CpuState myState;
CpuState myOldState;
};

View File

@ -23,8 +23,6 @@
#include "bspf.hxx"
#include "StellaKeys.hxx"
class Event;
/**
@author Bradford W. Mott
@version $Id$

View File

@ -126,67 +126,17 @@ void M6502::reset()
myDataAddressForPoke = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::irq()
{
myExecutionStatus |= MaskableInterruptBit;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::nmi()
{
myExecutionStatus |= NonmaskableInterruptBit;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::stop()
{
myExecutionStatus |= StopExecutionBit;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 M6502::PS() const
{
uInt8 ps = 0x20;
if(N)
ps |= 0x80;
if(V)
ps |= 0x40;
if(B)
ps |= 0x10;
if(D)
ps |= 0x08;
if(I)
ps |= 0x04;
if(!notZ)
ps |= 0x02;
if(C)
ps |= 0x01;
return ps;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6502::PS(uInt8 ps)
{
N = ps & 0x80;
V = ps & 0x40;
B = true; // B = ps & 0x10; The 6507's B flag always true
D = ps & 0x08;
I = ps & 0x04;
notZ = !(ps & 0x02);
C = ps & 0x01;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline uInt8 M6502::peek(uInt16 address, uInt8 flags)
{
////////////////////////////////////////////////
// TODO - move this logic directly into CartAR
if(address != myLastAddress)
{
myNumberOfDistinctAccesses++;
myLastAddress = address;
}
////////////////////////////////////////////////
mySystem->incrementCycles(mySystemCyclesPerProcessorCycle);
#ifdef DEBUGGER_SUPPORT
@ -208,11 +158,14 @@ inline uInt8 M6502::peek(uInt16 address, uInt8 flags)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void M6502::poke(uInt16 address, uInt8 value)
{
////////////////////////////////////////////////
// TODO - move this logic directly into CartAR
if(address != myLastAddress)
{
myNumberOfDistinctAccesses++;
myLastAddress = address;
}
////////////////////////////////////////////////
mySystem->incrementCycles(mySystemCyclesPerProcessorCycle);
#ifdef DEBUGGER_SUPPORT

View File

@ -87,12 +87,12 @@ class M6502 : public Serializable
/**
Request a maskable interrupt
*/
void irq();
void irq() { myExecutionStatus |= MaskableInterruptBit; }
/**
Request a non-maskable interrupt
*/
void nmi();
void nmi() { myExecutionStatus |= NonmaskableInterruptBit; }
/**
Execute instructions until the specified number of instructions
@ -109,7 +109,7 @@ class M6502 : public Serializable
method while the processor is executing instructions will stop
execution as soon as possible.
*/
void stop();
void stop() { myExecutionStatus |= StopExecutionBit; }
/**
Answer true iff a fatal error has occured from which the processor
@ -253,14 +253,34 @@ class M6502 : public Serializable
@return The processor status register
*/
uInt8 PS() const;
uInt8 PS() const {
uInt8 ps = 0x20;
if(N) ps |= 0x80;
if(V) ps |= 0x40;
if(B) ps |= 0x10;
if(D) ps |= 0x08;
if(I) ps |= 0x04;
if(!notZ) ps |= 0x02;
if(C) ps |= 0x01;
return ps;
}
/**
Change the Processor Status register to correspond to the given value.
@param ps The value to set the processor status register to
*/
void PS(uInt8 ps);
void PS(uInt8 ps) {
N = ps & 0x80;
V = ps & 0x40;
B = true; // B = ps & 0x10; The 6507's B flag always true
D = ps & 0x08;
I = ps & 0x04;
notZ = !(ps & 0x02);
C = ps & 0x01;
}
/**
Called after an interrupt has be requested using irq() or nmi()

View File

@ -115,10 +115,7 @@ class System : public Serializable
@return The attached 6502 microprocessor
*/
M6502& m6502()
{
return *myM6502;
}
M6502& m6502() { return *myM6502; }
/**
Answer the 6532 processor attached to the system. If a
@ -126,30 +123,21 @@ class System : public Serializable
@return The attached 6532 microprocessor
*/
M6532& m6532()
{
return *myM6532;
}
M6532& m6532() { return *myM6532; }
/**
Answer the TIA device attached to the system.
@return The attached TIA device
*/
TIA& tia()
{
return *myTIA;
}
TIA& tia() { return *myTIA; }
/**
Answer the random generator attached to the system.
@return The random generator
*/
Random& randGenerator()
{
return *myRandom;
}
Random& randGenerator() { return *myRandom; }
/**
Get the null device associated with the system. Every system
@ -158,10 +146,7 @@ class System : public Serializable
@return The null device associated with the system
*/
NullDevice& nullDevice()
{
return myNullDevice;
}
NullDevice& nullDevice() { return myNullDevice; }
/**
Get the total number of pages available in the system.
@ -198,10 +183,7 @@ class System : public Serializable
@param amount The amount to add to the system cycles counter
*/
void incrementCycles(uInt32 amount)
{
myCycles += amount;
}
void incrementCycles(uInt32 amount) { myCycles += amount; }
/**
Reset the system cycle count to zero. The first thing that