diff --git a/Machines/AtariST/AtariST.cpp b/Machines/AtariST/AtariST.cpp index 87821642d..9edf3b0dd 100644 --- a/Machines/AtariST/AtariST.cpp +++ b/Machines/AtariST/AtariST.cpp @@ -47,7 +47,8 @@ class ConcreteMachine: public Motorola::MFP68901::MFP68901::InterruptDelegate, public DMAController::InterruptDelegate, public MouseMachine::Machine, - public KeyboardMachine::MappedMachine { + public KeyboardMachine::MappedMachine, + public GI::AY38910::PortHandler { public: ConcreteMachine(const Target &target, const ROMMachine::ROMFetcher &rom_fetcher) : mc68000_(*this), @@ -99,6 +100,7 @@ class ConcreteMachine: mfp_->set_interrupt_delegate(this); dma_->set_interrupt_delegate(this); + ay_.set_port_handler(this); set_gpip_input(); } @@ -235,18 +237,6 @@ class ConcreteMachine: ay_.set_data_input(cycle.value8_high()); ay_.set_control_lines(GI::AY38910::ControlLines(0)); } - - /* - TODO: Port A: - b7: reserved - b6: "freely usable output (monitor jack)" - b5: centronics strobe - b4: RS-232 DTR output - b3: RS-232 RTS output - b2: select floppy drive 1 - b1: select floppy drive 0 - b0: "page choice signal for double-sided floppy drive" - */ return HalfCycles(2); // The MFP block: @@ -501,6 +491,25 @@ class ConcreteMachine: return &keyboard_mapper_; } + // MARK: - AYPortHandler + void set_port_output(bool port_b, uint8_t value) final { + if(port_b) { + // TODO: ? + } else { + /* + TODO: Port A: + b7: reserved + b6: "freely usable output (monitor jack)" + b5: centronics strobe + b4: RS-232 DTR output + b3: RS-232 RTS output + b2: select floppy drive 1 + b1: select floppy drive 0 + b0: "page choice signal for double-sided floppy drive" + */ + dma_->set_floppy_drive_selection(value & 2, value & 4, value & 1); + } + } }; } diff --git a/Machines/AtariST/DMAController.cpp b/Machines/AtariST/DMAController.cpp index 46ba8865e..2bb64a9c3 100644 --- a/Machines/AtariST/DMAController.cpp +++ b/Machines/AtariST/DMAController.cpp @@ -81,6 +81,10 @@ void DMAController::write(int address, uint16_t value) { } } +void DMAController::set_floppy_drive_selection(bool drive1, bool drive2, bool side2) { + fdc_.set_floppy_drive_selection(drive1, drive2, side2); +} + void DMAController::run_for(HalfCycles duration) { running_time_ += duration; fdc_.run_for(duration.flush()); diff --git a/Machines/AtariST/DMAController.hpp b/Machines/AtariST/DMAController.hpp index cbedc18ed..6e4194537 100644 --- a/Machines/AtariST/DMAController.hpp +++ b/Machines/AtariST/DMAController.hpp @@ -29,6 +29,8 @@ 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); + struct InterruptDelegate { virtual void dma_controller_did_change_interrupt_status(DMAController *) = 0; }; @@ -51,6 +53,18 @@ class DMAController: public WD::WD1770::Delegate, public ClockingHint::Source, p drives_[1]->set_motor_on(motor_on); } + void set_floppy_drive_selection(bool drive1, bool drive2, bool side2) { + // TODO: handle no drives and/or both drives selected. + if(drive1) { + set_drive(drives_[0]); + } else { + set_drive(drives_[1]); + } + + drives_[0]->set_head(side2); + drives_[1]->set_head(side2); + } + std::vector> drives_; } fdc_;