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_PADDLE_READER
19#define TIA_PADDLE_READER
20
21#include "bspf.hxx"
22#include "Serializable.hxx"
23#include "Console.hxx"
24
25class PaddleReader : public Serializable
26{
27 public:
28
29 PaddleReader();
30
31 public:
32
33 void reset(uInt64 timestamp);
34
35 void vblank(uInt8 value, uInt64 timestamp);
36 bool vblankDumped() const { return myIsDumped; }
37
38 uInt8 inpt(uInt64 timestamp);
39
40 void update(double value, uInt64 timestamp, ConsoleTiming consoleTiming);
41
42 /**
43 Serializable methods (see that class for more information).
44 */
45 bool save(Serializer& out) const override;
46 bool load(Serializer& in) override;
47
48 private:
49
50 void setConsoleTiming(ConsoleTiming timing);
51
52 void updateCharge(uInt64 timestamp);
53
54 private:
55
56 double myUThresh;
57 double myU;
58
59 double myValue;
60 uInt64 myTimestamp;
61
62 ConsoleTiming myConsoleTiming;
63 double myClockFreq;
64
65 bool myIsDumped;
66
67 static constexpr double
68 R0 = 1.5e3,
69 C = 68e-9,
70 RPOT = 1e6,
71 USUPP = 5;
72
73 static constexpr double TRIPPOINT_LINES = 379;
74
75 private:
76 PaddleReader(const PaddleReader&) = delete;
77 PaddleReader(PaddleReader&&) = delete;
78 PaddleReader& operator=(const PaddleReader&) = delete;
79 PaddleReader& operator=(PaddleReader&&) = delete;
80};
81
82#endif // TIA_PADDLE_READER
83