2009-04-05 20:18:41 +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
|
|
|
|
//
|
|
|
|
// Copyright (c) 1995-2009 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.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2009-04-05 20:18:41 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
#include "System.hxx"
|
|
|
|
#include "CartEFSC.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
CartridgeEFSC::CartridgeEFSC(const uInt8* image)
|
|
|
|
{
|
|
|
|
// Copy the ROM image into my buffer
|
|
|
|
memcpy(myImage, image, 65536);
|
2009-06-03 14:49:42 +00:00
|
|
|
|
|
|
|
// This cart contains 128 bytes extended RAM @ 0x1000
|
|
|
|
registerRamArea(0x1000, 128, 0x80, 0x00);
|
2009-04-05 20:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
CartridgeEFSC::~CartridgeEFSC()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeEFSC::reset()
|
|
|
|
{
|
|
|
|
// Initialize RAM with random values
|
|
|
|
for(uInt32 i = 0; i < 128; ++i)
|
2009-11-08 01:39:05 +00:00
|
|
|
myRAM[i] = mySystem->randGenerator().next();
|
2009-04-05 20:18:41 +00:00
|
|
|
|
|
|
|
// Upon reset we switch to bank 1
|
|
|
|
bank(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeEFSC::install(System& system)
|
|
|
|
{
|
|
|
|
mySystem = &system;
|
|
|
|
uInt16 shift = mySystem->pageShift();
|
|
|
|
uInt16 mask = mySystem->pageMask();
|
|
|
|
|
|
|
|
// Make sure the system we're being installed in has a page size that'll work
|
|
|
|
assert((0x1000 & mask) == 0);
|
|
|
|
|
|
|
|
// Set the page accessing methods for the hot spots
|
|
|
|
System::PageAccess access;
|
|
|
|
for(uInt32 i = (0x1FE0 & ~mask); i < 0x2000; i += (1 << shift))
|
|
|
|
{
|
|
|
|
access.directPeekBase = 0;
|
|
|
|
access.directPokeBase = 0;
|
|
|
|
access.device = this;
|
|
|
|
mySystem->setPageAccess(i >> shift, access);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the page accessing method for the RAM writing pages
|
|
|
|
for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift))
|
|
|
|
{
|
|
|
|
access.device = this;
|
|
|
|
access.directPeekBase = 0;
|
|
|
|
access.directPokeBase = &myRAM[j & 0x007F];
|
|
|
|
mySystem->setPageAccess(j >> shift, access);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the page accessing method for the RAM reading pages
|
|
|
|
for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift))
|
|
|
|
{
|
|
|
|
access.device = this;
|
|
|
|
access.directPeekBase = &myRAM[k & 0x007F];
|
|
|
|
access.directPokeBase = 0;
|
|
|
|
mySystem->setPageAccess(k >> shift, access);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Install pages for bank 1
|
|
|
|
bank(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8 CartridgeEFSC::peek(uInt16 address)
|
|
|
|
{
|
2009-05-01 11:25:07 +00:00
|
|
|
address &= 0x0FFF;
|
2009-04-05 20:18:41 +00:00
|
|
|
|
|
|
|
// Switch banks if necessary
|
|
|
|
if((address >= 0x0FE0) && (address <= 0x0FEF))
|
|
|
|
bank(address - 0x0FE0);
|
|
|
|
|
2009-05-25 17:51:52 +00:00
|
|
|
if(address < 0x0080) // Write port is at 0xF000 - 0xF080 (128 bytes)
|
|
|
|
{
|
2009-11-08 01:39:05 +00:00
|
|
|
// Reading from the write port triggers an unwanted write
|
|
|
|
uInt8 value = mySystem->getDataBusState(0xFF);
|
|
|
|
|
2009-11-11 20:53:57 +00:00
|
|
|
if(myBankLocked) return value;
|
|
|
|
else return myRAM[address] = value;
|
2009-05-25 17:51:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return myImage[(myCurrentBank << 12) + address];
|
2009-04-05 20:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeEFSC::poke(uInt16 address, uInt8)
|
|
|
|
{
|
2009-05-01 11:25:07 +00:00
|
|
|
address &= 0x0FFF;
|
2009-04-05 20:18:41 +00:00
|
|
|
|
|
|
|
// Switch banks if necessary
|
|
|
|
if((address >= 0x0FE0) && (address <= 0x0FEF))
|
|
|
|
bank(address - 0x0FE0);
|
|
|
|
|
|
|
|
// NOTE: This does not handle accessing RAM, however, this function
|
|
|
|
// should never be called for RAM because of the way page accessing
|
|
|
|
// has been setup
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeEFSC::bank(uInt16 bank)
|
|
|
|
{
|
|
|
|
if(myBankLocked) return;
|
|
|
|
|
|
|
|
// Remember what bank we're in
|
|
|
|
myCurrentBank = bank;
|
2009-05-25 17:51:52 +00:00
|
|
|
uInt16 offset = myCurrentBank << 12;
|
2009-04-05 20:18:41 +00:00
|
|
|
uInt16 shift = mySystem->pageShift();
|
|
|
|
uInt16 mask = mySystem->pageMask();
|
|
|
|
|
|
|
|
// Setup the page access methods for the current bank
|
|
|
|
System::PageAccess access;
|
|
|
|
access.device = this;
|
|
|
|
access.directPokeBase = 0;
|
|
|
|
|
|
|
|
// Map ROM image into the system
|
|
|
|
for(uInt32 address = 0x1100; address < (0x1FE0U & ~mask);
|
|
|
|
address += (1 << shift))
|
|
|
|
{
|
|
|
|
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
|
|
|
|
mySystem->setPageAccess(address >> shift, access);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int CartridgeEFSC::bank()
|
|
|
|
{
|
|
|
|
return myCurrentBank;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int CartridgeEFSC::bankCount()
|
|
|
|
{
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeEFSC::patch(uInt16 address, uInt8 value)
|
|
|
|
{
|
2009-05-25 17:51:52 +00:00
|
|
|
myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value;
|
2009-04-05 20:18:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8* CartridgeEFSC::getImage(int& size)
|
|
|
|
{
|
|
|
|
size = 65536;
|
|
|
|
return &myImage[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeEFSC::save(Serializer& out) const
|
|
|
|
{
|
OK, this looks like a huge update, but it's only because of some Serializer
class reworking. Serializer class now handles read/write of state from
files as well as in-memory streams. As a result, Deserializer class has
been removed.
Added state rewinding to the debugger. For now, this is limited to 100
levels of undo, with a new state generated each time a step/trace/frame/
scanline advance is performed. The undo level is 'rolling', in that it
remembers the last 100 levels (so you lose the oldest states when you
start adding more than 100). For now, this is tied to the 'Alt-r' key
in the debugger. Still TODO is add a button for it, and clean up some
TIA output issues when rewinding.
Added support for 6K version of Supercharger ROMs (this fixes issues
with the 6K version of Cubis).
Cleaned up the Serializable infrastructure, making sure that all
classes that need to implement it actually do so now.
Fixed issue with editable widgets in the UI, where pressing Enter
on the keypad wasn't actually being registered.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1849 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2009-08-05 16:05:34 +00:00
|
|
|
const string& cart = name();
|
2009-04-05 20:18:41 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
out.putString(cart);
|
|
|
|
|
|
|
|
out.putInt(myCurrentBank);
|
|
|
|
}
|
|
|
|
catch(const char* msg)
|
|
|
|
{
|
2009-08-27 22:59:14 +00:00
|
|
|
cerr << "ERROR: CartridgeEFSC::save" << endl << " " << msg << endl;
|
2009-04-05 20:18:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
OK, this looks like a huge update, but it's only because of some Serializer
class reworking. Serializer class now handles read/write of state from
files as well as in-memory streams. As a result, Deserializer class has
been removed.
Added state rewinding to the debugger. For now, this is limited to 100
levels of undo, with a new state generated each time a step/trace/frame/
scanline advance is performed. The undo level is 'rolling', in that it
remembers the last 100 levels (so you lose the oldest states when you
start adding more than 100). For now, this is tied to the 'Alt-r' key
in the debugger. Still TODO is add a button for it, and clean up some
TIA output issues when rewinding.
Added support for 6K version of Supercharger ROMs (this fixes issues
with the 6K version of Cubis).
Cleaned up the Serializable infrastructure, making sure that all
classes that need to implement it actually do so now.
Fixed issue with editable widgets in the UI, where pressing Enter
on the keypad wasn't actually being registered.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1849 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2009-08-05 16:05:34 +00:00
|
|
|
bool CartridgeEFSC::load(Serializer& in)
|
2009-04-05 20:18:41 +00:00
|
|
|
{
|
OK, this looks like a huge update, but it's only because of some Serializer
class reworking. Serializer class now handles read/write of state from
files as well as in-memory streams. As a result, Deserializer class has
been removed.
Added state rewinding to the debugger. For now, this is limited to 100
levels of undo, with a new state generated each time a step/trace/frame/
scanline advance is performed. The undo level is 'rolling', in that it
remembers the last 100 levels (so you lose the oldest states when you
start adding more than 100). For now, this is tied to the 'Alt-r' key
in the debugger. Still TODO is add a button for it, and clean up some
TIA output issues when rewinding.
Added support for 6K version of Supercharger ROMs (this fixes issues
with the 6K version of Cubis).
Cleaned up the Serializable infrastructure, making sure that all
classes that need to implement it actually do so now.
Fixed issue with editable widgets in the UI, where pressing Enter
on the keypad wasn't actually being registered.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1849 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2009-08-05 16:05:34 +00:00
|
|
|
const string& cart = name();
|
2009-04-05 20:18:41 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(in.getString() != cart)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
myCurrentBank = (uInt16) in.getInt();
|
|
|
|
}
|
|
|
|
catch(const char* msg)
|
|
|
|
{
|
2009-08-27 22:59:14 +00:00
|
|
|
cerr << "ERROR: CartridgeEFSC::load" << endl << " " << msg << endl;
|
2009-04-05 20:18:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remember what bank we were in
|
|
|
|
bank(myCurrentBank);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|