mirror of https://github.com/stella-emu/stella.git
Fixed issue with EEPROM access as reported on AtariAge. The AtariVox,
SaveKey and EEPROM are 'smart' controllers, making use of cycle counts for timing. All such devices may periodically need their counters reset to prevent overflow, and this was missing from the aforementioned controllers. Removed some debugging code from AtariVox class. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1518 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
52db865c0e
commit
f35ef466c6
|
@ -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: AtariVox.cxx,v 1.19 2008-05-06 16:39:10 stephena Exp $
|
||||
// $Id: AtariVox.cxx,v 1.20 2008-05-19 02:53:57 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifdef SPEAKJET_EMULATION
|
||||
|
@ -25,8 +25,6 @@
|
|||
#include "System.hxx"
|
||||
#include "AtariVox.hxx"
|
||||
|
||||
#define DEBUG_ATARIVOX 0
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
AtariVox::AtariVox(Jack jack, const Event& event, const System& system,
|
||||
const SerialPort& port, const string& portname,
|
||||
|
@ -93,9 +91,6 @@ bool AtariVox::read(DigitalPin pin)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariVox::write(DigitalPin pin, bool value)
|
||||
{
|
||||
if(DEBUG_ATARIVOX)
|
||||
cerr << "AtariVox: write to SWCHA" << endl;
|
||||
|
||||
// Change the pin state based on value
|
||||
switch(pin)
|
||||
{
|
||||
|
@ -109,12 +104,6 @@ void AtariVox::write(DigitalPin pin, bool value)
|
|||
// Pin 3: EEPROM SDA
|
||||
// output data to the 24LC256 EEPROM using the I2C protocol
|
||||
case Three:
|
||||
if(DEBUG_ATARIVOX)
|
||||
cerr << "AtariVox: value "
|
||||
<< value
|
||||
<< " written to SDA line at cycle "
|
||||
<< mySystem.cycles()
|
||||
<< endl;
|
||||
myDigitalPinState[Three] = value;
|
||||
myEEPROM->writeSDA(value);
|
||||
break;
|
||||
|
@ -122,12 +111,6 @@ void AtariVox::write(DigitalPin pin, bool value)
|
|||
// Pin 4: EEPROM SCL
|
||||
// output clock data to the 24LC256 EEPROM using the I2C protocol
|
||||
case Four:
|
||||
if(DEBUG_ATARIVOX)
|
||||
cerr << "AtariVox: value "
|
||||
<< value
|
||||
<< " written to SCLK line at cycle "
|
||||
<< mySystem.cycles()
|
||||
<< endl;
|
||||
myDigitalPinState[Four] = value;
|
||||
myEEPROM->writeSCL(value);
|
||||
break;
|
||||
|
@ -141,25 +124,9 @@ void AtariVox::write(DigitalPin pin, bool value)
|
|||
void AtariVox::clockDataIn(bool value)
|
||||
{
|
||||
uInt32 cycle = mySystem.cycles();
|
||||
if(DEBUG_ATARIVOX)
|
||||
cerr << "AtariVox: value "
|
||||
<< value
|
||||
<< " written to DATA line at "
|
||||
<< mySystem.cycles()
|
||||
<< " (-"
|
||||
<< myLastDataWriteCycle
|
||||
<< "=="
|
||||
<< (mySystem.cycles() - myLastDataWriteCycle)
|
||||
<< ")"
|
||||
<< endl;
|
||||
|
||||
if(value && (myShiftCount == 0))
|
||||
{
|
||||
if(DEBUG_ATARIVOX)
|
||||
cerr << "value && (myShiftCount == 0), returning" << endl;
|
||||
//cerr << "!!!!! INVALID START BIT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// If this is the first write this frame, or if it's been a long time
|
||||
// since the last write, start a new data byte.
|
||||
|
@ -167,25 +134,17 @@ void AtariVox::clockDataIn(bool value)
|
|||
{
|
||||
myShiftRegister = 0;
|
||||
myShiftCount = 0;
|
||||
//cerr << "!!!!! START NEW BYTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
|
||||
}
|
||||
else if(cycle > myLastDataWriteCycle + 1000)
|
||||
{
|
||||
myShiftRegister = 0;
|
||||
myShiftCount = 0;
|
||||
//cerr << "!!!!! DELAY TOO LONG !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
|
||||
}
|
||||
|
||||
//cerr << "value = " << value << " (" << (int)myShiftCount << ")" << endl;
|
||||
|
||||
// If this is the first write this frame, or if it's been 62 cycles
|
||||
// since the last write, shift this bit into the current byte.
|
||||
if(cycle < myLastDataWriteCycle || cycle >= myLastDataWriteCycle + 62)
|
||||
{
|
||||
if(DEBUG_ATARIVOX)
|
||||
cerr << "cycle >= myLastDataWriteCycle + 62, shiftIn("
|
||||
<< value << ")" << endl;
|
||||
|
||||
myShiftRegister >>= 1;
|
||||
myShiftRegister |= (value << 15);
|
||||
if(++myShiftCount == 10)
|
||||
|
@ -204,8 +163,6 @@ void AtariVox::clockDataIn(bool value)
|
|||
#else
|
||||
mySpeakJet->write(data);
|
||||
#endif
|
||||
//cerr << " ==> " << (int)data << endl;
|
||||
//cerr << "----------------------------------------------------------\n";
|
||||
}
|
||||
myShiftRegister = 0;
|
||||
}
|
||||
|
@ -214,6 +171,16 @@ void AtariVox::clockDataIn(bool value)
|
|||
myLastDataWriteCycle = cycle;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariVox::systemCyclesReset()
|
||||
{
|
||||
myLastDataWriteCycle -= mySystem.cycles();
|
||||
|
||||
// The EEPROM keeps track of cycle counts, and needs to know when the
|
||||
// cycles are reset
|
||||
myEEPROM->systemCyclesReset();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string AtariVox::about() const
|
||||
{
|
||||
|
|
|
@ -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: AtariVox.hxx,v 1.13 2008-04-20 19:52:33 stephena Exp $
|
||||
// $Id: AtariVox.hxx,v 1.14 2008-05-19 02:53:57 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef ATARIVOX_HXX
|
||||
|
@ -33,7 +33,7 @@ class MT24LC256;
|
|||
driver code.
|
||||
|
||||
@author B. Watson
|
||||
@version $Id: AtariVox.hxx,v 1.13 2008-04-20 19:52:33 stephena Exp $
|
||||
@version $Id: AtariVox.hxx,v 1.14 2008-05-19 02:53:57 stephena Exp $
|
||||
*/
|
||||
class AtariVox : public Controller
|
||||
{
|
||||
|
@ -82,6 +82,13 @@ class AtariVox : public Controller
|
|||
*/
|
||||
virtual void update() { }
|
||||
|
||||
/**
|
||||
Notification method invoked by the system right before the
|
||||
system resets its cycle counter to zero. It may be necessary
|
||||
to override this method for devices that remember cycle counts.
|
||||
*/
|
||||
virtual void systemCyclesReset();
|
||||
|
||||
virtual string about() const;
|
||||
|
||||
#ifdef SPEAKJET_EMULATION
|
||||
|
|
|
@ -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.142 2008-05-16 12:04:34 stephena Exp $
|
||||
// $Id: Console.cxx,v 1.143 2008-05-19 02:53:57 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -88,6 +88,16 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
// Construct the system and components
|
||||
mySystem = new System(13, 6);
|
||||
|
||||
// The real controllers for this console will be added later
|
||||
// For now, we just add dummy joystick controllers, since autodetection
|
||||
// runs the emulation for a while, and this may interfere with 'smart'
|
||||
// controllers such as the AVox and SaveKey
|
||||
// Note that the controllers must be added directly after the system
|
||||
// has been created, and before any other device is added
|
||||
// (particularly the M6532)
|
||||
myControllers[0] = new Joystick(Controller::Left, *myEvent, *mySystem);
|
||||
myControllers[1] = new Joystick(Controller::Right, *myEvent, *mySystem);
|
||||
|
||||
M6502* m6502;
|
||||
if(myOSystem->settings().getString("cpu") == "low")
|
||||
m6502 = new M6502Low(1);
|
||||
|
@ -111,13 +121,6 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props)
|
|||
myCart = cart;
|
||||
myRiot = m6532;
|
||||
|
||||
// The real controllers for this console will be added later
|
||||
// For now, we just add dummy joystick controllers, since autodetection
|
||||
// runs the emulation for a while, and this may interfere with 'smart'
|
||||
// controllers such as the AVox and SaveKey
|
||||
myControllers[0] = new Joystick(Controller::Left, *myEvent, *mySystem);
|
||||
myControllers[1] = new Joystick(Controller::Right, *myEvent, *mySystem);
|
||||
|
||||
// Query some info about this console
|
||||
ostringstream about, vidinfo;
|
||||
|
||||
|
|
|
@ -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.16 2008-05-15 15:07:29 stephena Exp $
|
||||
// $Id: Control.hxx,v 1.17 2008-05-19 02:53:57 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.16 2008-05-15 15:07:29 stephena Exp $
|
||||
@version $Id: Control.hxx,v 1.17 2008-05-19 02:53:57 stephena Exp $
|
||||
*/
|
||||
class Controller : public Serializable
|
||||
{
|
||||
|
@ -157,6 +157,13 @@ class Controller : public Serializable
|
|||
*/
|
||||
virtual void update() = 0;
|
||||
|
||||
/**
|
||||
Notification method invoked by the system right before the
|
||||
system resets its cycle counter to zero. It may be necessary
|
||||
to override this method for devices that remember cycle counts.
|
||||
*/
|
||||
virtual void systemCyclesReset() { };
|
||||
|
||||
/**
|
||||
Saves the current state of this controller to the given Serializer.
|
||||
|
||||
|
|
|
@ -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: M6532.cxx,v 1.25 2008-05-16 23:56:30 stephena Exp $
|
||||
// $Id: M6532.cxx,v 1.26 2008-05-19 02:53:57 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -73,6 +73,10 @@ void M6532::systemCyclesReset()
|
|||
// System cycles are being reset to zero so we need to adjust
|
||||
// the cycle count we remembered when the timer was last set
|
||||
myCyclesWhenTimerSet -= mySystem->cycles();
|
||||
|
||||
// We should also inform any 'smart' controllers as well
|
||||
myConsole.controller(Controller::Left).systemCyclesReset();
|
||||
myConsole.controller(Controller::Right).systemCyclesReset();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: MT24LC256.cxx,v 1.12 2008-05-17 15:16:45 stephena Exp $
|
||||
// $Id: MT24LC256.cxx,v 1.13 2008-05-19 02:53:57 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -140,13 +140,24 @@ void MT24LC256::update()
|
|||
{
|
||||
#if DEBUG_EEPROM
|
||||
cerr << endl << " I2C_PIN_WRITE(SCL = " << mySCL
|
||||
<< ", SDA = " << mySDA << ")" << endl;
|
||||
<< ", SDA = " << mySDA << ")" << " @ " << mySystem.cycles() << endl;
|
||||
#endif
|
||||
jpee_clock(mySCL);
|
||||
jpee_data(mySDA);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void MT24LC256::systemCyclesReset()
|
||||
{
|
||||
// System cycles are being reset to zero so we need to adjust
|
||||
// the cycle counts we remembered
|
||||
uInt32 cycles = mySystem.cycles();
|
||||
myCyclesWhenSDASet -= cycles;
|
||||
myCyclesWhenSCLSet -= cycles;
|
||||
myCyclesWhenTimerSet -= cycles;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void MT24LC256::jpee_init()
|
||||
{
|
||||
|
|
|
@ -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: MT24LC256.hxx,v 1.5 2008-05-11 21:18:35 stephena Exp $
|
||||
// $Id: MT24LC256.hxx,v 1.6 2008-05-19 02:53:57 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef MT24LC256_HXX
|
||||
|
@ -30,7 +30,7 @@ class System;
|
|||
(aka Supercat) for the bulk of this code.
|
||||
|
||||
@author Stephen Anthony & J. Payson
|
||||
@version $Id: MT24LC256.hxx,v 1.5 2008-05-11 21:18:35 stephena Exp $
|
||||
@version $Id: MT24LC256.hxx,v 1.6 2008-05-19 02:53:57 stephena Exp $
|
||||
*/
|
||||
class MT24LC256
|
||||
{
|
||||
|
@ -56,6 +56,13 @@ class MT24LC256
|
|||
void writeSDA(bool state);
|
||||
void writeSCL(bool state);
|
||||
|
||||
/**
|
||||
Notification method invoked by the system right before the
|
||||
system resets its cycle counter to zero. It may be necessary
|
||||
to override this method for devices that remember cycle counts.
|
||||
*/
|
||||
void systemCyclesReset();
|
||||
|
||||
private:
|
||||
// I2C access code provided by Supercat
|
||||
void jpee_init();
|
||||
|
|
|
@ -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: SaveKey.cxx,v 1.2 2008-05-06 16:39:12 stephena Exp $
|
||||
// $Id: SaveKey.cxx,v 1.3 2008-05-19 02:53:57 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include "MT24LC256.hxx"
|
||||
|
@ -80,3 +80,11 @@ void SaveKey::write(DigitalPin pin, bool value)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SaveKey::systemCyclesReset()
|
||||
{
|
||||
// The EEPROM keeps track of cycle counts, and needs to know when the
|
||||
// cycles are reset
|
||||
myEEPROM->systemCyclesReset();
|
||||
}
|
||||
|
|
|
@ -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: SaveKey.hxx,v 1.1 2008-04-29 15:49:34 stephena Exp $
|
||||
// $Id: SaveKey.hxx,v 1.2 2008-05-19 02:53:58 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SAVEKEY_HXX
|
||||
|
@ -31,7 +31,7 @@ class MT24LC256;
|
|||
driver code.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: SaveKey.hxx,v 1.1 2008-04-29 15:49:34 stephena Exp $
|
||||
@version $Id: SaveKey.hxx,v 1.2 2008-05-19 02:53:58 stephena Exp $
|
||||
*/
|
||||
class SaveKey : public Controller
|
||||
{
|
||||
|
@ -77,6 +77,13 @@ class SaveKey : public Controller
|
|||
*/
|
||||
virtual void update() { }
|
||||
|
||||
/**
|
||||
Notification method invoked by the system right before the
|
||||
system resets its cycle counter to zero. It may be necessary
|
||||
to override this method for devices that remember cycle counts.
|
||||
*/
|
||||
virtual void systemCyclesReset();
|
||||
|
||||
private:
|
||||
// The EEPROM used in the SaveKey
|
||||
MT24LC256* myEEPROM;
|
||||
|
|
Loading…
Reference in New Issue