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:
Stephen Anthony 2019-09-16 19:46:15 -02:30
parent a1fa3a57ba
commit 354d5aa35a
102 changed files with 758 additions and 702 deletions

View File

@ -23,7 +23,7 @@ ConvolutionBuffer::ConvolutionBuffer(uInt32 size)
mySize(size)
{
myData = make_unique<float[]>(mySize);
memset(myData.get(), 0, mySize * sizeof(float));
std::fill_n(myData.get(), mySize, 0.f);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -141,7 +141,7 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
}
if (!myCurrentFragment) {
memset(fragment, 0, sizeof(float) * length);
std::fill_n(fragment, length, 0.f);
return;
}

View File

@ -44,7 +44,7 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length)
}
if (!myCurrentFragment) {
memset(fragment, 0, sizeof(float) * length);
std::fill_n(fragment, length, 0.f);
return;
}

View File

@ -74,7 +74,6 @@ using std::make_shared;
using std::array;
using std::vector;
using std::runtime_error;
using std::memcpy;
// Common array types
using IntArray = std::vector<Int32>;
@ -85,6 +84,12 @@ using ShortArray = std::vector<uInt16>;
using StringList = std::vector<std::string>;
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("");
// This is defined by some systems, but Stella has other uses for it

View File

@ -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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -257,6 +257,8 @@ class CartDebug : public DebuggerSystem
using LabelToAddr = std::map<string, uInt16,
std::function<bool(const string&, const string&)>>;
using AddrTypeArray = std::array<uInt8, 0x1000>;
struct DirectiveTag {
DisasmType type;
uInt16 start;
@ -277,7 +279,7 @@ class CartDebug : public DebuggerSystem
};
// Address type information determined by Distella
uInt8 myDisLabels[0x1000], myDisDirectives[0x1000];
AddrTypeArray myDisLabels, myDisDirectives;
// Information on equates used in the disassembly
struct ReservedEquates {

View File

@ -23,7 +23,8 @@ using Common::Base;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
CartDebug::BankInfo& info, const DiStella::Settings& s,
uInt8* labels, uInt8* directives,
CartDebug::AddrTypeArray& labels,
CartDebug::AddrTypeArray& directives,
CartDebug::ReservedEquates& reserved)
: myDbg(dbg),
myList(list),
@ -57,8 +58,8 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
}
myAppData.length = info.size;
memset(myLabels, 0, 0x1000);
memset(myDirectives, 0, 0x1000);
myLabels.fill(0);
myDirectives.fill(0);
// Process any directives first, as they override automatic code determination
processDirectives(info.directiveList);

View File

@ -67,7 +67,8 @@ class DiStella
*/
DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
CartDebug::BankInfo& info, const DiStella::Settings& settings,
uInt8* labels, uInt8* directives,
CartDebug::AddrTypeArray& labels,
CartDebug::AddrTypeArray& directives,
CartDebug::ReservedEquates& reserved);
private:
@ -136,7 +137,8 @@ class DiStella
the directives take priority
The address mark type is defined in CartDebug.hxx
*/
uInt8 *myLabels, *myDirectives;
CartDebug::AddrTypeArray& myLabels;
CartDebug::AddrTypeArray& myDirectives;
/**
Enumeration of the 6502 addressing modes

View File

@ -22,38 +22,38 @@
class TrapArray
{
public:
TrapArray() : myInitialized(false) {}
public:
TrapArray() : myInitialized(false) {}
bool isSet(const uInt16 address) const { return myCount[address]; }
bool isClear(const uInt16 address) const { return myCount[address] == 0; }
bool isSet(const uInt16 address) const { return myCount[address]; }
bool isClear(const uInt16 address) const { return myCount[address] == 0; }
void add(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 add(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 initialize() {
if(!myInitialized)
memset(myCount, 0, sizeof(myCount));
myInitialized = true;
}
void clearAll() { myInitialized = false; memset(myCount, 0, sizeof(myCount)); }
void initialize() {
if(!myInitialized)
myCount.fill(0);
myInitialized = true;
}
void clearAll() { myInitialized = false; myCount.fill(0); }
bool isInitialized() const { return myInitialized; }
bool isInitialized() const { return myInitialized; }
private:
// The actual counts
uInt8 myCount[0x10000];
private:
// The actual counts
std::array<uInt8, 0x10000> myCount;
// Indicates whether we should treat this array as initialized
bool myInitialized;
// Indicates whether we should treat this array as initialized
bool myInitialized;
private:
// Following constructors and assignment operators not supported
TrapArray(const TrapArray&) = delete;
TrapArray(TrapArray&&) = delete;
TrapArray& operator=(const TrapArray&) = delete;
TrapArray& operator=(TrapArray&&) = delete;
private:
// Following constructors and assignment operators not supported
TrapArray(const TrapArray&) = delete;
TrapArray(TrapArray&&) = delete;
TrapArray& operator=(const TrapArray&) = delete;
TrapArray& operator=(TrapArray&&) = delete;
};
#endif

View File

@ -123,7 +123,7 @@ void Cartridge::createCodeAccessBase(uInt32 size)
{
#ifdef DEBUGGER_SUPPORT
myCodeAccessBase = make_unique<uInt8[]>(size);
memset(myCodeAccessBase.get(), CartDebug::ROW, size);
std::fill_n(myCodeAccessBase.get(), size, CartDebug::ROW);
#else
myCodeAccessBase = nullptr;
#endif
@ -136,7 +136,7 @@ void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const
for(uInt32 i = 0; i < size; ++i)
arr[i] = mySystem->randGenerator().next();
else
memset(arr, val, size);
std::fill_n(arr, size, val);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -153,17 +153,14 @@ class Cartridge : public Device
virtual bool bank(uInt16) { return false; }
/**
Get the current bank. Carts which have only one bank (either real
or virtual) always report that bank as zero.
*/
virtual uInt16 getBank() const { return 0; }
Get the current bank for the provided address. Carts which have only
one bank (either real or virtual) always report that bank as zero.
/**
Get the current bank for the provided address.
@param addr The address to get the bank for
@param address Query the bank used for this specific address
Derived classes are free to ignore this; it only
makes sense in some situations.
*/
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

View File

