diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 844b85f9c..78a63c13d 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -16,7 +16,8 @@ using namespace Commodore::Vic20; Machine::Machine() : _rom(nullptr), - _is_running_at_zero_cost(false) + _is_running_at_zero_cost(false), + _tape(1022727) { // create 6522s, serial port and bus _userPortVIA.reset(new UserPortVIA); @@ -350,36 +351,13 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) } } -//void Machine::set_tape(std::shared_ptr tape) -//{ -// _tape.set_tape(tape); -// if(_should_automatically_load_media) set_typer_for_string("LOAD\nRUN\n"); -//} - -void Machine::tape_did_change_input(Tape *tape) +void Machine::tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape) { _keyboardVIA->set_control_line_input(KeyboardVIA::Port::A, KeyboardVIA::Line::One, tape->get_input()); } #pragma mark - Disc -/*void Machine::set_disk(std::shared_ptr disk) -{ - // construct the 1540 - _c1540.reset(new ::Commodore::C1540::Machine); - - // attach it to the serial bus - _c1540->set_serial_bus(_serialBus); - - // hand it the disk - _c1540->set_disk(disk); - - // install the ROM if it was previously set - install_disk_rom(); - - if(_should_automatically_load_media) set_typer_for_string("LOAD\"*\",8,1\nRUN\n"); -}*/ - void Machine::install_disk_rom() { if(_driveROM && _c1540) @@ -496,20 +474,3 @@ bool Machine::typer_set_next_character(::Utility::Typer *typer, char character, return true; } -#pragma mark - Tape - -Tape::Tape() : TapePlayer(1022727) {} - -void Tape::set_motor_control(bool enabled) {} -void Tape::set_tape_output(bool set) {} - -void Tape::process_input_pulse(Storage::Tape::PRG::Pulse pulse) -{ - bool new_input_level = pulse.type == Storage::Tape::PRG::Pulse::Low; - if(_input_level != new_input_level) - { - _input_level = new_input_level; - if(_delegate) _delegate->tape_did_change_input(this); - } -} - diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index eb2bcabb5..f652bbdbe 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -214,29 +214,6 @@ class SerialPort : public ::Commodore::Serial::Port { std::weak_ptr _userPortVIA; }; -class Tape: public Storage::Tape::TapePlayer { - public: - Tape(); - - void set_motor_control(bool enabled); - void set_tape_output(bool set); - inline bool get_input() { return _input_level; } - - class Delegate { - public: - virtual void tape_did_change_input(Tape *tape) = 0; - }; - void set_delegate(Delegate *delegate) - { - _delegate = delegate; - } - - private: - Delegate *_delegate; - virtual void process_input_pulse(Storage::Tape::Tape::Pulse pulse); - bool _input_level; -}; - class Vic6560: public MOS::MOS6560 { public: inline void perform_read(uint16_t address, uint8_t *pixel_data, uint8_t *colour_data) @@ -254,7 +231,7 @@ class Machine: public CRTMachine::Machine, public MOS::MOS6522IRQDelegate::Delegate, public Utility::TypeRecipient, - public Tape::Delegate, + public Storage::Tape::BinaryTapePlayer::Delegate, public ConfigurationTarget::Machine { public: @@ -301,7 +278,7 @@ class Machine: virtual bool typer_set_next_character(Utility::Typer *typer, char character, int phase); // for Tape::Delegate - virtual void tape_did_change_input(Tape *tape); + virtual void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape); private: uint8_t _characterROM[0x1000]; @@ -332,7 +309,7 @@ class Machine: // std::shared_ptr<::Commodore::Serial::DebugPort> _debugPort; // Tape - Tape _tape; + Storage::Tape::BinaryTapePlayer _tape; bool _use_fast_tape_hack, _should_automatically_load_media; bool _is_running_at_zero_cost; diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index bf172d8ac..9307ec3d3 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -10,7 +10,7 @@ using namespace Oric; -Machine::Machine() : _cycles_since_video_update(0) +Machine::Machine() : _cycles_since_video_update(0), _tape(1000000) { set_clock_rate(1000000); _via.set_interrupt_delegate(this); @@ -107,3 +107,9 @@ void Machine::clear_all_keys() { memset(_keyboard->rows, 0, sizeof(_keyboard->rows)); } + +void Machine::tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player) +{ + // set CB1 + _via.set_control_line_input(VIA::Port::B, VIA::Line::One, tape_player->get_input()); +} diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index 132f09d14..10fae88b7 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -51,7 +51,8 @@ class Machine: public CPU6502::Processor, public CRTMachine::Machine, public ConfigurationTarget::Machine, - public MOS::MOS6522IRQDelegate::Delegate { + public MOS::MOS6522IRQDelegate::Delegate, + public Storage::Tape::BinaryTapePlayer::Delegate { public: Machine(); @@ -77,6 +78,9 @@ class Machine: // to satisfy MOS::MOS6522IRQDelegate::Delegate void mos6522_did_change_interrupt_status(void *mos6522); + // to satisfy Storage::Tape::BinaryTapePlayer::Delegate + void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player); + private: // RAM and ROM uint8_t _ram[65536], _rom[16384]; @@ -86,12 +90,17 @@ class Machine: // Outputs std::unique_ptr _videoOutput; - // + // Keyboard class Keyboard { public: uint8_t row; uint8_t rows[8]; }; + + // Tape player + Storage::Tape::BinaryTapePlayer _tape; + + // VIA class VIA: public MOS::MOS6522, public MOS::MOS6522IRQDelegate { public: using MOS6522IRQDelegate::set_interrupt_status; diff --git a/Storage/Tape/Tape.hpp b/Storage/Tape/Tape.hpp index cbf330e49..dc45e6e9c 100644 --- a/Storage/Tape/Tape.hpp +++ b/Storage/Tape/Tape.hpp @@ -94,6 +94,36 @@ class TapePlayer: public TimedEventLoop { Tape::Pulse _current_pulse; }; +class BinaryTapePlayer: public TapePlayer { + public: + BinaryTapePlayer(unsigned int input_clock_rate) : TapePlayer(input_clock_rate) {} + void set_motor_control(bool enabled) {} // TODO + void set_tape_output(bool set) {} // TODO + inline bool get_input() { return _input_level; } + + class Delegate { + public: + virtual void tape_did_change_input(BinaryTapePlayer *tape_player) = 0; + }; + void set_delegate(Delegate *delegate) + { + _delegate = delegate; + } + + private: + Delegate *_delegate; + virtual void process_input_pulse(Storage::Tape::Tape::Pulse pulse) + { + bool new_input_level = pulse.type == Tape::Pulse::Low; + if(_input_level != new_input_level) + { + _input_level = new_input_level; + if(_delegate) _delegate->tape_did_change_input(this); + } + } + bool _input_level; +}; + } }