Skip to content

Commit

Permalink
Minor AY8910 performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jan 14, 2024
1 parent 4c0d58d commit 1afc7dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/AY8910.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void AY8910::Init(int clockRate)
void AY8910::Reset(int clockRate)
{
m_iClockRate = clockRate;
m_iCyclesPerSample = m_iClockRate / GC_AUDIO_SAMPLE_RATE;

for (int i = 0; i < 16; i++)
{
Expand Down Expand Up @@ -300,10 +301,9 @@ void AY8910::Sync()
}

m_iSampleCounter++;
int cyclesPerSample = m_iClockRate / GC_AUDIO_SAMPLE_RATE;
if (m_iSampleCounter >= cyclesPerSample)
if (m_iSampleCounter >= m_iCyclesPerSample)
{
m_iSampleCounter -= cyclesPerSample;
m_iSampleCounter -= m_iCyclesPerSample;
m_CurrentSample = 0;

for (int i = 0; i < 3; i++)
Expand Down
1 change: 1 addition & 0 deletions src/AY8910.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class AY8910
bool m_Sign[3];
int m_iCycleCounter;
int m_iSampleCounter;
int m_iCyclesPerSample;
s16* m_pBuffer;
int m_iBufferIndex;
int m_ElapsedCycles;
Expand Down

0 comments on commit 1afc7dd

Please sign in to comment.