mirror of https://github.com/stella-emu/stella.git
Added the F4 bankswitching method to the emulator. This is a 32K cartridge
with eight 4K banks. Marble Craze (a new homebrew game) should work now. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@107 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
d34f42c679
commit
35fcaec0ff
|
@ -13,7 +13,7 @@
|
|||
## See the file "license" for information on usage and redistribution of
|
||||
## this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
##
|
||||
## $Id: makefile,v 1.19 2002-08-04 00:28:18 stephena Exp $
|
||||
## $Id: makefile,v 1.20 2002-08-14 02:30:52 bwmott Exp $
|
||||
##============================================================================
|
||||
|
||||
##============================================================================
|
||||
|
@ -24,11 +24,11 @@
|
|||
##============================================================================
|
||||
|
||||
### this should work with all compilers
|
||||
OPTIMIZATIONS =
|
||||
# OPTIMIZATIONS =
|
||||
### for normal optimization, full warnings
|
||||
# OPTIMIZATIONS = -O -Wall
|
||||
### for common optimizations, full warnings except unused vars
|
||||
# OPTIMIZATIONS = -O2 -Wall -Wno-unused
|
||||
OPTIMIZATIONS = -O2 -Wall -Wno-unused
|
||||
### to get full optimization under gcc/x Intel based OS's..
|
||||
# OPTIMIZATIONS = -O3 -mcpu=pentiumpro -march=pentiumpro -Wall -Wno-unused \
|
||||
# -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math \
|
||||
|
@ -224,9 +224,9 @@ solaris-x:
|
|||
M6502_OBJS = D6502.o Device.o M6502.o M6502Low.o M6502Hi.o NullDev.o System.o
|
||||
|
||||
CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
|
||||
CartE0.o CartE7.o CartF4SC.o CartF6.o CartF6SC.o CartF8.o \
|
||||
CartF8SC.o CartFASC.o CartFE.o CartMC.o CartCV.o CartMB.o \
|
||||
Console.o Control.o Driving.o \
|
||||
CartE0.o CartE7.o CartF4.o CartF4SC.o CartF6.o CartF6SC.o \
|
||||
CartF8.o CartF8SC.o CartFASC.o CartFE.o CartMC.o CartCV.o \
|
||||
CartMB.o Console.o Control.o Driving.o \
|
||||
Event.o Joystick.o Keyboard.o M6532.o MD5.o MediaSrc.o Paddles.o \
|
||||
Props.o PropsSet.o Random.o Sound.o Switches.o Settings.o TIA.o \
|
||||
Serializer.o Deserializer.o \
|
||||
|
@ -313,6 +313,9 @@ CartE0.o: $(CORE)/CartE0.cxx
|
|||
CartE7.o: $(CORE)/CartE7.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartE7.cxx
|
||||
|
||||
CartF4.o: $(CORE)/CartF4.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF4.cxx
|
||||
|
||||
CartF4SC.o: $(CORE)/CartF4SC.cxx
|
||||
$(CXX) -c $(CXXFLAGS) $(OPTIONS) $(CORE)/CartF4SC.cxx
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Cart.cxx,v 1.3 2002-01-18 16:03:48 estolberg Exp $
|
||||
// $Id: Cart.cxx,v 1.4 2002-08-14 02:30:52 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -26,6 +26,7 @@
|
|||
#include "CartDPC.hxx"
|
||||
#include "CartE0.hxx"
|
||||
#include "CartE7.hxx"
|
||||
#include "CartF4.hxx"
|
||||
#include "CartF4SC.hxx"
|
||||
#include "CartF6.hxx"
|
||||
#include "CartF6SC.hxx"
|
||||
|
@ -69,6 +70,8 @@ Cartridge* Cartridge::create(const uInt8* image, uInt32 size,
|
|||
cartridge = new CartridgeE0(image);
|
||||
else if(type == "E7")
|
||||
cartridge = new CartridgeE7(image);
|
||||
else if(type == "F4")
|
||||
cartridge = new CartridgeF4(image);
|
||||
else if(type == "F4SC")
|
||||
cartridge = new CartridgeF4SC(image);
|
||||
else if(type == "F6")
|
||||
|
@ -183,7 +186,19 @@ string Cartridge::autodetectType(const uInt8* image, uInt32 size)
|
|||
}
|
||||
else if(size == 32768)
|
||||
{
|
||||
// Assume this is a 32K super-cart then check to see if it is
|
||||
type = "F4SC";
|
||||
|
||||
uInt8 first = image[0];
|
||||
for(uInt32 i = 0; i < 256; ++i)
|
||||
{
|
||||
if(image[i] != first)
|
||||
{
|
||||
// It's not a super cart (probably)
|
||||
type = "F4";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(size == 65536)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
//============================================================================
|
||||
//
|
||||
// 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-2002 by Bradford W. Mott
|
||||
//
|
||||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CartF4.cxx,v 1.1 2002-08-14 02:30:52 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
#include "CartF4.hxx"
|
||||
#include "Random.hxx"
|
||||
#include "System.hxx"
|
||||
#include "Serializer.hxx"
|
||||
#include "Deserializer.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeF4::CartridgeF4(const uInt8* image)
|
||||
{
|
||||
// Copy the ROM image into my buffer
|
||||
for(uInt32 addr = 0; addr < 32768; ++addr)
|
||||
{
|
||||
myImage[addr] = image[addr];
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeF4::~CartridgeF4()
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const char* CartridgeF4::name() const
|
||||
{
|
||||
return "CartridgeF4";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeF4::reset()
|
||||
{
|
||||
// Upon reset we switch to bank 7
|
||||
bank(7);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeF4::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 = (0x1FF4 & ~mask); i < 0x2000; i += (1 << shift))
|
||||
{
|
||||
access.directPeekBase = 0;
|
||||
access.directPokeBase = 0;
|
||||
access.device = this;
|
||||
mySystem->setPageAccess(i >> shift, access);
|
||||
}
|
||||
|
||||
// Install pages for bank 7
|
||||
bank(7);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 CartridgeF4::peek(uInt16 address)
|
||||
{
|
||||
address = address & 0x0FFF;
|
||||
|
||||
// Switch banks if necessary
|
||||
if((address >= 0x0FF4) && (address <= 0x0FFB))
|
||||
{
|
||||
bank(address - 0x0FF4);
|
||||
}
|
||||
|
||||
return myImage[myCurrentBank * 4096 + address];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeF4::poke(uInt16 address, uInt8)
|
||||
{
|
||||
address = address & 0x0FFF;
|
||||
|
||||
// Switch banks if necessary
|
||||
if((address >= 0x0FF4) && (address <= 0x0FFB))
|
||||
{
|
||||
bank(address - 0x0FF4);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeF4::bank(uInt16 bank)
|
||||
{
|
||||
// Remember what bank we're in
|
||||
myCurrentBank = bank;
|
||||
uInt16 offset = myCurrentBank * 4096;
|
||||
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 = 0x1000; address < (0x1FF4U & ~mask);
|
||||
address += (1 << shift))
|
||||
{
|
||||
access.directPeekBase = &myImage[offset + (address & 0x0FFF)];
|
||||
mySystem->setPageAccess(address >> shift, access);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CartridgeF4::save(Serializer& out)
|
||||
{
|
||||
string cart = name();
|
||||
|
||||
try
|
||||
{
|
||||
out.putString(cart);
|
||||
out.putLong(myCurrentBank);
|
||||
}
|
||||
catch(char* msg)
|
||||
{
|
||||
cerr << msg << endl;
|
||||
return false;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
cerr << "Unknown error in save state for " << cart << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CartridgeF4::load(Deserializer& in)
|
||||
{
|
||||
string cart = name();
|
||||
|
||||
try
|
||||
{
|
||||
if(in.getString() != cart)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
myCurrentBank = (uInt16)in.getLong();
|
||||
}
|
||||
catch(char* msg)
|
||||
{
|
||||
cerr << msg << endl;
|
||||
return false;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
cerr << "Unknown error in load state for " << cart << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember what bank we were in
|
||||
bank(myCurrentBank);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
//============================================================================
|
||||
//
|
||||
// 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-2002 by Bradford W. Mott
|
||||
//
|
||||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: CartF4.hxx,v 1.1 2002-08-14 02:30:52 bwmott Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef CARTRIDGEF4_HXX
|
||||
#define CARTRIDGEF4_HXX
|
||||
|
||||
class CartridgeF4;
|
||||
class Serializer;
|
||||
class Deserializer;
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "Cart.hxx"
|
||||
|
||||
/**
|
||||
Cartridge class used for Atari's 32K bankswitched games. There
|
||||
are eight 4K banks.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: CartF4.hxx,v 1.1 2002-08-14 02:30:52 bwmott Exp $
|
||||
*/
|
||||
class CartridgeF4 : public Cartridge
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Create a new cartridge using the specified image
|
||||
|
||||
@param image Pointer to the ROM image
|
||||
*/
|
||||
CartridgeF4(const uInt8* image);
|
||||
|
||||
/**
|
||||
Destructor
|
||||
*/
|
||||
virtual ~CartridgeF4();
|
||||
|
||||
public:
|
||||
/**
|
||||
Get a null terminated string which is the device's name (i.e. "M6532")
|
||||
|
||||
@return The name of the device
|
||||
*/
|
||||
virtual const char* name() const;
|
||||
|
||||
/**
|
||||
Reset device to its power-on state
|
||||
*/
|
||||
virtual 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
|
||||
*/
|
||||
virtual void install(System& system);
|
||||
|
||||
/**
|
||||
Saves the current state of this device to the given Serializer.
|
||||
|
||||
@param out The serializer device to save to.
|
||||
@return The result of the save. True on success, false on failure.
|
||||
*/
|
||||
virtual bool save(Serializer& out);
|
||||
|
||||
/**
|
||||
Loads the current state of this device from the given Deserializer.
|
||||
|
||||
@param in The deserializer device to load from.
|
||||
@return The result of the load. True on success, false on failure.
|
||||
*/
|
||||
virtual bool load(Deserializer& in);
|
||||
|
||||
public:
|
||||
/**
|
||||
Get the byte at the specified address.
|
||||
|
||||
@return The byte at the specified address
|
||||
*/
|
||||
virtual 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
|
||||
*/
|
||||
virtual void poke(uInt16 address, uInt8 value);
|
||||
|
||||
private:
|
||||
/**
|
||||
Install pages for the specified bank in the system
|
||||
|
||||
@param bank The bank that should be installed in the system
|
||||
*/
|
||||
void bank(uInt16 bank);
|
||||
|
||||
private:
|
||||
// Indicates which bank is currently active
|
||||
uInt16 myCurrentBank;
|
||||
|
||||
// The 16K ROM image of the cartridge
|
||||
uInt8 myImage[32768];
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue