1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 18:30:21 +00:00

Adds a bunch of consts.

This commit is contained in:
Thomas Harte 2020-05-09 21:22:51 -04:00
parent 5c1ae40a9c
commit 31c6faf3c8
35 changed files with 65 additions and 66 deletions

View File

@ -67,7 +67,7 @@ class Source {
}
/// @returns the current preferred clocking strategy.
virtual Preference preferred_clocking() = 0;
virtual Preference preferred_clocking() const = 0;
private:
Observer *observer_ = nullptr;

View File

@ -824,11 +824,11 @@ void WD1770::set_head_loaded(bool head_loaded) {
if(head_loaded) posit_event(int(Event1770::HeadLoad));
}
bool WD1770::get_head_loaded() {
bool WD1770::get_head_loaded() const {
return head_is_loaded_;
}
ClockingHint::Preference WD1770::preferred_clocking() {
ClockingHint::Preference WD1770::preferred_clocking() const {
if(status_.busy) return ClockingHint::Preference::RealTime;
return Storage::Disk::MFMController::preferred_clocking();
}

View File

@ -62,18 +62,18 @@ class WD1770: public Storage::Disk::MFMController {
};
/// @returns The current value of the IRQ line output.
inline bool get_interrupt_request_line() { return status_.interrupt_request; }
inline bool get_interrupt_request_line() const { return status_.interrupt_request; }
/// @returns The current value of the DRQ line output.
inline bool get_data_request_line() { return status_.data_request; }
inline bool get_data_request_line() const { return status_.data_request; }
class Delegate {
public:
virtual void wd1770_did_change_output(WD1770 *wd1770) = 0;
};
inline void set_delegate(Delegate *delegate) { delegate_ = delegate; }
inline void set_delegate(Delegate *delegate) { delegate_ = delegate; }
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
protected:
virtual void set_head_load_request(bool head_load);
@ -81,12 +81,12 @@ class WD1770: public Storage::Disk::MFMController {
void set_head_loaded(bool head_loaded);
/// @returns The last value posted to @c set_head_loaded.
bool get_head_loaded();
bool get_head_loaded() const;
private:
Personality personality_;
inline bool has_motor_on_line() { return (personality_ != P1793 ) && (personality_ != P1773); }
inline bool has_head_load_line() { return (personality_ == P1793 ); }
const Personality personality_;
bool has_motor_on_line() const { return (personality_ != P1793 ) && (personality_ != P1773); }
bool has_head_load_line() const { return (personality_ == P1793 ); }
struct Status {
bool write_protect = false;

View File

@ -112,7 +112,7 @@ template <class T> class MOS6522: public MOS6522Storage {
void run_for(const Cycles cycles);
/// @returns @c true if the IRQ line is currently active; @c false otherwise.
bool get_interrupt_line();
bool get_interrupt_line() const;
/// Updates the port handler to the current time and then requests that it flush.
void flush();

View File

@ -383,9 +383,9 @@ template <typename T> void MOS6522<T>::run_for(const Cycles cycles) {
}
/*! @returns @c true if the IRQ line is currently active; @c false otherwise. */
template <typename T> bool MOS6522<T>::get_interrupt_line() {
template <typename T> bool MOS6522<T>::get_interrupt_line() const {
uint8_t interrupt_status = registers_.interrupt_flags & registers_.interrupt_enable & 0x7f;
return !!interrupt_status;
return interrupt_status;
}
template <typename T> void MOS6522<T>::evaluate_cb2_output() {

View File

@ -142,7 +142,7 @@ template <class T> class MOS6532 {
}
}
inline bool get_inerrupt_line() {
inline bool get_inerrupt_line() const {
return interrupt_line_;
}

View File

@ -87,8 +87,8 @@ template <class BusHandler> class MOS6560 {
void set_scan_target(Outputs::Display::ScanTarget *scan_target) { crt_.set_scan_target(scan_target); }
Outputs::Display::ScanStatus get_scaled_scan_status() const { return crt_.get_scaled_scan_status() / 4.0f; }
void set_display_type(Outputs::Display::DisplayType display_type) { crt_.set_display_type(display_type); }
Outputs::Display::DisplayType get_display_type() { return crt_.get_display_type(); }
Outputs::Speaker::Speaker *get_speaker() { return &speaker_; }
Outputs::Display::DisplayType get_display_type() const { return crt_.get_display_type(); }
Outputs::Speaker::Speaker *get_speaker() { return &speaker_; }
void set_high_frequency_cutoff(float cutoff) {
speaker_.set_high_frequency_cutoff(cutoff);
@ -420,11 +420,11 @@ template <class BusHandler> class MOS6560 {
/*
Reads from a 6560 register.
*/
uint8_t read(int address) {
uint8_t read(int address) const {
address &= 0xf;
switch(address) {
default: return registers_.direct_values[address];
case 0x03: return static_cast<uint8_t>(raster_value() << 7) | (registers_.direct_values[3] & 0x7f);
case 0x03: return uint8_t(raster_value() << 7) | (registers_.direct_values[3] & 0x7f);
case 0x04: return (raster_value() >> 1) & 0xff;
}
}
@ -462,11 +462,11 @@ template <class BusHandler> class MOS6560 {
// counters that cover an entire field
int horizontal_counter_ = 0, vertical_counter_ = 0;
const int lines_this_field() {
int lines_this_field() const {
// Necessary knowledge here: only the NTSC 6560 supports interlaced video.
return registers_.interlaced ? (is_odd_frame_ ? 262 : 263) : timing_.lines_per_progressive_field;
}
const int raster_value() {
int raster_value() const {
const int bonus_line = (horizontal_counter_ + timing_.line_counter_increment_offset) / timing_.cycles_per_line;
const int line = vertical_counter_ + bonus_line;
const int final_line = lines_this_field();
@ -481,7 +481,7 @@ template <class BusHandler> class MOS6560 {
}
// Cf. http://www.sleepingelephant.com/ipw-web/bulletin/bb/viewtopic.php?f=14&t=7237&start=15#p80737
}
bool is_odd_frame() {
bool is_odd_frame() const {
return is_odd_frame_ || !registers_.interlaced;
}

View File

@ -120,7 +120,7 @@ void ACIA::consider_transmission() {
}
}
ClockingHint::Preference ACIA::preferred_clocking() {
ClockingHint::Preference ACIA::preferred_clocking() const {
// Real-time clocking is required if a transmission is ongoing; this is a courtesy for whomever
// is on the receiving end.
if(transmit.transmission_data_time_remaining() > 0) return ClockingHint::Preference::RealTime;

View File

@ -86,7 +86,7 @@ class ACIA: public ClockingHint::Source, private Serial::Line::ReadDelegate {
Serial::Line request_to_send;
// ClockingHint::Source.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
struct InterruptDelegate {
virtual void acia6850_did_change_interrupt_status(ACIA *acia) = 0;

View File

@ -20,7 +20,7 @@
using namespace Motorola::MFP68901;
ClockingHint::Preference MFP68901::preferred_clocking() {
ClockingHint::Preference MFP68901::preferred_clocking() const {
// Rule applied: if any timer is actively running and permitted to produce an
// interrupt, request real-time running.
return

View File

@ -76,7 +76,7 @@ class MFP68901: public ClockingHint::Source {
void set_interrupt_delegate(InterruptDelegate *delegate);
// ClockingHint::Source.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
private:
// MARK: - Timers

View File

@ -82,7 +82,7 @@ i8272::i8272(BusHandler &bus_handler, Cycles clock_rate) :
posit_event(static_cast<int>(Event8272::CommandByte));
}
ClockingHint::Preference i8272::preferred_clocking() {
ClockingHint::Preference i8272::preferred_clocking() const {
const auto mfm_controller_preferred_clocking = Storage::Disk::MFMController::preferred_clocking();
if(mfm_controller_preferred_clocking != ClockingHint::Preference::None) return mfm_controller_preferred_clocking;
return is_sleeping_ ? ClockingHint::Preference::None : ClockingHint::Preference::JustInTime;

View File

@ -39,7 +39,7 @@ class i8272 : public Storage::Disk::MFMController {
void set_dma_acknowledge(bool dack);
void set_terminal_count(bool tc);
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
protected:
virtual void select_drive(int number) = 0;

View File

@ -16,7 +16,7 @@ void z8530::reset() {
// TODO.
}
bool z8530::get_interrupt_line() {
bool z8530::get_interrupt_line() const {
return
(master_interrupt_control_ & 0x8) &&
(
@ -253,7 +253,7 @@ void z8530::Channel::set_dcd(bool level) {
}
}
bool z8530::Channel::get_interrupt_line() {
bool z8530::Channel::get_interrupt_line() const {
return
(interrupt_mask_ & 1) && external_status_interrupt_;
// TODO: other potential causes of an interrupt.

View File

@ -33,7 +33,7 @@ class z8530 {
std::uint8_t read(int address);
void write(int address, std::uint8_t value);
void reset();
bool get_interrupt_line();
bool get_interrupt_line() const;
struct Delegate {
virtual void did_change_interrupt_status(z8530 *, bool new_status) = 0;
@ -53,7 +53,7 @@ class z8530 {
uint8_t read(bool data, uint8_t pointer);
void write(bool data, uint8_t pointer, uint8_t value);
void set_dcd(bool level);
bool get_interrupt_line();
bool get_interrupt_line() const;
private:
uint8_t data_ = 0xff;

View File

@ -33,6 +33,6 @@ void Toggle::set_output(bool enabled) {
});
}
bool Toggle::get_output() {
bool Toggle::get_output() const {
return is_enabled_;
}

View File

@ -24,10 +24,9 @@ class Toggle: public Outputs::Speaker::SampleSource {
void get_samples(std::size_t number_of_samples, std::int16_t *target);
void set_sample_volume_range(std::int16_t range);
void skip_samples(const std::size_t number_of_samples);
static constexpr bool get_is_stereo() { return false; }
void set_output(bool enabled);
bool get_output();
bool get_output() const;
private:
// Accessed on the calling thread.

View File

@ -225,7 +225,7 @@ void DiskII::set_component_prefers_clocking(ClockingHint::Source *component, Clo
decide_clocking_preference();
}
ClockingHint::Preference DiskII::preferred_clocking() {
ClockingHint::Preference DiskII::preferred_clocking() const {
return clocking_preference_;
}

View File

@ -76,7 +76,7 @@ class DiskII :
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk, int drive);
// As per Sleeper.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
// The Disk II functions as a potential target for @c Activity::Sources.
void set_activity_observer(Activity::Observer *observer);

View File

@ -251,7 +251,7 @@ void DMAController::set_component_prefers_clocking(ClockingHint::Source *, Clock
update_clocking_observer();
}
ClockingHint::Preference DMAController::preferred_clocking() {
ClockingHint::Preference DMAController::preferred_clocking() const {
return (fdc_.preferred_clocking() == ClockingHint::Preference::None) ? ClockingHint::Preference::None : ClockingHint::Preference::RealTime;
}

View File

@ -50,7 +50,7 @@ class DMAController: public WD::WD1770::Delegate, public ClockingHint::Source, p
void set_activity_observer(Activity::Observer *observer);
// ClockingHint::Source.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
private:
HalfCycles running_time_;

View File

@ -45,7 +45,7 @@ bool IntelligentKeyboard::serial_line_did_produce_bit(Serial::Line *, int bit) {
return true;
}
ClockingHint::Preference IntelligentKeyboard::preferred_clocking() {
ClockingHint::Preference IntelligentKeyboard::preferred_clocking() const {
return output_line_.transmission_data_time_remaining().as_integral() ? ClockingHint::Preference::RealTime : ClockingHint::Preference::None;
}

View File

@ -58,7 +58,7 @@ class IntelligentKeyboard:
public Inputs::Mouse {
public:
IntelligentKeyboard(Serial::Line &input, Serial::Line &output);
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
void run_for(HalfCycles duration);
void set_key_state(Key key, bool is_pressed);

View File

@ -10,7 +10,7 @@
#define ScanProducer_hpp
#include "../Outputs/ScanTarget.hpp"
#include "../Configurable/StandardOptions.hpp"
#include "../Configurable/Configurable.hpp"
#include "TimedMachine.hpp"

View File

@ -93,7 +93,7 @@ void CRT::set_display_type(Outputs::Display::DisplayType display_type) {
scan_target_->set_modals(scan_target_modals_);
}
Outputs::Display::DisplayType CRT::get_display_type() {
Outputs::Display::DisplayType CRT::get_display_type() const {
return scan_target_modals_.display_type;
}

View File

@ -299,7 +299,7 @@ class CRT {
void set_display_type(Outputs::Display::DisplayType);
/*! Gets the last display type provided to set_display_type. */
Outputs::Display::DisplayType get_display_type();
Outputs::Display::DisplayType get_display_type() const;
/*! Sets the offset to apply to phase when using the PhaseLinkedLuminance8 input data type. */
void set_phase_linked_luminance_offset(float);

View File

@ -129,7 +129,7 @@ struct Flywheel {
@returns The current output position.
*/
inline int get_current_output_position() {
inline int get_current_output_position() const {
if(counter_ < retrace_time_) {
const int retrace_distance = int((int64_t(counter_) * int64_t(standard_period_)) / int64_t(retrace_time_));
if(retrace_distance > counter_before_retrace_) return 0;
@ -145,56 +145,56 @@ struct Flywheel {
@returns The current output position.
*/
inline int get_current_phase() {
inline int get_current_phase() const {
return counter_ - retrace_time_;
}
/*!
@returns the amount of time since retrace last began. Time then counts monotonically up from zero.
*/
inline int get_current_time() {
inline int get_current_time() const {
return counter_;
}
/*!
@returns whether the output is currently retracing.
*/
inline bool is_in_retrace() {
inline bool is_in_retrace() const {
return counter_ < retrace_time_;
}
/*!
@returns the expected length of the scan period (excluding retrace).
*/
inline int get_scan_period() {
inline int get_scan_period() const {
return standard_period_ - retrace_time_;
}
/*!
@returns the actual length of the scan period (excluding retrace).
*/
inline int get_locked_scan_period() {
inline int get_locked_scan_period() const {
return expected_next_sync_ - retrace_time_;
}
/*!
@returns the expected length of a complete scan and retrace cycle.
*/
inline int get_standard_period() {
inline int get_standard_period() const {
return standard_period_;
}
/*!
@returns the actual current period for a complete scan (including retrace).
*/
inline int get_locked_period() {
inline int get_locked_period() const {
return expected_next_sync_;
}
/*!
@returns the amount by which the @c locked_period was adjusted, the last time that an adjustment was applied.
*/
inline int get_last_period_adjustment() {
inline int get_last_period_adjustment() const {
return last_adjustment_;
}
@ -211,21 +211,21 @@ struct Flywheel {
/*!
@returns A count of the number of retraces so far performed.
*/
inline int get_number_of_retraces() {
inline int get_number_of_retraces() const {
return number_of_retraces_;
}
/*!
@returns The amount of time this flywheel spends in retrace, as supplied at construction.
*/
inline int get_retrace_period() {
inline int get_retrace_period() const {
return retrace_time_;
}
/*!
@returns `true` if a sync is expected soon or if the time at which it was expected (or received) was recent.
*/
inline bool is_near_expected_sync() {
inline bool is_near_expected_sync() const {
return
(counter_ < (standard_period_ / 100)) ||
(counter_ >= expected_next_sync_ - (standard_period_ / 100));

View File

@ -24,7 +24,7 @@ void Controller::set_component_prefers_clocking(ClockingHint::Source *component,
update_clocking_observer();
}
ClockingHint::Preference Controller::preferred_clocking() {
ClockingHint::Preference Controller::preferred_clocking() const {
// Nominate RealTime clocking if any drive currently wants any clocking whatsoever.
// Otherwise, ::None will do.
for(auto &drive: drives_) {

View File

@ -134,7 +134,7 @@ class Controller:
/*!
As per ClockingHint::Source.
*/
ClockingHint::Preference preferred_clocking() override;
ClockingHint::Preference preferred_clocking() const override;
private:
Time bit_length_;

View File

@ -71,7 +71,7 @@ bool Drive::has_disk() const {
return has_disk_;
}
ClockingHint::Preference Drive::preferred_clocking() {
ClockingHint::Preference Drive::preferred_clocking() const {
return (!has_disk_ || (time_until_motor_transition == Cycles(0) && !disk_is_rotating_)) ? ClockingHint::Preference::None : ClockingHint::Preference::JustInTime;
}

View File

@ -152,7 +152,7 @@ class Drive: public ClockingHint::Source, public TimedEventLoop {
void set_event_delegate(EventDelegate *);
// As per Sleeper.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
/// Adds an activity observer; it'll be notified of disk activity.
/// The caller can specify whether to add an LED based on disk motor.

View File

@ -82,7 +82,7 @@ void Bus::add_observer(Observer *observer) {
observers_.push_back(observer);
}
ClockingHint::Preference Bus::preferred_clocking() {
ClockingHint::Preference Bus::preferred_clocking() const {
return (dispatch_index_ < dispatch_times_.size()) ? ClockingHint::Preference::RealTime : ClockingHint::Preference::None;
}

View File

@ -139,7 +139,7 @@ class Bus: public ClockingHint::Source, public Activity::Source {
void update_observers();
// As per ClockingHint::Source.
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
// Fulfilling public Activity::Source.
void set_activity_observer(Activity::Observer *observer) final;

View File

@ -64,7 +64,7 @@ void Tape::set_offset(uint64_t offset) {
// MARK: - Player
ClockingHint::Preference TapePlayer::preferred_clocking() {
ClockingHint::Preference TapePlayer::preferred_clocking() const {
return (!tape_ || tape_->is_at_end()) ? ClockingHint::Preference::None : ClockingHint::Preference::JustInTime;
}
@ -118,7 +118,7 @@ BinaryTapePlayer::BinaryTapePlayer(int input_clock_rate) :
TapePlayer(input_clock_rate)
{}
ClockingHint::Preference BinaryTapePlayer::preferred_clocking() {
ClockingHint::Preference BinaryTapePlayer::preferred_clocking() const {
if(!motor_is_running_) return ClockingHint::Preference::None;
return TapePlayer::preferred_clocking();
}

View File

@ -107,7 +107,7 @@ class TapePlayer: public TimedEventLoop, public ClockingHint::Source {
void run_for_input_pulse();
ClockingHint::Preference preferred_clocking() override;
ClockingHint::Preference preferred_clocking() const override;
protected:
virtual void process_next_event() override;
@ -145,7 +145,7 @@ class BinaryTapePlayer : public TapePlayer {
};
void set_delegate(Delegate *delegate);
ClockingHint::Preference preferred_clocking() final;
ClockingHint::Preference preferred_clocking() const final;
protected:
Delegate *delegate_ = nullptr;