First pass at implementing a new experimental scheme for a previously unreleased ROM.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3095 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-11-21 15:53:51 +00:00
parent fb4332a0c7
commit 10fbcdc00c
7 changed files with 416 additions and 3 deletions

View File

@ -67,6 +67,10 @@ class FBSurfaceSDL2 : public FBSurface
private:
void createSurface(uInt32 width, uInt32 height, const uInt32* data);
// Copy constructor and assignment operator not supported
FBSurfaceSDL2(const FBSurfaceSDL2&);
FBSurfaceSDL2& operator = (const FBSurfaceSDL2&);
private:
FrameBufferSDL2& myFB;

View File

@ -57,6 +57,7 @@
#include "CartFE.hxx"
#include "CartMC.hxx"
#include "CartMDM.hxx"
#include "CartPPA.hxx"
#include "CartSB.hxx"
#include "CartUA.hxx"
#include "CartX07.hxx"
@ -247,6 +248,8 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size, string& md5,
cartridge = new CartridgeMC(image, size, settings);
else if(type == "MDM")
cartridge = new CartridgeMDM(image, size, settings);
else if(type == "PPA")
cartridge = new CartridgePPA(image, size, settings);
else if(type == "UA")
cartridge = new CartridgeUA(image, size, settings);
else if(type == "SB")
@ -418,6 +421,10 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
else
type = "F8";
}
else if(size == 8*1024 + 3) // 8195 byte - Pink Panther Prototype
{
type = "PPA";
}
else if(size >= 10240 && size <= 10496) // ~10K - Pitfall2
{
type = "DPC";
@ -697,7 +704,7 @@ bool Cartridge::isProbablyCV(const uInt8* image, uInt32 size)
bool Cartridge::isProbablyDASH(const uInt8* image, uInt32 size)
{
// DASH cart is identified key 'TJAD' in the ROM
uInt8 signature[] = { 0x54, 0x4a, 0x41, 0x44 };
uInt8 signature[] = { 'T', 'J', 'A', 'D' };
return searchForBytes(image, size, signature, 4, 1);
}
@ -890,7 +897,7 @@ bool Cartridge::isProbablyFE(const uInt8* image, uInt32 size)
bool Cartridge::isProbablyMDM(const uInt8* image, uInt32 size)
{
// MDM cart is identified key 'MDMC' in the first 4K of ROM
uInt8 signature[] = { 0x4D, 0x44, 0x4D, 0x43 };
uInt8 signature[] = { 'M', 'D', 'M', 'C' };
return searchForBytes(image, 4096, signature, 4, 1);
}
@ -990,6 +997,7 @@ Cartridge::BankswitchType Cartridge::ourBSList[] = {
{ "FE", "FE (8K Decathlon)" },
{ "MC", "MC (C. Wilkson Megacart)" },
{ "MDM", "MDM (Menu Driven Megacart)" },
{ "PPA", "PPA (Pink Panther Prototype)" },
{ "SB", "SB (128-256K SUPERbank)" },
{ "UA", "UA (8K UA Ltd.)" },
{ "X07", "X07 (64K AtariAge)" }

View File

@ -216,7 +216,7 @@ class Cartridge : public Device
const char* type;
const char* desc;
};
enum { ourNumBSTypes = 44 };
enum { ourNumBSTypes = 45 };
static BankswitchType ourBSList[ourNumBSTypes];
protected:

166
src/emucore/CartPPA.cxx Normal file
View File

@ -0,0 +1,166 @@
//============================================================================
//
// 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-2014 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#include <cstring>
#include "System.hxx"
#include "CartPPA.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgePPA::CartridgePPA(const uInt8* image, uInt32 size,
const Settings& settings)
: Cartridge(settings)
{
// Copy the ROM image into my buffer
memcpy(myImage, image, BSPF_min(8192u, size));
createCodeAccessBase(8192);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgePPA::~CartridgePPA()
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgePPA::reset()
{
// Setup segments to some default slices
bank(0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgePPA::install(System& system)
{
mySystem = &system;
bank(0);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgePPA::peek(uInt16 address)
{
return 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgePPA::poke(uInt16 address, uInt8)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgePPA::bank(uInt16 bank)
{
if(bankLocked() || bank > 15) return false;
segmentZero(ourBankOrg[bank].zero);
segmentOne(ourBankOrg[bank].one);
segmentTwo(ourBankOrg[bank].two);
segmentThree(ourBankOrg[bank].three, ourBankOrg[bank].map3bytes);
return myBankChanged = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgePPA::segmentZero(uInt8 slice)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgePPA::segmentOne(uInt8 slice)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgePPA::segmentTwo(uInt8 slice)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgePPA::segmentThree(uInt8 slice, bool map3bytes)
{
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgePPA::patch(uInt16 address, uInt8 value)
{
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8* CartridgePPA::getImage(int& size) const
{
size = 8192;
return myImage;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgePPA::save(Serializer& out) const
{
try
{
out.putString(name());
out.putByteArray(myCurrentSlice, 4);
}
catch(...)
{
cerr << "ERROR: CartridgePPA::save" << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgePPA::load(Serializer& in)
{
try
{
if(in.getString() != name())
return false;
in.getByteArray(myCurrentSlice, 4);
}
catch(...)
{
cerr << "ERROR: CartridgePPA::load" << endl;
return false;
}
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgePPA::BankOrg CartridgePPA::ourBankOrg[16] = {
{ 0, 0, 1, 2, false },
{ 0, 1, 3, 2, false },
{ 4, 5, 6, 7, false },
{ 7, 4, 3, 2, false },
{ 0, 0, 6, 7, false },
{ 0, 1, 7, 6, false },
{ 3, 2, 4, 5, false },
{ 6, 0, 5, 1, false },
{ 0, 0, 1, 2, false },
{ 0, 1, 3, 2, false },
{ 4, 5, 6, 8, false },
{ 7, 4, 3, 2, false },
{ 0, 0, 6, 7, true },
{ 0, 1, 7, 6, true },
{ 3, 2, 4, 5, true },
{ 6, 0, 5, 1, true }
};

229
src/emucore/CartPPA.hxx Normal file
View File

@ -0,0 +1,229 @@
//============================================================================
//
// 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-2014 by Bradford W. Mott, Stephen Anthony
// and the Stella Team
//
// See the file "License.txt" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id$
//============================================================================
#ifndef CARTRIDGEPPA_HXX
#define CARTRIDGEPPA_HXX
class System;
#include "bspf.hxx"
#include "Cart.hxx"
#ifdef DEBUGGER_SUPPORT
// #include "CartPPAWidget.hxx"
#endif
/**
This is the cartridge class for the "Pink Panther" prototype cart.
The ROM is normally 8K, but sometimes has an extra 3 bytes appended,
to be mapped as described below. There is also 64 bytes of RAM.
In this bankswitching scheme the 2600's 4K cartridge address space
is broken into four 1K segments. The desired arrangement of 1K slices
is selected by accessing $30 - $FF of the first segment. The slices
are mapped into all 4 segments at once as follows:
$0030: 0,0,1,2
$0031: 0,1,3,2
$0032: 4,5,6,7
$0033: 7,4,3,2
$0034: 0,0,6,7
$0035: 0,1,7,6
$0036: 3,2,4,5
$0037: 6,0,5,1
$0038: 0,0,1,2
$0039: 0,1,3,2
$003A: 4,5,6,8
$003B: 7,4,3,2
$003C: 0,0,6,7*
$003D: 0,1,7,6*
$003E: 3,2,4,5*
$003F: 6,0,5,1*
In the last 4 cases, the extra 3 bytes of ROM past the 8K boundary are
mapped into $3FC - $3FE of the uppermost (third) segment.
The 64 bytes of RAM are accessible at $1000 - $103F (read port) and
$1040 - $107F (write port). Note that all the hotspots are in the
read port of RAM. Because the RAM takes 128 bytes of address space,
the range $1000 - $107F of segment 0 ROM will never be available.
@author Stephen Anthony
*/
class CartridgePPA : public Cartridge
{
friend class CartridgePPAWidget;
public:
/**
Create a new cartridge using the specified image
@param image Pointer to the ROM image
@param size The size of the ROM image
@param settings A reference to the various settings (read-only)
*/
CartridgePPA(const uInt8* image, uInt32 size, const Settings& settings);
/**
Destructor
*/
virtual ~CartridgePPA();
public:
/**
Reset device to its power-on state
*/
void reset();
/**
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
*/
void install(System& system);
/**
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
*/
bool patch(uInt16 address, uInt8 value);
/**
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
*/
const uInt8* getImage(int& size) const;
/**
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
*/
bool save(Serializer& out) const;
/**
Load the current state of this cart from the given Serializer.
@param in The Serializer object to use
@return False on any errors, else true
*/
bool load(Serializer& in);
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
string name() const { return "CartridgePPA"; }
#ifdef DEBUGGER_SUPPORT
/**
Get debugger widget responsible for accessing the inner workings
of the cart.
*/
CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont, int x, int y, int w, int h)
{
return nullptr;//new CartridgePPAWidget(boss, lfont, nfont, x, y, w, h, *this);
}
#endif
public:
/**
Get the byte at the specified address.
@return The byte at the specified address
*/
uInt8 peek(uInt16 address);
/**
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
@return True if the poke changed the device address space, else false
*/
bool poke(uInt16 address, uInt8 value);
private:
/**
Install slices for all four segments according to the bank index.
@param bank Index into BankOrg structure
*/
bool bank(uInt16 bank);
/**
Install the specified slice for segment zero.
Note that this method also takes care of mapping RAM.
@param slice The slice to map into the segment
*/
void segmentZero(uInt8 slice);
/**
Install the specified slice for segment one.
@param slice The slice to map into the segment
*/
void segmentOne(uInt8 slice);
/**
Install the specified slice for segment two.
@param slice The slice to map into the segment
*/
void segmentTwo(uInt8 slice);
/**
Install the specified slice for segment three.
Note that this method also takes care of mapping extra 3 bytes.
@param slice The slice to map into the segment
@param map3bytes Whether to map in an extra 3 bytes
*/
void segmentThree(uInt8 slice, bool map3bytes);
private:
// Indicates the slice mapped into each of the four segments
uInt8 myCurrentSlice[4];
// The 8K ROM image of the cartridge
uInt8 myImage[8192];
// The 64 bytes RAM of the cartridge
uInt8 myRAM[64];
// The 1K ROM mirror of segment 3 (sometimes contains extra 3 bytes)
uInt8 mySegment3[1024];
// The arrangement of banks to use on each hotspot read
struct BankOrg {
uInt8 zero, one, two, three;
bool map3bytes;
};
static BankOrg ourBankOrg[16];
};
#endif

View File

@ -320,6 +320,11 @@ class FBSurface
static void setPalette(const uInt32* palette) { myPalette = palette; }
private:
// Copy constructor and assignment operator not supported
FBSurface(const FBSurface&);
FBSurface& operator = (const FBSurface&);
protected:
static const uInt32* myPalette;
uInt32* myPixels;

View File

@ -38,6 +38,7 @@ MODULE_OBJS := \
src/emucore/CartFE.o \
src/emucore/CartMC.o \
src/emucore/CartMDM.o \
src/emucore/CartPPA.o \
src/emucore/CartSB.o \
src/emucore/CartUA.o \
src/emucore/CartX07.o \