From 0567410bcfebf5762e595e2fb6368d355e8dd79b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 2 Nov 2019 23:26:42 -0400 Subject: [PATCH] Attempts to start getting the WDC working. --- Machines/AtariST/AtariST.cpp | 16 ++++++++++++++++ Machines/AtariST/DMAController.cpp | 11 +++++++++++ Machines/AtariST/DMAController.hpp | 2 ++ 3 files changed, 29 insertions(+) diff --git a/Machines/AtariST/AtariST.cpp b/Machines/AtariST/AtariST.cpp index 9edf3b0dd..1e9f0a9ab 100644 --- a/Machines/AtariST/AtariST.cpp +++ b/Machines/AtariST/AtariST.cpp @@ -11,6 +11,7 @@ #include "../CRTMachine.hpp" #include "../KeyboardMachine.hpp" #include "../MouseMachine.hpp" +#include "../MediaTarget.hpp" //#define LOG_TRACE #include "../../Processors/68000/68000.hpp" @@ -48,6 +49,7 @@ class ConcreteMachine: public DMAController::InterruptDelegate, public MouseMachine::Machine, public KeyboardMachine::MappedMachine, + public MediaTarget::Machine, public GI::AY38910::PortHandler { public: ConcreteMachine(const Target &target, const ROMMachine::ROMFetcher &rom_fetcher) : @@ -103,6 +105,9 @@ class ConcreteMachine: ay_.set_port_handler(this); set_gpip_input(); + + // Insert any supplied media. + insert_media(target.media); } ~ConcreteMachine() { @@ -510,6 +515,17 @@ class ConcreteMachine: dma_->set_floppy_drive_selection(value & 2, value & 4, value & 1); } } + + // MARK: - MediaTarget + bool insert_media(const Analyser::Static::Media &media) final { + size_t c = 0; + for(const auto &disk: media.disks) { + dma_->set_floppy_disk(disk, c); + ++c; + if(c == 2) break; + } + return true; + } }; } diff --git a/Machines/AtariST/DMAController.cpp b/Machines/AtariST/DMAController.cpp index 2bb64a9c3..3f29af579 100644 --- a/Machines/AtariST/DMAController.cpp +++ b/Machines/AtariST/DMAController.cpp @@ -85,17 +85,28 @@ void DMAController::set_floppy_drive_selection(bool drive1, bool drive2, bool si fdc_.set_floppy_drive_selection(drive1, drive2, side2); } +void DMAController::set_floppy_disk(std::shared_ptr disk, size_t drive) { + fdc_.drives_[drive]->set_disk(disk); +} + void DMAController::run_for(HalfCycles duration) { running_time_ += duration; fdc_.run_for(duration.flush()); } void DMAController::wd1770_did_change_output(WD::WD1770 *) { + // Check for a change in interrupt state. const bool old_interrupt_line = interrupt_line_; interrupt_line_ = fdc_.get_interrupt_request_line(); if(interrupt_delegate_ && interrupt_line_ != old_interrupt_line) { interrupt_delegate_->dma_controller_did_change_interrupt_status(this); } + + // TODO: check for a data request. + if(fdc_.get_data_request_line()) { + // TODO: something? + printf("DRQ?\n"); + } } void DMAController::set_interrupt_delegate(InterruptDelegate *delegate) { diff --git a/Machines/AtariST/DMAController.hpp b/Machines/AtariST/DMAController.hpp index 6e4194537..79b362a22 100644 --- a/Machines/AtariST/DMAController.hpp +++ b/Machines/AtariST/DMAController.hpp @@ -30,6 +30,7 @@ class DMAController: public WD::WD1770::Delegate, public ClockingHint::Source, p bool get_interrupt_line(); void set_floppy_drive_selection(bool drive1, bool drive2, bool side2); + void set_floppy_disk(std::shared_ptr disk, size_t drive); struct InterruptDelegate { virtual void dma_controller_did_change_interrupt_status(DMAController *) = 0; @@ -46,6 +47,7 @@ class DMAController: public WD::WD1770::Delegate, public ClockingHint::Source, p drives_.emplace_back(new Storage::Disk::Drive(8000000, 300, 2)); drives_.emplace_back(new Storage::Disk::Drive(8000000, 300, 2)); set_drive(drives_[0]); + set_is_double_density(true); // TODO: is this selectable on the ST? } void set_motor_on(bool motor_on) final {