mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
Explained what this recently factored-out class does, and removed code from the header.
This commit is contained in:
parent
9c956f83b8
commit
cbbd31c2e0
@ -93,3 +93,45 @@ void TapePlayer::process_next_event()
|
||||
process_input_pulse(_current_pulse);
|
||||
get_next_pulse();
|
||||
}
|
||||
|
||||
#pragma mark - Binary Player
|
||||
|
||||
BinaryTapePlayer::BinaryTapePlayer(unsigned int input_clock_rate) :
|
||||
TapePlayer(input_clock_rate), _motor_is_running(false)
|
||||
{}
|
||||
|
||||
void BinaryTapePlayer::set_motor_control(bool enabled)
|
||||
{
|
||||
_motor_is_running = enabled;
|
||||
}
|
||||
|
||||
void BinaryTapePlayer::set_tape_output(bool set)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool BinaryTapePlayer::get_input()
|
||||
{
|
||||
return _input_level;
|
||||
}
|
||||
|
||||
void BinaryTapePlayer::run_for_cycles(int number_of_cycles)
|
||||
{
|
||||
if(_motor_is_running) TapePlayer::run_for_cycles(number_of_cycles);
|
||||
}
|
||||
|
||||
void BinaryTapePlayer::set_delegate(Delegate *delegate)
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
void BinaryTapePlayer::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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,39 +94,32 @@ class TapePlayer: public TimedEventLoop {
|
||||
Tape::Pulse _current_pulse;
|
||||
};
|
||||
|
||||
/*!
|
||||
A specific subclass of the tape player for machines that sample such as to report only either a
|
||||
high or a low current input level.
|
||||
|
||||
Such machines can use @c get_input() to get the current level of the input.
|
||||
|
||||
They can also provide a delegate to be notified upon any change in the input level.
|
||||
*/
|
||||
class BinaryTapePlayer: public TapePlayer {
|
||||
public:
|
||||
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; }
|
||||
BinaryTapePlayer(unsigned int input_clock_rate);
|
||||
void set_motor_control(bool enabled);
|
||||
void set_tape_output(bool set);
|
||||
bool get_input();
|
||||
|
||||
void run_for_cycles(int number_of_cycles) {
|
||||
if(_motor_is_running) {
|
||||
TapePlayer::run_for_cycles(number_of_cycles);
|
||||
}
|
||||
}
|
||||
void run_for_cycles(int number_of_cycles);
|
||||
|
||||
class Delegate {
|
||||
public:
|
||||
virtual void tape_did_change_input(BinaryTapePlayer *tape_player) = 0;
|
||||
};
|
||||
void set_delegate(Delegate *delegate)
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
void set_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);
|
||||
}
|
||||
}
|
||||
virtual void process_input_pulse(Storage::Tape::Tape::Pulse pulse);
|
||||
bool _input_level;
|
||||
bool _motor_is_running;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user