From 23a1e64e9f0f7674d48228795647aa0387686577 Mon Sep 17 00:00:00 2001 From: "Christopher A. Mosher" Date: Wed, 19 Dec 2018 23:52:21 -0500 Subject: [PATCH] implement LSS writing (to WOZ TRKS in memory) --- src/diskcontroller.cpp | 16 ++++++++++------ src/diskcontroller.h | 1 + src/wozfile.cpp | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/diskcontroller.cpp b/src/diskcontroller.cpp index 5ddd081..b6fae26 100644 --- a/src/diskcontroller.cpp +++ b/src/diskcontroller.cpp @@ -90,8 +90,11 @@ void DiskController::tick() { rotateCurrentDisk(); // run two LSS cycles = 2MHz + stepLss(); + // pulse lasts only 500 nanoseconds (1 LSS clock cycle), so clear it now: this->currentDrive->clearPulse(); + stepLss(); } @@ -109,8 +112,14 @@ void DiskController::stepLss() { this->seq = cmd & 0xF0u; // LSS command functions (UA2, 9-15, Table 9.3) -// printf("%02x:", cmd); if (cmd & 8u) { + if (cmd & 3u) { + if (this->write) { + const bool one = (seq&0x80u) != (this->prev_seq&0x80u); + this->prev_seq = seq; + this->currentDrive->writeBit(one); + } + } switch (cmd & 3u) { case 3: this->dataRegister = this->dataBusReadOnlyCopy; @@ -118,15 +127,10 @@ void DiskController::stepLss() { case 2: this->dataRegister >>= 1; this->dataRegister |= (isWriteProtected() << 7); - // TODO how to handle writing? break; case 1: this->dataRegister <<= 1; this->dataRegister |= ((cmd & 4u) >> 2); -// printf(this->dataRegister & 0x80u ? "\x1b[30;42m" : "\x1b[30;43m"); -// printf("%02X\x1b[0m ", this->dataRegister); -// if (this->dataRegister & 0x80u) printf("\n"); - // TODO how to handle writing? break; } } else { diff --git a/src/diskcontroller.h b/src/diskcontroller.h index ef3fa1f..45fc65b 100644 --- a/src/diskcontroller.h +++ b/src/diskcontroller.h @@ -58,6 +58,7 @@ private: // For ease of use, we store the 4-bit seq number in the _high order_ nibble here. // On the real Apple the read pulse goes thru this LS174 too, but we don't emulate that here. + std::uint8_t prev_seq; // remember previous seq, to determine if A7 changes (indicating write a 1 bit) std::uint8_t t; // used to keep track of 4 MPU cycles // TODO for a rev. 0 motherboard, the disk controller will auto reset the CPU (see UA2, 9-13) diff --git a/src/wozfile.cpp b/src/wozfile.cpp index 3541dbe..70c97ba 100644 --- a/src/wozfile.cpp +++ b/src/wozfile.cpp @@ -254,7 +254,7 @@ static std::uint8_t cb(std::uint8_t bit) { /* * Rotate the floppy disk by one bit. - * In real life we don't care what track we're one, but for the + * In real life we don't care what track we're on, but for the * emulator we need to know. This is because the tracks within the * WOZ file could be different lengths. So in order to know when * we need to loop back to the beginning of the track (circular