mirror of https://github.com/stella-emu/stella.git
Fixed gcc warnings wrt getBank virtual methods.
Converted many C-style arrays to C++ std::array. In the process, cleaned up a lot of magic constants. Replaced most C-style memset/memcpy operations with C++ equivalents: std::fill/std::copy. std::copy in particular fixes a few potential bugs, since it operates on the datatype size, and not just on raw bytes.
This commit is contained in:
parent
a1fa3a57ba
commit
354d5aa35a
|
@ -23,7 +23,7 @@ ConvolutionBuffer::ConvolutionBuffer(uInt32 size)
|
||||||
mySize(size)
|
mySize(size)
|
||||||
{
|
{
|
||||||
myData = make_unique<float[]>(mySize);
|
myData = make_unique<float[]>(mySize);
|
||||||
memset(myData.get(), 0, mySize * sizeof(float));
|
std::fill_n(myData.get(), mySize, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -141,7 +141,7 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myCurrentFragment) {
|
if (!myCurrentFragment) {
|
||||||
memset(fragment, 0, sizeof(float) * length);
|
std::fill_n(fragment, length, 0.f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!myCurrentFragment) {
|
if (!myCurrentFragment) {
|
||||||
memset(fragment, 0, sizeof(float) * length);
|
std::fill_n(fragment, length, 0.f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,6 @@ using std::make_shared;
|
||||||
using std::array;
|
using std::array;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
using std::memcpy;
|
|
||||||
|
|
||||||
// Common array types
|
// Common array types
|
||||||
using IntArray = std::vector<Int32>;
|
using IntArray = std::vector<Int32>;
|
||||||
|
@ -85,6 +84,12 @@ using ShortArray = std::vector<uInt16>;
|
||||||
using StringList = std::vector<std::string>;
|
using StringList = std::vector<std::string>;
|
||||||
using ByteBuffer = std::unique_ptr<uInt8[]>;
|
using ByteBuffer = std::unique_ptr<uInt8[]>;
|
||||||
|
|
||||||
|
// We use KB a lot; let's make a literal for it
|
||||||
|
constexpr size_t operator "" _KB(unsigned long long size)
|
||||||
|
{
|
||||||
|
return static_cast<size_t>(size * 1024);
|
||||||
|
}
|
||||||
|
|
||||||
static const string EmptyString("");
|
static const string EmptyString("");
|
||||||
|
|
||||||
// This is defined by some systems, but Stella has other uses for it
|
// This is defined by some systems, but Stella has other uses for it
|
||||||
|
|
|
@ -507,9 +507,9 @@ bool CartDebug::addDirective(CartDebug::DisasmType type,
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
int CartDebug::getBank(uInt16 addr)
|
int CartDebug::getBank(uInt16 address)
|
||||||
{
|
{
|
||||||
return myConsole.cartridge().getBank(addr);
|
return myConsole.cartridge().getBank(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -257,6 +257,8 @@ class CartDebug : public DebuggerSystem
|
||||||
using LabelToAddr = std::map<string, uInt16,
|
using LabelToAddr = std::map<string, uInt16,
|
||||||
std::function<bool(const string&, const string&)>>;
|
std::function<bool(const string&, const string&)>>;
|
||||||
|
|
||||||
|
using AddrTypeArray = std::array<uInt8, 0x1000>;
|
||||||
|
|
||||||
struct DirectiveTag {
|
struct DirectiveTag {
|
||||||
DisasmType type;
|
DisasmType type;
|
||||||
uInt16 start;
|
uInt16 start;
|
||||||
|
@ -277,7 +279,7 @@ class CartDebug : public DebuggerSystem
|
||||||
};
|
};
|
||||||
|
|
||||||
// Address type information determined by Distella
|
// Address type information determined by Distella
|
||||||
uInt8 myDisLabels[0x1000], myDisDirectives[0x1000];
|
AddrTypeArray myDisLabels, myDisDirectives;
|
||||||
|
|
||||||
// Information on equates used in the disassembly
|
// Information on equates used in the disassembly
|
||||||
struct ReservedEquates {
|
struct ReservedEquates {
|
||||||
|
|
|
@ -23,7 +23,8 @@ using Common::Base;
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
|
DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
|
||||||
CartDebug::BankInfo& info, const DiStella::Settings& s,
|
CartDebug::BankInfo& info, const DiStella::Settings& s,
|
||||||
uInt8* labels, uInt8* directives,
|
CartDebug::AddrTypeArray& labels,
|
||||||
|
CartDebug::AddrTypeArray& directives,
|
||||||
CartDebug::ReservedEquates& reserved)
|
CartDebug::ReservedEquates& reserved)
|
||||||
: myDbg(dbg),
|
: myDbg(dbg),
|
||||||
myList(list),
|
myList(list),
|
||||||
|
@ -57,8 +58,8 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
|
||||||
}
|
}
|
||||||
myAppData.length = info.size;
|
myAppData.length = info.size;
|
||||||
|
|
||||||
memset(myLabels, 0, 0x1000);
|
myLabels.fill(0);
|
||||||
memset(myDirectives, 0, 0x1000);
|
myDirectives.fill(0);
|
||||||
|
|
||||||
// Process any directives first, as they override automatic code determination
|
// Process any directives first, as they override automatic code determination
|
||||||
processDirectives(info.directiveList);
|
processDirectives(info.directiveList);
|
||||||
|
|
|
@ -67,7 +67,8 @@ class DiStella
|
||||||
*/
|
*/
|
||||||
DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
|
DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
|
||||||
CartDebug::BankInfo& info, const DiStella::Settings& settings,
|
CartDebug::BankInfo& info, const DiStella::Settings& settings,
|
||||||
uInt8* labels, uInt8* directives,
|
CartDebug::AddrTypeArray& labels,
|
||||||
|
CartDebug::AddrTypeArray& directives,
|
||||||
CartDebug::ReservedEquates& reserved);
|
CartDebug::ReservedEquates& reserved);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -136,7 +137,8 @@ class DiStella
|
||||||
the directives take priority
|
the directives take priority
|
||||||
The address mark type is defined in CartDebug.hxx
|
The address mark type is defined in CartDebug.hxx
|
||||||
*/
|
*/
|
||||||
uInt8 *myLabels, *myDirectives;
|
CartDebug::AddrTypeArray& myLabels;
|
||||||
|
CartDebug::AddrTypeArray& myDirectives;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Enumeration of the 6502 addressing modes
|
Enumeration of the 6502 addressing modes
|
||||||
|
|
|
@ -22,38 +22,38 @@
|
||||||
|
|
||||||
class TrapArray
|
class TrapArray
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TrapArray() : myInitialized(false) {}
|
TrapArray() : myInitialized(false) {}
|
||||||
|
|
||||||
bool isSet(const uInt16 address) const { return myCount[address]; }
|
bool isSet(const uInt16 address) const { return myCount[address]; }
|
||||||
bool isClear(const uInt16 address) const { return myCount[address] == 0; }
|
bool isClear(const uInt16 address) const { return myCount[address] == 0; }
|
||||||
|
|
||||||
void add(const uInt16 address) { myCount[address]++; }
|
void add(const uInt16 address) { myCount[address]++; }
|
||||||
void remove(const uInt16 address) { myCount[address]--; }
|
void remove(const uInt16 address) { myCount[address]--; }
|
||||||
//void toggle(uInt16 address) { myCount[address] ? remove(address) : add(address); } // TODO condition
|
// void toggle(uInt16 address) { myCount[address] ? remove(address) : add(address); } // TODO condition
|
||||||
|
|
||||||
void initialize() {
|
void initialize() {
|
||||||
if(!myInitialized)
|
if(!myInitialized)
|
||||||
memset(myCount, 0, sizeof(myCount));
|
myCount.fill(0);
|
||||||
myInitialized = true;
|
myInitialized = true;
|
||||||
}
|
}
|
||||||
void clearAll() { myInitialized = false; memset(myCount, 0, sizeof(myCount)); }
|
void clearAll() { myInitialized = false; myCount.fill(0); }
|
||||||
|
|
||||||
bool isInitialized() const { return myInitialized; }
|
bool isInitialized() const { return myInitialized; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The actual counts
|
// The actual counts
|
||||||
uInt8 myCount[0x10000];
|
std::array<uInt8, 0x10000> myCount;
|
||||||
|
|
||||||
// Indicates whether we should treat this array as initialized
|
// Indicates whether we should treat this array as initialized
|
||||||
bool myInitialized;
|
bool myInitialized;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
TrapArray(const TrapArray&) = delete;
|
TrapArray(const TrapArray&) = delete;
|
||||||
TrapArray(TrapArray&&) = delete;
|
TrapArray(TrapArray&&) = delete;
|
||||||
TrapArray& operator=(const TrapArray&) = delete;
|
TrapArray& operator=(const TrapArray&) = delete;
|
||||||
TrapArray& operator=(TrapArray&&) = delete;
|
TrapArray& operator=(TrapArray&&) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -123,7 +123,7 @@ void Cartridge::createCodeAccessBase(uInt32 size)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
myCodeAccessBase = make_unique<uInt8[]>(size);
|
myCodeAccessBase = make_unique<uInt8[]>(size);
|
||||||
memset(myCodeAccessBase.get(), CartDebug::ROW, size);
|
std::fill_n(myCodeAccessBase.get(), size, CartDebug::ROW);
|
||||||
#else
|
#else
|
||||||
myCodeAccessBase = nullptr;
|
myCodeAccessBase = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
@ -136,7 +136,7 @@ void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const
|
||||||
for(uInt32 i = 0; i < size; ++i)
|
for(uInt32 i = 0; i < size; ++i)
|
||||||
arr[i] = mySystem->randGenerator().next();
|
arr[i] = mySystem->randGenerator().next();
|
||||||
else
|
else
|
||||||
memset(arr, val, size);
|
std::fill_n(arr, size, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -153,17 +153,14 @@ class Cartridge : public Device
|
||||||
virtual bool bank(uInt16) { return false; }
|
virtual bool bank(uInt16) { return false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank. Carts which have only one bank (either real
|
Get the current bank for the provided address. Carts which have only
|
||||||
or virtual) always report that bank as zero.
|
one bank (either real or virtual) always report that bank as zero.
|
||||||
*/
|
|
||||||
virtual uInt16 getBank() const { return 0; }
|
|
||||||
|
|
||||||
/**
|
@param address Query the bank used for this specific address
|
||||||
Get the current bank for the provided address.
|
Derived classes are free to ignore this; it only
|
||||||
|
makes sense in some situations.
|
||||||
@param addr The address to get the bank for
|
|
||||||
*/
|
*/
|
||||||
virtual uInt16 getBank(uInt16 addr) const { return getBank(); }
|
virtual uInt16 getBank(uInt16 address = 0) const { return 0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of 'banks' supported by the cartridge. Note that
|
Query the number of 'banks' supported by the cartridge. Note that
|
||||||
|
|
|
@ -25,8 +25,8 @@ Cartridge0840::Cartridge0840(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(8192u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -145,7 +145,7 @@ bool Cartridge0840::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 Cartridge0840::getBank() const
|
uInt16 Cartridge0840::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,8 @@ bool Cartridge0840::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* Cartridge0840::getImage(uInt32& size) const
|
const uInt8* Cartridge0840::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 8192;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -72,8 +72,10 @@ class Cartridge0840 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -151,13 +153,13 @@ class Cartridge0840 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 8K ROM image of the cartridge
|
// The 8K ROM image of the cartridge
|
||||||
uInt8 myImage[8192];
|
std::array<uInt8, 8_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
||||||
// Previous Device's page access
|
// Previous Device's page access
|
||||||
System::PageAccess myHotSpotPageAccess[8];
|
std::array<System::PageAccess, 8> myHotSpotPageAccess;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -24,7 +24,7 @@ Cartridge2K::Cartridge2K(const ByteBuffer& image, uInt32 size,
|
||||||
: Cartridge(settings, md5)
|
: Cartridge(settings, md5)
|
||||||
{
|
{
|
||||||
// Size can be a maximum of 2K
|
// Size can be a maximum of 2K
|
||||||
if(size > 2048) size = 2048;
|
if(size > 2_KB) size = 2_KB;
|
||||||
|
|
||||||
// Set image size to closest power-of-two for the given size
|
// Set image size to closest power-of-two for the given size
|
||||||
mySize = 1;
|
mySize = 1;
|
||||||
|
@ -36,10 +36,10 @@ Cartridge2K::Cartridge2K(const ByteBuffer& image, uInt32 size,
|
||||||
|
|
||||||
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
|
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
memset(myImage.get(), 0x02, mySize);
|
std::fill_n(myImage.get(), mySize, 0x02);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), size);
|
std::copy_n(image.get(), size, myImage.get());
|
||||||
createCodeAccessBase(mySize);
|
createCodeAccessBase(mySize);
|
||||||
|
|
||||||
// Set mask for accessing the image buffer
|
// Set mask for accessing the image buffer
|
||||||
|
|
|
@ -30,14 +30,14 @@ Cartridge3E::Cartridge3E(const ByteBuffer& image, uInt32 size,
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.get());
|
||||||
createCodeAccessBase(mySize + 32768);
|
createCodeAccessBase(mySize + myRAM.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Cartridge3E::reset()
|
void Cartridge3E::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 32768);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(0);
|
initializeStartBank(0);
|
||||||
|
|
||||||
// We'll map the startup bank into the first segment upon reset
|
// We'll map the startup bank into the first segment upon reset
|
||||||
|
@ -198,9 +198,9 @@ bool Cartridge3E::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 Cartridge3E::getBank(uInt16 addr) const
|
uInt16 Cartridge3E::getBank(uInt16 address) const
|
||||||
{
|
{
|
||||||
if (addr & 0x800)
|
if (address & 0x800)
|
||||||
return 255; // 256 - 1 // 2K slices, fixed bank
|
return 255; // 256 - 1 // 2K slices, fixed bank
|
||||||
else
|
else
|
||||||
return myCurrentBank;
|
return myCurrentBank;
|
||||||
|
@ -248,7 +248,7 @@ bool Cartridge3E::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myCurrentBank);
|
out.putShort(myCurrentBank);
|
||||||
out.putByteArray(myRAM, 32768);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -265,7 +265,7 @@ bool Cartridge3E::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myCurrentBank = in.getShort();
|
myCurrentBank = in.getShort();
|
||||||
in.getByteArray(myRAM, 32768);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,8 +101,10 @@ class Cartridge3E : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank(uInt16 addr) const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -183,7 +185,7 @@ class Cartridge3E : public Cartridge
|
||||||
ByteBuffer myImage;
|
ByteBuffer myImage;
|
||||||
|
|
||||||
// RAM contents. For now every ROM gets all 32K of potential RAM
|
// RAM contents. For now every ROM gets all 32K of potential RAM
|
||||||
uInt8 myRAM[32 * 1024];
|
std::array<uInt8, 32_KB> myRAM;
|
||||||
|
|
||||||
// Size of the ROM image
|
// Size of the ROM image
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
|
@ -29,14 +29,14 @@ Cartridge3EPlus::Cartridge3EPlus(const ByteBuffer& image, uInt32 size,
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.get());
|
||||||
createCodeAccessBase(mySize + RAM_TOTAL_SIZE);
|
createCodeAccessBase(mySize + myRAM.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Cartridge3EPlus::reset()
|
void Cartridge3EPlus::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, RAM_TOTAL_SIZE);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
// Remember startup bank (0 per spec, rather than last per 3E scheme).
|
// Remember startup bank (0 per spec, rather than last per 3E scheme).
|
||||||
// Set this to go to 3rd 1K Bank.
|
// Set this to go to 3rd 1K Bank.
|
||||||
|
@ -44,8 +44,8 @@ void Cartridge3EPlus::reset()
|
||||||
|
|
||||||
// Initialise bank values for all ROM/RAM access
|
// Initialise bank values for all ROM/RAM access
|
||||||
// This is used to reverse-lookup from address to bank location
|
// This is used to reverse-lookup from address to bank location
|
||||||
for(uInt32 b = 0; b < 8; ++b)
|
for(auto& b: bankInUse)
|
||||||
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
|
b = BANK_UNDEFINED; // bank is undefined and inaccessible!
|
||||||
|
|
||||||
initializeBankState();
|
initializeBankState();
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ void Cartridge3EPlus::install(System& system)
|
||||||
|
|
||||||
// Initialise bank values for all ROM/RAM access
|
// Initialise bank values for all ROM/RAM access
|
||||||
// This is used to reverse-lookup from address to bank location
|
// This is used to reverse-lookup from address to bank location
|
||||||
for(uInt32 b = 0; b < 8; ++b)
|
for(auto& b: bankInUse)
|
||||||
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
|
b = BANK_UNDEFINED; // bank is undefined and inaccessible!
|
||||||
|
|
||||||
initializeBankState();
|
initializeBankState();
|
||||||
|
|
||||||
|
@ -79,9 +79,9 @@ void Cartridge3EPlus::install(System& system)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 Cartridge3EPlus::getBank(uInt16 addr) const
|
uInt16 Cartridge3EPlus::getBank(uInt16 address) const
|
||||||
{
|
{
|
||||||
return bankInUse[(addr & 0xFFF) >> 10]; // 1K slices
|
return bankInUse[(address & 0xFFF) >> 10]; // 1K slices
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -90,7 +90,6 @@ uInt16 Cartridge3EPlus::bankCount() const
|
||||||
return mySize >> 10; // 1K slices
|
return mySize >> 10; // 1K slices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt8 Cartridge3EPlus::peek(uInt16 address)
|
uInt8 Cartridge3EPlus::peek(uInt16 address)
|
||||||
{
|
{
|
||||||
|
@ -319,8 +318,8 @@ bool Cartridge3EPlus::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShortArray(bankInUse, 8);
|
out.putShortArray(bankInUse.data(), bankInUse.size());
|
||||||
out.putByteArray(myRAM, RAM_TOTAL_SIZE);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -335,8 +334,8 @@ bool Cartridge3EPlus::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getShortArray(bankInUse, 8);
|
in.getShortArray(bankInUse.data(), bankInUse.size());
|
||||||
in.getByteArray(myRAM, RAM_TOTAL_SIZE);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,8 +72,10 @@ class Cartridge3EPlus: public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank(uInt16 addr) const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -164,7 +166,7 @@ class Cartridge3EPlus: public Cartridge
|
||||||
// are consecutive. This allows us to determine on a read/write exactly where the data is.
|
// are consecutive. This allows us to determine on a read/write exactly where the data is.
|
||||||
|
|
||||||
static constexpr uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible
|
static constexpr uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible
|
||||||
uInt16 bankInUse[8]; // bank being used for ROM/RAM (eight 512 byte areas)
|
std::array<uInt16, 8> bankInUse; // bank being used for ROM/RAM (eight 512 byte areas)
|
||||||
|
|
||||||
static constexpr uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching
|
static constexpr uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching
|
||||||
static constexpr uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching
|
static constexpr uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching
|
||||||
|
@ -188,9 +190,9 @@ class Cartridge3EPlus: public Cartridge
|
||||||
|
|
||||||
static constexpr uInt16 RAM_WRITE_OFFSET = 0x200;
|
static constexpr uInt16 RAM_WRITE_OFFSET = 0x200;
|
||||||
|
|
||||||
ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge
|
ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge
|
||||||
uInt32 mySize; // Size of the ROM image
|
uInt32 mySize; // Size of the ROM image
|
||||||
uInt8 myRAM[RAM_TOTAL_SIZE];
|
std::array<uInt8, RAM_TOTAL_SIZE> myRAM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -30,7 +30,7 @@ Cartridge3F::Cartridge3F(const ByteBuffer& image, uInt32 size,
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.get());
|
||||||
createCodeAccessBase(mySize);
|
createCodeAccessBase(mySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,9 +125,9 @@ bool Cartridge3F::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 Cartridge3F::getBank(uInt16 addr) const
|
uInt16 Cartridge3F::getBank(uInt16 address) const
|
||||||
{
|
{
|
||||||
if (addr & 0x800)
|
if (address & 0x800)
|
||||||
return (mySize >> 11) - 1; // 2K slices, fixed bank
|
return (mySize >> 11) - 1; // 2K slices, fixed bank
|
||||||
else
|
else
|
||||||
return myCurrentBank;
|
return myCurrentBank;
|
||||||
|
|
|
@ -78,8 +78,10 @@ class Cartridge3F : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank(uInt16 addr) const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
|
|
@ -36,11 +36,11 @@ Cartridge4A50::Cartridge4A50(const ByteBuffer& image, uInt32 size,
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
// Supported file sizes are 32/64/128K, which are duplicated if necessary
|
// Supported file sizes are 32/64/128K, which are duplicated if necessary
|
||||||
if(size < 65536) size = 32768;
|
if(size < 64_KB) size = 32_KB;
|
||||||
else if(size < 131072) size = 65536;
|
else if(size < 128_KB) size = 64_KB;
|
||||||
else size = 131072;
|
else size = 128_KB;
|
||||||
for(uInt32 slice = 0; slice < 131072 / size; ++slice)
|
for(uInt32 slice = 0; slice < 128_KB / size; ++slice)
|
||||||
memcpy(myImage + (slice*size), image.get(), size);
|
std::copy_n(image.get(), size, myImage.begin() + (slice*size));
|
||||||
|
|
||||||
// We use System::PageAccess.codeAccessBase, but don't allow its use
|
// We use System::PageAccess.codeAccessBase, but don't allow its use
|
||||||
// through a pointer, since the address space of 4A50 carts can change
|
// through a pointer, since the address space of 4A50 carts can change
|
||||||
|
@ -49,13 +49,13 @@ Cartridge4A50::Cartridge4A50(const ByteBuffer& image, uInt32 size,
|
||||||
//
|
//
|
||||||
// Instead, access will be through the getAccessFlags and setAccessFlags
|
// Instead, access will be through the getAccessFlags and setAccessFlags
|
||||||
// methods below
|
// methods below
|
||||||
createCodeAccessBase(131072 + 32768);
|
createCodeAccessBase(myImage.size() + myRAM.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Cartridge4A50::reset()
|
void Cartridge4A50::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 32768);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
mySliceLow = mySliceMiddle = mySliceHigh = 0;
|
mySliceLow = mySliceMiddle = mySliceHigh = 0;
|
||||||
myIsRomLow = myIsRomMiddle = myIsRomHigh = true;
|
myIsRomLow = myIsRomMiddle = myIsRomHigh = true;
|
||||||
|
@ -359,7 +359,7 @@ bool Cartridge4A50::patch(uInt16 address, uInt8 value)
|
||||||
const uInt8* Cartridge4A50::getImage(uInt32& size) const
|
const uInt8* Cartridge4A50::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = mySize;
|
size = mySize;
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -368,7 +368,7 @@ bool Cartridge4A50::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// The 32K bytes of RAM
|
// The 32K bytes of RAM
|
||||||
out.putByteArray(myRAM, 32768);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
// Index pointers
|
// Index pointers
|
||||||
out.putShort(mySliceLow);
|
out.putShort(mySliceLow);
|
||||||
|
@ -398,7 +398,7 @@ bool Cartridge4A50::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getByteArray(myRAM, 32768);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
// Index pointers
|
// Index pointers
|
||||||
mySliceLow = in.getShort();
|
mySliceLow = in.getShort();
|
||||||
|
|
|
@ -219,10 +219,10 @@ class Cartridge4A50 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 128K ROM image of the cartridge
|
// The 128K ROM image of the cartridge
|
||||||
uInt8 myImage[131072];
|
std::array<uInt8, 128_KB> myImage;
|
||||||
|
|
||||||
// The 32K of RAM on the cartridge
|
// The 32K of RAM on the cartridge
|
||||||
uInt8 myRAM[32768];
|
std::array<uInt8, 32_KB> myRAM;
|
||||||
|
|
||||||
// (Actual) Size of the ROM image
|
// (Actual) Size of the ROM image
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
|
@ -24,8 +24,8 @@ Cartridge4K::Cartridge4K(const ByteBuffer& image, uInt32 size,
|
||||||
: Cartridge(settings, md5)
|
: Cartridge(settings, md5)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(4096u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(4096);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -61,8 +61,8 @@ bool Cartridge4K::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* Cartridge4K::getImage(uInt32& size) const
|
const uInt8* Cartridge4K::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 4096;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -124,7 +124,7 @@ class Cartridge4K : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 4K ROM image for the cartridge
|
// The 4K ROM image for the cartridge
|
||||||
uInt8 myImage[4096];
|
std::array<uInt8, 4_KB> myImage;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -24,14 +24,14 @@ Cartridge4KSC::Cartridge4KSC(const ByteBuffer& image, uInt32 size,
|
||||||
: Cartridge(settings, md5)
|
: Cartridge(settings, md5)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(4096u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(4096);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Cartridge4KSC::reset()
|
void Cartridge4KSC::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 128);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
myBankChanged = true;
|
myBankChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -120,8 +120,8 @@ bool Cartridge4KSC::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* Cartridge4KSC::getImage(uInt32& size) const
|
const uInt8* Cartridge4KSC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 4096;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -129,7 +129,7 @@ bool Cartridge4KSC::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ bool Cartridge4KSC::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,10 +133,10 @@ class Cartridge4KSC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 4K ROM image of the cartridge
|
// The 4K ROM image of the cartridge
|
||||||
uInt8 myImage[4096];
|
std::array<uInt8, 4_KB> myImage;
|
||||||
|
|
||||||
// The 128 bytes of RAM
|
// The 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -34,11 +34,11 @@ CartridgeAR::CartridgeAR(const ByteBuffer& image, uInt32 size,
|
||||||
// Create a load image buffer and copy the given image
|
// Create a load image buffer and copy the given image
|
||||||
myLoadImages = make_unique<uInt8[]>(mySize);
|
myLoadImages = make_unique<uInt8[]>(mySize);
|
||||||
myNumberOfLoadImages = mySize / 8448;
|
myNumberOfLoadImages = mySize / 8448;
|
||||||
memcpy(myLoadImages.get(), image.get(), size);
|
std::copy_n(image.get(), size, myLoadImages.get());
|
||||||
|
|
||||||
// Add header if image doesn't include it
|
// Add header if image doesn't include it
|
||||||
if(size < 8448)
|
if(size < 8448)
|
||||||
memcpy(myLoadImages.get()+8192, ourDefaultHeader, 256);
|
std::copy_n(ourDefaultHeader.data(), ourDefaultHeader.size(), myLoadImages.get()+myImage.size());
|
||||||
|
|
||||||
// We use System::PageAccess.codeAccessBase, but don't allow its use
|
// We use System::PageAccess.codeAccessBase, but don't allow its use
|
||||||
// through a pointer, since the AR scheme doesn't support bankswitching
|
// through a pointer, since the AR scheme doesn't support bankswitching
|
||||||
|
@ -54,9 +54,9 @@ void CartridgeAR::reset()
|
||||||
{
|
{
|
||||||
// Initialize RAM
|
// Initialize RAM
|
||||||
#if 0 // TODO - figure out actual behaviour of the real cart
|
#if 0 // TODO - figure out actual behaviour of the real cart
|
||||||
initializeRAM(myImage, 6*1024);
|
initializeRAM(myImage.data(), myImage.size());
|
||||||
#else
|
#else
|
||||||
memset(myImage, 0, 6 * 1024);
|
myImage.fill(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize SC BIOS ROM
|
// Initialize SC BIOS ROM
|
||||||
|
@ -316,10 +316,10 @@ void CartridgeAR::initializeROM()
|
||||||
ourDummyROMCode[281] = mySystem->randGenerator().next();
|
ourDummyROMCode[281] = mySystem->randGenerator().next();
|
||||||
|
|
||||||
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
|
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
|
||||||
memset(myImage + (3<<11), 0x02, 2048);
|
std::fill_n(myImage.begin() + (3<<11), 2048, 0x02);
|
||||||
|
|
||||||
// Copy the "dummy" Supercharger BIOS code into the ROM area
|
// Copy the "dummy" Supercharger BIOS code into the ROM area
|
||||||
memcpy(myImage + (3<<11), ourDummyROMCode, sizeof(ourDummyROMCode));
|
std::copy_n(ourDummyROMCode.data(), ourDummyROMCode.size(), myImage.data() + (3<<11));
|
||||||
|
|
||||||
// Finally set 6502 vectors to point to initial load code at 0xF80A of BIOS
|
// Finally set 6502 vectors to point to initial load code at 0xF80A of BIOS
|
||||||
myImage[(3<<11) + 2044] = 0x0A;
|
myImage[(3<<11) + 2044] = 0x0A;
|
||||||
|
@ -348,16 +348,14 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
|
||||||
for(image = 0; image < myNumberOfLoadImages; ++image)
|
for(image = 0; image < myNumberOfLoadImages; ++image)
|
||||||
{
|
{
|
||||||
// Is this the correct load?
|
// Is this the correct load?
|
||||||
if(myLoadImages[(image * 8448) + 8192 + 5] == load)
|
if(myLoadImages[(image * 8448) + myImage.size() + 5] == load)
|
||||||
{
|
{
|
||||||
// Copy the load's header
|
// Copy the load's header
|
||||||
memcpy(myHeader, myLoadImages.get() + (image * 8448) + 8192, 256);
|
std::copy_n(myLoadImages.get() + (image * 8448) + myImage.size(), myHeader.size(), myHeader.data());
|
||||||
|
|
||||||
// Verify the load's header
|
// Verify the load's header
|
||||||
if(checksum(myHeader, 8) != 0x55)
|
if(checksum(myHeader.data(), 8) != 0x55)
|
||||||
{
|
|
||||||
cerr << "WARNING: The Supercharger header checksum is invalid...\n";
|
cerr << "WARNING: The Supercharger header checksum is invalid...\n";
|
||||||
}
|
|
||||||
|
|
||||||
// Load all of the pages from the load
|
// Load all of the pages from the load
|
||||||
bool invalidPageChecksumSeen = false;
|
bool invalidPageChecksumSeen = false;
|
||||||
|
@ -376,9 +374,7 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
|
||||||
|
|
||||||
// Copy page to Supercharger RAM (don't allow a copy into ROM area)
|
// Copy page to Supercharger RAM (don't allow a copy into ROM area)
|
||||||
if(bank < 3)
|
if(bank < 3)
|
||||||
{
|
std::copy_n(src, 256, myImage.data() + (bank * 2048) + (page * 256));
|
||||||
memcpy(myImage + (bank * 2048) + (page * 256), src, 256);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the bank switching byte and starting address into the 2600's
|
// Copy the bank switching byte and starting address into the 2600's
|
||||||
|
@ -407,7 +403,7 @@ bool CartridgeAR::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeAR::getBank() const
|
uInt16 CartridgeAR::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myCurrentBank;
|
return myCurrentBank;
|
||||||
}
|
}
|
||||||
|
@ -438,13 +434,13 @@ bool CartridgeAR::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Indicates the offest within the image for the corresponding bank
|
// Indicates the offest within the image for the corresponding bank
|
||||||
out.putIntArray(myImageOffset, 2);
|
out.putIntArray(myImageOffset.data(), myImageOffset.size());
|
||||||
|
|
||||||
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
||||||
out.putByteArray(myImage, 8192);
|
out.putByteArray(myImage.data(), myImage.size());
|
||||||
|
|
||||||
// The 256 byte header for the current 8448 byte load
|
// The 256 byte header for the current 8448 byte load
|
||||||
out.putByteArray(myHeader, 256);
|
out.putByteArray(myHeader.data(), myHeader.size());
|
||||||
|
|
||||||
// All of the 8448 byte loads associated with the game
|
// All of the 8448 byte loads associated with the game
|
||||||
// Note that the size of this array is myNumberOfLoadImages * 8448
|
// Note that the size of this array is myNumberOfLoadImages * 8448
|
||||||
|
@ -483,13 +479,13 @@ bool CartridgeAR::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Indicates the offest within the image for the corresponding bank
|
// Indicates the offest within the image for the corresponding bank
|
||||||
in.getIntArray(myImageOffset, 2);
|
in.getIntArray(myImageOffset.data(), myImageOffset.size());
|
||||||
|
|
||||||
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
||||||
in.getByteArray(myImage, 8192);
|
in.getByteArray(myImage.data(), myImage.size());
|
||||||
|
|
||||||
// The 256 byte header for the current 8448 byte load
|
// The 256 byte header for the current 8448 byte load
|
||||||
in.getByteArray(myHeader, 256);
|
in.getByteArray(myHeader.data(), myHeader.size());
|
||||||
|
|
||||||
// All of the 8448 byte loads associated with the game
|
// All of the 8448 byte loads associated with the game
|
||||||
// Note that the size of this array is myNumberOfLoadImages * 8448
|
// Note that the size of this array is myNumberOfLoadImages * 8448
|
||||||
|
@ -523,7 +519,7 @@ bool CartridgeAR::load(Serializer& in)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt8 CartridgeAR::ourDummyROMCode[] = {
|
std::array<uInt8, 294> CartridgeAR::ourDummyROMCode = {
|
||||||
0xa5, 0xfa, 0x85, 0x80, 0x4c, 0x18, 0xf8, 0xff,
|
0xa5, 0xfa, 0x85, 0x80, 0x4c, 0x18, 0xf8, 0xff,
|
||||||
0xff, 0xff, 0x78, 0xd8, 0xa0, 0x00, 0xa2, 0x00,
|
0xff, 0xff, 0x78, 0xd8, 0xa0, 0x00, 0xa2, 0x00,
|
||||||
0x94, 0x00, 0xe8, 0xd0, 0xfb, 0x4c, 0x50, 0xf8,
|
0x94, 0x00, 0xe8, 0xd0, 0xfb, 0x4c, 0x50, 0xf8,
|
||||||
|
@ -564,7 +560,7 @@ uInt8 CartridgeAR::ourDummyROMCode[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8 CartridgeAR::ourDefaultHeader[256] = {
|
const std::array<uInt8, 256> CartridgeAR::ourDefaultHeader = {
|
||||||
0xac, 0xfa, 0x0f, 0x18, 0x62, 0x00, 0x24, 0x02,
|
0xac, 0xfa, 0x0f, 0x18, 0x62, 0x00, 0x24, 0x02,
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
|
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
|
||||||
|
|
|
@ -79,8 +79,10 @@ class CartridgeAR : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -185,13 +187,13 @@ class CartridgeAR : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Indicates the offset within the image for the corresponding bank
|
// Indicates the offset within the image for the corresponding bank
|
||||||
uInt32 myImageOffset[2];
|
std::array<uInt32, 2> myImageOffset;
|
||||||
|
|
||||||
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
// The 6K of RAM and 2K of ROM contained in the Supercharger
|
||||||
uInt8 myImage[8192];
|
std::array<uInt8, 8_KB> myImage;
|
||||||
|
|
||||||
// The 256 byte header for the current 8448 byte load
|
// The 256 byte header for the current 8448 byte load
|
||||||
uInt8 myHeader[256];
|
std::array<uInt8, 256> myHeader;
|
||||||
|
|
||||||
// Size of the ROM image
|
// Size of the ROM image
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
@ -221,11 +223,11 @@ class CartridgeAR : public Cartridge
|
||||||
uInt16 myCurrentBank;
|
uInt16 myCurrentBank;
|
||||||
|
|
||||||
// Fake SC-BIOS code to simulate the Supercharger load bars
|
// Fake SC-BIOS code to simulate the Supercharger load bars
|
||||||
static uInt8 ourDummyROMCode[294];
|
static std::array<uInt8, 294> ourDummyROMCode;
|
||||||
|
|
||||||
// Default 256-byte header to use if one isn't included in the ROM
|
// Default 256-byte header to use if one isn't included in the ROM
|
||||||
// This data comes from z26
|
// This data comes from z26
|
||||||
static const uInt8 ourDefaultHeader[256];
|
static const std::array<uInt8, 256> ourDefaultHeader;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -25,8 +25,8 @@ CartridgeBF::CartridgeBF(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(262144u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(262144);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -105,7 +105,7 @@ bool CartridgeBF::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeBF::getBank() const
|
uInt16 CartridgeBF::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ bool CartridgeBF::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeBF::getImage(uInt32& size) const
|
const uInt8* CartridgeBF::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 64 * 4096;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeBF : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,7 +154,7 @@ class CartridgeBF : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 256K ROM image of the cartridge
|
// The 256K ROM image of the cartridge
|
||||||
uInt8 myImage[64 * 4096];
|
std::array<uInt8, 256_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt32 myBankOffset;
|
uInt32 myBankOffset;
|
||||||
|
|
|
@ -25,14 +25,14 @@ CartridgeBFSC::CartridgeBFSC(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(262144u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(262144);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeBFSC::reset()
|
void CartridgeBFSC::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 128);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(15);
|
initializeStartBank(15);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -144,7 +144,7 @@ bool CartridgeBFSC::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeBFSC::getBank() const
|
uInt16 CartridgeBFSC::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,8 @@ bool CartridgeBFSC::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeBFSC::getImage(uInt32& size) const
|
const uInt8* CartridgeBFSC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 64 * 4096;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -186,7 +186,7 @@ bool CartridgeBFSC::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putInt(myBankOffset);
|
out.putInt(myBankOffset);
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ bool CartridgeBFSC::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getInt();
|
myBankOffset = in.getInt();
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeBFSC : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,10 +154,10 @@ class CartridgeBFSC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 256K ROM image of the cartridge
|
// The 256K ROM image of the cartridge
|
||||||
uInt8 myImage[64 * 4096];
|
std::array<uInt8, 256_KB> myImage;
|
||||||
|
|
||||||
// The 128 bytes of RAM
|
// The 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt32 myBankOffset;
|
uInt32 myBankOffset;
|
||||||
|
|
|
@ -49,25 +49,27 @@ CartridgeBUS::CartridgeBUS(const ByteBuffer& image, uInt32 size,
|
||||||
myFractionalClocks(0.0)
|
myFractionalClocks(0.0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(32768u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
|
|
||||||
// even though the ROM is 32K, only 28K is accessible to the 6507
|
// Even though the ROM is 32K, only 28K is accessible to the 6507
|
||||||
createCodeAccessBase(4096 * 7);
|
createCodeAccessBase(28_KB);
|
||||||
|
|
||||||
// Pointer to the program ROM (28K @ 0 byte offset)
|
// Pointer to the program ROM (28K @ 0 byte offset)
|
||||||
// which starts after the 2K BUS Driver and 2K C Code
|
// which starts after the 2K BUS Driver and 2K C Code
|
||||||
myProgramImage = myImage + 4096;
|
myProgramImage = myImage.data() + 4_KB;
|
||||||
|
|
||||||
// Pointer to BUS driver in RAM
|
// Pointer to BUS driver in RAM
|
||||||
myBusDriverImage = myBUSRAM;
|
myBusDriverImage = myBUSRAM.data();
|
||||||
|
|
||||||
// Pointer to the display RAM
|
// Pointer to the display RAM
|
||||||
myDisplayImage = myBUSRAM + DSRAM;
|
myDisplayImage = myBUSRAM.data() + DSRAM;
|
||||||
|
|
||||||
// Create Thumbulator ARM emulator
|
// Create Thumbulator ARM emulator
|
||||||
bool devSettings = settings.getBool("dev.settings");
|
bool devSettings = settings.getBool("dev.settings");
|
||||||
myThumbEmulator = make_unique<Thumbulator>(
|
myThumbEmulator = make_unique<Thumbulator>(
|
||||||
reinterpret_cast<uInt16*>(myImage), reinterpret_cast<uInt16*>(myBUSRAM), 32768,
|
reinterpret_cast<uInt16*>(myImage.data()),
|
||||||
|
reinterpret_cast<uInt16*>(myBUSRAM.data()),
|
||||||
|
myImage.size(),
|
||||||
devSettings ? settings.getBool("dev.thumb.trapfatal") : false, Thumbulator::ConfigureFor::BUS, this
|
devSettings ? settings.getBool("dev.thumb.trapfatal") : false, Thumbulator::ConfigureFor::BUS, this
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -77,7 +79,7 @@ CartridgeBUS::CartridgeBUS(const ByteBuffer& image, uInt32 size,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeBUS::reset()
|
void CartridgeBUS::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myBUSRAM+2048, 8192-2048);
|
initializeRAM(myBUSRAM.data() + 2_KB, 6_KB);
|
||||||
|
|
||||||
// BUS always starts in bank 6
|
// BUS always starts in bank 6
|
||||||
initializeStartBank(6);
|
initializeStartBank(6);
|
||||||
|
@ -96,10 +98,9 @@ void CartridgeBUS::reset()
|
||||||
void CartridgeBUS::setInitialState()
|
void CartridgeBUS::setInitialState()
|
||||||
{
|
{
|
||||||
// Copy initial BUS driver to Harmony RAM
|
// Copy initial BUS driver to Harmony RAM
|
||||||
memcpy(myBusDriverImage, myImage, 0x0800);
|
std::copy_n(myImage.begin(), 0x0800, myBusDriverImage);
|
||||||
|
|
||||||
for (int i=0; i < 3; ++i)
|
myMusicWaveformSize.fill(27);
|
||||||
myMusicWaveformSize[i] = 27;
|
|
||||||
|
|
||||||
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
|
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
|
||||||
// need to confirm with Chris
|
// need to confirm with Chris
|
||||||
|
@ -449,7 +450,7 @@ bool CartridgeBUS::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeBUS::getBank() const
|
uInt16 CartridgeBUS::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -478,8 +479,8 @@ bool CartridgeBUS::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeBUS::getImage(uInt32& size) const
|
const uInt8* CartridgeBUS::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 32768;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -547,7 +548,7 @@ bool CartridgeBUS::save(Serializer& out) const
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
|
|
||||||
// Harmony RAM
|
// Harmony RAM
|
||||||
out.putByteArray(myBUSRAM, 8192);
|
out.putByteArray(myBUSRAM.data(), myBUSRAM.size());
|
||||||
|
|
||||||
// Addresses for bus override logic
|
// Addresses for bus override logic
|
||||||
out.putShort(myBusOverdriveAddress);
|
out.putShort(myBusOverdriveAddress);
|
||||||
|
@ -560,9 +561,9 @@ bool CartridgeBUS::save(Serializer& out) const
|
||||||
out.putLong(myARMCycles);
|
out.putLong(myARMCycles);
|
||||||
|
|
||||||
// Audio info
|
// Audio info
|
||||||
out.putIntArray(myMusicCounters, 3);
|
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
out.putIntArray(myMusicFrequencies, 3);
|
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
out.putByteArray(myMusicWaveformSize, 3);
|
out.putByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
|
||||||
|
|
||||||
// Indicates current mode
|
// Indicates current mode
|
||||||
out.putByte(myMode);
|
out.putByte(myMode);
|
||||||
|
@ -588,7 +589,7 @@ bool CartridgeBUS::load(Serializer& in)
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
|
|
||||||
// Harmony RAM
|
// Harmony RAM
|
||||||
in.getByteArray(myBUSRAM, 8192);
|
in.getByteArray(myBUSRAM.data(), myBUSRAM.size());
|
||||||
|
|
||||||
// Addresses for bus override logic
|
// Addresses for bus override logic
|
||||||
myBusOverdriveAddress = in.getShort();
|
myBusOverdriveAddress = in.getShort();
|
||||||
|
@ -601,9 +602,9 @@ bool CartridgeBUS::load(Serializer& in)
|
||||||
myARMCycles = in.getLong();
|
myARMCycles = in.getLong();
|
||||||
|
|
||||||
// Audio info
|
// Audio info
|
||||||
in.getIntArray(myMusicCounters, 3);
|
in.getIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
in.getIntArray(myMusicFrequencies, 3);
|
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
in.getByteArray(myMusicWaveformSize, 3);
|
in.getByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
|
||||||
|
|
||||||
// Indicates current mode
|
// Indicates current mode
|
||||||
myMode = in.getByte();
|
myMode = in.getByte();
|
||||||
|
|
|
@ -90,8 +90,10 @@ class CartridgeBUS : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -209,7 +211,7 @@ class CartridgeBUS : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 32K ROM image of the cartridge
|
// The 32K ROM image of the cartridge
|
||||||
uInt8 myImage[32768];
|
std::array<uInt8, 32_KB> myImage;
|
||||||
|
|
||||||
// Pointer to the 28K program ROM image of the cartridge
|
// Pointer to the 28K program ROM image of the cartridge
|
||||||
uInt8* myProgramImage;
|
uInt8* myProgramImage;
|
||||||
|
@ -224,7 +226,7 @@ class CartridgeBUS : public Cartridge
|
||||||
// $0000 - 2K BUS driver
|
// $0000 - 2K BUS driver
|
||||||
// $0800 - 4K Display Data
|
// $0800 - 4K Display Data
|
||||||
// $1800 - 2K C Variable & Stack
|
// $1800 - 2K C Variable & Stack
|
||||||
uInt8 myBUSRAM[8192];
|
std::array<uInt8, 8_KB> myBUSRAM;
|
||||||
|
|
||||||
// Pointer to the Thumb ARM emulator object
|
// Pointer to the Thumb ARM emulator object
|
||||||
unique_ptr<Thumbulator> myThumbEmulator;
|
unique_ptr<Thumbulator> myThumbEmulator;
|
||||||
|
@ -249,13 +251,13 @@ class CartridgeBUS : public Cartridge
|
||||||
uInt64 myARMCycles;
|
uInt64 myARMCycles;
|
||||||
|
|
||||||
// The music mode counters
|
// The music mode counters
|
||||||
uInt32 myMusicCounters[3];
|
std::array<uInt32, 3> myMusicCounters;
|
||||||
|
|
||||||
// The music frequency
|
// The music frequency
|
||||||
uInt32 myMusicFrequencies[3];
|
std::array<uInt32, 3> myMusicFrequencies;
|
||||||
|
|
||||||
// The music waveform sizes
|
// The music waveform sizes
|
||||||
uInt8 myMusicWaveformSize[3];
|
std::array<uInt8, 3> myMusicWaveformSize;
|
||||||
|
|
||||||
// Fractional DPC music OSC clocks unused during the last update
|
// Fractional DPC music OSC clocks unused during the last update
|
||||||
double myFractionalClocks;
|
double myFractionalClocks;
|
||||||
|
|
|
@ -65,27 +65,29 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, uInt32 size,
|
||||||
myFractionalClocks(0.0)
|
myFractionalClocks(0.0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(32768u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
|
|
||||||
// even though the ROM is 32K, only 28K is accessible to the 6507
|
// even though the ROM is 32K, only 28K is accessible to the 6507
|
||||||
createCodeAccessBase(4096 * 7);
|
createCodeAccessBase(4096 * 7);
|
||||||
|
|
||||||
// Pointer to the program ROM (28K @ 0 byte offset)
|
// Pointer to the program ROM (28K @ 0 byte offset)
|
||||||
// which starts after the 2K CDF Driver and 2K C Code
|
// which starts after the 2K CDF Driver and 2K C Code
|
||||||
myProgramImage = myImage + 4096;
|
myProgramImage = myImage.data() + 4096;
|
||||||
|
|
||||||
// Pointer to CDF driver in RAM
|
// Pointer to CDF driver in RAM
|
||||||
myBusDriverImage = myCDFRAM;
|
myBusDriverImage = myCDFRAM.data();
|
||||||
|
|
||||||
// Pointer to the display RAM
|
// Pointer to the display RAM
|
||||||
myDisplayImage = myCDFRAM + DSRAM;
|
myDisplayImage = myCDFRAM.data() + DSRAM;
|
||||||
|
|
||||||
setupVersion();
|
setupVersion();
|
||||||
|
|
||||||
// Create Thumbulator ARM emulator
|
// Create Thumbulator ARM emulator
|
||||||
bool devSettings = settings.getBool("dev.settings");
|
bool devSettings = settings.getBool("dev.settings");
|
||||||
myThumbEmulator = make_unique<Thumbulator>(
|
myThumbEmulator = make_unique<Thumbulator>(
|
||||||
reinterpret_cast<uInt16*>(myImage), reinterpret_cast<uInt16*>(myCDFRAM), 32768,
|
reinterpret_cast<uInt16*>(myImage.data()),
|
||||||
|
reinterpret_cast<uInt16*>(myCDFRAM.data()),
|
||||||
|
myImage.size(),
|
||||||
devSettings ? settings.getBool("dev.thumb.trapfatal") : false, thumulatorConfiguration(myCDFSubtype), this);
|
devSettings ? settings.getBool("dev.thumb.trapfatal") : false, thumulatorConfiguration(myCDFSubtype), this);
|
||||||
|
|
||||||
setInitialState();
|
setInitialState();
|
||||||
|
@ -94,7 +96,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, uInt32 size,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeCDF::reset()
|
void CartridgeCDF::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myCDFRAM+2048, 8192-2048);
|
initializeRAM(myCDFRAM.data()+2048, myCDFRAM.size()-2048);
|
||||||
|
|
||||||
// CDF always starts in bank 6
|
// CDF always starts in bank 6
|
||||||
initializeStartBank(6);
|
initializeStartBank(6);
|
||||||
|
@ -112,10 +114,9 @@ void CartridgeCDF::reset()
|
||||||
void CartridgeCDF::setInitialState()
|
void CartridgeCDF::setInitialState()
|
||||||
{
|
{
|
||||||
// Copy initial CDF driver to Harmony RAM
|
// Copy initial CDF driver to Harmony RAM
|
||||||
memcpy(myBusDriverImage, myImage, 0x0800);
|
std::copy_n(myImage.begin(), 0x0800, myBusDriverImage);
|
||||||
|
|
||||||
for (int i=0; i < 3; ++i)
|
myMusicWaveformSize.fill(27);
|
||||||
myMusicWaveformSize[i] = 27;
|
|
||||||
|
|
||||||
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
|
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
|
||||||
// need to confirm with Chris
|
// need to confirm with Chris
|
||||||
|
@ -421,7 +422,7 @@ bool CartridgeCDF::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeCDF::getBank() const
|
uInt16 CartridgeCDF::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -450,12 +451,11 @@ bool CartridgeCDF::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeCDF::getImage(uInt32& size) const
|
const uInt8* CartridgeCDF::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 32768;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
|
uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
|
||||||
{
|
{
|
||||||
switch (function)
|
switch (function)
|
||||||
|
@ -484,7 +484,6 @@ uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool CartridgeCDF::save(Serializer& out) const
|
bool CartridgeCDF::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
|
@ -504,12 +503,12 @@ bool CartridgeCDF::save(Serializer& out) const
|
||||||
out.putShort(myJMPoperandAddress);
|
out.putShort(myJMPoperandAddress);
|
||||||
|
|
||||||
// Harmony RAM
|
// Harmony RAM
|
||||||
out.putByteArray(myCDFRAM, 8192);
|
out.putByteArray(myCDFRAM.data(), myCDFRAM.size());
|
||||||
|
|
||||||
// Audio info
|
// Audio info
|
||||||
out.putIntArray(myMusicCounters, 3);
|
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
out.putIntArray(myMusicFrequencies, 3);
|
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
out.putByteArray(myMusicWaveformSize, 3);
|
out.putByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
|
||||||
|
|
||||||
// Save cycles and clocks
|
// Save cycles and clocks
|
||||||
out.putLong(myAudioCycles);
|
out.putLong(myAudioCycles);
|
||||||
|
@ -544,12 +543,12 @@ bool CartridgeCDF::load(Serializer& in)
|
||||||
myJMPoperandAddress = in.getShort();
|
myJMPoperandAddress = in.getShort();
|
||||||
|
|
||||||
// Harmony RAM
|
// Harmony RAM
|
||||||
in.getByteArray(myCDFRAM, 8192);
|
in.getByteArray(myCDFRAM.data(), myCDFRAM.size());
|
||||||
|
|
||||||
// Audio info
|
// Audio info
|
||||||
in.getIntArray(myMusicCounters, 3);
|
in.getIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
in.getIntArray(myMusicFrequencies, 3);
|
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
in.getByteArray(myMusicWaveformSize, 3);
|
in.getByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
|
||||||
|
|
||||||
// Get cycles and clocks
|
// Get cycles and clocks
|
||||||
myAudioCycles = in.getLong();
|
myAudioCycles = in.getLong();
|
||||||
|
@ -604,13 +603,12 @@ uInt32 CartridgeCDF::getDatastreamIncrement(uInt8 index) const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt32 CartridgeCDF::getWaveform(uInt8 index) const
|
uInt32 CartridgeCDF::getWaveform(uInt8 index) const
|
||||||
{
|
{
|
||||||
uInt32 result;
|
|
||||||
uInt16 address = myWaveformBase + index * 4;
|
uInt16 address = myWaveformBase + index * 4;
|
||||||
|
|
||||||
result = myCDFRAM[address + 0] + // low byte
|
uInt32 result = myCDFRAM[address + 0] + // low byte
|
||||||
(myCDFRAM[address + 1] << 8) +
|
(myCDFRAM[address + 1] << 8) +
|
||||||
(myCDFRAM[address + 2] << 16) +
|
(myCDFRAM[address + 2] << 16) +
|
||||||
(myCDFRAM[address + 3] << 24); // high byte
|
(myCDFRAM[address + 3] << 24); // high byte
|
||||||
|
|
||||||
result -= (0x40000000 + DSRAM);
|
result -= (0x40000000 + DSRAM);
|
||||||
|
|
||||||
|
@ -623,13 +621,12 @@ uInt32 CartridgeCDF::getWaveform(uInt8 index) const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt32 CartridgeCDF::getSample()
|
uInt32 CartridgeCDF::getSample()
|
||||||
{
|
{
|
||||||
uInt32 result;
|
|
||||||
uInt16 address = myWaveformBase;
|
uInt16 address = myWaveformBase;
|
||||||
|
|
||||||
result = myCDFRAM[address + 0] + // low byte
|
uInt32 result = myCDFRAM[address + 0] + // low byte
|
||||||
(myCDFRAM[address + 1] << 8) +
|
(myCDFRAM[address + 1] << 8) +
|
||||||
(myCDFRAM[address + 2] << 16) +
|
(myCDFRAM[address + 2] << 16) +
|
||||||
(myCDFRAM[address + 3] << 24); // high byte
|
(myCDFRAM[address + 3] << 24); // high byte
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,10 @@ class CartridgeCDF : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -211,7 +213,7 @@ class CartridgeCDF : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 32K ROM image of the cartridge
|
// The 32K ROM image of the cartridge
|
||||||
uInt8 myImage[32768];
|
std::array<uInt8, 32_KB> myImage;
|
||||||
|
|
||||||
// Pointer to the 28K program ROM image of the cartridge
|
// Pointer to the 28K program ROM image of the cartridge
|
||||||
uInt8* myProgramImage;
|
uInt8* myProgramImage;
|
||||||
|
@ -226,7 +228,7 @@ class CartridgeCDF : public Cartridge
|
||||||
// $0000 - 2K CDF driver
|
// $0000 - 2K CDF driver
|
||||||
// $0800 - 4K Display Data
|
// $0800 - 4K Display Data
|
||||||
// $1800 - 2K C Variable & Stack
|
// $1800 - 2K C Variable & Stack
|
||||||
uInt8 myCDFRAM[8192];
|
std::array<uInt8, 8_KB> myCDFRAM;
|
||||||
|
|
||||||
// Pointer to the Thumb ARM emulator object
|
// Pointer to the Thumb ARM emulator object
|
||||||
unique_ptr<Thumbulator> myThumbEmulator;
|
unique_ptr<Thumbulator> myThumbEmulator;
|
||||||
|
@ -257,13 +259,13 @@ class CartridgeCDF : public Cartridge
|
||||||
r14 = timer base */
|
r14 = timer base */
|
||||||
|
|
||||||
// The music counters, ARM FIQ shadow registers r8, r9, r10
|
// The music counters, ARM FIQ shadow registers r8, r9, r10
|
||||||
uInt32 myMusicCounters[3];
|
std::array<uInt32, 3> myMusicCounters;
|
||||||
|
|
||||||
// The music frequency, ARM FIQ shadow registers r11, r12, r13
|
// The music frequency, ARM FIQ shadow registers r11, r12, r13
|
||||||
uInt32 myMusicFrequencies[3];
|
std::array<uInt32, 3> myMusicFrequencies;
|
||||||
|
|
||||||
// The music waveform sizes
|
// The music waveform sizes
|
||||||
uInt8 myMusicWaveformSize[3];
|
std::array<uInt8, 3> myMusicWaveformSize;
|
||||||
|
|
||||||
// Fractional CDF music, OSC clocks unused during the last update
|
// Fractional CDF music, OSC clocks unused during the last update
|
||||||
double myFractionalClocks;
|
double myFractionalClocks;
|
||||||
|
|
|
@ -28,14 +28,14 @@ CartridgeCM::CartridgeCM(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(16384u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(16384);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeCM::reset()
|
void CartridgeCM::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 2048);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
// On powerup, the last bank of ROM is enabled and RAM is disabled
|
// On powerup, the last bank of ROM is enabled and RAM is disabled
|
||||||
mySWCHA = 0xFF;
|
mySWCHA = 0xFF;
|
||||||
|
@ -153,7 +153,7 @@ bool CartridgeCM::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeCM::getBank() const
|
uInt16 CartridgeCM::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -182,8 +182,8 @@ bool CartridgeCM::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeCM::getImage(uInt32& size) const
|
const uInt8* CartridgeCM::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 16384;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -194,7 +194,7 @@ bool CartridgeCM::save(Serializer& out) const
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
out.putByte(mySWCHA);
|
out.putByte(mySWCHA);
|
||||||
out.putByte(myCompuMate->column());
|
out.putByte(myCompuMate->column());
|
||||||
out.putByteArray(myRAM, 2048);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +213,7 @@ bool CartridgeCM::load(Serializer& in)
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
mySWCHA = in.getByte();
|
mySWCHA = in.getByte();
|
||||||
myCompuMate->column() = in.getByte();
|
myCompuMate->column() = in.getByte();
|
||||||
in.getByteArray(myRAM, 2048);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -147,8 +147,10 @@ class CartridgeCM : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -241,10 +243,10 @@ class CartridgeCM : public Cartridge
|
||||||
shared_ptr<CompuMate> myCompuMate;
|
shared_ptr<CompuMate> myCompuMate;
|
||||||
|
|
||||||
// The 16K ROM image of the cartridge
|
// The 16K ROM image of the cartridge
|
||||||
uInt8 myImage[16384];
|
std::array<uInt8, 16_KB> myImage;
|
||||||
|
|
||||||
// The 2K of RAM
|
// The 2K of RAM
|
||||||
uInt8 myRAM[2048];
|
std::array<uInt8, 2_KB> myRAM;
|
||||||
|
|
||||||
// Current copy of SWCHA (controls ROM/RAM accesses)
|
// Current copy of SWCHA (controls ROM/RAM accesses)
|
||||||
uInt8 mySWCHA;
|
uInt8 mySWCHA;
|
||||||
|
|
|
@ -35,27 +35,27 @@ CartridgeCTY::CartridgeCTY(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(32768u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(32768);
|
createCodeAccessBase(myImage.size());
|
||||||
|
|
||||||
// Default to no tune data in case user is utilizing an old ROM
|
// Default to no tune data in case user is utilizing an old ROM
|
||||||
memset(myTuneData, 0, 28*1024);
|
myTuneData.fill(0);
|
||||||
|
|
||||||
// Extract tune data if it exists
|
// Extract tune data if it exists
|
||||||
if(size > 32768u)
|
if(size > myImage.size())
|
||||||
memcpy(myTuneData, image.get() + 32768u, size - 32768u);
|
std::copy_n(image.get() + myImage.size(), size - myImage.size(), myTuneData.begin());
|
||||||
|
|
||||||
// Point to the first tune
|
// Point to the first tune
|
||||||
myFrequencyImage = myTuneData;
|
myFrequencyImage = myTuneData.data();
|
||||||
|
|
||||||
for(uInt8 i = 0; i < 3; ++i)
|
myMusicCounters.fill(0);
|
||||||
myMusicCounters[i] = myMusicFrequencies[i] = 0;
|
myMusicFrequencies.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeCTY::reset()
|
void CartridgeCTY::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 64);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(1);
|
initializeStartBank(1);
|
||||||
|
|
||||||
myRAM[0] = myRAM[1] = myRAM[2] = myRAM[3] = 0xFF;
|
myRAM[0] = myRAM[1] = myRAM[2] = myRAM[3] = 0xFF;
|
||||||
|
@ -255,7 +255,7 @@ bool CartridgeCTY::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeCTY::getBank() const
|
uInt16 CartridgeCTY::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -287,8 +287,8 @@ bool CartridgeCTY::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeCTY::getImage(uInt32& size) const
|
const uInt8* CartridgeCTY::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 32768;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -297,7 +297,7 @@ bool CartridgeCTY::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(getBank());
|
out.putShort(getBank());
|
||||||
out.putByteArray(myRAM, 64);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
out.putByte(myOperationType);
|
out.putByte(myOperationType);
|
||||||
out.putShort(myTunePosition);
|
out.putShort(myTunePosition);
|
||||||
|
@ -305,9 +305,9 @@ bool CartridgeCTY::save(Serializer& out) const
|
||||||
out.putInt(myRandomNumber);
|
out.putInt(myRandomNumber);
|
||||||
out.putLong(myAudioCycles);
|
out.putLong(myAudioCycles);
|
||||||
out.putDouble(myFractionalClocks);
|
out.putDouble(myFractionalClocks);
|
||||||
out.putIntArray(myMusicCounters, 3);
|
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
out.putIntArray(myMusicFrequencies, 3);
|
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
out.putLong(myFrequencyImage - myTuneData);
|
out.putLong(myFrequencyImage - myTuneData.data()); // FIXME - storing pointer diff!
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -325,7 +325,7 @@ bool CartridgeCTY::load(Serializer& in)
|
||||||
{
|
{
|
||||||
// Remember what bank we were in
|
// Remember what bank we were in
|
||||||
bank(in.getShort());
|
bank(in.getShort());
|
||||||
in.getByteArray(myRAM, 64);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
myOperationType = in.getByte();
|
myOperationType = in.getByte();
|
||||||
myTunePosition = in.getShort();
|
myTunePosition = in.getShort();
|
||||||
|
@ -333,9 +333,9 @@ bool CartridgeCTY::load(Serializer& in)
|
||||||
myRandomNumber = in.getInt();
|
myRandomNumber = in.getInt();
|
||||||
myAudioCycles = in.getLong();
|
myAudioCycles = in.getLong();
|
||||||
myFractionalClocks = in.getDouble();
|
myFractionalClocks = in.getDouble();
|
||||||
in.getIntArray(myMusicCounters, 3);
|
in.getIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
in.getIntArray(myMusicFrequencies, 3);
|
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
myFrequencyImage = myTuneData + in.getLong();
|
myFrequencyImage = myTuneData.data() + in.getLong();
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -437,7 +437,7 @@ void CartridgeCTY::loadTune(uInt8 index)
|
||||||
// Each tune is offset by 4096 bytes
|
// Each tune is offset by 4096 bytes
|
||||||
// Instead of copying non-modifiable data around (as would happen on the
|
// Instead of copying non-modifiable data around (as would happen on the
|
||||||
// Harmony), we simply point to the appropriate tune
|
// Harmony), we simply point to the appropriate tune
|
||||||
myFrequencyImage = myTuneData + (index << 12);
|
myFrequencyImage = myTuneData.data() + (index << 12);
|
||||||
|
|
||||||
// Reset to beginning of tune
|
// Reset to beginning of tune
|
||||||
myTunePosition = 0;
|
myTunePosition = 0;
|
||||||
|
@ -501,17 +501,18 @@ void CartridgeCTY::loadScore(uInt8 index)
|
||||||
Serializer serializer(myEEPROMFile, Serializer::Mode::ReadOnly);
|
Serializer serializer(myEEPROMFile, Serializer::Mode::ReadOnly);
|
||||||
if(serializer)
|
if(serializer)
|
||||||
{
|
{
|
||||||
uInt8 scoreRAM[256];
|
std::array<uInt8, 256> scoreRAM;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.getByteArray(scoreRAM, 256);
|
serializer.getByteArray(scoreRAM.data(), scoreRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
memset(scoreRAM, 0, 256);
|
scoreRAM.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab 60B slice @ given index (first 4 bytes are ignored)
|
// Grab 60B slice @ given index (first 4 bytes are ignored)
|
||||||
memcpy(myRAM+4, scoreRAM + (index << 6) + 4, 60);
|
std::copy_n(scoreRAM.begin() + (index << 6) + 4, 60, myRAM.begin() + 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,24 +523,24 @@ void CartridgeCTY::saveScore(uInt8 index)
|
||||||
if(serializer)
|
if(serializer)
|
||||||
{
|
{
|
||||||
// Load score RAM
|
// Load score RAM
|
||||||
uInt8 scoreRAM[256];
|
std::array<uInt8, 256> scoreRAM;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.getByteArray(scoreRAM, 256);
|
serializer.getByteArray(scoreRAM.data(), scoreRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
memset(scoreRAM, 0, 256);
|
scoreRAM.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add 60B RAM to score table @ given index (first 4 bytes are ignored)
|
// Add 60B RAM to score table @ given index (first 4 bytes are ignored)
|
||||||
memcpy(scoreRAM + (index << 6) + 4, myRAM+4, 60);
|
std::copy_n(myRAM.begin() + 4, 60, scoreRAM.begin() + (index << 6) + 4);
|
||||||
|
|
||||||
// Save score RAM
|
// Save score RAM
|
||||||
serializer.rewind();
|
serializer.rewind();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.putByteArray(scoreRAM, 256);
|
serializer.putByteArray(scoreRAM.data(), scoreRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -556,11 +557,10 @@ void CartridgeCTY::wipeAllScores()
|
||||||
if(serializer)
|
if(serializer)
|
||||||
{
|
{
|
||||||
// Erase score RAM
|
// Erase score RAM
|
||||||
uInt8 scoreRAM[256];
|
std::array<uInt8, 256> scoreRAM = {};
|
||||||
memset(scoreRAM, 0, 256);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.putByteArray(scoreRAM, 256);
|
serializer.putByteArray(scoreRAM.data(), scoreRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,8 +145,10 @@ class CartridgeCTY : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -258,13 +260,13 @@ class CartridgeCTY : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 32K ROM image of the cartridge
|
// The 32K ROM image of the cartridge
|
||||||
uInt8 myImage[32768];
|
std::array<uInt8, 32_KB> myImage;
|
||||||
|
|
||||||
// The 28K ROM image of the music
|
// The 28K ROM image of the music
|
||||||
uInt8 myTuneData[28*1024];
|
std::array<uInt8, 28_KB> myTuneData;
|
||||||
|
|
||||||
// The 64 bytes of RAM accessible at $1000 - $1080
|
// The 64 bytes of RAM accessible at $1000 - $1080
|
||||||
uInt8 myRAM[64];
|
std::array<uInt8, 64> myRAM;
|
||||||
|
|
||||||
// Operation type (written to $1000, used by hotspot $1FF4)
|
// Operation type (written to $1000, used by hotspot $1FF4)
|
||||||
uInt8 myOperationType;
|
uInt8 myOperationType;
|
||||||
|
@ -277,10 +279,10 @@ class CartridgeCTY : public Cartridge
|
||||||
uInt16 myTunePosition;
|
uInt16 myTunePosition;
|
||||||
|
|
||||||
// The music mode counters
|
// The music mode counters
|
||||||
uInt32 myMusicCounters[3];
|
std::array<uInt32, 3> myMusicCounters;
|
||||||
|
|
||||||
// The music frequency
|
// The music frequency
|
||||||
uInt32 myMusicFrequencies[3];
|
std::array<uInt32, 3> myMusicFrequencies;
|
||||||
|
|
||||||
// Flags that last byte peeked was A9 (LDA #)
|
// Flags that last byte peeked was A9 (LDA #)
|
||||||
bool myLDAimmediate;
|
bool myLDAimmediate;
|
||||||
|
|
|
@ -24,36 +24,35 @@ CartridgeCV::CartridgeCV(const ByteBuffer& image, uInt32 size,
|
||||||
: Cartridge(settings, md5),
|
: Cartridge(settings, md5),
|
||||||
mySize(size)
|
mySize(size)
|
||||||
{
|
{
|
||||||
if(mySize == 2048)
|
if(mySize == myImage.size())
|
||||||
{
|
{
|
||||||
// Copy the ROM data into my buffer
|
// Copy the ROM data into my buffer
|
||||||
memcpy(myImage, image.get(), 2048);
|
std::copy_n(image.get(), myImage.size(), myImage.begin());
|
||||||
}
|
}
|
||||||
else if(mySize == 4096)
|
else if(mySize == 4_KB)
|
||||||
{
|
{
|
||||||
// The game has something saved in the RAM
|
// The game has something saved in the RAM
|
||||||
// Useful for MagiCard program listings
|
// Useful for MagiCard program listings
|
||||||
|
|
||||||
// Copy the ROM data into my buffer
|
// Copy the ROM data into my buffer
|
||||||
memcpy(myImage, image.get() + 2048, 2048);
|
std::copy_n(image.get() + myImage.size(), myImage.size(), myImage.begin());
|
||||||
|
|
||||||
// Copy the RAM image into a buffer for use in reset()
|
// Copy the RAM image into a buffer for use in reset()
|
||||||
myInitialRAM = make_unique<uInt8[]>(1024);
|
std::copy_n(image.get(), myInitialRAM.size(), myInitialRAM.begin());
|
||||||
memcpy(myInitialRAM.get(), image.get(), 1024);
|
|
||||||
}
|
}
|
||||||
createCodeAccessBase(2048+1024);
|
createCodeAccessBase(myImage.size() + myRAM.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeCV::reset()
|
void CartridgeCV::reset()
|
||||||
{
|
{
|
||||||
if(myInitialRAM)
|
if(mySize == 4_KB)
|
||||||
{
|
{
|
||||||
// Copy the RAM image into my buffer
|
// Copy the RAM image into my buffer
|
||||||
memcpy(myRAM, myInitialRAM.get(), 1024);
|
myRAM = myInitialRAM;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
initializeRAM(myRAM, 1024);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
myBankChanged = true;
|
myBankChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -131,8 +130,8 @@ bool CartridgeCV::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeCV::getImage(uInt32& size) const
|
const uInt8* CartridgeCV::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 2048;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -140,7 +139,7 @@ bool CartridgeCV::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putByteArray(myRAM, 1024);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +155,7 @@ bool CartridgeCV::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getByteArray(myRAM, 1024);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,18 +136,17 @@ class CartridgeCV : public Cartridge
|
||||||
bool poke(uInt16 address, uInt8 value) override;
|
bool poke(uInt16 address, uInt8 value) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Pointer to the initial RAM data from the cart
|
// The 2k ROM image for the cartridge
|
||||||
// This doesn't always exist, so we don't pre-allocate it
|
std::array<uInt8, 2048> myImage;
|
||||||
ByteBuffer myInitialRAM;
|
|
||||||
|
|
||||||
// Initial size of the cart data
|
// Initial size of the cart data
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
||||||
// The 2k ROM image for the cartridge
|
|
||||||
uInt8 myImage[2048];
|
|
||||||
|
|
||||||
// The 1024 bytes of RAM
|
// The 1024 bytes of RAM
|
||||||
uInt8 myRAM[1024];
|
std::array<uInt8, 1024> myRAM;
|
||||||
|
|
||||||
|
// Initial RAM data from the cart (doesn't always exist)
|
||||||
|
std::array<uInt8, 1024> myInitialRAM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -30,14 +30,14 @@ CartridgeCVPlus::CartridgeCVPlus(const ByteBuffer& image, uInt32 size,
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.get());
|
||||||
createCodeAccessBase(mySize + 1024);
|
createCodeAccessBase(mySize + myRAM.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeCVPlus::reset()
|
void CartridgeCVPlus::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 1024);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(0);
|
initializeStartBank(0);
|
||||||
|
|
||||||
// We'll map the startup bank into the first segment upon reset
|
// We'll map the startup bank into the first segment upon reset
|
||||||
|
@ -144,7 +144,7 @@ bool CartridgeCVPlus::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeCVPlus::getBank() const
|
uInt16 CartridgeCVPlus::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myCurrentBank;
|
return myCurrentBank;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ bool CartridgeCVPlus::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myCurrentBank);
|
out.putShort(myCurrentBank);
|
||||||
out.putByteArray(myRAM, 1024);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -204,7 +204,7 @@ bool CartridgeCVPlus::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myCurrentBank = in.getShort();
|
myCurrentBank = in.getShort();
|
||||||
in.getByteArray(myRAM, 1024);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,8 +84,10 @@ class CartridgeCVPlus : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -166,7 +168,7 @@ class CartridgeCVPlus : public Cartridge
|
||||||
ByteBuffer myImage;
|
ByteBuffer myImage;
|
||||||
|
|
||||||
// The 1024 bytes of RAM
|
// The 1024 bytes of RAM
|
||||||
uInt8 myRAM[1024];
|
std::array<uInt8, 1_KB> myRAM;
|
||||||
|
|
||||||
// Size of the ROM image
|
// Size of the ROM image
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
|
@ -29,14 +29,14 @@ CartridgeDASH::CartridgeDASH(const ByteBuffer& image, uInt32 size,
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.get());
|
||||||
createCodeAccessBase(mySize + RAM_TOTAL_SIZE);
|
createCodeAccessBase(mySize + myRAM.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeDASH::reset()
|
void CartridgeDASH::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, RAM_TOTAL_SIZE);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
// Remember startup bank (0 per spec, rather than last per 3E scheme).
|
// Remember startup bank (0 per spec, rather than last per 3E scheme).
|
||||||
// Set this to go to 3rd 1K Bank.
|
// Set this to go to 3rd 1K Bank.
|
||||||
|
@ -311,9 +311,9 @@ bool CartridgeDASH::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShortArray(bankInUse, 8);
|
out.putShortArray(bankInUse.data(), bankInUse.size());
|
||||||
out.putShortArray(segmentInUse, 4);
|
out.putShortArray(segmentInUse.data(), segmentInUse.size());
|
||||||
out.putByteArray(myRAM, RAM_TOTAL_SIZE);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -328,9 +328,9 @@ bool CartridgeDASH::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getShortArray(bankInUse, 8);
|
in.getShortArray(bankInUse.data(), bankInUse.size());
|
||||||
in.getShortArray(segmentInUse, 4);
|
in.getShortArray(segmentInUse.data(), segmentInUse.size());
|
||||||
in.getByteArray(myRAM, RAM_TOTAL_SIZE);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -236,8 +236,8 @@ class CartridgeDASH: public Cartridge
|
||||||
// are consecutive. This allows us to determine on a read/write exactly where the data is.
|
// are consecutive. This allows us to determine on a read/write exactly where the data is.
|
||||||
|
|
||||||
static constexpr uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible
|
static constexpr uInt16 BANK_UNDEFINED = 0x8000; // bank is undefined and inaccessible
|
||||||
uInt16 bankInUse[8]; // bank being used for ROM/RAM (eight 512 byte areas)
|
std::array<uInt16, 8> bankInUse; // bank being used for ROM/RAM (eight 512 byte areas)
|
||||||
uInt16 segmentInUse[4]; // set by bank methods, to know which hotspot was accessed
|
std::array<uInt16, 4> segmentInUse; // set by bank methods, to know which hotspot was accessed
|
||||||
|
|
||||||
static constexpr uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching
|
static constexpr uInt16 BANK_SWITCH_HOTSPOT_RAM = 0x3E; // writes to this address cause bankswitching
|
||||||
static constexpr uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching
|
static constexpr uInt16 BANK_SWITCH_HOTSPOT_ROM = 0x3F; // writes to this address cause bankswitching
|
||||||
|
@ -262,8 +262,8 @@ class CartridgeDASH: public Cartridge
|
||||||
static constexpr uInt16 RAM_WRITE_OFFSET = 0x800;
|
static constexpr uInt16 RAM_WRITE_OFFSET = 0x800;
|
||||||
|
|
||||||
ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge
|
ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge
|
||||||
uInt32 mySize; // Size of the ROM image
|
uInt32 mySize; // Size of the ROM image
|
||||||
uInt8 myRAM[RAM_TOTAL_SIZE];
|
std::array<uInt8, RAM_TOTAL_SIZE> myRAM;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -25,8 +25,8 @@ CartridgeDF::CartridgeDF(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(131072u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(131072);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -101,7 +101,7 @@ bool CartridgeDF::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeDF::getBank() const
|
uInt16 CartridgeDF::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ bool CartridgeDF::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeDF::getImage(uInt32& size) const
|
const uInt8* CartridgeDF::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 131072;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeDF : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,7 +154,7 @@ class CartridgeDF : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 128K ROM image of the cartridge
|
// The 128K ROM image of the cartridge
|
||||||
uInt8 myImage[32 * 4096];
|
std::array<uInt8, 128_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt32 myBankOffset;
|
uInt32 myBankOffset;
|
||||||
|
|
|
@ -25,14 +25,14 @@ CartridgeDFSC::CartridgeDFSC(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(131072u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(131072);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeDFSC::reset()
|
void CartridgeDFSC::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 128);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(15);
|
initializeStartBank(15);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -144,7 +144,7 @@ bool CartridgeDFSC::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeDFSC::getBank() const
|
uInt16 CartridgeDFSC::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,8 @@ bool CartridgeDFSC::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeDFSC::getImage(uInt32& size) const
|
const uInt8* CartridgeDFSC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 131072;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -186,7 +186,7 @@ bool CartridgeDFSC::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putInt(myBankOffset);
|
out.putInt(myBankOffset);
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ bool CartridgeDFSC::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getInt();
|
myBankOffset = in.getInt();
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeDFSC : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,10 +154,10 @@ class CartridgeDFSC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 128K ROM image of the cartridge
|
// The 128K ROM image of the cartridge
|
||||||
uInt8 myImage[32 * 4096];
|
std::array<uInt8, 128_KB> myImage;
|
||||||
|
|
||||||
// The 128 bytes of RAM
|
// The 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt32 myBankOffset;
|
uInt32 myBankOffset;
|
||||||
|
|
|
@ -29,27 +29,26 @@ CartridgeDPC::CartridgeDPC(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Make a copy of the entire image
|
// Make a copy of the entire image
|
||||||
memcpy(myImage, image.get(), std::min(size, 8192u + 2048u + 256u));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(8192);
|
||||||
|
|
||||||
// Pointer to the program ROM (8K @ 0 byte offset)
|
// Pointer to the program ROM (8K @ 0 byte offset)
|
||||||
myProgramImage = myImage;
|
myProgramImage = myImage.data();
|
||||||
|
|
||||||
// Pointer to the display ROM (2K @ 8K offset)
|
// Pointer to the display ROM (2K @ 8K offset)
|
||||||
myDisplayImage = myProgramImage + 8192;
|
myDisplayImage = myProgramImage + 8192;
|
||||||
|
|
||||||
// Initialize the DPC data fetcher registers
|
// Initialize the DPC data fetcher registers
|
||||||
for(int i = 0; i < 8; ++i)
|
myTops.fill(0);
|
||||||
{
|
myBottoms.fill(0);
|
||||||
myTops[i] = myBottoms[i] = myFlags[i] = 0;
|
myFlags.fill(0);
|
||||||
myCounters[i] = 0;
|
myCounters.fill(0);
|
||||||
}
|
|
||||||
|
|
||||||
// None of the data fetchers are in music mode
|
// None of the data fetchers are in music mode
|
||||||
myMusicMode[0] = myMusicMode[1] = myMusicMode[2] = false;
|
myMusicMode.fill(false);
|
||||||
|
|
||||||
// Initialize the DPC's random number generator register (must be non-zero)
|
// Initialize the DPC's random number generator register (must be non-zero)
|
||||||
myRandomNumber = 1;
|
myRandomNumber = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -405,7 +404,7 @@ bool CartridgeDPC::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeDPC::getBank() const
|
uInt16 CartridgeDPC::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -435,7 +434,7 @@ bool CartridgeDPC::patch(uInt16 address, uInt8 value)
|
||||||
const uInt8* CartridgeDPC::getImage(uInt32& size) const
|
const uInt8* CartridgeDPC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = mySize;
|
size = mySize;
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -447,20 +446,20 @@ bool CartridgeDPC::save(Serializer& out) const
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
|
|
||||||
// The top registers for the data fetchers
|
// The top registers for the data fetchers
|
||||||
out.putByteArray(myTops, 8);
|
out.putByteArray(myTops.data(), myTops.size());
|
||||||
|
|
||||||
// The bottom registers for the data fetchers
|
// The bottom registers for the data fetchers
|
||||||
out.putByteArray(myBottoms, 8);
|
out.putByteArray(myBottoms.data(), myBottoms.size());
|
||||||
|
|
||||||
// The counter registers for the data fetchers
|
// The counter registers for the data fetchers
|
||||||
out.putShortArray(myCounters, 8);
|
out.putShortArray(myCounters.data(), myCounters.size());
|
||||||
|
|
||||||
// The flag registers for the data fetchers
|
// The flag registers for the data fetchers
|
||||||
out.putByteArray(myFlags, 8);
|
out.putByteArray(myFlags.data(), myFlags.size());
|
||||||
|
|
||||||
// The music mode flags for the data fetchers
|
// The music mode flags for the data fetchers
|
||||||
for(int i = 0; i < 3; ++i)
|
for(const auto& mode: myMusicMode)
|
||||||
out.putBool(myMusicMode[i]);
|
out.putBool(mode);
|
||||||
|
|
||||||
// The random number generator register
|
// The random number generator register
|
||||||
out.putByte(myRandomNumber);
|
out.putByte(myRandomNumber);
|
||||||
|
@ -486,20 +485,20 @@ bool CartridgeDPC::load(Serializer& in)
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
|
|
||||||
// The top registers for the data fetchers
|
// The top registers for the data fetchers
|
||||||
in.getByteArray(myTops, 8);
|
in.getByteArray(myTops.data(), myTops.size());
|
||||||
|
|
||||||
// The bottom registers for the data fetchers
|
// The bottom registers for the data fetchers
|
||||||
in.getByteArray(myBottoms, 8);
|
in.getByteArray(myBottoms.data(), myBottoms.size());
|
||||||
|
|
||||||
// The counter registers for the data fetchers
|
// The counter registers for the data fetchers
|
||||||
in.getShortArray(myCounters, 8);
|
in.getShortArray(myCounters.data(), myCounters.size());
|
||||||
|
|
||||||
// The flag registers for the data fetchers
|
// The flag registers for the data fetchers
|
||||||
in.getByteArray(myFlags, 8);
|
in.getByteArray(myFlags.data(), myFlags.size());
|
||||||
|
|
||||||
// The music mode flags for the data fetchers
|
// The music mode flags for the data fetchers
|
||||||
for(int i = 0; i < 3; ++i)
|
for(auto& mode: myMusicMode)
|
||||||
myMusicMode[i] = in.getBool();
|
mode = in.getBool();
|
||||||
|
|
||||||
// The random number generator register
|
// The random number generator register
|
||||||
myRandomNumber = in.getByte();
|
myRandomNumber = in.getByte();
|
||||||
|
|
|
@ -77,8 +77,10 @@ class CartridgeDPC : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -170,7 +172,7 @@ class CartridgeDPC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The ROM image
|
// The ROM image
|
||||||
uInt8 myImage[8192 + 2048 + 256];
|
std::array<uInt8, 8_KB + 2_KB + 256> myImage;
|
||||||
|
|
||||||
// (Actual) Size of the ROM image
|
// (Actual) Size of the ROM image
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
@ -182,19 +184,19 @@ class CartridgeDPC : public Cartridge
|
||||||
uInt8* myDisplayImage;
|
uInt8* myDisplayImage;
|
||||||
|
|
||||||
// The top registers for the data fetchers
|
// The top registers for the data fetchers
|
||||||
uInt8 myTops[8];
|
std::array<uInt8, 8> myTops;
|
||||||
|
|
||||||
// The bottom registers for the data fetchers
|
// The bottom registers for the data fetchers
|
||||||
uInt8 myBottoms[8];
|
std::array<uInt8, 8> myBottoms;
|
||||||
|
|
||||||
// The counter registers for the data fetchers
|
// The counter registers for the data fetchers
|
||||||
uInt16 myCounters[8];
|
std::array<uInt16, 8> myCounters;
|
||||||
|
|
||||||
// The flag registers for the data fetchers
|
// The flag registers for the data fetchers
|
||||||
uInt8 myFlags[8];
|
std::array<uInt8, 8> myFlags;
|
||||||
|
|
||||||
// The music mode DF5, DF6, & DF7 enabled flags
|
// The music mode DF5, DF6, & DF7 enabled flags
|
||||||
bool myMusicMode[3];
|
std::array<bool, 3> myMusicMode;
|
||||||
|
|
||||||
// The random number generator register
|
// The random number generator register
|
||||||
uInt8 myRandomNumber;
|
uInt8 myRandomNumber;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, uInt32 size,
|
CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, uInt32 size,
|
||||||
const string& md5, const Settings& settings)
|
const string& md5, const Settings& settings)
|
||||||
: Cartridge(settings, md5),
|
: Cartridge(settings, md5),
|
||||||
mySize(std::min(size, 32768u)),
|
mySize(std::min<uInt32>(size, myImage.size())),
|
||||||
myFastFetch(false),
|
myFastFetch(false),
|
||||||
myLDAimmediate(false),
|
myLDAimmediate(false),
|
||||||
myParameterPointer(0),
|
myParameterPointer(0),
|
||||||
|
@ -41,16 +41,16 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, uInt32 size,
|
||||||
{
|
{
|
||||||
// Image is always 32K, but in the case of ROM > 29K, the image is
|
// Image is always 32K, but in the case of ROM > 29K, the image is
|
||||||
// copied to the end of the buffer
|
// copied to the end of the buffer
|
||||||
if(mySize < 32768u)
|
if(mySize < myImage.size())
|
||||||
memset(myImage, 0, 32768);
|
myImage.fill(0);
|
||||||
memcpy(myImage + (32768u - mySize), image.get(), size);
|
std::copy_n(image.get(), size, myImage.begin() + (myImage.size() - mySize));
|
||||||
createCodeAccessBase(4096 * 6);
|
createCodeAccessBase(4096 * 6);
|
||||||
|
|
||||||
// Pointer to the program ROM (24K @ 3072 byte offset; ignore first 3K)
|
// Pointer to the program ROM (24K @ 3072 byte offset; ignore first 3K)
|
||||||
myProgramImage = myImage + 0xC00;
|
myProgramImage = myImage.data() + 0xC00;
|
||||||
|
|
||||||
// Pointer to the display RAM
|
// Pointer to the display RAM
|
||||||
myDisplayImage = myDPCRAM + 0xC00;
|
myDisplayImage = myDPCRAM.data() + 0xC00;
|
||||||
|
|
||||||
// Pointer to the Frequency RAM
|
// Pointer to the Frequency RAM
|
||||||
myFrequencyImage = myDisplayImage + 0x1000;
|
myFrequencyImage = myDisplayImage + 0x1000;
|
||||||
|
@ -58,9 +58,9 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, uInt32 size,
|
||||||
// Create Thumbulator ARM emulator
|
// Create Thumbulator ARM emulator
|
||||||
bool devSettings = settings.getBool("dev.settings");
|
bool devSettings = settings.getBool("dev.settings");
|
||||||
myThumbEmulator = make_unique<Thumbulator>
|
myThumbEmulator = make_unique<Thumbulator>
|
||||||
(reinterpret_cast<uInt16*>(myImage),
|
(reinterpret_cast<uInt16*>(myImage.data()),
|
||||||
reinterpret_cast<uInt16*>(myDPCRAM),
|
reinterpret_cast<uInt16*>(myDPCRAM.data()),
|
||||||
32768,
|
myImage.size(),
|
||||||
devSettings ? settings.getBool("dev.thumb.trapfatal") : false,
|
devSettings ? settings.getBool("dev.thumb.trapfatal") : false,
|
||||||
Thumbulator::ConfigureFor::DPCplus,
|
Thumbulator::ConfigureFor::DPCplus,
|
||||||
this);
|
this);
|
||||||
|
@ -89,21 +89,20 @@ void CartridgeDPCPlus::reset()
|
||||||
void CartridgeDPCPlus::setInitialState()
|
void CartridgeDPCPlus::setInitialState()
|
||||||
{
|
{
|
||||||
// Reset various ROM and RAM locations
|
// Reset various ROM and RAM locations
|
||||||
memset(myDPCRAM, 0, 8192);
|
myDPCRAM.fill(0);
|
||||||
|
|
||||||
// Copy initial DPC display data and Frequency table state to Harmony RAM
|
// Copy initial DPC display data and Frequency table state to Harmony RAM
|
||||||
memcpy(myDisplayImage, myProgramImage + 0x6000, 0x1400);
|
std::copy_n(myProgramImage + 0x6000, 0x1400, myDisplayImage);
|
||||||
|
|
||||||
// Initialize the DPC data fetcher registers
|
// Initialize the DPC data fetcher registers
|
||||||
for(int i = 0; i < 8; ++i)
|
myTops.fill(0);
|
||||||
{
|
myBottoms.fill(0);
|
||||||
myTops[i] = myBottoms[i] = myFractionalIncrements[i] = 0;
|
myFractionalIncrements.fill(0);
|
||||||
myFractionalCounters[i] = 0;
|
myFractionalCounters.fill(0);
|
||||||
myCounters[i] = 0;
|
myCounters.fill(0);
|
||||||
}
|
|
||||||
|
|
||||||
// Set waveforms to first waveform entry
|
// Set waveforms to first waveform entry
|
||||||
myMusicWaveforms[0] = myMusicWaveforms[1] = myMusicWaveforms[2] = 0;
|
myMusicWaveforms.fill(0);
|
||||||
|
|
||||||
// Initialize the DPC's random number generator register (must be non-zero)
|
// Initialize the DPC's random number generator register (must be non-zero)
|
||||||
myRandomNumber = 0x2B435044; // "DPC+"
|
myRandomNumber = 0x2B435044; // "DPC+"
|
||||||
|
@ -603,7 +602,7 @@ bool CartridgeDPCPlus::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeDPCPlus::getBank() const
|
uInt16 CartridgeDPCPlus::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -633,7 +632,7 @@ bool CartridgeDPCPlus::patch(uInt16 address, uInt8 value)
|
||||||
const uInt8* CartridgeDPCPlus::getImage(uInt32& size) const
|
const uInt8* CartridgeDPCPlus::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = mySize;
|
size = mySize;
|
||||||
return myImage + (32768u - mySize);
|
return myImage.data() + (myImage.size() - mySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -645,38 +644,38 @@ bool CartridgeDPCPlus::save(Serializer& out) const
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
|
|
||||||
// Harmony RAM
|
// Harmony RAM
|
||||||
out.putByteArray(myDPCRAM, 8192);
|
out.putByteArray(myDPCRAM.data(), myDPCRAM.size());
|
||||||
|
|
||||||
// The top registers for the data fetchers
|
// The top registers for the data fetchers
|
||||||
out.putByteArray(myTops, 8);
|
out.putByteArray(myTops.data(), myTops.size());
|
||||||
|
|
||||||
// The bottom registers for the data fetchers
|
// The bottom registers for the data fetchers
|
||||||
out.putByteArray(myBottoms, 8);
|
out.putByteArray(myBottoms.data(), myBottoms.size());
|
||||||
|
|
||||||
// The counter registers for the data fetchers
|
// The counter registers for the data fetchers
|
||||||
out.putShortArray(myCounters, 8);
|
out.putShortArray(myCounters.data(), myCounters.size());
|
||||||
|
|
||||||
// The counter registers for the fractional data fetchers
|
// The counter registers for the fractional data fetchers
|
||||||
out.putIntArray(myFractionalCounters, 8);
|
out.putIntArray(myFractionalCounters.data(), myFractionalCounters.size());
|
||||||
|
|
||||||
// The fractional registers for the data fetchers
|
// The fractional registers for the data fetchers
|
||||||
out.putByteArray(myFractionalIncrements, 8);
|
out.putByteArray(myFractionalIncrements.data(), myFractionalIncrements.size());
|
||||||
|
|
||||||
// The Fast Fetcher Enabled flag
|
// The Fast Fetcher Enabled flag
|
||||||
out.putBool(myFastFetch);
|
out.putBool(myFastFetch);
|
||||||
out.putBool(myLDAimmediate);
|
out.putBool(myLDAimmediate);
|
||||||
|
|
||||||
// Control Byte to update
|
// Control Byte to update
|
||||||
out.putByteArray(myParameter, 8);
|
out.putByteArray(myParameter.data(), myParameter.size());
|
||||||
|
|
||||||
// The music counters
|
// The music counters
|
||||||
out.putIntArray(myMusicCounters, 3);
|
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
|
|
||||||
// The music frequencies
|
// The music frequencies
|
||||||
out.putIntArray(myMusicFrequencies, 3);
|
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
|
|
||||||
// The music waveforms
|
// The music waveforms
|
||||||
out.putShortArray(myMusicWaveforms, 3);
|
out.putShortArray(myMusicWaveforms.data(), myMusicWaveforms.size());
|
||||||
|
|
||||||
// The random number generator register
|
// The random number generator register
|
||||||
out.putInt(myRandomNumber);
|
out.putInt(myRandomNumber);
|
||||||
|
@ -706,38 +705,38 @@ bool CartridgeDPCPlus::load(Serializer& in)
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
|
|
||||||
// Harmony RAM
|
// Harmony RAM
|
||||||
in.getByteArray(myDPCRAM, 8192);
|
in.getByteArray(myDPCRAM.data(), myDPCRAM.size());
|
||||||
|
|
||||||
// The top registers for the data fetchers
|
// The top registers for the data fetchers
|
||||||
in.getByteArray(myTops, 8);
|
in.getByteArray(myTops.data(), myTops.size());
|
||||||
|
|
||||||
// The bottom registers for the data fetchers
|
// The bottom registers for the data fetchers
|
||||||
in.getByteArray(myBottoms, 8);
|
in.getByteArray(myBottoms.data(), myBottoms.size());
|
||||||
|
|
||||||
// The counter registers for the data fetchers
|
// The counter registers for the data fetchers
|
||||||
in.getShortArray(myCounters, 8);
|
in.getShortArray(myCounters.data(), myCounters.size());
|
||||||
|
|
||||||
// The counter registers for the fractional data fetchers
|
// The counter registers for the fractional data fetchers
|
||||||
in.getIntArray(myFractionalCounters, 8);
|
in.getIntArray(myFractionalCounters.data(), myFractionalCounters.size());
|
||||||
|
|
||||||
// The fractional registers for the data fetchers
|
// The fractional registers for the data fetchers
|
||||||
in.getByteArray(myFractionalIncrements, 8);
|
in.getByteArray(myFractionalIncrements.data(), myFractionalIncrements.size());
|
||||||
|
|
||||||
// The Fast Fetcher Enabled flag
|
// The Fast Fetcher Enabled flag
|
||||||
myFastFetch = in.getBool();
|
myFastFetch = in.getBool();
|
||||||
myLDAimmediate = in.getBool();
|
myLDAimmediate = in.getBool();
|
||||||
|
|
||||||
// Control Byte to update
|
// Control Byte to update
|
||||||
in.getByteArray(myParameter, 8);
|
in.getByteArray(myParameter.data(), myParameter.size());
|
||||||
|
|
||||||
// The music mode counters for the data fetchers
|
// The music mode counters for the data fetchers
|
||||||
in.getIntArray(myMusicCounters, 3);
|
in.getIntArray(myMusicCounters.data(), myMusicCounters.size());
|
||||||
|
|
||||||
// The music mode frequency addends for the data fetchers
|
// The music mode frequency addends for the data fetchers
|
||||||
in.getIntArray(myMusicFrequencies, 3);
|
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
|
||||||
|
|
||||||
// The music waveforms
|
// The music waveforms
|
||||||
in.getShortArray(myMusicWaveforms, 3);
|
in.getShortArray(myMusicWaveforms.data(), myMusicWaveforms.size());
|
||||||
|
|
||||||
// The random number generator register
|
// The random number generator register
|
||||||
myRandomNumber = in.getInt();
|
myRandomNumber = in.getInt();
|
||||||
|
|
|
@ -92,8 +92,10 @@ class CartridgeDPCPlus : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -198,7 +200,7 @@ class CartridgeDPCPlus : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The ROM image and size
|
// The ROM image and size
|
||||||
uInt8 myImage[32768];
|
std::array<uInt8, 32_KB> myImage;
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
||||||
// Pointer to the 24K program ROM image of the cartridge
|
// Pointer to the 24K program ROM image of the cartridge
|
||||||
|
@ -211,7 +213,7 @@ class CartridgeDPCPlus : public Cartridge
|
||||||
// 3K DPC+ driver
|
// 3K DPC+ driver
|
||||||
// 4K Display Data
|
// 4K Display Data
|
||||||
// 1K Frequency Data
|
// 1K Frequency Data
|
||||||
uInt8 myDPCRAM[8192];
|
std::array<uInt8, 8_KB> myDPCRAM;
|
||||||
|
|
||||||
// Pointer to the Thumb ARM emulator object
|
// Pointer to the Thumb ARM emulator object
|
||||||
unique_ptr<Thumbulator> myThumbEmulator;
|
unique_ptr<Thumbulator> myThumbEmulator;
|
||||||
|
@ -220,19 +222,19 @@ class CartridgeDPCPlus : public Cartridge
|
||||||
uInt8* myFrequencyImage;
|
uInt8* myFrequencyImage;
|
||||||
|
|
||||||
// The top registers for the data fetchers
|
// The top registers for the data fetchers
|
||||||
uInt8 myTops[8];
|
std::array<uInt8, 8> myTops;
|
||||||
|
|
||||||
// The bottom registers for the data fetchers
|
// The bottom registers for the data fetchers
|
||||||
uInt8 myBottoms[8];
|
std::array<uInt8, 8> myBottoms;
|
||||||
|
|
||||||
// The counter registers for the data fetchers
|
// The counter registers for the data fetchers
|
||||||
uInt16 myCounters[8];
|
std::array<uInt16, 8> myCounters;
|
||||||
|
|
||||||
// The counter registers for the fractional data fetchers
|
// The counter registers for the fractional data fetchers
|
||||||
uInt32 myFractionalCounters[8];
|
std::array<uInt32, 8> myFractionalCounters;
|
||||||
|
|
||||||
// The fractional increments for the data fetchers
|
// The fractional increments for the data fetchers
|
||||||
uInt8 myFractionalIncrements[8];
|
std::array<uInt8, 8> myFractionalIncrements;
|
||||||
|
|
||||||
// The Fast Fetcher Enabled flag
|
// The Fast Fetcher Enabled flag
|
||||||
bool myFastFetch;
|
bool myFastFetch;
|
||||||
|
@ -241,19 +243,19 @@ class CartridgeDPCPlus : public Cartridge
|
||||||
bool myLDAimmediate;
|
bool myLDAimmediate;
|
||||||
|
|
||||||
// Parameter for special functions
|
// Parameter for special functions
|
||||||
uInt8 myParameter[8];
|
std::array<uInt8, 8> myParameter;
|
||||||
|
|
||||||
// Parameter pointer for special functions
|
// Parameter pointer for special functions
|
||||||
uInt8 myParameterPointer;
|
uInt8 myParameterPointer;
|
||||||
|
|
||||||
// The music mode counters
|
// The music mode counters
|
||||||
uInt32 myMusicCounters[3];
|
std::array<uInt32, 3> myMusicCounters;
|
||||||
|
|
||||||
// The music frequency
|
// The music frequency
|
||||||
uInt32 myMusicFrequencies[3];
|
std::array<uInt32, 3> myMusicFrequencies;
|
||||||
|
|
||||||
// The music waveforms
|
// The music waveforms
|
||||||
uInt16 myMusicWaveforms[3];
|
std::array<uInt16, 3> myMusicWaveforms;
|
||||||
|
|
||||||
// The random number generator register
|
// The random number generator register
|
||||||
uInt32 myRandomNumber;
|
uInt32 myRandomNumber;
|
||||||
|
|
|
@ -24,8 +24,8 @@ CartridgeE0::CartridgeE0(const ByteBuffer& image, uInt32 size,
|
||||||
: Cartridge(settings, md5)
|
: Cartridge(settings, md5)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(8192u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -75,9 +75,9 @@ void CartridgeE0::install(System& system)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeE0::getBank(uInt16 addr) const
|
uInt16 CartridgeE0::getBank(uInt16 address) const
|
||||||
{
|
{
|
||||||
return myCurrentSlice[(addr & 0xFFF) >> 10]; // 1K slices
|
return myCurrentSlice[(address & 0xFFF) >> 10]; // 1K slices
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -203,8 +203,8 @@ bool CartridgeE0::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeE0::getImage(uInt32& size) const
|
const uInt8* CartridgeE0::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 8192;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -212,7 +212,7 @@ bool CartridgeE0::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShortArray(myCurrentSlice, 4);
|
out.putShortArray(myCurrentSlice.data(), myCurrentSlice.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,7 @@ bool CartridgeE0::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getShortArray(myCurrentSlice, 4);
|
in.getShortArray(myCurrentSlice.data(), myCurrentSlice.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,8 +75,10 @@ class CartridgeE0 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank(uInt16 addr) const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -175,11 +177,11 @@ class CartridgeE0 : public Cartridge
|
||||||
void segmentTwo(uInt16 slice);
|
void segmentTwo(uInt16 slice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Indicates the slice mapped into each of the four segments
|
|
||||||
uInt16 myCurrentSlice[4];
|
|
||||||
|
|
||||||
// The 8K ROM image of the cartridge
|
// The 8K ROM image of the cartridge
|
||||||
uInt8 myImage[8192];
|
std::array<uInt8, 8_KB> myImage;
|
||||||
|
|
||||||
|
// Indicates the slice mapped into each of the four segments
|
||||||
|
std::array<uInt16, 4> myCurrentSlice;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -25,8 +25,8 @@ CartridgeEF::CartridgeEF(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(65536u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(65536);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -101,7 +101,7 @@ bool CartridgeEF::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeEF::getBank() const
|
uInt16 CartridgeEF::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ bool CartridgeEF::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeEF::getImage(uInt32& size) const
|
const uInt8* CartridgeEF::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 65536;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeEF : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,7 +154,7 @@ class CartridgeEF : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 64K ROM image of the cartridge
|
// The 64K ROM image of the cartridge
|
||||||
uInt8 myImage[65536];
|
std::array<uInt8, 64_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,14 +25,14 @@ CartridgeEFSC::CartridgeEFSC(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(65536u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(65536);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeEFSC::reset()
|
void CartridgeEFSC::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 128);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(15);
|
initializeStartBank(15);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -144,7 +144,7 @@ bool CartridgeEFSC::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeEFSC::getBank() const
|
uInt16 CartridgeEFSC::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,8 @@ bool CartridgeEFSC::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeEFSC::getImage(uInt32& size) const
|
const uInt8* CartridgeEFSC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 65536;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -186,7 +186,7 @@ bool CartridgeEFSC::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ bool CartridgeEFSC::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,8 +74,10 @@ class CartridgeEFSC : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -153,10 +155,10 @@ class CartridgeEFSC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 64K ROM image of the cartridge
|
// The 64K ROM image of the cartridge
|
||||||
uInt8 myImage[65536];
|
std::array<uInt8, 64_KB> myImage;
|
||||||
|
|
||||||
// The 128 bytes of RAM
|
// The 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,8 +25,8 @@ CartridgeF0::CartridgeF0(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(65536u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(65536);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -109,7 +109,7 @@ bool CartridgeF0::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeF0::getBank() const
|
uInt16 CartridgeF0::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,8 @@ bool CartridgeF0::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeF0::getImage(uInt32& size) const
|
const uInt8* CartridgeF0::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 65536;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeF0 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -158,7 +160,7 @@ class CartridgeF0 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 64K ROM image of the cartridge
|
// The 64K ROM image of the cartridge
|
||||||
uInt8 myImage[65536];
|
std::array<uInt8, 64_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -26,8 +26,8 @@ CartridgeF4::CartridgeF4(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(32768u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(32768);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -105,7 +105,7 @@ bool CartridgeF4::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeF4::getBank() const
|
uInt16 CartridgeF4::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ bool CartridgeF4::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeF4::getImage(uInt32& size) const
|
const uInt8* CartridgeF4::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 32768;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -72,8 +72,10 @@ class CartridgeF4 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -151,7 +153,7 @@ class CartridgeF4 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 32K ROM image of the cartridge
|
// The 32K ROM image of the cartridge
|
||||||
uInt8 myImage[32768];
|
std::array<uInt8, 32_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,14 +25,14 @@ CartridgeF4SC::CartridgeF4SC(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(32768u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(32768);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeF4SC::reset()
|
void CartridgeF4SC::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 128);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(0);
|
initializeStartBank(0);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -144,7 +144,7 @@ bool CartridgeF4SC::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeF4SC::getBank() const
|
uInt16 CartridgeF4SC::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,8 @@ bool CartridgeF4SC::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeF4SC::getImage(uInt32& size) const
|
const uInt8* CartridgeF4SC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 32768;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -186,7 +186,7 @@ bool CartridgeF4SC::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -203,7 +203,7 @@ bool CartridgeF4SC::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeF4SC : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,10 +154,10 @@ class CartridgeF4SC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 32K ROM image of the cartridge
|
// The 32K ROM image of the cartridge
|
||||||
uInt8 myImage[32768];
|
std::array<uInt8, 32_KB> myImage;
|
||||||
|
|
||||||
// The 128 bytes of RAM
|
// The 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,8 +25,8 @@ CartridgeF6::CartridgeF6(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(16384u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(16384);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -145,7 +145,7 @@ bool CartridgeF6::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeF6::getBank() const
|
uInt16 CartridgeF6::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -166,8 +166,8 @@ bool CartridgeF6::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeF6::getImage(uInt32& size) const
|
const uInt8* CartridgeF6::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 16384;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -72,8 +72,10 @@ class CartridgeF6 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -151,7 +153,7 @@ class CartridgeF6 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 16K ROM image of the cartridge
|
// The 16K ROM image of the cartridge
|
||||||
uInt8 myImage[16384];
|
std::array<uInt8, 16_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,14 +25,14 @@ CartridgeF6SC::CartridgeF6SC(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(16384u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(16384);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeF6SC::reset()
|
void CartridgeF6SC::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 128);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(0);
|
initializeStartBank(0);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -184,7 +184,7 @@ bool CartridgeF6SC::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeF6SC::getBank() const
|
uInt16 CartridgeF6SC::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -216,8 +216,8 @@ bool CartridgeF6SC::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeF6SC::getImage(uInt32& size) const
|
const uInt8* CartridgeF6SC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 16384;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -226,7 +226,7 @@ bool CartridgeF6SC::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -243,7 +243,7 @@ bool CartridgeF6SC::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeF6SC : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,10 +154,10 @@ class CartridgeF6SC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 16K ROM image of the cartridge
|
// The 16K ROM image of the cartridge
|
||||||
uInt8 myImage[16384];
|
std::array<uInt8, 16_KB> myImage;
|
||||||
|
|
||||||
// The 128 bytes of RAM
|
// The 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,8 +25,8 @@ CartridgeF8::CartridgeF8(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(8192u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -126,7 +126,7 @@ bool CartridgeF8::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeF8::getBank() const
|
uInt16 CartridgeF8::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,8 @@ bool CartridgeF8::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeF8::getImage(uInt32& size) const
|
const uInt8* CartridgeF8::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 8192;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -72,8 +72,10 @@ class CartridgeF8 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -151,7 +153,7 @@ class CartridgeF8 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 8K ROM image of the cartridge
|
// The 8K ROM image of the cartridge
|
||||||
uInt8 myImage[8192];
|
std::array<uInt8, 8_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,14 +25,14 @@ CartridgeF8SC::CartridgeF8SC(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(8192u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeF8SC::reset()
|
void CartridgeF8SC::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 128);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(1);
|
initializeStartBank(1);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -164,7 +164,7 @@ bool CartridgeF8SC::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeF8SC::getBank() const
|
uInt16 CartridgeF8SC::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -196,8 +196,8 @@ bool CartridgeF8SC::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeF8SC::getImage(uInt32& size) const
|
const uInt8* CartridgeF8SC::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 8192;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -206,7 +206,7 @@ bool CartridgeF8SC::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -223,7 +223,7 @@ bool CartridgeF8SC::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeF8SC : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,10 +154,10 @@ class CartridgeF8SC : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 8K ROM image of the cartridge
|
// The 8K ROM image of the cartridge
|
||||||
uInt8 myImage[8192];
|
std::array<uInt8, 8_KB> myImage;
|
||||||
|
|
||||||
// The 128 bytes of RAM
|
// The 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -25,14 +25,14 @@ CartridgeFA::CartridgeFA(const ByteBuffer& image, uInt32 size,
|
||||||
myBankOffset(0)
|
myBankOffset(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(12288u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(12288);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeFA::reset()
|
void CartridgeFA::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 256);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(2);
|
initializeStartBank(2);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -174,7 +174,7 @@ bool CartridgeFA::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeFA::getBank() const
|
uInt16 CartridgeFA::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,8 @@ bool CartridgeFA::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeFA::getImage(uInt32& size) const
|
const uInt8* CartridgeFA::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 12288;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -216,7 +216,7 @@ bool CartridgeFA::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
out.putByteArray(myRAM, 256);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -233,7 +233,7 @@ bool CartridgeFA::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
in.getByteArray(myRAM, 256);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeFA : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,10 +154,10 @@ class CartridgeFA : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 12K ROM image of the cartridge
|
// The 12K ROM image of the cartridge
|
||||||
uInt8 myImage[12288];
|
std::array<uInt8, 12_KB> myImage;
|
||||||
|
|
||||||
// The 256 bytes of RAM on the cartridge
|
// The 256 bytes of RAM on the cartridge
|
||||||
uInt8 myRAM[256];
|
std::array<uInt8, 256> myRAM;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -31,20 +31,20 @@ CartridgeFA2::CartridgeFA2(const ByteBuffer& image, uInt32 size,
|
||||||
{
|
{
|
||||||
// 29/32K version of FA2 has valid data @ 1K - 29K
|
// 29/32K version of FA2 has valid data @ 1K - 29K
|
||||||
const uInt8* img_ptr = image.get();
|
const uInt8* img_ptr = image.get();
|
||||||
if(size >= 29 * 1024)
|
if(size >= 29_KB)
|
||||||
img_ptr += 1024;
|
img_ptr += 1_KB;
|
||||||
else if(size < mySize)
|
else if(size < mySize)
|
||||||
mySize = size;
|
mySize = size;
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, img_ptr, mySize);
|
std::copy_n(img_ptr, mySize, myImage.begin());
|
||||||
createCodeAccessBase(mySize);
|
createCodeAccessBase(mySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeFA2::reset()
|
void CartridgeFA2::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 256);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(0);
|
initializeStartBank(0);
|
||||||
|
|
||||||
// Upon reset we switch to the startup bank
|
// Upon reset we switch to the startup bank
|
||||||
|
@ -93,7 +93,7 @@ uInt8 CartridgeFA2::peek(uInt16 address)
|
||||||
{
|
{
|
||||||
case 0x0FF4:
|
case 0x0FF4:
|
||||||
// Load/save RAM to/from Harmony cart flash
|
// Load/save RAM to/from Harmony cart flash
|
||||||
if(mySize == 28*1024 && !bankLocked())
|
if(mySize == 28_KB && !bankLocked())
|
||||||
return ramReadWrite();
|
return ramReadWrite();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ uInt8 CartridgeFA2::peek(uInt16 address)
|
||||||
case 0x0FFB:
|
case 0x0FFB:
|
||||||
// Set the current bank to the seventh 4k bank
|
// Set the current bank to the seventh 4k bank
|
||||||
// This is only available on 28K ROMs
|
// This is only available on 28K ROMs
|
||||||
if(mySize == 28*1024) bank(6);
|
if(mySize == 28_KB) bank(6);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -151,7 +151,7 @@ bool CartridgeFA2::poke(uInt16 address, uInt8 value)
|
||||||
{
|
{
|
||||||
case 0x0FF4:
|
case 0x0FF4:
|
||||||
// Load/save RAM to/from Harmony cart flash
|
// Load/save RAM to/from Harmony cart flash
|
||||||
if(mySize == 28*1024 && !bankLocked())
|
if(mySize == 28_KB && !bankLocked())
|
||||||
ramReadWrite();
|
ramReadWrite();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ bool CartridgeFA2::poke(uInt16 address, uInt8 value)
|
||||||
case 0x0FFB:
|
case 0x0FFB:
|
||||||
// Set the current bank to the seventh 4k bank
|
// Set the current bank to the seventh 4k bank
|
||||||
// This is only available on 28K ROMs
|
// This is only available on 28K ROMs
|
||||||
if(mySize == 28*1024) bank(6);
|
if(mySize == 28_KB) bank(6);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -241,7 +241,7 @@ bool CartridgeFA2::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeFA2::getBank() const
|
uInt16 CartridgeFA2::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ uInt16 CartridgeFA2::getBank() const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeFA2::bankCount() const
|
uInt16 CartridgeFA2::bankCount() const
|
||||||
{
|
{
|
||||||
return (mySize / 4096);
|
return (mySize / 4_KB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -274,7 +274,7 @@ bool CartridgeFA2::patch(uInt16 address, uInt8 value)
|
||||||
const uInt8* CartridgeFA2::getImage(uInt32& size) const
|
const uInt8* CartridgeFA2::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = mySize;
|
size = mySize;
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -283,7 +283,7 @@ bool CartridgeFA2::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myBankOffset);
|
out.putShort(myBankOffset);
|
||||||
out.putByteArray(myRAM, 256);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -300,7 +300,7 @@ bool CartridgeFA2::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myBankOffset = in.getShort();
|
myBankOffset = in.getShort();
|
||||||
in.getByteArray(myRAM, 256);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -356,11 +356,11 @@ uInt8 CartridgeFA2::ramReadWrite()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.getByteArray(myRAM, 256);
|
serializer.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
memset(myRAM, 0, 256);
|
myRAM.fill(0);
|
||||||
}
|
}
|
||||||
myRamAccessTimeout += 500; // Add 0.5 ms delay for read
|
myRamAccessTimeout += 500; // Add 0.5 ms delay for read
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ uInt8 CartridgeFA2::ramReadWrite()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.putByteArray(myRAM, 256);
|
serializer.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -408,9 +408,8 @@ void CartridgeFA2::flash(uInt8 operation)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
uInt8 buf[256];
|
std::array<uInt8, 256> buf = {};
|
||||||
memset(buf, 0, 256);
|
serializer.putByteArray(buf.data(), buf.size());
|
||||||
serializer.putByteArray(buf, 256);
|
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -420,18 +419,18 @@ void CartridgeFA2::flash(uInt8 operation)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.getByteArray(myRAM, 256);
|
serializer.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
memset(myRAM, 0, 256);
|
myRAM.fill(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(operation == 2) // write
|
else if(operation == 2) // write
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
serializer.putByteArray(myRAM, 256);
|
serializer.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,8 +85,10 @@ class CartridgeFA2 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -191,13 +193,13 @@ class CartridgeFA2 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 24K/28K ROM image of the cartridge
|
// The 24K/28K ROM image of the cartridge
|
||||||
uInt8 myImage[28 * 1024];
|
std::array<uInt8, 28_KB> myImage;
|
||||||
|
|
||||||
// Actual usable size of the ROM image
|
// Actual usable size of the ROM image
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
||||||
// The 256 bytes of RAM on the cartridge
|
// The 256 bytes of RAM on the cartridge
|
||||||
uInt8 myRAM[256];
|
std::array<uInt8, 256> myRAM;
|
||||||
|
|
||||||
// The time after which the first request of a load/save operation
|
// The time after which the first request of a load/save operation
|
||||||
// will actually be completed
|
// will actually be completed
|
||||||
|
|
|
@ -27,8 +27,8 @@ CartridgeFE::CartridgeFE(const ByteBuffer& image, uInt32 size,
|
||||||
myLastAccessWasFE(false)
|
myLastAccessWasFE(false)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(8192u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -110,7 +110,7 @@ bool CartridgeFE::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeFE::getBank() const
|
uInt16 CartridgeFE::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -131,8 +131,8 @@ bool CartridgeFE::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeFE::getImage(uInt32& size) const
|
const uInt8* CartridgeFE::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 8192;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -115,8 +115,10 @@ class CartridgeFE : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -201,7 +203,7 @@ class CartridgeFE : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 8K ROM image of the cartridge
|
// The 8K ROM image of the cartridge
|
||||||
uInt8 myImage[8192];
|
std::array<uInt8, 8_KB> myImage;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -30,7 +30,7 @@ CartridgeMDM::CartridgeMDM(const ByteBuffer& image, uInt32 size,
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.get());
|
||||||
createCodeAccessBase(mySize);
|
createCodeAccessBase(mySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ bool CartridgeMDM::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeMDM::getBank() const
|
uInt16 CartridgeMDM::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,10 @@ class CartridgeMDM : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -169,7 +171,7 @@ class CartridgeMDM : public Cartridge
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
||||||
// Previous Device's page access
|
// Previous Device's page access
|
||||||
System::PageAccess myHotSpotPageAccess[8];
|
std::array<System::PageAccess, 8> myHotSpotPageAccess;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt32 myBankOffset;
|
uInt32 myBankOffset;
|
||||||
|
|
|
@ -35,8 +35,8 @@ void CartridgeMNetwork::initialize(const ByteBuffer& image, uInt32 size)
|
||||||
myImage = make_unique<uInt8[]>(size);
|
myImage = make_unique<uInt8[]>(size);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), std::min(romSize(), size));
|
std::copy_n(image.get(), std::min(romSize(), size), myImage.get());
|
||||||
createCodeAccessBase(romSize() + RAM_SIZE);
|
createCodeAccessBase(romSize() + myRAM.size());
|
||||||
|
|
||||||
myRAMSlice = bankCount() - 1;
|
myRAMSlice = bankCount() - 1;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ void CartridgeMNetwork::initialize(const ByteBuffer& image, uInt32 size)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeMNetwork::reset()
|
void CartridgeMNetwork::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, RAM_SIZE);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
initializeStartBank(0);
|
initializeStartBank(0);
|
||||||
uInt32 ramBank = randomStartBank() ?
|
uInt32 ramBank = randomStartBank() ?
|
||||||
|
@ -162,9 +162,9 @@ void CartridgeMNetwork::bankRAM(uInt16 bank)
|
||||||
|
|
||||||
// Setup the page access methods for the current bank
|
// Setup the page access methods for the current bank
|
||||||
// Set the page accessing method for the 256 bytes of RAM reading pages
|
// Set the page accessing method for the 256 bytes of RAM reading pages
|
||||||
setAccess(0x1800, 0x100, 1024 + offset, myRAM, romSize() + BANK_SIZE / 2, System::PageAccessType::WRITE);
|
setAccess(0x1800, 0x100, 1024 + offset, myRAM.data(), romSize() + BANK_SIZE / 2, System::PageAccessType::WRITE);
|
||||||
// Set the page accessing method for the 256 bytes of RAM reading pages
|
// Set the page accessing method for the 256 bytes of RAM reading pages
|
||||||
setAccess(0x1900, 0x100, 1024 + offset, myRAM, romSize() + BANK_SIZE / 2, System::PageAccessType::READ);
|
setAccess(0x1900, 0x100, 1024 + offset, myRAM.data(), romSize() + BANK_SIZE / 2, System::PageAccessType::READ);
|
||||||
|
|
||||||
myBankChanged = true;
|
myBankChanged = true;
|
||||||
}
|
}
|
||||||
|
@ -188,17 +188,17 @@ bool CartridgeMNetwork::bank(uInt16 slice)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set the page accessing method for the 1K slice of RAM writing pages
|
// Set the page accessing method for the 1K slice of RAM writing pages
|
||||||
setAccess(0x1000, BANK_SIZE / 2, 0, myRAM, romSize(), System::PageAccessType::WRITE);
|
setAccess(0x1000, BANK_SIZE / 2, 0, myRAM.data(), romSize(), System::PageAccessType::WRITE);
|
||||||
// Set the page accessing method for the 1K slice of RAM reading pages
|
// Set the page accessing method for the 1K slice of RAM reading pages
|
||||||
setAccess(0x1000 + BANK_SIZE / 2, BANK_SIZE / 2, 0, myRAM, romSize(), System::PageAccessType::READ);
|
setAccess(0x1000 + BANK_SIZE / 2, BANK_SIZE / 2, 0, myRAM.data(), romSize(), System::PageAccessType::READ);
|
||||||
}
|
}
|
||||||
return myBankChanged = true;
|
return myBankChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeMNetwork::getBank(uInt16 addr) const
|
uInt16 CartridgeMNetwork::getBank(uInt16 address) const
|
||||||
{
|
{
|
||||||
return myCurrentSlice[(addr & 0xFFF) >> 11]; // 2K slices
|
return myCurrentSlice[(address & 0xFFF) >> 11]; // 2K slices
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -243,9 +243,9 @@ bool CartridgeMNetwork::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShortArray(myCurrentSlice, NUM_SEGMENTS);
|
out.putShortArray(myCurrentSlice.data(), myCurrentSlice.size());
|
||||||
out.putShort(myCurrentRAM);
|
out.putShort(myCurrentRAM);
|
||||||
out.putByteArray(myRAM, RAM_SIZE);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -261,9 +261,9 @@ bool CartridgeMNetwork::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getShortArray(myCurrentSlice, NUM_SEGMENTS);
|
in.getShortArray(myCurrentSlice.data(), myCurrentSlice.size());
|
||||||
myCurrentRAM = in.getShort();
|
myCurrentRAM = in.getShort();
|
||||||
in.getByteArray(myRAM, RAM_SIZE);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,8 +100,10 @@ class CartridgeMNetwork : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank(uInt16 addr) const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -203,10 +205,10 @@ class CartridgeMNetwork : public Cartridge
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
||||||
// The 2K of RAM
|
// The 2K of RAM
|
||||||
uInt8 myRAM[RAM_SIZE];
|
std::array<uInt8, RAM_SIZE> myRAM;
|
||||||
|
|
||||||
// Indicates which slice is in the segment
|
// Indicates which slice is in the segment
|
||||||
uInt16 myCurrentSlice[NUM_SEGMENTS];
|
std::array<uInt16, NUM_SEGMENTS> myCurrentSlice;
|
||||||
|
|
||||||
// Indicates which 256 byte bank of RAM is being used
|
// Indicates which 256 byte bank of RAM is being used
|
||||||
uInt16 myCurrentRAM;
|
uInt16 myCurrentRAM;
|
||||||
|
|
|
@ -29,7 +29,7 @@ CartridgeSB::CartridgeSB(const ByteBuffer& image, uInt32 size,
|
||||||
myImage = make_unique<uInt8[]>(mySize);
|
myImage = make_unique<uInt8[]>(mySize);
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage.get(), image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.get());
|
||||||
createCodeAccessBase(mySize);
|
createCodeAccessBase(mySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ bool CartridgeSB::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeSB::getBank() const
|
uInt16 CartridgeSB::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeSB : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -159,7 +161,7 @@ class CartridgeSB : public Cartridge
|
||||||
uInt32 myBankOffset;
|
uInt32 myBankOffset;
|
||||||
|
|
||||||
// Previous Device's page access
|
// Previous Device's page access
|
||||||
System::PageAccess myHotSpotPageAccess[8];
|
std::array<System::PageAccess, 8> myHotSpotPageAccess;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -27,8 +27,8 @@ CartridgeUA::CartridgeUA(const ByteBuffer& image, uInt32 size,
|
||||||
mySwappedHotspots(swapHotspots)
|
mySwappedHotspots(swapHotspots)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(8192u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -143,7 +143,7 @@ bool CartridgeUA::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeUA::getBank() const
|
uInt16 CartridgeUA::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myBankOffset >> 12;
|
return myBankOffset >> 12;
|
||||||
}
|
}
|
||||||
|
@ -164,8 +164,8 @@ bool CartridgeUA::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeUA::getImage(uInt32& size) const
|
const uInt8* CartridgeUA::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 8192;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -73,8 +73,10 @@ class CartridgeUA : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -152,10 +154,10 @@ class CartridgeUA : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 8K ROM image of the cartridge
|
// The 8K ROM image of the cartridge
|
||||||
uInt8 myImage[8192];
|
std::array<uInt8, 8_KB> myImage;
|
||||||
|
|
||||||
// Previous Device's page access
|
// Previous Device's page access
|
||||||
System::PageAccess myHotSpotPageAccess[2];
|
std::array<System::PageAccess, 2> myHotSpotPageAccess;
|
||||||
|
|
||||||
// Indicates the offset into the ROM image (aligns to current bank)
|
// Indicates the offset into the ROM image (aligns to current bank)
|
||||||
uInt16 myBankOffset;
|
uInt16 myBankOffset;
|
||||||
|
|
|
@ -24,20 +24,20 @@
|
||||||
CartridgeWD::CartridgeWD(const ByteBuffer& image, uInt32 size,
|
CartridgeWD::CartridgeWD(const ByteBuffer& image, uInt32 size,
|
||||||
const string& md5, const Settings& settings)
|
const string& md5, const Settings& settings)
|
||||||
: Cartridge(settings, md5),
|
: Cartridge(settings, md5),
|
||||||
mySize(std::min(8195u, size)),
|
mySize(std::min<uInt32>(8_KB + 3, size)),
|
||||||
myCyclesAtBankswitchInit(0),
|
myCyclesAtBankswitchInit(0),
|
||||||
myPendingBank(0),
|
myPendingBank(0),
|
||||||
myCurrentBank(0)
|
myCurrentBank(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), mySize);
|
std::copy_n(image.get(), mySize, myImage.begin());
|
||||||
createCodeAccessBase(8192);
|
createCodeAccessBase(8_KB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeWD::reset()
|
void CartridgeWD::reset()
|
||||||
{
|
{
|
||||||
initializeRAM(myRAM, 64);
|
initializeRAM(myRAM.data(), myRAM.size());
|
||||||
initializeStartBank(0);
|
initializeStartBank(0);
|
||||||
|
|
||||||
myCyclesAtBankswitchInit = 0;
|
myCyclesAtBankswitchInit = 0;
|
||||||
|
@ -212,8 +212,8 @@ void CartridgeWD::segmentThree(uInt8 slice, bool map3bytes)
|
||||||
|
|
||||||
// Make a copy of the address space pointed to by the slice
|
// Make a copy of the address space pointed to by the slice
|
||||||
// Then map in the extra 3 bytes, if required
|
// Then map in the extra 3 bytes, if required
|
||||||
memcpy(mySegment3, myImage+offset, 1024);
|
std::copy_n(myImage.begin()+offset, mySegment3.size(), mySegment3.begin());
|
||||||
if(mySize == 8195 && map3bytes)
|
if(mySize == 8_KB + 3 && map3bytes)
|
||||||
{
|
{
|
||||||
mySegment3[0x3FC] = myImage[0x2000+0];
|
mySegment3[0x3FC] = myImage[0x2000+0];
|
||||||
mySegment3[0x3FD] = myImage[0x2000+1];
|
mySegment3[0x3FD] = myImage[0x2000+1];
|
||||||
|
@ -231,7 +231,7 @@ void CartridgeWD::segmentThree(uInt8 slice, bool map3bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeWD::getBank() const
|
uInt16 CartridgeWD::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myCurrentBank;
|
return myCurrentBank;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ bool CartridgeWD::patch(uInt16 address, uInt8 value)
|
||||||
const uInt8* CartridgeWD::getImage(uInt32& size) const
|
const uInt8* CartridgeWD::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = mySize;
|
size = mySize;
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -270,7 +270,7 @@ bool CartridgeWD::save(Serializer& out) const
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putShort(myCurrentBank);
|
out.putShort(myCurrentBank);
|
||||||
out.putByteArray(myRAM, 64);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
out.putLong(myCyclesAtBankswitchInit);
|
out.putLong(myCyclesAtBankswitchInit);
|
||||||
out.putShort(myPendingBank);
|
out.putShort(myPendingBank);
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ bool CartridgeWD::load(Serializer& in)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myCurrentBank = in.getShort();
|
myCurrentBank = in.getShort();
|
||||||
in.getByteArray(myRAM, 64);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
myCyclesAtBankswitchInit = in.getLong();
|
myCyclesAtBankswitchInit = in.getLong();
|
||||||
myPendingBank = in.getShort();
|
myPendingBank = in.getShort();
|
||||||
|
|
||||||
|
|
|
@ -101,8 +101,10 @@ class CartridgeWD : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -211,19 +213,19 @@ class CartridgeWD : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 8K ROM image of the cartridge
|
// The 8K ROM image of the cartridge
|
||||||
uInt8 myImage[8195];
|
std::array<uInt8, 8_KB + 3> myImage;
|
||||||
|
|
||||||
// Indicates the actual size of the ROM image (either 8K or 8K + 3)
|
// Indicates the actual size of the ROM image (either 8K or 8K + 3)
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
||||||
// The 64 bytes RAM of the cartridge
|
// The 64 bytes RAM of the cartridge
|
||||||
uInt8 myRAM[64];
|
std::array<uInt8, 64> myRAM;
|
||||||
|
|
||||||
// The 1K ROM mirror of segment 3 (sometimes contains extra 3 bytes)
|
// The 1K ROM mirror of segment 3 (sometimes contains extra 3 bytes)
|
||||||
uInt8 mySegment3[1024];
|
std::array<uInt8, 1_KB> mySegment3;
|
||||||
|
|
||||||
// Indicates the offset for each of the four segments
|
// Indicates the offset for each of the four segments
|
||||||
uInt16 myOffset[4];
|
std::array<uInt16, 4> myOffset;
|
||||||
|
|
||||||
// Indicates the cycle at which a bankswitch was initiated
|
// Indicates the cycle at which a bankswitch was initiated
|
||||||
uInt64 myCyclesAtBankswitchInit;
|
uInt64 myCyclesAtBankswitchInit;
|
||||||
|
|
|
@ -27,8 +27,8 @@ CartridgeX07::CartridgeX07(const ByteBuffer& image, uInt32 size,
|
||||||
myCurrentBank(0)
|
myCurrentBank(0)
|
||||||
{
|
{
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
memcpy(myImage, image.get(), std::min(65536u, size));
|
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
|
||||||
createCodeAccessBase(65536);
|
createCodeAccessBase(myImage.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -123,7 +123,7 @@ bool CartridgeX07::bank(uInt16 bank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt16 CartridgeX07::getBank() const
|
uInt16 CartridgeX07::getBank(uInt16) const
|
||||||
{
|
{
|
||||||
return myCurrentBank;
|
return myCurrentBank;
|
||||||
}
|
}
|
||||||
|
@ -144,8 +144,8 @@ bool CartridgeX07::patch(uInt16 address, uInt8 value)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8* CartridgeX07::getImage(uInt32& size) const
|
const uInt8* CartridgeX07::getImage(uInt32& size) const
|
||||||
{
|
{
|
||||||
size = 65536;
|
size = myImage.size();
|
||||||
return myImage;
|
return myImage.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -82,8 +82,10 @@ class CartridgeX07 : public Cartridge
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the current bank.
|
Get the current bank.
|
||||||
|
|
||||||
|
@param address The address to use when querying the bank
|
||||||
*/
|
*/
|
||||||
uInt16 getBank() const override;
|
uInt16 getBank(uInt16 address = 0) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Query the number of banks supported by the cartridge.
|
Query the number of banks supported by the cartridge.
|
||||||
|
@ -161,7 +163,7 @@ class CartridgeX07 : public Cartridge
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The 64K ROM image of the cartridge
|
// The 64K ROM image of the cartridge
|
||||||
uInt8 myImage[65536];
|
std::array<uInt8, 64_KB> myImage;
|
||||||
|
|
||||||
// Indicates which bank is currently active
|
// Indicates which bank is currently active
|
||||||
uInt16 myCurrentBank;
|
uInt16 myCurrentBank;
|
||||||
|
|
|
@ -45,7 +45,7 @@ void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const Common::Rect& rect
|
||||||
uInt8* src = reinterpret_cast<uInt8*>(myPixels + rect.y() * myPitch + rect.x());
|
uInt8* src = reinterpret_cast<uInt8*>(myPixels + rect.y() * myPitch + rect.x());
|
||||||
|
|
||||||
if(rect.empty())
|
if(rect.empty())
|
||||||
memcpy(buffer, src, width() * height() * 4);
|
std::copy_n(src, width() * height() * 4, buffer);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uInt32 w = std::min(rect.w(), width());
|
uInt32 w = std::min(rect.w(), width());
|
||||||
|
@ -55,7 +55,7 @@ void FBSurface::readPixels(uInt8* buffer, uInt32 pitch, const Common::Rect& rect
|
||||||
uInt8* dst = buffer;
|
uInt8* dst = buffer;
|
||||||
while(h--)
|
while(h--)
|
||||||
{
|
{
|
||||||
memcpy(dst, src, w * 4);
|
std::copy_n(src, w * 4, dst);
|
||||||
src += myPitch * 4;
|
src += myPitch * 4;
|
||||||
dst += pitch * 4;
|
dst += pitch * 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,13 +57,11 @@ void M6532::reset()
|
||||||
// Initialize the 128 bytes of memory
|
// Initialize the 128 bytes of memory
|
||||||
bool devSettings = mySettings.getBool("dev.settings");
|
bool devSettings = mySettings.getBool("dev.settings");
|
||||||
if(mySettings.getString(devSettings ? "dev.console" : "plr.console") == "7800")
|
if(mySettings.getString(devSettings ? "dev.console" : "plr.console") == "7800")
|
||||||
for(uInt32 t = 0; t < 128; ++t)
|
std::copy_n(RAM_7800, 128, myRAM.begin());
|
||||||
myRAM[t] = RAM_7800[t];
|
|
||||||
else if(mySettings.getBool(devSettings ? "dev.ramrandom" : "plr.ramrandom"))
|
else if(mySettings.getBool(devSettings ? "dev.ramrandom" : "plr.ramrandom"))
|
||||||
for(uInt32 t = 0; t < 128; ++t)
|
for(uInt32 t = 0; t < 128; ++t) myRAM[t] = mySystem->randGenerator().next();
|
||||||
myRAM[t] = mySystem->randGenerator().next();
|
|
||||||
else
|
else
|
||||||
memset(myRAM, 0, 128);
|
myRAM.fill(0);
|
||||||
|
|
||||||
myTimer = mySystem->randGenerator().next() & 0xff;
|
myTimer = mySystem->randGenerator().next() & 0xff;
|
||||||
myDivider = 1024;
|
myDivider = 1024;
|
||||||
|
@ -368,7 +366,7 @@ bool M6532::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out.putByteArray(myRAM, 128);
|
out.putByteArray(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
out.putInt(myTimer);
|
out.putInt(myTimer);
|
||||||
out.putInt(mySubTimer);
|
out.putInt(mySubTimer);
|
||||||
|
@ -401,7 +399,7 @@ bool M6532::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in.getByteArray(myRAM, 128);
|
in.getByteArray(myRAM.data(), myRAM.size());
|
||||||
|
|
||||||
myTimer = in.getInt();
|
myTimer = in.getInt();
|
||||||
mySubTimer = in.getInt();
|
mySubTimer = in.getInt();
|
||||||
|
@ -467,15 +465,10 @@ uInt32 M6532::timerClocks() const
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void M6532::createAccessBases()
|
void M6532::createAccessBases()
|
||||||
{
|
{
|
||||||
myRAMAccessBase = make_unique<uInt8[]>(RAM_SIZE);
|
myRAMAccessBase.fill(CartDebug::NONE);
|
||||||
memset(myRAMAccessBase.get(), CartDebug::NONE, RAM_SIZE);
|
myStackAccessBase.fill(CartDebug::NONE);
|
||||||
myStackAccessBase = make_unique<uInt8[]>(STACK_SIZE);
|
myIOAccessBase.fill(CartDebug::NONE);
|
||||||
memset(myStackAccessBase.get(), CartDebug::NONE, STACK_SIZE);
|
myZPAccessDelay.fill(ZP_DELAY);
|
||||||
myIOAccessBase = make_unique<uInt8[]>(IO_SIZE);
|
|
||||||
memset(myIOAccessBase.get(), CartDebug::NONE, IO_SIZE);
|
|
||||||
|
|
||||||
myZPAccessDelay = make_unique<uInt8[]>(RAM_SIZE);
|
|
||||||
memset(myZPAccessDelay.get(), ZP_DELAY, RAM_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -128,7 +128,7 @@ class M6532 : public Device
|
||||||
|
|
||||||
@return Pointer to RAM array.
|
@return Pointer to RAM array.
|
||||||
*/
|
*/
|
||||||
const uInt8* getRAM() const { return myRAM; }
|
const uInt8* getRAM() const { return myRAM.data(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class M6532 : public Device
|
||||||
const Settings& mySettings;
|
const Settings& mySettings;
|
||||||
|
|
||||||
// An amazing 128 bytes of RAM
|
// An amazing 128 bytes of RAM
|
||||||
uInt8 myRAM[128];
|
std::array<uInt8, 128> myRAM;
|
||||||
|
|
||||||
// Current value of the timer
|
// Current value of the timer
|
||||||
uInt8 myTimer;
|
uInt8 myTimer;
|
||||||
|
@ -217,19 +217,19 @@ class M6532 : public Device
|
||||||
static constexpr uInt8 TimerBit = 0x80, PA7Bit = 0x40;
|
static constexpr uInt8 TimerBit = 0x80, PA7Bit = 0x40;
|
||||||
|
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
// The arrays containing information about every byte of RIOT
|
|
||||||
// indicating whether and how (RW) it is used.
|
|
||||||
ByteBuffer myRAMAccessBase;
|
|
||||||
ByteBuffer myStackAccessBase;
|
|
||||||
ByteBuffer myIOAccessBase;
|
|
||||||
// The array used to skip the first ZP access tracking
|
|
||||||
ByteBuffer myZPAccessDelay;
|
|
||||||
|
|
||||||
static constexpr uInt16
|
static constexpr uInt16
|
||||||
RAM_SIZE = 0x80, RAM_MASK = RAM_SIZE - 1,
|
RAM_SIZE = 0x80, RAM_MASK = RAM_SIZE - 1,
|
||||||
STACK_SIZE = RAM_SIZE, STACK_MASK = RAM_MASK, STACK_BIT = 0x100,
|
STACK_SIZE = RAM_SIZE, STACK_MASK = RAM_MASK, STACK_BIT = 0x100,
|
||||||
IO_SIZE = 0x20, IO_MASK = IO_SIZE - 1, IO_BIT = 0x200,
|
IO_SIZE = 0x20, IO_MASK = IO_SIZE - 1, IO_BIT = 0x200,
|
||||||
ZP_DELAY = 1;
|
ZP_DELAY = 1;
|
||||||
|
|
||||||
|
// The arrays containing information about every byte of RIOT
|
||||||
|
// indicating whether and how (RW) it is used.
|
||||||
|
std::array<uInt8, RAM_SIZE> myRAMAccessBase;
|
||||||
|
std::array<uInt8, STACK_SIZE> myStackAccessBase;
|
||||||
|
std::array<uInt8, IO_SIZE> myIOAccessBase;
|
||||||
|
// The array used to skip the first ZP access tracking
|
||||||
|
std::array<uInt8, RAM_SIZE> myZPAccessDelay;
|
||||||
#endif // DEBUGGER_SUPPORT
|
#endif // DEBUGGER_SUPPORT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -78,7 +78,7 @@ MT24LC256::MT24LC256(const string& filename, const System& system,
|
||||||
if(uInt32(in.tellg()) == FLASH_SIZE)
|
if(uInt32(in.tellg()) == FLASH_SIZE)
|
||||||
{
|
{
|
||||||
in.seekg(0, std::ios::beg);
|
in.seekg(0, std::ios::beg);
|
||||||
in.read(reinterpret_cast<char*>(myData), FLASH_SIZE);
|
in.read(reinterpret_cast<char*>(myData.data()), myData.size());
|
||||||
myDataFileExists = true;
|
myDataFileExists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ MT24LC256::~MT24LC256()
|
||||||
{
|
{
|
||||||
ofstream out(myDataFile, std::ios_base::binary);
|
ofstream out(myDataFile, std::ios_base::binary);
|
||||||
if(out.is_open())
|
if(out.is_open())
|
||||||
out.write(reinterpret_cast<char*>(myData), FLASH_SIZE);
|
out.write(reinterpret_cast<char*>(myData.data()), myData.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,13 +150,13 @@ void MT24LC256::update()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void MT24LC256::systemReset()
|
void MT24LC256::systemReset()
|
||||||
{
|
{
|
||||||
std::fill(myPageHit, myPageHit + PAGE_NUM, false);
|
myPageHit.fill(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void MT24LC256::eraseAll()
|
void MT24LC256::eraseAll()
|
||||||
{
|
{
|
||||||
memset(myData, INIT_VALUE, FLASH_SIZE);
|
myData.fill(INIT_VALUE);
|
||||||
myDataChanged = true;
|
myDataChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ void MT24LC256::eraseCurrent()
|
||||||
{
|
{
|
||||||
if(myPageHit[page])
|
if(myPageHit[page])
|
||||||
{
|
{
|
||||||
memset(myData + page * PAGE_SIZE, INIT_VALUE, PAGE_SIZE);
|
std::fill_n(myData.begin() + page * PAGE_SIZE, PAGE_SIZE, INIT_VALUE);
|
||||||
myDataChanged = true;
|
myDataChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ void MT24LC256::jpee_init()
|
||||||
jpee_smallmode = 0;
|
jpee_smallmode = 0;
|
||||||
jpee_logmode = -1;
|
jpee_logmode = -1;
|
||||||
if(!myDataFileExists)
|
if(!myDataFileExists)
|
||||||
memset(myData, INIT_VALUE, FLASH_SIZE);
|
myData.fill(INIT_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -94,10 +94,10 @@ class MT24LC256
|
||||||
Controller::onMessageCallback myCallback;
|
Controller::onMessageCallback myCallback;
|
||||||
|
|
||||||
// The EEPROM data
|
// The EEPROM data
|
||||||
uInt8 myData[FLASH_SIZE];
|
std::array<uInt8, FLASH_SIZE> myData;
|
||||||
|
|
||||||
// Track which pages are used
|
// Track which pages are used
|
||||||
bool myPageHit[PAGE_NUM];
|
std::array<bool, PAGE_NUM> myPageHit;
|
||||||
|
|
||||||
// Cached state of the SDA and SCL pins on the last write
|
// Cached state of the SDA and SCL pins on the last write
|
||||||
bool mySDA, mySCL;
|
bool mySDA, mySCL;
|
||||||
|
@ -125,7 +125,7 @@ class MT24LC256
|
||||||
Int32 jpee_sizemask, jpee_pagemask, jpee_smallmode, jpee_logmode;
|
Int32 jpee_sizemask, jpee_pagemask, jpee_smallmode, jpee_logmode;
|
||||||
Int32 jpee_pptr, jpee_state, jpee_nb;
|
Int32 jpee_pptr, jpee_state, jpee_nb;
|
||||||
uInt32 jpee_address, jpee_ad_known;
|
uInt32 jpee_address, jpee_ad_known;
|
||||||
uInt8 jpee_packet[70];
|
std::array<uInt8, 70> jpee_packet;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
|
|
|
@ -58,7 +58,7 @@ TIASurface::TIASurface(OSystem& system)
|
||||||
myBaseTiaSurface = myFB.allocateSurface(TIAConstants::frameBufferWidth*2,
|
myBaseTiaSurface = myFB.allocateSurface(TIAConstants::frameBufferWidth*2,
|
||||||
TIAConstants::frameBufferHeight);
|
TIAConstants::frameBufferHeight);
|
||||||
|
|
||||||
memset(myRGBFramebuffer, 0, sizeof(myRGBFramebuffer));
|
myRGBFramebuffer.fill(0);
|
||||||
|
|
||||||
// Enable/disable threading in the NTSC TV effects renderer
|
// Enable/disable threading in the NTSC TV effects renderer
|
||||||
myNTSCFilter.enableThreading(myOSystem.settings().getBool("threads"));
|
myNTSCFilter.enableThreading(myOSystem.settings().getBool("threads"));
|
||||||
|
@ -216,7 +216,7 @@ void TIASurface::enablePhosphor(bool enable, int blend)
|
||||||
myPhosphorPercent = blend / 100.0f;
|
myPhosphorPercent = blend / 100.0f;
|
||||||
myFilter = Filter(enable ? uInt8(myFilter) | 0x01 : uInt8(myFilter) & 0x10);
|
myFilter = Filter(enable ? uInt8(myFilter) | 0x01 : uInt8(myFilter) & 0x10);
|
||||||
|
|
||||||
memset(myRGBFramebuffer, 0, sizeof(myRGBFramebuffer));
|
myRGBFramebuffer.fill(0);
|
||||||
|
|
||||||
// Precalculate the average colors for the 'phosphor' effect
|
// Precalculate the average colors for the 'phosphor' effect
|
||||||
if(myUsePhosphor)
|
if(myUsePhosphor)
|
||||||
|
@ -266,7 +266,7 @@ void TIASurface::enableNTSC(bool enable)
|
||||||
sl_attr.blendalpha = myOSystem.settings().getInt("tv.scanlines");
|
sl_attr.blendalpha = myOSystem.settings().getInt("tv.scanlines");
|
||||||
mySLineSurface->applyAttributes();
|
mySLineSurface->applyAttributes();
|
||||||
|
|
||||||
memset(myRGBFramebuffer, 0, sizeof(myRGBFramebuffer));
|
myRGBFramebuffer.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -317,8 +317,7 @@ inline uInt32 TIASurface::averageBuffers(uInt32 bufOfs)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void TIASurface::render()
|
void TIASurface::render()
|
||||||
{
|
{
|
||||||
uInt32 width = myTIA->width();
|
uInt32 width = myTIA->width(), height = myTIA->height();
|
||||||
uInt32 height = myTIA->height();
|
|
||||||
|
|
||||||
uInt32 *out, outPitch;
|
uInt32 *out, outPitch;
|
||||||
myTiaSurface->basePtr(out, outPitch);
|
myTiaSurface->basePtr(out, outPitch);
|
||||||
|
@ -346,10 +345,11 @@ void TIASurface::render()
|
||||||
case Filter::Phosphor:
|
case Filter::Phosphor:
|
||||||
{
|
{
|
||||||
uInt8* tiaIn = myTIA->frameBuffer();
|
uInt8* tiaIn = myTIA->frameBuffer();
|
||||||
uInt32* rgbIn = myRGBFramebuffer;
|
uInt32* rgbIn = myRGBFramebuffer.data();
|
||||||
|
|
||||||
if (mySaveSnapFlag)
|
if (mySaveSnapFlag)
|
||||||
memcpy(myPrevRGBFramebuffer, myRGBFramebuffer, width * height * sizeof(uInt32));
|
std::copy_n(myRGBFramebuffer.begin(), width * height,
|
||||||
|
myPrevRGBFramebuffer.begin());
|
||||||
|
|
||||||
uInt32 bufofs = 0, screenofsY = 0, pos;
|
uInt32 bufofs = 0, screenofsY = 0, pos;
|
||||||
for(uInt32 y = height; y ; --y)
|
for(uInt32 y = height; y ; --y)
|
||||||
|
@ -377,9 +377,10 @@ void TIASurface::render()
|
||||||
case Filter::BlarggPhosphor:
|
case Filter::BlarggPhosphor:
|
||||||
{
|
{
|
||||||
if(mySaveSnapFlag)
|
if(mySaveSnapFlag)
|
||||||
memcpy(myPrevRGBFramebuffer, myRGBFramebuffer, height * outPitch * sizeof(uInt32));
|
std::copy_n(myRGBFramebuffer.begin(), height * outPitch,
|
||||||
|
myPrevRGBFramebuffer.begin());
|
||||||
|
|
||||||
myNTSCFilter.render(myTIA->frameBuffer(), width, height, out, outPitch << 2, myRGBFramebuffer);
|
myNTSCFilter.render(myTIA->frameBuffer(), width, height, out, outPitch << 2, myRGBFramebuffer.data());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,10 +185,10 @@ class TIASurface
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// Phosphor mode items (aka reduced flicker on 30Hz screens)
|
// Phosphor mode items (aka reduced flicker on 30Hz screens)
|
||||||
// RGB frame buffer
|
// RGB frame buffer
|
||||||
uInt32 myRGBFramebuffer[AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
|
std::array<uInt32, AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
|
||||||
TIAConstants::frameBufferHeight];
|
TIAConstants::frameBufferHeight> myRGBFramebuffer;
|
||||||
uInt32 myPrevRGBFramebuffer[AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
|
std::array<uInt32, AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
|
||||||
TIAConstants::frameBufferHeight];
|
TIAConstants::frameBufferHeight> myPrevRGBFramebuffer;
|
||||||
|
|
||||||
// Use phosphor effect
|
// Use phosphor effect
|
||||||
bool myUsePhosphor;
|
bool myUsePhosphor;
|
||||||
|
|
|
@ -52,7 +52,7 @@ class DelayQueue : public Serializable
|
||||||
private:
|
private:
|
||||||
DelayQueueMember<capacity> myMembers[length];
|
DelayQueueMember<capacity> myMembers[length];
|
||||||
uInt8 myIndex;
|
uInt8 myIndex;
|
||||||
uInt8 myIndices[0xFF];
|
std::array<uInt8, 0xFF> myIndices;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DelayQueue(const DelayQueue&) = delete;
|
DelayQueue(const DelayQueue&) = delete;
|
||||||
|
@ -70,7 +70,7 @@ template<unsigned length, unsigned capacity>
|
||||||
DelayQueue<length, capacity>::DelayQueue()
|
DelayQueue<length, capacity>::DelayQueue()
|
||||||
: myIndex(0)
|
: myIndex(0)
|
||||||
{
|
{
|
||||||
memset(myIndices, 0xFF, 0xFF);
|
myIndices.fill(0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -99,7 +99,7 @@ void DelayQueue<length, capacity>::reset()
|
||||||
myMembers[i].clear();
|
myMembers[i].clear();
|
||||||
|
|
||||||
myIndex = 0;
|
myIndex = 0;
|
||||||
memset(myIndices, 0xFF, 0xFF);
|
myIndices.fill(0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -131,7 +131,7 @@ bool DelayQueue<length, capacity>::save(Serializer& out) const
|
||||||
myMembers[i].save(out);
|
myMembers[i].save(out);
|
||||||
|
|
||||||
out.putByte(myIndex);
|
out.putByte(myIndex);
|
||||||
out.putByteArray(myIndices, 0xFF);
|
out.putByteArray(myIndices.data(), myIndices.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ bool DelayQueue<length, capacity>::load(Serializer& in)
|
||||||
myMembers[i].load(in);
|
myMembers[i].load(in);
|
||||||
|
|
||||||
myIndex = in.getByte();
|
myIndex = in.getByte();
|
||||||
in.getByteArray(myIndices, 0xFF);
|
in.getByteArray(myIndices.data(), myIndices.size());
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue