// $Id: EmuTimer.cc 4861 2005-11-13 08:49:47Z m9710797 $ #include "EmuTimer.hh" #include "Clock.hh" namespace openmsx { template EmuTimer::EmuTimer( Scheduler& scheduler, EmuTimerCallback& cb_) : Schedulable(scheduler), count(256), counting(false), cb(cb_) { } template void EmuTimer::setValue(byte value) { count = 256 - value; } template void EmuTimer::setStart( bool start, const EmuTime& time) { if (start != counting) { counting = start; if (start) { schedule(time); } else { unschedule(); } } } template void EmuTimer::schedule(const EmuTime& time) { Clock now(time); now += count; setSyncPoint(now.getTime()); } template void EmuTimer::unschedule() { removeSyncPoint(); } template void EmuTimer::executeUntil( const EmuTime& time, int /*userData*/) { cb.callback(FLAG); schedule(time); } template const std::string& EmuTimer::schedName() const { static const std::string name("EmuTimer"); return name; } // Force template instantiation template class EmuTimer<0x40, 3579545, 72 * 4 >; // EmuTimerOPL3_1 template class EmuTimer<0x20, 3579545, 72 * 4 * 4>; // EmuTimerOPL3_2 template class EmuTimer<0x40, 33868800, 72 * 38 >; // EmuTimerOPL4_1 template class EmuTimer<0x20, 33868800, 72 * 38 * 4>; // EmuTimerOPL4_2 } // namespace openmsx