2012-01-02 16:37:17 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
2014-01-12 17:23:42 +00:00
|
|
|
// Copyright (c) 1995-2014 by Bradford W. Mott, Stephen Anthony
|
2012-01-02 16:37:17 +00:00
|
|
|
// and the Stella Team
|
|
|
|
//
|
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef COMPUMATE_HXX
|
|
|
|
#define COMPUMATE_HXX
|
|
|
|
|
|
|
|
#include "bspf.hxx"
|
2012-03-14 22:24:54 +00:00
|
|
|
#include "CartCM.hxx"
|
2012-01-02 16:37:17 +00:00
|
|
|
#include "Control.hxx"
|
|
|
|
#include "Event.hxx"
|
|
|
|
|
|
|
|
/**
|
2012-03-14 01:19:23 +00:00
|
|
|
Handler for SpectraVideo CompuMate bankswitched games.
|
|
|
|
|
|
|
|
The specifics of the CompuMate format can be found in both the Cart side
|
|
|
|
(CartCM) and the Controller side (CMControl). The CompuMate device is
|
|
|
|
unique for the 2600 in that it requires close co-operation between the
|
|
|
|
cartridge and the left and right controllers.
|
|
|
|
|
2012-03-14 22:24:54 +00:00
|
|
|
This class acts as a 'parent' for cartridge and both the left and right
|
|
|
|
CMControl's, taking care of their creation and communication between them.
|
2013-04-23 15:57:33 +00:00
|
|
|
It also allows to enable/disable the users actual keyboard when required.
|
2012-03-14 01:19:23 +00:00
|
|
|
|
|
|
|
@author Stephen Anthony
|
2012-01-02 16:37:17 +00:00
|
|
|
@version $Id$
|
|
|
|
*/
|
2012-03-14 01:19:23 +00:00
|
|
|
class CompuMate
|
2012-01-02 16:37:17 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2012-03-14 01:19:23 +00:00
|
|
|
Create a new CompuMate handler for both left and right ports.
|
|
|
|
Note that this class creates CMControl controllers for both ports,
|
|
|
|
but does not take responsibility for their deletion.
|
2012-01-02 16:37:17 +00:00
|
|
|
|
2012-03-14 22:24:54 +00:00
|
|
|
@param cart The CompuMate cartridge
|
2012-01-02 16:37:17 +00:00
|
|
|
@param event The event object to use for events
|
|
|
|
@param system The system using this controller
|
|
|
|
*/
|
2012-03-14 22:24:54 +00:00
|
|
|
CompuMate(CartridgeCM& cart, const Event& event, const System& system);
|
2012-01-02 16:37:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor
|
2012-03-14 01:19:23 +00:00
|
|
|
Controllers are deleted outside this class
|
2012-01-02 16:37:17 +00:00
|
|
|
*/
|
2012-03-14 01:19:23 +00:00
|
|
|
virtual ~CompuMate() { }
|
2012-01-02 16:37:17 +00:00
|
|
|
|
|
|
|
/**
|
2012-03-14 01:19:23 +00:00
|
|
|
Return the left and right CompuMate controllers
|
2012-01-02 16:37:17 +00:00
|
|
|
*/
|
2013-04-22 16:41:05 +00:00
|
|
|
Controller* leftController() { return myLeftController; }
|
|
|
|
Controller* rightController() { return myRightController; }
|
2012-01-02 16:37:17 +00:00
|
|
|
|
2013-04-23 15:57:33 +00:00
|
|
|
/**
|
|
|
|
In normal key-handling mode, the update handler receives key events
|
2013-06-26 16:03:08 +00:00
|
|
|
from the keyboard. This is meant to be used during emulation.
|
2013-04-23 15:57:33 +00:00
|
|
|
|
|
|
|
Otherwise, the update handler ignores keys from the keyboard and uses
|
|
|
|
its own internal buffer, which essentially can only be set directly
|
|
|
|
within the class itself (by the debugger).
|
|
|
|
|
|
|
|
This is necessary since Stella is otherwise event-based, whereas
|
|
|
|
reading from the keyboard (in the current code) bypasses the event
|
|
|
|
system. This leads to issues where typing commands in the debugger
|
|
|
|
would then be processed by the update handler as if they were
|
|
|
|
entered on the CompuMate keyboard.
|
|
|
|
*/
|
|
|
|
void enableKeyHandling(bool enable);
|
|
|
|
|
2012-01-02 16:37:17 +00:00
|
|
|
private:
|
2012-03-14 22:24:54 +00:00
|
|
|
/**
|
|
|
|
Called by the controller(s) when all pins have been written
|
|
|
|
This method keeps track of consecutive calls, and only updates once
|
|
|
|
*/
|
|
|
|
void update();
|
|
|
|
|
2012-03-14 01:19:23 +00:00
|
|
|
// The actual CompuMate controller
|
|
|
|
// More information about these scheme can be found in CartCM.hxx
|
|
|
|
class CMControl : public Controller
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Create a new CMControl controller plugged into the specified jack
|
|
|
|
|
|
|
|
@param handler Class which coordinates between left & right controllers
|
|
|
|
@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
|
|
|
|
*/
|
|
|
|
CMControl(class CompuMate& handler, Controller::Jack jack, const Event& event,
|
|
|
|
const System& system)
|
|
|
|
: Controller(jack, event, system, Controller::CompuMate),
|
|
|
|
myHandler(handler)
|
2012-03-15 15:22:57 +00:00
|
|
|
{ }
|
2012-03-14 01:19:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor
|
|
|
|
*/
|
|
|
|
virtual ~CMControl() { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Called after *all* digital pins have been written on Port A.
|
2012-03-25 14:42:09 +00:00
|
|
|
|
|
|
|
@param value The entire contents of the SWCHA register
|
2012-03-14 01:19:23 +00:00
|
|
|
*/
|
2012-03-25 14:42:09 +00:00
|
|
|
void controlWrite(uInt8) { myHandler.update(); }
|
2012-03-14 01:19:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Update the entire digital and analog pin state according to the
|
|
|
|
events currently set.
|
|
|
|
*/
|
|
|
|
void update() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
class CompuMate& myHandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2012-03-14 22:24:54 +00:00
|
|
|
// Cart, Event and System objects
|
|
|
|
CartridgeCM& myCart;
|
|
|
|
const Event& myEvent;
|
2012-03-14 01:19:23 +00:00
|
|
|
const System& mySystem;
|
|
|
|
|
|
|
|
// Left and right controllers
|
|
|
|
CMControl *myLeftController, *myRightController;
|
|
|
|
|
2012-04-19 15:25:09 +00:00
|
|
|
// The keyboard state array (tells us the current state of the keyboard)
|
2012-04-19 20:11:16 +00:00
|
|
|
const bool* myKeyTable;
|
2012-04-19 15:25:09 +00:00
|
|
|
|
2013-04-23 15:57:33 +00:00
|
|
|
// Array of keyboard key states when in the debugger (the normal keyboard
|
|
|
|
// keys are ignored in such a case)
|
|
|
|
bool myInternalKeyTable[KBDK_LAST];
|
|
|
|
|
2012-03-14 01:19:23 +00:00
|
|
|
// System cycle at which the update() method is called
|
|
|
|
// Multiple calls at the same cycle should be ignored
|
|
|
|
uInt32 myCycleAtLastUpdate;
|
2012-01-02 16:37:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|