2008-02-27 14:14:38 +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
|
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// Copyright (c) 1995-2010 by Bradford W. Mott and the Stella Team
|
2008-02-27 14:14:38 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2008-02-27 14:14:38 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-25 17:51:52 +00:00
|
|
|
// $Id$
|
2008-02-27 14:14:38 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <cassert>
|
2009-05-25 17:51:52 +00:00
|
|
|
#include <cstring>
|
2008-02-27 14:14:38 +00:00
|
|
|
|
|
|
|
#include "System.hxx"
|
|
|
|
#include "M6532.hxx"
|
|
|
|
#include "TIA.hxx"
|
|
|
|
#include "CartX07.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
CartridgeX07::CartridgeX07(const uInt8* image)
|
|
|
|
{
|
|
|
|
// Copy the ROM image into my buffer
|
2009-05-25 17:51:52 +00:00
|
|
|
memcpy(myImage, image, 65536);
|
2010-03-05 22:02:12 +00:00
|
|
|
|
|
|
|
// Remember startup bank
|
|
|
|
myStartBank = 0;
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
CartridgeX07::~CartridgeX07()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeX07::reset()
|
|
|
|
{
|
2010-03-05 22:02:12 +00:00
|
|
|
// Upon reset we switch to the startup bank
|
|
|
|
bank(myStartBank);
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeX07::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
|
|
|
|
// The hotspots use almost all addresses below 0x1000, so we simply grab them
|
|
|
|
// all and forward the TIA/RIOT calls from the peek and poke methods.
|
|
|
|
System::PageAccess access;
|
|
|
|
for(uInt32 i = 0x00; i < 0x1000; i += (1 << shift))
|
|
|
|
{
|
|
|
|
access.directPeekBase = 0;
|
|
|
|
access.directPokeBase = 0;
|
|
|
|
access.device = this;
|
|
|
|
mySystem->setPageAccess(i >> shift, access);
|
|
|
|
}
|
|
|
|
|
2010-03-05 22:02:12 +00:00
|
|
|
// Install pages for the startup bank
|
|
|
|
bank(myStartBank);
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8 CartridgeX07::peek(uInt16 address)
|
|
|
|
{
|
|
|
|
uInt8 value = 0;
|
|
|
|
|
|
|
|
// Check for RAM or TIA mirroring
|
|
|
|
uInt16 lowAddress = address & 0x3ff;
|
|
|
|
if(lowAddress & 0x80)
|
|
|
|
value = mySystem->m6532().peek(address);
|
|
|
|
else if(!(lowAddress & 0x200))
|
|
|
|
value = mySystem->tia().peek(address);
|
|
|
|
|
|
|
|
// Switch banks if necessary
|
2009-05-25 17:51:52 +00:00
|
|
|
if((address & 0x180f) == 0x080d)
|
|
|
|
bank((address & 0xf0) >> 4);
|
2008-02-27 14:14:38 +00:00
|
|
|
else if((address & 0x1880) == 0)
|
|
|
|
{
|
|
|
|
if((myCurrentBank & 0xe) == 0xe)
|
|
|
|
bank(((address & 0x40) >> 6) | (myCurrentBank & 0xe));
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeX07::poke(uInt16 address, uInt8 value)
|
|
|
|
{
|
|
|
|
// Check for RAM or TIA mirroring
|
|
|
|
uInt16 lowAddress = address & 0x3ff;
|
|
|
|
if(lowAddress & 0x80)
|
|
|
|
mySystem->m6532().poke(address, value);
|
|
|
|
else if(!(lowAddress & 0x200))
|
|
|
|
mySystem->tia().poke(address, value);
|
|
|
|
|
|
|
|
// Switch banks if necessary
|
2009-05-25 17:51:52 +00:00
|
|
|
if((address & 0x180f) == 0x080d)
|
|
|
|
bank((address & 0xf0) >> 4);
|
2008-02-27 14:14:38 +00:00
|
|
|
else if((address & 0x1880) == 0)
|
|
|
|
{
|
|
|
|
if((myCurrentBank & 0xe) == 0xe)
|
|
|
|
bank(((address & 0x40) >> 6) | (myCurrentBank & 0xe));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void CartridgeX07::bank(uInt16 bank)
|
|
|
|
{
|
2010-03-06 18:56:36 +00:00
|
|
|
if(bankLocked()) return;
|
2008-02-27 14:14:38 +00:00
|
|
|
|
|
|
|
// Remember what bank we're in
|
|
|
|
myCurrentBank = (bank & 0x0f);
|
2009-05-25 17:51:52 +00:00
|
|
|
uInt32 offset = myCurrentBank << 12;
|
2008-02-27 14:14:38 +00:00
|
|
|
uInt16 shift = mySystem->pageShift();
|
|
|
|
|
|
|
|
// 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 = 0x1000; address < 0x2000; address += (1 << shift))
|
|
|
|
{
|
|
|
|
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
|
|
|
|
mySystem->setPageAccess(address >> shift, access);
|
|
|
|
}
|
2010-03-06 18:56:36 +00:00
|
|
|
myBankChanged = true;
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int CartridgeX07::bank()
|
|
|
|
{
|
|
|
|
return myCurrentBank;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
int CartridgeX07::bankCount()
|
|
|
|
{
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeX07::patch(uInt16 address, uInt8 value)
|
|
|
|
{
|
2009-05-25 17:51:52 +00:00
|
|
|
myImage[(myCurrentBank << 12) + (address & 0x0FFF)] = value;
|
2010-03-06 18:56:36 +00:00
|
|
|
return myBankChanged = true;
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8* CartridgeX07::getImage(int& size)
|
|
|
|
{
|
|
|
|
size = 65536;
|
2010-03-06 18:56:36 +00:00
|
|
|
return myImage;
|
2008-02-27 14:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool CartridgeX07::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();
|
2008-02-27 14:14:38 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
out.putString(cart);
|
|
|
|
out.putInt(myCurrentBank);
|
|
|
|
}
|
2009-08-27 22:59:14 +00:00
|
|
|
catch(const char* msg)
|
2008-02-27 14:14:38 +00:00
|
|
|
{
|
2009-08-27 22:59:14 +00:00
|
|
|
cerr << "ERROR: CartridgeX07::save" << endl << " " << msg << endl;
|
2008-02-27 14:14:38 +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 CartridgeX07::load(Serializer& in)
|
2008-02-27 14:14:38 +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();
|
2008-02-27 14:14:38 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(in.getString() != cart)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
myCurrentBank = (uInt16)in.getInt();
|
|
|
|
}
|
2009-08-27 22:59:14 +00:00
|
|
|
catch(const char* msg)
|
2008-02-27 14:14:38 +00:00
|
|
|
{
|
2009-08-27 22:59:14 +00:00
|
|
|
cerr << "ERROR: CartridgeX07::load" << endl << " " << msg << endl;
|
2008-02-27 14:14:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remember what bank we were in
|
|
|
|
bank(myCurrentBank);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|