diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index fe9d829a1..e147c9935 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -133,6 +133,15 @@ void Serializer::getIntArray(uInt32* array, uInt32 size) const myStream->read(reinterpret_cast(array), sizeof(uInt32)*size); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +double Serializer::getDouble() const +{ + double val = 0.0; + myStream->read(reinterpret_cast(&val), sizeof(double)); + + return val; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string Serializer::getString() const { @@ -186,6 +195,12 @@ void Serializer::putIntArray(const uInt32* array, uInt32 size) myStream->write(reinterpret_cast(array), sizeof(uInt32)*size); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Serializer::putDouble(double value) +{ + myStream->write(reinterpret_cast(&value), sizeof(double)); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Serializer::putString(const string& str) { diff --git a/src/emucore/Serializer.hxx b/src/emucore/Serializer.hxx index 00776bd4e..e956a158c 100644 --- a/src/emucore/Serializer.hxx +++ b/src/emucore/Serializer.hxx @@ -110,6 +110,13 @@ class Serializer */ void getIntArray(uInt32* array, uInt32 size) const; + /** + Reads a double value (signed 64-bit) from the current input stream. + + @result The double value which has been read from the stream. + */ + double getDouble() const; + /** Reads a string from the current input stream. @@ -169,6 +176,13 @@ class Serializer */ void putIntArray(const uInt32* array, uInt32 size); + /** + Writes a double value (signed 64-bit) to the current output stream. + + @param value The double value to write to the output stream. + */ + void putDouble(double value); + /** Writes a string to the current output stream. diff --git a/src/emucore/StateManager.cxx b/src/emucore/StateManager.cxx index 270cc4ef7..8686f796a 100644 --- a/src/emucore/StateManager.cxx +++ b/src/emucore/StateManager.cxx @@ -28,7 +28,7 @@ #include "StateManager.hxx" -#define STATE_HEADER "04090200state" +#define STATE_HEADER "04090300state" #define MOVIE_HEADER "03030000movie" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index 7fbe34c14..b8106841f 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -530,7 +530,7 @@ int Thumbulator::execute() pc = read_register(15); -#if 0 // FIXME SA - not sure if this should be enabled +#if 0 if(handler_mode) { if((pc & 0xF0000000) == 0xF0000000) diff --git a/src/emucore/tia/Background.cxx b/src/emucore/tia/Background.cxx index 71c5f3536..65a4de825 100644 --- a/src/emucore/tia/Background.cxx +++ b/src/emucore/tia/Background.cxx @@ -90,8 +90,6 @@ bool Background::load(Serializer& in) myObjectColor = in.getByte(); myDebugColor = in.getByte(); myDebugEnabled = in.getBool(); - - applyColors(); } catch(...) { diff --git a/src/emucore/tia/Ball.cxx b/src/emucore/tia/Ball.cxx index 9177d3d97..348f5db4a 100644 --- a/src/emucore/tia/Ball.cxx +++ b/src/emucore/tia/Ball.cxx @@ -278,9 +278,6 @@ bool Ball::load(Serializer& in) myIsRendering = in.getBool(); myRenderCounter = in.getByte(); - - updateEnabled(); - applyColors(); } catch(...) { diff --git a/src/emucore/tia/DelayQueue.cxx b/src/emucore/tia/DelayQueue.cxx index 5f94a394b..bfbd680fa 100644 --- a/src/emucore/tia/DelayQueue.cxx +++ b/src/emucore/tia/DelayQueue.cxx @@ -56,3 +56,39 @@ void DelayQueue::reset() memset(myIndices, 0xFF, 0xFF); } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool DelayQueue::save(Serializer& out) const +{ + try + { + // FIXME out.putVector(myMembers); + out.putByte(myIndex); + out.putByteArray(myIndices, 0xFF); + } + catch(...) + { + cerr << "ERROR: TIA_DelayQueue::save" << endl; + return false; + } + + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool DelayQueue::load(Serializer& in) +{ + try + { + // FIXME in.getVector(myMembers); + myIndex = in.getByte(); + in.getByteArray(myIndices, 0xFF); + } + catch(...) + { + cerr << "ERROR: TIA_DelayQueue::load" << endl; + return false; + } + + return true; +} diff --git a/src/emucore/tia/DelayQueue.hxx b/src/emucore/tia/DelayQueue.hxx index a5b68aba7..c01c66b53 100644 --- a/src/emucore/tia/DelayQueue.hxx +++ b/src/emucore/tia/DelayQueue.hxx @@ -18,10 +18,11 @@ #ifndef TIA_DELAY_QUEUE #define TIA_DELAY_QUEUE +#include "Serializable.hxx" #include "bspf.hxx" #include "DelayQueueMember.hxx" -class DelayQueue +class DelayQueue : public Serializable { public: DelayQueue(uInt8 length, uInt8 size); @@ -34,12 +35,16 @@ class DelayQueue template void execute(T executor); + /** + Serializable methods (see that class for more information). + */ + bool save(Serializer& out) const override; + bool load(Serializer& in) override; + string name() const override { return "TIA_DelayQueue"; } + private: - vector myMembers; - uInt8 myIndex; - uInt8 myIndices[0xFF]; private: diff --git a/src/emucore/tia/DrawCounterDecodes.cxx b/src/emucore/tia/DrawCounterDecodes.cxx index cf5c1d808..553c2c6df 100644 --- a/src/emucore/tia/DrawCounterDecodes.cxx +++ b/src/emucore/tia/DrawCounterDecodes.cxx @@ -15,8 +15,6 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -// namespace TIA6502tsCore - #include "DrawCounterDecodes.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/FrameManager.cxx b/src/emucore/tia/FrameManager.cxx index 3b8f01615..61a632ead 100644 --- a/src/emucore/tia/FrameManager.cxx +++ b/src/emucore/tia/FrameManager.cxx @@ -316,7 +316,6 @@ void FrameManager::setFixedHeight(uInt32 height) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool FrameManager::save(Serializer& out) const { try @@ -325,7 +324,29 @@ bool FrameManager::save(Serializer& out) const if (!myVblankManager.save(out)) return false; - // TODO - save instance variables + out.putInt(uInt32(myLayout)); + out.putBool(myAutodetectLayout); + out.putInt(uInt32(myState)); + out.putInt(myLineInState); + out.putInt(myCurrentFrameTotalLines); + out.putInt(myCurrentFrameFinalLines); + out.putInt(myVsyncLines); + out.putDouble(myFrameRate); + out.putInt(myY); out.putInt(myLastY); + out.putBool(myFramePending); + + out.putInt(myTotalFrames); + out.putInt(myFramesInMode); + out.putBool(myModeConfirmed); + + out.putBool(myVsync); + + out.putInt(myVblankLines); + out.putInt(myKernelLines); + out.putInt(myOverscanLines); + out.putInt(myFrameLines); + out.putInt(myHeight); + out.putInt(myFixedHeight); } catch(...) { @@ -333,11 +354,10 @@ bool FrameManager::save(Serializer& out) const return false; } - return false; + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool FrameManager::load(Serializer& in) { try @@ -347,7 +367,29 @@ bool FrameManager::load(Serializer& in) if (!myVblankManager.load(in)) return false; - // TODO - load instance variables + myLayout = FrameLayout(in.getInt()); + myAutodetectLayout = in.getBool(); + myState = State(in.getInt()); + myLineInState = in.getInt(); + myCurrentFrameTotalLines = in.getInt(); + myCurrentFrameFinalLines = in.getInt(); + myVsyncLines = in.getInt(); + myFrameRate = float(in.getDouble()); + myY = in.getInt(); myLastY = in.getInt(); + myFramePending = in.getBool(); + + myTotalFrames = in.getInt(); + myFramesInMode = in.getInt(); + myModeConfirmed = in.getBool(); + + myVsync = in.getBool(); + + myVblankLines = in.getInt(); + myKernelLines = in.getInt(); + myOverscanLines = in.getInt(); + myFrameLines = in.getInt(); + myHeight = in.getInt(); + myFixedHeight = in.getInt(); } catch(...) { @@ -355,5 +397,5 @@ bool FrameManager::load(Serializer& in) return false; } - return false; + return true; } diff --git a/src/emucore/tia/LatchedInput.hxx b/src/emucore/tia/LatchedInput.hxx index 30e1e3ce1..211b68183 100644 --- a/src/emucore/tia/LatchedInput.hxx +++ b/src/emucore/tia/LatchedInput.hxx @@ -43,9 +43,7 @@ class LatchedInput : public Serializable string name() const override { return "TIA_LatchedInput"; } private: - bool myModeLatched; - uInt8 myLatchedValue; private: diff --git a/src/emucore/tia/Missile.cxx b/src/emucore/tia/Missile.cxx index 15724ebe4..c3afeebb5 100644 --- a/src/emucore/tia/Missile.cxx +++ b/src/emucore/tia/Missile.cxx @@ -26,7 +26,8 @@ enum Count: Int8 { Missile::Missile(uInt32 collisionMask) : myCollisionMaskDisabled(collisionMask), myCollisionMaskEnabled(0xFFFF), - myIsSuppressed(false) + myIsSuppressed(false), + myDecodesOffset(0) { reset(); } @@ -34,7 +35,7 @@ Missile::Missile(uInt32 collisionMask) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Missile::reset() { - myDecodes = DrawCounterDecodes::get().missileDecodes()[0]; + myDecodes = DrawCounterDecodes::get().missileDecodes()[myDecodesOffset]; myIsEnabled = false; myEnam = false; myResmp = 0; @@ -137,8 +138,9 @@ void Missile::nusiz(uInt8 value) { static constexpr uInt8 ourWidths[] = { 1, 2, 4, 8 }; + myDecodesOffset = value & 0x07; myWidth = ourWidths[(value & 0x30) >> 4]; - myDecodes = DrawCounterDecodes::get().missileDecodes()[value & 0x07]; + myDecodes = DrawCounterDecodes::get().missileDecodes()[myDecodesOffset]; if (myIsRendering && myRenderCounter >= myWidth) myIsRendering = false; @@ -243,14 +245,36 @@ void Missile::applyColors() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool Missile::save(Serializer& out) const { try { out.putString(name()); - // TODO - save instance variables + out.putInt(collision); + out.putInt(myCollisionMaskDisabled); + out.putInt(myCollisionMaskEnabled); + + out.putBool(myIsEnabled); + out.putBool(myIsSuppressed); + out.putBool(myEnam); + out.putByte(myResmp); + + out.putByte(myHmmClocks); + out.putByte(myCounter); + out.putBool(myIsMoving); + out.putByte(myWidth); + out.putByte(myEffectiveWidth); + out.putByte(myLastMovementTick); + + out.putBool(myIsRendering); + out.putByte(myRenderCounter); + + out.putByte(myDecodesOffset); + + out.putByte(myColor); + out.putByte(myObjectColor); out.putByte(myDebugColor); + out.putBool(myDebugEnabled); } catch(...) { @@ -258,11 +282,10 @@ bool Missile::save(Serializer& out) const return false; } - return false; + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool Missile::load(Serializer& in) { try @@ -270,7 +293,31 @@ bool Missile::load(Serializer& in) if(in.getString() != name()) return false; - // TODO - load instance variables + collision = in.getInt(); + myCollisionMaskDisabled = in.getInt(); + myCollisionMaskEnabled = in.getInt(); + + myIsEnabled = in.getBool(); + myIsSuppressed = in.getBool(); + myEnam = in.getBool(); + myResmp = in.getByte(); + + myHmmClocks = in.getByte(); + myCounter = in.getByte(); + myIsMoving = in.getBool(); + myWidth = in.getByte(); + myEffectiveWidth = in.getByte(); + myLastMovementTick = in.getByte(); + + myIsRendering = in.getBool(); + myRenderCounter = in.getByte(); + + myDecodesOffset = in.getByte(); + myDecodes = DrawCounterDecodes::get().missileDecodes()[myDecodesOffset]; + + myColor = in.getByte(); + myObjectColor = in.getByte(); myDebugColor = in.getByte(); + myDebugEnabled = in.getBool(); } catch(...) { @@ -278,5 +325,5 @@ bool Missile::load(Serializer& in) return false; } - return false; + return true; } diff --git a/src/emucore/tia/Missile.hxx b/src/emucore/tia/Missile.hxx index 0670d4d70..271d86687 100644 --- a/src/emucore/tia/Missile.hxx +++ b/src/emucore/tia/Missile.hxx @@ -102,6 +102,7 @@ class Missile : public Serializable Int8 myRenderCounter; const uInt8* myDecodes; + uInt8 myDecodesOffset; // needed for state saving uInt8 myColor; uInt8 myObjectColor, myDebugColor; diff --git a/src/emucore/tia/PaddleReader.cxx b/src/emucore/tia/PaddleReader.cxx index d8ec20738..3709912ce 100644 --- a/src/emucore/tia/PaddleReader.cxx +++ b/src/emucore/tia/PaddleReader.cxx @@ -105,14 +105,22 @@ void PaddleReader::updateCharge(double timestamp) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool PaddleReader::save(Serializer& out) const { try { out.putString(name()); - // TODO - save instance variables + out.putDouble(myUThresh); + out.putDouble(myU); + + out.putDouble(myValue); + out.putDouble(myTimestamp); + + out.putInt(int(myLayout)); + out.putDouble(myClockFreq); + + out.putBool(myIsDumped); } catch(...) { @@ -120,11 +128,10 @@ bool PaddleReader::save(Serializer& out) const return false; } - return false; + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool PaddleReader::load(Serializer& in) { try @@ -132,7 +139,16 @@ bool PaddleReader::load(Serializer& in) if(in.getString() != name()) return false; - // TODO - load instance variables + myUThresh = in.getDouble(); + myU = in.getDouble(); + + myValue = in.getDouble(); + myTimestamp = in.getDouble(); + + myLayout = FrameLayout(in.getInt()); + myClockFreq = in.getDouble(); + + myIsDumped = in.getBool(); } catch(...) { @@ -140,5 +156,5 @@ bool PaddleReader::load(Serializer& in) return false; } - return false; + return true; } diff --git a/src/emucore/tia/Player.cxx b/src/emucore/tia/Player.cxx index 64a67890c..c5d995dd5 100644 --- a/src/emucore/tia/Player.cxx +++ b/src/emucore/tia/Player.cxx @@ -26,7 +26,8 @@ enum Count: Int8 { Player::Player(uInt32 collisionMask) : myCollisionMaskDisabled(collisionMask), myCollisionMaskEnabled(0xFFFF), - myIsSuppressed(false) + myIsSuppressed(false), + myDecodesOffset(0) { reset(); } @@ -34,7 +35,7 @@ Player::Player(uInt32 collisionMask) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Player::reset() { - myDecodes = DrawCounterDecodes::get().playerDecodes()[0]; + myDecodes = DrawCounterDecodes::get().playerDecodes()[myDecodesOffset]; myHmmClocks = 0; myCounter = 0; myIsMoving = false; @@ -74,9 +75,9 @@ void Player::hmp(uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Player::nusiz(uInt8 value, bool hblank) { - const uInt8 masked = value & 0x07; + myDecodesOffset = value & 0x07; - switch (masked) { + switch (myDecodesOffset) { case 5: myDividerPending = 2; break; @@ -92,7 +93,7 @@ void Player::nusiz(uInt8 value, bool hblank) const uInt8* oldDecodes = myDecodes; - myDecodes = DrawCounterDecodes::get().playerDecodes()[masked]; + myDecodes = DrawCounterDecodes::get().playerDecodes()[myDecodesOffset]; if ( myDecodes != oldDecodes && @@ -363,14 +364,42 @@ void Player::applyColors() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool Player::save(Serializer& out) const { try { out.putString(name()); - // TODO - save instance variables + out.putInt(collision); + out.putInt(myCollisionMaskDisabled); + out.putInt(myCollisionMaskEnabled); + + out.putByte(myColor); + out.putByte(myObjectColor); out.putByte(myDebugColor); + out.putBool(myDebugEnabled); + + out.putBool(myIsSuppressed); + + out.putByte(myHmmClocks); + out.putByte(myCounter); + out.putBool(myIsMoving); + + out.putBool(myIsRendering); + out.putByte(myRenderCounter); + out.putByte(myRenderCounterTripPoint); + out.putByte(myDivider); + out.putByte(myDividerPending); + out.putByte(mySampleCounter); + out.putByte(myDividerChangeCounter); + + out.putByte(myDecodesOffset); + + out.putByte(myPatternOld); + out.putByte(myPatternNew); + out.putByte(myPattern); + + out.putBool(myIsReflected); + out.putBool(myIsDelaying); } catch(...) { @@ -378,11 +407,10 @@ bool Player::save(Serializer& out) const return false; } - return false; + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool Player::load(Serializer& in) { try @@ -390,7 +418,37 @@ bool Player::load(Serializer& in) if(in.getString() != name()) return false; - // TODO - load instance variables + collision = in.getInt(); + myCollisionMaskDisabled = in.getInt(); + myCollisionMaskEnabled = in.getInt(); + + myColor = in.getByte(); + myObjectColor = in.getByte(); myDebugColor = in.getByte(); + myDebugEnabled = in.getBool(); + + myIsSuppressed = in.getBool(); + + myHmmClocks = in.getByte(); + myCounter = in.getByte(); + myIsMoving = in.getBool(); + + myIsRendering = in.getBool(); + myRenderCounter = in.getByte(); + myRenderCounterTripPoint = in.getByte(); + myDivider = in.getByte(); + myDividerPending = in.getByte(); + mySampleCounter = in.getByte(); + myDividerChangeCounter = in.getByte(); + + myDecodesOffset = in.getByte(); + myDecodes = DrawCounterDecodes::get().playerDecodes()[myDecodesOffset]; + + myPatternOld = in.getByte(); + myPatternNew = in.getByte(); + myPattern = in.getByte(); + + myIsReflected = in.getBool(); + myIsDelaying = in.getBool(); } catch(...) { @@ -398,5 +456,5 @@ bool Player::load(Serializer& in) return false; } - return false; + return true; } diff --git a/src/emucore/tia/Player.hxx b/src/emucore/tia/Player.hxx index fb7091b6e..1279dcfc1 100644 --- a/src/emucore/tia/Player.hxx +++ b/src/emucore/tia/Player.hxx @@ -94,6 +94,7 @@ class Player : public Serializable uInt32 myCollisionMaskDisabled; uInt32 myCollisionMaskEnabled; + uInt8 myColor; uInt8 myObjectColor, myDebugColor; bool myDebugEnabled; @@ -113,6 +114,7 @@ class Player : public Serializable Int8 myDividerChangeCounter; const uInt8* myDecodes; + uInt8 myDecodesOffset; // needed for state saving uInt8 myPatternOld; uInt8 myPatternNew; diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index dab9ddbfc..411396e1c 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -72,14 +72,14 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings) mySound(sound), mySettings(settings), myDelayQueue(10, 20), - mySpriteEnabledBits(0xFF), - myCollisionsEnabledBits(0xFF), myPlayfield(~CollisionMask::playfield & 0x7FFF), myMissile0(~CollisionMask::missile0 & 0x7FFF), myMissile1(~CollisionMask::missile1 & 0x7FFF), myPlayer0(~CollisionMask::player0 & 0x7FFF), myPlayer1(~CollisionMask::player1 & 0x7FFF), - myBall(~CollisionMask::ball & 0x7FFF) + myBall(~CollisionMask::ball & 0x7FFF), + mySpriteEnabledBits(0xFF), + myCollisionsEnabledBits(0xFF) { myFrameManager.setHandlers( [this] () { @@ -196,9 +196,11 @@ bool TIA::save(Serializer& out) const { out.putString(name()); - // TODO - save instance variables + if(!mySound.save(out)) return false; + + if(!myDelayQueue.save(out)) return false; + if(!myFrameManager.save(out)) return false; - // Save the state of each graphics object if(!myBackground.save(out)) return false; if(!myPlayfield.save(out)) return false; if(!myMissile0.save(out)) return false; @@ -207,16 +209,51 @@ bool TIA::save(Serializer& out) const if(!myPlayer1.save(out)) return false; if(!myBall.save(out)) return false; - // Save dumped input ports for (const PaddleReader& paddleReader : myPaddleReaders) if(!paddleReader.save(out)) return false; - // Save latched input ports if(!myInput0.save(out)) return false; if(!myInput1.save(out)) return false; - // Save the sound sample stuff ... - if(!mySound.save(out)) return false; + out.putBool(myTIAPinsDriven); + + out.putInt(int(myHstate)); + out.putBool(myIsFreshLine); + + out.putInt(myHblankCtr); + out.putInt(myHctr); + out.putInt(myXDelta); + + out.putBool(myCollisionUpdateRequired); + out.putInt(myCollisionMask); + + out.putInt(myMovementClock); + out.putBool(myMovementInProgress); + out.putBool(myExtendedHblank); + + out.putInt(myLinesSinceChange); + + out.putInt(int(myPriority)); + out.putByte(myCtrlPF); + + out.putByte(mySubClock); + out.putInt(myLastCycle); + + out.putByte(mySpriteEnabledBits); + out.putByte(myCollisionsEnabledBits); + + out.putByte(myColorHBlank); + + out.putDouble(myTimestamp); + + out.putBool(myAutoFrameEnabled); + + out.putByte(myAUDV0); + out.putByte(myAUDV1); + out.putByte(myAUDC0); + out.putByte(myAUDC1); + out.putByte(myAUDF0); + out.putByte(myAUDF1); } catch(...) { @@ -224,7 +261,7 @@ bool TIA::save(Serializer& out) const return false; } - return false; // for now, until class is finalized + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -235,9 +272,11 @@ bool TIA::load(Serializer& in) if(in.getString() != name()) return false; - // TODO - load instance variables + if(!mySound.load(in)) return false; + + if(!myDelayQueue.load(in)) return false; + if(!myFrameManager.load(in)) return false; - // Load the state of each graphics object if(!myBackground.load(in)) return false; if(!myPlayfield.load(in)) return false; if(!myMissile0.load(in)) return false; @@ -246,16 +285,51 @@ bool TIA::load(Serializer& in) if(!myPlayer1.load(in)) return false; if(!myBall.load(in)) return false; - // Load dumped input ports for (PaddleReader& paddleReader : myPaddleReaders) if(!paddleReader.load(in)) return false; - // Load latched input ports if(!myInput0.load(in)) return false; if(!myInput1.load(in)) return false; - // Load the sound sample stuff ... - if(!mySound.load(in)) return false; + myTIAPinsDriven = in.getBool(); + + myHstate = HState(in.getInt()); + myIsFreshLine = in.getBool(); + + myHblankCtr = in.getInt(); + myHctr = in.getInt(); + myXDelta = in.getInt(); + + myCollisionUpdateRequired = in.getBool(); + myCollisionMask = in.getInt(); + + myMovementClock = in.getInt(); + myMovementInProgress = in.getBool(); + myExtendedHblank = in.getBool(); + + myLinesSinceChange = in.getInt(); + + myPriority = Priority(in.getInt()); + myCtrlPF = in.getByte(); + + mySubClock = in.getByte(); + myLastCycle = in.getInt(); + + mySpriteEnabledBits = in.getByte(); + myCollisionsEnabledBits = in.getByte(); + + myColorHBlank = in.getByte(); + + myTimestamp = in.getDouble(); + + myAutoFrameEnabled = in.getBool(); + + myAUDV0 = in.getByte(); + myAUDV1 = in.getByte(); + myAUDC0 = in.getByte(); + myAUDC1 = in.getByte(); + myAUDF0 = in.getByte(); + myAUDF1 = in.getByte(); } catch(...) { @@ -263,7 +337,7 @@ bool TIA::load(Serializer& in) return false; } - return false; // for now, until class is finalized + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/tia/TIA.hxx b/src/emucore/tia/TIA.hxx index 85f008916..0f5ef6043 100644 --- a/src/emucore/tia/TIA.hxx +++ b/src/emucore/tia/TIA.hxx @@ -409,11 +409,27 @@ class TIA : public Device Sound& mySound; Settings& mySettings; - bool myTIAPinsDriven; - DelayQueue myDelayQueue; FrameManager myFrameManager; + Background myBackground; + Playfield myPlayfield; + Missile myMissile0; + Missile myMissile1; + Player myPlayer0; + Player myPlayer1; + Ball myBall; + PaddleReader myPaddleReaders[4]; + + LatchedInput myInput0; + LatchedInput myInput1; + + // Pointer to the current and previous frame buffers + BytePtr myCurrentFrameBuffer; + BytePtr myPreviousFrameBuffer; + + bool myTIAPinsDriven; + HState myHstate; bool myIsFreshLine; @@ -446,22 +462,6 @@ class TIA : public Device // Automatic framerate correction based on number of scanlines bool myAutoFrameEnabled; - // Pointer to the current and previous frame buffers - BytePtr myCurrentFrameBuffer; - BytePtr myPreviousFrameBuffer; - - Background myBackground; - Playfield myPlayfield; - Missile myMissile0; - Missile myMissile1; - Player myPlayer0; - Player myPlayer1; - Ball myBall; - PaddleReader myPaddleReaders[4]; - - LatchedInput myInput0; - LatchedInput myInput1; - ////////////////////////////////////////////////////////////// // Audio values; only used by TIADebug // FIXME - remove this when the new sound core is implemented diff --git a/src/emucore/tia/VblankManager.cxx b/src/emucore/tia/VblankManager.cxx index a43eb4502..2f372e5ba 100644 --- a/src/emucore/tia/VblankManager.cxx +++ b/src/emucore/tia/VblankManager.cxx @@ -185,14 +185,25 @@ void VblankManager::setVblankMode(VblankMode mode) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool VblankManager::save(Serializer& out) const { try { out.putString(name()); - // TODO - save instance variables + out.putInt(myVblankLines); + out.putInt(myYstart); + out.putBool(myVblank); + out.putInt(myCurrentLine); + + out.putInt(int(myMode)); + out.putInt(myLastVblankLines); + out.putByte(myVblankViolations); + out.putByte(myStableVblankFrames); + out.putBool(myVblankViolated); + out.putByte(myFramesInLockedMode); + + out.putBool(myIsRunning); } catch(...) { @@ -200,11 +211,10 @@ bool VblankManager::save(Serializer& out) const return false; } - return false; + return true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// TODO: implement this once the class is finalized bool VblankManager::load(Serializer& in) { try @@ -212,7 +222,19 @@ bool VblankManager::load(Serializer& in) if(in.getString() != name()) return false; - // TODO - load instance variables + myVblankLines = in.getInt(); + myYstart = in.getInt(); + myVblank = in.getBool(); + myCurrentLine = in.getInt(); + + myMode = VblankMode(in.getInt()); + myLastVblankLines = in.getInt(); + myVblankViolations = in.getByte(); + myStableVblankFrames = in.getByte(); + myVblankViolated = in.getBool(); + myFramesInLockedMode = in.getByte(); + + myIsRunning = in.getBool(); } catch(...) { @@ -220,5 +242,5 @@ bool VblankManager::load(Serializer& in) return false; } - return false; + return true; }