1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Implements the real hardware ready test for Drives — motor on plus two index holes.

This commit is contained in:
Thomas Harte 2017-09-11 22:27:50 -04:00
parent 9ac831b09c
commit 82b13e98f2
2 changed files with 7 additions and 6 deletions

View File

@ -26,9 +26,6 @@ void Drive::set_disk(const std::shared_ptr<Disk> &disk) {
invalidate_track();
update_sleep_observer();
// TODO: implement ready properly.
is_ready_ = true;
}
bool Drive::has_disk() {
@ -76,11 +73,14 @@ bool Drive::get_is_read_only() {
}
bool Drive::get_is_ready() {
return is_ready_;
return ready_index_count_ == 2;
}
void Drive::set_motor_on(bool motor_is_on) {
motor_is_on_ = motor_is_on;
if(!motor_is_on) {
ready_index_count_ = 0;
}
update_sleep_observer();
}
@ -160,6 +160,7 @@ void Drive::process_next_event() {
// TODO: ready test here.
if(current_event_.type == Track::Event::IndexHole) {
assert(get_time_into_track() == Time(1) || get_time_into_track() == Time(0));
if(ready_index_count_ < 2) ready_index_count_++;
cycles_since_index_hole_ = 0;
}
if(event_delegate_) event_delegate_->process_event(current_event_);

View File

@ -155,8 +155,8 @@ class Drive: public Sleeper, public TimedEventLoop {
PCMSegment write_segment_;
Time write_start_time_;
// Indicates drive ready state.
bool is_ready_ = false;
// Indicates progress towards drive ready state.
int ready_index_count_ = 0;
// Maintains appropriate counting to know when to indicate that writing
// is complete.