diff --git a/src/emucore/Cart2K.cxx b/src/emucore/Cart2K.cxx index a806f3b48..56c0ac632 100644 --- a/src/emucore/Cart2K.cxx +++ b/src/emucore/Cart2K.cxx @@ -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(mySize, System::PAGE_SIZE); + mySize = std::max(mySize, System::PAGE_SIZE); // Initialize ROM with illegal 6502 opcode that causes a real 6502 to jam myImage = make_unique(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(mySize) - 1; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart2K.hxx b/src/emucore/Cart2K.hxx index fd636e0cf..e3fc8834a 100644 --- a/src/emucore/Cart2K.hxx +++ b/src/emucore/Cart2K.hxx @@ -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 diff --git a/src/emucore/Cart4K.cxx b/src/emucore/Cart4K.cxx index 89196c993..1c1ee885f 100644 --- a/src/emucore/Cart4K.cxx +++ b/src/emucore/Cart4K.cxx @@ -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; -} diff --git a/src/emucore/Cart4K.hxx b/src/emucore/Cart4K.hxx index 2cd5f6adb..5285dba35 100644 --- a/src/emucore/Cart4K.hxx +++ b/src/emucore/Cart4K.hxx @@ -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). diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index a8f84fa1e..094b2420f 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -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)); diff --git a/src/emucore/CartBUS.cxx b/src/emucore/CartBUS.cxx index f916f5cef..09572f083 100644 --- a/src/emucore/CartBUS.cxx +++ b/src/emucore/CartBUS.cxx @@ -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); diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index d1a79a16d..a3b8d92f1 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -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); diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index 81c41c7f8..7c1e6aad4 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -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: diff --git a/src/emucore/CartCV.hxx b/src/emucore/CartCV.hxx index 9a614c01b..d0df0115f 100644 --- a/src/emucore/CartCV.hxx +++ b/src/emucore/CartCV.hxx @@ -137,16 +137,16 @@ class CartridgeCV : public Cartridge private: // The 2k ROM image for the cartridge - std::array myImage; + std::array myImage; // Initial size of the cart data size_t mySize; // The 1024 bytes of RAM - std::array myRAM; + std::array myRAM; // Initial RAM data from the cart (doesn't always exist) - std::array myInitialRAM; + std::array myInitialRAM; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index f129c7a23..e25ecf093 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -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); diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index 75aa3dd12..3badc9fba 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -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); diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index b6c52a339..957178419 100644 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -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; diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index 0a61a2fff..54442928c 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -327,10 +327,10 @@ class Controller : public Serializable private: /// The boolean value on each digital pin - bool myDigitalPinState[5]; + std::array myDigitalPinState; /// The analog value on each analog pin - Int32 myAnalogPinValue[2]; + std::array myAnalogPinValue; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx index d9bc051a5..b58a9f15c 100644 --- a/src/emucore/M6532.cxx +++ b/src/emucore/M6532.cxx @@ -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(...) { diff --git a/src/emucore/M6532.hxx b/src/emucore/M6532.hxx index 2eed285e4..569dfda77 100644 --- a/src/emucore/M6532.hxx +++ b/src/emucore/M6532.hxx @@ -210,7 +210,7 @@ class M6532 : public Device bool myEdgeDetectPositive; // Last value written to the timer registers - uInt8 myOutTimer[4]; + std::array myOutTimer; // Accessible bits in the interrupt flag register // All other bits are always zeroed diff --git a/src/emucore/MT24LC256.hxx b/src/emucore/MT24LC256.hxx index 2a2009764..8555f53a5 100644 --- a/src/emucore/MT24LC256.hxx +++ b/src/emucore/MT24LC256.hxx @@ -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; diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index ce4151627..46e238d9e 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -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); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index 074af0f44..63c314385 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -399,10 +399,10 @@ class System : public Serializable NullDevice myNullDevice; // The list of PageAccess structures - PageAccess myPageAccessTable[NUM_PAGES]; + std::array myPageAccessTable; // The list of dirty pages - bool myPageIsDirtyTable[NUM_PAGES]; + std::array myPageIsDirtyTable; // The current state of the Data Bus uInt8 myDataBusState; diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index aab7a483e..dcf467ebe 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -734,7 +734,7 @@ class TIA : public Device /** * The paddle readout circuits. */ - PaddleReader myPaddleReaders[4]; + std::array myPaddleReaders; /** * Circuits for the "latched inputs".