mirror of https://github.com/stella-emu/stella.git
Open ROMs for profiling, refactoring.
This commit is contained in:
parent
58d7846f6b
commit
806045cb1c
|
@ -207,6 +207,17 @@ class Cartridge : public Device
|
||||||
virtual CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
|
virtual CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||||
const GUI::Font& nfont, int x, int y, int w, int h) { return nullptr; }
|
const GUI::Font& nfont, int x, int y, int w, int h) { return nullptr; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
We don't want cartridges to depend on OSystem by default. Cartridges that require OSystem
|
||||||
|
should override this method to get the OSystem instance injected via setter.
|
||||||
|
*/
|
||||||
|
virtual bool requiresOSystem() { return false; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Setter for injecting OSystem.
|
||||||
|
*/
|
||||||
|
virtual void setOSystem(OSystem* osystem) {};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
Get a random value to use when a read from the write port happens.
|
Get a random value to use when a read from the write port happens.
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
CartridgeCTY::CartridgeCTY(const BytePtr& image, uInt32 size,
|
CartridgeCTY::CartridgeCTY(const BytePtr& image, uInt32 size,
|
||||||
const string& md5, const OSystem& osystem)
|
const string& md5, const Settings& settings)
|
||||||
: Cartridge(osystem.settings(), md5),
|
: Cartridge(settings, md5),
|
||||||
myOSystem(osystem),
|
myOSystem(nullptr),
|
||||||
myOperationType(0),
|
myOperationType(0),
|
||||||
myTunePosition(0),
|
myTunePosition(0),
|
||||||
myLDAimmediate(false),
|
myLDAimmediate(false),
|
||||||
|
@ -344,7 +344,7 @@ bool CartridgeCTY::load(Serializer& in)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeCTY::setRomName(const string& name)
|
void CartridgeCTY::setRomName(const string& name)
|
||||||
{
|
{
|
||||||
myEEPROMFile = myOSystem.nvramDir() + name + "_eeprom.dat";
|
myEEPROMFile = myOSystem->nvramDir() + name + "_eeprom.dat";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -381,7 +381,7 @@ uInt8 CartridgeCTY::ramReadWrite()
|
||||||
if(index < 7)
|
if(index < 7)
|
||||||
{
|
{
|
||||||
// Add 0.5 s delay for read
|
// Add 0.5 s delay for read
|
||||||
myRamAccessTimeout = myOSystem.getTicks() + 500000;
|
myRamAccessTimeout = myOSystem->getTicks() + 500000;
|
||||||
loadTune(index);
|
loadTune(index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -389,7 +389,7 @@ uInt8 CartridgeCTY::ramReadWrite()
|
||||||
if(index < 4)
|
if(index < 4)
|
||||||
{
|
{
|
||||||
// Add 0.5 s delay for read
|
// Add 0.5 s delay for read
|
||||||
myRamAccessTimeout = myOSystem.getTicks() + 500000;
|
myRamAccessTimeout = myOSystem->getTicks() + 500000;
|
||||||
loadScore(index);
|
loadScore(index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -397,13 +397,13 @@ uInt8 CartridgeCTY::ramReadWrite()
|
||||||
if(index < 4)
|
if(index < 4)
|
||||||
{
|
{
|
||||||
// Add 1 s delay for write
|
// Add 1 s delay for write
|
||||||
myRamAccessTimeout = myOSystem.getTicks() + 1000000;
|
myRamAccessTimeout = myOSystem->getTicks() + 1000000;
|
||||||
saveScore(index);
|
saveScore(index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4: // Wipe all score tables
|
case 4: // Wipe all score tables
|
||||||
// Add 1 s delay for write
|
// Add 1 s delay for write
|
||||||
myRamAccessTimeout = myOSystem.getTicks() + 1000000;
|
myRamAccessTimeout = myOSystem->getTicks() + 1000000;
|
||||||
wipeAllScores();
|
wipeAllScores();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@ uInt8 CartridgeCTY::ramReadWrite()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Have we reached the timeout value yet?
|
// Have we reached the timeout value yet?
|
||||||
if(myOSystem.getTicks() >= myRamAccessTimeout)
|
if(myOSystem->getTicks() >= myRamAccessTimeout)
|
||||||
{
|
{
|
||||||
myRamAccessTimeout = 0; // Turn off timer
|
myRamAccessTimeout = 0; // Turn off timer
|
||||||
myRAM[0] = 0; // Successful operation
|
myRAM[0] = 0; // Successful operation
|
||||||
|
|
|
@ -119,7 +119,7 @@ class CartridgeCTY : public Cartridge
|
||||||
@param osystem A reference to the OSystem currently in use
|
@param osystem A reference to the OSystem currently in use
|
||||||
*/
|
*/
|
||||||
CartridgeCTY(const BytePtr& image, uInt32 size, const string& md5,
|
CartridgeCTY(const BytePtr& image, uInt32 size, const string& md5,
|
||||||
const OSystem& osystem);
|
const Settings& settings);
|
||||||
virtual ~CartridgeCTY() = default;
|
virtual ~CartridgeCTY() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -256,9 +256,13 @@ class CartridgeCTY : public Cartridge
|
||||||
|
|
||||||
void updateTune();
|
void updateTune();
|
||||||
|
|
||||||
|
bool requiresOSystem() override { return true; }
|
||||||
|
|
||||||
|
void setOSystem(OSystem* osystem) override { myOSystem = osystem; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// OSsytem currently in use
|
// OSsytem currently in use
|
||||||
const OSystem& myOSystem;
|
const OSystem* myOSystem;
|
||||||
|
|
||||||
// The 32K ROM image of the cartridge
|
// The 32K ROM image of the cartridge
|
||||||
uInt8 myImage[32768];
|
uInt8 myImage[32768];
|
||||||
|
|
|
@ -61,14 +61,13 @@
|
||||||
#include "CartX07.hxx"
|
#include "CartX07.hxx"
|
||||||
#include "MD5.hxx"
|
#include "MD5.hxx"
|
||||||
#include "Props.hxx"
|
#include "Props.hxx"
|
||||||
#include "Settings.hxx"
|
|
||||||
|
|
||||||
#include "CartDetector.hxx"
|
#include "CartDetector.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
const BytePtr& image, uInt32 size, string& md5,
|
const BytePtr& image, uInt32 size, string& md5,
|
||||||
const string& propertiesType, const OSystem& osystem)
|
const string& propertiesType, Settings& settings)
|
||||||
{
|
{
|
||||||
unique_ptr<Cartridge> cartridge;
|
unique_ptr<Cartridge> cartridge;
|
||||||
Bankswitch::Type type = Bankswitch::nameToType(propertiesType),
|
Bankswitch::Type type = Bankswitch::nameToType(propertiesType),
|
||||||
|
@ -86,7 +85,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
|
|
||||||
// See if we should try to auto-detect the cartridge type
|
// See if we should try to auto-detect the cartridge type
|
||||||
// If we ask for extended info, always do an autodetect
|
// If we ask for extended info, always do an autodetect
|
||||||
if(type == Bankswitch::Type::_AUTO || osystem.settings().getBool("rominfo"))
|
if(type == Bankswitch::Type::_AUTO || settings.getBool("rominfo"))
|
||||||
{
|
{
|
||||||
detectedType = autodetectType(image, size);
|
detectedType = autodetectType(image, size);
|
||||||
if(type != Bankswitch::Type::_AUTO && type != detectedType)
|
if(type != Bankswitch::Type::_AUTO && type != detectedType)
|
||||||
|
@ -108,7 +107,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
if(size == 2*2048 || size == 2*4096 || size == 2*8192 || size == 2*16384)
|
if(size == 2*2048 || size == 2*4096 || size == 2*8192 || size == 2*16384)
|
||||||
{
|
{
|
||||||
cartridge =
|
cartridge =
|
||||||
createFromMultiCart(image, size, 2, md5, detectedType, id, osystem);
|
createFromMultiCart(image, size, 2, md5, detectedType, id, settings);
|
||||||
buf << id;
|
buf << id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -121,7 +120,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
if(size == 4*2048 || size == 4*4096 || size == 4*8192)
|
if(size == 4*2048 || size == 4*4096 || size == 4*8192)
|
||||||
{
|
{
|
||||||
cartridge =
|
cartridge =
|
||||||
createFromMultiCart(image, size, 4, md5, detectedType, id, osystem);
|
createFromMultiCart(image, size, 4, md5, detectedType, id, settings);
|
||||||
buf << id;
|
buf << id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -134,7 +133,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
if(size == 8*2048 || size == 8*4096 || size == 8*8192)
|
if(size == 8*2048 || size == 8*4096 || size == 8*8192)
|
||||||
{
|
{
|
||||||
cartridge =
|
cartridge =
|
||||||
createFromMultiCart(image, size, 8, md5, detectedType, id, osystem);
|
createFromMultiCart(image, size, 8, md5, detectedType, id, settings);
|
||||||
buf << id;
|
buf << id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -147,7 +146,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
if(size == 16*2048 || size == 16*4096 || size == 16*8192)
|
if(size == 16*2048 || size == 16*4096 || size == 16*8192)
|
||||||
{
|
{
|
||||||
cartridge =
|
cartridge =
|
||||||
createFromMultiCart(image, size, 16, md5, detectedType, id, osystem);
|
createFromMultiCart(image, size, 16, md5, detectedType, id, settings);
|
||||||
buf << id;
|
buf << id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -160,7 +159,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
if(size == 32*2048 || size == 32*4096)
|
if(size == 32*2048 || size == 32*4096)
|
||||||
{
|
{
|
||||||
cartridge =
|
cartridge =
|
||||||
createFromMultiCart(image, size, 32, md5, detectedType, id, osystem);
|
createFromMultiCart(image, size, 32, md5, detectedType, id, settings);
|
||||||
buf << id;
|
buf << id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -173,7 +172,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
if(size == 64*2048 || size == 64*4096)
|
if(size == 64*2048 || size == 64*4096)
|
||||||
{
|
{
|
||||||
cartridge =
|
cartridge =
|
||||||
createFromMultiCart(image, size, 64, md5, detectedType, id, osystem);
|
createFromMultiCart(image, size, 64, md5, detectedType, id, settings);
|
||||||
buf << id;
|
buf << id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -186,7 +185,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
if(size == 128*2048 || size == 128*4096)
|
if(size == 128*2048 || size == 128*4096)
|
||||||
{
|
{
|
||||||
cartridge =
|
cartridge =
|
||||||
createFromMultiCart(image, size, 128, md5, detectedType, id, osystem);
|
createFromMultiCart(image, size, 128, md5, detectedType, id, settings);
|
||||||
buf << id;
|
buf << id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -195,7 +194,7 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cartridge = createFromImage(image, size, detectedType, md5, osystem);
|
cartridge = createFromImage(image, size, detectedType, md5, settings);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +211,10 @@ unique_ptr<Cartridge> CartDetector::create(const FilesystemNode& file,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
unique_ptr<Cartridge>
|
unique_ptr<Cartridge>
|
||||||
CartDetector::createFromMultiCart(const BytePtr& image, uInt32& size,
|
CartDetector::createFromMultiCart(const BytePtr& image, uInt32& size,
|
||||||
uInt32 numroms, string& md5, Bankswitch::Type type, string& id, const OSystem& osystem)
|
uInt32 numroms, string& md5, Bankswitch::Type type, string& id, Settings& settings)
|
||||||
{
|
{
|
||||||
// Get a piece of the larger image
|
// Get a piece of the larger image
|
||||||
uInt32 i = osystem.settings().getInt("romloadcount");
|
uInt32 i = settings.getInt("romloadcount");
|
||||||
size /= numroms;
|
size /= numroms;
|
||||||
BytePtr slice = make_unique<uInt8[]>(size);
|
BytePtr slice = make_unique<uInt8[]>(size);
|
||||||
memcpy(slice.get(), image.get()+i*size, size);
|
memcpy(slice.get(), image.get()+i*size, size);
|
||||||
|
@ -227,108 +226,108 @@ CartDetector::createFromMultiCart(const BytePtr& image, uInt32& size,
|
||||||
id = buf.str();
|
id = buf.str();
|
||||||
|
|
||||||
// Move to the next game the next time this ROM is loaded
|
// Move to the next game the next time this ROM is loaded
|
||||||
osystem.settings().setValue("romloadcount", (i+1)%numroms);
|
settings.setValue("romloadcount", (i+1)%numroms);
|
||||||
|
|
||||||
if(size <= 2048) type = Bankswitch::Type::_2K;
|
if(size <= 2048) type = Bankswitch::Type::_2K;
|
||||||
else if(size == 4096) type = Bankswitch::Type::_4K;
|
else if(size == 4096) type = Bankswitch::Type::_4K;
|
||||||
else if(size == 8192) type = Bankswitch::Type::_F8;
|
else if(size == 8192) type = Bankswitch::Type::_F8;
|
||||||
else /* default */ type = Bankswitch::Type::_4K;
|
else /* default */ type = Bankswitch::Type::_4K;
|
||||||
|
|
||||||
return createFromImage(slice, size, type, md5, osystem);
|
return createFromImage(slice, size, type, md5, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
unique_ptr<Cartridge>
|
unique_ptr<Cartridge>
|
||||||
CartDetector::createFromImage(const BytePtr& image, uInt32 size, Bankswitch::Type type,
|
CartDetector::createFromImage(const BytePtr& image, uInt32 size, Bankswitch::Type type,
|
||||||
const string& md5, const OSystem& osystem)
|
const string& md5, Settings& settings)
|
||||||
{
|
{
|
||||||
// We should know the cart's type by now so let's create it
|
// We should know the cart's type by now so let's create it
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Bankswitch::Type::_0840:
|
case Bankswitch::Type::_0840:
|
||||||
return make_unique<Cartridge0840>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge0840>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_2K:
|
case Bankswitch::Type::_2K:
|
||||||
return make_unique<Cartridge2K>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge2K>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_3E:
|
case Bankswitch::Type::_3E:
|
||||||
return make_unique<Cartridge3E>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge3E>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_3EP:
|
case Bankswitch::Type::_3EP:
|
||||||
return make_unique<Cartridge3EPlus>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge3EPlus>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_3F:
|
case Bankswitch::Type::_3F:
|
||||||
return make_unique<Cartridge3F>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge3F>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_4A50:
|
case Bankswitch::Type::_4A50:
|
||||||
return make_unique<Cartridge4A50>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge4A50>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_4K:
|
case Bankswitch::Type::_4K:
|
||||||
return make_unique<Cartridge4K>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge4K>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_4KSC:
|
case Bankswitch::Type::_4KSC:
|
||||||
return make_unique<Cartridge4KSC>(image, size, md5, osystem.settings());
|
return make_unique<Cartridge4KSC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_AR:
|
case Bankswitch::Type::_AR:
|
||||||
return make_unique<CartridgeAR>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeAR>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_BF:
|
case Bankswitch::Type::_BF:
|
||||||
return make_unique<CartridgeBF>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeBF>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_BFSC:
|
case Bankswitch::Type::_BFSC:
|
||||||
return make_unique<CartridgeBFSC>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeBFSC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_BUS:
|
case Bankswitch::Type::_BUS:
|
||||||
return make_unique<CartridgeBUS>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeBUS>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_CDF:
|
case Bankswitch::Type::_CDF:
|
||||||
return make_unique<CartridgeCDF>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeCDF>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_CM:
|
case Bankswitch::Type::_CM:
|
||||||
return make_unique<CartridgeCM>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeCM>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_CTY:
|
case Bankswitch::Type::_CTY:
|
||||||
return make_unique<CartridgeCTY>(image, size, md5, osystem);
|
return make_unique<CartridgeCTY>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_CV:
|
case Bankswitch::Type::_CV:
|
||||||
return make_unique<CartridgeCV>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeCV>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_CVP:
|
case Bankswitch::Type::_CVP:
|
||||||
return make_unique<CartridgeCVPlus>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeCVPlus>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_DASH:
|
case Bankswitch::Type::_DASH:
|
||||||
return make_unique<CartridgeDASH>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeDASH>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_DF:
|
case Bankswitch::Type::_DF:
|
||||||
return make_unique<CartridgeDF>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeDF>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_DFSC:
|
case Bankswitch::Type::_DFSC:
|
||||||
return make_unique<CartridgeDFSC>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeDFSC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_DPC:
|
case Bankswitch::Type::_DPC:
|
||||||
return make_unique<CartridgeDPC>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeDPC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_DPCP:
|
case Bankswitch::Type::_DPCP:
|
||||||
return make_unique<CartridgeDPCPlus>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeDPCPlus>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_E0:
|
case Bankswitch::Type::_E0:
|
||||||
return make_unique<CartridgeE0>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeE0>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_E7:
|
case Bankswitch::Type::_E7:
|
||||||
return make_unique<CartridgeE7>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeE7>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_E78K:
|
case Bankswitch::Type::_E78K:
|
||||||
return make_unique<CartridgeE78K>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeE78K>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_EF:
|
case Bankswitch::Type::_EF:
|
||||||
return make_unique<CartridgeEF>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeEF>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_EFSC:
|
case Bankswitch::Type::_EFSC:
|
||||||
return make_unique<CartridgeEFSC>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeEFSC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_F0:
|
case Bankswitch::Type::_F0:
|
||||||
return make_unique<CartridgeF0>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeF0>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_F4:
|
case Bankswitch::Type::_F4:
|
||||||
return make_unique<CartridgeF4>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeF4>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_F4SC:
|
case Bankswitch::Type::_F4SC:
|
||||||
return make_unique<CartridgeF4SC>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeF4SC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_F6:
|
case Bankswitch::Type::_F6:
|
||||||
return make_unique<CartridgeF6>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeF6>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_F6SC:
|
case Bankswitch::Type::_F6SC:
|
||||||
return make_unique<CartridgeF6SC>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeF6SC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_F8:
|
case Bankswitch::Type::_F8:
|
||||||
return make_unique<CartridgeF8>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeF8>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_F8SC:
|
case Bankswitch::Type::_F8SC:
|
||||||
return make_unique<CartridgeF8SC>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeF8SC>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_FA:
|
case Bankswitch::Type::_FA:
|
||||||
return make_unique<CartridgeFA>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeFA>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_FA2:
|
case Bankswitch::Type::_FA2:
|
||||||
return make_unique<CartridgeFA2>(image, size, md5, osystem);
|
return make_unique<CartridgeFA2>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_FE:
|
case Bankswitch::Type::_FE:
|
||||||
return make_unique<CartridgeFE>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeFE>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_MDM:
|
case Bankswitch::Type::_MDM:
|
||||||
return make_unique<CartridgeMDM>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeMDM>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_UA:
|
case Bankswitch::Type::_UA:
|
||||||
return make_unique<CartridgeUA>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeUA>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_SB:
|
case Bankswitch::Type::_SB:
|
||||||
return make_unique<CartridgeSB>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeSB>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_WD:
|
case Bankswitch::Type::_WD:
|
||||||
return make_unique<CartridgeWD>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeWD>(image, size, md5, settings);
|
||||||
case Bankswitch::Type::_X07:
|
case Bankswitch::Type::_X07:
|
||||||
return make_unique<CartridgeX07>(image, size, md5, osystem.settings());
|
return make_unique<CartridgeX07>(image, size, md5, settings);
|
||||||
default:
|
default:
|
||||||
return nullptr; // The remaining types have already been handled
|
return nullptr; // The remaining types have already been handled
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
class Cartridge;
|
class Cartridge;
|
||||||
class Properties;
|
class Properties;
|
||||||
class OSystem;
|
|
||||||
|
|
||||||
#include "Bankswitch.hxx"
|
#include "Bankswitch.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
#include "Settings.hxx"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Auto-detect cart type based on various attributes (file size, signatures,
|
Auto-detect cart type based on various attributes (file size, signatures,
|
||||||
|
@ -42,12 +42,12 @@ class CartDetector
|
||||||
@param size The size of the ROM image
|
@param size The size of the ROM image
|
||||||
@param md5 The md5sum for the given ROM image (can be updated)
|
@param md5 The md5sum for the given ROM image (can be updated)
|
||||||
@param dtype The detected bankswitch type of the ROM image
|
@param dtype The detected bankswitch type of the ROM image
|
||||||
@param system The osystem associated with the system
|
@param settings The settings container
|
||||||
@return Pointer to the new cartridge object allocated on the heap
|
@return Pointer to the new cartridge object allocated on the heap
|
||||||
*/
|
*/
|
||||||
static unique_ptr<Cartridge> create(const FilesystemNode& file,
|
static unique_ptr<Cartridge> create(const FilesystemNode& file,
|
||||||
const BytePtr& image, uInt32 size, string& md5,
|
const BytePtr& image, uInt32 size, string& md5,
|
||||||
const string& dtype, const OSystem& system);
|
const string& dtype, Settings& settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@ -60,14 +60,14 @@ class CartDetector
|
||||||
@param md5 The md5sum for the slice of the ROM image
|
@param md5 The md5sum for the slice of the ROM image
|
||||||
@param type The detected type of the slice of the ROM image
|
@param type The detected type of the slice of the ROM image
|
||||||
@param id The ID for the slice of the ROM image
|
@param id The ID for the slice of the ROM image
|
||||||
@param osystem The osystem associated with the system
|
@param settings The settings container
|
||||||
|
|
||||||
@return Pointer to the new cartridge object allocated on the heap
|
@return Pointer to the new cartridge object allocated on the heap
|
||||||
*/
|
*/
|
||||||
static unique_ptr<Cartridge>
|
static unique_ptr<Cartridge>
|
||||||
createFromMultiCart(const BytePtr& image, uInt32& size,
|
createFromMultiCart(const BytePtr& image, uInt32& size,
|
||||||
uInt32 numroms, string& md5, Bankswitch::Type type, string& id,
|
uInt32 numroms, string& md5, Bankswitch::Type type, string& id,
|
||||||
const OSystem& osystem);
|
Settings& settings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a cartridge from the entire image pointer.
|
Create a cartridge from the entire image pointer.
|
||||||
|
@ -76,13 +76,13 @@ class CartDetector
|
||||||
@param size The size of the ROM image
|
@param size The size of the ROM image
|
||||||
@param type The bankswitch type of the ROM image
|
@param type The bankswitch type of the ROM image
|
||||||
@param md5 The md5sum for the ROM image
|
@param md5 The md5sum for the ROM image
|
||||||
@param osystem The osystem associated with the system
|
@param settings The settings container
|
||||||
|
|
||||||
@return Pointer to the new cartridge object allocated on the heap
|
@return Pointer to the new cartridge object allocated on the heap
|
||||||
*/
|
*/
|
||||||
static unique_ptr<Cartridge>
|
static unique_ptr<Cartridge>
|
||||||
createFromImage(const BytePtr& image, uInt32 size, Bankswitch::Type type,
|
createFromImage(const BytePtr& image, uInt32 size, Bankswitch::Type type,
|
||||||
const string& md5, const OSystem& osystem);
|
const string& md5, Settings& settings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Try to auto-detect the bankswitching type of the cartridge
|
Try to auto-detect the bankswitching type of the cartridge
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
CartridgeFA2::CartridgeFA2(const BytePtr& image, uInt32 size,
|
CartridgeFA2::CartridgeFA2(const BytePtr& image, uInt32 size,
|
||||||
const string& md5, const OSystem& osystem)
|
const string& md5, const Settings& settings)
|
||||||
: Cartridge(osystem.settings(), md5),
|
: Cartridge(settings, md5),
|
||||||
myOSystem(osystem),
|
myOSystem(nullptr),
|
||||||
mySize(28 * 1024),
|
mySize(28 * 1024),
|
||||||
myRamAccessTimeout(0),
|
myRamAccessTimeout(0),
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
|
@ -305,7 +305,7 @@ bool CartridgeFA2::load(Serializer& in)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeFA2::setRomName(const string& name)
|
void CartridgeFA2::setRomName(const string& name)
|
||||||
{
|
{
|
||||||
myFlashFile = myOSystem.nvramDir() + name + "_flash.dat";
|
myFlashFile = myOSystem->nvramDir() + name + "_flash.dat";
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -333,7 +333,7 @@ uInt8 CartridgeFA2::ramReadWrite()
|
||||||
if(myRamAccessTimeout == 0)
|
if(myRamAccessTimeout == 0)
|
||||||
{
|
{
|
||||||
// Remember when the first access was made
|
// Remember when the first access was made
|
||||||
myRamAccessTimeout = myOSystem.getTicks();
|
myRamAccessTimeout = myOSystem->getTicks();
|
||||||
|
|
||||||
// We go ahead and do the access now, and only return when a sufficient
|
// We go ahead and do the access now, and only return when a sufficient
|
||||||
// amount of time has passed
|
// amount of time has passed
|
||||||
|
@ -372,7 +372,7 @@ uInt8 CartridgeFA2::ramReadWrite()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Have we reached the timeout value yet?
|
// Have we reached the timeout value yet?
|
||||||
if(myOSystem.getTicks() >= myRamAccessTimeout)
|
if(myOSystem->getTicks() >= myRamAccessTimeout)
|
||||||
{
|
{
|
||||||
myRamAccessTimeout = 0; // Turn off timer
|
myRamAccessTimeout = 0; // Turn off timer
|
||||||
myRAM[255] = 0; // Successful operation
|
myRAM[255] = 0; // Successful operation
|
||||||
|
|
|
@ -59,7 +59,7 @@ class CartridgeFA2 : public Cartridge
|
||||||
@param osystem A reference to the OSystem currently in use
|
@param osystem A reference to the OSystem currently in use
|
||||||
*/
|
*/
|
||||||
CartridgeFA2(const BytePtr& image, uInt32 size, const string& md5,
|
CartridgeFA2(const BytePtr& image, uInt32 size, const string& md5,
|
||||||
const OSystem& osystem);
|
const Settings& settings);
|
||||||
virtual ~CartridgeFA2() = default;
|
virtual ~CartridgeFA2() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -189,9 +189,13 @@ class CartridgeFA2 : public Cartridge
|
||||||
*/
|
*/
|
||||||
void flash(uInt8 operation);
|
void flash(uInt8 operation);
|
||||||
|
|
||||||
|
bool requiresOSystem() override { return true; }
|
||||||
|
|
||||||
|
void setOSystem(OSystem* osystem) override { myOSystem = osystem; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// OSsytem currently in use
|
// OSsytem currently in use
|
||||||
const OSystem& myOSystem;
|
const OSystem* myOSystem;
|
||||||
|
|
||||||
// The 24K/28K ROM image of the cartridge
|
// The 24K/28K ROM image of the cartridge
|
||||||
uInt8 myImage[28 * 1024];
|
uInt8 myImage[28 * 1024];
|
||||||
|
|
|
@ -497,7 +497,9 @@ unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile, string&
|
||||||
string cartmd5 = md5;
|
string cartmd5 = md5;
|
||||||
const string& type = props.get(Cartridge_Type);
|
const string& type = props.get(Cartridge_Type);
|
||||||
unique_ptr<Cartridge> cart =
|
unique_ptr<Cartridge> cart =
|
||||||
CartDetector::create(romfile, image, size, cartmd5, type, *this);
|
CartDetector::create(romfile, image, size, cartmd5, type, *mySettings);
|
||||||
|
|
||||||
|
if (cart->requiresOSystem()) cart->setOSystem(this);
|
||||||
|
|
||||||
// It's possible that the cart created was from a piece of the image,
|
// It's possible that the cart created was from a piece of the image,
|
||||||
// and that the md5 (and hence the cart) has changed
|
// and that the md5 (and hence the cart) has changed
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "ProfilingRunner.hxx"
|
#include "ProfilingRunner.hxx"
|
||||||
|
#include "FSNode.hxx"
|
||||||
|
#include "CartDetector.hxx"
|
||||||
|
#include "Cart.hxx"
|
||||||
|
#include "MD5.hxx"
|
||||||
|
|
||||||
static constexpr uInt32 RUNTIME_DEFAULT = 60;
|
static constexpr uInt32 RUNTIME_DEFAULT = 60;
|
||||||
|
|
||||||
|
@ -42,10 +46,46 @@ ProfilingRunner::ProfilingRunner(int argc, char* argv[])
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool ProfilingRunner::run()
|
bool ProfilingRunner::run()
|
||||||
{
|
{
|
||||||
cout << "Profiling Stela..." << endl << endl;
|
cout << "Profiling Stella..." << endl;
|
||||||
|
|
||||||
for (ProfilingRun& run : profilingRuns) {
|
for (ProfilingRun& run : profilingRuns) {
|
||||||
cout << "running " << run.romFile << " for " << run.runtime << " seconds..." << endl;
|
cout << endl << "running " << run.romFile << " for " << run.runtime << " seconds..." << endl;
|
||||||
|
|
||||||
|
if (!runOne(run)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool ProfilingRunner::runOne(const ProfilingRun run)
|
||||||
|
{
|
||||||
|
FilesystemNode imageFile(run.romFile);
|
||||||
|
|
||||||
|
if (!imageFile.isFile()) {
|
||||||
|
cout << "ERROR: " << run.romFile << " is not a ROM image" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BytePtr image;
|
||||||
|
uInt32 size = imageFile.read(image);
|
||||||
|
if (size == 0) {
|
||||||
|
cout << "ERROR: unable to read " << run.romFile << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string md5 = MD5::hash(image, size);
|
||||||
|
string type = "";
|
||||||
|
unique_ptr<Cartridge> cartridge = CartDetector::create(imageFile, image, size, md5, type, mySettings);
|
||||||
|
|
||||||
|
if (!cartridge) {
|
||||||
|
cout << "ERROR: unable to determine cartridge type" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cartridge->requiresOSystem()) {
|
||||||
|
cout << "ERROR: profiling not supported for " << cartridge->name() << " ROM images" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
#ifndef PROFILING_RUNNER
|
#ifndef PROFILING_RUNNER
|
||||||
#define PROFILING_RUNNER
|
#define PROFILING_RUNNER
|
||||||
|
|
||||||
#include <bspf.hxx>
|
#include "bspf.hxx"
|
||||||
|
#include "Settings.hxx"
|
||||||
|
|
||||||
class ProfilingRunner {
|
class ProfilingRunner {
|
||||||
public:
|
public:
|
||||||
|
@ -34,9 +35,15 @@ class ProfilingRunner {
|
||||||
uInt32 runtime;
|
uInt32 runtime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool runOne(const ProfilingRun run);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
vector<ProfilingRun> profilingRuns;
|
vector<ProfilingRun> profilingRuns;
|
||||||
|
|
||||||
|
Settings mySettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROFILING_RUNNER
|
#endif // PROFILING_RUNNER
|
||||||
|
|
Loading…
Reference in New Issue