openMSX
Public Member Functions | Static Public Member Functions | List of all members
openmsx::Clock< FREQ_NUM, FREQ_DENOM > Class Template Reference

Represents a clock with a fixed frequency. More...

#include <Clock.hh>

Inheritance diagram for openmsx::Clock< FREQ_NUM, FREQ_DENOM >:
Inheritance graph
[legend]

Public Member Functions

 Clock (EmuTime::param e)
 Create a new clock, which starts ticking at the given time. More...
 
EmuTime::param getTime () const
 Gets the time at which the last clock tick occurred. More...
 
bool before (EmuTime::param e) const
 Checks whether this clock's last tick is or is not before the given time stamp. More...
 
unsigned getTicksTill (EmuTime::param e) const
 Calculate the number of ticks for this clock until the given time. More...
 
unsigned getTicksTill_fast (EmuTime::param e) const
 Same as above, only faster, Though the time interval may not be too large. More...
 
uint64_t getTicksTillUp (EmuTime::param e) const
 Calculate the number of ticks this clock has to tick to reach or go past the given time. More...
 
EmuTime operator+ (uint64_t n) const
 Calculate the time at which this clock will have ticked the given number of times (counted from its last tick). More...
 
EmuTime getFastAdd (unsigned n) const
 Like operator+() but faster, though the step can't be too big (max a little over 1 second). More...
 
void reset (EmuTime::param e)
 Reset the clock to start ticking at the given time. More...
 
void advance (EmuTime::param e)
 Advance this clock in time until the last tick which is not past the given time. More...
 
void advance_fast (EmuTime::param e)
 Same as above, only faster, Though the time interval may not be too large. More...
 
void operator+= (unsigned n)
 Advance this clock by the given number of ticks. More...
 
void fastAdd (unsigned n)
 Advance this clock by the given number of ticks. More...
 
template<typename Archive >
void serialize (Archive &ar, unsigned)
 

Static Public Member Functions

static EmuDuration duration (unsigned ticks)
 Calculates the duration of the given number of ticks at this clock's frequency. More...
 

Detailed Description

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
class openmsx::Clock< FREQ_NUM, FREQ_DENOM >

Represents a clock with a fixed frequency.

The frequency is in Hertz, so every tick is 1/frequency second. A clock has a current time, which can be increased by an integer number of ticks.

Definition at line 18 of file Clock.hh.

Constructor & Destructor Documentation

◆ Clock()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
openmsx::Clock< FREQ_NUM, FREQ_DENOM >::Clock ( EmuTime::param  e)
inlineexplicit

Create a new clock, which starts ticking at the given time.

Definition at line 41 of file Clock.hh.

Member Function Documentation

◆ advance()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
void openmsx::Clock< FREQ_NUM, FREQ_DENOM >::advance ( EmuTime::param  e)
inline

Advance this clock in time until the last tick which is not past the given time.

It is not allowed to advance a clock to a time in the past.

Definition at line 110 of file Clock.hh.

Referenced by openmsx::RealDrive::getMotor(), openmsx::Y8950Adpcm::sync(), openmsx::MSXHiResTimer::writeIO(), openmsx::VDPIODelay::writeIO(), openmsx::MSXTurboRPCM::writeIO(), openmsx::MSXE6Timer::writeIO(), and openmsx::SCC::writeMem().

◆ advance_fast()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
void openmsx::Clock< FREQ_NUM, FREQ_DENOM >::advance_fast ( EmuTime::param  e)
inline

Same as above, only faster, Though the time interval may not be too large.

Definition at line 117 of file Clock.hh.

◆ before()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
bool openmsx::Clock< FREQ_NUM, FREQ_DENOM >::before ( EmuTime::param  e) const
inline

Checks whether this clock's last tick is or is not before the given time stamp.

Definition at line 51 of file Clock.hh.

◆ duration()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
static EmuDuration openmsx::Clock< FREQ_NUM, FREQ_DENOM >::duration ( unsigned  ticks)
inlinestatic

Calculates the duration of the given number of ticks at this clock's frequency.

Definition at line 35 of file Clock.hh.

Referenced by openmsx::Touchpad::~Touchpad().

◆ fastAdd()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
void openmsx::Clock< FREQ_NUM, FREQ_DENOM >::fastAdd ( unsigned  n)
inline

Advance this clock by the given number of ticks.

This method is similar to operator+=, but it's optimized for speed. OTOH the amount of ticks should not be too large, otherwise an overflow occurs. Use operator+() when the duration of the ticks approaches 1 second.

Definition at line 135 of file Clock.hh.

◆ getFastAdd()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
EmuTime openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getFastAdd ( unsigned  n) const
inline

Like operator+() but faster, though the step can't be too big (max a little over 1 second).

Definition at line 93 of file Clock.hh.

Referenced by openmsx::VDPAccessSlots::Calculator::getTime().

◆ getTicksTill()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
unsigned openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTicksTill ( EmuTime::param  e) const
inline

◆ getTicksTill_fast()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
unsigned openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTicksTill_fast ( EmuTime::param  e) const
inline

Same as above, only faster, Though the time interval may not be too large.

Definition at line 70 of file Clock.hh.

Referenced by openmsx::VDPAccessSlots::Calculator::Calculator(), openmsx::VDPAccessSlots::getAccessSlot(), openmsx::V9990::getColorMode(), and openmsx::V9990::getUCTicksThisFrame().

◆ getTicksTillUp()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
uint64_t openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTicksTillUp ( EmuTime::param  e) const
inline

Calculate the number of ticks this clock has to tick to reach or go past the given time.

It is not allowed to call this method for a time in the past.

Definition at line 79 of file Clock.hh.

Referenced by openmsx::RealDrive::getMotor().

◆ getTime()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
EmuTime::param openmsx::Clock< FREQ_NUM, FREQ_DENOM >::getTime ( ) const
inline

◆ operator+()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
EmuTime openmsx::Clock< FREQ_NUM, FREQ_DENOM >::operator+ ( uint64_t  n) const
inline

Calculate the time at which this clock will have ticked the given number of times (counted from its last tick).

Definition at line 87 of file Clock.hh.

◆ operator+=()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
void openmsx::Clock< FREQ_NUM, FREQ_DENOM >::operator+= ( unsigned  n)
inline

Advance this clock by the given number of ticks.

Definition at line 125 of file Clock.hh.

◆ reset()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
void openmsx::Clock< FREQ_NUM, FREQ_DENOM >::reset ( EmuTime::param  e)
inline

◆ serialize()

template<unsigned FREQ_NUM, unsigned FREQ_DENOM = 1>
template<typename Archive >
void openmsx::Clock< FREQ_NUM, FREQ_DENOM >::serialize ( Archive &  ar,
unsigned   
)
inline

Definition at line 144 of file Clock.hh.


The documentation for this class was generated from the following file: