1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-08 14:25:05 +00:00

Improve style: indentation, constness, names.

This commit is contained in:
Thomas Harte
2024-12-06 15:29:49 -05:00
parent ea4fe5e809
commit f43e594eca
8 changed files with 83 additions and 83 deletions

View File

@@ -15,8 +15,7 @@ namespace MachineTypes {
/*!
An AudioProducer is any machine that **might** produce audio. This isn't always knowable statically.
*/
class AudioProducer {
public:
struct AudioProducer {
/// @returns The speaker that receives this machine's output, or @c nullptr if this machine is mute.
virtual Outputs::Speaker::Speaker *get_speaker() = 0;
};

View File

@@ -13,8 +13,7 @@
namespace MachineTypes {
class JoystickMachine {
public:
struct JoystickMachine {
virtual const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() = 0;
};

View File

@@ -41,8 +41,7 @@ struct KeyActions {
/*!
Describes an emulated machine which exposes a keyboard and accepts a typed string.
*/
class KeyboardMachine: public KeyActions {
public:
struct KeyboardMachine: public KeyActions {
/*!
Causes the machine to attempt to type the supplied string.
@@ -74,7 +73,13 @@ class KeyboardMachine: public KeyActions {
(i) if @c symbol can be typed and this is a key down, @c type_string it;
(ii) if @c symbol cannot be typed, set @c key as @c is_pressed
*/
bool apply_key(Inputs::Keyboard::Key key, char symbol, bool is_pressed, bool is_repeat, bool map_logically) {
bool apply_key(
const Inputs::Keyboard::Key key,
const char symbol,
const bool is_pressed,
const bool is_repeat,
const bool map_logically
) {
Inputs::Keyboard &keyboard = get_keyboard();
if(!map_logically) {
@@ -119,9 +124,8 @@ public:
A keyboard mapper attempts to provide a physical mapping between host keys and emulated keys.
See the character mapper for logical mapping.
*/
class KeyboardMapper {
public:
virtual uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const = 0;
struct KeyboardMapper {
virtual uint16_t mapped_key_for_key(Inputs::Keyboard::Key) const = 0;
};
/// Terminates a key sequence from the character mapper.
@@ -146,8 +150,8 @@ public:
virtual Inputs::Keyboard &get_keyboard() override;
private:
bool keyboard_did_change_key(Inputs::Keyboard *keyboard, Inputs::Keyboard::Key key, bool is_pressed) override;
void reset_all_keys(Inputs::Keyboard *keyboard) override;
bool keyboard_did_change_key(Inputs::Keyboard *, Inputs::Keyboard::Key, bool is_pressed) override;
void reset_all_keys(Inputs::Keyboard *) override;
Inputs::Keyboard keyboard_;
};

View File

@@ -18,14 +18,13 @@ namespace MachineTypes {
/*!
A MediaTarget::Machine is anything that can accept new media while running.
*/
class MediaTarget {
public:
struct MediaTarget {
/*!
Requests that the machine insert @c media as a modification to current state
@returns @c true if any media was inserted; @c false otherwise.
*/
virtual bool insert_media(const Analyser::Static::Media &media) = 0;
virtual bool insert_media(const Analyser::Static::Media &) = 0;
};
}

View File

@@ -12,8 +12,7 @@
namespace MachineTypes {
class MouseMachine {
public:
struct MouseMachine {
// TODO: support multiple mice?
virtual Inputs::Mouse &get_mouse() = 0;
};

View File

@@ -27,10 +27,10 @@ namespace ROMMachine {
return a vector of unique_ptrs that either contain the contents of the ROM from @c names that corresponds by
index, or else are @c nullptr.
*/
typedef std::function<ROM::Map(const ROM::Request &request)> ROMFetcher;
typedef std::function<ROM::Map(const ROM::Request &)> ROMFetcher;
enum class Error {
MissingROMs
MissingROMs,
};
}

View File

@@ -53,7 +53,7 @@ protected:
Maps from Configurable::Display to Outputs::Display::VideoSignal and calls
@c set_display_type with the result.
*/
void set_video_signal_configurable(Configurable::Display type) {
void set_video_signal_configurable(const Configurable::Display type) {
Outputs::Display::DisplayType display_type;
switch(type) {
default:

View File

@@ -25,7 +25,7 @@ namespace MachineTypes {
class TimedMachine {
public:
/// Runs the machine for @c duration seconds.
virtual void run_for(Time::Seconds duration) {
virtual void run_for(const Time::Seconds duration) {
const double cycles = (duration * clock_rate_ * speed_multiplier_) + clock_conversion_error_;
clock_conversion_error_ = std::fmod(cycles, 1.0);
run_for(Cycles(int(cycles)));
@@ -36,7 +36,7 @@ public:
emulated machine to run 50% faster than a real machine. This speed-up is an emulation
fiction: it will apply across the system, including to the CRT.
*/
virtual void set_speed_multiplier(double multiplier) {
virtual void set_speed_multiplier(const double multiplier) {
if(speed_multiplier_ == multiplier) {
return;
}
@@ -75,10 +75,10 @@ public:
protected:
/// Runs the machine for @c cycles.
virtual void run_for(const Cycles cycles) = 0;
virtual void run_for(const Cycles) = 0;
/// Sets this machine's clock rate.
void set_clock_rate(double clock_rate) {
void set_clock_rate(const double clock_rate) {
clock_rate_ = clock_rate;
}