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 SWITCHES_HXX |
19 | #define SWITCHES_HXX |
20 | |
21 | class Event; |
22 | class Properties; |
23 | class Settings; |
24 | |
25 | #include "Serializable.hxx" |
26 | #include "bspf.hxx" |
27 | |
28 | /** |
29 | This class represents the console switches of the game console. |
30 | |
31 | @author Bradford W. Mott |
32 | */ |
33 | class Switches : public Serializable |
34 | { |
35 | /** |
36 | Riot debug class needs special access to the underlying controller state |
37 | */ |
38 | friend class RiotDebug; |
39 | |
40 | public: |
41 | /** |
42 | Create a new set of switches using the specified events and |
43 | properties. |
44 | |
45 | @param event The event object to use for events |
46 | @param props The ROM properties to use for the currently enabled ROM |
47 | @param settings The settings used by the system |
48 | */ |
49 | Switches(const Event& event, const Properties& props, const Settings& settings); |
50 | virtual ~Switches() = default; |
51 | |
52 | public: |
53 | /** |
54 | Get the value of the console switches. |
55 | |
56 | @return The 8 bits which represent the state of the console switches |
57 | */ |
58 | uInt8 read() const { return mySwitches; } |
59 | |
60 | /** |
61 | Update the switches variable. |
62 | */ |
63 | void update(); |
64 | |
65 | /** |
66 | Save the current state of the switches to the given Serializer. |
67 | |
68 | @param out The Serializer object to use |
69 | @return False on any errors, else true |
70 | */ |
71 | bool save(Serializer& out) const override; |
72 | |
73 | /** |
74 | Load the current state of the switches from the given Serializer. |
75 | |
76 | @param in The Serializer object to use |
77 | @return False on any errors, else true |
78 | */ |
79 | bool load(Serializer& in) override; |
80 | |
81 | /** |
82 | Query the 'Console_TelevisionType' switches bit. |
83 | |
84 | @return True if 'Color', false if 'BlackWhite' |
85 | */ |
86 | bool tvColor() const { return mySwitches & 0x08; } |
87 | |
88 | /** |
89 | Sets 'Console_TelevisionType' switches bit. |
90 | */ |
91 | void setTvColor(bool setColor); |
92 | |
93 | /** |
94 | Query the 'Console_LeftDifficulty' switches bit. |
95 | |
96 | @return True if 'A', false if 'B' |
97 | */ |
98 | bool leftDifficultyA() const { return mySwitches & 0x40; } |
99 | |
100 | /** |
101 | Sets 'Console_LeftDifficulty' switches bit. |
102 | */ |
103 | void setLeftDifficultyA(bool setA); |
104 | |
105 | /** |
106 | Query the 'Console_RightDifficulty' switches bit. |
107 | |
108 | @return True if 'A', false if 'B' |
109 | */ |
110 | bool rightDifficultyA() const { return mySwitches & 0x80; } |
111 | |
112 | /** |
113 | Sets 'Console_LeftDifficulty' switches bit. |
114 | */ |
115 | void setRightDifficultyA(bool setA); |
116 | |
117 | |
118 | /** |
119 | Toggle between 2600 and 7800 mode depending on settings. |
120 | |
121 | @return True if 7800 mode enabled, else false |
122 | */ |
123 | bool check7800Mode(const Settings& settings); |
124 | |
125 | private: |
126 | // Reference to the event object to use |
127 | const Event& myEvent; |
128 | |
129 | // State of the console switches |
130 | uInt8 mySwitches; |
131 | |
132 | // Are we in 7800 or 2600 mode? |
133 | bool myIs7800; |
134 | |
135 | private: |
136 | // Following constructors and assignment operators not supported |
137 | Switches() = delete; |
138 | Switches(const Switches&) = delete; |
139 | Switches(Switches&&) = delete; |
140 | Switches& operator=(const Switches&) = delete; |
141 | Switches& operator=(Switches&&) = delete; |
142 | }; |
143 | |
144 | #endif |
145 | |