From eaae879d9b3a51ef72c3d7e1c3ab6c4ae2daf7e5 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 25 Jan 2020 18:02:07 -0330 Subject: [PATCH] Optimize state save for Audio classes; save byte instead of integer. --- src/common/StateManager.hxx | 2 +- src/emucore/Console.cxx | 1 - src/emucore/tia/Audio.cxx | 4 ++-- src/emucore/tia/AudioChannel.cxx | 24 ++++++++++++------------ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/common/StateManager.hxx b/src/common/StateManager.hxx index 5613e5350..a9fc87052 100644 --- a/src/common/StateManager.hxx +++ b/src/common/StateManager.hxx @@ -18,7 +18,7 @@ #ifndef STATE_MANAGER_HXX #define STATE_MANAGER_HXX -#define STATE_HEADER "06000006state" +#define STATE_HEADER "06000007state" class OSystem; class RewindManager; diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index 5b4cc882e..8e94c3739 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -272,7 +272,6 @@ void Console::redetectFrameLayout() initializeAudio(); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string Console::formatFromFilename() const { diff --git a/src/emucore/tia/Audio.cxx b/src/emucore/tia/Audio.cxx index 5bafedea4..4ddb78179 100644 --- a/src/emucore/tia/Audio.cxx +++ b/src/emucore/tia/Audio.cxx @@ -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; diff --git a/src/emucore/tia/AudioChannel.cxx b/src/emucore/tia/AudioChannel.cxx index 8a2dc25b6..9a8a03972 100644 --- a/src/emucore/tia/AudioChannel.cxx +++ b/src/emucore/tia/AudioChannel.cxx @@ -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(...) {