~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/emucore/Control.hxx

  • Committer: Bazaar Package Importer
  • Author(s): Tom Lear
  • Date: 1999-11-06 16:41:05 UTC
  • Revision ID: james.westby@ubuntu.com-19991106164105-iygopamo5mpcozvx
Tags: upstream-1.1
ImportĀ upstreamĀ versionĀ 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-1998 by Bradford W. Mott
 
12
//
 
13
// See the file "license" for information on usage and redistribution of
 
14
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
15
//
 
16
// $Id: Control.hxx,v 1.2 1998/07/15 20:51:07 bwmott Exp $
 
17
//============================================================================
 
18
 
 
19
#ifndef CONTROLLER_HXX
 
20
#define CONTROLLER_HXX
 
21
 
 
22
class Controller;
 
23
class Event;
 
24
 
 
25
#include "bspf.hxx"
 
26
 
 
27
/**
 
28
  A controller is a device that plugs into either the left or right 
 
29
  controller jack of the Video Computer System (VCS).  The pins of 
 
30
  the controller jacks are mapped as follows:
 
31
 
 
32
                           -------------
 
33
                           \ 1 2 3 4 5 /
 
34
                            \ 6 7 8 9 /
 
35
                             ---------
 
36
 
 
37
            Left Controller             Right Controller
 
38
 
 
39
    pin 1   D4  PIA SWCHA               D0  PIA SWCHA
 
40
    pin 2   D5  PIA SWCHA               D1  PIA SWCHA
 
41
    pin 3   D6  PIA SWCHA               D2  PIA SWCHA
 
42
    pin 4   D7  PIA SWCHA               D3  PIA SWCHA
 
43
    pin 5   D7  TIA INPT1 (Dumped)      D7  TIA INPT3 (Dumped)
 
44
    pin 6   D7  TIA INPT4 (Latched)     D7  TIA INPT5 (Latched)
 
45
    pin 7   +5                          +5
 
46
    pin 8   GND                         GND
 
47
    pin 9   D7  TIA INPT0 (Dumped)      D7  TIA INPT2 (Dumped)
 
48
 
 
49
  Each of the pins connected to the PIA can be configured as an
 
50
  input or output pin.  The "dumped" TIA pins are used to charge
 
51
  a capacitor.  A potentiometer is sometimes connected to these
 
52
  pins for analog input.
 
53
 
 
54
  This is a base class for all controllers.  It provides a view 
 
55
  of the controller from the prespective of the controller's jack.  
 
56
 
 
57
  @author  Bradford W. Mott
 
58
  @version $Id: Control.hxx,v 1.2 1998/07/15 20:51:07 bwmott Exp $
 
59
*/
 
60
class Controller
 
61
{
 
62
  public:
 
63
    /**
 
64
      Enumeration of the controller jacks
 
65
    */
 
66
    enum Jack
 
67
    {
 
68
      Left, Right
 
69
    };
 
70
 
 
71
  public:
 
72
    /**
 
73
      Create a new controller plugged into the specified jack
 
74
 
 
75
      @param jack The jack the controller is plugged into
 
76
      @param event The event object to use for events
 
77
    */
 
78
    Controller(Jack jack, const Event& event);
 
79
 
 
80
    /**
 
81
      Destructor
 
82
    */
 
83
    virtual ~Controller();
 
84
 
 
85
  public:
 
86
    /**
 
87
      Enumeration of the digital pins of a controller port
 
88
    */
 
89
    enum DigitalPin
 
90
    {
 
91
      One, Two, Three, Four, Six
 
92
    };
 
93
 
 
94
    /**
 
95
      Enumeration of the analog pins of a controller port
 
96
    */
 
97
    enum AnalogPin
 
98
    {
 
99
      Five, Nine
 
100
    };
 
101
 
 
102
  public:
 
103
    /**
 
104
      Read the value of the specified digital pin for this controller.
 
105
 
 
106
      @param pin The pin of the controller jack to read
 
107
      @return The state of the pin
 
108
    */
 
109
    virtual bool read(DigitalPin pin) = 0;
 
110
 
 
111
    /**
 
112
      Read the resistance at the specified analog pin for this controller.  
 
113
      The returned value is the resistance measured in ohms.
 
114
 
 
115
      @param pin The pin of the controller jack to read
 
116
      @return The resistance at the specified pin
 
117
    */
 
118
    virtual Int32 read(AnalogPin pin) = 0;
 
119
 
 
120
    /**
 
121
      Write the given value to the specified digital pin for this 
 
122
      controller.  Writing is only allowed to the pins associated 
 
123
      with the PIA.  Therefore you cannot write to pin six.
 
124
 
 
125
      @param pin The pin of the controller jack to write to
 
126
      @param value The value to write to the pin
 
127
    */
 
128
    virtual void write(DigitalPin pin, bool value) = 0;
 
129
 
 
130
  public:
 
131
    /// Constant which represents maximum resistance for analog pins
 
132
    static const Int32 maximumResistance;
 
133
 
 
134
    /// Constant which represents minimum resistance for analog pins
 
135
    static const Int32 minimumResistance;
 
136
 
 
137
  protected:
 
138
    /// Specifies which jack the controller is plugged in
 
139
    const Jack myJack;
 
140
 
 
141
    /// Reference to the event object this controller uses
 
142
    const Event& myEvent;
 
143
 
 
144
  protected:
 
145
    // Copy constructor isn't supported by controllers so make it private
 
146
    Controller(const Controller&);
 
147
 
 
148
    // Assignment operator isn't supported by controllers so make it private
 
149
    Controller& operator = (const Controller&);
 
150
};
 
151
#endif
 
152