2010-03-18 17:34:53 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2010-04-03 12:45:20 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2010-03-18 17:34:53 +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
|
|
|
|
//
|
2010-04-10 21:37:23 +00:00
|
|
|
// Copyright (c) 1995-2010 by Bradford W. Mott, Stephen Anthony
|
|
|
|
// and the Stella Team
|
2010-03-18 17:34:53 +00:00
|
|
|
//
|
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef CARTRIDGE_DPC_PLUS_HXX
|
|
|
|
#define CARTRIDGE_DPC_PLUS_HXX
|
|
|
|
|
|
|
|
class System;
|
|
|
|
|
|
|
|
#include "bspf.hxx"
|
|
|
|
#include "Cart.hxx"
|
|
|
|
|
|
|
|
/**
|
2010-04-18 15:01:38 +00:00
|
|
|
Cartridge class used for DPC+. There are six 4K program banks, a 4K
|
|
|
|
display bank, 1K frequency table and the DPC chip. For complete details on
|
|
|
|
the DPC chip see David P. Crane's United States Patent Number 4,644,495.
|
2010-03-18 17:34:53 +00:00
|
|
|
|
2010-03-28 03:13:10 +00:00
|
|
|
@author Darrell Spice Jr, Fred Quimby, Stephen Anthony
|
2010-03-18 17:34:53 +00:00
|
|
|
@version $Id$
|
|
|
|
*/
|
|
|
|
class CartridgeDPCPlus : public Cartridge
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Create a new cartridge using the specified image
|
|
|
|
|
|
|
|
@param image Pointer to the ROM image
|
|
|
|
*/
|
|
|
|
CartridgeDPCPlus(const uInt8* image, uInt32 size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor
|
|
|
|
*/
|
|
|
|
virtual ~CartridgeDPCPlus();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Reset device to its power-on state
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
void reset();
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Notification method invoked by the system right before the
|
|
|
|
system resets its cycle counter to zero. It may be necessary
|
|
|
|
to override this method for devices that remember cycle counts.
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
void systemCyclesReset();
|
2010-03-18 17:34:53 +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
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
void install(System& system);
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Install pages for the specified bank in the system.
|
|
|
|
|
|
|
|
@param bank The bank that should be installed in the system
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
void bank(uInt16 bank);
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the current bank.
|
|
|
|
*/
|
2010-04-02 22:09:31 +00:00
|
|
|
uInt16 bank() const;
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Query the number of banks supported by the cartridge.
|
|
|
|
*/
|
2010-04-02 22:09:31 +00:00
|
|
|
uInt16 bankCount() const;
|
2010-03-18 17:34:53 +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
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
bool patch(uInt16 address, uInt8 value);
|
2010-03-18 17:34:53 +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
|
|
|
|
*/
|
2010-04-02 22:09:31 +00:00
|
|
|
const uInt8* getImage(int& size) const;
|
2010-03-18 17:34:53 +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
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
bool save(Serializer& out) const;
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
bool load(Serializer& in);
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get a descriptor for the device name (used in error checking).
|
|
|
|
|
|
|
|
@return The name of the object
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
string name() const { return "CartridgeDPCPlus"; }
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Get the byte at the specified address.
|
|
|
|
|
|
|
|
@return The byte at the specified address
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
uInt8 peek(uInt16 address);
|
2010-03-18 17:34:53 +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
|
2010-03-18 17:34:53 +00:00
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
bool poke(uInt16 address, uInt8 value);
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
Clocks the random number generator to move it to its next state
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
inline void clockRandomNumberGenerator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Clocks the random number generator to move it to its prior state
|
|
|
|
*/
|
|
|
|
inline void priorClockRandomNumberGenerator();
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Updates any data fetchers in music mode based on the number of
|
|
|
|
CPU cycles which have passed since the last update.
|
|
|
|
*/
|
2010-03-28 03:13:10 +00:00
|
|
|
inline void updateMusicModeDataFetchers();
|
2010-03-18 17:34:53 +00:00
|
|
|
|
2010-04-04 13:15:35 +00:00
|
|
|
/**
|
2010-04-25 23:33:49 +00:00
|
|
|
Call Special Functions
|
2010-04-04 13:15:35 +00:00
|
|
|
*/
|
2010-04-25 23:33:49 +00:00
|
|
|
inline void callFunction(uInt8 value);
|
2010-04-04 13:15:35 +00:00
|
|
|
|
2010-03-18 17:34:53 +00:00
|
|
|
private:
|
|
|
|
// Indicates which bank is currently active
|
|
|
|
uInt16 myCurrentBank;
|
|
|
|
|
2010-03-28 03:13:10 +00:00
|
|
|
// The 24K program ROM image of the cartridge
|
2010-03-18 17:34:53 +00:00
|
|
|
uInt8 myProgramImage[4096 * 6];
|
|
|
|
|
2010-03-28 03:13:10 +00:00
|
|
|
// The 4K display ROM image of the cartridge
|
2010-03-18 17:34:53 +00:00
|
|
|
uInt8 myDisplayImage[4096];
|
|
|
|
|
2010-03-28 03:13:10 +00:00
|
|
|
// The 1K frequency table
|
|
|
|
uInt8 myFrequencyImage[1024];
|
|
|
|
|
2010-03-18 17:34:53 +00:00
|
|
|
// Copy of the raw image, for use by getImage()
|
2010-03-28 03:13:10 +00:00
|
|
|
uInt8 myImageCopy[4096 * 6 + 4096 + 1024 + 255];
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
// The top registers for the data fetchers
|
|
|
|
uInt8 myTops[8];
|
|
|
|
|
|
|
|
// The bottom registers for the data fetchers
|
|
|
|
uInt8 myBottoms[8];
|
|
|
|
|
|
|
|
// The counter registers for the data fetchers
|
2010-04-02 18:56:50 +00:00
|
|
|
uInt16 myCounters[8];
|
2010-03-28 03:13:10 +00:00
|
|
|
|
2010-04-02 18:56:50 +00:00
|
|
|
// The counter registers for the fractional data fetchers
|
|
|
|
uInt32 myFractionalCounters[8];
|
|
|
|
|
2010-03-28 03:13:10 +00:00
|
|
|
// The fractional increments for the data fetchers
|
|
|
|
uInt8 myFractionalIncrements[8];
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
// The flag registers for the data fetchers
|
|
|
|
uInt8 myFlags[8];
|
|
|
|
|
2010-04-02 18:56:50 +00:00
|
|
|
// The Fast Fetcher Enabled flag
|
|
|
|
bool myFastFetch;
|
2010-04-03 12:45:20 +00:00
|
|
|
|
|
|
|
// Flags that last byte peeked was A9 (LDA #)
|
2010-04-02 18:56:50 +00:00
|
|
|
bool myLDAimmediate;
|
|
|
|
|
2010-04-25 23:33:49 +00:00
|
|
|
// Parameter for special functions
|
|
|
|
uInt8 myParameter;
|
2010-04-03 12:45:20 +00:00
|
|
|
|
2010-03-28 03:13:10 +00:00
|
|
|
// The music mode counters
|
2010-04-03 12:45:20 +00:00
|
|
|
uInt32 myMusicCounters[3];
|
2010-03-28 03:13:10 +00:00
|
|
|
|
2010-04-04 13:15:35 +00:00
|
|
|
// The music frequency
|
2010-04-03 12:45:20 +00:00
|
|
|
uInt32 myMusicFrequencies[3];
|
|
|
|
|
|
|
|
// The music waveforms
|
2010-04-18 15:01:38 +00:00
|
|
|
uInt16 myMusicWaveforms[3];
|
|
|
|
|
2010-03-18 17:34:53 +00:00
|
|
|
// The random number generator register
|
2010-03-28 03:13:10 +00:00
|
|
|
uInt32 myRandomNumber;
|
2010-03-18 17:34:53 +00:00
|
|
|
|
|
|
|
// System cycle count when the last update to music data fetchers occurred
|
|
|
|
Int32 mySystemCycles;
|
|
|
|
|
|
|
|
// Fractional DPC music OSC clocks unused during the last update
|
|
|
|
double myFractionalClocks;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|