mirror of https://github.com/stella-emu/stella.git
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
This commit is contained in:
parent
a95c81ad80
commit
068f07d919
|
@ -27,7 +27,6 @@
|
||||||
CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size,
|
CartridgeAR::CartridgeAR(const uInt8* image, uInt32 size,
|
||||||
const Settings& settings)
|
const Settings& settings)
|
||||||
: Cartridge(settings),
|
: Cartridge(settings),
|
||||||
my6502(0),
|
|
||||||
mySize(BSPF_max(size, 8448u)),
|
mySize(BSPF_max(size, 8448u)),
|
||||||
myLoadImages(nullptr)
|
myLoadImages(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -85,11 +84,8 @@ void CartridgeAR::reset()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeAR::systemCyclesReset()
|
void CartridgeAR::systemCyclesReset()
|
||||||
{
|
{
|
||||||
// Get the current system cycle
|
|
||||||
uInt32 cycles = mySystem->cycles();
|
|
||||||
|
|
||||||
// Adjust cycle values
|
// Adjust cycle values
|
||||||
myPowerRomCycle -= cycles;
|
myPowerRomCycle -= mySystem->cycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -97,8 +93,6 @@ void CartridgeAR::install(System& system)
|
||||||
{
|
{
|
||||||
mySystem = &system;
|
mySystem = &system;
|
||||||
|
|
||||||
my6502 = &(mySystem->m6502());
|
|
||||||
|
|
||||||
// Map all of the accesses to call peek and poke (we don't yet indicate RAM areas)
|
// Map all of the accesses to call peek and poke (we don't yet indicate RAM areas)
|
||||||
System::PageAccess access(this, System::PA_READ);
|
System::PageAccess access(this, System::PA_READ);
|
||||||
for(uInt32 i = 0x1000; i < 0x2000; i += (1 << System::PAGE_SHIFT))
|
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
|
// Cancel any pending write if more than 5 distinct accesses have occurred
|
||||||
// TODO: Modify to handle when the distinct counter wraps around...
|
// TODO: Modify to handle when the distinct counter wraps around...
|
||||||
if(myWritePending &&
|
if(myWritePending &&
|
||||||
(my6502->distinctAccesses() > myNumberOfDistinctAccesses + 5))
|
(mySystem->m6502().distinctAccesses() > myNumberOfDistinctAccesses + 5))
|
||||||
{
|
{
|
||||||
myWritePending = false;
|
myWritePending = false;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +133,7 @@ uInt8 CartridgeAR::peek(uInt16 addr)
|
||||||
if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending))
|
if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending))
|
||||||
{
|
{
|
||||||
myDataHoldRegister = addr;
|
myDataHoldRegister = addr;
|
||||||
myNumberOfDistinctAccesses = my6502->distinctAccesses();
|
myNumberOfDistinctAccesses = mySystem->m6502().distinctAccesses();
|
||||||
myWritePending = true;
|
myWritePending = true;
|
||||||
}
|
}
|
||||||
// Is the bank configuration hotspot being accessed?
|
// Is the bank configuration hotspot being accessed?
|
||||||
|
@ -151,7 +145,7 @@ uInt8 CartridgeAR::peek(uInt16 addr)
|
||||||
}
|
}
|
||||||
// Handle poke if writing enabled
|
// Handle poke if writing enabled
|
||||||
else if(myWriteEnabled && myWritePending &&
|
else if(myWriteEnabled && myWritePending &&
|
||||||
(my6502->distinctAccesses() == (myNumberOfDistinctAccesses + 5)))
|
(mySystem->m6502().distinctAccesses() == (myNumberOfDistinctAccesses + 5)))
|
||||||
{
|
{
|
||||||
if((addr & 0x0800) == 0)
|
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
|
// Cancel any pending write if more than 5 distinct accesses have occurred
|
||||||
// TODO: Modify to handle when the distinct counter wraps around...
|
// TODO: Modify to handle when the distinct counter wraps around...
|
||||||
if(myWritePending &&
|
if(myWritePending &&
|
||||||
(my6502->distinctAccesses() > myNumberOfDistinctAccesses + 5))
|
(mySystem->m6502().distinctAccesses() > myNumberOfDistinctAccesses + 5))
|
||||||
{
|
{
|
||||||
myWritePending = false;
|
myWritePending = false;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +180,7 @@ bool CartridgeAR::poke(uInt16 addr, uInt8)
|
||||||
if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending))
|
if(!(addr & 0x0F00) && (!myWriteEnabled || !myWritePending))
|
||||||
{
|
{
|
||||||
myDataHoldRegister = addr;
|
myDataHoldRegister = addr;
|
||||||
myNumberOfDistinctAccesses = my6502->distinctAccesses();
|
myNumberOfDistinctAccesses = mySystem->m6502().distinctAccesses();
|
||||||
myWritePending = true;
|
myWritePending = true;
|
||||||
}
|
}
|
||||||
// Is the bank configuration hotspot being accessed?
|
// Is the bank configuration hotspot being accessed?
|
||||||
|
@ -198,7 +192,7 @@ bool CartridgeAR::poke(uInt16 addr, uInt8)
|
||||||
}
|
}
|
||||||
// Handle poke if writing enabled
|
// Handle poke if writing enabled
|
||||||
else if(myWriteEnabled && myWritePending &&
|
else if(myWriteEnabled && myWritePending &&
|
||||||
(my6502->distinctAccesses() == (myNumberOfDistinctAccesses + 5)))
|
(mySystem->m6502().distinctAccesses() == (myNumberOfDistinctAccesses + 5)))
|
||||||
{
|
{
|
||||||
if((addr & 0x0800) == 0)
|
if((addr & 0x0800) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#ifndef CARTRIDGEAR_HXX
|
#ifndef CARTRIDGEAR_HXX
|
||||||
#define CARTRIDGEAR_HXX
|
#define CARTRIDGEAR_HXX
|
||||||
|
|
||||||
class M6502;
|
|
||||||
class System;
|
class System;
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
@ -190,9 +189,6 @@ class CartridgeAR : public Cartridge
|
||||||
void initializeROM();
|
void initializeROM();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Pointer to the 6502 processor in the system
|
|
||||||
M6502* my6502;
|
|
||||||
|
|
||||||
// Indicates the offset within the image for the corresponding bank
|
// Indicates the offset within the image for the corresponding bank
|
||||||
uInt32 myImageOffset[2];
|
uInt32 myImageOffset[2];
|
||||||
|
|
||||||
|
|
|
@ -73,11 +73,8 @@ void CartridgeDPC::reset()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeDPC::systemCyclesReset()
|
void CartridgeDPC::systemCyclesReset()
|
||||||
{
|
{
|
||||||
// Get the current system cycle
|
|
||||||
uInt32 cycles = mySystem->cycles();
|
|
||||||
|
|
||||||
// Adjust the cycle counter so that it reflects the new value
|
// Adjust the cycle counter so that it reflects the new value
|
||||||
mySystemCycles -= cycles;
|
mySystemCycles -= mySystem->cycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -113,11 +113,8 @@ void CartridgeDPCPlus::setInitialState()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeDPCPlus::systemCyclesReset()
|
void CartridgeDPCPlus::systemCyclesReset()
|
||||||
{
|
{
|
||||||
// Get the current system cycle
|
|
||||||
uInt32 cycles = mySystem->cycles();
|
|
||||||
|
|
||||||
// Adjust the cycle counter so that it reflects the new value
|
// Adjust the cycle counter so that it reflects the new value
|
||||||
mySystemCycles -= cycles;
|
mySystemCycles -= mySystem->cycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -50,7 +50,6 @@ M6502::M6502(const Settings& settings)
|
||||||
mySystem(nullptr),
|
mySystem(nullptr),
|
||||||
mySettings(settings),
|
mySettings(settings),
|
||||||
myLastAccessWasRead(true),
|
myLastAccessWasRead(true),
|
||||||
myTotalInstructionCount(0),
|
|
||||||
myNumberOfDistinctAccesses(0),
|
myNumberOfDistinctAccesses(0),
|
||||||
myLastAddress(0),
|
myLastAddress(0),
|
||||||
myLastPeekAddress(0),
|
myLastPeekAddress(0),
|
||||||
|
@ -104,8 +103,6 @@ void M6502::reset()
|
||||||
// Load PC from the reset vector
|
// Load PC from the reset vector
|
||||||
PC = (uInt16)mySystem->peek(0xfffc) | ((uInt16)mySystem->peek(0xfffd) << 8);
|
PC = (uInt16)mySystem->peek(0xfffc) | ((uInt16)mySystem->peek(0xfffd) << 8);
|
||||||
|
|
||||||
myTotalInstructionCount = 0;
|
|
||||||
|
|
||||||
myLastAddress = myLastPeekAddress = myLastPokeAddress = 0;
|
myLastAddress = myLastPeekAddress = myLastPokeAddress = 0;
|
||||||
myLastSrcAddressS = myLastSrcAddressA =
|
myLastSrcAddressS = myLastSrcAddressA =
|
||||||
myLastSrcAddressX = myLastSrcAddressY = -1;
|
myLastSrcAddressX = myLastSrcAddressY = -1;
|
||||||
|
@ -220,7 +217,6 @@ bool M6502::execute(uInt32 number)
|
||||||
// Oops, illegal instruction executed so set fatal error flag
|
// Oops, illegal instruction executed so set fatal error flag
|
||||||
myExecutionStatus |= FatalErrorBit;
|
myExecutionStatus |= FatalErrorBit;
|
||||||
}
|
}
|
||||||
myTotalInstructionCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we need to handle an interrupt
|
// See if we need to handle an interrupt
|
||||||
|
|
|
@ -164,13 +164,6 @@ class M6502 : public Serializable
|
||||||
Int32 lastSrcAddressX() const { return myLastSrcAddressX; }
|
Int32 lastSrcAddressX() const { return myLastSrcAddressX; }
|
||||||
Int32 lastSrcAddressY() const { return myLastSrcAddressY; }
|
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
|
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
|
/// Indicates if the last memory access was a read or not
|
||||||
bool myLastAccessWasRead;
|
bool myLastAccessWasRead;
|
||||||
|
|
||||||
/// The total number of instructions executed so far
|
|
||||||
int myTotalInstructionCount;
|
|
||||||
|
|
||||||
/// Indicates the numer of distinct memory accesses
|
/// Indicates the numer of distinct memory accesses
|
||||||
uInt32 myNumberOfDistinctAccesses;
|
uInt32 myNumberOfDistinctAccesses;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue