// $Id: Autofire.hh 5993 2007-01-12 22:12:12Z m9710797 $ #ifndef AUTOFIRE_HH #define AUTOFIRE_HH #include "Observer.hh" #include "DynamicClock.hh" #include "noncopyable.hh" #include #include namespace openmsx { class CommandController; class IntegerSetting; class Setting; /** * Autofire is a device that is between two other devices and outside * the bus. For example, between the keyboard and the PPI * or between a joyport connecter and the PSG. * * There can be multiple autofire circuits. For example, one used * by the Ren-Sha Turbo and another one built into a joystick. */ class Autofire : private Observer, private noncopyable { public: Autofire(CommandController& commandController, unsigned newMinInts, unsigned newMaxInts, const std::string& name); virtual ~Autofire(); /** Get the output signal in negative logic. * @result When auto-fire is on, result will alternate between true * and false. When auto-fire if off result is false. */ bool getSignal(const EmuTime& time); private: /** Sets the clock frequency according to the current value of the speed * settings. */ void setClock(); virtual void update(const Setting& setting); // Following two values specify the range of the autofire // as measured by the test program: /** Number of interrupts at fastest setting (>=1). * The number of interrupts for 50 periods, measured * in ntsc mode (which gives 60 interrupts per second). */ unsigned min_ints; /** Number of interrupts at slowest setting (>=min_ints+1). * The number of interrupts for 50 periods, measured * in ntsc mode (which gives 60 interrupts per second). */ unsigned max_ints; /** The currently selected speed. */ std::auto_ptr speedSetting; /** Each tick of this clock, the signal changes. * Frequency is derived from speed, min_ints and max_ints. */ DynamicClock clock; }; } // namespace openmsx #endif