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
#define STATE_MANAGER_HXX
#define STATE_HEADER "06000006state"
#define STATE_HEADER "06000007state"
class OSystem;
class RewindManager;

View File

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

View File

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

View File

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