mirror of
https://github.com/TomHarte/CLK.git
synced 2024-08-21 04:29:34 +00:00
With lots of logging arising temporarily, fixed bug whereby conversion to a patched track would lead to holding a track with a distinct measure of time, leading to improperly-placed patches.
This commit is contained in:
parent
b538ee5bd8
commit
742c5df367
@ -535,7 +535,7 @@ void WD1770::posit_event(Event new_event_type)
|
|||||||
}
|
}
|
||||||
if(distance_into_section_ == 7)
|
if(distance_into_section_ == 7)
|
||||||
{
|
{
|
||||||
printf("Considering %d/%d\n", header_[0], header_[2]);
|
printf("Considering %d/%d at %0.4f\n", header_[0], header_[2], get_time_into_track().get_float());
|
||||||
is_reading_data_ = false;
|
is_reading_data_ = false;
|
||||||
if(header_[0] == track_ && header_[2] == sector_ &&
|
if(header_[0] == track_ && header_[2] == sector_ &&
|
||||||
(has_motor_on_line() || !(command_&0x02) || ((command_&0x08) >> 3) == header_[1]))
|
(has_motor_on_line() || !(command_&0x02) || ((command_&0x08) >> 3) == header_[1]))
|
||||||
@ -563,6 +563,7 @@ void WD1770::posit_event(Event new_event_type)
|
|||||||
});
|
});
|
||||||
distance_into_section_ = 0;
|
distance_into_section_ = 0;
|
||||||
is_reading_data_ = true;
|
is_reading_data_ = true;
|
||||||
|
printf("\n");
|
||||||
goto type2_read_byte;
|
goto type2_read_byte;
|
||||||
}
|
}
|
||||||
goto type2_read_data;
|
goto type2_read_data;
|
||||||
@ -570,7 +571,7 @@ void WD1770::posit_event(Event new_event_type)
|
|||||||
type2_read_byte:
|
type2_read_byte:
|
||||||
WAIT_FOR_EVENT(Event::Token);
|
WAIT_FOR_EVENT(Event::Token);
|
||||||
if(latest_token_.type != Token::Byte) goto type2_read_byte;
|
if(latest_token_.type != Token::Byte) goto type2_read_byte;
|
||||||
data_ = latest_token_.byte_value;
|
data_ = latest_token_.byte_value; printf("%02x", data_);
|
||||||
update_status([] (Status &status) {
|
update_status([] (Status &status) {
|
||||||
status.lost_data |= status.data_request;
|
status.lost_data |= status.data_request;
|
||||||
status.data_request = true;
|
status.data_request = true;
|
||||||
@ -579,6 +580,7 @@ void WD1770::posit_event(Event new_event_type)
|
|||||||
if(distance_into_section_ == 128 << header_[3])
|
if(distance_into_section_ == 128 << header_[3])
|
||||||
{
|
{
|
||||||
distance_into_section_ = 0;
|
distance_into_section_ = 0;
|
||||||
|
printf("\n");
|
||||||
goto type2_check_crc;
|
goto type2_check_crc;
|
||||||
}
|
}
|
||||||
goto type2_read_byte;
|
goto type2_read_byte;
|
||||||
@ -640,9 +642,10 @@ void WD1770::posit_event(Event new_event_type)
|
|||||||
|
|
||||||
WAIT_FOR_EVENT(Event::DataWritten);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
distance_into_section_ = 0;
|
distance_into_section_ = 0;
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
type2_write_loop:
|
type2_write_loop:
|
||||||
write_byte(data_);
|
write_byte(data_); printf("%02x", data_);
|
||||||
update_status([] (Status &status) {
|
update_status([] (Status &status) {
|
||||||
status.data_request = true;
|
status.data_request = true;
|
||||||
});
|
});
|
||||||
@ -650,6 +653,7 @@ void WD1770::posit_event(Event new_event_type)
|
|||||||
distance_into_section_++;
|
distance_into_section_++;
|
||||||
if(distance_into_section_ == 128 << header_[3])
|
if(distance_into_section_ == 128 << header_[3])
|
||||||
{
|
{
|
||||||
|
printf("\n");
|
||||||
goto type2_write_crc;
|
goto type2_write_crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,11 +166,15 @@ void Controller::end_writing()
|
|||||||
|
|
||||||
if(!patched_track_)
|
if(!patched_track_)
|
||||||
{
|
{
|
||||||
// TODO: is the track already actually a patched track?
|
// Avoid creating a new patched track if this one is already patched
|
||||||
// see dynamic_pointer_cast
|
patched_track_ = std::dynamic_pointer_cast<PCMPatchedTrack>(track_);
|
||||||
patched_track_.reset(new PCMPatchedTrack(track_));
|
if(!patched_track_)
|
||||||
|
{
|
||||||
|
patched_track_.reset(new PCMPatchedTrack(track_));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
patched_track_->add_segment(write_start_time_, write_segment_);
|
patched_track_->add_segment(write_start_time_, write_segment_);
|
||||||
|
invalidate_track(); // TEMPORARY: to force a seek
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - PLL control and delegate
|
#pragma mark - PLL control and delegate
|
||||||
|
@ -110,6 +110,7 @@ class Controller: public DigitalPhaseLockedLoop::Delegate, public TimedEventLoop
|
|||||||
void step(int direction);
|
void step(int direction);
|
||||||
virtual bool get_drive_is_ready();
|
virtual bool get_drive_is_ready();
|
||||||
bool get_drive_is_read_only();
|
bool get_drive_is_read_only();
|
||||||
|
Time get_time_into_track();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Time bit_length_;
|
Time bit_length_;
|
||||||
@ -135,7 +136,6 @@ class Controller: public DigitalPhaseLockedLoop::Delegate, public TimedEventLoop
|
|||||||
Time cycles_per_bit_;
|
Time cycles_per_bit_;
|
||||||
|
|
||||||
void setup_track();
|
void setup_track();
|
||||||
Time get_time_into_track();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,7 @@ void PCMPatchedTrack::add_segment(const Time &start_time, const PCMSegment &segm
|
|||||||
|
|
||||||
// the vector may have been resized, potentially invalidating active_period_ even if
|
// the vector may have been resized, potentially invalidating active_period_ even if
|
||||||
// the thing it pointed to is still the same thing. So work it out afresh.
|
// the thing it pointed to is still the same thing. So work it out afresh.
|
||||||
active_period_ = periods_.begin();
|
insertion_error_ = current_time_ - seek_to(current_time_);
|
||||||
while(active_period_->start_time > current_time_) active_period_++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCMPatchedTrack::insert_period(const Period &period)
|
void PCMPatchedTrack::insert_period(const Period &period)
|
||||||
@ -155,7 +154,8 @@ Track::Event PCMPatchedTrack::get_next_event()
|
|||||||
else event = underlying_track_->get_next_event();
|
else event = underlying_track_->get_next_event();
|
||||||
|
|
||||||
// see what time that gets us to. If it's still within the current period, return the found event
|
// see what time that gets us to. If it's still within the current period, return the found event
|
||||||
Time event_time = current_time_ + event.length - period_error;
|
Time event_time = current_time_ + event.length - period_error - insertion_error_;
|
||||||
|
insertion_error_.set_zero();
|
||||||
if(event_time < active_period_->end_time)
|
if(event_time < active_period_->end_time)
|
||||||
{
|
{
|
||||||
current_time_ = event_time;
|
current_time_ = event_time;
|
||||||
|
@ -52,7 +52,7 @@ class PCMPatchedTrack: public Track {
|
|||||||
};
|
};
|
||||||
std::vector<Period> periods_;
|
std::vector<Period> periods_;
|
||||||
std::vector<Period>::iterator active_period_;
|
std::vector<Period>::iterator active_period_;
|
||||||
Time current_time_;
|
Time current_time_, insertion_error_;
|
||||||
|
|
||||||
void insert_period(const Period &period);
|
void insert_period(const Period &period);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user