diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiJoystickMachine.cpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiJoystickMachine.cpp
index c73bd37b7..7bf109e1b 100644
--- a/Analyser/Dynamic/MultiMachine/Implementation/MultiJoystickMachine.cpp
+++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiJoystickMachine.cpp
@@ -25,7 +25,7 @@ class MultiJoystick: public Inputs::Joystick {
}
}
- std::vector &get_inputs() final {
+ const std::vector &get_inputs() final {
if(inputs.empty()) {
for(const auto &joystick: joysticks_) {
std::vector joystick_inputs = joystick->get_inputs();
diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp
index 1292b403f..6fff286da 100644
--- a/Components/9918/Implementation/9918Base.hpp
+++ b/Components/9918/Implementation/9918Base.hpp
@@ -51,7 +51,7 @@ class Base {
}
protected:
- const static int output_lag = 11; // i.e. pixel output will occur 11 cycles after corresponding data read.
+ static constexpr int output_lag = 11; // i.e. pixel output will occur 11 cycles after corresponding data read.
// The default TMS palette.
const uint32_t palette[16] = {
diff --git a/Inputs/Joystick.hpp b/Inputs/Joystick.hpp
index 49f20dfcf..3d0313f78 100644
--- a/Inputs/Joystick.hpp
+++ b/Inputs/Joystick.hpp
@@ -98,7 +98,7 @@ class Joystick {
};
/// @returns The list of all inputs defined on this joystick.
- virtual std::vector &get_inputs() = 0;
+ virtual const std::vector &get_inputs() = 0;
/*!
Sets the digital value of @c input. This may have direct effect or
@@ -170,7 +170,7 @@ class ConcreteJoystick: public Joystick {
}
}
- std::vector &get_inputs() final {
+ const std::vector &get_inputs() final {
return inputs_;
}
@@ -223,7 +223,7 @@ class ConcreteJoystick: public Joystick {
}
private:
- std::vector inputs_;
+ const std::vector inputs_;
enum class StickType {
Digital,
diff --git a/Inputs/Keyboard.hpp b/Inputs/Keyboard.hpp
index 30bd84191..924526ce9 100644
--- a/Inputs/Keyboard.hpp
+++ b/Inputs/Keyboard.hpp
@@ -80,10 +80,11 @@ class Keyboard {
private:
std::set observed_keys_;
- std::set essential_modifiers_;
+ const std::set essential_modifiers_;
+ const bool is_exclusive_ = true;
+
std::vector key_states_;
Delegate *delegate_ = nullptr;
- bool is_exclusive_ = true;
};
}
diff --git a/Machines/Atari/2600/Atari2600.cpp b/Machines/Atari/2600/Atari2600.cpp
index 2580c428d..6906b72ab 100644
--- a/Machines/Atari/2600/Atari2600.cpp
+++ b/Machines/Atari/2600/Atari2600.cpp
@@ -29,8 +29,8 @@
#include "Cartridges/Unpaged.hpp"
namespace {
- static const double NTSC_clock_rate = 1194720;
- static const double PAL_clock_rate = 1182298;
+ static constexpr double NTSC_clock_rate = 1194720;
+ static constexpr double PAL_clock_rate = 1182298;
}
namespace Atari2600 {
diff --git a/Machines/KeyboardMachine.hpp b/Machines/KeyboardMachine.hpp
index fc83ded7b..bd90ded02 100644
--- a/Machines/KeyboardMachine.hpp
+++ b/Machines/KeyboardMachine.hpp
@@ -121,13 +121,13 @@ class MappedKeyboardMachine: public Inputs::Keyboard::Delegate, public KeyboardM
};
/// Terminates a key sequence from the character mapper.
- static const uint16_t KeyEndSequence = 0xffff;
+ static constexpr uint16_t KeyEndSequence = 0xffff;
/*!
Indicates that a key is not mapped (for the keyboard mapper) or that a
character cannot be typed (for the character mapper).
*/
- static const uint16_t KeyNotMapped = 0xfffe;
+ static constexpr uint16_t KeyNotMapped = 0xfffe;
/*!
Allows individual machines to provide the mapping between host keys
diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp
index 6356e12c6..7d40dea1d 100644
--- a/Machines/MasterSystem/MasterSystem.cpp
+++ b/Machines/MasterSystem/MasterSystem.cpp
@@ -133,30 +133,31 @@ class ConcreteMachine:
paging_registers_[2] = 0;
}
- // Load the BIOS if relevant.
- if(has_bios()) {
- // TODO: there's probably a million other versions of the Master System BIOS; try to build a
- // CRC32 catalogue of those. So far:
- //
- // 0072ed54 = US/European BIOS 1.3
- // 48d44a13 = Japanese BIOS 2.1
- const bool is_japanese = target.region == Target::Region::Japan;
- const auto roms = rom_fetcher(
- { {"MasterSystem",
- is_japanese ? "the Japanese Master System BIOS" : "the European/US Master System BIOS",
- is_japanese ? "japanese-bios.sms" : "bios.sms",
- 8*1024,
- { is_japanese ? 0x48d44a13u : 0x0072ed54u }
- } }
- );
- if(!roms[0]) {
- // No BIOS found; attempt to boot as though it has already disabled itself.
- memory_control_ |= 0x08;
- std::cerr << "No BIOS found; attempting to start cartridge directly" << std::endl;
- } else {
- roms[0]->resize(8*1024);
- memcpy(&bios_, roms[0]->data(), roms[0]->size());
- }
+ // Load the BIOS if available.
+ //
+ // TODO: there's probably a million other versions of the Master System BIOS; try to build a
+ // CRC32 catalogue of those. So far:
+ //
+ // 0072ed54 = US/European BIOS 1.3
+ // 48d44a13 = Japanese BIOS 2.1
+ const bool is_japanese = target.region == Target::Region::Japan;
+ const auto roms = rom_fetcher(
+ { {"MasterSystem",
+ is_japanese ? "the Japanese Master System BIOS" : "the European/US Master System BIOS",
+ is_japanese ? "japanese-bios.sms" : "bios.sms",
+ 8*1024,
+ { is_japanese ? 0x48d44a13u : 0x0072ed54u }
+ } }
+ );
+ if(!roms[0]) {
+ // No BIOS found; attempt to boot as though it has already disabled itself.
+ has_bios_ = false;
+ memory_control_ |= 0x08;
+ std::cerr << "No BIOS found; attempting to start cartridge directly" << std::endl;
+ } else {
+ has_bios_ = true;
+ roms[0]->resize(8*1024);
+ memcpy(&bios_, roms[0]->data(), roms[0]->size());
}
page_cartridge();
@@ -486,9 +487,9 @@ class ConcreteMachine:
}
using Target = Analyser::Static::Sega::Target;
- Target::Model model_;
- Target::Region region_;
- Target::PagingScheme paging_scheme_;
+ const Target::Model model_;
+ const Target::Region region_;
+ const Target::PagingScheme paging_scheme_;
CPU::Z80::Processor z80_;
JustInTimeActor vdp_;
@@ -550,13 +551,11 @@ class ConcreteMachine:
}
// Throw the BIOS on top if this machine has one and it isn't disabled.
- if(has_bios() && !(memory_control_ & 0x08)) {
+ if(has_bios_ && !(memory_control_ & 0x08)) {
map(read_pointers_, bios_, 8*1024, 0);
}
}
- bool has_bios() {
- return is_master_system(model_) && region_ != Target::Region::Japan;
- }
+ bool has_bios_ = true;
};
}
diff --git a/Outputs/CRT/CRT.hpp b/Outputs/CRT/CRT.hpp
index d640b01a7..2e6f34e22 100644
--- a/Outputs/CRT/CRT.hpp
+++ b/Outputs/CRT/CRT.hpp
@@ -83,7 +83,7 @@ class CRT {
Outputs::Display::ScanTarget *scan_target_ = &Outputs::Display::NullScanTarget::singleton;
Outputs::Display::ScanTarget::Modals scan_target_modals_;
- static const uint8_t DefaultAmplitude = 80;
+ static constexpr uint8_t DefaultAmplitude = 80;
#ifndef NDEBUG
size_t allocated_data_length_ = std::numeric_limits::min();
diff --git a/Processors/68000/68000.hpp b/Processors/68000/68000.hpp
index 6a7f0399b..afc90b8af 100644
--- a/Processors/68000/68000.hpp
+++ b/Processors/68000/68000.hpp
@@ -91,7 +91,7 @@ struct Microcycle {
/// Provides the 68000's bus grant line — indicating whether a bus request has been acknowledged.
static constexpr int BusGrant = 1 << 10;
- /// Contains a valid combination of the various static const int flags, describing the operation
+ /// Contains a valid combination of the various static constexpr int flags, describing the operation
/// performed by this Microcycle.
int operation = 0;
diff --git a/Processors/68000/Implementation/68000Storage.hpp b/Processors/68000/Implementation/68000Storage.hpp
index 79971d479..913deb09f 100644
--- a/Processors/68000/Implementation/68000Storage.hpp
+++ b/Processors/68000/Implementation/68000Storage.hpp
@@ -323,7 +323,7 @@ class ProcessorStorage {
static constexpr int DestinationMask = 1 << 6;
uint8_t action = uint8_t(Action::None);
- static const uint16_t NoBusProgram = std::numeric_limits::max();
+ static constexpr uint16_t NoBusProgram = std::numeric_limits::max();
uint16_t bus_program = NoBusProgram;
MicroOp() {}