23 inline void add(
unsigned ticks) { clock += ticks; }
24 inline void sync()
const { }
28 inline void add(
unsigned ticks) { remaining -= narrow_cast<int>(ticks); }
30 clock.
fastAdd(limit - remaining);
39 return clock.
getFastAdd(limit - remaining + cc);
44 [[nodiscard]] EmuTime
calcTime(EmuTime::param time,
unsigned ticks)
const {
45 return clock.
add(time, ticks);
53 unsigned advanceHalt(
unsigned hltStates, EmuTime::param time) {
56 unsigned halts = (ticks + hltStates - 1) / hltStates;
57 clock += halts * hltStates;
96 assert(remaining == limit);
108 limitEnabled =
false;
109 int extra = limit - remaining;
111 remaining = limit - extra;
114 return remaining < 0;
117 template<
typename Archive>
118 void serialize(Archive& ar,
unsigned version);
124 mutable int limit = -1;
125 bool limitEnabled =
false;
void setFreq(unsigned freq)
unsigned advanceHalt(unsigned hltStates, EmuTime::param time)
Implementation of the HALT instruction timing.
EmuTime::param getTime() const
void serialize(Archive &ar, unsigned version)
void advanceTime(EmuTime::param time)
bool limitReached() const
EmuTime getTimeFast() const
void setTime(EmuTime::param time)
EmuTime calcTime(EmuTime::param time, unsigned ticks) const
void setLimit(EmuTime::param time)
EmuTime getTimeFast(int cc) const
void waitForEvenCycle(int cc)
R800 runs at 7MHz, but I/O is done over a slower 3.5MHz bus.
Represents a clock with a variable frequency.
EmuTime getFastAdd(unsigned n) const
uint64_t getTotalTicks() const
unsigned getFreq() const
Returns the frequency (in Hz) at which this clock ticks.
unsigned getTicksTillUp(EmuTime::param e) const
Calculate the number of ticks this clock has to tick to reach or go past the given time.
EmuTime add(EmuTime::param time, unsigned n) const
void reset(EmuTime::param e)
Reset the clock to start ticking at the given time.
void fastAdd(unsigned n)
Advance this clock by the given number of ticks.
void setFreq(unsigned freq)
Change the frequency at which this clock ticks.
EmuTime::param getTime() const
Gets the time at which the last clock tick occurred.
EmuTime::param getNext() const
TODO.
This file implemented 3 utility functions: