Added support for CX-22, CX-80 and AmigaMouse trackball-type controllers.

This code was heavily borrowed from z26.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1502 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-05-12 22:40:26 +00:00
parent 19be269077
commit 30ee2804b8
12 changed files with 362 additions and 180 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Console.cxx,v 1.140 2008-05-11 21:18:35 stephena Exp $
// $Id: Console.cxx,v 1.141 2008-05-12 22:40:23 stephena Exp $
//============================================================================
#include <cassert>
@ -44,7 +44,7 @@
#include "Switches.hxx"
#include "System.hxx"
#include "TIA.hxx"
#include "TrackBall22.hxx"
#include "TrackBall.hxx"
#include "FrameBuffer.hxx"
#include "OSystem.hxx"
#include "Menu.hxx"
@ -604,7 +604,18 @@ void Console::setControllers()
}
else if(left == "TRACKBALL22")
{
myControllers[leftPort] = new TrackBall22(Controller::Left, *myEvent, *mySystem);
myControllers[leftPort] = new TrackBall(Controller::Left, *myEvent, *mySystem,
Controller::TrackBall22);
}
else if(left == "TRACKBALL80")
{
myControllers[leftPort] = new TrackBall(Controller::Left, *myEvent, *mySystem,
Controller::TrackBall80);
}
else if(left == "AMIGAMOUSE")
{
myControllers[leftPort] = new TrackBall(Controller::Left, *myEvent, *mySystem,
Controller::AmigaMouse);
}
else
{
@ -630,7 +641,18 @@ void Console::setControllers()
}
else if(right == "TRACKBALL22")
{
myControllers[rightPort] = new TrackBall22(Controller::Right, *myEvent, *mySystem);
myControllers[rightPort] = new TrackBall(Controller::Left, *myEvent, *mySystem,
Controller::TrackBall22);
}
else if(right == "TRACKBALL80")
{
myControllers[rightPort] = new TrackBall(Controller::Left, *myEvent, *mySystem,
Controller::TrackBall80);
}
else if(right == "AMIGAMOUSE")
{
myControllers[rightPort] = new TrackBall(Controller::Left, *myEvent, *mySystem,
Controller::AmigaMouse);
}
else if(right == "ATARIVOX")
{

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Control.cxx,v 1.11 2008-04-29 15:13:16 stephena Exp $
// $Id: Control.cxx,v 1.12 2008-05-12 22:40:23 stephena Exp $
//============================================================================
#include <cassert>
@ -58,6 +58,12 @@ Controller::Controller(Jack jack, const Event& event, const System& system,
case TrackBall22:
myName = "TrackBall22";
break;
case TrackBall80:
myName = "TrackBall80";
break;
case AmigaMouse:
myName = "AmigaMouse";
break;
case AtariVox:
myName = "AtariVox";
break;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Control.hxx,v 1.14 2008-04-29 15:13:16 stephena Exp $
// $Id: Control.hxx,v 1.15 2008-05-12 22:40:23 stephena Exp $
//============================================================================
#ifndef CONTROLLER_HXX
@ -57,7 +57,7 @@ class System;
of the controller from the perspective of the controller's jack.
@author Bradford W. Mott
@version $Id: Control.hxx,v 1.14 2008-04-29 15:13:16 stephena Exp $
@version $Id: Control.hxx,v 1.15 2008-05-12 22:40:23 stephena Exp $
*/
class Controller : public Serializable
{
@ -76,7 +76,7 @@ class Controller : public Serializable
enum Type
{
BoosterGrip, Driving, Keyboard, Paddles, Joystick,
TrackBall22, AtariVox, SaveKey
TrackBall22, TrackBall80, AmigaMouse, AtariVox, SaveKey
};
public:

View File

@ -304,7 +304,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = {
{ "17ee23e5da931be82f733917adcb6386", "Salu, Dennis M. Kiss", "460758", "Acid Drop (1992) (Salu) (PAL)", "", "Extremely Rare", "", "", "", "", "", "", "", "", "", "", "54", "", "", "", "" },
{ "1802cc46b879b229272501998c5de04f", "Atari, Christopher H. Omarzu", "CX26104", "Big Bird's Egg Catch (1983) (Atari)", "Uses Kids/Keypad Controllers", "Rare", "", "", "", "", "", "", "KEYBOARD", "KEYBOARD", "", "", "", "", "", "", "" },
{ "180c234496f31a8671226277e0afbf2f", "", "", "Greeting Cart Mario And Luigi(PD)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "183020a80848e06a1238a1ab74079d52", "Thomas Jentzsch", "", "Missile Command (Amiga Mouse) (2002) (TJ) (PAL)", "Uses Amiga Mouse Controller", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "183020a80848e06a1238a1ab74079d52", "Thomas Jentzsch", "", "Missile Command (Amiga Mouse) (2002) (TJ) (PAL)", "Uses Amiga Mouse Controller", "Homebrew", "", "", "", "", "", "", "AMIGAMOUSE", "", "", "", "", "", "YES", "", "" },
{ "1862fca4f98e66f363308b859b5863af", "Atari", "", "128-in-1 Junior Console (Chip 1) (1991) (Atari) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "250", "", "", "" },
{ "18760f1f9ca5e18610115cf7b815b824", "", "", "Star Fire (23-10-2002) (MP)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "18b28b386abdadb3a700ac8fb68e639a", "Manuel Polik", "", "Gunfight 2600 (MP) (PAL)", "", "New Release", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
@ -417,7 +417,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = {
{ "2327456f86d7e0deda94758c518d05b3", "Digitel", "", "Mr. Postman (Digitel)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "2351d26d0bfdee3095bec9c05cbcf7b0", "", "", "Warring Worms (19-01-2002) (Billy Eno)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "235436ab0832370e73677c9c6f0c8b06", "", "", "Beast Invaders (Double Shot) (Hack)", "Hack of Space Invaders", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "2365e1534d67f94d8670394ab99150ce", "Thomas Jentzsch", "", "Missile Command (CX-80 Trackball) (2002) (TJ)", "Uses CX-80 TrackBall Controller", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "2365e1534d67f94d8670394ab99150ce", "Thomas Jentzsch", "", "Missile Command (CX-80 Trackball) (2002) (TJ)", "Uses CX-80 Trackball Controller", "Homebrew", "", "", "", "", "", "", "TRACKBALL80", "", "", "", "", "", "YES", "", "" },
{ "23d445ea19a18fb78d5035878d9fb649", "CBS Electronics", "4L1818, 4L1819, 4L1820", "Mouse Trap (1982) (CBS Electronics) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "23e4ca038aba11982e1694559f3be10f", "", "", "Big Dig (V3) (20-10-2002) (CT)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "23fad5a125bcd4463701c8ad8a0043a9", "CCE", "C-840", "Stone Age (1983) (CCE)", "", "", "", "", "", "", "", "", "", "", "", "", "26", "220", "", "", "" },
@ -1658,7 +1658,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = {
{ "8bbfd951c89cc09c148bfabdefa08bec", "UA Limited", "", "Pleiades (1983) (UA Limited) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "32", "", "YES", "", "" },
{ "8bc0d2052b4f259e7a50a7c771b45241", "Xonox, Anthony R. Henderson", "", "Tomarc the Barbarian (1983) (Xonox)", "", "", "", "", "", "", "", "", "", "", "", "", "24", "", "", "", "" },
{ "8bd8f65377023bdb7c5fcf46ddda5d31", "Activision, Bob Whitehead", "AG-019", "Sky Jinks (1982) (Activision) (4K)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "8bebac614571135933116045204f0f00", "Thomas Jentzsch", "", "Missile Command (CX-22 Trackball) (2002) (TJ) (PAL)", "Uses CX-22 Trackball Controller", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "8bebac614571135933116045204f0f00", "Thomas Jentzsch", "", "Missile Command (CX-22 Trackball) (2002) (TJ) (PAL)", "Uses CX-22 Trackball Controller", "Homebrew", "", "", "", "", "", "", "TRACKBALL22", "", "", "", "", "", "YES", "", "" },
{ "8c103a79b007a2fd5af602334937b4e1", "Thomas Jentzsch", "", "Laser Base (Thomas Jentzsch)", "NTSC Conversion", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "240", "", "", "" },
{ "8c136e97c0a4af66da4a249561ed17db", "", "", "Poker Squares (V0.27) (2001) (B. Watson)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "8c2fa33048f055f38358d51eefe417db", "Home Vision - Gem Int'l Corp.", "VCS83137", "Teddy Apple (1983) (Home Vision) (PAL)", "AKA Open, Sesame!", "", "", "", "", "", "", "", "", "", "", "", "42", "", "YES", "", "" },
@ -1666,10 +1666,10 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = {
{ "8c8a26ed57870daba8e13162d497bad1", "HES", "", "2 Pak Special Green - Dolphin, Oink (1990) (HES) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "8ccaa442d26b09139685f5b22bf189c4", "Retroactive", "", "Qb (V1.01) (NTSC) (2001) (Retroactive)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "8cd26dcf249456fe4aeb8db42d49df74", "Atari", "CX26139", "Crossbow (1987) (Atari)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "8ce9126066f2ddd5173e9f1f9ce1494e", "Thomas Jentzsch", "", "Missile Command (CX-22 Trackball) (2002) (TJ)", "Uses CX-22 Trackball Controller", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "8ce9126066f2ddd5173e9f1f9ce1494e", "Thomas Jentzsch", "", "Missile Command (CX-22 Trackball) (2002) (TJ)", "Uses CX-22 Trackball Controller", "Homebrew", "", "", "", "", "", "", "TRACKBALL22", "", "", "", "", "", "YES", "", "" },
{ "8cf0d333bbe85b9549b1e6b1e2390b8d", "Atari, Brad Stewart", "CX2649, CX2649P", "Asteroids (1981) (Atari) (PAL)", "", "Common", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "8d00a38f4c8f8800f1c237215ac243fc", "", "", "3-D Corridor (Green) (30-03-2003) (AD)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "8d1e2a6d2885966e6d86717180938f87", "Thomas Jentzsch", "", "Missile Command (Amiga Mouse) (2002) (TJ)", "Uses Amiga Mouse Controller", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "8d1e2a6d2885966e6d86717180938f87", "Thomas Jentzsch", "", "Missile Command (Amiga Mouse) (2002) (TJ)", "Uses Amiga Mouse Controller", "Homebrew", "", "", "", "", "", "", "AMIGAMOUSE", "", "", "", "", "", "YES", "", "" },
{ "8d8b7d7b983f75debbdaac651e814768", "", "", "Demo Image Series #15 - Three Marios (PAL) (06-03-2003) (AD)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "8d9a06101ebb0f147936356e645309b8", "", "", "Grid Pattern Demo 2 (20-12-2002) (CT)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "8da51e0c4b6b46f7619425119c7d018e", "Atari, David Lubar", "CX26183", "Sentinel (1990) (Atari)", "Uses the Light Gun Controller (left only)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
@ -1771,7 +1771,7 @@ static const char* DefProps[DEF_PROPS_SIZE][21] = {
{ "969b968383d9f0e9d8ffd1056bcaef49", "Atari, Larry Kaplan", "CX2628, CX2628P", "Bowling (1979) (Atari) (PAL)", "", "Common", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "96bcb3d97ce4ff7586326d183ac338a2", "", "", "Revenge of the Apes (Hack) [h2]", "Hack of Planet of the Apes", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "96e798995af6ed9d8601166d4350f276", "20th Century Fox Video Games, David Ross", "11029", "Meltdown (1983) (20th Century Fox) (Prototype)", "", "Prototype", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "96eccc2277043508a6c481ea432d7dd9", "Thomas Jentzsch", "", "Missile Command (CX-80 Trackball) (2002) (TJ) (PAL)", "Uses CX-80 Trackball Controller", "Homebrew", "", "", "", "", "", "", "", "", "", "", "", "", "YES", "", "" },
{ "96eccc2277043508a6c481ea432d7dd9", "Thomas Jentzsch", "", "Missile Command (CX-80 Trackball) (2002) (TJ) (PAL)", "Uses CX-80 Trackball Controller", "Homebrew", "", "", "", "", "", "", "TRACKBALL80", "", "", "", "", "", "YES", "", "" },
{ "96f806fc62005205d851e758d050dfca", "", "", "Push (V0.05) (2001) (AD)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "972486110933623039a3581db308fda6", "", "", "Xeno Plus (Hack)", "Hack of Xenophobe", "Hack", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "97327d6962f8c64e6f926f79cd01c6b9", "", "", "Jawbreaker (Unknown) (PAL)", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },

View File

@ -0,0 +1,185 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TrackBall.cxx,v 1.1 2008-05-12 22:40:25 stephena Exp $
//============================================================================
#include "Event.hxx"
#include "System.hxx"
#include "TIA.hxx"
#include "TrackBall.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrackBall::TrackBall(Jack jack, const Event& event, const System& system,
Type type)
: Controller(jack, event, system, type),
myHCounter(0),
myVCounter(0),
myCyclesWhenSWCHARead(0)
{
if(myJack == Left)
{
myPin1Mask = 0x10;
myPin2Mask = 0x20;
myPin3Mask = 0x40;
myPin4Mask = 0x80;
}
else
{
myPin1Mask = 0x01;
myPin2Mask = 0x02;
myPin3Mask = 0x04;
myPin4Mask = 0x08;
}
myTrakBallCountH = myTrakBallCountV = 0;
myTrakBallLinesH = myTrakBallLinesV = 1;
myTrakBallLeft = myTrakBallDown = myScanCountV = myScanCountH =
myCountV = myCountH = 0;
// Analog pins are never used by the trackball controller
myAnalogPinValue[Five] = myAnalogPinValue[Nine] = maximumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrackBall::~TrackBall()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TrackBall::read(DigitalPin pin)
{
// Only update the controller pins when an SWCHA read is actually
// different from a previous one
// This is done since Stella tends to read several pins consecutively
// in the same processor 'cycle', and it would be inefficient/incorrect
// to do this work multiple times per processor cycle
if(myCyclesWhenSWCHARead != mySystem.cycles())
{
int scanline = ((System&)mySystem).tia().scanlines();
if(myScanCountV > scanline) myScanCountV = 0;
if(myScanCountH > scanline) myScanCountH = 0;
while((myScanCountV + myTrakBallLinesV) < scanline)
{
if(myTrakBallCountV)
{
if(myTrakBallDown) myCountV--;
else myCountV++;
myTrakBallCountV--;
}
myScanCountV += myTrakBallLinesV;
}
while((myScanCountH + myTrakBallLinesH) < scanline)
{
if(myTrakBallCountH)
{
if(myTrakBallLeft) myCountH--;
else myCountH++;
myTrakBallCountH--;
}
myScanCountH += myTrakBallLinesH;
}
myCountV &= 0x03;
myCountH &= 0x03;
uInt8 IOPortA = 0x00;
switch(myType)
{
case Controller::TrackBall80:
IOPortA = IOPortA
| ourTrakBallTableST_V[myCountV]
| ourTrakBallTableST_H[myCountH];
break;
case Controller::TrackBall22:
IOPortA = IOPortA
| ourTrakBallTableTB_V[myCountV & 0x01][myTrakBallDown]
| ourTrakBallTableTB_H[myCountH & 0x01][myTrakBallLeft];
break;
case Controller::AmigaMouse:
IOPortA = IOPortA
| ourTrakBallTableAM_V[myCountV]
| ourTrakBallTableAM_H[myCountH];
break;
default:
break;
}
myDigitalPinState[One] = IOPortA & myPin1Mask;
myDigitalPinState[Two] = IOPortA & myPin2Mask;
myDigitalPinState[Three] = IOPortA & myPin3Mask;
myDigitalPinState[Four] = IOPortA & myPin4Mask;
}
// Remember when the SWCHA read was issued
myCyclesWhenSWCHARead = mySystem.cycles();
return Controller::read(pin);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TrackBall::update()
{
// Get the current mouse position
myHCounter = myEvent.get(Event::MouseAxisXValue);
myVCounter = myEvent.get(Event::MouseAxisYValue);
if(myVCounter < 0) myTrakBallLeft = 1;
else myTrakBallLeft = 0;
if(myHCounter < 0) myTrakBallDown = 0;
else myTrakBallDown = 1;
myTrakBallCountH = abs(myVCounter >> 1);
myTrakBallCountV = abs(myHCounter >> 1);
myTrakBallLinesH = 200 /*LinesInFrame*/ / (myTrakBallCountH + 1);
if(myTrakBallLinesH == 0) myTrakBallLinesH = 1;
myTrakBallLinesV = 200 /*LinesInFrame*/ / (myTrakBallCountV + 1);
if(myTrakBallLinesV == 0) myTrakBallLinesV = 1;
// Get mouse button state
myDigitalPinState[Six] = (myEvent.get(Event::MouseButtonValue) == 0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TrackBall::ourTrakBallTableTB_H[2][2] = {
{ 0x40, 0x00 }, { 0xc0, 0x80 }
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TrackBall::ourTrakBallTableTB_V[2][2] = {
{ 0x00, 0x10 }, { 0x20, 0x30 }
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TrackBall::ourTrakBallTableST_H[4] = {
0x00, 0x80, 0xc0, 0x40
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TrackBall::ourTrakBallTableST_V[4] = {
0x00, 0x10, 0x30, 0x20
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TrackBall::ourTrakBallTableAM_H[4] = {
0x00, 0x10, 0x50, 0x40
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt32 TrackBall::ourTrakBallTableAM_V[4] = {
0x00, 0x80, 0xa0, 0x20
};

View File

@ -0,0 +1,111 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TrackBall.hxx,v 1.1 2008-05-12 22:40:25 stephena Exp $
//============================================================================
#ifndef TRACKBALL_HXX
#define TRACKBALL_HXX
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The various trackball-like controllers supported by the Atari 2600.
They're all placed in one class, since other than a few minor
differences, they work almost exactly the same. This code was
heavily borrowed from z26.
The supported controllers include:
TrackBall22: Atari 2600 CX-22 Trakball
TrackBall80: Atari ST CX-80 Trakball
AmigaMouse: Amiga Mouse
@author Stephen Anthony & z26 team
@version $Id: TrackBall.hxx,v 1.1 2008-05-12 22:40:25 stephena Exp $
*/
class TrackBall : public Controller
{
public:
/**
Create a new TrackBall controller plugged into the specified jack
@param jack The jack the controller is plugged into
@param event The event object to use for events
@param system The system using this controller
@param type The type of trackball controller
*/
TrackBall(Jack jack, const Event& event, const System& system, Type type);
/**
Destructor
*/
virtual ~TrackBall();
public:
/**
Read the value of the specified digital pin for this controller.
@param pin The pin of the controller jack to read
@return The state of the pin
*/
virtual bool read(DigitalPin pin);
/**
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual void update();
private:
// Counter to iterate through the gray codes
int myHCounter, myVCounter;
// Indicates the processor cycle when SWCHA was last read
uInt32 myCyclesWhenSWCHARead;
// Masks to indicate how to access the pins (differentiate between
// left and right ports)
uInt8 myPin1Mask, myPin2Mask, myPin3Mask, myPin4Mask;
// How many new horizontal and vertical values this frame
int myTrakBallCountH, myTrakBallCountV;
// How many lines to wait before sending new horz and vert val
int myTrakBallLinesH, myTrakBallLinesV;
// Was TrakBall moved left or moved right instead
int myTrakBallLeft;
// Was TrakBall moved down or moved up instead
int myTrakBallDown;
int myScanCountH, myScanCountV, myCountH, myCountV;
// CX-22
static const uInt32 ourTrakBallTableTB_H[2][2];
static const uInt32 ourTrakBallTableTB_V[2][2];
// ST mouse / CX-80
static const uInt32 ourTrakBallTableST_H[4];
static const uInt32 ourTrakBallTableST_V[4];
// Amiga mouse
static const uInt32 ourTrakBallTableAM_H[4];
static const uInt32 ourTrakBallTableAM_V[4];
};
#endif

View File

@ -1,86 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TrackBall22.cxx,v 1.5 2008-04-13 23:43:14 stephena Exp $
//============================================================================
#include "Event.hxx"
#include "TrackBall22.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrackBall22::TrackBall22(Jack jack, const Event& event, const System& system)
: Controller(jack, event, system, Controller::TrackBall22),
myHCounter(0),
myVCounter(0)
{
if(myJack == Left)
{
myUpEvent = Event::JoystickZeroUp;
myDownEvent = Event::JoystickZeroDown;
myLeftEvent = Event::JoystickZeroLeft;
myRightEvent = Event::JoystickZeroRight;
myFireEvent = Event::JoystickZeroFire1;
}
else
{
myUpEvent = Event::JoystickOneUp;
myDownEvent = Event::JoystickOneDown;
myLeftEvent = Event::JoystickOneLeft;
myRightEvent = Event::JoystickOneRight;
myFireEvent = Event::JoystickOneFire1;
}
// Analog pins are never used by the CX-22
myAnalogPinValue[Five] = myAnalogPinValue[Nine] = maximumResistance;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TrackBall22::~TrackBall22()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TrackBall22::update()
{
//db TrakBallTableTB_V[2][2] = {{0x00, 0x10},{0x20, 0x30}}; /* CX-22 */
//db TrakBallTableTB_H[2][2] = {{0x40, 0x00},{0xc0, 0x80}}; /* CX-22 */
// Gray codes for rotation
static const uInt8 graytable[] = { 0x00, 0x10, 0x20, 0x30 };
// Determine which gray code we're at
if(myEvent.get(myLeftEvent) != 0)
{
myHCounter--;
cerr << "left\n";
}
else if(myEvent.get(myRightEvent) != 0)
{
myHCounter++;
cerr << "right\n";
}
// Only consider the lower-most bits (corresponding to pins 1 & 2)
myHCounter &= 0x0f;
uInt8 gray = graytable[myHCounter >> 2];
// Determine which bits are set
myDigitalPinState[One] = (gray & 0x1) != 0;
myDigitalPinState[Two] = (gray & 0x2) != 0;
myDigitalPinState[Three] = (gray & 0x1) != 0;
myDigitalPinState[Four] = (gray & 0x2) != 0;
myDigitalPinState[Six] = (myEvent.get(myFireEvent) == 0);
}

View File

@ -1,65 +0,0 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TrackBall22.hxx,v 1.3 2008-04-13 23:43:14 stephena Exp $
//============================================================================
#ifndef TRACKBALL22_HXX
#define TRACKBALL22_HXX
#include "bspf.hxx"
#include "Control.hxx"
#include "Event.hxx"
/**
The standard Atari 2600 CX-22 Trakball controller.
@author Stephen Anthony
@version $Id: TrackBall22.hxx,v 1.3 2008-04-13 23:43:14 stephena Exp $
*/
class TrackBall22 : public Controller
{
public:
/**
Create a new CX-22 TrackBall controller plugged into the specified jack
@param jack The jack the controller is plugged into
@param event The event object to use for events
@param system The system using this controller
*/
TrackBall22(Jack jack, const Event& event, const System& system);
/**
Destructor
*/
virtual ~TrackBall22();
public:
/**
Update the entire digital and analog pin state according to the
events currently set.
*/
virtual void update();
private:
// Counter to iterate through the gray codes
uInt32 myHCounter, myVCounter;
// Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update()
Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, myFireEvent;
};
#endif

View File

@ -55,7 +55,7 @@ MODULE_OBJS := \
src/emucore/StateManager.o \
src/emucore/TIA.o \
src/emucore/TIASnd.o \
src/emucore/TrackBall22.o \
src/emucore/TrackBall.o \
src/emucore/unzip.o \
src/emucore/MediaFactory.o

View File

@ -1758,6 +1758,7 @@
"Cartridge.Name" "Missile Command (Amiga Mouse) (2002) (TJ) (PAL)"
"Cartridge.Note" "Uses Amiga Mouse Controller"
"Cartridge.Rarity" "Homebrew"
"Controller.Left" "AMIGAMOUSE"
"Display.Phosphor" "YES"
""
@ -2443,8 +2444,9 @@
"Cartridge.MD5" "2365e1534d67f94d8670394ab99150ce"
"Cartridge.Manufacturer" "Thomas Jentzsch"
"Cartridge.Name" "Missile Command (CX-80 Trackball) (2002) (TJ)"
"Cartridge.Note" "Uses CX-80 TrackBall Controller"
"Cartridge.Note" "Uses CX-80 Trackball Controller"
"Cartridge.Rarity" "Homebrew"
"Controller.Left" "TRACKBALL80"
"Display.Phosphor" "YES"
""
@ -9862,6 +9864,7 @@
"Cartridge.Name" "Missile Command (CX-22 Trackball) (2002) (TJ) (PAL)"
"Cartridge.Note" "Uses CX-22 Trackball Controller"
"Cartridge.Rarity" "Homebrew"
"Controller.Left" "TRACKBALL22"
"Display.Phosphor" "YES"
""
@ -9943,6 +9946,7 @@
"Cartridge.Name" "Missile Command (CX-22 Trackball) (2002) (TJ)"
"Cartridge.Note" "Uses CX-22 Trackball Controller"
"Cartridge.Rarity" "Homebrew"
"Controller.Left" "TRACKBALL22"
"Display.Phosphor" "YES"
""
@ -9970,6 +9974,7 @@
"Cartridge.Name" "Missile Command (Amiga Mouse) (2002) (TJ)"
"Cartridge.Note" "Uses Amiga Mouse Controller"
"Cartridge.Rarity" "Homebrew"
"Controller.Left" "AMIGAMOUSE"
"Display.Phosphor" "YES"
""
@ -10555,6 +10560,7 @@
"Cartridge.Name" "Missile Command (CX-80 Trackball) (2002) (TJ) (PAL)"
"Cartridge.Note" "Uses CX-80 Trackball Controller"
"Cartridge.Rarity" "Homebrew"
"Controller.Left" "TRACKBALL80"
"Display.Phosphor" "YES"
""

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: GameInfoDialog.cxx,v 1.54 2008-05-11 21:18:35 stephena Exp $
// $Id: GameInfoDialog.cxx,v 1.55 2008-05-12 22:40:26 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -171,7 +171,7 @@ GameInfoDialog::GameInfoDialog(
xpos = 10; ypos = vBorder;
lwidth = font.getStringWidth("P0 Controller: ");
pwidth = font.getStringWidth("Booster-Grip");
pwidth = font.getStringWidth("CX-22 Trakball");
new StaticTextWidget(myTab, font, xpos, ypos+1, lwidth, fontHeight,
"P0 Controller:", kTextAlignLeft);
myP0Controller = new PopUpWidget(myTab, font, xpos+lwidth, ypos,
@ -556,7 +556,7 @@ void GameInfoDialog::saveConfig()
{
if(i == tag-1)
{
myGameProperties.set(Controller_Left, ourControllerList[i][0]);
myGameProperties.set(Controller_Left, ourControllerList[i][1]);
break;
}
}
@ -566,7 +566,7 @@ void GameInfoDialog::saveConfig()
{
if(i == tag-1)
{
myGameProperties.set(Controller_Right, ourControllerList[i][0]);
myGameProperties.set(Controller_Right, ourControllerList[i][1]);
break;
}
}
@ -677,6 +677,9 @@ const char* GameInfoDialog::ourControllerList[kNumControllerTypes][2] = {
{ "Booster-Grip", "BOOSTER-GRIP" },
{ "Driving", "DRIVING" },
{ "Keyboard", "KEYBOARD" },
{ "CX-22 Trakball", "TRACKBALL22" },
{ "CX-80 Mouse", "TRACKBALL80" },
{ "AmigaMouse", "AMIGAMOUSE" },
{ "AtariVox", "ATARIVOX" },
{ "SaveKey", "SAVEKEY" }
};

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: GameInfoDialog.hxx,v 1.32 2008-05-11 21:18:35 stephena Exp $
// $Id: GameInfoDialog.hxx,v 1.33 2008-05-12 22:40:26 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -99,7 +99,7 @@ class GameInfoDialog : public Dialog, public CommandSender
kPhosphorChanged = 'PPch',
kPPBlendChanged = 'PBch',
kNumCartTypes = 25,
kNumControllerTypes = 7
kNumControllerTypes = 10
};
/** Game properties for currently loaded ROM */