Positioning for missiles and ball.

This commit is contained in:
Christian Speckner 2017-03-29 22:53:42 +02:00
parent d00698c3e4
commit 988b36010b
6 changed files with 56 additions and 15 deletions

View File

@ -567,37 +567,28 @@ uInt8 TIADebug::posP1(int newVal)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::posM0(int newVal)
{
#if 0 // FIXME
if(newVal > -1)
myTIA.myPOSM0 = newVal;
myTIA.myMissile0.setPosition(newVal);
return myTIA.myPOSM0;
#endif
return 0;
return myTIA.myMissile0.getPosition();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::posM1(int newVal)
{
#if 0 // FIXME
if(newVal > -1)
myTIA.myPOSM1 = newVal;
myTIA.myMissile1.setPosition(newVal);
return myTIA.myPOSM1;
#endif
return 0;
return myTIA.myMissile1.getPosition();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 TIADebug::posBL(int newVal)
{
#if 0 // FIXME
if(newVal > -1)
myTIA.myPOSBL = newVal;
myTIA.myBall.setPosition(newVal);
return myTIA.myPOSBL;
#endif
return 0;
return myTIA.myBall.getPosition();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -205,6 +205,19 @@ void Ball::applyColors()
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Ball::getPosition() const
{
// Mind the sign of renderCounterOffset: it's defined negative above
return (316 - myCounter - Count::renderCounterOffset + myPlayfieldPositionProvider->getPosition()) % 160;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Ball::setPosition(uInt8 newPosition)
{
myCounter = (316 - newPosition - Count::renderCounterOffset + myPlayfieldPositionProvider->getPosition()) % 160;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Ball::save(Serializer& out) const
{

View File

@ -20,6 +20,7 @@
#include "Serializable.hxx"
#include "bspf.hxx"
#include "PlayfieldPositionProvider.hxx"
class Ball : public Serializable
{
@ -29,6 +30,10 @@ class Ball : public Serializable
public:
void setPlayfieldPositionProvider(PlayfieldPositionProvider* playfieldPositionProvider) {
myPlayfieldPositionProvider = playfieldPositionProvider;
}
void reset();
void enabl(uInt8 value);
@ -64,6 +69,9 @@ class Ball : public Serializable
void shuffleStatus();
uInt8 getPosition() const;
void setPosition(uInt8 newPosition);
/**
Serializable methods (see that class for more information).
*/
@ -105,6 +113,8 @@ class Ball : public Serializable
bool myIsRendering;
Int8 myRenderCounter;
PlayfieldPositionProvider* myPlayfieldPositionProvider;
private:
Ball() = delete;
Ball(const Ball&) = delete;

View File

@ -244,6 +244,19 @@ void Missile::applyColors()
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Missile::getPosition() const
{
// Mind the sign of renderCounterOffset: it's defined negative above
return (316 - myCounter - Count::renderCounterOffset + myPlayfieldPositionProvider->getPosition()) % 160;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Missile::setPosition(uInt8 newPosition)
{
myCounter = (316 - newPosition - Count::renderCounterOffset + myPlayfieldPositionProvider->getPosition()) % 160;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Missile::save(Serializer& out) const
{

View File

@ -21,14 +21,20 @@
#include "Serializable.hxx"
#include "bspf.hxx"
#include "Player.hxx"
#include "PlayfieldPositionProvider.hxx"
class Missile : public Serializable
{
public:
Missile(uInt32 collisionMask);
public:
void setPlayfieldPositionProvider(PlayfieldPositionProvider* playfieldPositionProvider) {
myPlayfieldPositionProvider = playfieldPositionProvider;
}
void reset();
void enam(uInt8 value);
@ -62,6 +68,9 @@ class Missile : public Serializable
return (collision & 0x8000) ? myColor : colorIn;
}
uInt8 getPosition() const;
void setPosition(uInt8 newPosition);
/**
Serializable methods (see that class for more information).
*/
@ -105,6 +114,8 @@ class Missile : public Serializable
uInt8 myObjectColor, myDebugColor;
bool myDebugEnabled;
PlayfieldPositionProvider *myPlayfieldPositionProvider;
private:
Missile(const Missile&) = delete;
Missile(Missile&&) = delete;

View File

@ -97,6 +97,9 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings)
myPlayer0.setPlayfieldPositionProvider(this);
myPlayer1.setPlayfieldPositionProvider(this);
myMissile0.setPlayfieldPositionProvider(this);
myMissile1.setPlayfieldPositionProvider(this);
myBall.setPlayfieldPositionProvider(this);
reset();
}