Commit 56669c54 authored by Stephen Anthony's avatar Stephen Anthony
Browse files

Convert Cart classes to receive 'md5' parameter.

That's an *awful* lot of work to simply pass info to each class :)
parent dea62573
......@@ -26,16 +26,13 @@
#include "Cart.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge::Cartridge(const Settings& settings)
Cartridge::Cartridge(const Settings& settings, const string& md5)
: mySettings(settings),
myBankChanged(true),
myCodeAccessBase(nullptr),
myStartBank(0),
myBankLocked(false)
{
// TODO - get md5 from parameter
string md5 = "d30b89fcc488b7ac2fcbd96c06cb932e";
auto to_uInt32 = [](const string& s, uInt32 pos) {
return uInt32(std::stoul(s.substr(pos, 8), nullptr, 16));
};
......
......@@ -47,8 +47,9 @@ class Cartridge : public Device
Create a new cartridge
@param settings A reference to the various settings (read-only)
@param md5 The md5sum of the cart image
*/
Cartridge(const Settings& settings);
Cartridge(const Settings& settings, const string& md5);
virtual ~Cartridge() = default;
/**
......
......@@ -20,8 +20,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge0840::Cartridge0840(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
myBankOffset(0)
{
// Copy the ROM image into my buffer
......
......@@ -42,9 +42,11 @@ class Cartridge0840 : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge0840(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge0840(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge0840() = default;
public:
......
......@@ -20,8 +20,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge2K::Cartridge2K(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings)
const string& md5, const Settings& settings)
: Cartridge(settings, md5)
{
// Size can be a maximum of 2K
if(size > 2048) size = 2048;
......
......@@ -45,9 +45,11 @@ class Cartridge2K : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image (<= 2048 bytes)
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge2K(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge2K(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge2K() = default;
public:
......
......@@ -21,8 +21,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge3E::Cartridge3E(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
mySize(size),
myCurrentBank(0)
{
......
......@@ -71,9 +71,11 @@ class Cartridge3E : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge3E(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge3E(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge3E() = default;
public:
......
......@@ -21,8 +21,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge3EPlus::Cartridge3EPlus(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
mySize(size)
{
// Allocate array for the ROM image
......
......@@ -51,9 +51,11 @@ class Cartridge3EPlus: public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge3EPlus(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge3EPlus(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge3EPlus() = default;
public:
......
......@@ -21,8 +21,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge3F::Cartridge3F(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
mySize(size),
myCurrentBank(0)
{
......
......@@ -48,9 +48,11 @@ class Cartridge3F : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge3F(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge3F(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge3F() = default;
public:
......
......@@ -22,8 +22,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4A50::Cartridge4A50(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
mySize(size),
mySliceLow(0),
mySliceMiddle(0),
......
......@@ -62,9 +62,11 @@ class Cartridge4A50 : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge4A50(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge4A50(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge4A50() = default;
public:
......
......@@ -20,8 +20,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4K::Cartridge4K(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings)
const string& md5, const Settings& settings)
: Cartridge(settings, md5)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(4096u, size));
......
......@@ -42,9 +42,11 @@ class Cartridge4K : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge4K(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge4K(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge4K() = default;
public:
......
......@@ -20,8 +20,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge4KSC::Cartridge4KSC(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings)
const string& md5, const Settings& settings)
: Cartridge(settings, md5)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(4096u, size));
......
......@@ -41,9 +41,11 @@ class Cartridge4KSC : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
Cartridge4KSC(const BytePtr& image, uInt32 size, const Settings& settings);
Cartridge4KSC(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~Cartridge4KSC() = default;
public:
......
......@@ -21,8 +21,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeAR::CartridgeAR(const BytePtr& image, uInt32 size,
const Settings& settings)
: Cartridge(settings),
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
mySize(std::max(size, 8448u)),
myWriteEnabled(false),
myPower(true),
......
......@@ -49,9 +49,11 @@ class CartridgeAR : public Cartridge
@param image Pointer to the ROM image
@param size The size of the ROM image
@param md5 The md5sum of the ROM image
@param settings A reference to the various settings (read-only)
*/
CartridgeAR(const BytePtr& image, uInt32 size, const Settings& settings);
CartridgeAR(const BytePtr& image, uInt32 size, const string& md5,
const Settings& settings);
virtual ~CartridgeAR() = default;
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment