2001-12-27 19:54:36 +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
|
2001-12-27 19:54:36 +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
|
2001-12-27 19:54:36 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2001-12-27 19:54:36 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef CARTRIDGEE7_HXX
|
|
|
|
#define CARTRIDGEE7_HXX
|
|
|
|
|
2007-01-14 16:17:57 +00:00
|
|
|
class System;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
#include "bspf.hxx"
|
|
|
|
#include "Cart.hxx"
|
2013-04-12 12:36:57 +00:00
|
|
|
#ifdef DEBUGGER_SUPPORT
|
|
|
|
#include "CartE7Widget.hxx"
|
|
|
|
#endif
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
/**
|
2016-12-30 00:00:30 +00:00
|
|
|
This is the cartridge class for M-Network bankswitched games.
|
|
|
|
In this bankswitching scheme the 2600's 4K cartridge address
|
2001-12-27 19:54:36 +00:00
|
|
|
space is broken into two 2K segments.
|
|
|
|
|
|
|
|
Kevin Horton describes E7 as follows:
|
|
|
|
|
2016-12-30 00:00:30 +00:00
|
|
|
Only M-Network used this scheme. This has to be the
|
|
|
|
most complex method used in any cart! :-) It allows
|
|
|
|
for the capability of 2K of RAM; although it doesn't
|
|
|
|
have to be used (in fact, only one cart used it).
|
|
|
|
There are now 8 2K banks, instead of 4. The last 2K
|
|
|
|
in the cart always points to the last 2K of the ROM
|
|
|
|
image, while the first 2K is selectable. You access
|
2001-12-27 19:54:36 +00:00
|
|
|
1FE0 to 1FE6 to select which 2K bank. Note that you
|
2016-12-30 00:00:30 +00:00
|
|
|
cannot select the last 2K of the ROM image into the
|
|
|
|
lower 2K of the cart! Accessing 1FE7 selects 1K of
|
2001-12-27 19:54:36 +00:00
|
|
|
RAM at 1000-17FF instead of ROM! The 2K of RAM is
|
2016-12-30 00:00:30 +00:00
|
|
|
broken up into two 1K sections. One 1K section is
|
|
|
|
mapped in at 1000-17FF if 1FE7 has been accessed.
|
|
|
|
1000-13FF is the write port, while 1400-17FF is the
|
|
|
|
read port. The second 1K of RAM appears at 1800-19FF.
|
|
|
|
1800-18FF is the write port while 1900-19FF is the
|
|
|
|
read port. You select which 256 byte block appears
|
2010-01-09 20:50:38 +00:00
|
|
|
here by accessing 1FE8 to 1FEB.
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2010-03-28 03:13:10 +00:00
|
|
|
This cart reports having 8 banks; 1 for each of the possible 7
|
|
|
|
slices in the lower 2K area, and the last for RAM in the lower
|
|
|
|
2K area.
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
@author Bradford W. Mott
|
|
|
|
*/
|
|
|
|
class CartridgeE7 : public Cartridge
|
|
|
|
{
|
2013-04-12 12:36:57 +00:00
|
|
|
friend class CartridgeE7Widget;
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Create a new cartridge using the specified image
|
|
|
|
|
2010-08-19 21:48:28 +00:00
|
|
|
@param image Pointer to the ROM image
|
2012-01-02 20:31:42 +00:00
|
|
|
@param size The size of the ROM image
|
2010-08-19 21:48:28 +00:00
|
|
|
@param settings A reference to the various settings (read-only)
|
2001-12-27 19:54:36 +00:00
|
|
|
*/
|
2017-07-02 21:57:27 +00:00
|
|
|
CartridgeE7(const BytePtr& image, uInt32 size, const Settings& settings);
|
2015-12-29 21:28:10 +00:00
|
|
|
virtual ~CartridgeE7() = default;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Reset device to its power-on state
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
void reset() override;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Install cartridge in the specified system. Invoked by the system
|
|
|
|
when the cartridge is attached to it.
|
|
|
|
|
|
|
|
@param system The system the device should install itself in
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
void install(System& system) override;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2007-01-14 16:17:57 +00:00
|
|
|
/**
|
|
|
|
Install pages for the specified bank in the system.
|
|
|
|
|
|
|
|
@param bank The bank that should be installed in the system
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
bool bank(uInt16 bank) override;
|
2007-01-14 16:17:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the current bank.
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
uInt16 getBank() const override;
|
2007-01-14 16:17:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Query the number of banks supported by the cartridge.
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
uInt16 bankCount() const override;
|
2007-01-14 16:17:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Patch the cartridge ROM.
|
|
|
|
|
|
|
|
@param address The ROM address to patch
|
|
|
|
@param value The value to place into the address
|
|
|
|
@return Success or failure of the patch operation
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
bool patch(uInt16 address, uInt8 value) override;
|
2007-01-14 16:17:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Access the internal ROM image for this cartridge.
|
|
|
|
|
|
|
|
@param size Set to the size of the internal ROM image data
|
|
|
|
@return A pointer to the internal ROM image data
|
|
|
|
*/
|
2017-09-01 12:53:17 +00:00
|
|
|
const uInt8* getImage(uInt32& size) const override;
|
2005-07-30 16:58:22 +00:00
|
|
|
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
/**
|
|
|
|
Save the current state of this cart to the given Serializer.
|
|
|
|
|
|
|
|
@param out The Serializer object to use
|
|
|
|
@return False on any errors, else true
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
bool save(Serializer& out) const override;
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +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
|
|
|
Load the current state of this cart from the given Serializer.
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +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
|
|
|
@param in The Serializer object to use
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
@return False on any errors, else true
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
bool load(Serializer& in) override;
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get a descriptor for the device name (used in error checking).
|
|
|
|
|
|
|
|
@return The name of the object
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
string name() const override { return "CartridgeE7"; }
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
|
2013-04-12 12:36:57 +00:00
|
|
|
#ifdef DEBUGGER_SUPPORT
|
|
|
|
/**
|
|
|
|
Get debugger widget responsible for accessing the inner workings
|
|
|
|
of the cart.
|
|
|
|
*/
|
2013-08-26 13:01:29 +00:00
|
|
|
CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
|
2015-07-10 18:59:03 +00:00
|
|
|
const GUI::Font& nfont, int x, int y, int w, int h) override
|
2013-04-12 12:36:57 +00:00
|
|
|
{
|
2013-08-26 13:01:29 +00:00
|
|
|
return new CartridgeE7Widget(boss, lfont, nfont, x, y, w, h, *this);
|
2013-04-12 12:36:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Get the byte at the specified address.
|
|
|
|
|
|
|
|
@return The byte at the specified address
|
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
uInt8 peek(uInt16 address) override;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Change the byte at the specified address to the given value
|
|
|
|
|
|
|
|
@param address The address where the value should be stored
|
|
|
|
@param value The value to be stored at the address
|
2010-03-28 03:13:10 +00:00
|
|
|
@return True if the poke changed the device address space, else false
|
2001-12-27 19:54:36 +00:00
|
|
|
*/
|
2015-07-10 18:59:03 +00:00
|
|
|
bool poke(uInt16 address, uInt8 value) override;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2005-06-27 12:43:49 +00:00
|
|
|
private:
|
2001-12-27 19:54:36 +00:00
|
|
|
/**
|
|
|
|
Install pages for the specified 256 byte bank of RAM
|
|
|
|
|
|
|
|
@param bank The bank that should be installed in the system
|
|
|
|
*/
|
|
|
|
void bankRAM(uInt16 bank);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// The 16K ROM image of the cartridge
|
|
|
|
uInt8 myImage[16384];
|
|
|
|
|
|
|
|
// The 2048 bytes of RAM
|
|
|
|
uInt8 myRAM[2048];
|
2015-04-26 19:02:42 +00:00
|
|
|
|
2015-12-05 01:30:17 +00:00
|
|
|
// Indicates which slice is in the segment
|
|
|
|
uInt16 myCurrentSlice[2];
|
|
|
|
|
|
|
|
// Indicates which 256 byte bank of RAM is being used
|
|
|
|
uInt16 myCurrentRAM;
|
|
|
|
|
2015-04-26 19:02:42 +00:00
|
|
|
private:
|
|
|
|
// Following constructors and assignment operators not supported
|
|
|
|
CartridgeE7() = delete;
|
|
|
|
CartridgeE7(const CartridgeE7&) = delete;
|
|
|
|
CartridgeE7(CartridgeE7&&) = delete;
|
|
|
|
CartridgeE7& operator=(const CartridgeE7&) = delete;
|
|
|
|
CartridgeE7& operator=(CartridgeE7&&) = delete;
|
2001-12-27 19:54:36 +00:00
|
|
|
};
|
|
|
|
|
2007-01-14 16:17:57 +00:00
|
|
|
#endif
|