1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#ifndef TIA_JITTER_EMULATION
19#define TIA_JITTER_EMULATION
20
21#include "bspf.hxx"
22#include "Serializable.hxx"
23
24class JitterEmulation: public Serializable {
25 public:
26
27 JitterEmulation();
28
29 public:
30
31 void reset();
32
33 void frameComplete(uInt32 scanlineCount);
34
35 void setJitterFactor(Int32 factor) { myJitterFactor = factor; }
36
37 Int32 jitter() const { return myJitter; }
38
39 void setYStart(uInt32 ystart) { myYStart = ystart; }
40
41 /**
42 * Save state.
43 */
44 bool save(Serializer& out) const override;
45
46 /**
47 * Restore state.
48 */
49 bool load(Serializer& in) override;
50
51 private:
52
53 void updateJitter(Int32 scanlineDifference);
54
55 private:
56
57 uInt32 myLastFrameScanlines;
58
59 Int32 myStableFrameFinalLines;
60
61 uInt32 myStableFrames;
62
63 uInt32 myStabilizationCounter;
64
65 uInt32 myDestabilizationCounter;
66
67 Int32 myJitter;
68
69 Int32 myJitterFactor;
70
71 uInt32 myYStart;
72
73 private:
74
75 JitterEmulation(const JitterEmulation&) = delete;
76 JitterEmulation(JitterEmulation&&) = delete;
77 JitterEmulation& operator=(const JitterEmulation&) = delete;
78 JitterEmulation& operator=(JitterEmulation&&) = delete;
79};
80
81#endif // TIA_JITTER_EMULATION
82