| 1 |
#ifndef AUTOFIRE_HH |
| 2 |
#define AUTOFIRE_HH |
| 3 |
|
| 4 |
#include "DynamicClock.hh" |
| 5 |
#include "EmuTime.hh" |
| 6 |
#include "IntegerSetting.hh" |
| 7 |
#include "Observer.hh" |
| 8 |
#include "StateChange.hh" |
| 9 |
#include "StateChangeListener.hh" |
| 10 |
|
| 11 |
#include <cstdint> |
| 12 |
|
| 13 |
namespace openmsx { |
| 14 |
|
| 15 |
class MSXMotherBoard; |
| 16 |
class Scheduler; |
| 17 |
class StateChangeDistributor; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class Autofire final : private Observer<Setting>, private StateChangeListener |
| 28 |
{ |
| 29 |
public: |
| 30 |
Autofire(MSXMotherBoard& motherBoard, |
| 31 |
unsigned newMinInts, unsigned newMaxInts, |
| 32 |
AutofireID id); |
| 33 |
~Autofire(); |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
[[nodiscard]] bool getSignal(EmuTime time) const; |
| 40 |
|
| 41 |
template<typename Archive> |
| 42 |
void serialize(Archive& ar, unsigned version); |
| 43 |
|
| 44 |
private: |
| 45 |
void setSpeed(EmuTime time); |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
void setClock(int speed); |
| 51 |
|
| 52 |
|
| 53 |
void update(const Setting& setting) noexcept override; |
| 54 |
|
| 55 |
|
| 56 |
void signalStateChange(const StateChange& event) override; |
| 57 |
void stopReplay(EmuTime time) noexcept override; |
| 58 |
|
| 59 |
private: |
| 60 |
Scheduler& scheduler; |
| 61 |
StateChangeDistributor& stateChangeDistributor; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
const unsigned min_ints; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
const unsigned max_ints; |
| 75 |
|
| 76 |
|
| 77 |
IntegerSetting speedSetting; |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
DynamicClock clock; |
| 83 |
|
| 84 |
const AutofireID id; |
| 85 |
}; |
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
#endif |