mirror of https://github.com/stella-emu/stella.git
Some more std::array and size_t updates.
This commit is contained in:
parent
b00a438608
commit
700fbd9c91
|
@ -32,7 +32,7 @@ Cartridge2K::Cartridge2K(const ByteBuffer& image, size_t size,
|
|||
mySize <<= 1;
|
||||
|
||||
// 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
|
||||
myImage = make_unique<uInt8[]>(mySize);
|
||||
|
@ -44,7 +44,7 @@ Cartridge2K::Cartridge2K(const ByteBuffer& image, size_t size,
|
|||
|
||||
// Set mask for accessing the image buffer
|
||||
// This is guaranteed to work, as mySize is a power of two
|
||||
myMask = mySize - 1;
|
||||
myMask = static_cast<uInt16>(mySize) - 1;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -130,10 +130,10 @@ class Cartridge2K : public Cartridge
|
|||
ByteBuffer myImage;
|
||||
|
||||
// Size of the ROM image
|
||||
uInt32 mySize;
|
||||
size_t mySize;
|
||||
|
||||
// Mask to use for mirroring
|
||||
uInt32 myMask;
|
||||
uInt16 myMask;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -64,15 +64,3 @@ const uInt8* Cartridge4K::getImage(size_t& size) const
|
|||
size = myImage.size();
|
||||
return myImage.data();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Cartridge4K::save(Serializer&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Cartridge4K::load(Serializer&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class Cartridge4K : public Cartridge
|
|||
@param out The Serializer object to use
|
||||
@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.
|
||||
|
@ -94,7 +94,7 @@ class Cartridge4K : public Cartridge
|
|||
@param in The Serializer object to use
|
||||
@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).
|
||||
|
|
|
@ -316,7 +316,7 @@ void CartridgeAR::initializeROM()
|
|||
ourDummyROMCode[281] = mySystem->randGenerator().next();
|
||||
|
||||
// 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
|
||||
std::copy_n(ourDummyROMCode.data(), ourDummyROMCode.size(), myImage.data() + (3<<11));
|
||||
|
|
|
@ -98,7 +98,7 @@ void CartridgeBUS::reset()
|
|||
void CartridgeBUS::setInitialState()
|
||||
{
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -68,11 +68,11 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size,
|
|||
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
|
||||
createCodeAccessBase(4096 * 7);
|
||||
createCodeAccessBase(28_KB);
|
||||
|
||||
// Pointer to the program ROM (28K @ 0 byte offset)
|
||||
// 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
|
||||
myBusDriverImage = myCDFRAM.data();
|
||||
|
@ -96,7 +96,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
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
|
||||
initializeStartBank(6);
|
||||
|
@ -114,7 +114,7 @@ void CartridgeCDF::reset()
|
|||
void CartridgeCDF::setInitialState()
|
||||
{
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
class System;
|
||||
class Thumbulator;
|
||||
class CartridgeCDFWidget;
|
||||
class CartridgeCDFInfoWidget;
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "Cart.hxx"
|
||||
|
@ -41,8 +39,8 @@ class CartridgeCDFInfoWidget;
|
|||
*/
|
||||
class CartridgeCDF : public Cartridge
|
||||
{
|
||||
friend CartridgeCDFWidget;
|
||||
friend CartridgeCDFInfoWidget;
|
||||
friend class CartridgeCDFWidget;
|
||||
friend class CartridgeCDFInfoWidget;
|
||||
friend class CartridgeRamCDFWidget;
|
||||
|
||||
public:
|
||||
|
|
|
@ -137,16 +137,16 @@ class CartridgeCV : public Cartridge
|
|||
|
||||
private:
|
||||
// The 2k ROM image for the cartridge
|
||||
std::array<uInt8, 0x0800> myImage;
|
||||
std::array<uInt8, 2_KB> myImage;
|
||||
|
||||
// Initial size of the cart data
|
||||
size_t mySize;
|
||||
|
||||
// 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)
|
||||
std::array<uInt8, 0x0400> myInitialRAM;
|
||||
std::array<uInt8, 1_KB> myInitialRAM;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -30,13 +30,13 @@ CartridgeDPC::CartridgeDPC(const ByteBuffer& image, size_t size,
|
|||
{
|
||||
// Make a copy of the entire image
|
||||
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)
|
||||
myProgramImage = myImage.data();
|
||||
|
||||
// Pointer to the display ROM (2K @ 8K offset)
|
||||
myDisplayImage = myProgramImage + 8192;
|
||||
myDisplayImage = myProgramImage + 8_KB;
|
||||
|
||||
// Initialize the DPC data fetcher registers
|
||||
myTops.fill(0);
|
||||
|
|
|
@ -44,16 +44,16 @@ CartridgeDPCPlus::CartridgeDPCPlus(const ByteBuffer& image, size_t size,
|
|||
if(mySize < myImage.size())
|
||||
myImage.fill(0);
|
||||
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)
|
||||
myProgramImage = myImage.data() + 0xC00;
|
||||
// Pointer to the program ROM (24K @ 3K offset; ignore first 3K)
|
||||
myProgramImage = myImage.data() + 3_KB;
|
||||
|
||||
// Pointer to the display RAM
|
||||
myDisplayImage = myDPCRAM.data() + 0xC00;
|
||||
myDisplayImage = myDPCRAM.data() + 3_KB;
|
||||
|
||||
// Pointer to the Frequency RAM
|
||||
myFrequencyImage = myDisplayImage + 0x1000;
|
||||
myFrequencyImage = myDisplayImage + 4_KB;
|
||||
|
||||
// Create Thumbulator ARM emulator
|
||||
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
|
||||
// with the default mask to use for DFxFRACLOW
|
||||
if(MD5::hash(image, 3*1024) == "8dd73b44fd11c488326ce507cbeb19d1")
|
||||
if(MD5::hash(image, 3_KB) == "8dd73b44fd11c488326ce507cbeb19d1")
|
||||
myFractionalLowMask = 0x0F0000;
|
||||
|
||||
setInitialState();
|
||||
|
@ -92,7 +92,7 @@ void CartridgeDPCPlus::setInitialState()
|
|||
myDPCRAM.fill(0);
|
||||
|
||||
// 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
|
||||
myTops.fill(0);
|
||||
|
|
|
@ -402,7 +402,7 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ bool CartDetector::isProbablyFA2(const ByteBuffer& image, size_t)
|
|||
// file sizes
|
||||
|
||||
// 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)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -327,10 +327,10 @@ class Controller : public Serializable
|
|||
|
||||
private:
|
||||
/// The boolean value on each digital pin
|
||||
bool myDigitalPinState[5];
|
||||
std::array<bool, 5> myDigitalPinState;
|
||||
|
||||
/// The analog value on each analog pin
|
||||
Int32 myAnalogPinValue[2];
|
||||
std::array<Int32, 2> myAnalogPinValue;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -75,7 +75,7 @@ void M6532::reset()
|
|||
myDDRA = myDDRB = myOutA = myOutB = 0x00;
|
||||
|
||||
// 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
|
||||
myInterruptFlag = 0x00;
|
||||
|
@ -383,7 +383,7 @@ bool M6532::save(Serializer& out) const
|
|||
|
||||
out.putByte(myInterruptFlag);
|
||||
out.putBool(myEdgeDetectPositive);
|
||||
out.putByteArray(myOutTimer, 4);
|
||||
out.putByteArray(myOutTimer.data(), myOutTimer.size());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -416,7 +416,7 @@ bool M6532::load(Serializer& in)
|
|||
|
||||
myInterruptFlag = in.getByte();
|
||||
myEdgeDetectPositive = in.getBool();
|
||||
in.getByteArray(myOutTimer, 4);
|
||||
in.getByteArray(myOutTimer.data(), myOutTimer.size());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
|
|
@ -210,7 +210,7 @@ class M6532 : public Device
|
|||
bool myEdgeDetectPositive;
|
||||
|
||||
// Last value written to the timer registers
|
||||
uInt8 myOutTimer[4];
|
||||
std::array<uInt8, 4> myOutTimer;
|
||||
|
||||
// Accessible bits in the interrupt flag register
|
||||
// All other bits are always zeroed
|
||||
|
|
|
@ -46,7 +46,7 @@ class MT24LC256
|
|||
|
||||
private:
|
||||
// Sizes of the EEPROM
|
||||
static constexpr uInt32 FLASH_SIZE = 32 * 1024;
|
||||
static constexpr uInt32 FLASH_SIZE = 32_KB;
|
||||
|
||||
public:
|
||||
static constexpr uInt32 PAGE_SIZE = 64;
|
||||
|
|
|
@ -41,11 +41,8 @@ System::System(Random& random, M6502& m6502, M6532& m6532,
|
|||
{
|
||||
// Initialize page access table
|
||||
PageAccess access(&myNullDevice, System::PageAccessType::READ);
|
||||
for(int page = 0; page < NUM_PAGES; ++page)
|
||||
{
|
||||
myPageAccessTable[page] = access;
|
||||
myPageIsDirtyTable[page] = false;
|
||||
}
|
||||
myPageAccessTable.fill(access);
|
||||
myPageIsDirtyTable.fill(false);
|
||||
|
||||
// Bus starts out unlocked (in other words, peek() changes myDataBusState)
|
||||
myDataBusLocked = false;
|
||||
|
@ -102,8 +99,7 @@ bool System::isPageDirty(uInt16 start_addr, uInt16 end_addr) const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void System::clearDirtyPages()
|
||||
{
|
||||
for(uInt32 i = 0; i < NUM_PAGES; ++i)
|
||||
myPageIsDirtyTable[i] = false;
|
||||
myPageIsDirtyTable.fill(false);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -399,10 +399,10 @@ class System : public Serializable
|
|||
NullDevice myNullDevice;
|
||||
|
||||
// The list of PageAccess structures
|
||||
PageAccess myPageAccessTable[NUM_PAGES];
|
||||
std::array<PageAccess, NUM_PAGES> myPageAccessTable;
|
||||
|
||||
// The list of dirty pages
|
||||
bool myPageIsDirtyTable[NUM_PAGES];
|
||||
std::array<bool, NUM_PAGES> myPageIsDirtyTable;
|
||||
|
||||
// The current state of the Data Bus
|
||||
uInt8 myDataBusState;
|
||||
|
|
|
@ -734,7 +734,7 @@ class TIA : public Device
|
|||
/**
|
||||
* The paddle readout circuits.
|
||||
*/
|
||||
PaddleReader myPaddleReaders[4];
|
||||
std::array<PaddleReader, 4> myPaddleReaders;
|
||||
|
||||
/**
|
||||
* Circuits for the "latched inputs".
|
||||
|
|
Loading…
Reference in New Issue