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.
|
1K C Varaible and Stack, and the BUS chip.
|
||||||
BUS chip access is mapped to $1000 - $103F.
|
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
|
Stephen Anthony, Bradford W. Mott
|
||||||
*/
|
*/
|
||||||
class CartridgeBUS : public Cartridge
|
class CartridgeBUS : public Cartridge
|
||||||
|
|
|
@ -39,7 +39,7 @@ class System;
|
||||||
1K C Varaible and Stack, and the CDF chip.
|
1K C Varaible and Stack, and the CDF chip.
|
||||||
CDF chip access is mapped to $1000 - $103F.
|
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
|
Stephen Anthony, Bradford W. Mott
|
||||||
*/
|
*/
|
||||||
class CartridgeCDF : public Cartridge
|
class CartridgeCDF : public Cartridge
|
||||||
|
|
|
@ -33,6 +33,11 @@ class Serializable
|
||||||
Serializable() = default;
|
Serializable() = default;
|
||||||
virtual ~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.
|
Save the current state of the object to the given Serializer.
|
||||||
|
|
||||||
|
@ -55,13 +60,6 @@ class Serializable
|
||||||
@return The name of the object
|
@return The name of the object
|
||||||
*/
|
*/
|
||||||
virtual string name() const = 0;
|
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
|
#endif
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include "StateManager.hxx"
|
#include "StateManager.hxx"
|
||||||
|
|
||||||
#define STATE_HEADER "04090300state"
|
#define STATE_HEADER "04090400state"
|
||||||
#define MOVIE_HEADER "03030000movie"
|
#define MOVIE_HEADER "03030000movie"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -62,7 +62,10 @@ bool DelayQueue::save(Serializer& out) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// FIXME out.putVector(myMembers);
|
out.putInt(myMembers.size());
|
||||||
|
for(const DelayQueueMember& m: myMembers)
|
||||||
|
m.save(out);
|
||||||
|
|
||||||
out.putByte(myIndex);
|
out.putByte(myIndex);
|
||||||
out.putByteArray(myIndices, 0xFF);
|
out.putByteArray(myIndices, 0xFF);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +83,10 @@ bool DelayQueue::load(Serializer& in)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// FIXME in.getVector(myMembers);
|
myMembers.resize(in.getInt());
|
||||||
|
for(DelayQueueMember& m: myMembers)
|
||||||
|
m.load(in);
|
||||||
|
|
||||||
myIndex = in.getByte();
|
myIndex = in.getByte();
|
||||||
in.getByteArray(myIndices, 0xFF);
|
in.getByteArray(myIndices, 0xFF);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,56 @@ void DelayQueueMember::remove(uInt8 address)
|
||||||
{
|
{
|
||||||
size_t index;
|
size_t index;
|
||||||
|
|
||||||
for (index = 0; index < mySize; index++) {
|
for (index = 0; index < mySize; index++)
|
||||||
if (myEntries.at(index).address == address) break;
|
if (myEntries.at(index).address == address)
|
||||||
}
|
break;
|
||||||
|
|
||||||
if (index < mySize) {
|
if (index < mySize) {
|
||||||
myEntries.at(index) = myEntries.at(mySize - 1);
|
myEntries.at(index) = myEntries.at(mySize - 1);
|
||||||
mySize--;
|
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
|
#ifndef TIA_DELAY_QUEUE_MEMBER
|
||||||
#define TIA_DELAY_QUEUE_MEMBER
|
#define TIA_DELAY_QUEUE_MEMBER
|
||||||
|
|
||||||
|
#include "Serializable.hxx"
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
class DelayQueueMember
|
class DelayQueueMember : public Serializable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Entry {
|
struct Entry {
|
||||||
uInt8 address;
|
uInt8 address;
|
||||||
uInt8 value;
|
uInt8 value;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
DelayQueueMember(uInt8 size = 0);
|
||||||
DelayQueueMember(uInt8 size);
|
|
||||||
|
|
||||||
DelayQueueMember(DelayQueueMember&&) = default;
|
DelayQueueMember(DelayQueueMember&&) = default;
|
||||||
|
|
||||||
DelayQueueMember& operator=(DelayQueueMember&&) = default;
|
DelayQueueMember& operator=(DelayQueueMember&&) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -55,17 +53,20 @@ class DelayQueueMember
|
||||||
mySize = 0;
|
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:
|
private:
|
||||||
|
|
||||||
vector<Entry> myEntries;
|
vector<Entry> myEntries;
|
||||||
|
|
||||||
size_t mySize;
|
size_t mySize;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DelayQueueMember() = delete;
|
|
||||||
DelayQueueMember(const DelayQueueMember&) = delete;
|
DelayQueueMember(const DelayQueueMember&) = delete;
|
||||||
DelayQueueMember& operator=(const DelayQueueMember&) = delete;
|
DelayQueueMember& operator=(const DelayQueueMember&) = delete;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TIA_DELAY_QUEUE_MEMBER
|
#endif // TIA_DELAY_QUEUE_MEMBER
|
||||||
|
|
Loading…
Reference in New Issue