For a change of pace from the GUI stuff, I added the ability to enable/

disable the various bits in the TIA (P0, P1, M0, M1, BL, PL).  The code
works, but isn't yet tied to a key event.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@395 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-04-21 18:55:15 +00:00
parent 93563f4929
commit 9fd0aded02
2 changed files with 62 additions and 21 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.cxx,v 1.38 2005-02-22 02:59:54 stephena Exp $ // $Id: TIA.cxx,v 1.39 2005-04-21 18:55:15 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -49,6 +49,9 @@ TIA::TIA(const Console& console, Sound& sound, Settings& settings)
myCurrentFrameBuffer = new uInt8[160 * 300]; myCurrentFrameBuffer = new uInt8[160 * 300];
myPreviousFrameBuffer = new uInt8[160 * 300]; myPreviousFrameBuffer = new uInt8[160 * 300];
for(uInt32 i = 0; i < 6; ++i)
myBitEnabled[i] = true;
for(uInt16 x = 0; x < 2; ++x) for(uInt16 x = 0; x < 2; ++x)
{ {
for(uInt16 enabled = 0; enabled < 256; ++enabled) for(uInt16 enabled = 0; enabled < 256; ++enabled)
@ -186,7 +189,6 @@ void TIA::reset()
myPOSM1 = 0; myPOSM1 = 0;
myPOSBL = 0; myPOSBL = 0;
// Some default values for the "current" variables // Some default values for the "current" variables
myCurrentGRP0 = 0; myCurrentGRP0 = 0;
myCurrentGRP1 = 0; myCurrentGRP1 = 0;
@ -202,6 +204,9 @@ void TIA::reset()
myM0CosmicArkMotionEnabled = false; myM0CosmicArkMotionEnabled = false;
myM0CosmicArkCounter = 0; myM0CosmicArkCounter = 0;
for(uInt32 i = 0; i < 6; ++i)
myBitEnabled[i] = true;
myDumpEnabled = false; myDumpEnabled = false;
myDumpDisabledCycle = 0; myDumpDisabledCycle = 0;
@ -358,6 +363,11 @@ bool TIA::save(Serializer& out)
out.putBool(myM0CosmicArkMotionEnabled); out.putBool(myM0CosmicArkMotionEnabled);
out.putLong(myM0CosmicArkCounter); out.putLong(myM0CosmicArkCounter);
// There are currently six bits defined in TIABit
out.putLong(6);
for(uInt32 i = 0; i < 6; ++i)
out.putBool(myBitEnabled[i]);
out.putBool(myDumpEnabled); out.putBool(myDumpEnabled);
out.putLong(myDumpDisabledCycle); out.putLong(myDumpDisabledCycle);
@ -454,6 +464,11 @@ bool TIA::load(Deserializer& in)
myM0CosmicArkMotionEnabled = in.getBool(); myM0CosmicArkMotionEnabled = in.getBool();
myM0CosmicArkCounter = (uInt32) in.getLong(); myM0CosmicArkCounter = (uInt32) in.getLong();
// We abuse the concept of 'enum' here
uInt32 limit = (uInt32) in.getLong();
for(uInt32 i = 0; i < limit; ++i)
myBitEnabled[i] = in.getBool();
myDumpEnabled = in.getBool(); myDumpEnabled = in.getBool();
myDumpDisabledCycle = (Int32) in.getLong(); myDumpDisabledCycle = (Int32) in.getLong();
@ -2150,10 +2165,10 @@ void TIA::poke(uInt16 addr, uInt8 value)
{ {
myPF = (myPF & 0x000FFFF0) | ((value >> 4) & 0x0F); myPF = (myPF & 0x000FFFF0) | ((value >> 4) & 0x0F);
if(myPF != 0) if(!myBitEnabled[TIA::PF] || myPF == 0)
myEnabledObjects |= myPFBit;
else
myEnabledObjects &= ~myPFBit; myEnabledObjects &= ~myPFBit;
else
myEnabledObjects |= myPFBit;
break; break;
} }
@ -2162,10 +2177,10 @@ void TIA::poke(uInt16 addr, uInt8 value)
{ {
myPF = (myPF & 0x000FF00F) | ((uInt32)value << 4); myPF = (myPF & 0x000FF00F) | ((uInt32)value << 4);
if(myPF != 0) if(!myBitEnabled[TIA::PF] || myPF == 0)
myEnabledObjects |= myPFBit;
else
myEnabledObjects &= ~myPFBit; myEnabledObjects &= ~myPFBit;
else
myEnabledObjects |= myPFBit;
break; break;
} }
@ -2174,10 +2189,10 @@ void TIA::poke(uInt16 addr, uInt8 value)
{ {
myPF = (myPF & 0x00000FFF) | ((uInt32)value << 12); myPF = (myPF & 0x00000FFF) | ((uInt32)value << 12);
if(myPF != 0) if(!myBitEnabled[TIA::PF] || myPF == 0)
myEnabledObjects |= myPFBit;
else
myEnabledObjects &= ~myPFBit; myEnabledObjects &= ~myPFBit;
else
myEnabledObjects |= myPFBit;
break; break;
} }
@ -2385,7 +2400,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
case 0x1B: // Graphics Player 0 case 0x1B: // Graphics Player 0
{ {
// Set player 0 graphics // Set player 0 graphics
myGRP0 = value; myGRP0 = (myBitEnabled[TIA::P0] ? value : 0);
// Copy player 1 graphics into its delayed register // Copy player 1 graphics into its delayed register
myDGRP1 = myGRP1; myDGRP1 = myGRP1;
@ -2415,7 +2430,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
case 0x1C: // Graphics Player 1 case 0x1C: // Graphics Player 1
{ {
// Set player 1 graphics // Set player 1 graphics
myGRP1 = value; myGRP1 = (myBitEnabled[TIA::P1] ? value : 0);
// Copy player 0 graphics into its delayed register // Copy player 0 graphics into its delayed register
myDGRP0 = myGRP0; myDGRP0 = myGRP0;
@ -2450,9 +2465,9 @@ void TIA::poke(uInt16 addr, uInt8 value)
break; break;
} }
case 0x1D: // Enable Missle 0 graphics case 0x1D: // Enable Missile 0 graphics
{ {
myENAM0 = value & 0x02; myENAM0 = (myBitEnabled[TIA::M0] ? value & 0x02 : 0);
if(myENAM0 && !myRESMP0) if(myENAM0 && !myRESMP0)
myEnabledObjects |= myM0Bit; myEnabledObjects |= myM0Bit;
@ -2461,9 +2476,9 @@ void TIA::poke(uInt16 addr, uInt8 value)
break; break;
} }
case 0x1E: // Enable Missle 1 graphics case 0x1E: // Enable Missile 1 graphics
{ {
myENAM1 = value & 0x02; myENAM1 = (myBitEnabled[TIA::M1] ? value & 0x02 : 0);
if(myENAM1 && !myRESMP1) if(myENAM1 && !myRESMP1)
myEnabledObjects |= myM1Bit; myEnabledObjects |= myM1Bit;
@ -2474,7 +2489,7 @@ void TIA::poke(uInt16 addr, uInt8 value)
case 0x1F: // Enable Ball graphics case 0x1F: // Enable Ball graphics
{ {
myENABL = value & 0x02; myENABL = (myBitEnabled[TIA::BL] ? value & 0x02 : 0);
if(myVDELBL ? myDENABL : myENABL) if(myVDELBL ? myDENABL : myENABL)
myEnabledObjects |= myBLBit; myEnabledObjects |= myBLBit;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: TIA.hxx,v 1.16 2005-02-21 20:43:25 stephena Exp $ // $Id: TIA.hxx,v 1.17 2005-04-21 18:55:15 stephena Exp $
//============================================================================ //============================================================================
#ifndef TIA_HXX #ifndef TIA_HXX
@ -42,7 +42,7 @@ class Settings;
be displayed on screen. be displayed on screen.
@author Bradford W. Mott @author Bradford W. Mott
@version $Id: TIA.hxx,v 1.16 2005-02-21 20:43:25 stephena Exp $ @version $Id: TIA.hxx,v 1.17 2005-04-21 18:55:15 stephena Exp $
*/ */
class TIA : public Device , public MediaSource class TIA : public Device , public MediaSource
{ {
@ -171,6 +171,29 @@ class TIA : public Device , public MediaSource
*/ */
uInt32 scanlines() const; uInt32 scanlines() const;
enum TIABit {
P0, // Descriptor for Player 0 Bit
M0, // Descriptor for Missle 0 Bit
P1, // Descriptor for Player 1 Bit
M1, // Descriptor for Missle 1 Bit
BL, // Descriptor for Ball Bit
PF // Descriptor for Playfield Bit
};
/**
Enables/disables the specified TIA bit.
@return Whether the bit was enabled or disabled
*/
bool enableBit(TIABit b, bool mode) { myBitEnabled[b] = mode; return mode; }
/**
Toggles the specified TIA bit.
@return Whether the bit was enabled or disabled
*/
bool toggleBit(TIABit b) { myBitEnabled[b] = !myBitEnabled[b]; return myBitEnabled[b]; }
private: private:
// Compute the ball mask table // Compute the ball mask table
void computeBallMaskTable(); void computeBallMaskTable();
@ -313,7 +336,7 @@ class TIA : public Device , public MediaSource
bool myREFP0; // Indicates if player 0 is being reflected bool myREFP0; // Indicates if player 0 is being reflected
bool myREFP1; // Indicates if player 1 is being reflected bool myREFP1; // Indicates if player 1 is being reflected
uInt32 myPF; // Playfield graphics (19-12:PF2 11-4:PF1 3-0:PF0) uInt32 myPF; // Playfield graphics (19-12:PF2 11-4:PF1 3-0:PF0)
uInt8 myGRP0; // Player 0 graphics register uInt8 myGRP0; // Player 0 graphics register
uInt8 myGRP1; // Player 1 graphics register uInt8 myGRP1; // Player 1 graphics register
@ -404,6 +427,9 @@ class TIA : public Device , public MediaSource
// Counter used for TIA M0 "bug" // Counter used for TIA M0 "bug"
uInt32 myM0CosmicArkCounter; uInt32 myM0CosmicArkCounter;
// Answers whether specified bits (from TIABit) are enabled or disabled
bool myBitEnabled[6];
private: private:
// Ball mask table (entries are true or false) // Ball mask table (entries are true or false)
static uInt8 ourBallMaskTable[4][4][320]; static uInt8 ourBallMaskTable[4][4][320];