DynamicClock.cc 748 B

1234567891011121314151617181920212223242526272829
  1. #include "DynamicClock.hh"
  2. #include "serialize.hh"
  3. #include <cassert>
  4. namespace openmsx {
  5. template<typename Archive>
  6. void DynamicClock::serialize(Archive& ar, unsigned version)
  7. {
  8. ar.serialize("lastTick", lastTick);
  9. if (ar.versionAtLeast(version, 2)) {
  10. EmuDuration period = getPeriod();
  11. ar.serialize("period", period);
  12. setPeriod(period);
  13. } else {
  14. // Because of possible rounding errors 'auto f = getFreq()'
  15. // followed by 'setFreq(f)' is not guaranteed to reproduce the
  16. // exact same result. So in newer versions serialize the period
  17. // instead of the frequency.
  18. assert(ar.isLoader());
  19. unsigned freq = 0;
  20. ar.serialize("freq", freq);
  21. setFreq(freq);
  22. }
  23. }
  24. INSTANTIATE_SERIALIZE_METHODS(DynamicClock);
  25. } // namespace openmsx