Better naming, implement player position setters

This commit is contained in:
Christian Speckner 2017-03-29 22:02:15 +02:00
parent a7fc82cbea
commit d00698c3e4
6 changed files with 24 additions and 19 deletions

View File

@ -549,10 +549,8 @@ uInt8 TIADebug::grP1(int newVal)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::posP0(int newVal)
{
#if 0 // FIXME
if(newVal > -1)
myTIA.myPOSP0 = newVal;
#endif
myTIA.myPlayer0.setPosition(newVal);
return myTIA.myPlayer0.getPosition();
}
@ -560,10 +558,8 @@ uInt8 TIADebug::posP0(int newVal)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::posP1(int newVal)
{
#if 0 // FIXME
if(newVal > -1)
myTIA.myPOSP1 = newVal;
#endif
myTIA.myPlayer1.setPosition(newVal);
return myTIA.myPlayer1.getPosition();
}

View File

@ -369,7 +369,15 @@ uInt8 Player::getPosition() const
const uInt8 shift = myDivider == 1 ? 0 : 1;
// Mind the sign of renderCounterOffset: it's defined negative above
return (316 - myCounter - Count::renderCounterOffset + shift + myPositioningProvider->getPosition()) % 160;
return (316 - myCounter - Count::renderCounterOffset + shift + myPlayfieldPositionProvider->getPosition()) % 160;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Player::setPosition(uInt8 newPosition)
{
const uInt8 shift = myDivider == 1 ? 0 : 1;
myCounter = (316 - newPosition - Count::renderCounterOffset + shift + myPlayfieldPositionProvider->getPosition()) % 160;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -20,7 +20,7 @@
#include "bspf.hxx"
#include "Serializable.hxx"
#include "PositioningProvider.hxx"
#include "PlayfieldPositionProvider.hxx"
class Player : public Serializable
{
@ -29,8 +29,8 @@ class Player : public Serializable
public:
void setPositioningProvider(PositioningProvider* positioningProvider) {
myPositioningProvider = positioningProvider;
void setPlayfieldPositionProvider(PlayfieldPositionProvider* playfieldPositionProvider) {
myPlayfieldPositionProvider = playfieldPositionProvider;
}
void reset();
@ -74,6 +74,7 @@ class Player : public Serializable
uInt8 getRespClock() const;
uInt8 getPosition() const;
void setPosition(uInt8 newPosition);
/**
Serializable methods (see that class for more information).
@ -125,7 +126,7 @@ class Player : public Serializable
bool myIsReflected;
bool myIsDelaying;
PositioningProvider *myPositioningProvider;
PlayfieldPositionProvider *myPlayfieldPositionProvider;
private:
Player(const Player&) = delete;

View File

@ -15,8 +15,8 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef TIA_POSITIONING_PROVIDER
#define TIA_POSITIONING_PROVIDER
#ifndef TIA_PLAYFIELD_PROVIDER
#define TIA_PLAYFIELD_PROVIDER
#include "bspf.hxx"
@ -27,7 +27,7 @@
@author Christian Speckner (DirtyHairy) and Stephen Anthony
*/
class PositioningProvider
class PlayfieldPositionProvider
{
public:
@ -38,7 +38,7 @@ class PositioningProvider
protected:
~PositioningProvider() = default;
~PlayfieldPositionProvider() = default;
};

View File

@ -95,8 +95,8 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings)
myTIAPinsDriven = mySettings.getBool("tiadriven");
myPlayer0.setPositioningProvider(this);
myPlayer1.setPositioningProvider(this);
myPlayer0.setPlayfieldPositionProvider(this);
myPlayer1.setPlayfieldPositionProvider(this);
reset();
}

View File

@ -35,7 +35,7 @@
#include "Ball.hxx"
#include "LatchedInput.hxx"
#include "PaddleReader.hxx"
#include "PositioningProvider.hxx"
#include "PlayfieldPositionProvider.hxx"
/**
This class is a device that emulates the Television Interface Adaptor
@ -50,7 +50,7 @@
@author Christian Speckner (DirtyHairy) and Stephen Anthony
*/
class TIA : public Device, public PositioningProvider
class TIA : public Device, public PlayfieldPositionProvider
{
public:
friend class TIADebug;