1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-30 22:56:03 +00:00

Drives now have a finite number of heads.

The Amstrad volunteers itself to be single sided. Everything else stays as it was.
This commit is contained in:
Thomas Harte 2017-09-15 21:18:36 -04:00
parent 35fe4d50d4
commit da082673d7
9 changed files with 14 additions and 10 deletions

View File

@ -587,7 +587,7 @@ class FDC: public Intel::i8272::i8272 {
public:
FDC() :
i8272(bus_handler_, Cycles(8000000)),
drive_(new Storage::Disk::Drive(8000000, 300)) {
drive_(new Storage::Disk::Drive(8000000, 300, 1)) {
set_drive(drive_);
}

View File

@ -23,7 +23,7 @@ MachineBase::MachineBase() :
serial_port_VIA_port_handler_(new SerialPortVIA(serial_port_VIA_)),
drive_VIA_(drive_VIA_port_handler_),
serial_port_VIA_(*serial_port_VIA_port_handler_),
drive_(new Storage::Disk::Drive(1000000, 300)) {
drive_(new Storage::Disk::Drive(1000000, 300, 2)) {
// attach the serial port to its VIA and vice versa
serial_port_->set_serial_port_via(serial_port_VIA_port_handler_);
serial_port_VIA_port_handler_->set_serial_port(serial_port_);

View File

@ -16,7 +16,7 @@ Plus3::Plus3() : WD1770(P1770) {
void Plus3::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive) {
if(!drives_[drive]) {
drives_[drive].reset(new Storage::Disk::Drive(8000000, 300));
drives_[drive].reset(new Storage::Disk::Drive(8000000, 300, 2));
if(drive == selected_drive_) set_drive(drives_[drive]);
}
drives_[drive]->set_disk(disk);

View File

@ -30,7 +30,7 @@ Microdisc::Microdisc() :
void Microdisc::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive) {
if(!drives_[drive]) {
drives_[drive].reset(new Storage::Disk::Drive(8000000, 300));
drives_[drive].reset(new Storage::Disk::Drive(8000000, 300, 2));
if(drive == selected_drive_) set_drive(drives_[drive]);
}
drives_[drive]->set_disk(disk);

View File

@ -22,7 +22,7 @@ class CommodoreGCRParser: public Storage::Disk::Controller {
std::shared_ptr<Storage::Disk::Drive> drive;
CommodoreGCRParser() : Storage::Disk::Controller(4000000), shift_register_(0), track_(1) {
drive.reset(new Storage::Disk::Drive(4000000, 300));
drive.reset(new Storage::Disk::Drive(4000000, 300, 2));
set_drive(drive);
drive->set_motor_on(true);
}

View File

@ -15,7 +15,7 @@ using namespace Storage::Disk;
Controller::Controller(Cycles clock_rate) :
clock_rate_multiplier_(128000000 / clock_rate.as_int()),
clock_rate_(clock_rate.as_int() * clock_rate_multiplier_),
empty_drive_(new Drive((unsigned int)clock_rate.as_int(), 1)) {
empty_drive_(new Drive((unsigned int)clock_rate.as_int(), 1, 1)) {
// seed this class with a PLL, any PLL, so that it's safe to assume non-nullptr later
Time one(1);
set_expected_bit_length(one);

View File

@ -15,9 +15,10 @@
using namespace Storage::Disk;
Drive::Drive(unsigned int input_clock_rate, int revolutions_per_minute):
Drive::Drive(unsigned int input_clock_rate, int revolutions_per_minute, unsigned int number_of_heads):
Storage::TimedEventLoop(input_clock_rate),
rotational_multiplier_(60, revolutions_per_minute) {
rotational_multiplier_(60, revolutions_per_minute),
available_heads_(number_of_heads) {
}
void Drive::set_disk(const std::shared_ptr<Disk> &disk) {
@ -51,6 +52,7 @@ void Drive::step(int direction) {
}
void Drive::set_head(unsigned int head) {
head = std::min(head, available_heads_ - 1);
if(head != head_) {
head_ = head;
track_ = nullptr;
@ -73,6 +75,7 @@ bool Drive::get_is_read_only() {
}
bool Drive::get_is_ready() {
return true;
return ready_index_count_ == 2;
}

View File

@ -23,7 +23,7 @@ namespace Disk {
class Drive: public Sleeper, public TimedEventLoop {
public:
Drive(unsigned int input_clock_rate, int revolutions_per_minute);
Drive(unsigned int input_clock_rate, int revolutions_per_minute, unsigned int number_of_heads);
/*!
Replaces whatever is in the drive with @c disk.
@ -140,6 +140,7 @@ class Drive: public Sleeper, public TimedEventLoop {
// A record of head position and active head.
int head_position_ = 0;
unsigned int head_ = 0;
unsigned int available_heads_ = 0;
// Motor control state.
bool motor_is_on_ = false;

View File

@ -244,7 +244,7 @@ Parser::Parser(bool is_mfm) :
bit_length.clock_rate = is_mfm ? 500000 : 250000; // i.e. 250 kbps (including clocks)
set_expected_bit_length(bit_length);
drive_.reset(new Storage::Disk::Drive(4000000, 300));
drive_.reset(new Storage::Disk::Drive(4000000, 300, 2));
set_drive(drive_);
drive_->set_motor_on(true);
}