mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Updated TapePlayer
and BinaryTapePlayer
to be sleepers.
This commit is contained in:
parent
e88a51e75e
commit
8fdc5012e4
@ -65,10 +65,15 @@ void Tape::set_offset(uint64_t offset) {
|
||||
|
||||
#pragma mark - Player
|
||||
|
||||
bool TapePlayer::is_sleeping() {
|
||||
return !tape_ || tape_->is_at_end();
|
||||
}
|
||||
|
||||
void TapePlayer::set_tape(std::shared_ptr<Storage::Tape::Tape> tape) {
|
||||
tape_ = tape;
|
||||
reset_timer();
|
||||
get_next_pulse();
|
||||
update_sleep_observer();
|
||||
}
|
||||
|
||||
std::shared_ptr<Storage::Tape::Tape> TapePlayer::get_tape() {
|
||||
@ -81,8 +86,10 @@ bool TapePlayer::has_tape() {
|
||||
|
||||
void TapePlayer::get_next_pulse() {
|
||||
// get the new pulse
|
||||
if(tape_)
|
||||
if(tape_) {
|
||||
current_pulse_ = tape_->get_next_pulse();
|
||||
if(tape_->is_at_end()) update_sleep_observer();
|
||||
}
|
||||
else {
|
||||
current_pulse_.length.length = 1;
|
||||
current_pulse_.length.clock_rate = 1;
|
||||
@ -113,8 +120,13 @@ BinaryTapePlayer::BinaryTapePlayer(unsigned int input_clock_rate) :
|
||||
TapePlayer(input_clock_rate), motor_is_running_(false), input_level_(false), delegate_(nullptr)
|
||||
{}
|
||||
|
||||
bool BinaryTapePlayer::is_sleeping() {
|
||||
return !motor_is_running_ || TapePlayer::is_sleeping();
|
||||
}
|
||||
|
||||
void BinaryTapePlayer::set_motor_control(bool enabled) {
|
||||
motor_is_running_ = enabled;
|
||||
update_sleep_observer();
|
||||
}
|
||||
|
||||
void BinaryTapePlayer::set_tape_output(bool set) {
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <memory>
|
||||
|
||||
#include "../../ClockReceiver/ClockReceiver.hpp"
|
||||
#include "../../ClockReceiver/Sleeper.hpp"
|
||||
|
||||
#include "../TimedEventLoop.hpp"
|
||||
|
||||
namespace Storage {
|
||||
@ -93,7 +95,7 @@ class Tape {
|
||||
Will call @c process_input_pulse instantaneously upon reaching *the end* of a pulse. Therefore a subclass
|
||||
can decode pulses into data within process_input_pulse, using the supplied pulse's @c length and @c type.
|
||||
*/
|
||||
class TapePlayer: public TimedEventLoop {
|
||||
class TapePlayer: public TimedEventLoop, public Sleeper {
|
||||
public:
|
||||
TapePlayer(unsigned int input_clock_rate);
|
||||
|
||||
@ -105,6 +107,8 @@ class TapePlayer: public TimedEventLoop {
|
||||
|
||||
void run_for_input_pulse();
|
||||
|
||||
bool is_sleeping();
|
||||
|
||||
protected:
|
||||
virtual void process_next_event();
|
||||
virtual void process_input_pulse(const Tape::Pulse &pulse) = 0;
|
||||
@ -139,6 +143,8 @@ class BinaryTapePlayer: public TapePlayer {
|
||||
};
|
||||
void set_delegate(Delegate *delegate);
|
||||
|
||||
bool is_sleeping();
|
||||
|
||||
protected:
|
||||
Delegate *delegate_;
|
||||
virtual void process_input_pulse(const Storage::Tape::Tape::Pulse &pulse);
|
||||
|
Loading…
Reference in New Issue
Block a user