From 178c5b4eafb2a1ae58f2d8e8e6db6cc60dc8797f Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Thu, 30 Nov 2017 10:36:31 -0330 Subject: [PATCH] Changed 'const' to 'constexpr' in several places. Note that constexpr should be preferred, since it _guarantees_ compile-time usage, whereas 'const' alone doesn't necessarily do that. So constexpr is guaranteed to be more efficient. --- src/emucore/CartE7.hxx | 2 +- src/emucore/CartE78K.hxx | 2 +- src/emucore/CartMNetwork.cxx | 13 ++++++++----- src/emucore/CartMNetwork.hxx | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/emucore/CartE7.hxx b/src/emucore/CartE7.hxx index e2fa40965..fa2d809e5 100644 --- a/src/emucore/CartE7.hxx +++ b/src/emucore/CartE7.hxx @@ -82,7 +82,7 @@ class CartridgeE7 : public CartridgeMNetwork void checkSwitchBank(uInt16 address) override; // Number of banks - static const uInt32 BANK_COUNT = 8; + static constexpr uInt32 BANK_COUNT = 8; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/CartE78K.hxx b/src/emucore/CartE78K.hxx index dd08cb61d..9bdd562ec 100644 --- a/src/emucore/CartE78K.hxx +++ b/src/emucore/CartE78K.hxx @@ -80,7 +80,7 @@ class CartridgeE78K : public CartridgeMNetwork void checkSwitchBank(uInt16 address) override; // Number of banks - static const uInt32 BANK_COUNT = 4; + static constexpr uInt32 BANK_COUNT = 4; private: // Following constructors and assignment operators not supported diff --git a/src/emucore/CartMNetwork.cxx b/src/emucore/CartMNetwork.cxx index 7a7568d9d..e35d47089 100644 --- a/src/emucore/CartMNetwork.cxx +++ b/src/emucore/CartMNetwork.cxx @@ -20,11 +20,13 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeMNetwork::CartridgeMNetwork(const BytePtr& image, uInt32 size, - const Settings& settings) + const Settings& settings) : Cartridge(settings), myCurrentRAM(0) -{} +{ +} +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeMNetwork::initialize(const BytePtr& image, uInt32 size) { // Copy the ROM image into my buffer @@ -54,8 +56,9 @@ void CartridgeMNetwork::reset() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeMNetwork::setAccess(uInt16 addrFrom, uInt16 size, uInt16 directOffset, uInt8* directData, - uInt16 codeOffset, System::PageAccessType type, uInt16 addrMask) +void CartridgeMNetwork::setAccess(uInt16 addrFrom, uInt16 size, + uInt16 directOffset, uInt8* directData, uInt16 codeOffset, + System::PageAccessType type, uInt16 addrMask) { if(addrMask == 0) addrMask = size - 1; @@ -90,7 +93,7 @@ void CartridgeMNetwork::install(System& system) 0, nullptr, 0x1fc0, System::PA_NONE, 0x1fc0);*/ // Setup the second segment to always point to the last ROM slice - setAccess(0x1A00, 0x1FE0U & ~System::PAGE_MASK - 0x1A00, + setAccess(0x1A00, 0x1FE0U & (~System::PAGE_MASK - 0x1A00), myRAMSlice * BANK_SIZE, myImage, myRAMSlice * BANK_SIZE, System::PA_READ, BANK_SIZE - 1); myCurrentSlice[1] = myRAMSlice; diff --git a/src/emucore/CartMNetwork.hxx b/src/emucore/CartMNetwork.hxx index af79a1fa0..832221c55 100644 --- a/src/emucore/CartMNetwork.hxx +++ b/src/emucore/CartMNetwork.hxx @@ -165,13 +165,13 @@ class CartridgeMNetwork : public Cartridge void bankRAM(uInt16 bank); // Size of a ROM or RAM bank - static const uInt32 BANK_SIZE = 0x800; // 2K + static constexpr uInt32 BANK_SIZE = 0x800; // 2K private: // Size of RAM in the cart - static const uInt32 RAM_SIZE = 0x800; // 1K + 4 * 256B = 2K + static constexpr uInt32 RAM_SIZE = 0x800; // 1K + 4 * 256B = 2K // Number of slices with 4K address space - static const uInt32 NUM_SEGMENTS = 2; + static constexpr uInt32 NUM_SEGMENTS = 2; /** Query the size of the BS type.