@ -25,8 +25,8 @@ Cartridge0840::Cartridge0840(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(8192u, size));
createCodeAccessBase(8192);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -145,7 +145,7 @@ bool Cartridge0840::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Cartridge0840::getBank() const
uInt16 Cartridge0840::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -166,8 +166,8 @@ bool Cartridge0840::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* Cartridge0840::getImage(uInt32& size) const
{
size = 8192;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -72,8 +72,10 @@ class Cartridge0840 : public Cartridge
/**
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.
@ -151,13 +153,13 @@ class Cartridge0840 : public Cartridge
private:
// 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)
uInt16 myBankOffset;
// Previous Device's page access
System::PageAccess myHotSpotPageAccess[8];
std::array<System::PageAccess, 8> myHotSpotPageAccess;
private:
// Following constructors and assignment operators not supported

View File

@ -24,7 +24,7 @@ Cartridge2K::Cartridge2K(const ByteBuffer& image, uInt32 size,
: Cartridge(settings, md5)
{
// 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
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
myImage = make_unique<uInt8[]>(mySize);
memset(myImage.get(), 0x02, mySize);
std::fill_n(myImage.get(), mySize, 0x02);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), size);
std::copy_n(image.get(), size, myImage.get());
createCodeAccessBase(mySize);
// Set mask for accessing the image buffer

View File

@ -30,14 +30,14 @@ Cartridge3E::Cartridge3E(const ByteBuffer& image, uInt32 size,
myImage = make_unique<uInt8[]>(mySize);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), mySize);
createCodeAccessBase(mySize + 32768);
std::copy_n(image.get(), mySize, myImage.get());
createCodeAccessBase(mySize + myRAM.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3E::reset()
{
initializeRAM(myRAM, 32768);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(0);
// 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
else
return myCurrentBank;
@ -248,7 +248,7 @@ bool Cartridge3E::save(Serializer& out) const
try
{
out.putShort(myCurrentBank);
out.putByteArray(myRAM, 32768);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -265,7 +265,7 @@ bool Cartridge3E::load(Serializer& in)
try
{
myCurrentBank = in.getShort();
in.getByteArray(myRAM, 32768);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -101,8 +101,10 @@ class Cartridge3E : public Cartridge
/**
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.
@ -183,7 +185,7 @@ class Cartridge3E : public Cartridge
ByteBuffer myImage;
// 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
uInt32 mySize;

View File

@ -29,14 +29,14 @@ Cartridge3EPlus::Cartridge3EPlus(const ByteBuffer& image, uInt32 size,
myImage = make_unique<uInt8[]>(mySize);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), mySize);
createCodeAccessBase(mySize + RAM_TOTAL_SIZE);
std::copy_n(image.get(), mySize, myImage.get());
createCodeAccessBase(mySize + myRAM.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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).
// Set this to go to 3rd 1K Bank.
@ -44,8 +44,8 @@ void Cartridge3EPlus::reset()
// Initialise bank values for all ROM/RAM access
// This is used to reverse-lookup from address to bank location
for(uInt32 b = 0; b < 8; ++b)
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
for(auto& b: bankInUse)
b = BANK_UNDEFINED; // bank is undefined and inaccessible!
initializeBankState();
@ -67,8 +67,8 @@ void Cartridge3EPlus::install(System& system)
// Initialise bank values for all ROM/RAM access
// This is used to reverse-lookup from address to bank location
for(uInt32 b = 0; b < 8; ++b)
bankInUse[b] = BANK_UNDEFINED; // bank is undefined and inaccessible!
for(auto& b: bankInUse)
b = BANK_UNDEFINED; // bank is undefined and inaccessible!
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
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Cartridge3EPlus::peek(uInt16 address)
{
@ -319,8 +318,8 @@ bool Cartridge3EPlus::save(Serializer& out) const
{
try
{
out.putShortArray(bankInUse, 8);
out.putByteArray(myRAM, RAM_TOTAL_SIZE);
out.putShortArray(bankInUse.data(), bankInUse.size());
out.putByteArray(myRAM.data(), myRAM.size());
}
catch (...)
{
@ -335,8 +334,8 @@ bool Cartridge3EPlus::load(Serializer& in)
{
try
{
in.getShortArray(bankInUse, 8);
in.getByteArray(myRAM, RAM_TOTAL_SIZE);
in.getShortArray(bankInUse.data(), bankInUse.size());
in.getByteArray(myRAM.data(), myRAM.size());
}
catch (...)
{

View File

@ -72,8 +72,10 @@ class Cartridge3EPlus: public Cartridge
/**
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.
@ -164,7 +166,7 @@ class Cartridge3EPlus: public Cartridge
// 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
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_ROM = 0x3F; // writes to this address cause bankswitching
@ -188,9 +190,9 @@ class Cartridge3EPlus: public Cartridge
static constexpr uInt16 RAM_WRITE_OFFSET = 0x200;
ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge
uInt32 mySize; // Size of the ROM image
uInt8 myRAM[RAM_TOTAL_SIZE];
ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge
uInt32 mySize; // Size of the ROM image
std::array<uInt8, RAM_TOTAL_SIZE> myRAM;
private:
// Following constructors and assignment operators not supported

View File

@ -30,7 +30,7 @@ Cartridge3F::Cartridge3F(const ByteBuffer& image, uInt32 size,
myImage = make_unique<uInt8[]>(mySize);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), mySize);
std::copy_n(image.get(), mySize, myImage.get());
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
else
return myCurrentBank;

View File

@ -78,8 +78,10 @@ class Cartridge3F : public Cartridge
/**
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.

View File

@ -36,11 +36,11 @@ Cartridge4A50::Cartridge4A50(const ByteBuffer& image, uInt32 size,
{
// Copy the ROM image into my buffer
// Supported file sizes are 32/64/128K, which are duplicated if necessary
if(size < 65536) size = 32768;
else if(size < 131072) size = 65536;
else size = 131072;
for(uInt32 slice = 0; slice < 131072 / size; ++slice)
memcpy(myImage + (slice*size), image.get(), size);
if(size < 64_KB) size = 32_KB;
else if(size < 128_KB) size = 64_KB;
else size = 128_KB;
for(uInt32 slice = 0; slice < 128_KB / size; ++slice)
std::copy_n(image.get(), size, myImage.begin() + (slice*size));
// We use System::PageAccess.codeAccessBase, but don't allow its use
// 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
// methods below
createCodeAccessBase(131072 + 32768);
createCodeAccessBase(myImage.size() + myRAM.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4A50::reset()
{
initializeRAM(myRAM, 32768);
initializeRAM(myRAM.data(), myRAM.size());
mySliceLow = mySliceMiddle = mySliceHigh = 0;
myIsRomLow = myIsRomMiddle = myIsRomHigh = true;
@ -359,7 +359,7 @@ bool Cartridge4A50::patch(uInt16 address, uInt8 value)
const uInt8* Cartridge4A50::getImage(uInt32& size) const
{
size = mySize;
return myImage;
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -368,7 +368,7 @@ bool Cartridge4A50::save(Serializer& out) const
try
{
// The 32K bytes of RAM
out.putByteArray(myRAM, 32768);
out.putByteArray(myRAM.data(), myRAM.size());
// Index pointers
out.putShort(mySliceLow);
@ -398,7 +398,7 @@ bool Cartridge4A50::load(Serializer& in)
{
try
{
in.getByteArray(myRAM, 32768);
in.getByteArray(myRAM.data(), myRAM.size());
// Index pointers
mySliceLow = in.getShort();

View File

@ -219,10 +219,10 @@ class Cartridge4A50 : public Cartridge
private:
// The 128K ROM image of the cartridge
uInt8 myImage[131072];
std::array<uInt8, 128_KB> myImage;
// The 32K of RAM on the cartridge
uInt8 myRAM[32768];
std::array<uInt8, 32_KB> myRAM;
// (Actual) Size of the ROM image
uInt32 mySize;

View File

@ -24,8 +24,8 @@ Cartridge4K::Cartridge4K(const ByteBuffer& image, uInt32 size,
: Cartridge(settings, md5)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(4096u, size));
createCodeAccessBase(4096);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -61,8 +61,8 @@ bool Cartridge4K::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* Cartridge4K::getImage(uInt32& size) const
{
size = 4096;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -124,7 +124,7 @@ class Cartridge4K : public Cartridge
private:
// The 4K ROM image for the cartridge
uInt8 myImage[4096];
std::array<uInt8, 4_KB> myImage;
private:
// Following constructors and assignment operators not supported

View File

@ -24,14 +24,14 @@ Cartridge4KSC::Cartridge4KSC(const ByteBuffer& image, uInt32 size,
: Cartridge(settings, md5)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(4096u, size));
createCodeAccessBase(4096);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge4KSC::reset()
{
initializeRAM(myRAM, 128);
initializeRAM(myRAM.data(), myRAM.size());
myBankChanged = true;
}
@ -120,8 +120,8 @@ bool Cartridge4KSC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* Cartridge4KSC::getImage(uInt32& size) const
{
size = 4096;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -129,7 +129,7 @@ bool Cartridge4KSC::save(Serializer& out) const
{
try
{
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -145,7 +145,7 @@ bool Cartridge4KSC::load(Serializer& in)
{
try
{
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -133,10 +133,10 @@ class Cartridge4KSC : public Cartridge
private:
// The 4K ROM image of the cartridge
uInt8 myImage[4096];
std::array<uInt8, 4_KB> myImage;
// The 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
private:
// Following constructors and assignment operators not supported

View File

@ -34,11 +34,11 @@ CartridgeAR::CartridgeAR(const ByteBuffer& image, uInt32 size,
// Create a load image buffer and copy the given image
myLoadImages = make_unique<uInt8[]>(mySize);
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
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
// through a pointer, since the AR scheme doesn't support bankswitching
@ -54,9 +54,9 @@ void CartridgeAR::reset()
{
// Initialize RAM
#if 0 // TODO - figure out actual behaviour of the real cart
initializeRAM(myImage, 6*1024);
initializeRAM(myImage.data(), myImage.size());
#else
memset(myImage, 0, 6 * 1024);
myImage.fill(0);
#endif
// Initialize SC BIOS ROM
@ -316,10 +316,10 @@ void CartridgeAR::initializeROM()
ourDummyROMCode[281] = mySystem->randGenerator().next();
// 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
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
myImage[(3<<11) + 2044] = 0x0A;
@ -348,16 +348,14 @@ void CartridgeAR::loadIntoRAM(uInt8 load)
for(image = 0; image < myNumberOfLoadImages; ++image)
{
// 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
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
if(checksum(myHeader, 8) != 0x55)
{
if(checksum(myHeader.data(), 8) != 0x55)
cerr << "WARNING: The Supercharger header checksum is invalid...\n";
}
// Load all of the pages from the load
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)
if(bank < 3)
{
memcpy(myImage + (bank * 2048) + (page * 256), src, 256);
}
std::copy_n(src, 256, myImage.data() + (bank * 2048) + (page * 256));
}
// 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;
}
@ -438,13 +434,13 @@ bool CartridgeAR::save(Serializer& out) const
try
{
// 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
out.putByteArray(myImage, 8192);
out.putByteArray(myImage.data(), myImage.size());
// 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
// Note that the size of this array is myNumberOfLoadImages * 8448
@ -483,13 +479,13 @@ bool CartridgeAR::load(Serializer& in)
try
{
// 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
in.getByteArray(myImage, 8192);
in.getByteArray(myImage.data(), myImage.size());
// 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
// 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,
0xff, 0xff, 0x78, 0xd8, 0xa0, 0x00, 0xa2, 0x00,
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,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,

View File

@ -79,8 +79,10 @@ class CartridgeAR : public Cartridge
/**
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.
@ -185,13 +187,13 @@ class CartridgeAR : public Cartridge
private:
// 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
uInt8 myImage[8192];
std::array<uInt8, 8_KB> myImage;
// The 256 byte header for the current 8448 byte load
uInt8 myHeader[256];
std::array<uInt8, 256> myHeader;
// Size of the ROM image
uInt32 mySize;
@ -221,11 +223,11 @@ class CartridgeAR : public Cartridge
uInt16 myCurrentBank;
// 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
// This data comes from z26
static const uInt8 ourDefaultHeader[256];
static const std::array<uInt8, 256> ourDefaultHeader;
private:
// Following constructors and assignment operators not supported

View File

@ -25,8 +25,8 @@ CartridgeBF::CartridgeBF(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(262144u, size));
createCodeAccessBase(262144);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -105,7 +105,7 @@ bool CartridgeBF::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeBF::getBank() const
uInt16 CartridgeBF::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -126,8 +126,8 @@ bool CartridgeBF::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeBF::getImage(uInt32& size) const
{
size = 64 * 4096;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -73,8 +73,10 @@ class CartridgeBF : public Cartridge
/**
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.
@ -152,7 +154,7 @@ class CartridgeBF : public Cartridge
private:
// 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)
uInt32 myBankOffset;

View File

@ -25,14 +25,14 @@ CartridgeBFSC::CartridgeBFSC(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(262144u, size));
createCodeAccessBase(262144);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBFSC::reset()
{
initializeRAM(myRAM, 128);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(15);
// 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;
}
@ -176,8 +176,8 @@ bool CartridgeBFSC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeBFSC::getImage(uInt32& size) const
{
size = 64 * 4096;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -186,7 +186,7 @@ bool CartridgeBFSC::save(Serializer& out) const
try
{
out.putInt(myBankOffset);
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -203,7 +203,7 @@ bool CartridgeBFSC::load(Serializer& in)
try
{
myBankOffset = in.getInt();
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -73,8 +73,10 @@ class CartridgeBFSC : public Cartridge
/**
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.
@ -152,10 +154,10 @@ class CartridgeBFSC : public Cartridge
private:
// The 256K ROM image of the cartridge
uInt8 myImage[64 * 4096];
std::array<uInt8, 256_KB> myImage;
// The 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
// Indicates the offset into the ROM image (aligns to current bank)
uInt32 myBankOffset;

View File

@ -49,25 +49,27 @@ CartridgeBUS::CartridgeBUS(const ByteBuffer& image, uInt32 size,
myFractionalClocks(0.0)
{
// 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
createCodeAccessBase(4096 * 7);
// Even though the ROM is 32K, only 28K is accessible to the 6507
createCodeAccessBase(28_KB);
// Pointer to the program ROM (28K @ 0 byte offset)
// 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
myBusDriverImage = myBUSRAM;
myBusDriverImage = myBUSRAM.data();
// Pointer to the display RAM
myDisplayImage = myBUSRAM + DSRAM;
myDisplayImage = myBUSRAM.data() + DSRAM;
// Create Thumbulator ARM emulator
bool devSettings = settings.getBool("dev.settings");
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
);
@ -77,7 +79,7 @@ CartridgeBUS::CartridgeBUS(const ByteBuffer& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUS::reset()
{
initializeRAM(myBUSRAM+2048, 8192-2048);
initializeRAM(myBUSRAM.data() + 2_KB, 6_KB);
// BUS always starts in bank 6
initializeStartBank(6);
@ -96,10 +98,9 @@ void CartridgeBUS::reset()
void CartridgeBUS::setInitialState()
{
// 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[i] = 27;
myMusicWaveformSize.fill(27);
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
// 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;
}
@ -478,8 +479,8 @@ bool CartridgeBUS::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeBUS::getImage(uInt32& size) const
{
size = 32768;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -547,7 +548,7 @@ bool CartridgeBUS::save(Serializer& out) const
out.putShort(myBankOffset);
// Harmony RAM
out.putByteArray(myBUSRAM, 8192);
out.putByteArray(myBUSRAM.data(), myBUSRAM.size());
// Addresses for bus override logic
out.putShort(myBusOverdriveAddress);
@ -560,9 +561,9 @@ bool CartridgeBUS::save(Serializer& out) const
out.putLong(myARMCycles);
// Audio info
out.putIntArray(myMusicCounters, 3);
out.putIntArray(myMusicFrequencies, 3);
out.putByteArray(myMusicWaveformSize, 3);
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
out.putByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
// Indicates current mode
out.putByte(myMode);
@ -588,7 +589,7 @@ bool CartridgeBUS::load(Serializer& in)
myBankOffset = in.getShort();
// Harmony RAM
in.getByteArray(myBUSRAM, 8192);
in.getByteArray(myBUSRAM.data(), myBUSRAM.size());
// Addresses for bus override logic
myBusOverdriveAddress = in.getShort();
@ -601,9 +602,9 @@ bool CartridgeBUS::load(Serializer& in)
myARMCycles = in.getLong();
// Audio info
in.getIntArray(myMusicCounters, 3);
in.getIntArray(myMusicFrequencies, 3);
in.getByteArray(myMusicWaveformSize, 3);
in.getIntArray(myMusicCounters.data(), myMusicCounters.size());
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
in.getByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
// Indicates current mode
myMode = in.getByte();

View File

@ -90,8 +90,10 @@ class CartridgeBUS : public Cartridge
/**
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.
@ -209,7 +211,7 @@ class CartridgeBUS : public Cartridge
private:
// 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
uInt8* myProgramImage;
@ -224,7 +226,7 @@ class CartridgeBUS : public Cartridge
// $0000 - 2K BUS driver
// $0800 - 4K Display Data
// $1800 - 2K C Variable & Stack
uInt8 myBUSRAM[8192];
std::array<uInt8, 8_KB> myBUSRAM;
// Pointer to the Thumb ARM emulator object
unique_ptr<Thumbulator> myThumbEmulator;
@ -249,13 +251,13 @@ class CartridgeBUS : public Cartridge
uInt64 myARMCycles;
// The music mode counters
uInt32 myMusicCounters[3];
std::array<uInt32, 3> myMusicCounters;
// The music frequency
uInt32 myMusicFrequencies[3];
std::array<uInt32, 3> myMusicFrequencies;
// The music waveform sizes
uInt8 myMusicWaveformSize[3];
std::array<uInt8, 3> myMusicWaveformSize;
// Fractional DPC music OSC clocks unused during the last update
double myFractionalClocks;

View File

@ -65,27 +65,29 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, uInt32 size,
myFractionalClocks(0.0)
{
// 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
createCodeAccessBase(4096 * 7);
// Pointer to the program ROM (28K @ 0 byte offset)
// which starts after the 2K CDF Driver and 2K C Code
myProgramImage = myImage + 4096;
myProgramImage = myImage.data() + 4096;
// Pointer to CDF driver in RAM
myBusDriverImage = myCDFRAM;
myBusDriverImage = myCDFRAM.data();
// Pointer to the display RAM
myDisplayImage = myCDFRAM + DSRAM;
myDisplayImage = myCDFRAM.data() + DSRAM;
setupVersion();
// Create Thumbulator ARM emulator
bool devSettings = settings.getBool("dev.settings");
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);
setInitialState();
@ -94,7 +96,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, uInt32 size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDF::reset()
{
initializeRAM(myCDFRAM+2048, 8192-2048);
initializeRAM(myCDFRAM.data()+2048, myCDFRAM.size()-2048);
// CDF always starts in bank 6
initializeStartBank(6);
@ -112,10 +114,9 @@ void CartridgeCDF::reset()
void CartridgeCDF::setInitialState()
{
// 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[i] = 27;
myMusicWaveformSize.fill(27);
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
// 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;
}
@ -450,12 +451,11 @@ bool CartridgeCDF::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeCDF::getImage(uInt32& size) const
{
size = 32768;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
{
switch (function)
@ -484,7 +484,6 @@ uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2)
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeCDF::save(Serializer& out) const
{
@ -504,12 +503,12 @@ bool CartridgeCDF::save(Serializer& out) const
out.putShort(myJMPoperandAddress);
// Harmony RAM
out.putByteArray(myCDFRAM, 8192);
out.putByteArray(myCDFRAM.data(), myCDFRAM.size());
// Audio info
out.putIntArray(myMusicCounters, 3);
out.putIntArray(myMusicFrequencies, 3);
out.putByteArray(myMusicWaveformSize, 3);
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
out.putByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
// Save cycles and clocks
out.putLong(myAudioCycles);
@ -544,12 +543,12 @@ bool CartridgeCDF::load(Serializer& in)
myJMPoperandAddress = in.getShort();
// Harmony RAM
in.getByteArray(myCDFRAM, 8192);
in.getByteArray(myCDFRAM.data(), myCDFRAM.size());
// Audio info
in.getIntArray(myMusicCounters, 3);
in.getIntArray(myMusicFrequencies, 3);
in.getByteArray(myMusicWaveformSize, 3);
in.getIntArray(myMusicCounters.data(), myMusicCounters.size());
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
in.getByteArray(myMusicWaveformSize.data(), myMusicWaveformSize.size());
// Get cycles and clocks
myAudioCycles = in.getLong();
@ -604,13 +603,12 @@ uInt32 CartridgeCDF::getDatastreamIncrement(uInt8 index) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeCDF::getWaveform(uInt8 index) const
{
uInt32 result;
uInt16 address = myWaveformBase + index * 4;
result = myCDFRAM[address + 0] + // low byte
(myCDFRAM[address + 1] << 8) +
(myCDFRAM[address + 2] << 16) +
(myCDFRAM[address + 3] << 24); // high byte
uInt32 result = myCDFRAM[address + 0] + // low byte
(myCDFRAM[address + 1] << 8) +
(myCDFRAM[address + 2] << 16) +
(myCDFRAM[address + 3] << 24); // high byte
result -= (0x40000000 + DSRAM);
@ -623,13 +621,12 @@ uInt32 CartridgeCDF::getWaveform(uInt8 index) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeCDF::getSample()
{
uInt32 result;
uInt16 address = myWaveformBase;
result = myCDFRAM[address + 0] + // low byte
(myCDFRAM[address + 1] << 8) +
(myCDFRAM[address + 2] << 16) +
(myCDFRAM[address + 3] << 24); // high byte
uInt32 result = myCDFRAM[address + 0] + // low byte
(myCDFRAM[address + 1] << 8) +
(myCDFRAM[address + 2] << 16) +
(myCDFRAM[address + 3] << 24); // high byte
return result;
}

View File

@ -98,8 +98,10 @@ class CartridgeCDF : public Cartridge
/**
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.
@ -211,7 +213,7 @@ class CartridgeCDF : public Cartridge
private:
// 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
uInt8* myProgramImage;
@ -226,7 +228,7 @@ class CartridgeCDF : public Cartridge
// $0000 - 2K CDF driver
// $0800 - 4K Display Data
// $1800 - 2K C Variable & Stack
uInt8 myCDFRAM[8192];
std::array<uInt8, 8_KB> myCDFRAM;
// Pointer to the Thumb ARM emulator object
unique_ptr<Thumbulator> myThumbEmulator;
@ -257,13 +259,13 @@ class CartridgeCDF : public Cartridge
r14 = timer base */
// 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
uInt32 myMusicFrequencies[3];
std::array<uInt32, 3> myMusicFrequencies;
// The music waveform sizes
uInt8 myMusicWaveformSize[3];
std::array<uInt8, 3> myMusicWaveformSize;
// Fractional CDF music, OSC clocks unused during the last update
double myFractionalClocks;

View File

@ -28,14 +28,14 @@ CartridgeCM::CartridgeCM(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(16384u, size));
createCodeAccessBase(16384);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCM::reset()
{
initializeRAM(myRAM, 2048);
initializeRAM(myRAM.data(), myRAM.size());
// On powerup, the last bank of ROM is enabled and RAM is disabled
mySWCHA = 0xFF;
@ -153,7 +153,7 @@ bool CartridgeCM::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeCM::getBank() const
uInt16 CartridgeCM::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -182,8 +182,8 @@ bool CartridgeCM::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeCM::getImage(uInt32& size) const
{
size = 16384;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -194,7 +194,7 @@ bool CartridgeCM::save(Serializer& out) const
out.putShort(myBankOffset);
out.putByte(mySWCHA);
out.putByte(myCompuMate->column());
out.putByteArray(myRAM, 2048);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -213,7 +213,7 @@ bool CartridgeCM::load(Serializer& in)
myBankOffset = in.getShort();
mySWCHA = in.getByte();
myCompuMate->column() = in.getByte();
in.getByteArray(myRAM, 2048);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -147,8 +147,10 @@ class CartridgeCM : public Cartridge
/**
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.
@ -241,10 +243,10 @@ class CartridgeCM : public Cartridge
shared_ptr<CompuMate> myCompuMate;
// The 16K ROM image of the cartridge
uInt8 myImage[16384];
std::array<uInt8, 16_KB> myImage;
// The 2K of RAM
uInt8 myRAM[2048];
std::array<uInt8, 2_KB> myRAM;
// Current copy of SWCHA (controls ROM/RAM accesses)
uInt8 mySWCHA;

View File

@ -35,27 +35,27 @@ CartridgeCTY::CartridgeCTY(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(32768u, size));
createCodeAccessBase(32768);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
// 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
if(size > 32768u)
memcpy(myTuneData, image.get() + 32768u, size - 32768u);
if(size > myImage.size())
std::copy_n(image.get() + myImage.size(), size - myImage.size(), myTuneData.begin());
// Point to the first tune
myFrequencyImage = myTuneData;
myFrequencyImage = myTuneData.data();
for(uInt8 i = 0; i < 3; ++i)
myMusicCounters[i] = myMusicFrequencies[i] = 0;
myMusicCounters.fill(0);
myMusicFrequencies.fill(0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCTY::reset()
{
initializeRAM(myRAM, 64);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(1);
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;
}
@ -287,8 +287,8 @@ bool CartridgeCTY::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeCTY::getImage(uInt32& size) const
{
size = 32768;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -297,7 +297,7 @@ bool CartridgeCTY::save(Serializer& out) const
try
{
out.putShort(getBank());
out.putByteArray(myRAM, 64);
out.putByteArray(myRAM.data(), myRAM.size());
out.putByte(myOperationType);
out.putShort(myTunePosition);
@ -305,9 +305,9 @@ bool CartridgeCTY::save(Serializer& out) const
out.putInt(myRandomNumber);
out.putLong(myAudioCycles);
out.putDouble(myFractionalClocks);
out.putIntArray(myMusicCounters, 3);
out.putIntArray(myMusicFrequencies, 3);
out.putLong(myFrequencyImage - myTuneData);
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
out.putLong(myFrequencyImage - myTuneData.data()); // FIXME - storing pointer diff!
}
catch(...)
{
@ -325,7 +325,7 @@ bool CartridgeCTY::load(Serializer& in)
{
// Remember what bank we were in
bank(in.getShort());
in.getByteArray(myRAM, 64);
in.getByteArray(myRAM.data(), myRAM.size());
myOperationType = in.getByte();
myTunePosition = in.getShort();
@ -333,9 +333,9 @@ bool CartridgeCTY::load(Serializer& in)
myRandomNumber = in.getInt();
myAudioCycles = in.getLong();
myFractionalClocks = in.getDouble();
in.getIntArray(myMusicCounters, 3);
in.getIntArray(myMusicFrequencies, 3);
myFrequencyImage = myTuneData + in.getLong();
in.getIntArray(myMusicCounters.data(), myMusicCounters.size());
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
myFrequencyImage = myTuneData.data() + in.getLong();
}
catch(...)
{
@ -437,7 +437,7 @@ void CartridgeCTY::loadTune(uInt8 index)
// Each tune is offset by 4096 bytes
// Instead of copying non-modifiable data around (as would happen on the
// Harmony), we simply point to the appropriate tune
myFrequencyImage = myTuneData + (index << 12);
myFrequencyImage = myTuneData.data() + (index << 12);
// Reset to beginning of tune
myTunePosition = 0;
@ -501,17 +501,18 @@ void CartridgeCTY::loadScore(uInt8 index)
Serializer serializer(myEEPROMFile, Serializer::Mode::ReadOnly);
if(serializer)
{
uInt8 scoreRAM[256];
std::array<uInt8, 256> scoreRAM;
try
{
serializer.getByteArray(scoreRAM, 256);
serializer.getByteArray(scoreRAM.data(), scoreRAM.size());
}
catch(...)
{
memset(scoreRAM, 0, 256);
scoreRAM.fill(0);
}
// 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)
{
// Load score RAM
uInt8 scoreRAM[256];
std::array<uInt8, 256> scoreRAM;
try
{
serializer.getByteArray(scoreRAM, 256);
serializer.getByteArray(scoreRAM.data(), scoreRAM.size());
}
catch(...)
{
memset(scoreRAM, 0, 256);
scoreRAM.fill(0);
}
// 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
serializer.rewind();
try
{
serializer.putByteArray(scoreRAM, 256);
serializer.putByteArray(scoreRAM.data(), scoreRAM.size());
}
catch(...)
{
@ -556,11 +557,10 @@ void CartridgeCTY::wipeAllScores()
if(serializer)
{
// Erase score RAM
uInt8 scoreRAM[256];
memset(scoreRAM, 0, 256);
std::array<uInt8, 256> scoreRAM = {};
try
{
serializer.putByteArray(scoreRAM, 256);
serializer.putByteArray(scoreRAM.data(), scoreRAM.size());
}
catch(...)
{

View File

@ -145,8 +145,10 @@ class CartridgeCTY : public Cartridge
/**
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.
@ -258,13 +260,13 @@ class CartridgeCTY : public Cartridge
private:
// The 32K ROM image of the cartridge
uInt8 myImage[32768];
std::array<uInt8, 32_KB> myImage;
// 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
uInt8 myRAM[64];
std::array<uInt8, 64> myRAM;
// Operation type (written to $1000, used by hotspot $1FF4)
uInt8 myOperationType;
@ -277,10 +279,10 @@ class CartridgeCTY : public Cartridge
uInt16 myTunePosition;
// The music mode counters
uInt32 myMusicCounters[3];
std::array<uInt32, 3> myMusicCounters;
// The music frequency
uInt32 myMusicFrequencies[3];
std::array<uInt32, 3> myMusicFrequencies;
// Flags that last byte peeked was A9 (LDA #)
bool myLDAimmediate;

View File

@ -24,36 +24,35 @@ CartridgeCV::CartridgeCV(const ByteBuffer& image, uInt32 size,
: Cartridge(settings, md5),
mySize(size)
{
if(mySize == 2048)
if(mySize == myImage.size())
{
// 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
// Useful for MagiCard program listings
// 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()
myInitialRAM = make_unique<uInt8[]>(1024);
memcpy(myInitialRAM.get(), image.get(), 1024);
std::copy_n(image.get(), myInitialRAM.size(), myInitialRAM.begin());
}
createCodeAccessBase(2048+1024);
createCodeAccessBase(myImage.size() + myRAM.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCV::reset()
{
if(myInitialRAM)
if(mySize == 4_KB)
{
// Copy the RAM image into my buffer
memcpy(myRAM, myInitialRAM.get(), 1024);
myRAM = myInitialRAM;
}
else
initializeRAM(myRAM, 1024);
initializeRAM(myRAM.data(), myRAM.size());
myBankChanged = true;
}
@ -131,8 +130,8 @@ bool CartridgeCV::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeCV::getImage(uInt32& size) const
{
size = 2048;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -140,7 +139,7 @@ bool CartridgeCV::save(Serializer& out) const
{
try
{
out.putByteArray(myRAM, 1024);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -156,7 +155,7 @@ bool CartridgeCV::load(Serializer& in)
{
try
{
in.getByteArray(myRAM, 1024);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -136,18 +136,17 @@ class CartridgeCV : public Cartridge
bool poke(uInt16 address, uInt8 value) override;
private:
// Pointer to the initial RAM data from the cart
// This doesn't always exist, so we don't pre-allocate it
ByteBuffer myInitialRAM;
// The 2k ROM image for the cartridge
std::array<uInt8, 2048> myImage;
// Initial size of the cart data
uInt32 mySize;
// The 2k ROM image for the cartridge
uInt8 myImage[2048];
// 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:
// Following constructors and assignment operators not supported

View File

@ -30,14 +30,14 @@ CartridgeCVPlus::CartridgeCVPlus(const ByteBuffer& image, uInt32 size,
myImage = make_unique<uInt8[]>(mySize);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), mySize);
createCodeAccessBase(mySize + 1024);
std::copy_n(image.get(), mySize, myImage.get());
createCodeAccessBase(mySize + myRAM.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCVPlus::reset()
{
initializeRAM(myRAM, 1024);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(0);
// 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;
}
@ -187,7 +187,7 @@ bool CartridgeCVPlus::save(Serializer& out) const
try
{
out.putShort(myCurrentBank);
out.putByteArray(myRAM, 1024);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -204,7 +204,7 @@ bool CartridgeCVPlus::load(Serializer& in)
try
{
myCurrentBank = in.getShort();
in.getByteArray(myRAM, 1024);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -84,8 +84,10 @@ class CartridgeCVPlus : public Cartridge
/**
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.
@ -166,7 +168,7 @@ class CartridgeCVPlus : public Cartridge
ByteBuffer myImage;
// The 1024 bytes of RAM
uInt8 myRAM[1024];
std::array<uInt8, 1_KB> myRAM;
// Size of the ROM image
uInt32 mySize;

View File

@ -29,14 +29,14 @@ CartridgeDASH::CartridgeDASH(const ByteBuffer& image, uInt32 size,
myImage = make_unique<uInt8[]>(mySize);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), mySize);
createCodeAccessBase(mySize + RAM_TOTAL_SIZE);
std::copy_n(image.get(), mySize, myImage.get());
createCodeAccessBase(mySize + myRAM.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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).
// Set this to go to 3rd 1K Bank.
@ -311,9 +311,9 @@ bool CartridgeDASH::save(Serializer& out) const
{
try
{
out.putShortArray(bankInUse, 8);
out.putShortArray(segmentInUse, 4);
out.putByteArray(myRAM, RAM_TOTAL_SIZE);
out.putShortArray(bankInUse.data(), bankInUse.size());
out.putShortArray(segmentInUse.data(), segmentInUse.size());
out.putByteArray(myRAM.data(), myRAM.size());
}
catch (...)
{
@ -328,9 +328,9 @@ bool CartridgeDASH::load(Serializer& in)
{
try
{
in.getShortArray(bankInUse, 8);
in.getShortArray(segmentInUse, 4);
in.getByteArray(myRAM, RAM_TOTAL_SIZE);
in.getShortArray(bankInUse.data(), bankInUse.size());
in.getShortArray(segmentInUse.data(), segmentInUse.size());
in.getByteArray(myRAM.data(), myRAM.size());
}
catch (...)
{

View File

@ -236,8 +236,8 @@ class CartridgeDASH: public Cartridge
// 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
uInt16 bankInUse[8]; // 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, 8> bankInUse; // bank being used for ROM/RAM (eight 512 byte areas)
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_ROM = 0x3F; // writes to this address cause bankswitching
@ -262,8 +262,8 @@ class CartridgeDASH: public Cartridge
static constexpr uInt16 RAM_WRITE_OFFSET = 0x800;
ByteBuffer myImage; // Pointer to a dynamically allocated ROM image of the cartridge
uInt32 mySize; // Size of the ROM image
uInt8 myRAM[RAM_TOTAL_SIZE];
uInt32 mySize; // Size of the ROM image
std::array<uInt8, RAM_TOTAL_SIZE> myRAM;
private:
// Following constructors and assignment operators not supported

View File

@ -25,8 +25,8 @@ CartridgeDF::CartridgeDF(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(131072u, size));
createCodeAccessBase(131072);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -101,7 +101,7 @@ bool CartridgeDF::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDF::getBank() const
uInt16 CartridgeDF::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -122,8 +122,8 @@ bool CartridgeDF::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeDF::getImage(uInt32& size) const
{
size = 131072;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -73,8 +73,10 @@ class CartridgeDF : public Cartridge
/**
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.
@ -152,7 +154,7 @@ class CartridgeDF : public Cartridge
private:
// 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)
uInt32 myBankOffset;

View File

@ -25,14 +25,14 @@ CartridgeDFSC::CartridgeDFSC(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(131072u, size));
createCodeAccessBase(131072);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDFSC::reset()
{
initializeRAM(myRAM, 128);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(15);
// 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;
}
@ -176,8 +176,8 @@ bool CartridgeDFSC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeDFSC::getImage(uInt32& size) const
{
size = 131072;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -186,7 +186,7 @@ bool CartridgeDFSC::save(Serializer& out) const
try
{
out.putInt(myBankOffset);
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -203,7 +203,7 @@ bool CartridgeDFSC::load(Serializer& in)
try
{
myBankOffset = in.getInt();
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -73,8 +73,10 @@ class CartridgeDFSC : public Cartridge
/**
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.
@ -152,10 +154,10 @@ class CartridgeDFSC : public Cartridge
private:
// The 128K ROM image of the cartridge
uInt8 myImage[32 * 4096];
std::array<uInt8, 128_KB> myImage;
// The 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
// Indicates the offset into the ROM image (aligns to current bank)
uInt32 myBankOffset;

View File

@ -29,27 +29,26 @@ CartridgeDPC::CartridgeDPC(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// 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);
// Pointer to the program ROM (8K @ 0 byte offset)
myProgramImage = myImage;
myProgramImage = myImage.data();
// Pointer to the display ROM (2K @ 8K offset)
myDisplayImage = myProgramImage + 8192;
// Initialize the DPC data fetcher registers
for(int i = 0; i < 8; ++i)
{
myTops[i] = myBottoms[i] = myFlags[i] = 0;
myCounters[i] = 0;
}
myTops.fill(0);
myBottoms.fill(0);
myFlags.fill(0);
myCounters.fill(0);
// 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)
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;
}
@ -435,7 +434,7 @@ bool CartridgeDPC::patch(uInt16 address, uInt8 value)
const uInt8* CartridgeDPC::getImage(uInt32& size) const
{
size = mySize;
return myImage;
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -447,20 +446,20 @@ bool CartridgeDPC::save(Serializer& out) const
out.putShort(myBankOffset);
// The top registers for the data fetchers
out.putByteArray(myTops, 8);
out.putByteArray(myTops.data(), myTops.size());
// The bottom registers for the data fetchers
out.putByteArray(myBottoms, 8);
out.putByteArray(myBottoms.data(), myBottoms.size());
// The counter registers for the data fetchers
out.putShortArray(myCounters, 8);
out.putShortArray(myCounters.data(), myCounters.size());
// 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
for(int i = 0; i < 3; ++i)
out.putBool(myMusicMode[i]);
for(const auto& mode: myMusicMode)
out.putBool(mode);
// The random number generator register
out.putByte(myRandomNumber);
@ -486,20 +485,20 @@ bool CartridgeDPC::load(Serializer& in)
myBankOffset = in.getShort();
// The top registers for the data fetchers
in.getByteArray(myTops, 8);
in.getByteArray(myTops.data(), myTops.size());
// The bottom registers for the data fetchers
in.getByteArray(myBottoms, 8);
in.getByteArray(myBottoms.data(), myBottoms.size());
// The counter registers for the data fetchers
in.getShortArray(myCounters, 8);
in.getShortArray(myCounters.data(), myCounters.size());
// 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
for(int i = 0; i < 3; ++i)
myMusicMode[i] = in.getBool();
for(auto& mode: myMusicMode)
mode = in.getBool();
// The random number generator register
myRandomNumber = in.getByte();

View File

@ -77,8 +77,10 @@ class CartridgeDPC : public Cartridge
/**
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.
@ -170,7 +172,7 @@ class CartridgeDPC : public Cartridge
private:
// The ROM image
uInt8 myImage[8192 + 2048 + 256];
std::array<uInt8, 8_KB + 2_KB + 256> myImage;
// (Actual) Size of the ROM image
uInt32 mySize;
@ -182,19 +184,19 @@ class CartridgeDPC : public Cartridge
uInt8* myDisplayImage;
// The top registers for the data fetchers
uInt8 myTops[8];
std::array<uInt8, 8> myTops;
// The bottom registers for the data fetchers
uInt8 myBottoms[8];
std::array<uInt8, 8> myBottoms;
// The counter registers for the data fetchers
uInt16 myCounters[8];
std::array<uInt16, 8> myCounters;
// The flag registers for the data fetchers
uInt8 myFlags[8];
std::array<uInt8, 8> myFlags;
// The music mode DF5, DF6, & DF7 enabled flags
bool myMusicMode[3];
std::array<bool, 3> myMusicMode;
// The random number generator register
uInt8 myRandomNumber;

View File

@ -29,7 +29,7 @@
CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, uInt32 size,
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
mySize(std::min(size, 32768u)),
mySize(std::min<uInt32>(size, myImage.size())),
myFastFetch(false),
myLDAimmediate(false),
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
// copied to the end of the buffer
if(mySize < 32768u)
memset(myImage, 0, 32768);
memcpy(myImage + (32768u - mySize), image.get(), size);
if(mySize < myImage.size())
myImage.fill(0);
std::copy_n(image.get(), size, myImage.begin() + (myImage.size() - mySize));
createCodeAccessBase(4096 * 6);
// Pointer to the program ROM (24K @ 3072 byte offset; ignore first 3K)
myProgramImage = myImage + 0xC00;
myProgramImage = myImage.data() + 0xC00;
// Pointer to the display RAM
myDisplayImage = myDPCRAM + 0xC00;
myDisplayImage = myDPCRAM.data() + 0xC00;
// Pointer to the Frequency RAM
myFrequencyImage = myDisplayImage + 0x1000;
@ -58,9 +58,9 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, uInt32 size,
// Create Thumbulator ARM emulator
bool devSettings = settings.getBool("dev.settings");
myThumbEmulator = make_unique<Thumbulator>
(reinterpret_cast<uInt16*>(myImage),
reinterpret_cast<uInt16*>(myDPCRAM),
32768,
(reinterpret_cast<uInt16*>(myImage.data()),
reinterpret_cast<uInt16*>(myDPCRAM.data()),
myImage.size(),
devSettings ? settings.getBool("dev.thumb.trapfatal") : false,
Thumbulator::ConfigureFor::DPCplus,
this);
@ -89,21 +89,20 @@ void CartridgeDPCPlus::reset()
void CartridgeDPCPlus::setInitialState()
{
// 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
memcpy(myDisplayImage, myProgramImage + 0x6000, 0x1400);
std::copy_n(myProgramImage + 0x6000, 0x1400, myDisplayImage);
// Initialize the DPC data fetcher registers
for(int i = 0; i < 8; ++i)
{
myTops[i] = myBottoms[i] = myFractionalIncrements[i] = 0;
myFractionalCounters[i] = 0;
myCounters[i] = 0;
}
myTops.fill(0);
myBottoms.fill(0);
myFractionalIncrements.fill(0);
myFractionalCounters.fill(0);
myCounters.fill(0);
// 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)
myRandomNumber = 0x2B435044; // "DPC+"
@ -603,7 +602,7 @@ bool CartridgeDPCPlus::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeDPCPlus::getBank() const
uInt16 CartridgeDPCPlus::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -633,7 +632,7 @@ bool CartridgeDPCPlus::patch(uInt16 address, uInt8 value)
const uInt8* CartridgeDPCPlus::getImage(uInt32& size) const
{
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);
// Harmony RAM
out.putByteArray(myDPCRAM, 8192);
out.putByteArray(myDPCRAM.data(), myDPCRAM.size());
// The top registers for the data fetchers
out.putByteArray(myTops, 8);
out.putByteArray(myTops.data(), myTops.size());
// The bottom registers for the data fetchers
out.putByteArray(myBottoms, 8);
out.putByteArray(myBottoms.data(), myBottoms.size());
// 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
out.putIntArray(myFractionalCounters, 8);
out.putIntArray(myFractionalCounters.data(), myFractionalCounters.size());
// The fractional registers for the data fetchers
out.putByteArray(myFractionalIncrements, 8);
out.putByteArray(myFractionalIncrements.data(), myFractionalIncrements.size());
// The Fast Fetcher Enabled flag
out.putBool(myFastFetch);
out.putBool(myLDAimmediate);
// Control Byte to update
out.putByteArray(myParameter, 8);
out.putByteArray(myParameter.data(), myParameter.size());
// The music counters
out.putIntArray(myMusicCounters, 3);
out.putIntArray(myMusicCounters.data(), myMusicCounters.size());
// The music frequencies
out.putIntArray(myMusicFrequencies, 3);
out.putIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
// The music waveforms
out.putShortArray(myMusicWaveforms, 3);
out.putShortArray(myMusicWaveforms.data(), myMusicWaveforms.size());
// The random number generator register
out.putInt(myRandomNumber);
@ -706,38 +705,38 @@ bool CartridgeDPCPlus::load(Serializer& in)
myBankOffset = in.getShort();
// Harmony RAM
in.getByteArray(myDPCRAM, 8192);
in.getByteArray(myDPCRAM.data(), myDPCRAM.size());
// The top registers for the data fetchers
in.getByteArray(myTops, 8);
in.getByteArray(myTops.data(), myTops.size());
// The bottom registers for the data fetchers
in.getByteArray(myBottoms, 8);
in.getByteArray(myBottoms.data(), myBottoms.size());
// 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
in.getIntArray(myFractionalCounters, 8);
in.getIntArray(myFractionalCounters.data(), myFractionalCounters.size());
// The fractional registers for the data fetchers
in.getByteArray(myFractionalIncrements, 8);
in.getByteArray(myFractionalIncrements.data(), myFractionalIncrements.size());
// The Fast Fetcher Enabled flag
myFastFetch = in.getBool();
myLDAimmediate = in.getBool();
// Control Byte to update
in.getByteArray(myParameter, 8);
in.getByteArray(myParameter.data(), myParameter.size());
// 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
in.getIntArray(myMusicFrequencies, 3);
in.getIntArray(myMusicFrequencies.data(), myMusicFrequencies.size());
// The music waveforms
in.getShortArray(myMusicWaveforms, 3);
in.getShortArray(myMusicWaveforms.data(), myMusicWaveforms.size());
// The random number generator register
myRandomNumber = in.getInt();

View File

@ -92,8 +92,10 @@ class CartridgeDPCPlus : public Cartridge
/**
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.
@ -198,7 +200,7 @@ class CartridgeDPCPlus : public Cartridge
private:
// The ROM image and size
uInt8 myImage[32768];
std::array<uInt8, 32_KB> myImage;
uInt32 mySize;
// Pointer to the 24K program ROM image of the cartridge
@ -211,7 +213,7 @@ class CartridgeDPCPlus : public Cartridge
// 3K DPC+ driver
// 4K Display Data
// 1K Frequency Data
uInt8 myDPCRAM[8192];
std::array<uInt8, 8_KB> myDPCRAM;
// Pointer to the Thumb ARM emulator object
unique_ptr<Thumbulator> myThumbEmulator;
@ -220,19 +222,19 @@ class CartridgeDPCPlus : public Cartridge
uInt8* myFrequencyImage;
// The top registers for the data fetchers
uInt8 myTops[8];
std::array<uInt8, 8> myTops;
// The bottom registers for the data fetchers
uInt8 myBottoms[8];
std::array<uInt8, 8> myBottoms;
// The counter registers for the data fetchers
uInt16 myCounters[8];
std::array<uInt16, 8> myCounters;
// The counter registers for the fractional data fetchers
uInt32 myFractionalCounters[8];
std::array<uInt32, 8> myFractionalCounters;
// The fractional increments for the data fetchers
uInt8 myFractionalIncrements[8];
std::array<uInt8, 8> myFractionalIncrements;
// The Fast Fetcher Enabled flag
bool myFastFetch;
@ -241,19 +243,19 @@ class CartridgeDPCPlus : public Cartridge
bool myLDAimmediate;
// Parameter for special functions
uInt8 myParameter[8];
std::array<uInt8, 8> myParameter;
// Parameter pointer for special functions
uInt8 myParameterPointer;
// The music mode counters
uInt32 myMusicCounters[3];
std::array<uInt32, 3> myMusicCounters;
// The music frequency
uInt32 myMusicFrequencies[3];
std::array<uInt32, 3> myMusicFrequencies;
// The music waveforms
uInt16 myMusicWaveforms[3];
std::array<uInt16, 3> myMusicWaveforms;
// The random number generator register
uInt32 myRandomNumber;

View File

@ -24,8 +24,8 @@ CartridgeE0::CartridgeE0(const ByteBuffer& image, uInt32 size,
: Cartridge(settings, md5)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(8192u, size));
createCodeAccessBase(8192);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
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
{
size = 8192;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -212,7 +212,7 @@ bool CartridgeE0::save(Serializer& out) const
{
try
{
out.putShortArray(myCurrentSlice, 4);
out.putShortArray(myCurrentSlice.data(), myCurrentSlice.size());
}
catch(...)
{
@ -228,7 +228,7 @@ bool CartridgeE0::load(Serializer& in)
{
try
{
in.getShortArray(myCurrentSlice, 4);
in.getShortArray(myCurrentSlice.data(), myCurrentSlice.size());
}
catch(...)
{

View File

@ -75,8 +75,10 @@ class CartridgeE0 : public Cartridge
/**
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.
@ -175,11 +177,11 @@ class CartridgeE0 : public Cartridge
void segmentTwo(uInt16 slice);
private:
// Indicates the slice mapped into each of the four segments
uInt16 myCurrentSlice[4];
// 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:
// Following constructors and assignment operators not supported

View File

@ -25,8 +25,8 @@ CartridgeEF::CartridgeEF(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(65536u, size));
createCodeAccessBase(65536);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -101,7 +101,7 @@ bool CartridgeEF::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeEF::getBank() const
uInt16 CartridgeEF::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -122,8 +122,8 @@ bool CartridgeEF::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeEF::getImage(uInt32& size) const
{
size = 65536;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -73,8 +73,10 @@ class CartridgeEF : public Cartridge
/**
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.
@ -152,7 +154,7 @@ class CartridgeEF : public Cartridge
private:
// 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)
uInt16 myBankOffset;

View File

@ -25,14 +25,14 @@ CartridgeEFSC::CartridgeEFSC(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(65536u, size));
createCodeAccessBase(65536);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEFSC::reset()
{
initializeRAM(myRAM, 128);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(15);
// 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;
}
@ -176,8 +176,8 @@ bool CartridgeEFSC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeEFSC::getImage(uInt32& size) const
{
size = 65536;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -186,7 +186,7 @@ bool CartridgeEFSC::save(Serializer& out) const
try
{
out.putShort(myBankOffset);
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -203,7 +203,7 @@ bool CartridgeEFSC::load(Serializer& in)
try
{
myBankOffset = in.getShort();
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -74,8 +74,10 @@ class CartridgeEFSC : public Cartridge
/**
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.
@ -153,10 +155,10 @@ class CartridgeEFSC : public Cartridge
private:
// The 64K ROM image of the cartridge
uInt8 myImage[65536];
std::array<uInt8, 64_KB> myImage;
// The 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;

View File

@ -25,8 +25,8 @@ CartridgeF0::CartridgeF0(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(65536u, size));
createCodeAccessBase(65536);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -109,7 +109,7 @@ bool CartridgeF0::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF0::getBank() const
uInt16 CartridgeF0::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -130,8 +130,8 @@ bool CartridgeF0::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeF0::getImage(uInt32& size) const
{
size = 65536;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -73,8 +73,10 @@ class CartridgeF0 : public Cartridge
/**
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.
@ -158,7 +160,7 @@ class CartridgeF0 : public Cartridge
private:
// 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)
uInt16 myBankOffset;

View File

@ -26,8 +26,8 @@ CartridgeF4::CartridgeF4(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(32768u, size));
createCodeAccessBase(32768);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -105,7 +105,7 @@ bool CartridgeF4::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF4::getBank() const
uInt16 CartridgeF4::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -126,8 +126,8 @@ bool CartridgeF4::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeF4::getImage(uInt32& size) const
{
size = 32768;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -72,8 +72,10 @@ class CartridgeF4 : public Cartridge
/**
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.
@ -151,7 +153,7 @@ class CartridgeF4 : public Cartridge
private:
// 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)
uInt16 myBankOffset;

View File

@ -25,14 +25,14 @@ CartridgeF4SC::CartridgeF4SC(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(32768u, size));
createCodeAccessBase(32768);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF4SC::reset()
{
initializeRAM(myRAM, 128);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(0);
// 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;
}
@ -176,8 +176,8 @@ bool CartridgeF4SC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeF4SC::getImage(uInt32& size) const
{
size = 32768;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -186,7 +186,7 @@ bool CartridgeF4SC::save(Serializer& out) const
try
{
out.putShort(myBankOffset);
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -203,7 +203,7 @@ bool CartridgeF4SC::load(Serializer& in)
try
{
myBankOffset = in.getShort();
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -73,8 +73,10 @@ class CartridgeF4SC : public Cartridge
/**
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.
@ -152,10 +154,10 @@ class CartridgeF4SC : public Cartridge
private:
// The 32K ROM image of the cartridge
uInt8 myImage[32768];
std::array<uInt8, 32_KB> myImage;
// The 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;

View File

@ -25,8 +25,8 @@ CartridgeF6::CartridgeF6(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(16384u, size));
createCodeAccessBase(16384);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -145,7 +145,7 @@ bool CartridgeF6::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF6::getBank() const
uInt16 CartridgeF6::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -166,8 +166,8 @@ bool CartridgeF6::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeF6::getImage(uInt32& size) const
{
size = 16384;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -72,8 +72,10 @@ class CartridgeF6 : public Cartridge
/**
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.
@ -151,7 +153,7 @@ class CartridgeF6 : public Cartridge
private:
// 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)
uInt16 myBankOffset;

View File

@ -25,14 +25,14 @@ CartridgeF6SC::CartridgeF6SC(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(16384u, size));
createCodeAccessBase(16384);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF6SC::reset()
{
initializeRAM(myRAM, 128);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(0);
// 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;
}
@ -216,8 +216,8 @@ bool CartridgeF6SC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeF6SC::getImage(uInt32& size) const
{
size = 16384;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -226,7 +226,7 @@ bool CartridgeF6SC::save(Serializer& out) const
try
{
out.putShort(myBankOffset);
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -243,7 +243,7 @@ bool CartridgeF6SC::load(Serializer& in)
try
{
myBankOffset = in.getShort();
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -73,8 +73,10 @@ class CartridgeF6SC : public Cartridge
/**
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.
@ -152,10 +154,10 @@ class CartridgeF6SC : public Cartridge
private:
// The 16K ROM image of the cartridge
uInt8 myImage[16384];
std::array<uInt8, 16_KB> myImage;
// The 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;

View File

@ -25,8 +25,8 @@ CartridgeF8::CartridgeF8(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(8192u, size));
createCodeAccessBase(8192);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -126,7 +126,7 @@ bool CartridgeF8::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeF8::getBank() const
uInt16 CartridgeF8::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -147,8 +147,8 @@ bool CartridgeF8::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeF8::getImage(uInt32& size) const
{
size = 8192;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -72,8 +72,10 @@ class CartridgeF8 : public Cartridge
/**
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.
@ -151,7 +153,7 @@ class CartridgeF8 : public Cartridge
private:
// 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)
uInt16 myBankOffset;

View File

@ -25,14 +25,14 @@ CartridgeF8SC::CartridgeF8SC(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(8192u, size));
createCodeAccessBase(8192);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeF8SC::reset()
{
initializeRAM(myRAM, 128);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(1);
// 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;
}
@ -196,8 +196,8 @@ bool CartridgeF8SC::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeF8SC::getImage(uInt32& size) const
{
size = 8192;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -206,7 +206,7 @@ bool CartridgeF8SC::save(Serializer& out) const
try
{
out.putShort(myBankOffset);
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -223,7 +223,7 @@ bool CartridgeF8SC::load(Serializer& in)
try
{
myBankOffset = in.getShort();
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -73,8 +73,10 @@ class CartridgeF8SC : public Cartridge
/**
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.
@ -152,10 +154,10 @@ class CartridgeF8SC : public Cartridge
private:
// The 8K ROM image of the cartridge
uInt8 myImage[8192];
std::array<uInt8, 8_KB> myImage;
// The 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;

View File

@ -25,14 +25,14 @@ CartridgeFA::CartridgeFA(const ByteBuffer& image, uInt32 size,
myBankOffset(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(12288u, size));
createCodeAccessBase(12288);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFA::reset()
{
initializeRAM(myRAM, 256);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(2);
// 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;
}
@ -206,8 +206,8 @@ bool CartridgeFA::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeFA::getImage(uInt32& size) const
{
size = 12288;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -216,7 +216,7 @@ bool CartridgeFA::save(Serializer& out) const
try
{
out.putShort(myBankOffset);
out.putByteArray(myRAM, 256);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -233,7 +233,7 @@ bool CartridgeFA::load(Serializer& in)
try
{
myBankOffset = in.getShort();
in.getByteArray(myRAM, 256);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -73,8 +73,10 @@ class CartridgeFA : public Cartridge
/**
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.
@ -152,10 +154,10 @@ class CartridgeFA : public Cartridge
private:
// The 12K ROM image of the cartridge
uInt8 myImage[12288];
std::array<uInt8, 12_KB> myImage;
// 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)
uInt16 myBankOffset;

View File

@ -31,20 +31,20 @@ CartridgeFA2::CartridgeFA2(const ByteBuffer& image, uInt32 size,
{
// 29/32K version of FA2 has valid data @ 1K - 29K
const uInt8* img_ptr = image.get();
if(size >= 29 * 1024)
img_ptr += 1024;
if(size >= 29_KB)
img_ptr += 1_KB;
else if(size < mySize)
mySize = size;
// Copy the ROM image into my buffer
memcpy(myImage, img_ptr, mySize);
std::copy_n(img_ptr, mySize, myImage.begin());
createCodeAccessBase(mySize);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeFA2::reset()
{
initializeRAM(myRAM, 256);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(0);
// Upon reset we switch to the startup bank
@ -93,7 +93,7 @@ uInt8 CartridgeFA2::peek(uInt16 address)
{
case 0x0FF4:
// Load/save RAM to/from Harmony cart flash
if(mySize == 28*1024 && !bankLocked())
if(mySize == 28_KB && !bankLocked())
return ramReadWrite();
break;
@ -130,7 +130,7 @@ uInt8 CartridgeFA2::peek(uInt16 address)
case 0x0FFB:
// Set the current bank to the seventh 4k bank
// This is only available on 28K ROMs
if(mySize == 28*1024) bank(6);
if(mySize == 28_KB) bank(6);
break;
default:
@ -151,7 +151,7 @@ bool CartridgeFA2::poke(uInt16 address, uInt8 value)
{
case 0x0FF4:
// Load/save RAM to/from Harmony cart flash
if(mySize == 28*1024 && !bankLocked())
if(mySize == 28_KB && !bankLocked())
ramReadWrite();
return false;
@ -188,7 +188,7 @@ bool CartridgeFA2::poke(uInt16 address, uInt8 value)
case 0x0FFB:
// Set the current bank to the seventh 4k bank
// This is only available on 28K ROMs
if(mySize == 28*1024) bank(6);
if(mySize == 28_KB) bank(6);
return false;
default:
@ -241,7 +241,7 @@ bool CartridgeFA2::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeFA2::getBank() const
uInt16 CartridgeFA2::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -249,7 +249,7 @@ uInt16 CartridgeFA2::getBank() 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
{
size = mySize;
return myImage;
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -283,7 +283,7 @@ bool CartridgeFA2::save(Serializer& out) const
try
{
out.putShort(myBankOffset);
out.putByteArray(myRAM, 256);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -300,7 +300,7 @@ bool CartridgeFA2::load(Serializer& in)
try
{
myBankOffset = in.getShort();
in.getByteArray(myRAM, 256);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -356,11 +356,11 @@ uInt8 CartridgeFA2::ramReadWrite()
{
try
{
serializer.getByteArray(myRAM, 256);
serializer.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
memset(myRAM, 0, 256);
myRAM.fill(0);
}
myRamAccessTimeout += 500; // Add 0.5 ms delay for read
}
@ -368,7 +368,7 @@ uInt8 CartridgeFA2::ramReadWrite()
{
try
{
serializer.putByteArray(myRAM, 256);
serializer.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -408,9 +408,8 @@ void CartridgeFA2::flash(uInt8 operation)
{
try
{
uInt8 buf[256];
memset(buf, 0, 256);
serializer.putByteArray(buf, 256);
std::array<uInt8, 256> buf = {};
serializer.putByteArray(buf.data(), buf.size());
}
catch(...)
{
@ -420,18 +419,18 @@ void CartridgeFA2::flash(uInt8 operation)
{
try
{
serializer.getByteArray(myRAM, 256);
serializer.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
memset(myRAM, 0, 256);
myRAM.fill(0);
}
}
else if(operation == 2) // write
{
try
{
serializer.putByteArray(myRAM, 256);
serializer.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -85,8 +85,10 @@ class CartridgeFA2 : public Cartridge
/**
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.
@ -191,13 +193,13 @@ class CartridgeFA2 : public Cartridge
private:
// 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
uInt32 mySize;
// 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
// will actually be completed

View File

@ -27,8 +27,8 @@ CartridgeFE::CartridgeFE(const ByteBuffer& image, uInt32 size,
myLastAccessWasFE(false)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(8192u, size));
createCodeAccessBase(8192);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -110,7 +110,7 @@ bool CartridgeFE::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeFE::getBank() const
uInt16 CartridgeFE::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -131,8 +131,8 @@ bool CartridgeFE::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeFE::getImage(uInt32& size) const
{
size = 8192;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -115,8 +115,10 @@ class CartridgeFE : public Cartridge
/**
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.
@ -201,7 +203,7 @@ class CartridgeFE : public Cartridge
private:
// 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)
uInt16 myBankOffset;

View File

@ -30,7 +30,7 @@ CartridgeMDM::CartridgeMDM(const ByteBuffer& image, uInt32 size,
myImage = make_unique<uInt8[]>(mySize);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), mySize);
std::copy_n(image.get(), mySize, myImage.get());
createCodeAccessBase(mySize);
}
@ -124,7 +124,7 @@ bool CartridgeMDM::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeMDM::getBank() const
uInt16 CartridgeMDM::getBank(uInt16) const
{
return myBankOffset >> 12;
}

View File

@ -84,8 +84,10 @@ class CartridgeMDM : public Cartridge
/**
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.
@ -169,7 +171,7 @@ class CartridgeMDM : public Cartridge
uInt32 mySize;
// 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)
uInt32 myBankOffset;

View File

@ -35,8 +35,8 @@ void CartridgeMNetwork::initialize(const ByteBuffer& image, uInt32 size)
myImage = make_unique<uInt8[]>(size);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), std::min(romSize(), size));
createCodeAccessBase(romSize() + RAM_SIZE);
std::copy_n(image.get(), std::min(romSize(), size), myImage.get());
createCodeAccessBase(romSize() + myRAM.size());
myRAMSlice = bankCount() - 1;
}
@ -44,7 +44,7 @@ void CartridgeMNetwork::initialize(const ByteBuffer& image, uInt32 size)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeMNetwork::reset()
{
initializeRAM(myRAM, RAM_SIZE);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(0);
uInt32 ramBank = randomStartBank() ?
@ -162,9 +162,9 @@ void CartridgeMNetwork::bankRAM(uInt16 bank)
// Setup the page access methods for the current bank
// 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
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;
}
@ -188,17 +188,17 @@ bool CartridgeMNetwork::bank(uInt16 slice)
else
{
// 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
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;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
{
out.putShortArray(myCurrentSlice, NUM_SEGMENTS);
out.putShortArray(myCurrentSlice.data(), myCurrentSlice.size());
out.putShort(myCurrentRAM);
out.putByteArray(myRAM, RAM_SIZE);
out.putByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{
@ -261,9 +261,9 @@ bool CartridgeMNetwork::load(Serializer& in)
{
try
{
in.getShortArray(myCurrentSlice, NUM_SEGMENTS);
in.getShortArray(myCurrentSlice.data(), myCurrentSlice.size());
myCurrentRAM = in.getShort();
in.getByteArray(myRAM, RAM_SIZE);
in.getByteArray(myRAM.data(), myRAM.size());
}
catch(...)
{

View File

@ -100,8 +100,10 @@ class CartridgeMNetwork : public Cartridge
/**
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.
@ -203,10 +205,10 @@ class CartridgeMNetwork : public Cartridge
uInt32 mySize;
// The 2K of RAM
uInt8 myRAM[RAM_SIZE];
std::array<uInt8, RAM_SIZE> myRAM;
// 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
uInt16 myCurrentRAM;

View File

@ -29,7 +29,7 @@ CartridgeSB::CartridgeSB(const ByteBuffer& image, uInt32 size,
myImage = make_unique<uInt8[]>(mySize);
// Copy the ROM image into my buffer
memcpy(myImage.get(), image.get(), mySize);
std::copy_n(image.get(), mySize, myImage.get());
createCodeAccessBase(mySize);
}
@ -129,7 +129,7 @@ bool CartridgeSB::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeSB::getBank() const
uInt16 CartridgeSB::getBank(uInt16) const
{
return myBankOffset >> 12;
}

View File

@ -73,8 +73,10 @@ class CartridgeSB : public Cartridge
/**
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.
@ -159,7 +161,7 @@ class CartridgeSB : public Cartridge
uInt32 myBankOffset;
// Previous Device's page access
System::PageAccess myHotSpotPageAccess[8];
std::array<System::PageAccess, 8> myHotSpotPageAccess;
private:
// Following constructors and assignment operators not supported

View File

@ -27,8 +27,8 @@ CartridgeUA::CartridgeUA(const ByteBuffer& image, uInt32 size,
mySwappedHotspots(swapHotspots)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(8192u, size));
createCodeAccessBase(8192);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -143,7 +143,7 @@ bool CartridgeUA::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeUA::getBank() const
uInt16 CartridgeUA::getBank(uInt16) const
{
return myBankOffset >> 12;
}
@ -164,8 +164,8 @@ bool CartridgeUA::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeUA::getImage(uInt32& size) const
{
size = 8192;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -73,8 +73,10 @@ class CartridgeUA : public Cartridge
/**
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.
@ -152,10 +154,10 @@ class CartridgeUA : public Cartridge
private:
// The 8K ROM image of the cartridge
uInt8 myImage[8192];
std::array<uInt8, 8_KB> myImage;
// 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)
uInt16 myBankOffset;

View File

@ -24,20 +24,20 @@
CartridgeWD::CartridgeWD(const ByteBuffer& image, uInt32 size,
const string& md5, const Settings& settings)
: Cartridge(settings, md5),
mySize(std::min(8195u, size)),
mySize(std::min<uInt32>(8_KB + 3, size)),
myCyclesAtBankswitchInit(0),
myPendingBank(0),
myCurrentBank(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), mySize);
createCodeAccessBase(8192);
std::copy_n(image.get(), mySize, myImage.begin());
createCodeAccessBase(8_KB);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeWD::reset()
{
initializeRAM(myRAM, 64);
initializeRAM(myRAM.data(), myRAM.size());
initializeStartBank(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
// Then map in the extra 3 bytes, if required
memcpy(mySegment3, myImage+offset, 1024);
if(mySize == 8195 && map3bytes)
std::copy_n(myImage.begin()+offset, mySegment3.size(), mySegment3.begin());
if(mySize == 8_KB + 3 && map3bytes)
{
mySegment3[0x3FC] = myImage[0x2000+0];
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;
}
@ -261,7 +261,7 @@ bool CartridgeWD::patch(uInt16 address, uInt8 value)
const uInt8* CartridgeWD::getImage(uInt32& size) const
{
size = mySize;
return myImage;
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -270,7 +270,7 @@ bool CartridgeWD::save(Serializer& out) const
try
{
out.putShort(myCurrentBank);
out.putByteArray(myRAM, 64);
out.putByteArray(myRAM.data(), myRAM.size());
out.putLong(myCyclesAtBankswitchInit);
out.putShort(myPendingBank);
}
@ -289,7 +289,7 @@ bool CartridgeWD::load(Serializer& in)
try
{
myCurrentBank = in.getShort();
in.getByteArray(myRAM, 64);
in.getByteArray(myRAM.data(), myRAM.size());
myCyclesAtBankswitchInit = in.getLong();
myPendingBank = in.getShort();

View File

@ -101,8 +101,10 @@ class CartridgeWD : public Cartridge
/**
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.
@ -211,19 +213,19 @@ class CartridgeWD : public Cartridge
private:
// 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)
uInt32 mySize;
// 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)
uInt8 mySegment3[1024];
std::array<uInt8, 1_KB> mySegment3;
// 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
uInt64 myCyclesAtBankswitchInit;

View File

@ -27,8 +27,8 @@ CartridgeX07::CartridgeX07(const ByteBuffer& image, uInt32 size,
myCurrentBank(0)
{
// Copy the ROM image into my buffer
memcpy(myImage, image.get(), std::min(65536u, size));
createCodeAccessBase(65536);
std::copy_n(image.get(), std::min<uInt32>(myImage.size(), size), myImage.begin());
createCodeAccessBase(myImage.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -123,7 +123,7 @@ bool CartridgeX07::bank(uInt16 bank)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 CartridgeX07::getBank() const
uInt16 CartridgeX07::getBank(uInt16) const
{
return myCurrentBank;
}
@ -144,8 +144,8 @@ bool CartridgeX07::patch(uInt16 address, uInt8 value)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgeX07::getImage(uInt32& size) const
{
size = 65536;
return myImage;
size = myImage.size();
return myImage.data();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -82,8 +82,10 @@ class CartridgeX07 : public Cartridge
/**
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.
@ -161,7 +163,7 @@ class CartridgeX07 : public Cartridge
private:
// The 64K ROM image of the cartridge
uInt8 myImage[65536];
std::array<uInt8, 64_KB> myImage;
// Indicates which bank is currently active
uInt16 myCurrentBank;

View File

@ -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());
if(rect.empty())
memcpy(buffer, src, width() * height() * 4);
std::copy_n(src, width() * height() * 4, buffer);
else
{
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;
while(h--)
{
memcpy(dst, src, w * 4);
std::copy_n(src, w * 4, dst);
src += myPitch * 4;
dst += pitch * 4;
}

View File

@ -57,13 +57,11 @@ void M6532::reset()
// Initialize the 128 bytes of memory
bool devSettings = mySettings.getBool("dev.settings");
if(mySettings.getString(devSettings ? "dev.console" : "plr.console") == "7800")
for(uInt32 t = 0; t < 128; ++t)
myRAM[t] = RAM_7800[t];
std::copy_n(RAM_7800, 128, myRAM.begin());
else if(mySettings.getBool(devSettings ? "dev.ramrandom" : "plr.ramrandom"))
for(uInt32 t = 0; t < 128; ++t)
myRAM[t] = mySystem->randGenerator().next();
for(uInt32 t = 0; t < 128; ++t) myRAM[t] = mySystem->randGenerator().next();
else
memset(myRAM, 0, 128);
myRAM.fill(0);
myTimer = mySystem->randGenerator().next() & 0xff;
myDivider = 1024;
@ -368,7 +366,7 @@ bool M6532::save(Serializer& out) const
{
try
{
out.putByteArray(myRAM, 128);
out.putByteArray(myRAM.data(), myRAM.size());
out.putInt(myTimer);
out.putInt(mySubTimer);
@ -401,7 +399,7 @@ bool M6532::load(Serializer& in)
{
try
{
in.getByteArray(myRAM, 128);
in.getByteArray(myRAM.data(), myRAM.size());
myTimer = in.getInt();
mySubTimer = in.getInt();
@ -467,15 +465,10 @@ uInt32 M6532::timerClocks() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void M6532::createAccessBases()
{
myRAMAccessBase = make_unique<uInt8[]>(RAM_SIZE);
memset(myRAMAccessBase.get(), CartDebug::NONE, RAM_SIZE);
myStackAccessBase = make_unique<uInt8[]>(STACK_SIZE);
memset(myStackAccessBase.get(), CartDebug::NONE, STACK_SIZE);
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);
myRAMAccessBase.fill(CartDebug::NONE);
myStackAccessBase.fill(CartDebug::NONE);
myIOAccessBase.fill(CartDebug::NONE);
myZPAccessDelay.fill(ZP_DELAY);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -128,7 +128,7 @@ class M6532 : public Device
@return Pointer to RAM array.
*/
const uInt8* getRAM() const { return myRAM; }
const uInt8* getRAM() const { return myRAM.data(); }
private:
@ -169,7 +169,7 @@ class M6532 : public Device
const Settings& mySettings;
// An amazing 128 bytes of RAM
uInt8 myRAM[128];
std::array<uInt8, 128> myRAM;
// Current value of the timer
uInt8 myTimer;
@ -217,19 +217,19 @@ class M6532 : public Device
static constexpr uInt8 TimerBit = 0x80, PA7Bit = 0x40;
#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
RAM_SIZE = 0x80, RAM_MASK = RAM_SIZE - 1,
STACK_SIZE = RAM_SIZE, STACK_MASK = RAM_MASK, STACK_BIT = 0x100,
IO_SIZE = 0x20, IO_MASK = IO_SIZE - 1, IO_BIT = 0x200,
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
private:

View File

@ -78,7 +78,7 @@ MT24LC256::MT24LC256(const string& filename, const System& system,
if(uInt32(in.tellg()) == FLASH_SIZE)
{
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;
}
}
@ -99,7 +99,7 @@ MT24LC256::~MT24LC256()
{
ofstream out(myDataFile, std::ios_base::binary);
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()
{
std::fill(myPageHit, myPageHit + PAGE_NUM, false);
myPageHit.fill(false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MT24LC256::eraseAll()
{
memset(myData, INIT_VALUE, FLASH_SIZE);
myData.fill(INIT_VALUE);
myDataChanged = true;
}
@ -167,7 +167,7 @@ void MT24LC256::eraseCurrent()
{
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;
}
}
@ -193,7 +193,7 @@ void MT24LC256::jpee_init()
jpee_smallmode = 0;
jpee_logmode = -1;
if(!myDataFileExists)
memset(myData, INIT_VALUE, FLASH_SIZE);
myData.fill(INIT_VALUE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -94,10 +94,10 @@ class MT24LC256
Controller::onMessageCallback myCallback;
// The EEPROM data
uInt8 myData[FLASH_SIZE];
std::array<uInt8, FLASH_SIZE> myData;
// 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
bool mySDA, mySCL;
@ -125,7 +125,7 @@ class MT24LC256
Int32 jpee_sizemask, jpee_pagemask, jpee_smallmode, jpee_logmode;
Int32 jpee_pptr, jpee_state, jpee_nb;
uInt32 jpee_address, jpee_ad_known;
uInt8 jpee_packet[70];
std::array<uInt8, 70> jpee_packet;
private:
// Following constructors and assignment operators not supported

View File

@ -58,7 +58,7 @@ TIASurface::TIASurface(OSystem& system)
myBaseTiaSurface = myFB.allocateSurface(TIAConstants::frameBufferWidth*2,
TIAConstants::frameBufferHeight);
memset(myRGBFramebuffer, 0, sizeof(myRGBFramebuffer));
myRGBFramebuffer.fill(0);
// Enable/disable threading in the NTSC TV effects renderer
myNTSCFilter.enableThreading(myOSystem.settings().getBool("threads"));
@ -216,7 +216,7 @@ void TIASurface::enablePhosphor(bool enable, int blend)
myPhosphorPercent = blend / 100.0f;
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
if(myUsePhosphor)
@ -266,7 +266,7 @@ void TIASurface::enableNTSC(bool enable)
sl_attr.blendalpha = myOSystem.settings().getInt("tv.scanlines");
mySLineSurface->applyAttributes();
memset(myRGBFramebuffer, 0, sizeof(myRGBFramebuffer));
myRGBFramebuffer.fill(0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -317,8 +317,7 @@ inline uInt32 TIASurface::averageBuffers(uInt32 bufOfs)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TIASurface::render()
{
uInt32 width = myTIA->width();
uInt32 height = myTIA->height();
uInt32 width = myTIA->width(), height = myTIA->height();
uInt32 *out, outPitch;
myTiaSurface->basePtr(out, outPitch);
@ -346,10 +345,11 @@ void TIASurface::render()
case Filter::Phosphor:
{
uInt8* tiaIn = myTIA->frameBuffer();
uInt32* rgbIn = myRGBFramebuffer;
uInt32* rgbIn = myRGBFramebuffer.data();
if (mySaveSnapFlag)
memcpy(myPrevRGBFramebuffer, myRGBFramebuffer, width * height * sizeof(uInt32));
std::copy_n(myRGBFramebuffer.begin(), width * height,
myPrevRGBFramebuffer.begin());
uInt32 bufofs = 0, screenofsY = 0, pos;
for(uInt32 y = height; y ; --y)
@ -377,9 +377,10 @@ void TIASurface::render()
case Filter::BlarggPhosphor:
{
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;
}
}

View File

@ -185,10 +185,10 @@ class TIASurface
/////////////////////////////////////////////////////////////
// Phosphor mode items (aka reduced flicker on 30Hz screens)
// RGB frame buffer
uInt32 myRGBFramebuffer[AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
TIAConstants::frameBufferHeight];
uInt32 myPrevRGBFramebuffer[AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
TIAConstants::frameBufferHeight];
std::array<uInt32, AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
TIAConstants::frameBufferHeight> myRGBFramebuffer;
std::array<uInt32, AtariNTSC::outWidth(TIAConstants::frameBufferWidth) *
TIAConstants::frameBufferHeight> myPrevRGBFramebuffer;
// Use phosphor effect
bool myUsePhosphor;

View File

@ -52,7 +52,7 @@ class DelayQueue : public Serializable
private:
DelayQueueMember<capacity> myMembers[length];
uInt8 myIndex;
uInt8 myIndices[0xFF];
std::array<uInt8, 0xFF> myIndices;
private:
DelayQueue(const DelayQueue&) = delete;
@ -70,7 +70,7 @@ template<unsigned length, unsigned capacity>
DelayQueue<length, capacity>::DelayQueue()
: myIndex(0)
{
memset(myIndices, 0xFF, 0xFF);
myIndices.fill(0xFF);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -99,7 +99,7 @@ void DelayQueue<length, capacity>::reset()
myMembers[i].clear();
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);
out.putByte(myIndex);
out.putByteArray(myIndices, 0xFF);
out.putByteArray(myIndices.data(), myIndices.size());
}
catch(...)
{
@ -154,7 +154,7 @@ bool DelayQueue<length, capacity>::load(Serializer& in)
myMembers[i].load(in);
myIndex = in.getByte();
in.getByteArray(myIndices, 0xFF);
in.getByteArray(myIndices.data(), myIndices.size());
}
catch(...)
{

Some files were not shown because too many files have changed in this diff Show More