From 2a684ab3029a20b62995652ebab0da8c92a04757 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 14 Feb 2024 10:55:53 -0500 Subject: [PATCH] Include a single AY in the mix if appropriate. --- Machines/Apple/AppleII/AppleII.cpp | 48 ++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 63ab3713a..8680d6ce3 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -17,6 +17,7 @@ #include "../../../Components/AudioToggle/AudioToggle.hpp" #include "../../../Components/AY38910/AY38910.hpp" +#include "../../../Outputs/Speaker/Implementation/CompoundSource.hpp" #include "../../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp" #include "../../../Outputs/Log.hpp" @@ -65,6 +66,8 @@ struct StretchedAY: public GI::AY38910::AY38910SampleSource, public Outputs::Speaker::BufferSource { + using GI::AY38910::AY38910SampleSource::AY38910SampleSource; + template void apply_samples(std::size_t number_of_samples, Outputs::Speaker::MonoSample *target) { @@ -104,7 +107,7 @@ struct StretchedAY: namespace Apple { namespace II { -template class ConcreteMachine: +template class ConcreteMachine: public Apple::II::Machine, public MachineTypes::TimedMachine, public MachineTypes::ScanProducer, @@ -162,9 +165,23 @@ template class ConcreteMachine: Concurrency::AsyncTaskQueue audio_queue_; Audio::Toggle audio_toggle_; - Outputs::Speaker::PullLowpass speaker_; + StretchedAY ay_; + using SourceT = + std::conditional_t, Audio::Toggle>; + using LowpassT = Outputs::Speaker::PullLowpass; + + Outputs::Speaker::CompoundSource mixer_; + Outputs::Speaker::PullLowpass speaker_; Cycles cycles_since_audio_update_; + constexpr SourceT &lowpass_source() { + if constexpr (has_mockingboard) { + return mixer_; + } else { + return audio_toggle_; + } + } + // MARK: - Cards static constexpr size_t NoActiveCard = 7; // There is no 'card 0' in internal numbering. size_t active_card_ = NoActiveCard; @@ -533,7 +550,9 @@ template class ConcreteMachine: video_bus_handler_(ram_, aux_ram_), video_(video_bus_handler_), audio_toggle_(audio_queue_), - speaker_(audio_toggle_), + ay_(GI::AY38910::Personality::AY38910, audio_queue_), + mixer_(audio_toggle_, ay_), + speaker_(lowpass_source()), language_card_(*this), auxiliary_switches_(*this), keyboard_(&m6502_) { @@ -1039,12 +1058,23 @@ using namespace Apple::II; std::unique_ptr Machine::AppleII(const Analyser::Static::Target *target, const ROMMachine::ROMFetcher &rom_fetcher) { using Target = Analyser::Static::AppleII::Target; const Target *const appleii_target = dynamic_cast(target); - switch(appleii_target->model) { - default: return nullptr; - case Target::Model::II: return std::make_unique>(*appleii_target, rom_fetcher); - case Target::Model::IIplus: return std::make_unique>(*appleii_target, rom_fetcher); - case Target::Model::IIe: return std::make_unique>(*appleii_target, rom_fetcher); - case Target::Model::EnhancedIIe: return std::make_unique>(*appleii_target, rom_fetcher); + + if(appleii_target->has_mockingboard) { + switch(appleii_target->model) { + default: return nullptr; + case Target::Model::II: return std::make_unique>(*appleii_target, rom_fetcher); + case Target::Model::IIplus: return std::make_unique>(*appleii_target, rom_fetcher); + case Target::Model::IIe: return std::make_unique>(*appleii_target, rom_fetcher); + case Target::Model::EnhancedIIe: return std::make_unique>(*appleii_target, rom_fetcher); + } + } else { + switch(appleii_target->model) { + default: return nullptr; + case Target::Model::II: return std::make_unique>(*appleii_target, rom_fetcher); + case Target::Model::IIplus: return std::make_unique>(*appleii_target, rom_fetcher); + case Target::Model::IIe: return std::make_unique>(*appleii_target, rom_fetcher); + case Target::Model::EnhancedIIe: return std::make_unique>(*appleii_target, rom_fetcher); + } } }