1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Attempts to start getting the WDC working.

This commit is contained in:
Thomas Harte 2019-11-02 23:26:42 -04:00
parent 6d1e09ba55
commit 0567410bcf
3 changed files with 29 additions and 0 deletions

View File

@ -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;
}
};
}

View File

@ -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<Storage::Disk::Disk> disk, size_t drive) {
fdc_.drives_[drive]->set_disk(disk);
}
void DMAController::run_for(HalfCycles duration) {
running_time_ += duration;
fdc_.run_for(duration.flush<Cycles>());
}
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) {

View File

@ -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<Storage::Disk::Disk> 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 {