Added infrastructure for 'smart' controllers, which need access to the

System object.  Eventually, this will lead to more accurate emulation
for Driving controllers, and hopefully support TrakBall/Amiga/ST mouse
as well.

Fixed snapshot bug where a snapshot included the CommandDialog UI when
launched from that mode.

Bumped version number to 2.3.6.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1318 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-02-22 02:15:46 +00:00
parent 0d7ee2f4d6
commit 8874d38323
9 changed files with 56 additions and 99 deletions

View File

@ -13,13 +13,13 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Version.hxx,v 1.25 2007-01-17 13:17:42 stephena Exp $ // $Id: Version.hxx,v 1.26 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#ifndef VERSION_HXX #ifndef VERSION_HXX
#define VERSION_HXX #define VERSION_HXX
#define STELLA_BASE_VERSION "2.3.5" #define STELLA_BASE_VERSION "2.3.6cvs"
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
#define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD #define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: AtariVox.hxx,v 1.6 2007-01-01 18:04:44 stephena Exp $ // $Id: AtariVox.hxx,v 1.7 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#ifdef ATARIVOX_SUPPORT #ifdef ATARIVOX_SUPPORT
@ -22,8 +22,6 @@
#ifndef ATARIVOX_HXX #ifndef ATARIVOX_HXX
#define ATARIVOX_HXX #define ATARIVOX_HXX
#include "bspf.hxx"
#include "System.hxx"
#include "Control.hxx" #include "Control.hxx"
#include "SpeakJet.hxx" #include "SpeakJet.hxx"
@ -35,7 +33,7 @@
driver code. driver code.
@author B. Watson @author B. Watson
@version $Id: AtariVox.hxx,v 1.6 2007-01-01 18:04:44 stephena Exp $ @version $Id: AtariVox.hxx,v 1.7 2007-02-22 02:15:46 stephena Exp $
*/ */
class AtariVox : public Controller class AtariVox : public Controller
{ {
@ -66,7 +64,7 @@ class AtariVox : public Controller
Read the resistance at the specified analog pin for this controller. Read the resistance at the specified analog pin for this controller.
The returned value is the resistance measured in ohms. The returned value is the resistance measured in ohms.
The AtariVox doesn't use the analog pins. The AtariVox doesn't use the analog pins.
@param pin The pin of the controller jack to read @param pin The pin of the controller jack to read
@return The resistance at the specified pin @return The resistance at the specified pin
@ -83,52 +81,42 @@ class AtariVox : public Controller
*/ */
virtual void write(DigitalPin pin, bool value); virtual void write(DigitalPin pin, bool value);
void setSystem(System *system);
SpeakJet* getSpeakJet() { return mySpeakJet; } SpeakJet* getSpeakJet() { return mySpeakJet; }
private: private:
void clockDataIn(bool value); void clockDataIn(bool value);
void shiftIn(bool value); void shiftIn(bool value);
private: private:
// How far off (in CPU cycles) can each write occur from when it's // How far off (in CPU cycles) can each write occur from when it's
// supposed to happen? Eventually, this will become a user-settable // supposed to happen? Eventually, this will become a user-settable
// property... or it may turn out to be unnecessary. // property... or it may turn out to be unnecessary.
enum { TIMING_SLOP = 0 }; enum { TIMING_SLOP = 0 };
private: // Instance of SpeakJet which will actually do the talking for us.
// Instance of SpeakJet which will actually do the talking for us.
// In the future, we'll support both real and emulated SpeakJet // In the future, we'll support both real and emulated SpeakJet
// chips; for now we only emulate it. // chips; for now we only emulate it.
SpeakJet *mySpeakJet; SpeakJet *mySpeakJet;
// Hang on to a reference to the system, for timing purposes. Data
// bits are supposed to come in 62 CPU cycles apart (plus or minus
// TIMING_SLOP), so we need to be able to call mySystem.cycles().
System *mySystem;
private:
// State of the output pins // State of the output pins
uInt8 myPinState; uInt8 myPinState;
// How many bits have been shifted into the shift register? // How many bits have been shifted into the shift register?
uInt8 myShiftCount; uInt8 myShiftCount;
private: // Shift register. Data comes in serially:
// Shift register. Data comes in serially: // 1 start bit, always 0
// 1 start bit, always 0 // 8 data bits, LSB first
// 8 data bits, LSB first // 1 stop bit, always 1
// 1 stop bit, always 1 uInt16 myShiftRegister;
uInt16 myShiftRegister;
private:
// When did the last data write start, in CPU cycles? // When did the last data write start, in CPU cycles?
// The real SpeakJet chip reads data at 19200 bits/sec. Alex's // The real SpeakJet chip reads data at 19200 bits/sec. Alex's
// driver code sends data at 62 CPU cycles per bit, which is // driver code sends data at 62 CPU cycles per bit, which is
// "close enough". // "close enough".
uInt32 myLastDataWriteCycle; uInt32 myLastDataWriteCycle;
}; };
#endif #endif
#endif
#endif // ATARIVOX_SUPPORT

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Console.cxx,v 1.125 2007-02-06 23:34:31 stephena Exp $ // $Id: Console.cxx,v 1.126 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -77,8 +77,8 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
loadUserPalette(); loadUserPalette();
// Setup the controllers based on properties // Setup the controllers based on properties
string left = myProperties.get(Controller_Left); const string& left = myProperties.get(Controller_Left);
string right = myProperties.get(Controller_Right); const string& right = myProperties.get(Controller_Right);
// Swap the ports if necessary // Swap the ports if necessary
int leftPort, rightPort; int leftPort, rightPort;
@ -116,10 +116,6 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
myControllers[leftPort] = new Joystick(Controller::Left, *myEvent); myControllers[leftPort] = new Joystick(Controller::Left, *myEvent);
} }
#ifdef ATARIVOX_SUPPORT
vox = 0;
#endif
// Construct right controller // Construct right controller
if(right == "BOOSTER-GRIP") if(right == "BOOSTER-GRIP")
{ {
@ -137,10 +133,10 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
{ {
myControllers[rightPort] = new Paddles(Controller::Right, *myEvent, swapPaddles); myControllers[rightPort] = new Paddles(Controller::Right, *myEvent, swapPaddles);
} }
#ifdef ATARIVOX_SUPPORT #ifdef ATARIVOX_SUPPORT
else if(right == "ATARIVOX") else if(right == "ATARIVOX")
{ {
myControllers[rightPort] = vox = new AtariVox(Controller::Right, *myEvent); myControllers[rightPort] = new AtariVox(Controller::Right, *myEvent);
} }
#endif #endif
else else
@ -154,12 +150,9 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
// Now, we can construct the system and components // Now, we can construct the system and components
mySystem = new System(13, 6); mySystem = new System(13, 6);
// AtariVox is a smart peripheral; it needs access to the system // Inform the controllers about the system
// cycles counter, so it needs a reference to the System myControllers[0]->setSystem(mySystem);
#ifdef ATARIVOX_SUPPORT myControllers[1]->setSystem(mySystem);
if(vox)
vox->setSystem(mySystem);
#endif
M6502* m6502; M6502* m6502;
if(myOSystem->settings().getString("cpu") == "low") if(myOSystem->settings().getString("cpu") == "low")

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Control.hxx,v 1.8 2007-01-05 17:54:09 stephena Exp $ // $Id: Control.hxx,v 1.9 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#ifndef CONTROLLER_HXX #ifndef CONTROLLER_HXX
@ -21,6 +21,7 @@
class Controller; class Controller;
class Event; class Event;
class System;
#include "bspf.hxx" #include "bspf.hxx"
@ -55,7 +56,7 @@ class Event;
of the controller from the perspective of the controller's jack. of the controller from the perspective of the controller's jack.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: Control.hxx,v 1.8 2007-01-05 17:54:09 stephena Exp $ @version $Id: Control.hxx,v 1.9 2007-02-22 02:15:46 stephena Exp $
*/ */
class Controller class Controller
{ {
@ -97,6 +98,11 @@ class Controller
*/ */
const Type type(); const Type type();
/**
Inform this controller about the current System.
*/
void setSystem(System* system) { mySystem = system; }
public: public:
/** /**
Enumeration of the digital pins of a controller port Enumeration of the digital pins of a controller port
@ -159,6 +165,9 @@ class Controller
/// Specifies which type of controller this is (defined by child classes) /// Specifies which type of controller this is (defined by child classes)
const Type myType; const Type myType;
/// Pointer to the System object (used for timing purposes)
System* mySystem;
protected: protected:
// Copy constructor isn't supported by controllers so make it private // Copy constructor isn't supported by controllers so make it private
Controller(const Controller&); Controller(const Controller&);

View File

@ -13,10 +13,11 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Driving.cxx,v 1.10 2007-01-23 09:30:22 knakos Exp $ // $Id: Driving.cxx,v 1.11 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#include <assert.h> #include <cassert>
#include "Event.hxx" #include "Event.hxx"
#include "Driving.hxx" #include "Driving.hxx"
#include "System.hxx" #include "System.hxx"

View File

@ -14,7 +14,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.cxx,v 1.201 2007-02-06 23:34:33 stephena Exp $ // $Id: EventHandler.cxx,v 1.202 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#include <sstream> #include <sstream>
@ -1259,26 +1259,6 @@ bool EventHandler::eventStateChange(Event::Type type)
return handled; return handled;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::createMouseMotionEvent(int x, int y)
{
SDL_WarpMouse(x, y);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::createMouseButtonEvent(int x, int y, int state)
{
// Synthesize an left mouse button press/release event
SDL_MouseButtonEvent mouseEvent;
mouseEvent.type = state ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
mouseEvent.button = SDL_BUTTON_LEFT;
mouseEvent.state = state ? SDL_PRESSED : SDL_RELEASED;
mouseEvent.x = x;
mouseEvent.y = y;
handleMouseButtonEvent((SDL_Event&)mouseEvent, state);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setActionMappings(EventMode mode) void EventHandler::setActionMappings(EventMode mode)
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EventHandler.hxx,v 1.101 2007-01-30 17:13:10 stephena Exp $ // $Id: EventHandler.hxx,v 1.102 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#ifndef EVENTHANDLER_HXX #ifndef EVENTHANDLER_HXX
@ -62,7 +62,7 @@ enum EventMode {
mapping can take place. mapping can take place.
@author Stephen Anthony @author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.101 2007-01-30 17:13:10 stephena Exp $ @version $Id: EventHandler.hxx,v 1.102 2007-02-22 02:15:46 stephena Exp $
*/ */
class EventHandler class EventHandler
{ {
@ -265,23 +265,6 @@ class EventHandler
inline bool frying() { return myFryingFlag; } inline bool frying() { return myFryingFlag; }
/**
Create a synthetic SDL mouse motion event based on the given x,y values.
@param x The x coordinate of motion, scaled in value
@param y The y coordinate of motion, scaled in value
*/
void createMouseMotionEvent(int x, int y);
/**
Create a synthetic SDL mouse button event based on the given x,y values.
@param x The x coordinate of motion, scaled in value
@param y The y coordinate of motion, scaled in value
@param state The state of the button click (on or off)
*/
void createMouseButtonEvent(int x, int y, int state);
inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; } inline SDL_Joystick* getJoystick(int i) { return ourJoysticks[i].stick; }
StringList getActionList(EventMode mode); StringList getActionList(EventMode mode);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.hxx,v 1.41 2007-01-06 21:13:29 stephena Exp $ // $Id: TIA.hxx,v 1.42 2007-02-22 02:15:46 stephena Exp $
//============================================================================ //============================================================================
#ifndef TIA_HXX #ifndef TIA_HXX
@ -42,7 +42,7 @@ class Settings;
be displayed on screen. be displayed on screen.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: TIA.hxx,v 1.41 2007-01-06 21:13:29 stephena Exp $ @version $Id: TIA.hxx,v 1.42 2007-02-22 02:15:46 stephena Exp $
*/ */
class TIA : public Device , public MediaSource class TIA : public Device , public MediaSource
{ {
@ -165,14 +165,14 @@ class TIA : public Device , public MediaSource
/** /**
Answers the total number of scanlines the media source generated Answers the total number of scanlines the media source generated
in producing the current frame buffer. For partial frames, this in producing the current frame buffer. For partial frames, this
will be the current scanline. will be the current scanline.
@return The total number of scanlines generated @return The total number of scanlines generated
*/ */
uInt32 scanlines() const; uInt32 scanlines() const;
/** /**
Answers the current color clock we've gotten to on this scanline. Answers the current color clock we've gotten to on this scanline.
@return The current color clock @return The current color clock
*/ */

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: CommandDialog.cxx,v 1.14 2007-01-01 19:55:56 stephena Exp $ // $Id: CommandDialog.cxx,v 1.15 2007-02-22 02:15:46 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -177,7 +177,10 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
break; break;
case kSnapshotCmd: case kSnapshotCmd:
event = Event::TakeSnapshot; instance()->eventHandler().leaveMenuMode();
instance()->eventHandler().refreshDisplay(true);
instance()->eventHandler().handleEvent(Event::TakeSnapshot, 1);
execute = false;
break; break;
case kFormatCmd: case kFormatCmd: