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.
This commit is contained in:
Stephen Anthony 2017-11-30 10:36:31 -03:30
parent a636e6859d
commit 178c5b4eaf
4 changed files with 13 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -23,8 +23,10 @@ CartridgeMNetwork::CartridgeMNetwork(const BytePtr& image, uInt32 size,
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;

View File

@ -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.