mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Updated curly bracket placement.
This commit is contained in:
parent
e5b30cdfbb
commit
e5aea632ee
@ -19,22 +19,19 @@ TapePlayer::TapePlayer(unsigned int input_clock_rate) :
|
|||||||
|
|
||||||
#pragma mark - Seeking
|
#pragma mark - Seeking
|
||||||
|
|
||||||
void Storage::Tape::Tape::seek(Time &seek_time)
|
void Storage::Tape::Tape::seek(Time &seek_time) {
|
||||||
{
|
|
||||||
current_time_.set_zero();
|
current_time_.set_zero();
|
||||||
next_time_.set_zero();
|
next_time_.set_zero();
|
||||||
while(next_time_ < seek_time) get_next_pulse();
|
while(next_time_ < seek_time) get_next_pulse();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Storage::Tape::Tape::reset()
|
void Storage::Tape::Tape::reset() {
|
||||||
{
|
|
||||||
current_time_.set_zero();
|
current_time_.set_zero();
|
||||||
next_time_.set_zero();
|
next_time_.set_zero();
|
||||||
virtual_reset();
|
virtual_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Tape::Pulse Tape::get_next_pulse()
|
Tape::Pulse Tape::get_next_pulse() {
|
||||||
{
|
|
||||||
Tape::Pulse pulse = virtual_get_next_pulse();
|
Tape::Pulse pulse = virtual_get_next_pulse();
|
||||||
current_time_ = next_time_;
|
current_time_ = next_time_;
|
||||||
next_time_ += pulse.length;
|
next_time_ += pulse.length;
|
||||||
@ -43,30 +40,25 @@ Tape::Pulse Tape::get_next_pulse()
|
|||||||
|
|
||||||
#pragma mark - Player
|
#pragma mark - Player
|
||||||
|
|
||||||
void TapePlayer::set_tape(std::shared_ptr<Storage::Tape::Tape> tape)
|
void TapePlayer::set_tape(std::shared_ptr<Storage::Tape::Tape> tape) {
|
||||||
{
|
|
||||||
tape_ = tape;
|
tape_ = tape;
|
||||||
reset_timer();
|
reset_timer();
|
||||||
get_next_pulse();
|
get_next_pulse();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Storage::Tape::Tape> TapePlayer::get_tape()
|
std::shared_ptr<Storage::Tape::Tape> TapePlayer::get_tape() {
|
||||||
{
|
|
||||||
return tape_;
|
return tape_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TapePlayer::has_tape()
|
bool TapePlayer::has_tape() {
|
||||||
{
|
|
||||||
return (bool)tape_;
|
return (bool)tape_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TapePlayer::get_next_pulse()
|
void TapePlayer::get_next_pulse() {
|
||||||
{
|
|
||||||
// get the new pulse
|
// get the new pulse
|
||||||
if(tape_)
|
if(tape_)
|
||||||
current_pulse_ = tape_->get_next_pulse();
|
current_pulse_ = tape_->get_next_pulse();
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
current_pulse_.length.length = 1;
|
current_pulse_.length.length = 1;
|
||||||
current_pulse_.length.clock_rate = 1;
|
current_pulse_.length.clock_rate = 1;
|
||||||
current_pulse_.type = Tape::Pulse::Zero;
|
current_pulse_.type = Tape::Pulse::Zero;
|
||||||
@ -75,21 +67,17 @@ void TapePlayer::get_next_pulse()
|
|||||||
set_next_event_time_interval(current_pulse_.length);
|
set_next_event_time_interval(current_pulse_.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TapePlayer::run_for_cycles(int number_of_cycles)
|
void TapePlayer::run_for_cycles(int number_of_cycles) {
|
||||||
{
|
if(has_tape()) {
|
||||||
if(has_tape())
|
|
||||||
{
|
|
||||||
TimedEventLoop::run_for_cycles(number_of_cycles);
|
TimedEventLoop::run_for_cycles(number_of_cycles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TapePlayer::run_for_input_pulse()
|
void TapePlayer::run_for_input_pulse() {
|
||||||
{
|
|
||||||
jump_to_next_event();
|
jump_to_next_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TapePlayer::process_next_event()
|
void TapePlayer::process_next_event() {
|
||||||
{
|
|
||||||
process_input_pulse(current_pulse_);
|
process_input_pulse(current_pulse_);
|
||||||
get_next_pulse();
|
get_next_pulse();
|
||||||
}
|
}
|
||||||
@ -100,38 +88,30 @@ BinaryTapePlayer::BinaryTapePlayer(unsigned int input_clock_rate) :
|
|||||||
TapePlayer(input_clock_rate), motor_is_running_(false)
|
TapePlayer(input_clock_rate), motor_is_running_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void BinaryTapePlayer::set_motor_control(bool enabled)
|
void BinaryTapePlayer::set_motor_control(bool enabled) {
|
||||||
{
|
|
||||||
motor_is_running_ = enabled;
|
motor_is_running_ = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryTapePlayer::set_tape_output(bool set)
|
void BinaryTapePlayer::set_tape_output(bool set) {
|
||||||
{
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BinaryTapePlayer::get_input()
|
bool BinaryTapePlayer::get_input() {
|
||||||
{
|
|
||||||
return input_level_;
|
return input_level_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryTapePlayer::run_for_cycles(int number_of_cycles)
|
void BinaryTapePlayer::run_for_cycles(int number_of_cycles) {
|
||||||
{
|
|
||||||
if(motor_is_running_) TapePlayer::run_for_cycles(number_of_cycles);
|
if(motor_is_running_) TapePlayer::run_for_cycles(number_of_cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryTapePlayer::set_delegate(Delegate *delegate)
|
void BinaryTapePlayer::set_delegate(Delegate *delegate) {
|
||||||
{
|
|
||||||
delegate_ = delegate;
|
delegate_ = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryTapePlayer::process_input_pulse(Storage::Tape::Tape::Pulse pulse)
|
void BinaryTapePlayer::process_input_pulse(Storage::Tape::Tape::Pulse pulse) {
|
||||||
{
|
|
||||||
bool new_input_level = pulse.type == Tape::Pulse::Low;
|
bool new_input_level = pulse.type == Tape::Pulse::Low;
|
||||||
if(input_level_ != new_input_level)
|
if(input_level_ != new_input_level) {
|
||||||
{
|
|
||||||
input_level_ = new_input_level;
|
input_level_ = new_input_level;
|
||||||
if(delegate_) delegate_->tape_did_change_input(this);
|
if(delegate_) delegate_->tape_did_change_input(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user