Some more std::array and size_t updates.

This commit is contained in:
Stephen Anthony 2019-09-18 10:27:32 -02:30
parent b00a438608
commit 700fbd9c91
19 changed files with 41 additions and 59 deletions

View File

@ -32,7 +32,7 @@ Cartridge2K::Cartridge2K(const ByteBuffer& image, size_t size,
mySize <<= 1; mySize <<= 1;
// We can't use a size smaller than the minimum page size in Stella // We can't use a size smaller than the minimum page size in Stella
mySize = std::max<uInt32>(mySize, System::PAGE_SIZE); mySize = std::max<size_t>(mySize, System::PAGE_SIZE);
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam // Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
myImage = make_unique<uInt8[]>(mySize); myImage = make_unique<uInt8[]>(mySize);
@ -44,7 +44,7 @@ Cartridge2K::Cartridge2K(const ByteBuffer& image, size_t size,
// Set mask for accessing the image buffer // Set mask for accessing the image buffer
// This is guaranteed to work, as mySize is a power of two // This is guaranteed to work, as mySize is a power of two
myMask = mySize - 1; myMask = static_cast<uInt16>(mySize) - 1;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -130,10 +130,10 @@ class Cartridge2K : public Cartridge
ByteBuffer myImage; ByteBuffer myImage;
// Size of the ROM image // Size of the ROM image
uInt32 mySize; size_t mySize;
// Mask to use for mirroring // Mask to use for mirroring
uInt32 myMask; uInt16 myMask;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -64,15 +64,3 @@ const uInt8* Cartridge4K::getImage(size_t& size) const
size = myImage.size(); size = myImage.size();
return myImage.data(); return myImage.data();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::save(Serializer&) const
{
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge4K::load(Serializer&)
{
return true;
}

View File

@ -86,7 +86,7 @@ class Cartridge4K : public Cartridge
@param out The Serializer object to use @param out The Serializer object to use
@return False on any errors, else true @return False on any errors, else true
*/ */
bool save(Serializer& out) const override; bool save(Serializer& out) const override { return true; }
/** /**
Load the current state of this cart from the given Serializer. Load the current state of this cart from the given Serializer.
@ -94,7 +94,7 @@ class Cartridge4K : public Cartridge
@param in The Serializer object to use @param in The Serializer object to use
@return False on any errors, else true @return False on any errors, else true
*/ */
bool load(Serializer& in) override; bool load(Serializer& in) override { return true; }
/** /**
Get a descriptor for the device name (used in error checking). Get a descriptor for the device name (used in error checking).

View File

@ -316,7 +316,7 @@ void CartridgeAR::initializeROM()
ourDummyROMCode[281] = mySystem->randGenerator().next(); ourDummyROMCode[281] = mySystem->randGenerator().next();
// Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam // Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam
std::fill_n(myImage.begin() + (3<<11), 2048, 0x02); std::fill_n(myImage.begin() + (3<<11), 2_KB, 0x02);
// Copy the "dummy" Supercharger BIOS code into the ROM area // Copy the "dummy" Supercharger BIOS code into the ROM area
std::copy_n(ourDummyROMCode.data(), ourDummyROMCode.size(), myImage.data() + (3<<11)); std::copy_n(ourDummyROMCode.data(), ourDummyROMCode.size(), myImage.data() + (3<<11));

View File

@ -98,7 +98,7 @@ void CartridgeBUS::reset()
void CartridgeBUS::setInitialState() void CartridgeBUS::setInitialState()
{ {
// Copy initial BUS driver to Harmony RAM // Copy initial BUS driver to Harmony RAM
std::copy_n(myImage.begin(), 0x0800, myBusDriverImage); std::copy_n(myImage.begin(), 2_KB, myBusDriverImage);
myMusicWaveformSize.fill(27); myMusicWaveformSize.fill(27);

View File

@ -68,11 +68,11 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size,
std::copy_n(image.get(), std::min(myImage.size(), size), myImage.begin()); std::copy_n(image.get(), std::min(myImage.size(), size), myImage.begin());
// even though the ROM is 32K, only 28K is accessible to the 6507 // even though the ROM is 32K, only 28K is accessible to the 6507
createCodeAccessBase(4096 * 7); createCodeAccessBase(28_KB);
// Pointer to the program ROM (28K @ 0 byte offset) // Pointer to the program ROM (28K @ 0 byte offset)
// which starts after the 2K CDF Driver and 2K C Code // which starts after the 2K CDF Driver and 2K C Code
myProgramImage = myImage.data() + 4096; myProgramImage = myImage.data() + 4_KB;
// Pointer to CDF driver in RAM // Pointer to CDF driver in RAM
myBusDriverImage = myCDFRAM.data(); myBusDriverImage = myCDFRAM.data();
@ -96,7 +96,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDF::reset() void CartridgeCDF::reset()
{ {
initializeRAM(myCDFRAM.data()+2048, myCDFRAM.size()-2048); initializeRAM(myCDFRAM.data()+2_KB, myCDFRAM.size()-2_KB);
// CDF always starts in bank 6 // CDF always starts in bank 6
initializeStartBank(6); initializeStartBank(6);
@ -114,7 +114,7 @@ void CartridgeCDF::reset()
void CartridgeCDF::setInitialState() void CartridgeCDF::setInitialState()
{ {
// Copy initial CDF driver to Harmony RAM // Copy initial CDF driver to Harmony RAM
std::copy_n(myImage.begin(), 0x0800, myBusDriverImage); std::copy_n(myImage.begin(), 2_KB, myBusDriverImage);
myMusicWaveformSize.fill(27); myMusicWaveformSize.fill(27);

View File

@ -20,8 +20,6 @@
class System; class System;
class Thumbulator; class Thumbulator;
class CartridgeCDFWidget;
class CartridgeCDFInfoWidget;
#include "bspf.hxx" #include "bspf.hxx"
#include "Cart.hxx" #include "Cart.hxx"
@ -41,8 +39,8 @@ class CartridgeCDFInfoWidget;
*/ */
class CartridgeCDF : public Cartridge class CartridgeCDF : public Cartridge
{ {
friend CartridgeCDFWidget; friend class CartridgeCDFWidget;
friend CartridgeCDFInfoWidget; friend class CartridgeCDFInfoWidget;
friend class CartridgeRamCDFWidget; friend class CartridgeRamCDFWidget;
public: public:

View File

@ -137,16 +137,16 @@ class CartridgeCV : public Cartridge
private: private:
// The 2k ROM image for the cartridge // The 2k ROM image for the cartridge
std::array<uInt8, 0x0800> myImage; std::array<uInt8, 2_KB> myImage;
// Initial size of the cart data // Initial size of the cart data
size_t mySize; size_t mySize;
// The 1024 bytes of RAM // The 1024 bytes of RAM
std::array<uInt8, 0x0400> myRAM; std::array<uInt8, 1_KB> myRAM;
// Initial RAM data from the cart (doesn't always exist) // Initial RAM data from the cart (doesn't always exist)
std::array<uInt8, 0x0400> myInitialRAM; std::array<uInt8, 1_KB> myInitialRAM;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -30,13 +30,13 @@ CartridgeDPC::CartridgeDPC(const ByteBuffer& image, size_t size,
{ {
// Make a copy of the entire image // Make a copy of the entire image
std::copy_n(image.get(), std::min(myImage.size(), size), myImage.begin()); std::copy_n(image.get(), std::min(myImage.size(), size), myImage.begin());
createCodeAccessBase(8192); createCodeAccessBase(8_KB);
// Pointer to the program ROM (8K @ 0 byte offset) // Pointer to the program ROM (8K @ 0 byte offset)
myProgramImage = myImage.data(); myProgramImage = myImage.data();
// Pointer to the display ROM (2K @ 8K offset) // Pointer to the display ROM (2K @ 8K offset)
myDisplayImage = myProgramImage + 8192; myDisplayImage = myProgramImage + 8_KB;
// Initialize the DPC data fetcher registers // Initialize the DPC data fetcher registers
myTops.fill(0); myTops.fill(0);

View File

@ -44,16 +44,16 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, size_t size,
if(mySize < myImage.size()) if(mySize < myImage.size())
myImage.fill(0); myImage.fill(0);
std::copy_n(image.get(), size, myImage.begin() + (myImage.size() - mySize)); std::copy_n(image.get(), size, myImage.begin() + (myImage.size() - mySize));
createCodeAccessBase(4_KB * 6); createCodeAccessBase(24_KB);
// Pointer to the program ROM (24K @ 3072 byte offset; ignore first 3K) // Pointer to the program ROM (24K @ 3K offset; ignore first 3K)
myProgramImage = myImage.data() + 0xC00; myProgramImage = myImage.data() + 3_KB;
// Pointer to the display RAM // Pointer to the display RAM
myDisplayImage = myDPCRAM.data() + 0xC00; myDisplayImage = myDPCRAM.data() + 3_KB;
// Pointer to the Frequency RAM // Pointer to the Frequency RAM
myFrequencyImage = myDisplayImage + 0x1000; myFrequencyImage = myDisplayImage + 4_KB;
// Create Thumbulator ARM emulator // Create Thumbulator ARM emulator
bool devSettings = settings.getBool("dev.settings"); bool devSettings = settings.getBool("dev.settings");
@ -67,7 +67,7 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, size_t size,
// Currently only one known DPC+ ARM driver exhibits a problem // Currently only one known DPC+ ARM driver exhibits a problem
// with the default mask to use for DFxFRACLOW // with the default mask to use for DFxFRACLOW
if(MD5::hash(image, 3*1024) == "8dd73b44fd11c488326ce507cbeb19d1") if(MD5::hash(image, 3_KB) == "8dd73b44fd11c488326ce507cbeb19d1")
myFractionalLowMask = 0x0F0000; myFractionalLowMask = 0x0F0000;
setInitialState(); setInitialState();
@ -92,7 +92,7 @@ void CartridgeDPCPlus::setInitialState()
myDPCRAM.fill(0); myDPCRAM.fill(0);
// Copy initial DPC display data and Frequency table state to Harmony RAM // Copy initial DPC display data and Frequency table state to Harmony RAM
std::copy_n(myProgramImage + 0x6000, 0x1400, myDisplayImage); std::copy_n(myProgramImage + 24_KB, 5_KB, myDisplayImage);
// Initialize the DPC data fetcher registers // Initialize the DPC data fetcher registers
myTops.fill(0); myTops.fill(0);

View File

@ -402,7 +402,7 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
{ {
type = Bankswitch::Type::_WD; type = Bankswitch::Type::_WD;
} }
else if(size >= 10240 && size <= 10496) // ~10K - Pitfall2 else if(size >= 10_KB && size <= 10_KB + 256) // ~10K - Pitfall2
{ {
type = Bankswitch::Type::_DPC; type = Bankswitch::Type::_DPC;
} }
@ -915,7 +915,7 @@ bool CartDetector::isProbablyFA2(const ByteBuffer& image, size_t)
// file sizes // file sizes
// 32K version has all zeros in 29K-32K area // 32K version has all zeros in 29K-32K area
for(uInt32 i = 29*1024; i < 32*1024; ++i) for(uInt32 i = 29_KB; i < 32_KB; ++i)
if(image[i] != 0) if(image[i] != 0)
return false; return false;

View File

@ -327,10 +327,10 @@ class Controller : public Serializable
private: private:
/// The boolean value on each digital pin /// The boolean value on each digital pin
bool myDigitalPinState[5]; std::array<bool, 5> myDigitalPinState;
/// The analog value on each analog pin /// The analog value on each analog pin
Int32 myAnalogPinValue[2]; std::array<Int32, 2> myAnalogPinValue;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -75,7 +75,7 @@ void M6532::reset()
myDDRA = myDDRB = myOutA = myOutB = 0x00; myDDRA = myDDRB = myOutA = myOutB = 0x00;
// Zero the timer registers // Zero the timer registers
myOutTimer[0] = myOutTimer[1] = myOutTimer[2] = myOutTimer[3] = 0x00; myOutTimer.fill(0x00);
// Zero the interrupt flag register and mark D7 as invalid // Zero the interrupt flag register and mark D7 as invalid
myInterruptFlag = 0x00; myInterruptFlag = 0x00;
@ -383,7 +383,7 @@ bool M6532::save(Serializer& out) const
out.putByte(myInterruptFlag); out.putByte(myInterruptFlag);
out.putBool(myEdgeDetectPositive); out.putBool(myEdgeDetectPositive);
out.putByteArray(myOutTimer, 4); out.putByteArray(myOutTimer.data(), myOutTimer.size());
} }
catch(...) catch(...)
{ {
@ -416,7 +416,7 @@ bool M6532::load(Serializer& in)
myInterruptFlag = in.getByte(); myInterruptFlag = in.getByte();
myEdgeDetectPositive = in.getBool(); myEdgeDetectPositive = in.getBool();
in.getByteArray(myOutTimer, 4); in.getByteArray(myOutTimer.data(), myOutTimer.size());
} }
catch(...) catch(...)
{ {

View File

@ -210,7 +210,7 @@ class M6532 : public Device
bool myEdgeDetectPositive; bool myEdgeDetectPositive;
// Last value written to the timer registers // Last value written to the timer registers
uInt8 myOutTimer[4]; std::array<uInt8, 4> myOutTimer;
// Accessible bits in the interrupt flag register // Accessible bits in the interrupt flag register
// All other bits are always zeroed // All other bits are always zeroed

View File

@ -46,7 +46,7 @@ class MT24LC256
private: private:
// Sizes of the EEPROM // Sizes of the EEPROM
static constexpr uInt32 FLASH_SIZE = 32 * 1024; static constexpr uInt32 FLASH_SIZE = 32_KB;
public: public:
static constexpr uInt32 PAGE_SIZE = 64; static constexpr uInt32 PAGE_SIZE = 64;

View File

@ -41,11 +41,8 @@ System::System(Random& random, M6502& m6502, M6532& m6532,
{ {
// Initialize page access table // Initialize page access table
PageAccess access(&myNullDevice, System::PageAccessType::READ); PageAccess access(&myNullDevice, System::PageAccessType::READ);
for(int page = 0; page < NUM_PAGES; ++page) myPageAccessTable.fill(access);
{ myPageIsDirtyTable.fill(false);
myPageAccessTable[page] = access;
myPageIsDirtyTable[page] = false;
}
// Bus starts out unlocked (in other words, peek() changes myDataBusState) // Bus starts out unlocked (in other words, peek() changes myDataBusState)
myDataBusLocked = false; myDataBusLocked = false;
@ -102,8 +99,7 @@ bool System::isPageDirty(uInt16 start_addr, uInt16 end_addr) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void System::clearDirtyPages() void System::clearDirtyPages()
{ {
for(uInt32 i = 0; i < NUM_PAGES; ++i) myPageIsDirtyTable.fill(false);
myPageIsDirtyTable[i] = false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -399,10 +399,10 @@ class System : public Serializable
NullDevice myNullDevice; NullDevice myNullDevice;
// The list of PageAccess structures // The list of PageAccess structures
PageAccess myPageAccessTable[NUM_PAGES]; std::array<PageAccess, NUM_PAGES> myPageAccessTable;
// The list of dirty pages // The list of dirty pages
bool myPageIsDirtyTable[NUM_PAGES]; std::array<bool, NUM_PAGES> myPageIsDirtyTable;
// The current state of the Data Bus // The current state of the Data Bus
uInt8 myDataBusState; uInt8 myDataBusState;

View File

@ -734,7 +734,7 @@ class TIA : public Device
/** /**
* The paddle readout circuits. * The paddle readout circuits.
*/ */
PaddleReader myPaddleReaders[4]; std::array<PaddleReader, 4> myPaddleReaders;
/** /**
* Circuits for the "latched inputs". * Circuits for the "latched inputs".