From 117f9a9794237e4779c28b8e3e62a3b9a3845323 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 21 Jun 2021 07:31:58 -0400 Subject: [PATCH] Adds notes on intended meaning of status register. --- Machines/Enterprise/EXDos.cpp | 41 ++++++++++++++++++++++-------- Machines/Enterprise/EXDos.hpp | 2 +- Machines/Enterprise/Enterprise.cpp | 2 +- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Machines/Enterprise/EXDos.cpp b/Machines/Enterprise/EXDos.cpp index cec9c34e9..189a18468 100644 --- a/Machines/Enterprise/EXDos.cpp +++ b/Machines/Enterprise/EXDos.cpp @@ -17,12 +17,30 @@ EXDos::EXDos() : WD1770(P1770) { void EXDos::set_disk(std::shared_ptr disk, size_t drive) { get_drive(drive).set_disk(disk); + disk_did_change_ = true; } -void EXDos::set_control_register(uint8_t control) { - printf("Control: %02x\n", control); +// Documentation for the control register: +// +// Write: +// b7 in use (???) +// b6 disk change reset +// b5 0 = double density, 1 = single density +// b4 side 1 select +// b3, b3, b1, b0 select drive 3, 2, 1, 0 +// +// Read: +// b7 data request from WD1770 +// b6 disk change +// b5, b4, b3, b2: not used +// b1 interrupt request from WD1770 +// b0 drive ready - last_control_ = control; +void EXDos::set_control_register(uint8_t control) { + printf("Set control: %02x\n", control); + + if(control & 0x40) disk_did_change_ = false; + set_is_double_density(!(control & 0x20)); // Set side. const int head = (control >> 4) & 1; @@ -38,16 +56,19 @@ void EXDos::set_control_register(uint8_t control) { set_drive(c); } } - - // TODO: seems like bit 6 might be connected to the drive's RDY line? - - // TODO: does part of this register select double/single density mode? - // Probably either bit 5 or bit 7 of the control register? - set_is_double_density(true); } uint8_t EXDos::get_control_register() { - return last_control_ | (get_drive().get_is_ready() ? 0x40 : 0x00); + // TODO: how does disk_did_change_ really work? Presumably + // it latches RDY? + const uint8_t status = + (get_data_request_line() ? 0x80 : 0x00) | + (disk_did_change_ ? 0x40 : 0x00) | + (get_interrupt_request_line() ? 0x02 : 0x00) | + (get_drive().get_is_ready() ? 0x01 : 0x00); + + printf("Get status: %02x\n", status); + return status; } void EXDos::set_motor_on(bool on) { diff --git a/Machines/Enterprise/EXDos.hpp b/Machines/Enterprise/EXDos.hpp index cc60a0033..42d8f81c1 100644 --- a/Machines/Enterprise/EXDos.hpp +++ b/Machines/Enterprise/EXDos.hpp @@ -24,7 +24,7 @@ class EXDos final : public WD::WD1770 { uint8_t get_control_register(); private: - uint8_t last_control_ = 0; + bool disk_did_change_ = false; void set_motor_on(bool on) override; }; diff --git a/Machines/Enterprise/Enterprise.cpp b/Machines/Enterprise/Enterprise.cpp index cd5dd6188..ee0a598e4 100644 --- a/Machines/Enterprise/Enterprise.cpp +++ b/Machines/Enterprise/Enterprise.cpp @@ -287,7 +287,7 @@ template class ConcreteMachine: case 0xa4: case 0xa5: case 0xa6: case 0xa7: case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf: - printf("TODO: audio adjust %04x <- %02x\n", address, *cycle.value); +// printf("TODO: audio adjust %04x <- %02x\n", address, *cycle.value); break; case 0xb4: