mirror of https://github.com/stella-emu/stella.git
In the TIA class, isolate developer settings and re-apply them on each state load.
Eliminates saving of certain variables into the state file which really don't belong there.
This commit is contained in:
parent
ea89ef01b4
commit
dd09187fc0
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "StateManager.hxx"
|
||||
|
||||
#define STATE_HEADER "06000002state"
|
||||
#define STATE_HEADER "06000003state"
|
||||
// #define MOVIE_HEADER "03030000movie"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -80,9 +80,6 @@ TIA::TIA(ConsoleIO& console, ConsoleTimingProvider timingProvider, Settings& set
|
|||
mySpriteEnabledBits(0xFF),
|
||||
myCollisionsEnabledBits(0xFF)
|
||||
{
|
||||
bool devSettings = mySettings.getBool("dev.settings");
|
||||
myTIAPinsDriven = devSettings ? mySettings.getBool("dev.tiadriven") : false;
|
||||
|
||||
myBackground.setTIA(this);
|
||||
myPlayfield.setTIA(this);
|
||||
myPlayer0.setTIA(this);
|
||||
|
@ -91,14 +88,11 @@ TIA::TIA(ConsoleIO& console, ConsoleTimingProvider timingProvider, Settings& set
|
|||
myMissile1.setTIA(this);
|
||||
myBall.setTIA(this);
|
||||
|
||||
myEnableJitter = mySettings.getBool(devSettings ? "dev.tv.jitter" : "plr.tv.jitter");
|
||||
myJitterFactor = mySettings.getInt(devSettings ? "dev.tv.jitter_recovery" : "plr.tv.jitter_recovery");
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::setFrameManager(AbstractFrameManager *frameManager)
|
||||
void TIA::setFrameManager(AbstractFrameManager* frameManager)
|
||||
{
|
||||
clearFrameManager();
|
||||
|
||||
|
@ -171,62 +165,29 @@ void TIA::reset()
|
|||
for (PaddleReader& paddleReader : myPaddleReaders)
|
||||
paddleReader.reset(myTimestamp);
|
||||
|
||||
bool devSettings = mySettings.getBool("dev.settings");
|
||||
if(devSettings)
|
||||
{
|
||||
bool custom = BSPF::equalsIgnoreCase("custom", mySettings.getString("dev.tia.type"));
|
||||
|
||||
setPlInvertedPhaseClock(custom
|
||||
? mySettings.getBool("dev.tia.plinvphase")
|
||||
: BSPF::equalsIgnoreCase("koolaidman", mySettings.getString("dev.tia.type")));
|
||||
setMsInvertedPhaseClock(custom
|
||||
? mySettings.getBool("dev.tia.msinvphase")
|
||||
: BSPF::equalsIgnoreCase("cosmicark", mySettings.getString("dev.tia.type")));
|
||||
setBlInvertedPhaseClock(custom ? mySettings.getBool("dev.tia.blinvphase") : false);
|
||||
setPFBitsDelay(custom
|
||||
? mySettings.getBool("dev.tia.delaypfbits")
|
||||
: BSPF::equalsIgnoreCase("pesco", mySettings.getString("dev.tia.type")));
|
||||
setPFColorDelay(custom
|
||||
? mySettings.getBool("dev.tia.delaypfcolor")
|
||||
: BSPF::equalsIgnoreCase("quickstep", mySettings.getString("dev.tia.type")));
|
||||
setPlSwapDelay(custom
|
||||
? mySettings.getBool("dev.tia.delayplswap")
|
||||
: BSPF::equalsIgnoreCase("heman", mySettings.getString("dev.tia.type")));
|
||||
setBlSwapDelay(custom ? mySettings.getBool("dev.tia.delayblswap") : false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setPlInvertedPhaseClock(false);
|
||||
setMsInvertedPhaseClock(false);
|
||||
setBlInvertedPhaseClock(false);
|
||||
setPFBitsDelay(false);
|
||||
setPFColorDelay(false);
|
||||
setPlSwapDelay(false);
|
||||
setBlSwapDelay(false);
|
||||
}
|
||||
myDelayQueue.reset();
|
||||
|
||||
myCyclesAtFrameStart = 0;
|
||||
|
||||
if (myFrameManager)
|
||||
{
|
||||
myFrameManager->reset();
|
||||
enableColorLoss(mySettings.getBool(devSettings ? "dev.colorloss" : "plr.colorloss"));
|
||||
}
|
||||
|
||||
myFrontBufferScanlines = myFrameBufferScanlines = 0;
|
||||
|
||||
myFramesSinceLastRender = 0;
|
||||
|
||||
// Must be done last, after all other items have reset
|
||||
enableFixedColors(mySettings.getBool(devSettings ? "dev.debugcolors" : "plr.debugcolors"));
|
||||
setFixedColorPalette(mySettings.getString("tia.dbgcolors"));
|
||||
|
||||
// Blank the various framebuffers; they may contain graphical garbage
|
||||
memset(myBackBuffer, 0, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
memset(myBackBuffer, 0, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
memset(myFrontBuffer, 0, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
memset(myFramebuffer, 0, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
|
||||
applyDeveloperSettings();
|
||||
|
||||
// Must be done last, after all other items have reset
|
||||
bool devSettings = mySettings.getBool("dev.settings");
|
||||
enableFixedColors(mySettings.getBool(devSettings ? "dev.debugcolors" : "plr.debugcolors"));
|
||||
setFixedColorPalette(mySettings.getString("tia.dbgcolors"));
|
||||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
createAccessBase();
|
||||
#endif // DEBUGGER_SUPPORT
|
||||
|
@ -284,8 +245,6 @@ bool TIA::save(Serializer& out) const
|
|||
if(!myInput0.save(out)) return false;
|
||||
if(!myInput1.save(out)) return false;
|
||||
|
||||
out.putBool(myTIAPinsDriven);
|
||||
|
||||
out.putInt(int(myHstate));
|
||||
|
||||
out.putInt(myHctr);
|
||||
|
@ -357,8 +316,6 @@ bool TIA::load(Serializer& in)
|
|||
if(!myInput0.load(in)) return false;
|
||||
if(!myInput1.load(in)) return false;
|
||||
|
||||
myTIAPinsDriven = in.getBool();
|
||||
|
||||
myHstate = HState(in.getInt());
|
||||
|
||||
myHctr = in.getInt();
|
||||
|
@ -397,6 +354,9 @@ bool TIA::load(Serializer& in)
|
|||
myPFBitsDelay = in.getByte();
|
||||
myPFColorDelay = in.getByte();
|
||||
myPlSwapDelay = in.getByte();
|
||||
|
||||
// Re-apply dev settings
|
||||
applyDeveloperSettings();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -831,7 +791,7 @@ bool TIA::saveDisplay(Serializer& out) const
|
|||
try
|
||||
{
|
||||
out.putByteArray(myFramebuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
out.putByteArray(myBackBuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
out.putByteArray(myBackBuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
out.putByteArray(myFrontBuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
out.putInt(myFramesSinceLastRender);
|
||||
}
|
||||
|
@ -851,7 +811,7 @@ bool TIA::loadDisplay(Serializer& in)
|
|||
{
|
||||
// Reset frame buffer pointer and data
|
||||
in.getByteArray(myFramebuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
in.getByteArray(myBackBuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
in.getByteArray(myBackBuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
in.getByteArray(myFrontBuffer, TIAConstants::H_PIXEL * TIAConstants::frameBufferHeight);
|
||||
myFramesSinceLastRender = in.getInt();
|
||||
}
|
||||
|
@ -864,6 +824,52 @@ bool TIA::loadDisplay(Serializer& in)
|
|||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::applyDeveloperSettings()
|
||||
{
|
||||
bool devSettings = mySettings.getBool("dev.settings");
|
||||
if(devSettings)
|
||||
{
|
||||
bool custom = BSPF::equalsIgnoreCase("custom", mySettings.getString("dev.tia.type"));
|
||||
|
||||
setPlInvertedPhaseClock(custom
|
||||
? mySettings.getBool("dev.tia.plinvphase")
|
||||
: BSPF::equalsIgnoreCase("koolaidman", mySettings.getString("dev.tia.type")));
|
||||
setMsInvertedPhaseClock(custom
|
||||
? mySettings.getBool("dev.tia.msinvphase")
|
||||
: BSPF::equalsIgnoreCase("cosmicark", mySettings.getString("dev.tia.type")));
|
||||
setBlInvertedPhaseClock(custom ? mySettings.getBool("dev.tia.blinvphase") : false);
|
||||
setPFBitsDelay(custom
|
||||
? mySettings.getBool("dev.tia.delaypfbits")
|
||||
: BSPF::equalsIgnoreCase("pesco", mySettings.getString("dev.tia.type")));
|
||||
setPFColorDelay(custom
|
||||
? mySettings.getBool("dev.tia.delaypfcolor")
|
||||
: BSPF::equalsIgnoreCase("quickstep", mySettings.getString("dev.tia.type")));
|
||||
setPlSwapDelay(custom
|
||||
? mySettings.getBool("dev.tia.delayplswap")
|
||||
: BSPF::equalsIgnoreCase("heman", mySettings.getString("dev.tia.type")));
|
||||
setBlSwapDelay(custom ? mySettings.getBool("dev.tia.delayblswap") : false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setPlInvertedPhaseClock(false);
|
||||
setMsInvertedPhaseClock(false);
|
||||
setBlInvertedPhaseClock(false);
|
||||
setPFBitsDelay(false);
|
||||
setPFColorDelay(false);
|
||||
setPlSwapDelay(false);
|
||||
setBlSwapDelay(false);
|
||||
}
|
||||
|
||||
myTIAPinsDriven = devSettings ? mySettings.getBool("dev.tiadriven") : false;
|
||||
|
||||
myEnableJitter = mySettings.getBool(devSettings ? "dev.tv.jitter" : "plr.tv.jitter");
|
||||
myJitterFactor = mySettings.getInt(devSettings ? "dev.tv.jitter_recovery" : "plr.tv.jitter_recovery");
|
||||
|
||||
if(myFrameManager)
|
||||
enableColorLoss(mySettings.getBool(devSettings ? "dev.colorloss" : "plr.colorloss"));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void TIA::update(DispatchResult& result, uInt64 maxCycles)
|
||||
{
|
||||
|
|
|
@ -548,7 +548,6 @@ class TIA : public Device
|
|||
string myFixedColorNames[7];
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* This callback is invoked by FrameManager when a new frame starts.
|
||||
*/
|
||||
|
@ -646,8 +645,8 @@ class TIA : public Device
|
|||
uInt8 collCXBLPF() const;
|
||||
|
||||
/**
|
||||
Toggle the specified collision bits
|
||||
*/
|
||||
* Toggle the specified collision bits
|
||||
*/
|
||||
void toggleCollP0PF();
|
||||
void toggleCollP0BL();
|
||||
void toggleCollP0M1();
|
||||
|
@ -664,6 +663,13 @@ class TIA : public Device
|
|||
void toggleCollM1BL();
|
||||
void toggleCollBLPF();
|
||||
|
||||
/**
|
||||
* Re-apply developer settings from the settings object.
|
||||
* This should be done each time the device is reset, or after
|
||||
* a state load occurs.
|
||||
*/
|
||||
void applyDeveloperSettings();
|
||||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
void createAccessBase();
|
||||
|
||||
|
@ -683,9 +689,8 @@ class TIA : public Device
|
|||
#endif // DEBUGGER_SUPPORT
|
||||
|
||||
private:
|
||||
|
||||
ConsoleIO& myConsole;
|
||||
ConsoleTimingProvider myTimingProvider;
|
||||
ConsoleTimingProvider myTimingProvider;
|
||||
Settings& mySettings;
|
||||
|
||||
/**
|
||||
|
@ -717,7 +722,7 @@ class TIA : public Device
|
|||
* The frame manager is responsible for detecting frame boundaries and the visible
|
||||
* region of each frame.
|
||||
*/
|
||||
AbstractFrameManager *myFrameManager;
|
||||
AbstractFrameManager* myFrameManager;
|
||||
|
||||
/**
|
||||
* The various TIA objects.
|
||||
|
@ -771,13 +776,14 @@ class TIA : public Device
|
|||
/**
|
||||
* Master line counter
|
||||
*/
|
||||
|
||||
uInt8 myHctr;
|
||||
|
||||
/**
|
||||
* Delta between master line counter and actual color clock. Nonzero after
|
||||
* RSYNC (before the scanline terminates)
|
||||
*/
|
||||
Int32 myHctrDelta;
|
||||
|
||||
/**
|
||||
* Electron beam x at rendering start (used for blanking out any pixels from
|
||||
* the last frame that are not overwritten)
|
||||
|
@ -804,10 +810,12 @@ class TIA : public Device
|
|||
* movement.
|
||||
*/
|
||||
uInt32 myMovementClock;
|
||||
|
||||
/**
|
||||
* Movement mode --- are we sending movement clocks?
|
||||
*/
|
||||
bool myMovementInProgress;
|
||||
|
||||
/**
|
||||
* Do we have an extended hblank this line? Get set by strobing HMOVE and
|
||||
* cleared when the line wraps.
|
||||
|
@ -830,6 +838,7 @@ class TIA : public Device
|
|||
* The index of the last CPU cycle that was included in the simulation.
|
||||
*/
|
||||
uInt64 myLastCycle;
|
||||
|
||||
/**
|
||||
* Keeps track of a possible fractional number of clocks that still need
|
||||
* to be simulated.
|
||||
|
|
Loading…
Reference in New Issue