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
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// Copyright (c) 1995-2017 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 <fstream>
|
|
|
|
|
|
|
|
#include "System.hxx"
|
|
|
|
#include "MT24LC256.hxx"
|
|
|
|
|
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
|
|
|
#define DEBUG_EEPROM 0
|
|
|
|
|
|
|
|
#if DEBUG_EEPROM
|
|
|
|
char jpee_msg[256];
|
|
|
|
#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)
|
|
|
|
#else
|
2012-10-24 10:10:32 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2008-04-13 23:43:14 +00:00
|
|
|
MT24LC256::MT24LC256(const string& filename, const System& system)
|
|
|
|
: mySystem(system),
|
2008-05-06 16:39:12 +00:00
|
|
|
mySDA(false),
|
|
|
|
mySCL(false),
|
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
|
|
|
myTimerActive(false),
|
2008-04-13 23:43:14 +00:00
|
|
|
myCyclesWhenTimerSet(0),
|
2008-05-06 16:39:12 +00:00
|
|
|
myCyclesWhenSDASet(0),
|
|
|
|
myCyclesWhenSCLSet(0),
|
2008-05-11 21:18:35 +00:00
|
|
|
myDataFile(filename),
|
|
|
|
myDataFileExists(false),
|
2014-10-27 14:41:46 +00:00
|
|
|
myDataChanged(false),
|
|
|
|
jpee_mdat(0),
|
|
|
|
jpee_sdat(0),
|
|
|
|
jpee_mclk(0),
|
|
|
|
jpee_sizemask(0),
|
|
|
|
jpee_pagemask(0),
|
|
|
|
jpee_smallmode(0),
|
|
|
|
jpee_logmode(0),
|
|
|
|
jpee_pptr(0),
|
|
|
|
jpee_state(0),
|
|
|
|
jpee_nb(0),
|
|
|
|
jpee_address(0),
|
|
|
|
jpee_ad_known(0)
|
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);
|
2015-09-14 22:18:55 +00:00
|
|
|
if(uInt32(in.tellg()) == 32768u)
|
2008-04-13 15:05:59 +00:00
|
|
|
{
|
2016-05-24 16:55:45 +00:00
|
|
|
in.seekg(0, std::ios::beg);
|
2015-09-14 21:33:50 +00:00
|
|
|
in.read(reinterpret_cast<char*>(myData), 32768);
|
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();
|
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())
|
2015-09-14 21:33:50 +00:00
|
|
|
out.write(reinterpret_cast<char*>(myData), 32768);
|
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)
|
|
|
|
{
|
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 DEBUG_EEPROM
|
|
|
|
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
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-29 23:25:53 +00:00
|
|
|
void MT24LC256::erase()
|
|
|
|
{
|
|
|
|
memset(myData, 0xff, 32768);
|
|
|
|
myDataChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2008-05-19 02:53:58 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-04-13 15:05:59 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void MT24LC256::jpee_init()
|
|
|
|
{
|
|
|
|
jpee_sdat = 1;
|
|
|
|
jpee_address = 0;
|
|
|
|
jpee_state=0;
|
|
|
|
jpee_sizemask = 32767;
|
|
|
|
jpee_pagemask = 63;
|
|
|
|
jpee_smallmode = 0;
|
|
|
|
jpee_logmode = -1;
|
2008-05-15 19:05:09 +00:00
|
|
|
if(!myDataFileExists)
|
2008-05-17 15:16:45 +00:00
|
|
|
memset(myData, 0xff, 32768);
|
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))
|
|
|
|
{
|
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
|
|
|
JPEE_LOG0("I2C_WARNING ABANDON WRITE");
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_ad_known = 0;
|
|
|
|
}
|
|
|
|
if (jpee_state == 3)
|
|
|
|
{
|
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
|
|
|
JPEE_LOG0("I2C_WARNING ABANDON READ");
|
2008-04-13 15:05:59 +00:00
|
|
|
}
|
|
|
|
if (!jpee_timercheck(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
|
|
|
JPEE_LOG0("I2C_START");
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
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)
|
|
|
|
{
|
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
|
|
|
JPEE_LOG0("I2C_WARNING ABANDON_WRITE");
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_ad_known = 0;
|
|
|
|
}
|
|
|
|
if (jpee_state == 3)
|
|
|
|
{
|
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
|
|
|
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);
|
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
|
|
|
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);
|
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
|
|
|
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;
|
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;
|
|
|
|
}
|
|
|
|
else
|
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
|
|
|
JPEE_LOG0("I2C_STOP");
|
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;
|
2008-04-13 23:43:14 +00:00
|
|
|
if (jpee_packet[1] != (jpee_address >> 8) && (jpee_packet[0] & 1))
|
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
|
|
|
JPEE_LOG0("I2C_WARNING ADDRESS MSB CHANGED");
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_nb &= 0x1A1;
|
|
|
|
}
|
|
|
|
if (jpee_nb == 0x1A0)
|
|
|
|
{
|
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
|
|
|
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;
|
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
|
|
|
JPEE_LOG2("I2C_SENT(%02X--start read @%04X)",
|
2008-04-13 23:43:14 +00:00
|
|
|
jpee_packet[0],jpee_address);
|
|
|
|
if (!jpee_ad_known)
|
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
|
|
|
JPEE_LOG0("I2C_WARNING ADDRESS IS UNKNOWN");
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_sdat = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
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)
|
|
|
|
{
|
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
|
|
|
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;
|
|
|
|
}
|
2008-04-13 23:43:14 +00:00
|
|
|
else
|
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
|
|
|
JPEE_LOG0("I2C_WARNING OUTPUT_OVERFLOW!");
|
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)
|
|
|
|
{
|
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
|
|
|
JPEE_LOG0("I2C_READ_NAK");
|
2008-04-13 15:05:59 +00:00
|
|
|
jpee_state=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
jpee_state=3;
|
|
|
|
jpee_nb = (myData[jpee_address & jpee_sizemask] << 1) | 1; /* Fall through */
|
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
|
|
|
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;
|
|
|
|
jpee_address++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Do nothing */
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
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)
|
|
|
|
{
|
|
|
|
uInt32 elapsed = mySystem.cycles() - myCyclesWhenTimerSet;
|
2015-09-14 21:33:50 +00:00
|
|
|
myTimerActive = elapsed < uInt32(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
|
|
|
}
|
|
|
|
}
|
2008-04-13 15:05:59 +00:00
|
|
|
|
2008-04-13 23:43:14 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int MT24LC256::jpee_logproc(char const *st)
|
|
|
|
{
|
2008-05-06 16:39:12 +00:00
|
|
|
cerr << " " << st << endl;
|
2008-04-13 15:05:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|