Optimize state save for Audio classes; save byte instead of integer.

This commit is contained in:
Stephen Anthony 2020-01-25 18:02:07 -03:30
parent c95acefffd
commit eaae879d9b
4 changed files with 15 additions and 16 deletions

View File

@ -18,7 +18,7 @@
#ifndef STATE_MANAGER_HXX #ifndef STATE_MANAGER_HXX
#define STATE_MANAGER_HXX #define STATE_MANAGER_HXX
#define STATE_HEADER "06000006state" #define STATE_HEADER "06000007state"
class OSystem; class OSystem;
class RewindManager; class RewindManager;

View File

@ -272,7 +272,6 @@ void Console::redetectFrameLayout()
initializeAudio(); initializeAudio();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Console::formatFromFilename() const string Console::formatFromFilename() const
{ {

View File

@ -118,7 +118,7 @@ bool Audio::save(Serializer& out) const
{ {
try try
{ {
out.putInt(myCounter); out.putByte(myCounter);
// The queue starts out pristine after loading, so we don't need to save // The queue starts out pristine after loading, so we don't need to save
// any other parts of our state // any other parts of our state
@ -140,7 +140,7 @@ bool Audio::load(Serializer& in)
{ {
try try
{ {
myCounter = in.getInt(); myCounter = in.getByte();
if (!myChannel0.load(in)) return false; if (!myChannel0.load(in)) return false;
if (!myChannel1.load(in)) return false; if (!myChannel1.load(in)) return false;

View File

@ -140,18 +140,18 @@ bool AudioChannel::save(Serializer& out) const
{ {
try try
{ {
out.putInt(myAudc); out.putByte(myAudc);
out.putInt(myAudv); out.putByte(myAudv);
out.putInt(myAudf); out.putByte(myAudf);
out.putBool(myClockEnable); out.putBool(myClockEnable);
out.putBool(myNoiseFeedback); out.putBool(myNoiseFeedback);
out.putBool(myNoiseCounterBit4); out.putBool(myNoiseCounterBit4);
out.putBool(myPulseCounterHold); out.putBool(myPulseCounterHold);
out.putInt(myDivCounter); out.putByte(myDivCounter);
out.putInt(myPulseCounter); out.putByte(myPulseCounter);
out.putInt(myNoiseCounter); out.putByte(myNoiseCounter);
} }
catch(...) catch(...)
{ {
@ -167,18 +167,18 @@ bool AudioChannel::load(Serializer& in)
{ {
try try
{ {
myAudc = in.getInt(); myAudc = in.getByte();
myAudv = in.getInt(); myAudv = in.getByte();
myAudf = in.getInt(); myAudf = in.getByte();
myClockEnable = in.getBool(); myClockEnable = in.getBool();
myNoiseFeedback = in.getBool(); myNoiseFeedback = in.getBool();
myNoiseCounterBit4 = in.getBool(); myNoiseCounterBit4 = in.getBool();
myPulseCounterHold = in.getBool(); myPulseCounterHold = in.getBool();
myDivCounter = in.getInt(); myDivCounter = in.getByte();
myPulseCounter = in.getInt(); myPulseCounter = in.getByte();
myNoiseCounter = in.getInt(); myNoiseCounter = in.getByte();
} }
catch(...) catch(...)
{ {