diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.cpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.cpp index d7ec688c6..5c12ff92f 100644 --- a/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.cpp +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.cpp @@ -36,7 +36,7 @@ void MultiKeyboardMachine::type_string(const std::string &string) { } } -bool MultiKeyboardMachine::can_type(char c) { +bool MultiKeyboardMachine::can_type(char c) const { bool can_type = true; for(const auto &machine: machines_) { can_type &= machine->can_type(c); @@ -70,10 +70,10 @@ void MultiKeyboardMachine::MultiKeyboard::reset_all_keys() { } } -const std::set &MultiKeyboardMachine::MultiKeyboard::observed_keys() { +const std::set &MultiKeyboardMachine::MultiKeyboard::observed_keys() const { return observed_keys_; } -bool MultiKeyboardMachine::MultiKeyboard::is_exclusive() { +bool MultiKeyboardMachine::MultiKeyboard::is_exclusive() const { return is_exclusive_; } diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.hpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.hpp index 723cb05a7..aa5433563 100644 --- a/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.hpp +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiKeyboardMachine.hpp @@ -34,8 +34,8 @@ class MultiKeyboardMachine: public MachineTypes::KeyboardMachine { bool set_key_pressed(Key key, char value, bool is_pressed) final; void reset_all_keys() final; - const std::set &observed_keys() final; - bool is_exclusive() final; + const std::set &observed_keys() const final; + bool is_exclusive() const final; private: const std::vector &machines_; @@ -51,7 +51,7 @@ class MultiKeyboardMachine: public MachineTypes::KeyboardMachine { void clear_all_keys() final; void set_key_state(uint16_t key, bool is_pressed) final; void type_string(const std::string &) final; - bool can_type(char c) final; + bool can_type(char c) const final; Inputs::Keyboard &get_keyboard() final; }; diff --git a/ClockReceiver/DeferredQueue.hpp b/ClockReceiver/DeferredQueue.hpp index be1c7b01e..a2015aea3 100644 --- a/ClockReceiver/DeferredQueue.hpp +++ b/ClockReceiver/DeferredQueue.hpp @@ -49,7 +49,7 @@ template class DeferredQueue { @returns The amount of time until the next enqueued action will occur, or TimeUnit(-1) if the queue is empty. */ - TimeUnit time_until_next_action() { + TimeUnit time_until_next_action() const { if(pending_actions_.empty()) return TimeUnit(-1); return pending_actions_.front().delay; } @@ -95,7 +95,7 @@ template class DeferredQueue { template class DeferredQueuePerformer: public DeferredQueue { public: /// Constructs a DeferredQueue that will call target(period) in between deferred actions. - DeferredQueuePerformer(std::function &&target) : target_(std::move(target)) {} + constexpr DeferredQueuePerformer(std::function &&target) : target_(std::move(target)) {} /*! Runs for @c length units of time. diff --git a/Components/9918/9918.cpp b/Components/9918/9918.cpp index 42b4e8a44..11512c7ae 100644 --- a/Components/9918/9918.cpp +++ b/Components/9918/9918.cpp @@ -129,7 +129,7 @@ void TMS9918::set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); } -Outputs::Display::DisplayType TMS9918::get_display_type() { +Outputs::Display::DisplayType TMS9918::get_display_type() const { return crt_.get_display_type(); } diff --git a/Components/9918/9918.hpp b/Components/9918/9918.hpp index 4f2530bf3..70f9d55c1 100644 --- a/Components/9918/9918.hpp +++ b/Components/9918/9918.hpp @@ -51,7 +51,7 @@ class TMS9918: public Base { void set_display_type(Outputs::Display::DisplayType); /*! Gets the type of display the CRT will request. */ - Outputs::Display::DisplayType get_display_type(); + Outputs::Display::DisplayType get_display_type() const; /*! Runs the VCP for the number of cycles indicate; it is an implicit assumption of the code diff --git a/Inputs/Keyboard.cpp b/Inputs/Keyboard.cpp index 16c342f71..6491744e5 100644 --- a/Inputs/Keyboard.cpp +++ b/Inputs/Keyboard.cpp @@ -30,7 +30,7 @@ bool Keyboard::set_key_pressed(Key key, char value, bool is_pressed) { return false; } -const std::set &Keyboard::get_essential_modifiers() { +const std::set &Keyboard::get_essential_modifiers() const { return essential_modifiers_; } @@ -43,16 +43,16 @@ void Keyboard::set_delegate(Delegate *delegate) { delegate_ = delegate; } -bool Keyboard::get_key_state(Key key) { +bool Keyboard::get_key_state(Key key) const { const size_t key_offset = size_t(key); if(key_offset >= key_states_.size()) return false; return key_states_[key_offset]; } -const std::set &Keyboard::observed_keys() { +const std::set &Keyboard::observed_keys() const { return observed_keys_; } -bool Keyboard::is_exclusive() { +bool Keyboard::is_exclusive() const { return is_exclusive_; } diff --git a/Inputs/Keyboard.hpp b/Inputs/Keyboard.hpp index 924526ce9..56105b279 100644 --- a/Inputs/Keyboard.hpp +++ b/Inputs/Keyboard.hpp @@ -53,10 +53,10 @@ class Keyboard { virtual void reset_all_keys(); /// @returns a set of all Keys that this keyboard responds to. - virtual const std::set &observed_keys(); + virtual const std::set &observed_keys() const; /// @returns the list of modifiers that this keyboard considers 'essential' (i.e. both mapped and highly used). - virtual const std::set &get_essential_modifiers(); + virtual const std::set &get_essential_modifiers() const; /*! @returns @c true if this keyboard, on its original machine, looked @@ -68,7 +68,7 @@ class Keyboard { which has some buttons that you'd expect an emulator to map to its host keyboard but which does not offer a full keyboard. */ - virtual bool is_exclusive(); + virtual bool is_exclusive() const; // Delegate interface. struct Delegate { @@ -76,7 +76,7 @@ class Keyboard { virtual void reset_all_keys(Keyboard *keyboard) = 0; }; void set_delegate(Delegate *delegate); - bool get_key_state(Key key); + bool get_key_state(Key key) const; private: std::set observed_keys_; diff --git a/Inputs/QuadratureMouse/QuadratureMouse.hpp b/Inputs/QuadratureMouse/QuadratureMouse.hpp index e3ba34d6b..b1b596a79 100644 --- a/Inputs/QuadratureMouse/QuadratureMouse.hpp +++ b/Inputs/QuadratureMouse/QuadratureMouse.hpp @@ -111,8 +111,8 @@ class QuadratureMouse: public Mouse { private: const int number_of_buttons_ = 0; - std::atomic button_flags_; - std::atomic axes_[2]; + std::atomic button_flags_{0}; + std::atomic axes_[2]{0, 0}; int primaries_[2] = {0, 0}; int secondaries_[2] = {0, 0}; diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index 1d4db3b8c..e05d92b95 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -346,7 +346,7 @@ class CRTCBusHandler { } /// Gets the type of display. - Outputs::Display::DisplayType get_display_type() { + Outputs::Display::DisplayType get_display_type() const { return crt_.get_display_type(); } @@ -1044,7 +1044,7 @@ template class ConcreteMachine: } /// A CRTMachine function; gets the output display type. - Outputs::Display::DisplayType get_display_type() { + Outputs::Display::DisplayType get_display_type() const final { return crtc_bus_handler_.get_display_type(); } @@ -1085,15 +1085,15 @@ template class ConcreteMachine: Utility::TypeRecipient::add_typer(string); } - bool can_type(char c) final { + bool can_type(char c) const final { return Utility::TypeRecipient::can_type(c); } - HalfCycles get_typer_delay() final { + HalfCycles get_typer_delay() const final { return z80_.get_is_resetting() ? Cycles(3'400'000) : Cycles(0); } - HalfCycles get_typer_frequency() final { + HalfCycles get_typer_frequency() const final { return Cycles(80'000); // Perform one key transition per frame. } diff --git a/Machines/AmstradCPC/Keyboard.cpp b/Machines/AmstradCPC/Keyboard.cpp index 21aee331b..98b67e8ae 100644 --- a/Machines/AmstradCPC/Keyboard.cpp +++ b/Machines/AmstradCPC/Keyboard.cpp @@ -10,7 +10,7 @@ using namespace AmstradCPC; -uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { #define BIND(source, dest) case Inputs::Keyboard::Key::source: return dest switch(key) { default: break; @@ -77,7 +77,7 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { return MachineTypes::MappedKeyboardMachine::KeyNotMapped; } -uint16_t *CharacterMapper::sequence_for_character(char character) { +const uint16_t *CharacterMapper::sequence_for_character(char character) const { #define KEYS(...) {__VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define SHIFT(...) {KeyShift, __VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define X {MachineTypes::MappedKeyboardMachine::KeyNotMapped} @@ -154,6 +154,6 @@ uint16_t *CharacterMapper::sequence_for_character(char character) { return table_lookup_sequence_for_character(key_sequences, sizeof(key_sequences), character); } -bool CharacterMapper::needs_pause_after_key(uint16_t key) { +bool CharacterMapper::needs_pause_after_key(uint16_t key) const { return key != KeyControl && key != KeyShift; } diff --git a/Machines/AmstradCPC/Keyboard.hpp b/Machines/AmstradCPC/Keyboard.hpp index b477b618a..120dbc394 100644 --- a/Machines/AmstradCPC/Keyboard.hpp +++ b/Machines/AmstradCPC/Keyboard.hpp @@ -34,14 +34,14 @@ enum Key: uint16_t { }; struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key); + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const override; }; struct CharacterMapper: public ::Utility::CharacterMapper { - uint16_t *sequence_for_character(char character) override; + const uint16_t *sequence_for_character(char character) const override; - bool needs_pause_after_reset_all_keys() override { return false; } - bool needs_pause_after_key(uint16_t key) override; + bool needs_pause_after_reset_all_keys() const override { return false; } + bool needs_pause_after_key(uint16_t key) const override; }; }; diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index b3f1b2905..e57fca73a 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -423,7 +423,7 @@ template class ConcreteMachine: video_.set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return video_.get_display_type(); } @@ -857,7 +857,7 @@ template class ConcreteMachine: string_serialiser_ = std::make_unique(string, true); } - bool can_type(char c) final { + bool can_type(char c) const final { // Make an effort to type the entire printable ASCII range. return c >= 32 && c < 127; } diff --git a/Machines/Apple/AppleII/Video.cpp b/Machines/Apple/AppleII/Video.cpp index 70aa02b8c..c249b3540 100644 --- a/Machines/Apple/AppleII/Video.cpp +++ b/Machines/Apple/AppleII/Video.cpp @@ -55,7 +55,7 @@ void VideoBase::set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); } -Outputs::Display::DisplayType VideoBase::get_display_type() { +Outputs::Display::DisplayType VideoBase::get_display_type() const { return crt_.get_display_type(); } diff --git a/Machines/Apple/AppleII/Video.hpp b/Machines/Apple/AppleII/Video.hpp index 4f2623d14..07297222e 100644 --- a/Machines/Apple/AppleII/Video.hpp +++ b/Machines/Apple/AppleII/Video.hpp @@ -47,7 +47,7 @@ class VideoBase { void set_display_type(Outputs::Display::DisplayType); /// Gets the type of output. - Outputs::Display::DisplayType get_display_type(); + Outputs::Display::DisplayType get_display_type() const; /* Descriptions for the setters below are taken verbatim from diff --git a/Machines/Apple/Macintosh/Keyboard.cpp b/Machines/Apple/Macintosh/Keyboard.cpp index c1c5a5ae6..e9631857f 100644 --- a/Machines/Apple/Macintosh/Keyboard.cpp +++ b/Machines/Apple/Macintosh/Keyboard.cpp @@ -10,7 +10,7 @@ using namespace Apple::Macintosh; -uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { using Key = Inputs::Keyboard::Key; using MacKey = Apple::Macintosh::Key; switch(key) { diff --git a/Machines/Apple/Macintosh/Keyboard.hpp b/Machines/Apple/Macintosh/Keyboard.hpp index 158776991..241fef658 100644 --- a/Machines/Apple/Macintosh/Keyboard.hpp +++ b/Machines/Apple/Macintosh/Keyboard.hpp @@ -291,7 +291,7 @@ class Keyboard { Provides a mapping from idiomatic PC keys to Macintosh keys. */ class KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) final; + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final; }; } diff --git a/Machines/Atari/ST/AtariST.cpp b/Machines/Atari/ST/AtariST.cpp index fa566ba04..722604358 100644 --- a/Machines/Atari/ST/AtariST.cpp +++ b/Machines/Atari/ST/AtariST.cpp @@ -141,7 +141,7 @@ class ConcreteMachine: video_->set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return video_->get_display_type(); } diff --git a/Machines/Atari/ST/IntelligentKeyboard.cpp b/Machines/Atari/ST/IntelligentKeyboard.cpp index 06f848778..a1f325b9c 100644 --- a/Machines/Atari/ST/IntelligentKeyboard.cpp +++ b/Machines/Atari/ST/IntelligentKeyboard.cpp @@ -22,11 +22,6 @@ IntelligentKeyboard::IntelligentKeyboard(Serial::Line &input, Serial::Line &outp // Add two joysticks into the mix. joysticks_.emplace_back(new Joystick); joysticks_.emplace_back(new Joystick); - - mouse_button_state_ = 0; - mouse_button_events_ = 0; - mouse_movement_[0] = 0; - mouse_movement_[1] = 0; } bool IntelligentKeyboard::serial_line_did_produce_bit(Serial::Line *, int bit) { @@ -361,7 +356,7 @@ void IntelligentKeyboard::set_key_state(Key key, bool is_pressed) { } } -uint16_t IntelligentKeyboard::KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t IntelligentKeyboard::KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { using Key = Inputs::Keyboard::Key; using STKey = Atari::ST::Key; switch(key) { diff --git a/Machines/Atari/ST/IntelligentKeyboard.hpp b/Machines/Atari/ST/IntelligentKeyboard.hpp index 54b6d0560..fb96045e6 100644 --- a/Machines/Atari/ST/IntelligentKeyboard.hpp +++ b/Machines/Atari/ST/IntelligentKeyboard.hpp @@ -63,7 +63,7 @@ class IntelligentKeyboard: void set_key_state(Key key, bool is_pressed); class KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) final; + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final; }; const std::vector> &get_joysticks() { @@ -127,9 +127,9 @@ class IntelligentKeyboard: void post_relative_mouse_event(int x, int y); // Received mouse state. - std::atomic mouse_movement_[2]; - std::atomic mouse_button_state_; - std::atomic mouse_button_events_; + std::atomic mouse_movement_[2]{0, 0}; + std::atomic mouse_button_state_{0}; + std::atomic mouse_button_events_{0}; // MARK: - Joystick. void disable_joysticks(); diff --git a/Machines/Atari/ST/Video.cpp b/Machines/Atari/ST/Video.cpp index 5c3ba851f..5a12ff781 100644 --- a/Machines/Atari/ST/Video.cpp +++ b/Machines/Atari/ST/Video.cpp @@ -146,7 +146,7 @@ void Video::set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); } -Outputs::Display::DisplayType Video::get_display_type() { +Outputs::Display::DisplayType Video::get_display_type() const { return crt_.get_display_type(); } diff --git a/Machines/Atari/ST/Video.hpp b/Machines/Atari/ST/Video.hpp index 851d8674c..867d6c632 100644 --- a/Machines/Atari/ST/Video.hpp +++ b/Machines/Atari/ST/Video.hpp @@ -57,7 +57,7 @@ class Video { /*! Gets the type of output. */ - Outputs::Display::DisplayType get_display_type(); + Outputs::Display::DisplayType get_display_type() const; /*! Produces the next @c duration period of pixels. diff --git a/Machines/ColecoVision/ColecoVision.cpp b/Machines/ColecoVision/ColecoVision.cpp index 5660723ac..0de8f56d0 100644 --- a/Machines/ColecoVision/ColecoVision.cpp +++ b/Machines/ColecoVision/ColecoVision.cpp @@ -189,7 +189,7 @@ class ConcreteMachine: vdp_->set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return vdp_->get_display_type(); } diff --git a/Machines/Commodore/Vic-20/Keyboard.cpp b/Machines/Commodore/Vic-20/Keyboard.cpp index edcb75c87..1b79bd414 100644 --- a/Machines/Commodore/Vic-20/Keyboard.cpp +++ b/Machines/Commodore/Vic-20/Keyboard.cpp @@ -10,7 +10,7 @@ using namespace Commodore::Vic20; -uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { #define BIND(source, dest) case Inputs::Keyboard::Key::source: return Commodore::Vic20::dest switch(key) { default: break; @@ -79,7 +79,7 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { return MachineTypes::MappedKeyboardMachine::KeyNotMapped; } -uint16_t *CharacterMapper::sequence_for_character(char character) { +const uint16_t *CharacterMapper::sequence_for_character(char character) const { #define KEYS(...) {__VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define SHIFT(...) {KeyLShift, __VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define X {MachineTypes::MappedKeyboardMachine::KeyNotMapped} diff --git a/Machines/Commodore/Vic-20/Keyboard.hpp b/Machines/Commodore/Vic-20/Keyboard.hpp index 84d54c6dd..cfe7f8a8b 100644 --- a/Machines/Commodore/Vic-20/Keyboard.hpp +++ b/Machines/Commodore/Vic-20/Keyboard.hpp @@ -48,11 +48,11 @@ enum Key: uint16_t { }; struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key); + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final; }; struct CharacterMapper: public ::Utility::CharacterMapper { - uint16_t *sequence_for_character(char character); + const uint16_t *sequence_for_character(char character) const final; }; } diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 2df232ed4..9630f2dd4 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -646,7 +646,7 @@ class ConcreteMachine: mos6560_.set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return mos6560_.get_display_type(); } @@ -663,7 +663,7 @@ class ConcreteMachine: Utility::TypeRecipient::add_typer(string); } - bool can_type(char c) final { + bool can_type(char c) const final { return Utility::TypeRecipient::can_type(c); } diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index c987172d3..39251917f 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -409,7 +409,7 @@ class ConcreteMachine: video_output_.set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return video_output_.get_display_type(); } @@ -426,11 +426,11 @@ class ConcreteMachine: evaluate_interrupts(); } - HalfCycles get_typer_delay() final { + HalfCycles get_typer_delay() const final { return m6502_.get_is_resetting() ? Cycles(750'000) : Cycles(0); } - HalfCycles get_typer_frequency() final { + HalfCycles get_typer_frequency() const final { return Cycles(60'000); } @@ -438,7 +438,7 @@ class ConcreteMachine: Utility::TypeRecipient::add_typer(string); } - bool can_type(char c) final { + bool can_type(char c) const final { return Utility::TypeRecipient::can_type(c); } diff --git a/Machines/Electron/Keyboard.cpp b/Machines/Electron/Keyboard.cpp index e09125dad..887ac5aff 100644 --- a/Machines/Electron/Keyboard.cpp +++ b/Machines/Electron/Keyboard.cpp @@ -10,7 +10,7 @@ using namespace Electron; -uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { #define BIND(source, dest) case Inputs::Keyboard::Key::source: return Electron::Key::dest switch(key) { default: break; @@ -69,7 +69,7 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { return MachineTypes::MappedKeyboardMachine::KeyNotMapped; } -uint16_t *CharacterMapper::sequence_for_character(char character) { +const uint16_t *CharacterMapper::sequence_for_character(char character) const { #define KEYS(...) {__VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define SHIFT(...) {KeyShift, __VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define CTRL(...) {KeyControl, __VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} @@ -147,6 +147,6 @@ uint16_t *CharacterMapper::sequence_for_character(char character) { return table_lookup_sequence_for_character(key_sequences, sizeof(key_sequences), character); } -bool CharacterMapper::needs_pause_after_key(uint16_t key) { +bool CharacterMapper::needs_pause_after_key(uint16_t key) const { return key != KeyControl && key != KeyShift && key != KeyFunc; } diff --git a/Machines/Electron/Keyboard.hpp b/Machines/Electron/Keyboard.hpp index 7b95e8967..d41f6500c 100644 --- a/Machines/Electron/Keyboard.hpp +++ b/Machines/Electron/Keyboard.hpp @@ -37,14 +37,14 @@ enum Key: uint16_t { }; struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) final; + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final; }; struct CharacterMapper: public ::Utility::CharacterMapper { - uint16_t *sequence_for_character(char character) override; + const uint16_t *sequence_for_character(char character) const override; - bool needs_pause_after_reset_all_keys() override { return false; } - bool needs_pause_after_key(uint16_t key) override; + bool needs_pause_after_reset_all_keys() const override { return false; } + bool needs_pause_after_key(uint16_t key) const override; }; }; diff --git a/Machines/Electron/Video.cpp b/Machines/Electron/Video.cpp index 7cc20fcf7..461057ebf 100644 --- a/Machines/Electron/Video.cpp +++ b/Machines/Electron/Video.cpp @@ -64,7 +64,7 @@ void VideoOutput::set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); } -Outputs::Display::DisplayType VideoOutput::get_display_type() { +Outputs::Display::DisplayType VideoOutput::get_display_type() const { return crt_.get_display_type(); } diff --git a/Machines/Electron/Video.hpp b/Machines/Electron/Video.hpp index aa2b28dec..137dca0e0 100644 --- a/Machines/Electron/Video.hpp +++ b/Machines/Electron/Video.hpp @@ -46,7 +46,7 @@ class VideoOutput { void set_display_type(Outputs::Display::DisplayType); /// Gets the type of output. - Outputs::Display::DisplayType get_display_type(); + Outputs::Display::DisplayType get_display_type() const; /*! Writes @c value to the register at @c address. May mutate the results of @c get_next_interrupt, diff --git a/Machines/KeyboardMachine.hpp b/Machines/KeyboardMachine.hpp index bd90ded02..1ef6fcec0 100644 --- a/Machines/KeyboardMachine.hpp +++ b/Machines/KeyboardMachine.hpp @@ -49,7 +49,7 @@ class KeyboardMachine: public KeyActions { /*! @returns @c true if this machine can type the character @c c as part of a @c type_string; @c false otherwise. */ - virtual bool can_type(char c) { return false; } + virtual bool can_type(char c) const { return false; } /*! Provides a destination for keyboard input. @@ -117,7 +117,7 @@ class MappedKeyboardMachine: public Inputs::Keyboard::Delegate, public KeyboardM */ class KeyboardMapper { public: - virtual uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) = 0; + virtual uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const = 0; }; /// Terminates a key sequence from the character mapper. diff --git a/Machines/MSX/Keyboard.cpp b/Machines/MSX/Keyboard.cpp index 2ca15e306..494ab6232 100644 --- a/Machines/MSX/Keyboard.cpp +++ b/Machines/MSX/Keyboard.cpp @@ -8,7 +8,7 @@ #include "Keyboard.hpp" -uint16_t MSX::KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t MSX::KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { #define BIND(source, dest) case Inputs::Keyboard::Key::source: return MSX::Key::dest switch(key) { BIND(k0, Key0); BIND(k1, Key1); BIND(k2, Key2); BIND(k3, Key3); BIND(k4, Key4); diff --git a/Machines/MSX/Keyboard.hpp b/Machines/MSX/Keyboard.hpp index 07fd35526..445a1a1f0 100644 --- a/Machines/MSX/Keyboard.hpp +++ b/Machines/MSX/Keyboard.hpp @@ -34,7 +34,7 @@ enum Key: uint16_t { }; struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key); + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final; }; }; diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index faabc8142..2bd9ee16c 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -284,7 +284,7 @@ class ConcreteMachine: vdp_->set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return vdp_->get_display_type(); } @@ -367,7 +367,7 @@ class ConcreteMachine: ); } - bool can_type(char c) final { + bool can_type(char c) const final { // Make an effort to type the entire printable ASCII range. return c >= 32 && c < 127; } diff --git a/Machines/MasterSystem/MasterSystem.cpp b/Machines/MasterSystem/MasterSystem.cpp index 7d40dea1d..f43e999ea 100644 --- a/Machines/MasterSystem/MasterSystem.cpp +++ b/Machines/MasterSystem/MasterSystem.cpp @@ -201,7 +201,7 @@ class ConcreteMachine: vdp_->set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return vdp_->get_display_type(); } diff --git a/Machines/Oric/Keyboard.cpp b/Machines/Oric/Keyboard.cpp index 40661448e..2e373ad57 100644 --- a/Machines/Oric/Keyboard.cpp +++ b/Machines/Oric/Keyboard.cpp @@ -10,7 +10,7 @@ using namespace Oric; -uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { #define BIND(source, dest) case Inputs::Keyboard::Key::source: return Oric::dest switch(key) { default: break; @@ -54,7 +54,7 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { return MachineTypes::MappedKeyboardMachine::KeyNotMapped; } -uint16_t *CharacterMapper::sequence_for_character(char character) { +const uint16_t *CharacterMapper::sequence_for_character(char character) const { #define KEYS(...) {__VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define SHIFT(...) {KeyLeftShift, __VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define X {MachineTypes::MappedKeyboardMachine::KeyNotMapped} diff --git a/Machines/Oric/Keyboard.hpp b/Machines/Oric/Keyboard.hpp index 87c20d1c1..d40fd0abf 100644 --- a/Machines/Oric/Keyboard.hpp +++ b/Machines/Oric/Keyboard.hpp @@ -37,11 +37,11 @@ enum Key: uint16_t { }; struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key); + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final; }; struct CharacterMapper: public ::Utility::CharacterMapper { - uint16_t *sequence_for_character(char character); + const uint16_t *sequence_for_character(char character) const final; }; }; diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 05d78197e..e336148a0 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -555,7 +555,7 @@ template class Co video_output_.set_display_type(display_type); } - Outputs::Display::DisplayType get_display_type() final { + Outputs::Display::DisplayType get_display_type() const final { return video_output_.get_display_type(); } @@ -583,7 +583,7 @@ template class Co string_serialiser_ = std::make_unique(string, true); } - bool can_type(char c) final { + bool can_type(char c) const final { // Make an effort to type the entire printable ASCII range. return c >= 32 && c < 127; } diff --git a/Machines/Oric/Video.cpp b/Machines/Oric/Video.cpp index 8bbc8563a..30fe2f805 100644 --- a/Machines/Oric/Video.cpp +++ b/Machines/Oric/Video.cpp @@ -67,7 +67,7 @@ void VideoOutput::set_display_type(Outputs::Display::DisplayType display_type) { } } -Outputs::Display::DisplayType VideoOutput::get_display_type() { +Outputs::Display::DisplayType VideoOutput::get_display_type() const { return crt_.get_display_type(); } diff --git a/Machines/Oric/Video.hpp b/Machines/Oric/Video.hpp index fe3001efe..59181526d 100644 --- a/Machines/Oric/Video.hpp +++ b/Machines/Oric/Video.hpp @@ -27,7 +27,7 @@ class VideoOutput { void set_scan_target(Outputs::Display::ScanTarget *scan_target); void set_display_type(Outputs::Display::DisplayType display_type); - Outputs::Display::DisplayType get_display_type(); + Outputs::Display::DisplayType get_display_type() const; Outputs::Display::ScanStatus get_scaled_scan_status() const; void register_crt_frequency_mismatch(); diff --git a/Machines/ScanProducer.hpp b/Machines/ScanProducer.hpp index 4393086e1..3fbf95839 100644 --- a/Machines/ScanProducer.hpp +++ b/Machines/ScanProducer.hpp @@ -78,7 +78,7 @@ class ScanProducer { Maps back from Outputs::Display::VideoSignal to Configurable::Display, calling @c get_display_type for the input. */ - Configurable::Display get_video_signal_configurable() { + Configurable::Display get_video_signal_configurable() const { switch(get_display_type()) { default: case Outputs::Display::DisplayType::RGB: return Configurable::Display::RGB; @@ -96,7 +96,7 @@ class ScanProducer { /*! Gets the display type. */ - virtual Outputs::Display::DisplayType get_display_type() { return Outputs::Display::DisplayType::RGB; } + virtual Outputs::Display::DisplayType get_display_type() const { return Outputs::Display::DisplayType::RGB; } }; } diff --git a/Machines/Utility/Typer.cpp b/Machines/Utility/Typer.cpp index 824f8278a..4470f97c2 100644 --- a/Machines/Utility/Typer.cpp +++ b/Machines/Utility/Typer.cpp @@ -134,7 +134,7 @@ bool Typer::type_next_character() { // MARK: - Character mapper -uint16_t *CharacterMapper::table_lookup_sequence_for_character(KeySequence *sequences, std::size_t length, char character) { +uint16_t *CharacterMapper::table_lookup_sequence_for_character(KeySequence *sequences, std::size_t length, char character) const { std::size_t ucharacter = size_t((unsigned char)character); if(ucharacter >= (length / sizeof(KeySequence))) return nullptr; if(sequences[ucharacter][0] == MachineTypes::MappedKeyboardMachine::KeyNotMapped) return nullptr; diff --git a/Machines/Utility/Typer.hpp b/Machines/Utility/Typer.hpp index 8f73b8c99..0e2ed9ef1 100644 --- a/Machines/Utility/Typer.hpp +++ b/Machines/Utility/Typer.hpp @@ -26,19 +26,19 @@ class CharacterMapper { virtual ~CharacterMapper() {} /// @returns The EndSequence-terminated sequence of keys that would cause @c character to be typed. - virtual uint16_t *sequence_for_character(char character) = 0; + virtual const uint16_t *sequence_for_character(char character) const = 0; /// The typer will automatically reset all keys in between each sequence that it types. /// By default it will pause for one key's duration when doing so. Character mappers /// can eliminate that pause by overriding this method. /// @returns @c true if the typer should pause after performing a reset; @c false otherwise. - virtual bool needs_pause_after_reset_all_keys() { return true; } + virtual bool needs_pause_after_reset_all_keys() const { return true; } /// The typer will pause between every entry in a keyboard sequence. On some machines /// that may not be necessary — it'll often depends on whether the machine needs time to /// observe a modifier like shift before it sees the actual keypress. /// @returns @c true if the typer should pause after forwarding @c key; @c false otherwise. - virtual bool needs_pause_after_key(uint16_t key) { return true; } + virtual bool needs_pause_after_key(uint16_t key) const { return true; } protected: typedef uint16_t KeySequence[16]; @@ -48,7 +48,7 @@ class CharacterMapper { with @c length entries, returns the sequence for character @c character if it exists; otherwise returns @c nullptr. */ - uint16_t *table_lookup_sequence_for_character(KeySequence *sequences, std::size_t length, char character); + uint16_t *table_lookup_sequence_for_character(KeySequence *sequences, std::size_t length, char character) const; }; /*! @@ -118,7 +118,7 @@ class TypeRecipient: public Typer::Delegate { /*! @returns @c true if the character mapper provides a mapping for @c c; @c false otherwise. */ - bool can_type(char c) { + bool can_type(char c) const { const auto sequence = character_mapper.sequence_for_character(c); return sequence && sequence[0] != MachineTypes::MappedKeyboardMachine::KeyNotMapped; } @@ -137,8 +137,8 @@ class TypeRecipient: public Typer::Delegate { typer_ = nullptr; } - virtual HalfCycles get_typer_delay() { return HalfCycles(0); } - virtual HalfCycles get_typer_frequency() { return HalfCycles(0); } + virtual HalfCycles get_typer_delay() const { return HalfCycles(0); } + virtual HalfCycles get_typer_frequency() const { return HalfCycles(0); } std::unique_ptr typer_; private: diff --git a/Machines/ZX8081/Keyboard.cpp b/Machines/ZX8081/Keyboard.cpp index d4e2a5e4a..d3e25f381 100644 --- a/Machines/ZX8081/Keyboard.cpp +++ b/Machines/ZX8081/Keyboard.cpp @@ -10,7 +10,7 @@ using namespace ZX8081; -uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { +uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) const { #define BIND(source, dest) case Inputs::Keyboard::Key::source: return ZX8081::dest switch(key) { default: break; @@ -44,7 +44,7 @@ uint16_t KeyboardMapper::mapped_key_for_key(Inputs::Keyboard::Key key) { CharacterMapper::CharacterMapper(bool is_zx81) : is_zx81_(is_zx81) {} -uint16_t *CharacterMapper::sequence_for_character(char character) { +const uint16_t *CharacterMapper::sequence_for_character(char character) const { #define KEYS(...) {__VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define SHIFT(...) {KeyShift, __VA_ARGS__, MachineTypes::MappedKeyboardMachine::KeyEndSequence} #define X {MachineTypes::MappedKeyboardMachine::KeyNotMapped} @@ -189,6 +189,6 @@ uint16_t *CharacterMapper::sequence_for_character(char character) { return table_lookup_sequence_for_character(zx80_key_sequences, sizeof(zx80_key_sequences), character); } -bool CharacterMapper::needs_pause_after_key(uint16_t key) { +bool CharacterMapper::needs_pause_after_key(uint16_t key) const { return key != KeyShift; } diff --git a/Machines/ZX8081/Keyboard.hpp b/Machines/ZX8081/Keyboard.hpp index d4f930bf2..56cb848ad 100644 --- a/Machines/ZX8081/Keyboard.hpp +++ b/Machines/ZX8081/Keyboard.hpp @@ -30,15 +30,15 @@ enum Key: uint16_t { }; struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper { - uint16_t mapped_key_for_key(Inputs::Keyboard::Key key); + uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const override; }; class CharacterMapper: public ::Utility::CharacterMapper { public: CharacterMapper(bool is_zx81); - uint16_t *sequence_for_character(char character) override; + const uint16_t *sequence_for_character(char character) const override; - bool needs_pause_after_key(uint16_t key) override; + bool needs_pause_after_key(uint16_t key) const override; private: bool is_zx81_; diff --git a/Machines/ZX8081/ZX8081.cpp b/Machines/ZX8081/ZX8081.cpp index ec5b7cf8b..6108ef28a 100644 --- a/Machines/ZX8081/ZX8081.cpp +++ b/Machines/ZX8081/ZX8081.cpp @@ -337,7 +337,7 @@ template class ConcreteMachine: Utility::TypeRecipient::add_typer(string); } - bool can_type(char c) final { + bool can_type(char c) const final { return Utility::TypeRecipient::can_type(c); } @@ -393,11 +393,11 @@ template class ConcreteMachine: } // MARK: - Typer timing - HalfCycles get_typer_delay() final { + HalfCycles get_typer_delay() const final { return z80_.get_is_resetting() ? Cycles(7'000'000) : Cycles(0); } - HalfCycles get_typer_frequency() final { + HalfCycles get_typer_frequency() const final { return Cycles(146'250); } diff --git a/Numeric/CRC.hpp b/Numeric/CRC.hpp index 1ae096b7d..9e10c9a41 100644 --- a/Numeric/CRC.hpp +++ b/Numeric/CRC.hpp @@ -21,7 +21,7 @@ template > 1)); for(int c = 0; c < 256; c++) { IntType shift_value = IntType(c << multibyte_shift); diff --git a/Numeric/LFSR.hpp b/Numeric/LFSR.hpp index 979d465aa..3bf8a8881 100644 --- a/Numeric/LFSR.hpp +++ b/Numeric/LFSR.hpp @@ -43,7 +43,7 @@ template state_ = State::Running; + std::atomic state_{State::Running}; Time::ScanSynchroniser scan_synchroniser_; diff --git a/Outputs/DisplayMetrics.cpp b/Outputs/DisplayMetrics.cpp index 3df043af6..8ab24a942 100644 --- a/Outputs/DisplayMetrics.cpp +++ b/Outputs/DisplayMetrics.cpp @@ -34,13 +34,13 @@ void Metrics::add_line_total(int total) { line_total_history_pointer_ = (line_total_history_pointer_ + 1) % line_total_history_.size(); } -float Metrics::visible_lines_per_frame_estimate() { +float Metrics::visible_lines_per_frame_estimate() const { // Just average the number of records contained in line_total_history_ to provide this estimate; // that array should be an even number, to allow for potential interlaced sources. return float(std::accumulate(line_total_history_.begin(), line_total_history_.end(), 0)) / float(line_total_history_.size()); } -int Metrics::current_line() { +int Metrics::current_line() const { return lines_this_frame_; } @@ -79,7 +79,7 @@ void Metrics::announce_draw_status(size_t lines, std::chrono::high_resolution_cl } } -bool Metrics::should_lower_resolution() { +bool Metrics::should_lower_resolution() const { // If less than 100 frames are on record, return no opinion; otherwise // suggest a lower resolution if more than 10 frames in the last 100-200 // took too long to produce. diff --git a/Outputs/DisplayMetrics.hpp b/Outputs/DisplayMetrics.hpp index 4854e950b..9cd4f7889 100644 --- a/Outputs/DisplayMetrics.hpp +++ b/Outputs/DisplayMetrics.hpp @@ -29,17 +29,18 @@ class Metrics { /// Notifies Metrics that the size of the output buffer has changed. void announce_did_resize(); + /// Provides Metrics with a new data point for output speed estimation. void announce_draw_status(size_t lines, std::chrono::high_resolution_clock::duration duration, bool complete); /// @returns @c true if Metrics thinks a lower output buffer resolution is desirable in the abstract; @c false otherwise. - bool should_lower_resolution(); + bool should_lower_resolution() const; /// @returns An estimate of the number of lines being produced per frame, excluding vertical sync. - float visible_lines_per_frame_estimate(); + float visible_lines_per_frame_estimate() const; /// @returns The number of lines since vertical retrace ended. - int current_line(); + int current_line() const; private: int lines_this_frame_ = 0; diff --git a/Outputs/ScanTarget.hpp b/Outputs/ScanTarget.hpp index 94529142b..1b25c4bb1 100644 --- a/Outputs/ScanTarget.hpp +++ b/Outputs/ScanTarget.hpp @@ -31,8 +31,8 @@ struct Rect { float width, height; } size; - Rect() : origin({0.0f, 0.0f}), size({1.0f, 1.0f}) {} - Rect(float x, float y, float width, float height) : + constexpr Rect() : origin({0.0f, 0.0f}), size({1.0f, 1.0f}) {} + constexpr Rect(float x, float y, float width, float height) : origin({x, y}), size({width, height}) {} }; diff --git a/Outputs/Speaker/Speaker.hpp b/Outputs/Speaker/Speaker.hpp index 13a67e674..0de8f4bc2 100644 --- a/Outputs/Speaker/Speaker.hpp +++ b/Outputs/Speaker/Speaker.hpp @@ -118,7 +118,7 @@ class Speaker { } delegate->speaker_did_complete_samples(this, mix_buffer_); } - std::atomic delegate_ = nullptr; + std::atomic delegate_{nullptr}; private: void compute_output_rate() { @@ -131,7 +131,7 @@ class Speaker { float input_rate_multiplier_ = 1.0f; float output_cycles_per_second_ = 1.0f; int output_buffer_size_ = 1; - std::atomic stereo_output_ = false; + std::atomic stereo_output_{false}; std::vector mix_buffer_; }; diff --git a/Processors/Z80/Implementation/Z80Base.cpp b/Processors/Z80/Implementation/Z80Base.cpp index e01bd484b..038daabaf 100644 --- a/Processors/Z80/Implementation/Z80Base.cpp +++ b/Processors/Z80/Implementation/Z80Base.cpp @@ -15,7 +15,7 @@ void ProcessorBase::reset_power_on() { last_request_status_ &= ~Interrupt::PowerOn; } -uint16_t ProcessorBase::get_value_of_register(Register r) { +uint16_t ProcessorBase::get_value_of_register(Register r) const { switch (r) { case Register::ProgramCounter: return pc_.full; case Register::StackPointer: return sp_.full; diff --git a/Processors/Z80/Implementation/Z80Implementation.hpp b/Processors/Z80/Implementation/Z80Implementation.hpp index c328075f0..2685e907e 100644 --- a/Processors/Z80/Implementation/Z80Implementation.hpp +++ b/Processors/Z80/Implementation/Z80Implementation.hpp @@ -907,7 +907,7 @@ template < class T, template < class T, bool uses_bus_request, bool uses_wait_line> bool Processor - ::get_bus_request_line() { + ::get_bus_request_line() const { return bus_request_line_; } @@ -922,7 +922,7 @@ template < class T, template < class T, bool uses_bus_request, bool uses_wait_line> bool Processor - ::get_wait_line() { + ::get_wait_line() const { return wait_line_; } @@ -1013,7 +1013,7 @@ template < class T, #undef isTerminal -bool ProcessorBase::get_halt_line() { +bool ProcessorBase::get_halt_line() const { return halt_mask_ == 0x00; } @@ -1036,7 +1036,7 @@ void ProcessorBase::set_interrupt_line(bool value, HalfCycles offset) { } } -bool ProcessorBase::get_interrupt_line() { +bool ProcessorBase::get_interrupt_line() const { return irq_line_; } @@ -1065,7 +1065,7 @@ void ProcessorBase::set_non_maskable_interrupt_line(bool value, HalfCycles offse } } -bool ProcessorBase::get_non_maskable_interrupt_line() { +bool ProcessorBase::get_non_maskable_interrupt_line() const { return nmi_line_; } diff --git a/Processors/Z80/Implementation/Z80Storage.cpp b/Processors/Z80/Implementation/Z80Storage.cpp index 14bb76de8..b41d8715e 100644 --- a/Processors/Z80/Implementation/Z80Storage.cpp +++ b/Processors/Z80/Implementation/Z80Storage.cpp @@ -545,12 +545,12 @@ void ProcessorStorage::assemble_fetch_decode_execute(InstructionPage &target, in target.fetch_decode_execute_data = target.fetch_decode_execute.data(); } -bool ProcessorBase::is_starting_new_instruction() { +bool ProcessorBase::is_starting_new_instruction() const { return current_instruction_page_ == &base_page_ && scheduled_program_counter_ == &base_page_.fetch_decode_execute[0]; } -bool ProcessorBase::get_is_resetting() { +bool ProcessorBase::get_is_resetting() const { return request_status_ & (Interrupt::PowerOn | Interrupt::Reset); } diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index 718ebea27..f470a6614 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -171,7 +171,7 @@ class ProcessorBase: public ProcessorStorage { @param r The register to set. @returns The value of the register. 8-bit registers will be returned as unsigned. */ - uint16_t get_value_of_register(Register r); + uint16_t get_value_of_register(Register r) const; /*! Sets the value of a register. @@ -186,7 +186,7 @@ class ProcessorBase: public ProcessorStorage { /*! Gets the value of the HALT output line. */ - inline bool get_halt_line(); + inline bool get_halt_line() const; /*! Sets the logical value of the interrupt line. @@ -200,7 +200,7 @@ class ProcessorBase: public ProcessorStorage { /*! Gets the value of the interrupt line. */ - inline bool get_interrupt_line(); + inline bool get_interrupt_line() const; /*! Sets the logical value of the non-maskable interrupt line. @@ -212,7 +212,7 @@ class ProcessorBase: public ProcessorStorage { /*! Gets the value of the non-maskable interrupt line. */ - inline bool get_non_maskable_interrupt_line(); + inline bool get_non_maskable_interrupt_line() const; /*! Sets the logical value of the reset line. @@ -224,7 +224,7 @@ class ProcessorBase: public ProcessorStorage { @returns @c true if the line is logically active; @c false otherwise. */ - bool get_is_resetting(); + bool get_is_resetting() const; /*! This emulation automatically sets itself up in power-on state at creation, which has the effect of triggering a @@ -237,7 +237,7 @@ class ProcessorBase: public ProcessorStorage { This is not a speedy operation. */ - bool is_starting_new_instruction(); + bool is_starting_new_instruction() const; }; /*! @@ -271,7 +271,7 @@ template class Processor: /*! Gets the logical value of the bus request line. */ - bool get_bus_request_line(); + bool get_bus_request_line() const; /*! Sets the logical value of the wait line, having asserted that this Z80 supports the wait line. @@ -281,7 +281,7 @@ template class Processor: /*! Gets the logical value of the bus request line. */ - bool get_wait_line(); + bool get_wait_line() const; private: T &bus_handler_; diff --git a/Storage/Disk/Track/Track.hpp b/Storage/Disk/Track/Track.hpp index d86af916f..7debed708 100644 --- a/Storage/Disk/Track/Track.hpp +++ b/Storage/Disk/Track/Track.hpp @@ -84,7 +84,7 @@ class Track { int rhs_largest_position = rhs.position.as_largest(); return std::tie(head, largest_position) < std::tie(rhs.head, rhs_largest_position); } - Address(int head, HeadPosition position) : head(head), position(position) {} + constexpr Address(int head, HeadPosition position) : head(head), position(position) {} }; /*! diff --git a/Storage/Storage.hpp b/Storage/Storage.hpp index f73a52f89..f096e63bb 100644 --- a/Storage/Storage.hpp +++ b/Storage/Storage.hpp @@ -22,11 +22,11 @@ namespace Storage { */ struct Time { unsigned int length, clock_rate; - Time() : length(0), clock_rate(1) {} - Time(unsigned int unsigned_int_value) : length(unsigned_int_value), clock_rate(1) {} - Time(int int_value) : Time(unsigned(int_value)) {} - Time(unsigned int length, unsigned int clock_rate) : length(length), clock_rate(clock_rate) {} - Time(int length, int clock_rate) : Time(unsigned(length), unsigned(clock_rate)) {} + constexpr Time() : length(0), clock_rate(1) {} + constexpr Time(unsigned int unsigned_int_value) : length(unsigned_int_value), clock_rate(1) {} + constexpr Time(int int_value) : Time(unsigned(int_value)) {} + constexpr Time(unsigned int length, unsigned int clock_rate) : length(length), clock_rate(clock_rate) {} + constexpr Time(int length, int clock_rate) : Time(unsigned(length), unsigned(clock_rate)) {} Time(uint64_t length, uint64_t clock_rate) { install_result(length, clock_rate); }