From 07c11e8268a7a1389c793fa80da80c9f6b2487a5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 14 Feb 2024 15:18:19 -0500 Subject: [PATCH] Begin 6522 wiring. --- Analyser/Static/AppleII/Target.hpp | 2 +- Machines/Apple/AppleII/AppleII.cpp | 25 ++++++++--- Machines/Apple/AppleII/Mockingboard.hpp | 44 +++++++++++++++++++ .../Clock Signal.xcodeproj/project.pbxproj | 2 + 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 Machines/Apple/AppleII/Mockingboard.hpp diff --git a/Analyser/Static/AppleII/Target.hpp b/Analyser/Static/AppleII/Target.hpp index 8002a2009..f08bf1f68 100644 --- a/Analyser/Static/AppleII/Target.hpp +++ b/Analyser/Static/AppleII/Target.hpp @@ -34,7 +34,7 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl { + public Outputs::Speaker::BufferSource { using AYPair::AYPair; @@ -195,12 +196,12 @@ template Concurrency::AsyncTaskQueue audio_queue_; Audio::Toggle audio_toggle_; - StretchedAY ay_; + StretchedAYPair ays_; using SourceT = - std::conditional_t, Audio::Toggle>; + std::conditional_t, Audio::Toggle>; using LowpassT = Outputs::Speaker::PullLowpass; - Outputs::Speaker::CompoundSource mixer_; + Outputs::Speaker::CompoundSource mixer_; Outputs::Speaker::PullLowpass speaker_; Cycles cycles_since_audio_update_; @@ -255,6 +256,10 @@ template pick_card_messaging_group(card); } + Apple::II::Mockingboard *mockingboard() { + return dynamic_cast(cards_[MockingboardSlot - 1].get()); + } + Apple::II::DiskIICard *diskii_card() { return dynamic_cast(cards_[DiskIISlot - 1].get()); } @@ -580,8 +585,8 @@ template video_bus_handler_(ram_, aux_ram_), video_(video_bus_handler_), audio_toggle_(audio_queue_), - ay_(audio_queue_), - mixer_(audio_toggle_, ay_), + ays_(audio_queue_), + mixer_(audio_toggle_, ays_), speaker_(lowpass_source()), language_card_(*this), auxiliary_switches_(*this), @@ -659,6 +664,12 @@ template install_card(SCSISlot, new Apple::II::SCSICard(roms, int(master_clock / 14.0f))); } + if(target.has_mockingboard) { + // The Mockingboard has a parasitic relationship with this class due to the way + // that audio outputs are implemented in this emulator. + install_card(MockingboardSlot, new Apple::II::Mockingboard()); + } + rom_ = std::move(roms.find(system)->second); // The IIe and Enhanced IIe ROMs often distributed are oversized; trim if necessary. if(system == ROM::Name::AppleIIe || system == ROM::Name::AppleIIEnhancedE) { diff --git a/Machines/Apple/AppleII/Mockingboard.hpp b/Machines/Apple/AppleII/Mockingboard.hpp new file mode 100644 index 000000000..dbde129e5 --- /dev/null +++ b/Machines/Apple/AppleII/Mockingboard.hpp @@ -0,0 +1,44 @@ +// +// Mockingboard.hpp +// Clock Signal +// +// Created by Thomas Harte on 14/02/2024. +// Copyright © 2024 Thomas Harte. All rights reserved. +// + +#pragma once + +#include "Card.hpp" + +#include "../../../Components/6522/6522.hpp" + + +namespace Apple::II { + +class Mockingboard: public Card { + public: + Mockingboard() : + vias_{ {handlers_[0]}, {handlers_[1]} } {} + + void perform_bus_operation(Select select, bool is_read, uint16_t address, uint8_t *value) final { + if(!(select & Device)) { + return; + } + + int index = (address >> 7) & 1; + if(is_read) { + *value = vias_[index].read(address); + } else { + vias_[index].write(address, *value); + } + } + + private: + class AYVIA: public MOS::MOS6522::IRQDelegatePortHandler { + }; + + MOS::MOS6522::MOS6522 vias_[2]; + AYVIA handlers_[2]; +}; + +} diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 3babbde3e..069031998 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -1568,6 +1568,7 @@ 4B71368D1F788112008B8ED9 /* Parser.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Parser.hpp; sourceTree = ""; }; 4B71368F1F789C93008B8ED9 /* SegmentParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SegmentParser.cpp; sourceTree = ""; }; 4B7136901F789C93008B8ED9 /* SegmentParser.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SegmentParser.hpp; sourceTree = ""; }; + 4B72FAEF2B7D51BB000C7E90 /* Mockingboard.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Mockingboard.hpp; sourceTree = ""; }; 4B74CF7F2312FA9C00500CE8 /* HFV.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HFV.hpp; sourceTree = ""; }; 4B74CF802312FA9C00500CE8 /* HFV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HFV.cpp; sourceTree = ""; }; 4B75F978280D7C5100121055 /* 68000DecoderTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = 68000DecoderTests.mm; sourceTree = ""; }; @@ -4840,6 +4841,7 @@ 4B2E86E125DC95150024F1E9 /* Joystick.hpp */, 4BF40A5525424C770033EA39 /* LanguageCardSwitches.hpp */, 4BE0151C286A8C8E00EA42E9 /* MemorySwitches.hpp */, + 4B72FAEF2B7D51BB000C7E90 /* Mockingboard.hpp */, 4B4C81C428B3C5CD00F84AE9 /* SCSICard.hpp */, 4BCE004F227CE8CA000CA200 /* Video.hpp */, 4B8DF4F2254E141700F3433C /* VideoSwitches.hpp */,