2008-04-13 15:05:59 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2008-04-13 15:05:59 +00:00
|
|
|
// 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
|
|
|
|
//
|
2019-12-31 17:18:56 +00:00
|
|
|
// Copyright (c) 1995-2020 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2008-04-13 15:05:59 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2008-04-13 15:05:59 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
2008-04-13 23:43:14 +00:00
|
|
|
#include <cstdio>
|
2008-04-13 15:05:59 +00:00
|
|
|
|
|
|
|
#include "System.hxx"
|
|
|
|
#include "MT24LC256.hxx"
|
|
|
|
|
2019-03-03 18:48:58 +00:00
|
|
|
//#define DEBUG_EEPROM
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
|
2019-03-03 18:48:58 +00:00
|
|
|
#ifdef DEBUG_EEPROM
|
|
|
|
static char jpee_msg[256];
|
2019-03-09 21:31:38 +00:00
|
|
|
#define JPEE_LOG0(msg) jpee_logproc(msg);
|
|
|
|
#define JPEE_LOG1(msg,arg1) sprintf(jpee_msg,(msg),(arg1)), jpee_logproc(jpee_msg);
|
|
|
|
#define JPEE_LOG2(msg,arg1,arg2) sprintf(jpee_msg,(msg),(arg1),(arg2)), jpee_logproc(jpee_msg);
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
#else
|
2019-03-03 18:48:58 +00:00
|
|
|
#define JPEE_LOG0(msg)
|
|
|
|
#define JPEE_LOG1(msg,arg1)
|
|
|
|
#define JPEE_LOG2(msg,arg1,arg2)
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
#endif
|
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
/*
|
|
|
|
State values for I2C:
|
|
|
|
0 - Idle
|
|
|
|
1 - Byte going to chip (shift left until bit 8 is set)
|
|
|
|
2 - Chip outputting acknowledgement
|
|
|
|
3 - Byte coming in from chip (shift left until lower 8 bits are clear)
|
|
|
|
4 - Chip waiting for acknowledgement
|
|
|
|
*/
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2019-03-04 01:33:44 +00:00
|
|
|
MT24LC256::MT24LC256(const string& filename, const System& system,
|
2019-12-25 01:41:36 +00:00
|
|
|
const Controller::onMessageCallback& callback)
|
2008-04-13 23:43:14 +00:00
|
|
|
: mySystem(system),
|
2019-03-04 01:33:44 +00:00
|
|
|
myCallback(callback),
|
2019-12-29 22:06:56 +00:00
|
|
|
myDataFile(filename)
|
2008-04-13 15:05:59 +00:00
|
|
|
{
|
2008-05-15 19:05:09 +00:00
|
|
|
// Load the data from an external file (if it exists)
|
2016-05-24 16:55:45 +00:00
|
|
|
ifstream in(myDataFile, std::ios_base::binary);
|
2008-04-13 15:05:59 +00:00
|
|
|
if(in.is_open())
|
|
|
|
{
|
|
|
|
// Get length of file; it must be 32768
|
2016-05-24 16:55:45 +00:00
|
|
|
in.seekg(0, std::ios::end);
|
2017-09-29 18:12:41 +00:00
|
|
|
if(uInt32(in.tellg()) == FLASH_SIZE)
|
2008-04-13 15:05:59 +00:00
|
|
|
{
|
2016-05-24 16:55:45 +00:00
|
|
|
in.seekg(0, std::ios::beg);
|
2019-09-16 22:16:15 +00:00
|
|
|
in.read(reinterpret_cast<char*>(myData.data()), myData.size());
|
2008-05-11 21:18:35 +00:00
|
|
|
myDataFileExists = true;
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-11 21:18:35 +00:00
|
|
|
else
|
|
|
|
myDataFileExists = false;
|
2008-05-15 19:05:09 +00:00
|
|
|
|
|
|
|
// Then initialize the I2C state
|
|
|
|
jpee_init();
|
2018-08-27 13:39:03 +00:00
|
|
|
|
|
|
|
systemReset();
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
2015-12-04 19:08:14 +00:00
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
MT24LC256::~MT24LC256()
|
|
|
|
{
|
2008-05-11 21:18:35 +00:00
|
|
|
// Save EEPROM data to external file only when necessary
|
|
|
|
if(!myDataFileExists || myDataChanged)
|
2008-04-13 15:05:59 +00:00
|
|
|
{
|
2016-05-24 16:55:45 +00:00
|
|
|
ofstream out(myDataFile, std::ios_base::binary);
|
2008-05-11 21:18:35 +00:00
|
|
|
if(out.is_open())
|
2019-09-16 22:16:15 +00:00
|
|
|
out.write(reinterpret_cast<char*>(myData.data()), myData.size());
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::writeSDA(bool state)
|
|
|
|
{
|
2008-05-06 16:39:12 +00:00
|
|
|
mySDA = state;
|
|
|
|
myCyclesWhenSDASet = mySystem.cycles();
|
2008-04-13 15:05:59 +00:00
|
|
|
|
2008-05-06 16:39:12 +00:00
|
|
|
update();
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::writeSCL(bool state)
|
|
|
|
{
|
2008-05-06 16:39:12 +00:00
|
|
|
mySCL = state;
|
|
|
|
myCyclesWhenSCLSet = mySystem.cycles();
|
2008-04-13 15:05:59 +00:00
|
|
|
|
2008-05-06 16:39:12 +00:00
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::update()
|
|
|
|
{
|
2008-04-13 23:43:14 +00:00
|
|
|
#define jpee_clock(x) ( (x) ? \
|
|
|
|
(jpee_mclk = 1) : \
|
2008-04-13 15:05:59 +00:00
|
|
|
(jpee_mclk && (jpee_clock_fall(),1), jpee_mclk = 0))
|
|
|
|
|
2008-05-06 16:39:12 +00:00
|
|
|
#define jpee_data(x) ( (x) ? \
|
|
|
|
(!jpee_mdat && jpee_sdat && jpee_mclk && (jpee_data_stop(),1), jpee_mdat = 1) : \
|
|
|
|
(jpee_mdat && jpee_sdat && jpee_mclk && (jpee_data_start(),1), jpee_mdat = 0))
|
|
|
|
|
|
|
|
// These pins have to be updated at the same time
|
2011-12-29 19:10:57 +00:00
|
|
|
// However, there's no guarantee that the writeSDA() and writeSCL()
|
2008-05-06 16:39:12 +00:00
|
|
|
// methods will be called at the same time or in the correct order, so
|
|
|
|
// we only do the write when they have the same 'timestamp'
|
|
|
|
if(myCyclesWhenSDASet == myCyclesWhenSCLSet)
|
|
|
|
{
|
2019-03-03 18:48:58 +00:00
|
|
|
#ifdef DEBUG_EEPROM
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
cerr << endl << " I2C_PIN_WRITE(SCL = " << mySCL
|
2008-05-19 02:53:58 +00:00
|
|
|
<< ", SDA = " << mySDA << ")" << " @ " << mySystem.cycles() << endl;
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
#endif
|
2008-05-06 16:39:12 +00:00
|
|
|
jpee_clock(mySCL);
|
|
|
|
jpee_data(mySDA);
|
|
|
|
}
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
|
2008-05-19 02:53:58 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2017-09-08 13:59:30 +00:00
|
|
|
void MT24LC256::systemReset()
|
2014-06-29 23:25:53 +00:00
|
|
|
{
|
2019-09-16 22:16:15 +00:00
|
|
|
myPageHit.fill(false);
|
2014-06-29 23:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2017-09-29 18:12:41 +00:00
|
|
|
void MT24LC256::eraseAll()
|
2008-05-19 02:53:58 +00:00
|
|
|
{
|
2019-12-08 20:02:29 +00:00
|
|
|
// Work around a bug in XCode 11.2 with -O0 and -O1
|
2019-12-08 19:52:22 +00:00
|
|
|
const uInt8 initialValue = INITIAL_VALUE;
|
|
|
|
|
|
|
|
myData.fill(initialValue);
|
2017-09-08 13:59:30 +00:00
|
|
|
myDataChanged = true;
|
2008-05-19 02:53:58 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 18:12:41 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::eraseCurrent()
|
|
|
|
{
|
2019-12-08 20:02:29 +00:00
|
|
|
// Work around a bug in XCode 11.2 with -O0 and -O1
|
2019-12-08 19:52:22 +00:00
|
|
|
const uInt8 initialValue = INITIAL_VALUE;
|
|
|
|
|
2018-08-28 18:49:50 +00:00
|
|
|
for(uInt32 page = 0; page < PAGE_NUM; ++page)
|
2017-09-29 18:12:41 +00:00
|
|
|
{
|
2017-10-01 18:53:53 +00:00
|
|
|
if(myPageHit[page])
|
2017-09-29 18:12:41 +00:00
|
|
|
{
|
2019-12-08 19:52:22 +00:00
|
|
|
std::fill_n(myData.begin() + page * PAGE_SIZE, PAGE_SIZE, initialValue);
|
2017-09-29 18:12:41 +00:00
|
|
|
myDataChanged = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-01 07:52:39 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2017-10-01 18:53:53 +00:00
|
|
|
bool MT24LC256::isPageUsed(uInt32 page) const
|
2017-10-01 07:52:39 +00:00
|
|
|
{
|
|
|
|
if(page < PAGE_NUM)
|
|
|
|
return myPageHit[page];
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::jpee_init()
|
|
|
|
{
|
2019-12-08 20:02:29 +00:00
|
|
|
// Work around a bug in XCode 11.2 with -O0 and -O1
|
2019-12-08 19:52:22 +00:00
|
|
|
const uInt8 initialValue = INITIAL_VALUE;
|
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_sdat = 1;
|
|
|
|
jpee_address = 0;
|
|
|
|
jpee_state=0;
|
2017-09-29 18:12:41 +00:00
|
|
|
jpee_sizemask = FLASH_SIZE - 1;
|
|
|
|
jpee_pagemask = PAGE_SIZE - 1;
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_smallmode = 0;
|
|
|
|
jpee_logmode = -1;
|
2008-05-15 19:05:09 +00:00
|
|
|
if(!myDataFileExists)
|
2019-12-08 19:52:22 +00:00
|
|
|
myData.fill(initialValue);
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::jpee_data_start()
|
|
|
|
{
|
|
|
|
/* We have a start condition */
|
|
|
|
if (jpee_state == 1 && (jpee_nb != 1 || jpee_pptr != 3))
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG0("I2C_WARNING ABANDON WRITE")
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_ad_known = 0;
|
|
|
|
}
|
|
|
|
if (jpee_state == 3)
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG0("I2C_WARNING ABANDON READ")
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
if (!jpee_timercheck(0))
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG0("I2C_START")
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG0("I2C_BUSY")
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state = 0;
|
|
|
|
}
|
|
|
|
jpee_pptr = 0;
|
|
|
|
jpee_nb = 0;
|
|
|
|
jpee_packet[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::jpee_data_stop()
|
|
|
|
{
|
|
|
|
if (jpee_state == 1 && jpee_nb != 1)
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG0("I2C_WARNING ABANDON_WRITE")
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_ad_known = 0;
|
|
|
|
}
|
|
|
|
if (jpee_state == 3)
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG0("I2C_WARNING ABANDON_READ")
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_ad_known = 0;
|
|
|
|
}
|
|
|
|
/* We have a stop condition. */
|
|
|
|
if (jpee_state == 1 && jpee_nb == 1 && jpee_pptr > 3)
|
|
|
|
{
|
|
|
|
jpee_timercheck(1);
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG2("I2C_STOP(Write %d bytes at %04X)",jpee_pptr-3,jpee_address)
|
2008-04-13 15:05:59 +00:00
|
|
|
if (((jpee_address + jpee_pptr-4) ^ jpee_address) & ~jpee_pagemask)
|
|
|
|
{
|
|
|
|
jpee_pptr = 4+jpee_pagemask-(jpee_address & jpee_pagemask);
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG1("I2C_WARNING PAGECROSSING!(Truncate to %d bytes)",jpee_pptr-3)
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
2014-10-27 14:41:46 +00:00
|
|
|
for (int i=3; i<jpee_pptr; i++)
|
2008-04-13 15:05:59 +00:00
|
|
|
{
|
2008-05-11 21:18:35 +00:00
|
|
|
myDataChanged = true;
|
2017-10-01 10:00:07 +00:00
|
|
|
myPageHit[jpee_address / PAGE_SIZE] = true;
|
2019-03-04 01:33:44 +00:00
|
|
|
|
|
|
|
myCallback("AtariVox/SaveKey EEPROM write");
|
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
myData[(jpee_address++) & jpee_sizemask] = jpee_packet[i];
|
|
|
|
if (!(jpee_address & jpee_pagemask))
|
|
|
|
break; /* Writes can't cross page boundary! */
|
|
|
|
}
|
|
|
|
jpee_ad_known = 0;
|
|
|
|
}
|
2019-03-09 21:31:38 +00:00
|
|
|
#ifdef DEBUG_EEPROM
|
2008-04-13 15:05:59 +00:00
|
|
|
else
|
2019-03-09 21:31:38 +00:00
|
|
|
jpee_logproc("I2C_STOP");
|
|
|
|
#endif
|
2008-04-13 23:43:14 +00:00
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::jpee_clock_fall()
|
|
|
|
{
|
|
|
|
switch(jpee_state)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
jpee_nb <<= 1;
|
|
|
|
jpee_nb |= jpee_mdat;
|
|
|
|
if (jpee_nb & 256)
|
|
|
|
{
|
|
|
|
if (!jpee_pptr)
|
|
|
|
{
|
2015-09-14 21:33:50 +00:00
|
|
|
jpee_packet[0] = uInt8(jpee_nb);
|
2008-04-13 15:05:59 +00:00
|
|
|
if (jpee_smallmode && ((jpee_nb & 0xF0) == 0xA0))
|
|
|
|
{
|
|
|
|
jpee_packet[1] = (jpee_nb >> 1) & 7;
|
2019-03-09 21:31:38 +00:00
|
|
|
#ifdef DEBUG_EEPROM
|
2008-04-13 23:43:14 +00:00
|
|
|
if (jpee_packet[1] != (jpee_address >> 8) && (jpee_packet[0] & 1))
|
2019-03-09 21:31:38 +00:00
|
|
|
jpee_logproc("I2C_WARNING ADDRESS MSB CHANGED");
|
|
|
|
#endif
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_nb &= 0x1A1;
|
|
|
|
}
|
|
|
|
if (jpee_nb == 0x1A0)
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG1("I2C_SENT(%02X--start write)",jpee_packet[0])
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state = 2;
|
|
|
|
jpee_sdat = 0;
|
|
|
|
}
|
|
|
|
else if (jpee_nb == 0x1A1)
|
|
|
|
{
|
|
|
|
jpee_state = 4;
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG2("I2C_SENT(%02X--start read @%04X)", jpee_packet[0],jpee_address)
|
|
|
|
#ifdef DEBUG_EEPROM
|
2008-04-13 23:43:14 +00:00
|
|
|
if (!jpee_ad_known)
|
2019-03-09 21:31:38 +00:00
|
|
|
jpee_logproc("I2C_WARNING ADDRESS IS UNKNOWN");
|
|
|
|
#endif
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_sdat = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG1("I2C_WARNING ODDBALL FIRST BYTE!(%02X)",jpee_nb & 0xFF)
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
jpee_state = 2;
|
|
|
|
jpee_sdat = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if (jpee_nb)
|
|
|
|
{
|
|
|
|
if (!jpee_pptr)
|
|
|
|
{
|
2015-09-14 21:33:50 +00:00
|
|
|
jpee_packet[0] = uInt8(jpee_nb);
|
2008-04-13 15:05:59 +00:00
|
|
|
if (jpee_smallmode)
|
|
|
|
jpee_pptr=2;
|
|
|
|
else
|
|
|
|
jpee_pptr=1;
|
|
|
|
}
|
|
|
|
else if (jpee_pptr < 70)
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG1("I2C_SENT(%02X)",jpee_nb & 0xFF)
|
2015-09-14 21:33:50 +00:00
|
|
|
jpee_packet[jpee_pptr++] = uInt8(jpee_nb);
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_address = (jpee_packet[1] << 8) | jpee_packet[2];
|
|
|
|
if (jpee_pptr > 2)
|
|
|
|
jpee_ad_known = 1;
|
|
|
|
}
|
2019-03-09 21:31:38 +00:00
|
|
|
#ifdef DEBUG_EEPROM
|
2008-04-13 23:43:14 +00:00
|
|
|
else
|
2019-03-09 21:31:38 +00:00
|
|
|
jpee_logproc("I2C_WARNING OUTPUT_OVERFLOW!");
|
|
|
|
#endif
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
jpee_sdat = 1;
|
|
|
|
jpee_nb = 1;
|
|
|
|
jpee_state=1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
if (jpee_mdat && jpee_sdat)
|
|
|
|
{
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG0("I2C_READ_NAK")
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
jpee_state=3;
|
2017-10-01 10:00:07 +00:00
|
|
|
myPageHit[jpee_address / PAGE_SIZE] = true;
|
2018-01-17 09:27:18 +00:00
|
|
|
|
2019-03-04 01:33:44 +00:00
|
|
|
myCallback("AtariVox/SaveKey EEPROM read");
|
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_nb = (myData[jpee_address & jpee_sizemask] << 1) | 1; /* Fall through */
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG2("I2C_READ(%04X=%02X)",jpee_address,jpee_nb/2)
|
2017-05-27 16:40:05 +00:00
|
|
|
[[fallthrough]];
|
2008-04-13 15:05:59 +00:00
|
|
|
|
|
|
|
case 3:
|
|
|
|
jpee_sdat = !!(jpee_nb & 256);
|
|
|
|
jpee_nb <<= 1;
|
|
|
|
if (!(jpee_nb & 510))
|
|
|
|
{
|
|
|
|
jpee_state = 4;
|
|
|
|
jpee_sdat = 1;
|
2018-08-28 18:49:50 +00:00
|
|
|
++jpee_address;
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Do nothing */
|
|
|
|
break;
|
|
|
|
}
|
2019-03-09 21:31:38 +00:00
|
|
|
JPEE_LOG2("I2C_CLOCK (dat=%d/%d)",jpee_mdat,jpee_sdat)
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2008-04-13 23:43:14 +00:00
|
|
|
bool MT24LC256::jpee_timercheck(int mode)
|
2008-04-13 15:05:59 +00:00
|
|
|
{
|
|
|
|
/*
|
2008-04-13 23:43:14 +00:00
|
|
|
Evaluate how long the EEPROM is busy. When invoked with an argument of 1,
|
|
|
|
start a timer (probably about 5 milliseconds); when invoked with an
|
|
|
|
argument of 0, return zero if the timer has expired or non-zero if it is
|
|
|
|
still running.
|
2008-04-13 15:05:59 +00:00
|
|
|
*/
|
2008-04-13 23:43:14 +00:00
|
|
|
if(mode) // set timer
|
|
|
|
{
|
|
|
|
myCyclesWhenTimerSet = mySystem.cycles();
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
return myTimerActive = true;
|
2008-04-13 23:43:14 +00:00
|
|
|
}
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
else // read timer
|
2008-04-13 23:43:14 +00:00
|
|
|
{
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
if(myTimerActive)
|
|
|
|
{
|
2018-05-20 00:31:00 +00:00
|
|
|
uInt64 elapsed = mySystem.cycles() - myCyclesWhenTimerSet;
|
|
|
|
myTimerActive = elapsed < uInt64(5000000.0 / 838.0);
|
Success at last!!! I finally have the AVox and SaveKey EEPROM emulation
working. After about a week of banging my head against the wall, I
happened to try another test ROM, and everything worked. So it seems
that the SaveKey test ROM from Thomas J. (with the optimized I2C
macros) isn't working correctly, or I miscompiled it or something.
All other ROMs I've tested work fine, including MGD, Fall Down,
Stratogems Deluxe, Go Fish, etc. Thomas, if you're reading this, could
we try to figure out what's going on here??
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1500 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-05-10 22:21:09 +00:00
|
|
|
}
|
|
|
|
return myTimerActive;
|
2008-04-13 23:43:14 +00:00
|
|
|
}
|
|
|
|
}
|