1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-17 21:30:14 +00:00

Begin 6522 wiring.

This commit is contained in:
Thomas Harte 2024-02-14 15:18:19 -05:00
parent 0dcceff410
commit 07c11e8268
4 changed files with 65 additions and 8 deletions

View File

@ -34,7 +34,7 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
Model model = Model::IIe;
DiskController disk_controller = DiskController::None;
SCSIController scsi_controller = SCSIController::None;
bool has_mockingboard = false;
bool has_mockingboard = true;
Target() : Analyser::Static::Target(Machine::AppleII) {
if(needs_declare()) {

View File

@ -26,6 +26,7 @@
#include "DiskIICard.hpp"
#include "Joystick.hpp"
#include "LanguageCardSwitches.hpp"
#include "Mockingboard.hpp"
#include "SCSICard.hpp"
#include "Video.hpp"
@ -92,9 +93,9 @@ class AYPair {
/// Provides an AY that runs at the CPU rate divided by 4 given an input of the master clock divided by 2,
/// allowing for stretched CPU clock cycles.
struct StretchedAY:
struct StretchedAYPair:
AYPair,
public Outputs::Speaker::BufferSource<StretchedAY, false> {
public Outputs::Speaker::BufferSource<StretchedAYPair, false> {
using AYPair::AYPair;
@ -195,12 +196,12 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
Concurrency::AsyncTaskQueue<false> audio_queue_;
Audio::Toggle audio_toggle_;
StretchedAY ay_;
StretchedAYPair ays_;
using SourceT =
std::conditional_t<has_mockingboard, Outputs::Speaker::CompoundSource<Audio::Toggle, StretchedAY>, Audio::Toggle>;
std::conditional_t<has_mockingboard, Outputs::Speaker::CompoundSource<Audio::Toggle, StretchedAYPair>, Audio::Toggle>;
using LowpassT = Outputs::Speaker::PullLowpass<SourceT>;
Outputs::Speaker::CompoundSource<Audio::Toggle, StretchedAY> mixer_;
Outputs::Speaker::CompoundSource<Audio::Toggle, StretchedAYPair> mixer_;
Outputs::Speaker::PullLowpass<SourceT> speaker_;
Cycles cycles_since_audio_update_;
@ -255,6 +256,10 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
pick_card_messaging_group(card);
}
Apple::II::Mockingboard *mockingboard() {
return dynamic_cast<Apple::II::Mockingboard *>(cards_[MockingboardSlot - 1].get());
}
Apple::II::DiskIICard *diskii_card() {
return dynamic_cast<Apple::II::DiskIICard *>(cards_[DiskIISlot - 1].get());
}
@ -580,8 +585,8 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
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 <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
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) {

View File

@ -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<AYVIA> vias_[2];
AYVIA handlers_[2];
};
}

View File

@ -1568,6 +1568,7 @@
4B71368D1F788112008B8ED9 /* Parser.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Parser.hpp; sourceTree = "<group>"; };
4B71368F1F789C93008B8ED9 /* SegmentParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SegmentParser.cpp; sourceTree = "<group>"; };
4B7136901F789C93008B8ED9 /* SegmentParser.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SegmentParser.hpp; sourceTree = "<group>"; };
4B72FAEF2B7D51BB000C7E90 /* Mockingboard.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Mockingboard.hpp; sourceTree = "<group>"; };
4B74CF7F2312FA9C00500CE8 /* HFV.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HFV.hpp; sourceTree = "<group>"; };
4B74CF802312FA9C00500CE8 /* HFV.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HFV.cpp; sourceTree = "<group>"; };
4B75F978280D7C5100121055 /* 68000DecoderTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = 68000DecoderTests.mm; sourceTree = "<group>"; };
@ -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 */,