From 92d5875f59c33bff46bcd74ff259a004255de559 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 11 Oct 2020 20:17:55 +0300 Subject: [PATCH] Return random data if disk DMA started with selected drive but motor turned off. --- disk.cpp | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/disk.cpp b/disk.cpp index 3b31b695..cd7a517a 100644 --- a/disk.cpp +++ b/disk.cpp @@ -3633,21 +3633,6 @@ static int doreaddma (void) return 0; } -static void disk_doupdate_read_nothing(int floppybits) -{ - while (floppybits >= get_floppy_speed ()) { - word <<= 1; - doreaddma (); - if ((bitoffset & 7) == 7) { - dskbytr_val = word & 0xff; - dskbytr_val |= 0x8000; - } - bitoffset++; - bitoffset &= 15; - floppybits -= get_floppy_speed (); - } -} - static void wordsync_detected(bool startup) { dsksync_cycles = get_cycles() + WORDSYNC_TIME * CYCLE_UNIT; @@ -3674,6 +3659,37 @@ static void wordsync_detected(bool startup) } } +static void disk_doupdate_read_nothing(int floppybits) +{ + while (floppybits >= get_floppy_speed()) { + bool skipbit = false; + word <<= 1; + word |= (uaerand() & 0x1000) ? 1 : 0; + doreaddma(); + // MSBSYNC + if (adkcon & 0x200) { + if ((word & 0x0001) == 0 && bitoffset == 0) { + word = 0; + skipbit = true; + } + if ((word & 0x0001) == 0 && bitoffset == 8) { + word >>= 1; + skipbit = true; + } + } + if (!skipbit && (bitoffset & 7) == 7) { + dskbytr_val = word & 0xff; + dskbytr_val |= 0x8000; + } + if (!(adkcon & 0x200) && word == dsksync) { + wordsync_detected(false); + } + bitoffset++; + bitoffset &= 15; + floppybits -= get_floppy_speed(); + } +} + static void disk_doupdate_read (drive * drv, int floppybits) { /* -- 2.47.3