From 7996fe6dab7bfab8802377a5080fdae94e157453 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 30 Aug 2022 16:40:25 -0400 Subject: [PATCH] 'Clock' the SCSI bus (i.e. make it aware of passing time). --- Machines/Apple/AppleII/AppleII.cpp | 5 ++++- Machines/Apple/AppleII/Card.hpp | 2 +- Machines/Apple/AppleII/SCSICard.cpp | 6 +++--- Machines/Apple/AppleII/SCSICard.hpp | 6 +++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 7a1b5fb68..7a63a981e 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -494,7 +494,10 @@ template class ConcreteMachine: if(has_scsi_card) { // Install the SCSI card in slot 7, to one-up any connected Disk II. - install_card(7, new Apple::II::SCSICard(roms)); + // + // Rounding the clock rate slightly shouldn't matter, but: + // TODO: be [slightly] more honest about clock rate. + install_card(7, new Apple::II::SCSICard(roms, int(master_clock / 14.0f))); } rom_ = std::move(roms.find(system)->second); diff --git a/Machines/Apple/AppleII/Card.hpp b/Machines/Apple/AppleII/Card.hpp index 386e5d657..60c3bd519 100644 --- a/Machines/Apple/AppleII/Card.hpp +++ b/Machines/Apple/AppleII/Card.hpp @@ -58,7 +58,7 @@ class Card { no constraints, that want to be informed of every machine cycle, will receive a call to perform_bus_operation every cycle and should use that for time keeping. */ - virtual void run_for([[maybe_unused]] Cycles half_cycles, [[maybe_unused]] int stretches) {} + virtual void run_for([[maybe_unused]] Cycles cycles, [[maybe_unused]] int stretches) {} /// Requests a flush of any pending audio or video output. virtual void flush() {} diff --git a/Machines/Apple/AppleII/SCSICard.cpp b/Machines/Apple/AppleII/SCSICard.cpp index 62b73cd9a..0c5dbd43e 100644 --- a/Machines/Apple/AppleII/SCSICard.cpp +++ b/Machines/Apple/AppleII/SCSICard.cpp @@ -58,9 +58,9 @@ ROM::Request SCSICard::rom_request() { } // TODO: accept and supply real clock rate. -SCSICard::SCSICard(ROM::Map &map) : - scsi_bus_(1), - ncr5380_(scsi_bus_, 1), +SCSICard::SCSICard(ROM::Map &map, int clock_rate) : + scsi_bus_(clock_rate), + ncr5380_(scsi_bus_, clock_rate), storage_(scsi_bus_, 6) { // Grab a copy of the SCSI ROM. diff --git a/Machines/Apple/AppleII/SCSICard.hpp b/Machines/Apple/AppleII/SCSICard.hpp index d00627db4..8ce7ce20d 100644 --- a/Machines/Apple/AppleII/SCSICard.hpp +++ b/Machines/Apple/AppleII/SCSICard.hpp @@ -27,12 +27,16 @@ namespace II { class SCSICard: public Card { public: static ROM::Request rom_request(); - SCSICard(ROM::Map &); + SCSICard(ROM::Map &, int clock_rate); void perform_bus_operation(Select select, bool is_read, uint16_t address, uint8_t *value) final; void set_storage_device(const std::shared_ptr &device); + void run_for([[maybe_unused]] Cycles cycles, [[maybe_unused]] int stretches) final { + scsi_bus_.run_for(cycles); + } + private: uint8_t *ram_pointer_ = nullptr; uint8_t *rom_pointer_ = nullptr;