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 CONTROLLER_LOW_LEVEL_HXX |
19 | #define CONTROLLER_LOW_LEVEL_HXX |
20 | |
21 | #include "Control.hxx" |
22 | |
23 | /** |
24 | Some subsystems (ie, the debugger) need low-level access to the controller |
25 | ports. In particular, they need to be able to bypass the normal read/write |
26 | methods and operate directly on the individual pins. This class provides |
27 | an abstraction for that functionality. |
28 | |
29 | Classes that inherit from this class will have low-level access to the |
30 | Controller class, since it is a 'friend' of that class. |
31 | |
32 | @author Stephen Anthony |
33 | */ |
34 | class ControllerLowLevel |
35 | { |
36 | public: |
37 | ControllerLowLevel(Controller& controller) : myController(controller) { } |
38 | virtual ~ControllerLowLevel() = default; |
39 | |
40 | inline bool setPin(Controller::DigitalPin pin, bool value) { |
41 | return myController.setPin(pin, value); |
42 | } |
43 | inline bool togglePin(Controller::DigitalPin pin) { return false; } |
44 | inline bool getPin(Controller::DigitalPin pin) const { |
45 | return myController.getPin(pin); |
46 | } |
47 | inline void setPin(Controller::AnalogPin pin, Int32 value) { |
48 | myController.setPin(pin, value); |
49 | } |
50 | inline Int32 getPin(Controller::AnalogPin pin) const { |
51 | return myController.getPin(pin); |
52 | } |
53 | inline void resetDigitalPins() { |
54 | myController.resetDigitalPins(); |
55 | } |
56 | inline void resetAnalogPins() { |
57 | myController.resetAnalogPins(); |
58 | } |
59 | inline Controller& controller() const { return myController; } |
60 | |
61 | protected: |
62 | Controller& myController; |
63 | |
64 | private: |
65 | // Following constructors and assignment operators not supported |
66 | ControllerLowLevel() = delete; |
67 | ControllerLowLevel(const ControllerLowLevel&) = delete; |
68 | ControllerLowLevel(ControllerLowLevel&&) = delete; |
69 | ControllerLowLevel& operator=(const ControllerLowLevel&) = delete; |
70 | ControllerLowLevel& operator=(ControllerLowLevel&&) = delete; |
71 | }; |
72 | |
73 | #endif |
74 | |