Re-enable fixed debug colors.

This commit is contained in:
Stephen Anthony 2016-12-04 14:48:17 -03:30
parent 9ca6f89778
commit c526d260a0
13 changed files with 362 additions and 37 deletions

View File

@ -0,0 +1,102 @@
//
// 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-2016 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 "Background.hxx"
namespace TIA6502tsCore {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Background::Background()
{
reset();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Background::reset()
{
myColor = myObjectColor = myDebugColor = 0;
myDebugEnabled = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Background::setColor(uInt8 color)
{
myObjectColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Background::setDebugColor(uInt8 color)
{
myDebugColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Background::enableDebugColors(bool enabled)
{
myDebugEnabled = enabled;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Background::applyColors()
{
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: implement this once the class is finalized
bool Background::save(Serializer& out) const
{
try
{
out.putString(name());
// TODO - save instance variables
}
catch(...)
{
cerr << "ERROR: TIA_BK::save" << endl;
return false;
}
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: implement this once the class is finalized
bool Background::load(Serializer& in)
{
try
{
if(in.getString() != name())
return false;
// TODO - load instance variables
}
catch(...)
{
cerr << "ERROR: TIA_BK::load" << endl;
return false;
}
return false;
}
} // namespace TIA6502tsCore

View File

@ -0,0 +1,66 @@
//============================================================================
//
// 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-2016 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 TIA_6502TS_CORE_BACKGROUND
#define TIA_6502TS_CORE_BACKGROUND
#include "Serializable.hxx"
#include "bspf.hxx"
namespace TIA6502tsCore {
class Background : public Serializable
{
public:
Background();
public:
void reset();
void setColor(uInt8 color);
void setDebugColor(uInt8 color);
void enableDebugColors(bool enabled);
uInt8 getColor() const { return myColor; }
/**
Serializable methods (see that class for more information).
*/
bool save(Serializer& out) const override;
bool load(Serializer& in) override;
string name() const override { return "TIA_BK"; }
private:
void applyColors();
private:
uInt8 myColor;
uInt8 myObjectColor, myDebugColor;
bool myDebugEnabled;
private:
Background(const Background&) = delete;
Background(Background&&) = delete;
Background& operator=(const Background&) = delete;
Background& operator=(Background&&);
};
} // namespace TIA6502tsCore
#endif // TIA_6502TS_CORE_BACKGROUND

View File

@ -36,7 +36,7 @@ Ball::Ball(uInt32 collisionMask)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::reset()
{
myColor = 0;
myColor = myObjectColor = myDebugColor = 0;
collision = myCollisionMaskDisabled;
myIsEnabledOld = false;
myIsEnabledNew = false;
@ -47,9 +47,11 @@ void Ball::reset()
myIsMoving = false;
myWidth = 1;
myIsRendering = false;
myDebugEnabled = false;
myRenderCounter = 0;
updateEnabled();
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -99,14 +101,28 @@ void Ball::toggleCollisions(bool enabled)
void Ball::toggleEnabled(bool enabled)
{
myIsSuppressed = !enabled;
updateEnabled();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::setColor(uInt8 color)
{
myColor = color;
myObjectColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::setDebugColor(uInt8 color)
{
myDebugColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::enableDebugColors(bool enabled)
{
myDebugEnabled = enabled;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -163,6 +179,12 @@ void Ball::updateEnabled()
myIsEnabled = !myIsSuppressed && (myIsDelaying ? myIsEnabledOld : myIsEnabledNew);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::applyColors()
{
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: implement this once the class is finalized
bool Ball::save(Serializer& out) const

View File

@ -51,6 +51,9 @@ class Ball : public Serializable
void setColor(uInt8 color);
void setDebugColor(uInt8 color);
void enableDebugColors(bool enabled);
void startMovement();
bool movementTick(uInt32 clock, bool apply);
@ -79,6 +82,7 @@ class Ball : public Serializable
private:
void updateEnabled();
void applyColors();
private:
@ -86,6 +90,8 @@ class Ball : public Serializable
uInt32 myCollisionMaskEnabled;
uInt8 myColor;
uInt8 myObjectColor, myDebugColor;
bool myDebugEnabled;
bool myIsEnabledOld;
bool myIsEnabledNew;
@ -102,7 +108,6 @@ class Ball : public Serializable
Int8 myRenderCounter;
private:
Ball() = delete;
Ball(const Ball&) = delete;
Ball(Ball&&) = delete;

View File

@ -48,7 +48,8 @@ void Missile::reset()
myWidth = 1;
myIsRendering = false;
myRenderCounter = 0;
myColor = 0;
myColor = myObjectColor = myDebugColor = 0;
myDebugEnabled = false;
collision = myCollisionMaskDisabled;
updateEnabled();
@ -78,11 +79,13 @@ void Missile::resmp(uInt8 value, const Player& player)
{
const uInt8 resmp = value & 0x02;
if (resmp == myResmp) return;
if (resmp == myResmp)
return;
myResmp = resmp;
if (!myResmp) myCounter = player.getRespClock();
if (!myResmp)
myCounter = player.getRespClock();
updateEnabled();
}
@ -155,7 +158,22 @@ void Missile::tick()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::setColor(uInt8 color)
{
myColor = color;
myObjectColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::setDebugColor(uInt8 color)
{
myDebugColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::enableDebugColors(bool enabled)
{
myDebugEnabled = enabled;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -164,6 +182,12 @@ void Missile::updateEnabled()
myIsEnabled = !myIsSuppressed && myEnam && !myResmp;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::applyColors()
{
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: implement this once the class is finalized
bool Missile::save(Serializer& out) const

View File

@ -55,6 +55,9 @@ class Missile : public Serializable
void setColor(uInt8 color);
void setDebugColor(uInt8 color);
void enableDebugColors(bool enabled);
void toggleCollisions(bool enabled);
void toggleEnabled(bool enabled);
@ -77,6 +80,7 @@ class Missile : public Serializable
private:
void updateEnabled();
void applyColors();
private:
@ -99,6 +103,8 @@ class Missile : public Serializable
const uInt8* myDecodes;
uInt8 myColor;
uInt8 myObjectColor, myDebugColor;
bool myDebugEnabled;
private:
Missile(const Missile&) = delete;

View File

@ -50,6 +50,8 @@ void Player::reset()
myPattern = 0;
myIsReflected = 0;
myIsDelaying = false;
myColor = myObjectColor = myDebugColor = 0;
myDebugEnabled = false;
collision = myCollisionMaskDisabled;
updatePattern();
@ -132,7 +134,22 @@ void Player::toggleCollisions(bool enabled)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::setColor(uInt8 color)
{
myColor = color;
myObjectColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::setDebugColor(uInt8 color)
{
myDebugColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::enableDebugColors(bool enabled)
{
myDebugEnabled = enabled;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -214,7 +231,7 @@ void Player::updatePattern()
if (myIsSuppressed) {
myPattern = 0;
return;
}
}
const uInt32 pattern = myIsDelaying ? myPatternOld : myPatternNew;
@ -286,6 +303,12 @@ void Player::updatePattern()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::applyColors()
{
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: implement this once the class is finalized
bool Player::save(Serializer& out) const

View File

@ -52,6 +52,9 @@ class Player : public Serializable
void setColor(uInt8 color);
void setDebugColor(uInt8 color);
void enableDebugColors(bool enabled);
void startMovement();
bool movementTick(uInt32 clock, bool apply);
@ -82,12 +85,15 @@ class Player : public Serializable
private:
void updatePattern();
void applyColors();
private:
uInt32 myCollisionMaskDisabled;
uInt32 myCollisionMaskEnabled;
uInt8 myColor;
uInt8 myObjectColor, myDebugColor;
bool myDebugEnabled;
bool myIsSuppressed;

View File

@ -41,10 +41,11 @@ void Playfield::reset()
myPf1 = 0;
myPf2 = 0;
myColor = 0;
myObjectColor = myDebugColor = 0;
myColorP0 = 0;
myColorP1 = 0;
myColorMode = ColorMode::normal;
myDebugEnabled = false;
collision = 0;
@ -109,7 +110,7 @@ void Playfield::toggleCollisions(bool enabled)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Playfield::setColor(uInt8 color)
{
myColor = color;
myObjectColor = color;
applyColors();
}
@ -127,6 +128,20 @@ void Playfield::setColorP1(uInt8 color)
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Playfield::setDebugColor(uInt8 color)
{
myDebugColor = color;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Playfield::enableDebugColors(bool enabled)
{
myDebugEnabled = enabled;
applyColors();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Playfield::tick(uInt32 x)
{
@ -154,10 +169,14 @@ void Playfield::tick(uInt32 x)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Playfield::applyColors()
{
if (myDebugEnabled)
myColorLeft = myColorRight = myDebugColor;
else
{
switch (myColorMode)
{
case ColorMode::normal:
myColorLeft = myColorRight = myColor;
myColorLeft = myColorRight = myObjectColor;
break;
case ColorMode::score:
@ -165,6 +184,7 @@ void Playfield::applyColors()
myColorRight = myColorP1;
break;
}
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -52,6 +52,9 @@ class Playfield : public Serializable
void setColorP1(uInt8 color);
void setDebugColor(uInt8 color);
void enableDebugColors(bool enabled);
void tick(uInt32 x);
uInt8 getPixel(uInt8 colorIn) const {
@ -90,7 +93,9 @@ class Playfield : public Serializable
uInt8 myColorRight;
uInt8 myColorP0;
uInt8 myColorP1;
uInt8 myColor;
uInt8 myObjectColor, myDebugColor;
bool myDebugEnabled;
ColorMode myColorMode;
uInt32 myPattern;

View File

@ -97,11 +97,12 @@ void TIA::reset()
myCollisionMask = 0;
myLinesSinceChange = 0;
myCollisionUpdateRequired = false;
myColorBk = 0;
myColorHBlank = 0;
myLastCycle = 0;
mySubClock = 0;
myBackground.reset();
myPlayfield.reset();
myMissile0.reset();
myMissile1.reset();
@ -119,6 +120,8 @@ void TIA::reset()
mySound.reset();
myDelayQueue.reset();
myFrameManager.reset();
toggleFixedColors(0); // Turn off debug colours
frameReset(); // Recalculate the size of the display
}
@ -128,7 +131,7 @@ void TIA::frameReset()
// Clear frame buffers
clearBuffers();
// TODO - make use of ystart and height
// TODO - make use of ystart and height, maybe move to FrameManager
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -370,7 +373,7 @@ bool TIA::poke(uInt16 address, uInt8 value)
case COLUBK:
myLinesSinceChange = 0;
myColorBk = value & 0xFE;
myBackground.setColor(value & 0xFE);
break;
case COLUP0:
@ -724,10 +727,31 @@ bool TIA::toggleCollisions()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO: stub
bool TIA::toggleFixedColors(uInt8 mode)
{
return false;
// If mode is 0 or 1, use it as a boolean (off or on)
// Otherwise, flip the state
bool on = (mode == 0 || mode == 1) ? bool(mode) : myColorHBlank == 0;
bool pal = isPAL();
myMissile0.setDebugColor(pal ? M0ColorPAL : M0ColorNTSC);
myMissile1.setDebugColor(pal ? M1ColorPAL : M1ColorNTSC);
myPlayer0.setDebugColor(pal ? P0ColorPAL : P0ColorNTSC);
myPlayer1.setDebugColor(pal ? P1ColorPAL : P1ColorNTSC);
myBall.setDebugColor(pal ? BLColorPAL : BLColorNTSC);
myPlayfield.setDebugColor(pal ? PFColorPAL : PFColorNTSC);
myBackground.setDebugColor(pal ? BKColorPAL : BKColorNTSC);
myMissile0.enableDebugColors(on);
myMissile1.enableDebugColors(on);
myPlayer0.enableDebugColors(on);
myPlayer1.enableDebugColors(on);
myBall.enableDebugColors(on);
myPlayfield.enableDebugColors(on);
myBackground.enableDebugColors(on);
myColorHBlank = on ? HBLANKColor : 0x00;
return on;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -735,7 +759,7 @@ bool TIA::driveUnusedPinsRandom(uInt8 mode)
{
// If mode is 0 or 1, use it as a boolean (off or on)
// Otherwise, return the state
if(mode == 0 || mode == 1)
if (mode == 0 || mode == 1)
{
myTIAPinsDriven = bool(mode);
mySettings.setValue("tiadriven", myTIAPinsDriven);
@ -905,7 +929,7 @@ void TIA::updateCollision()
void TIA::renderPixel(uInt32 x, uInt32 y, bool lineNotCached)
{
if (lineNotCached) {
uInt8 color = myColorBk;
uInt8 color = myBackground.getColor();
switch (myPriority)
{
@ -959,7 +983,8 @@ void TIA::renderPixel(uInt32 x, uInt32 y, bool lineNotCached)
void TIA::clearHmoveComb()
{
if (myFrameManager.isRendering() && myHstate == HState::blank)
memset(myCurrentFrameBuffer.get() + myFrameManager.currentLine() * 160, 0, 8);
memset(myCurrentFrameBuffer.get() + myFrameManager.currentLine() * 160,
myColorHBlank, 8);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -27,6 +27,7 @@
#include "TIATypes.hxx"
#include "DelayQueue.hxx"
#include "FrameManager.hxx"
#include "Background.hxx"
#include "Playfield.hxx"
#include "Missile.hxx"
#include "Player.hxx"
@ -179,6 +180,24 @@ class TIA : public AbstractTIA
enum HState {blank, frame};
enum Priority {pfp, score, normal};
enum FixedColors {
P0ColorNTSC = 0x30,
P1ColorNTSC = 0x16,
M0ColorNTSC = 0x38,
M1ColorNTSC = 0x12,
BLColorNTSC = 0x7e,
PFColorNTSC = 0x76,
BKColorNTSC = 0x0a,
P0ColorPAL = 0x62,
P1ColorPAL = 0x26,
M0ColorPAL = 0x68,
M1ColorPAL = 0x2e,
BLColorPAL = 0xde,
PFColorPAL = 0xd8,
BKColorPAL = 0x1c,
HBLANKColor = 0x0e
};
private:
void updateEmulation();
@ -245,7 +264,7 @@ class TIA : public AbstractTIA
uInt8 mySpriteEnabledBits;
uInt8 myCollisionsEnabledBits;
uInt8 myColorBk;
uInt8 myColorHBlank;
double myTimestamp;
@ -253,6 +272,7 @@ class TIA : public AbstractTIA
BytePtr myCurrentFrameBuffer;
BytePtr myPreviousFrameBuffer;
Background myBackground;
Playfield myPlayfield;
Missile myMissile0;
Missile myMissile1;

View File

@ -10,6 +10,7 @@ MODULE_OBJS := \
src/emucore/tia/core_6502ts/Missile.o \
src/emucore/tia/core_6502ts/Player.o \
src/emucore/tia/core_6502ts/Ball.o \
src/emucore/tia/core_6502ts/Background.o \
src/emucore/tia/core_6502ts/LatchedInput.o \
src/emucore/tia/core_6502ts/PaddleReader.o