mirror of https://github.com/stella-emu/stella.git
Oops, forgot to include the SaveKey class.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1490 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
0b272431ca
commit
6e51d951ef
|
@ -0,0 +1,94 @@
|
|||
//============================================================================
|
||||
//
|
||||
// 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: SaveKey.cxx,v 1.1 2008-04-29 15:49:34 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "MT24LC256.hxx"
|
||||
#include "System.hxx"
|
||||
#include "SaveKey.hxx"
|
||||
|
||||
#define DEBUG_SAVEKEY 0
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SaveKey::SaveKey(Jack jack, const Event& event, const System& system,
|
||||
const string& eepromfile)
|
||||
: Controller(jack, event, system, Controller::SaveKey),
|
||||
myEEPROM(NULL)
|
||||
{
|
||||
myEEPROM = new MT24LC256(eepromfile, system);
|
||||
|
||||
myDigitalPinState[One] = myDigitalPinState[Two] = true;
|
||||
myAnalogPinValue[Five] = myAnalogPinValue[Nine] = maximumResistance;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SaveKey::~SaveKey()
|
||||
{
|
||||
delete myEEPROM;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool SaveKey::read(DigitalPin pin)
|
||||
{
|
||||
// We need to override the Controller::read() method, since the timing
|
||||
// of the actual read is important for the EEPROM (we can't just read
|
||||
// 60 times per second in the ::update() method)
|
||||
switch(pin)
|
||||
{
|
||||
// Pin 3: EEPROM SDA
|
||||
// input data from the 24LC256 EEPROM using the I2C protocol
|
||||
case Three:
|
||||
return myDigitalPinState[Three] = myEEPROM->readSDA();
|
||||
|
||||
default:
|
||||
return Controller::read(pin);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SaveKey::write(DigitalPin pin, bool value)
|
||||
{
|
||||
// Change the pin state based on value
|
||||
switch(pin)
|
||||
{
|
||||
// Pin 3: EEPROM SDA
|
||||
// output data to the 24LC256 EEPROM using the I2C protocol
|
||||
case Three:
|
||||
if(DEBUG_SAVEKEY)
|
||||
cerr << "SaveKey: value "
|
||||
<< value
|
||||
<< " written to SDA line at cycle "
|
||||
<< mySystem.cycles()
|
||||
<< endl;
|
||||
myEEPROM->writeSDA(value);
|
||||
break;
|
||||
|
||||
// Pin 4: EEPROM SCL
|
||||
// output clock data to the 24LC256 EEPROM using the I2C protocol
|
||||
case Four:
|
||||
if(DEBUG_SAVEKEY)
|
||||
cerr << "SaveKey: value "
|
||||
<< value
|
||||
<< " written to SCLK line at cycle "
|
||||
<< mySystem.cycles()
|
||||
<< endl;
|
||||
myEEPROM->writeSCL(value);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
//============================================================================
|
||||
//
|
||||
// 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: SaveKey.hxx,v 1.1 2008-04-29 15:49:34 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SAVEKEY_HXX
|
||||
#define SAVEKEY_HXX
|
||||
|
||||
class MT24LC256;
|
||||
|
||||
#include "Control.hxx"
|
||||
|
||||
/**
|
||||
Richard Hutchinson's SaveKey "controller", consisting of a 32KB EEPROM
|
||||
accessible using the I2C protocol.
|
||||
|
||||
This code owes a great debt to Alex Herbert's AtariVox documentation and
|
||||
driver code.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: SaveKey.hxx,v 1.1 2008-04-29 15:49:34 stephena Exp $
|
||||
*/
|
||||
class SaveKey : public Controller
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Create a new AtariVox 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 eepromfile The file containing the EEPROM data
|
||||
*/
|
||||
SaveKey(Jack jack, const Event& event, const System& system,
|
||||
const string& eepromfile);
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
virtual ~SaveKey();
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
Write the given value to the specified digital pin for this
|
||||
controller. Writing is only allowed to the pins associated
|
||||
with the PIA. Therefore you cannot write to pin six.
|
||||
|
||||
@param pin The pin of the controller jack to write to
|
||||
@param value The value to write to the pin
|
||||
*/
|
||||
virtual void write(DigitalPin pin, bool value);
|
||||
|
||||
/**
|
||||
Update the entire digital and analog pin state according to the
|
||||
events currently set.
|
||||
*/
|
||||
virtual void update() { }
|
||||
|
||||
private:
|
||||
// The EEPROM used in the SaveKey
|
||||
MT24LC256* myEEPROM;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue