mirror of https://github.com/stella-emu/stella.git
Final state load/save updates for DelayQueue.
This commit is contained in:
parent
73beb8cb40
commit
94cd456076
|
@ -39,7 +39,7 @@ class System;
|
|||
1K C Varaible and Stack, and the BUS chip.
|
||||
BUS chip access is mapped to $1000 - $103F.
|
||||
|
||||
Authors: Darrell Spice Jr, Chris Walton, Fred Quimby,
|
||||
@authors: Darrell Spice Jr, Chris Walton, Fred Quimby,
|
||||
Stephen Anthony, Bradford W. Mott
|
||||
*/
|
||||
class CartridgeBUS : public Cartridge
|
||||
|
|
|
@ -39,7 +39,7 @@ class System;
|
|||
1K C Varaible and Stack, and the CDF chip.
|
||||
CDF chip access is mapped to $1000 - $103F.
|
||||
|
||||
Authors: Darrell Spice Jr, Chris Walton, Fred Quimby,
|
||||
@authors: Darrell Spice Jr, Chris Walton, Fred Quimby,
|
||||
Stephen Anthony, Bradford W. Mott
|
||||
*/
|
||||
class CartridgeCDF : public Cartridge
|
||||
|
|
|
@ -33,6 +33,11 @@ class Serializable
|
|||
Serializable() = default;
|
||||
virtual ~Serializable() = default;
|
||||
|
||||
Serializable(const Serializable&) = default;
|
||||
Serializable(Serializable&&) = default;
|
||||
Serializable& operator=(const Serializable&) = default;
|
||||
Serializable& operator=(Serializable&&) = default;
|
||||
|
||||
/**
|
||||
Save the current state of the object to the given Serializer.
|
||||
|
||||
|
@ -55,13 +60,6 @@ class Serializable
|
|||
@return The name of the object
|
||||
*/
|
||||
virtual string name() const = 0;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
Serializable(const Serializable&) = delete;
|
||||
Serializable(Serializable&&) = delete;
|
||||
Serializable& operator=(const Serializable&) = delete;
|
||||
Serializable& operator=(Serializable&&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "StateManager.hxx"
|
||||
|
||||
#define STATE_HEADER "04090300state"
|
||||
#define STATE_HEADER "04090400state"
|
||||
#define MOVIE_HEADER "03030000movie"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -62,7 +62,10 @@ bool DelayQueue::save(Serializer& out) const
|
|||
{
|
||||
try
|
||||
{
|
||||
// FIXME out.putVector(myMembers);
|
||||
out.putInt(myMembers.size());
|
||||
for(const DelayQueueMember& m: myMembers)
|
||||
m.save(out);
|
||||
|
||||
out.putByte(myIndex);
|
||||
out.putByteArray(myIndices, 0xFF);
|
||||
}
|
||||
|
@ -80,7 +83,10 @@ bool DelayQueue::load(Serializer& in)
|
|||
{
|
||||
try
|
||||
{
|
||||
// FIXME in.getVector(myMembers);
|
||||
myMembers.resize(in.getInt());
|
||||
for(DelayQueueMember& m: myMembers)
|
||||
m.load(in);
|
||||
|
||||
myIndex = in.getByte();
|
||||
in.getByteArray(myIndices, 0xFF);
|
||||
}
|
||||
|
|
|
@ -38,12 +38,56 @@ void DelayQueueMember::remove(uInt8 address)
|
|||
{
|
||||
size_t index;
|
||||
|
||||
for (index = 0; index < mySize; index++) {
|
||||
if (myEntries.at(index).address == address) break;
|
||||
}
|
||||
for (index = 0; index < mySize; index++)
|
||||
if (myEntries.at(index).address == address)
|
||||
break;
|
||||
|
||||
if (index < mySize) {
|
||||
myEntries.at(index) = myEntries.at(mySize - 1);
|
||||
mySize--;
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool DelayQueueMember::save(Serializer& out) const
|
||||
{
|
||||
try
|
||||
{
|
||||
out.putInt(mySize);
|
||||
for(size_t i = 0; i < mySize; ++i)
|
||||
{
|
||||
const Entry& e = myEntries[i];
|
||||
out.putByte(e.address);
|
||||
out.putByte(e.value);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
cerr << "ERROR: TIA_DelayQueueMember::save" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool DelayQueueMember::load(Serializer& in)
|
||||
{
|
||||
try
|
||||
{
|
||||
mySize = size_t(in.getInt());
|
||||
for(size_t i = 0; i < mySize; ++i)
|
||||
{
|
||||
Entry& e = myEntries[i];
|
||||
e.address = in.getByte();
|
||||
e.value = in.getByte();
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
cerr << "ERROR: TIA_DelayQueueMember::load" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,23 +18,21 @@
|
|||
#ifndef TIA_DELAY_QUEUE_MEMBER
|
||||
#define TIA_DELAY_QUEUE_MEMBER
|
||||
|
||||
#include "Serializable.hxx"
|
||||
#include "bspf.hxx"
|
||||
|
||||
class DelayQueueMember
|
||||
class DelayQueueMember : public Serializable
|
||||
{
|
||||
public:
|
||||
|
||||
struct Entry {
|
||||
uInt8 address;
|
||||
uInt8 value;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
DelayQueueMember(uInt8 size);
|
||||
DelayQueueMember(uInt8 size = 0);
|
||||
|
||||
DelayQueueMember(DelayQueueMember&&) = default;
|
||||
|
||||
DelayQueueMember& operator=(DelayQueueMember&&) = default;
|
||||
|
||||
public:
|
||||
|
@ -55,17 +53,20 @@ class DelayQueueMember
|
|||
mySize = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
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_DelayQueueMember"; }
|
||||
|
||||
private:
|
||||
|
||||
vector<Entry> myEntries;
|
||||
|
||||
size_t mySize;
|
||||
|
||||
private:
|
||||
DelayQueueMember() = delete;
|
||||
DelayQueueMember(const DelayQueueMember&) = delete;
|
||||
DelayQueueMember& operator=(const DelayQueueMember&) = delete;
|
||||
|
||||
};
|
||||
|
||||
#endif // TIA_DELAY_QUEUE_MEMBER
|
||||
|
|
Loading…
Reference in New Issue