OXYGENHUB
◆ main openmsx / src / DynamicClock.cc
755 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "DynamicClock.hh"
2
3
#include "serialize.hh"
4
5
#include <cassert>
6
7
namespace openmsx {
8
9
template<typename Archive>
10
void DynamicClock::serialize(Archive& ar, unsigned version)
11
{
12
	ar.serialize("lastTick", lastTick);
13
	if (ar.versionAtLeast(version, 2)) {
14
		EmuDuration period = getPeriod();
15
		ar.serialize("period", period);
16
		setPeriod(period);
17
	} else {
18
		// Because of possible rounding errors 'auto f = getFreq()'
19
		// followed by 'setFreq(f)' is not guaranteed to reproduce the
20
		// exact same result. So in newer versions serialize the period
21
		// instead of the frequency.
22
		assert(Archive::IS_LOADER);
23
		unsigned freq = 0;
24
		ar.serialize("freq", freq);
25
		setFreq(freq);
26
	}
27
}
28
INSTANTIATE_SERIALIZE_METHODS(DynamicClock);
29
30
} // namespace openmsx