mirror of
https://github.com/TomHarte/CLK.git
synced 2024-08-17 07:29:04 +00:00
Fixed potential bug whereby inserting a disk into a drive that hadn't been lazily allocated yet but had already been selected wouldn't take effect.
This commit is contained in:
parent
ea33a28695
commit
09f965e6a9
@ -12,8 +12,12 @@ using namespace Electron;
|
|||||||
|
|
||||||
void Plus3::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive)
|
void Plus3::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, int drive)
|
||||||
{
|
{
|
||||||
if(!_drives[drive]) _drives[drive].reset(new Storage::Disk::Drive);
|
if(!drives_[drive])
|
||||||
_drives[drive]->set_disk(disk);
|
{
|
||||||
|
drives_[drive].reset(new Storage::Disk::Drive);
|
||||||
|
if(drive == selected_drive_) set_drive(drives_[drive]);
|
||||||
|
}
|
||||||
|
drives_[drive]->set_disk(disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plus3::set_control_register(uint8_t control)
|
void Plus3::set_control_register(uint8_t control)
|
||||||
@ -25,11 +29,11 @@ void Plus3::set_control_register(uint8_t control)
|
|||||||
// bit 3 => single density select
|
// bit 3 => single density select
|
||||||
switch(control&3)
|
switch(control&3)
|
||||||
{
|
{
|
||||||
case 0: set_drive(nullptr); break;
|
case 0: selected_drive_ = -1; set_drive(nullptr); break;
|
||||||
default: set_drive(_drives[0]); break;
|
default: selected_drive_ = 0; set_drive(drives_[0]); break;
|
||||||
case 2: set_drive(_drives[1]); break;
|
case 2: selected_drive_ = 1; set_drive(drives_[1]); break;
|
||||||
}
|
}
|
||||||
if(_drives[0]) _drives[0]->set_head((control & 0x04) ? 1 : 0);
|
if(drives_[0]) drives_[0]->set_head((control & 0x04) ? 1 : 0);
|
||||||
if(_drives[1]) _drives[1]->set_head((control & 0x04) ? 1 : 0);
|
if(drives_[1]) drives_[1]->set_head((control & 0x04) ? 1 : 0);
|
||||||
set_is_double_density(!(control & 0x08));
|
set_is_double_density(!(control & 0x08));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ class Plus3 : public WD::WD1770 {
|
|||||||
void set_control_register(uint8_t control);
|
void set_control_register(uint8_t control);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Storage::Disk::Drive> _drives[2];
|
std::shared_ptr<Storage::Disk::Drive> drives_[2];
|
||||||
|
int selected_drive_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user