Skip to content

Commit

Permalink
Potential optimization for AudioChannel. Fix spelling mistake.
Browse files Browse the repository at this point in the history
  • Loading branch information
sa666666 committed Aug 7, 2024
1 parent 637c194 commit 83e4413
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/common/StateManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef STATE_MANAGER_HXX
#define STATE_MANAGER_HXX

#define STATE_HEADER "06070010state"
#define STATE_HEADER "06070020state"

class OSystem;
class RewindManager;
Expand Down
32 changes: 3 additions & 29 deletions src/emucore/tia/AudioChannel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioChannel::reset()
{
myAudc = myAudv = myAudf = 0;
myAudc = myAudf = myAudv = 0;
myClockEnable = myNoiseFeedback = myNoiseCounterBit4 = myPulseCounterHold = false;
myDivCounter = myPulseCounter = myNoiseCounter = 0;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
20 changes: 15 additions & 5 deletions src/emucore/tia/AudioChannel.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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};
Expand Down

0 comments on commit 83e4413

Please sign in to comment.