diff --git a/Machines/Oric/Jasmin.cpp b/Machines/Oric/Jasmin.cpp index 8193ae87e..9282bd156 100644 --- a/Machines/Oric/Jasmin.cpp +++ b/Machines/Oric/Jasmin.cpp @@ -43,11 +43,21 @@ void Jasmin::write(int address, uint8_t value) { select_paged_item(); break; - case 0x3fc: case 0x3fd: case 0x3fe: case 0x3ff: - get_drive().set_motor_on(false); - set_drive(1 << (address - 0x3fc)); - get_drive().set_motor_on(motor_on_); - break; + case 0x3fc: case 0x3fd: case 0x3fe: case 0x3ff: { + // Updated selected drives mask. + const uint8_t mask = uint8_t(1 << (address - 0x3fc)); + selected_drives_ = (selected_drives_ & ~mask) | (mask * (value & 1)); + + // Select drive. + set_drive(selected_drives_); + + // Update motor inputs: apply the motor only to selected drives. + // Which may or may not be correct. + for_all_drives([mask, this] (Storage::Disk::Drive &drive, size_t index) { + const uint8_t shift_mask = uint8_t(1 << index); + drive.set_motor_on( (mask & shift_mask) ? motor_on_ : false ); + }); + } break; default: return WD::WD1770::write(address, value); diff --git a/Machines/Oric/Jasmin.hpp b/Machines/Oric/Jasmin.hpp index 7b3eb2b35..c496d6e1e 100644 --- a/Machines/Oric/Jasmin.hpp +++ b/Machines/Oric/Jasmin.hpp @@ -26,6 +26,7 @@ class Jasmin: public DiskController { private: void set_motor_on(bool on) final; bool motor_on_ = false; + uint8_t selected_drives_ = 0; Activity::Observer *observer_ = nullptr; };