mirror of https://github.com/stella-emu/stella.git
Position readout for players.
This commit is contained in:
parent
f1eb76303c
commit
a7fc82cbea
|
@ -552,10 +552,9 @@ uInt8 TIADebug::posP0(int newVal)
|
||||||
#if 0 // FIXME
|
#if 0 // FIXME
|
||||||
if(newVal > -1)
|
if(newVal > -1)
|
||||||
myTIA.myPOSP0 = newVal;
|
myTIA.myPOSP0 = newVal;
|
||||||
|
|
||||||
return myTIA.myPOSP0;
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
|
||||||
|
return myTIA.myPlayer0.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -564,10 +563,9 @@ uInt8 TIADebug::posP1(int newVal)
|
||||||
#if 0 // FIXME
|
#if 0 // FIXME
|
||||||
if(newVal > -1)
|
if(newVal > -1)
|
||||||
myTIA.myPOSP1 = newVal;
|
myTIA.myPOSP1 = newVal;
|
||||||
|
|
||||||
return myTIA.myPOSP1;
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
|
||||||
|
return myTIA.myPlayer1.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -363,6 +363,15 @@ void Player::applyColors()
|
||||||
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
|
myColor = myDebugEnabled ? myDebugColor : myObjectColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool Player::save(Serializer& out) const
|
bool Player::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
#ifndef TIA_PLAYER
|
#ifndef TIA_PLAYER
|
||||||
#define TIA_PLAYER
|
#define TIA_PLAYER
|
||||||
|
|
||||||
#include "Serializable.hxx"
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
#include "Serializable.hxx"
|
||||||
|
#include "PositioningProvider.hxx"
|
||||||
|
|
||||||
class Player : public Serializable
|
class Player : public Serializable
|
||||||
{
|
{
|
||||||
|
@ -28,6 +29,10 @@ class Player : public Serializable
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void setPositioningProvider(PositioningProvider* positioningProvider) {
|
||||||
|
myPositioningProvider = positioningProvider;
|
||||||
|
}
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void grp(uInt8 value);
|
void grp(uInt8 value);
|
||||||
|
@ -68,6 +73,8 @@ class Player : public Serializable
|
||||||
|
|
||||||
uInt8 getRespClock() const;
|
uInt8 getRespClock() const;
|
||||||
|
|
||||||
|
uInt8 getPosition() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Serializable methods (see that class for more information).
|
Serializable methods (see that class for more information).
|
||||||
*/
|
*/
|
||||||
|
@ -118,6 +125,8 @@ class Player : public Serializable
|
||||||
bool myIsReflected;
|
bool myIsReflected;
|
||||||
bool myIsDelaying;
|
bool myIsDelaying;
|
||||||
|
|
||||||
|
PositioningProvider *myPositioningProvider;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Player(const Player&) = delete;
|
Player(const Player&) = delete;
|
||||||
Player(Player&&) = delete;
|
Player(Player&&) = delete;
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// 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-2017 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.
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
#ifndef TIA_POSITIONING_PROVIDER
|
||||||
|
#define TIA_POSITIONING_PROVIDER
|
||||||
|
|
||||||
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is an abstract interface class that provides a subset of TIA
|
||||||
|
functionality for sprite positioning while avoiding circular dependencies
|
||||||
|
between TIA and sprites.
|
||||||
|
|
||||||
|
@author Christian Speckner (DirtyHairy) and Stephen Anthony
|
||||||
|
*/
|
||||||
|
class PositioningProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the current x value
|
||||||
|
*/
|
||||||
|
virtual uInt8 getPosition() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
~PositioningProvider() = default;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIA_POSITIONING_PROVIDER
|
|
@ -95,6 +95,9 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings)
|
||||||
|
|
||||||
myTIAPinsDriven = mySettings.getBool("tiadriven");
|
myTIAPinsDriven = mySettings.getBool("tiadriven");
|
||||||
|
|
||||||
|
myPlayer0.setPositioningProvider(this);
|
||||||
|
myPlayer1.setPositioningProvider(this);
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "Ball.hxx"
|
#include "Ball.hxx"
|
||||||
#include "LatchedInput.hxx"
|
#include "LatchedInput.hxx"
|
||||||
#include "PaddleReader.hxx"
|
#include "PaddleReader.hxx"
|
||||||
|
#include "PositioningProvider.hxx"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class is a device that emulates the Television Interface Adaptor
|
This class is a device that emulates the Television Interface Adaptor
|
||||||
|
@ -49,7 +50,7 @@
|
||||||
|
|
||||||
@author Christian Speckner (DirtyHairy) and Stephen Anthony
|
@author Christian Speckner (DirtyHairy) and Stephen Anthony
|
||||||
*/
|
*/
|
||||||
class TIA : public Device
|
class TIA : public Device, public PositioningProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
friend class TIADebug;
|
friend class TIADebug;
|
||||||
|
@ -308,9 +309,16 @@ class TIA : public Device
|
||||||
*/
|
*/
|
||||||
void updateScanlineByTrace(int target);
|
void updateScanlineByTrace(int target);
|
||||||
|
|
||||||
// Retrieve the last value written to a certain register
|
/**
|
||||||
|
Retrieve the last value written to a certain register
|
||||||
|
*/
|
||||||
uInt8 lastValueWrittenToRegister(uInt8 reg) const;
|
uInt8 lastValueWrittenToRegister(uInt8 reg) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the current x value
|
||||||
|
*/
|
||||||
|
virtual uInt8 getPosition() {return (myHctr < 68) ? 0 : (myHctr - 68 - myXDelta);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Save the current state of this device to the given Serializer.
|
Save the current state of this device to the given Serializer.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue