openMSX
Autofire.hh
Go to the documentation of this file.
1 #ifndef AUTOFIRE_HH
2 #define AUTOFIRE_HH
3 
4 #include "Observer.hh"
5 #include "DynamicClock.hh"
6 #include "EmuTime.hh"
7 #include "IntegerSetting.hh"
8 #include "StateChangeListener.hh"
9 #include "static_string_view.hh"
10 
11 namespace openmsx {
12 
13 class MSXMotherBoard;
14 class Scheduler;
15 class StateChangeDistributor;
16 
25 class Autofire final : private Observer<Setting>, private StateChangeListener
26 {
27 public:
28  Autofire(MSXMotherBoard& motherBoard,
29  unsigned newMinInts, unsigned newMaxInts,
30  static_string_view name);
31  ~Autofire();
32 
37  [[nodiscard]] bool getSignal(EmuTime::param time);
38 
39  template<typename Archive>
40  void serialize(Archive& ar, unsigned version);
41 
42 private:
43  void setSpeed(EmuTime::param time);
44 
48  void setClock(int speed);
49 
50  // Observer<Setting>
51  void update(const Setting& setting) noexcept override;
52 
53  // StateChangeListener
54  void signalStateChange(const std::shared_ptr<StateChange>& event) override;
55  void stopReplay(EmuTime::param time) noexcept override;
56 
57 private:
58  Scheduler& scheduler;
59  StateChangeDistributor& stateChangeDistributor;
60  const static_string_view name;
61 
62  // Following two values specify the range of the autofire
63  // as measured by the test program:
68  const unsigned min_ints;
73  const unsigned max_ints;
74 
76  IntegerSetting speedSetting;
77 
81  DynamicClock clock;
82 };
83 
84 } // namespace openmsx
85 
86 #endif
Autofire is a device that is between two other devices and outside the bus.
Definition: Autofire.hh:26
Autofire(MSXMotherBoard &motherBoard, unsigned newMinInts, unsigned newMaxInts, static_string_view name)
Definition: Autofire.cc:34
bool getSignal(EmuTime::param time)
Get the output signal in negative logic.
Definition: Autofire.cc:94
void serialize(Archive &ar, unsigned version)
Definition: Autofire.cc:102
Represents a clock with a variable frequency.
Definition: DynamicClock.hh:17
A Setting with an integer value.
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10
static_string_view
This file implemented 3 utility functions:
Definition: Autofire.cc:9