From 5504d280c7d1606c1cf64d26f6f06a200b5ca40c Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 3 Dec 2018 17:38:52 +0000 Subject: [PATCH] When drive is off then data register holds its present state. (Fixes #599) NB. Drive off = motor off && stopped spinning after 1 sec delay. --- source/Disk.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index d3998ae7..06cb34dc 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -892,10 +892,14 @@ static void __stdcall DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULO } } - // Should really test for drive off - after 1 second drive off delay (UTAIIe page 9-13) - // but Sherwood Forest sets shift mode and reads with the drive off, so don't check for now if (!floppywritemode) { + // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13) + // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12) + // Note: Sherwood Forest sets shift mode and reads with the drive off. + if (!pDrive->spinning) // GH#599 + return; + const ULONG nReadCycleDiff = (ULONG) (g_nCumulativeCycles - g_uDiskLastReadLatchCycle); // Support partial nibble read if disk reads are very close: (GH#582) @@ -954,10 +958,8 @@ static void __stdcall DiskReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULO if (++pFloppy->byte >= pFloppy->nibbles) pFloppy->byte = 0; - // Feature Request #201 Show track status - // https://github.com/AppleWin/AppleWin/issues/201 - // NB. Prevent flooding of forcing UI to redraw!!! - if( ((pFloppy->byte) & 0xFF) == 0 ) + // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! + if ((pFloppy->byte & 0xFF) == 0) FrameDrawDiskStatus( (HDC)0 ); } @@ -1052,11 +1054,16 @@ bool DiskSelect(const int iDrive) static void __stdcall DiskLoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG) { /* floppyloadmode = 1; */ + + // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13) + // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12) + // Note: Gemstone Warrior sets load mode with the drive off. + if (g_aFloppyDrive[currdrive].spinning) // GH#599 + return; + if (!write) { // Notes: - // . Should really test for drive off - after 1 second drive off delay (UTAIIe page 9-13) - // but Gemstone Warrior sets load mode with the drive off, so don't check for now // . Phase 1 on also forces write protect in the Disk II drive (UTAIIe page 9-7) but we don't implement that // . write mode doesn't prevent reading write protect (GH#537): // "If for some reason the above write protect check were entered with the READ/WRITE switch in WRITE,