diff --git a/src/emucore/tia/core_6502ts/Ball.cxx b/src/emucore/tia/core_6502ts/Ball.cxx index f22618462..084be8d10 100644 --- a/src/emucore/tia/core_6502ts/Ball.cxx +++ b/src/emucore/tia/core_6502ts/Ball.cxx @@ -131,12 +131,6 @@ void Ball::tick() myCounter = 0; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 Ball::getPixel(uInt8 colorIn) const -{ - return collision > 0 ? colorIn : myColor; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Ball::shuffleStatus() { diff --git a/src/emucore/tia/core_6502ts/Ball.hxx b/src/emucore/tia/core_6502ts/Ball.hxx index 84c28933d..aee1aadc9 100644 --- a/src/emucore/tia/core_6502ts/Ball.hxx +++ b/src/emucore/tia/core_6502ts/Ball.hxx @@ -55,7 +55,9 @@ class Ball : public Serializable void tick(); - uInt8 getPixel(uInt8 colorIn) const; + uInt8 getPixel(uInt8 colorIn) const { + return collision > 0 ? colorIn : myColor; + } void shuffleStatus(); diff --git a/src/emucore/tia/core_6502ts/LatchedInput.cxx b/src/emucore/tia/core_6502ts/LatchedInput.cxx index 1a294e35a..6c76ccf45 100644 --- a/src/emucore/tia/core_6502ts/LatchedInput.cxx +++ b/src/emucore/tia/core_6502ts/LatchedInput.cxx @@ -37,7 +37,8 @@ void LatchedInput::reset() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LatchedInput::vblank(uInt8 value) { - if (value & 0x40) myModeLatched = true; + if (value & 0x40) + myModeLatched = true; else { myModeLatched = false; myLatchedValue = 0x80; @@ -57,4 +58,4 @@ uInt8 LatchedInput::inpt(bool pinState) return value; } -} // namespace TIA6502tsCore { \ No newline at end of file +} // namespace TIA6502tsCore diff --git a/src/emucore/tia/core_6502ts/LatchedInput.hxx b/src/emucore/tia/core_6502ts/LatchedInput.hxx index 896c5523c..594dc683f 100644 --- a/src/emucore/tia/core_6502ts/LatchedInput.hxx +++ b/src/emucore/tia/core_6502ts/LatchedInput.hxx @@ -27,7 +27,6 @@ namespace TIA6502tsCore { class LatchedInput { public: - LatchedInput(); public: @@ -45,7 +44,6 @@ class LatchedInput uInt8 myLatchedValue; private: - LatchedInput(const LatchedInput&) = delete; LatchedInput(LatchedInput&&) = delete; LatchedInput& operator=(const LatchedInput&) = delete; @@ -54,4 +52,4 @@ class LatchedInput } // namespace TIA6502tsCore -#endif // TIA_6502TS_CORE_LATCHED_INPUT \ No newline at end of file +#endif // TIA_6502TS_CORE_LATCHED_INPUT diff --git a/src/emucore/tia/core_6502ts/Missile.cxx b/src/emucore/tia/core_6502ts/Missile.cxx index 59026f124..4dbbb1c48 100644 --- a/src/emucore/tia/core_6502ts/Missile.cxx +++ b/src/emucore/tia/core_6502ts/Missile.cxx @@ -142,12 +142,6 @@ void Missile::setColor(uInt8 color) myColor = color; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 Missile::getPixel(uInt8 colorIn) const -{ - return collision ? colorIn : myColor; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // TODO: implement this once the class is finalized bool Missile::save(Serializer& out) const diff --git a/src/emucore/tia/core_6502ts/Missile.hxx b/src/emucore/tia/core_6502ts/Missile.hxx index 27fa3db3f..b05fde2b4 100644 --- a/src/emucore/tia/core_6502ts/Missile.hxx +++ b/src/emucore/tia/core_6502ts/Missile.hxx @@ -55,7 +55,9 @@ class Missile : public Serializable void setColor(uInt8 color); - uInt8 getPixel(uInt8 colorIn) const; + uInt8 getPixel(uInt8 colorIn) const { + return collision ? colorIn : myColor; + } /** Serializable methods (see that class for more information). diff --git a/src/emucore/tia/core_6502ts/Player.cxx b/src/emucore/tia/core_6502ts/Player.cxx index 552d9faa1..59409c163 100644 --- a/src/emucore/tia/core_6502ts/Player.cxx +++ b/src/emucore/tia/core_6502ts/Player.cxx @@ -162,12 +162,6 @@ void Player::tick() if (++myCounter >= 160) myCounter = 0; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 Player::getPixel(uInt8 colorIn) const -{ - return collision ? colorIn : myColor; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Player::shufflePatterns() { diff --git a/src/emucore/tia/core_6502ts/Player.hxx b/src/emucore/tia/core_6502ts/Player.hxx index c2ceee7b9..ba16026fc 100644 --- a/src/emucore/tia/core_6502ts/Player.hxx +++ b/src/emucore/tia/core_6502ts/Player.hxx @@ -56,7 +56,9 @@ class Player : public Serializable void tick(); - uInt8 getPixel(uInt8 colorIn) const; + uInt8 getPixel(uInt8 colorIn) const { + return collision ? colorIn : myColor; + } void shufflePatterns(); diff --git a/src/emucore/tia/core_6502ts/Playfield.cxx b/src/emucore/tia/core_6502ts/Playfield.cxx index fc3b28cc9..9fad3b1c3 100644 --- a/src/emucore/tia/core_6502ts/Playfield.cxx +++ b/src/emucore/tia/core_6502ts/Playfield.cxx @@ -128,14 +128,6 @@ void Playfield::tick(uInt32 x) collision = currentPixel ? 0 : myCollisionMask; } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 Playfield::getPixel(uInt8 colorIn) const -{ - if (!collision) return myX < 80 ? myColorLeft : myColorRight; - - return colorIn; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Playfield::applyColors() { diff --git a/src/emucore/tia/core_6502ts/Playfield.hxx b/src/emucore/tia/core_6502ts/Playfield.hxx index d57d92bec..de95b6903 100644 --- a/src/emucore/tia/core_6502ts/Playfield.hxx +++ b/src/emucore/tia/core_6502ts/Playfield.hxx @@ -50,7 +50,10 @@ class Playfield : public Serializable void tick(uInt32 x); - uInt8 getPixel(uInt8 colorIn) const; + uInt8 getPixel(uInt8 colorIn) const { + if (!collision) return myX < 80 ? myColorLeft : myColorRight; + return colorIn; + } /** Serializable methods (see that class for more information). diff --git a/src/emucore/tia/core_6502ts/TIA.cxx b/src/emucore/tia/core_6502ts/TIA.cxx index 135c9d644..1ba0d63da 100644 --- a/src/emucore/tia/core_6502ts/TIA.cxx +++ b/src/emucore/tia/core_6502ts/TIA.cxx @@ -346,7 +346,8 @@ bool TIA::poke(uInt16 address, uInt8 value) case CTRLPF: myLinesSinceChange = 0; - myPriority = (value & 0x04) ? Priority::inverted : Priority::normal; + myPriority = (value & 0x04) ? Priority::pfp : + (value & 0x02) ? Priority::score : Priority::normal; myPlayfield.ctrlpf(value); myBall.ctrlpf(value); break; @@ -834,20 +835,55 @@ void TIA::renderPixel(uInt32 x, uInt32 y, bool lineNotCached) if (lineNotCached) { uInt8 color = myColorBk; - if (myPriority == Priority::normal) { - color = myPlayfield.getPixel(color); - color = myBall.getPixel(color); - color = myMissile1.getPixel(color); - color = myPlayer1.getPixel(color); - color = myMissile0.getPixel(color); - color = myPlayer0.getPixel(color); - } else { - color = myMissile1.getPixel(color); - color = myPlayer1.getPixel(color); - color = myMissile0.getPixel(color); - color = myPlayer0.getPixel(color); - color = myPlayfield.getPixel(color); - color = myBall.getPixel(color); + switch (myPriority) + { + // Playfield has priority so ScoreBit isn't used + // Priority from highest to lowest: + // BL/PF => P0/M0 => P1/M1 => BK + case Priority::pfp: // CTRLPF D2=1, D1=ignored + color = myMissile1.getPixel(color); + color = myPlayer1.getPixel(color); + color = myMissile0.getPixel(color); + color = myPlayer0.getPixel(color); + color = myPlayfield.getPixel(color); + color = myBall.getPixel(color); + break; + + case Priority::score: // CTRLPF D2=0, D1=1 + // Score mode left half + if (x < 80) { + // Priority from highest to lowest: + // PF/P0/M0 => P1/M1 => BL => BK + color = myBall.getPixel(color); + color = myMissile1.getPixel(color); + color = myPlayer1.getPixel(color); + color = myMissile0.getPixel(color); + color = myPlayer0.getPixel(color); + color = myPlayfield.getPixel(color); + } + else // Score mode right half + { + // Priority from highest to lowest: + // P0/M0 => PF/P1/M1 => BL => BK + color = myBall.getPixel(color); + color = myMissile1.getPixel(color); + color = myPlayer1.getPixel(color); + color = myPlayfield.getPixel(color); + color = myMissile0.getPixel(color); + color = myPlayer0.getPixel(color); + } + break; + + // Priority from highest to lowest: + // P0/M0 => P1/M1 => BL/PF => BK + case Priority::normal: // CTRLPF D2=0, D1=0 + color = myPlayfield.getPixel(color); + color = myBall.getPixel(color); + color = myMissile1.getPixel(color); + color = myPlayer1.getPixel(color); + color = myMissile0.getPixel(color); + color = myPlayer0.getPixel(color); + break; } myCurrentFrameBuffer.get()[y * 160 + x] = myFrameManager.vblank() ? 0 : color; diff --git a/src/emucore/tia/core_6502ts/TIA.hxx b/src/emucore/tia/core_6502ts/TIA.hxx index 5c3441f4c..8998756e0 100644 --- a/src/emucore/tia/core_6502ts/TIA.hxx +++ b/src/emucore/tia/core_6502ts/TIA.hxx @@ -144,7 +144,7 @@ class TIA : public AbstractTIA enum HState {blank, frame}; - enum Priority {normal, inverted}; + enum Priority {pfp, score, normal}; private: