From 5d9d0b8a089cd1662353a44bb7783eeed8040e0e Mon Sep 17 00:00:00 2001 From: JetSetIlly Date: Tue, 6 Aug 2024 22:40:14 +0100 Subject: [PATCH] AudioChannel::phase1() no longer returns uInt8 the uInt8 is retreived with the new AudioChannel::volume() function this separation is because we want to take the volume of the audio channel every colour clock but 'phase 1' for the channel happens only twice per scanline --- src/emucore/tia/Audio.hxx | 8 +++++--- src/emucore/tia/AudioChannel.cxx | 5 ++++- src/emucore/tia/AudioChannel.hxx | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/emucore/tia/Audio.hxx b/src/emucore/tia/Audio.hxx index c656ed5a3..aa2e5e611 100644 --- a/src/emucore/tia/Audio.hxx +++ b/src/emucore/tia/Audio.hxx @@ -98,8 +98,8 @@ void Audio::tick() { // volume for each channel is sampled every color clock. the average of // these samples will be taken twice a scanline in the phase1() function - sumChannel0 += (uInt32)myChannel0.phase1(); - sumChannel1 += (uInt32)myChannel1.phase1(); + sumChannel0 += (uInt32)myChannel0.volume(); + sumChannel1 += (uInt32)myChannel1.volume(); sumCt++; switch (myCounter) { @@ -111,7 +111,9 @@ void Audio::tick() case 37: case 149: - phase1(); + myChannel0.phase1(); + myChannel1.phase1(); + phase1(); break; default: diff --git a/src/emucore/tia/AudioChannel.cxx b/src/emucore/tia/AudioChannel.cxx index 72db5a076..4bd8eaec0 100644 --- a/src/emucore/tia/AudioChannel.cxx +++ b/src/emucore/tia/AudioChannel.cxx @@ -77,7 +77,7 @@ void AudioChannel::phase0() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 AudioChannel::phase1() +void AudioChannel::phase1() { if (myClockEnable) { bool pulseFeedback = false; @@ -118,7 +118,10 @@ uInt8 AudioChannel::phase1() } } } +} +uInt8 AudioChannel::volume() +{ return (myPulseCounter & 0x01) * myAudv; } diff --git a/src/emucore/tia/AudioChannel.hxx b/src/emucore/tia/AudioChannel.hxx index 6302dcba3..f00938114 100644 --- a/src/emucore/tia/AudioChannel.hxx +++ b/src/emucore/tia/AudioChannel.hxx @@ -30,7 +30,9 @@ class AudioChannel : public Serializable void phase0(); - uInt8 phase1(); + void phase1(); + + uInt8 volume(); void audc(uInt8 value);