diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 9307ec3d3..1297e0e07 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -10,17 +10,23 @@ using namespace Oric; -Machine::Machine() : _cycles_since_video_update(0), _tape(1000000) +Machine::Machine() : _cycles_since_video_update(0) { set_clock_rate(1000000); + _via.tape.reset(new Storage::Tape::BinaryTapePlayer(1000000)); _via.set_interrupt_delegate(this); _keyboard.reset(new Keyboard); _via.keyboard = _keyboard; clear_all_keys(); + _via.tape->set_delegate(this); } void Machine::configure_as_target(const StaticAnalyser::Target &target) { + if(target.tapes.size()) + { + _via.tape->set_tape(target.tapes.front()); + } } void Machine::set_rom(std::vector data) @@ -54,6 +60,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin } _via.run_for_half_cycles(2); + _via.tape->run_for_cycles(1); _cycles_since_video_update++; return 1; } diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index 10fae88b7..baf37008f 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -97,10 +97,7 @@ class Machine: uint8_t rows[8]; }; - // Tape player - Storage::Tape::BinaryTapePlayer _tape; - - // VIA + // VIA (which owns the tape and the AY) class VIA: public MOS::MOS6522, public MOS::MOS6522IRQDelegate { public: using MOS6522IRQDelegate::set_interrupt_status; @@ -118,6 +115,7 @@ class Machine: if(port) { keyboard->row = value; + tape->set_motor_control(value & 0x40); } else { @@ -145,6 +143,7 @@ class Machine: } std::shared_ptr ay8910; + std::shared_ptr tape; std::shared_ptr keyboard; inline void synchronise() { update_ay(); } diff --git a/Storage/Tape/Tape.hpp b/Storage/Tape/Tape.hpp index dc45e6e9c..fcf2b3d2a 100644 --- a/Storage/Tape/Tape.hpp +++ b/Storage/Tape/Tape.hpp @@ -96,11 +96,17 @@ class TapePlayer: public TimedEventLoop { class BinaryTapePlayer: public TapePlayer { public: - BinaryTapePlayer(unsigned int input_clock_rate) : TapePlayer(input_clock_rate) {} - void set_motor_control(bool enabled) {} // TODO + BinaryTapePlayer(unsigned int input_clock_rate) : TapePlayer(input_clock_rate), _motor_is_running(false) {} + void set_motor_control(bool enabled) { _motor_is_running = enabled; } void set_tape_output(bool set) {} // TODO inline bool get_input() { return _input_level; } + void run_for_cycles(int number_of_cycles) { + if(_motor_is_running) { + TapePlayer::run_for_cycles(number_of_cycles); + } + } + class Delegate { public: virtual void tape_did_change_input(BinaryTapePlayer *tape_player) = 0; @@ -122,6 +128,7 @@ class BinaryTapePlayer: public TapePlayer { } } bool _input_level; + bool _motor_is_running; }; }