Potential optimization for AudioChannel. Fix spelling mistake.

This commit is contained in:
Stephen Anthony 2024-08-07 17:58:12 -02:30
parent 637c194f80
commit 83e4413e2a
3 changed files with 19 additions and 35 deletions

View File

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

View File

@ -20,7 +20,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioChannel::reset()
{
myAudc = myAudv = myAudf = 0;
myAudc = myAudf = myAudv = 0;
myClockEnable = myNoiseFeedback = myNoiseCounterBit4 = myPulseCounterHold = false;
myDivCounter = myPulseCounter = myNoiseCounter = 0;
}
@ -120,40 +120,14 @@ void AudioChannel::phase1()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// The actual volume of a chaneel is the volume register multiplied by the
// lowest of the pulse counter
uInt8 AudioChannel::actualVolume() const
{
return (myPulseCounter & 0x01) * myAudv;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioChannel::audc(uInt8 value)
{
myAudc = value & 0x0f;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioChannel::audv(uInt8 value)
{
myAudv = value & 0x0f;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioChannel::audf(uInt8 value)
{
myAudf = value & 0x1f;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AudioChannel::save(Serializer& out) const
{
try
{
out.putByte(myAudc);
out.putByte(myAudv);
out.putByte(myAudf);
out.putByte(myAudv);
out.putBool(myClockEnable);
out.putBool(myNoiseFeedback);
@ -179,8 +153,8 @@ bool AudioChannel::load(Serializer& in)
try
{
myAudc = in.getByte();
myAudv = in.getByte();
myAudf = in.getByte();
myAudv = in.getByte();
myClockEnable = in.getBool();
myNoiseFeedback = in.getBool();

View File

@ -32,13 +32,23 @@ class AudioChannel : public Serializable
void phase1();
uInt8 actualVolume() const;
// The actual volume of a channel is the volume register multiplied by the
// lowest of the pulse counter
uInt8 actualVolume() const {
return (myPulseCounter & 0x01) * myAudv;
}
void audc(uInt8 value);
void audc(uInt8 value) {
myAudc = value & 0x0f;
}
void audf(uInt8 value);
void audf(uInt8 value) {
myAudf = value & 0x1f;
}
void audv(uInt8 value);
void audv(uInt8 value) {
myAudv = value & 0x0f;
}
/**
Serializable methods (see that class for more information).
@ -48,8 +58,8 @@ class AudioChannel : public Serializable
private:
uInt8 myAudc{0};
uInt8 myAudv{0};
uInt8 myAudf{0};
uInt8 myAudv{0};
bool myClockEnable{false};
bool myNoiseFeedback{false};