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  enum ID { RENSHATURBO, UNKNOWN };
29 
30 public:
31  Autofire(MSXMotherBoard& motherBoard,
32  unsigned newMinInts, unsigned newMaxInts,
33  ID id);
34  ~Autofire();
35 
40  [[nodiscard]] bool getSignal(EmuTime::param time);
41 
42  template<typename Archive>
43  void serialize(Archive& ar, unsigned version);
44 
45 private:
46  void setSpeed(EmuTime::param time);
47 
51  void setClock(int speed);
52 
53  // Observer<Setting>
54  void update(const Setting& setting) noexcept override;
55 
56  // StateChangeListener
57  void signalStateChange(const StateChange& event) override;
58  void stopReplay(EmuTime::param time) noexcept override;
59 
60 private:
61  Scheduler& scheduler;
62  StateChangeDistributor& stateChangeDistributor;
63 
64  // Following two values specify the range of the autofire
65  // as measured by the test program:
70  const unsigned min_ints;
75  const unsigned max_ints;
76 
78  IntegerSetting speedSetting;
79 
83  DynamicClock clock;
84 
85  const ID id;
86 };
87 
88 } // namespace openmsx
89 
90 #endif
BaseSetting * setting
Definition: Interpreter.cc:27
Autofire is a device that is between two other devices and outside the bus.
Definition: Autofire.hh:26
bool getSignal(EmuTime::param time)
Get the output signal in negative logic.
Definition: Autofire.cc:109
Autofire(MSXMotherBoard &motherBoard, unsigned newMinInts, unsigned newMaxInts, ID id)
Definition: Autofire.cc:49
void serialize(Archive &ar, unsigned version)
Definition: Autofire.cc:117
Represents a clock with a variable frequency.
Definition: DynamicClock.hh:16
A Setting with an integer value.
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:10
Base class for all external MSX state changing events.
Definition: StateChange.hh:20
This file implemented 3 utility functions:
Definition: Autofire.cc:9