From 82d6a5387f940954387ccea00766c4c1497d881f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 29 Jul 2020 21:06:41 -0400 Subject: [PATCH] Gives Qt disk controllers independent ROM/RAM selection logic. In particular, this fixes the Microdisc. --- Machines/Oric/BD500.hpp | 15 +++++++++++++++ Machines/Oric/DiskController.hpp | 22 ++++++---------------- Machines/Oric/Jasmin.hpp | 10 ++++++++++ Machines/Oric/Microdisc.cpp | 15 ++++++++++----- Storage/Disk/Controller/DiskController.cpp | 4 ++-- 5 files changed, 43 insertions(+), 23 deletions(-) diff --git a/Machines/Oric/BD500.hpp b/Machines/Oric/BD500.hpp index f371dd506..89d839db1 100644 --- a/Machines/Oric/BD500.hpp +++ b/Machines/Oric/BD500.hpp @@ -18,6 +18,11 @@ namespace Oric { +/*! + Emulates a Byte Drive 500, at least to some extent. Very little is known about this interface, + and I'm in possession of only a single disk image. So much of the below is community guesswork; + see the thread at https://forum.defence-force.org/viewtopic.php?f=25&t=2055 +*/ class BD500: public DiskController { public: BD500(); @@ -36,6 +41,16 @@ class BD500: public DiskController { void access(int address); void set_head_loaded(bool loaded); + + bool enable_overlay_ram_ = false; + bool disable_basic_rom_ = false; + void select_paged_item() { + PagedItem item = PagedItem::RAM; + if(!enable_overlay_ram_) { + item = disable_basic_rom_ ? PagedItem::DiskROM : PagedItem::BASIC; + } + set_paged_item(item); + } }; }; diff --git a/Machines/Oric/DiskController.hpp b/Machines/Oric/DiskController.hpp index 6cee28d63..91056a9c9 100644 --- a/Machines/Oric/DiskController.hpp +++ b/Machines/Oric/DiskController.hpp @@ -44,28 +44,18 @@ class DiskController: public WD::WD1770 { protected: Delegate *delegate_ = nullptr; - bool enable_overlay_ram_ = false; - bool disable_basic_rom_ = false; - void select_paged_item() { - PagedItem item = PagedItem::RAM; - if(!enable_overlay_ram_) { - item = disable_basic_rom_ ? PagedItem::DiskROM : PagedItem::BASIC; - } - set_paged_item(item); - } - - private: - PagedItem paged_item_ = PagedItem::DiskROM; - int clock_rate_; - Storage::Disk::Drive::ReadyType ready_type_; - - inline void set_paged_item(PagedItem item) { + void set_paged_item(PagedItem item) { if(paged_item_ == item) return; paged_item_ = item; if(delegate_) { delegate_->disk_controller_did_change_paged_item(this); } } + + private: + PagedItem paged_item_ = PagedItem::DiskROM; + int clock_rate_; + Storage::Disk::Drive::ReadyType ready_type_; }; diff --git a/Machines/Oric/Jasmin.hpp b/Machines/Oric/Jasmin.hpp index c496d6e1e..9793b92cf 100644 --- a/Machines/Oric/Jasmin.hpp +++ b/Machines/Oric/Jasmin.hpp @@ -29,6 +29,16 @@ class Jasmin: public DiskController { uint8_t selected_drives_ = 0; Activity::Observer *observer_ = nullptr; + + bool enable_overlay_ram_ = false; + bool disable_basic_rom_ = false; + void select_paged_item() { + PagedItem item = PagedItem::RAM; + if(!enable_overlay_ram_) { + item = disable_basic_rom_ ? PagedItem::DiskROM : PagedItem::BASIC; + } + set_paged_item(item); + } }; }; diff --git a/Machines/Oric/Microdisc.cpp b/Machines/Oric/Microdisc.cpp index 73c685507..4aac79ae7 100644 --- a/Machines/Oric/Microdisc.cpp +++ b/Machines/Oric/Microdisc.cpp @@ -38,7 +38,7 @@ void Microdisc::set_control_register(uint8_t control, uint8_t changes) { // b4: side select if(changes & 0x10) { - const int head = (control & 0x10) ? 1 : 0; + const int head = (control & 0x10) >> 4; for_all_drives([head] (Storage::Disk::Drive &drive, size_t) { drive.set_head(head); }); @@ -52,7 +52,7 @@ void Microdisc::set_control_register(uint8_t control, uint8_t changes) { // b0: IRQ enable if(changes & 0x01) { const bool had_irq = get_interrupt_request_line(); - irq_enable_ = !!(control & 0x01); + irq_enable_ = bool(control & 0x01); const bool has_irq = get_interrupt_request_line(); if(has_irq != had_irq && delegate_) { delegate_->wd1770_did_change_output(this); @@ -62,9 +62,14 @@ void Microdisc::set_control_register(uint8_t control, uint8_t changes) { // b7: EPROM select (0 = select) // b1: ROM disable (0 = disable) if(changes & 0x82) { - enable_overlay_ram_ = control & 0x80; - disable_basic_rom_ = !(control & 0x02); - select_paged_item(); + PagedItem item; + if(control & 0x02) item = PagedItem::BASIC; + else if(control & 0x80) { + item = PagedItem::RAM; + } else { + item = PagedItem::DiskROM; + } + set_paged_item(item); } } diff --git a/Storage/Disk/Controller/DiskController.cpp b/Storage/Disk/Controller/DiskController.cpp index 5972e2dc6..1cba5d39a 100644 --- a/Storage/Disk/Controller/DiskController.cpp +++ b/Storage/Disk/Controller/DiskController.cpp @@ -90,7 +90,7 @@ void Controller::set_drive(int index_mask) { return; } - ClockingHint::Preference former_prefernece = preferred_clocking(); + const ClockingHint::Preference former_preference = preferred_clocking(); // Stop receiving events from the current drive. get_drive().set_event_delegate(nullptr); @@ -114,7 +114,7 @@ void Controller::set_drive(int index_mask) { get_drive().set_event_delegate(this); - if(preferred_clocking() != former_prefernece) { + if(preferred_clocking() != former_preference) { update_clocking_observer(); } }