mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-04 17:56:29 +00:00
Puts the disk controller back into the loop with knowledge about reading mode, and uses that knowledge to cut off the PLL.
This commit is contained in:
parent
b62f3e726a
commit
4d4a0cf1d2
@ -541,7 +541,7 @@ void WD1770::posit_event(int new_event_type) {
|
|||||||
});
|
});
|
||||||
WAIT_FOR_EVENT(Event::DataWritten);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
if(status_.data_request) {
|
if(status_.data_request) {
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
update_status([] (Status &status) {
|
update_status([] (Status &status) {
|
||||||
status.lost_data = true;
|
status.lost_data = true;
|
||||||
});
|
});
|
||||||
@ -554,7 +554,7 @@ void WD1770::posit_event(int new_event_type) {
|
|||||||
write_crc();
|
write_crc();
|
||||||
write_byte(0xff);
|
write_byte(0xff);
|
||||||
WAIT_FOR_EVENT(Event::DataWritten);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
|
|
||||||
if(command_ & 0x10) {
|
if(command_ & 0x10) {
|
||||||
sector_++;
|
sector_++;
|
||||||
@ -755,11 +755,11 @@ void WD1770::posit_event(int new_event_type) {
|
|||||||
update_status([] (Status &status) {
|
update_status([] (Status &status) {
|
||||||
status.lost_data = true;
|
status.lost_data = true;
|
||||||
});
|
});
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
goto wait_for_command;
|
goto wait_for_command;
|
||||||
}
|
}
|
||||||
if(index_hole_count_) {
|
if(index_hole_count_) {
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
goto wait_for_command;
|
goto wait_for_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
WAIT_FOR_EVENT(Event::DataWritten);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
if(!has_input_) {
|
if(!has_input_) {
|
||||||
SetOverrun();
|
SetOverrun();
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
write_byte(input_);
|
write_byte(input_);
|
||||||
@ -540,7 +540,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
write_crc();
|
write_crc();
|
||||||
expects_input_ = false;
|
expects_input_ = false;
|
||||||
WAIT_FOR_EVENT(Event::DataWritten);
|
WAIT_FOR_EVENT(Event::DataWritten);
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
|
|
||||||
if(sector_ != command_[6]) {
|
if(sector_ != command_[6]) {
|
||||||
sector_++;
|
sector_++;
|
||||||
@ -646,7 +646,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
switch(event_type) {
|
switch(event_type) {
|
||||||
case (int)Event::IndexHole:
|
case (int)Event::IndexHole:
|
||||||
SetOverrun();
|
SetOverrun();
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
goto abort;
|
goto abort;
|
||||||
break;
|
break;
|
||||||
case (int)Event::DataWritten:
|
case (int)Event::DataWritten:
|
||||||
@ -683,7 +683,7 @@ void i8272::posit_event(int event_type) {
|
|||||||
WAIT_FOR_EVENT((int)Event::DataWritten | (int)Event::IndexHole);
|
WAIT_FOR_EVENT((int)Event::DataWritten | (int)Event::IndexHole);
|
||||||
if(event_type != (int)Event::IndexHole) goto format_track_pad;
|
if(event_type != (int)Event::IndexHole) goto format_track_pad;
|
||||||
|
|
||||||
get_drive().end_writing();
|
end_writing();
|
||||||
|
|
||||||
cylinder_ = header_[0];
|
cylinder_ = header_[0];
|
||||||
head_ = header_[1];
|
head_ = header_[1];
|
||||||
|
@ -48,7 +48,7 @@ void Controller::process_event(const Track::Event &event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Controller::advance(const Cycles cycles) {
|
void Controller::advance(const Cycles cycles) {
|
||||||
pll_->run_for(Cycles(cycles.as_int() * clock_rate_multiplier_));
|
if(is_reading_) pll_->run_for(Cycles(cycles.as_int() * clock_rate_multiplier_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::process_write_completed() {
|
void Controller::process_write_completed() {
|
||||||
@ -72,7 +72,7 @@ void Controller::set_expected_bit_length(Time bit_length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Controller::digital_phase_locked_loop_output_bit(int value) {
|
void Controller::digital_phase_locked_loop_output_bit(int value) {
|
||||||
process_input_bit(value);
|
if(is_reading_) process_input_bit(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::set_drive(std::shared_ptr<Drive> drive) {
|
void Controller::set_drive(std::shared_ptr<Drive> drive) {
|
||||||
@ -99,5 +99,15 @@ void Controller::set_drive(std::shared_ptr<Drive> drive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Controller::begin_writing(bool clamp_to_index_hole) {
|
void Controller::begin_writing(bool clamp_to_index_hole) {
|
||||||
|
is_reading_ = false;
|
||||||
get_drive().begin_writing(bit_length_, clamp_to_index_hole);
|
get_drive().begin_writing(bit_length_, clamp_to_index_hole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::end_writing() {
|
||||||
|
is_reading_ = true;
|
||||||
|
get_drive().end_writing();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Controller::is_reading() {
|
||||||
|
return is_reading_;
|
||||||
|
}
|
||||||
|
@ -68,13 +68,25 @@ class Controller: public DigitalPhaseLockedLoop::Delegate, public Drive::EventDe
|
|||||||
virtual void process_write_completed();
|
virtual void process_write_completed();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Puts the drive returned by get_drive() into write mode, supplying the current bit length.
|
Puts the drive returned by get_drive() into write mode, supplying the current bit length
|
||||||
|
and marks the controller as being in write mode.
|
||||||
|
|
||||||
@param clamp_to_index_hole If @c true then writing will automatically be truncated by
|
@param clamp_to_index_hole If @c true then writing will automatically be truncated by
|
||||||
the index hole. Writing will continue over the index hole otherwise.
|
the index hole. Writing will continue over the index hole otherwise.
|
||||||
*/
|
*/
|
||||||
void begin_writing(bool clamp_to_index_hole);
|
void begin_writing(bool clamp_to_index_hole);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Puts the drive returned by get_drive() out of write mode, and marks the controller
|
||||||
|
as no longer being in write mode.
|
||||||
|
*/
|
||||||
|
void end_writing();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@returns @c true if the controller is in reading mode; @c false otherwise.
|
||||||
|
*/
|
||||||
|
bool is_reading();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the connected drive or, if none is connected, an invented one. No guarantees are
|
Returns the connected drive or, if none is connected, an invented one. No guarantees are
|
||||||
made about the lifetime or the exclusivity of the invented drive.
|
made about the lifetime or the exclusivity of the invented drive.
|
||||||
@ -85,8 +97,10 @@ class Controller: public DigitalPhaseLockedLoop::Delegate, public Drive::EventDe
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Time bit_length_;
|
Time bit_length_;
|
||||||
int clock_rate_multiplier_;
|
int clock_rate_multiplier_ = 1;
|
||||||
int clock_rate_;
|
int clock_rate_ = 1;
|
||||||
|
|
||||||
|
bool is_reading_ = true;
|
||||||
|
|
||||||
std::shared_ptr<DigitalPhaseLockedLoop> pll_;
|
std::shared_ptr<DigitalPhaseLockedLoop> pll_;
|
||||||
std::shared_ptr<Drive> drive_;
|
std::shared_ptr<Drive> drive_;
|
||||||
|
Loading…
Reference in New Issue
Block a user