From f5eeb2681d2cc1af975cd5cbd161b78644d68d51 Mon Sep 17 00:00:00 2001 From: pnp2084 Date: Sat, 22 Oct 2022 02:13:31 -0700 Subject: wd_fdc: reset the contents of data_reg when the sync is changed --- src/devices/machine/wd_fdc.cpp | 29 ++++++++++++++++++----------- src/devices/machine/wd_fdc.h | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/devices/machine/wd_fdc.cpp b/src/devices/machine/wd_fdc.cpp index 1310dc2a792..bb2d798e554 100644 --- a/src/devices/machine/wd_fdc.cpp +++ b/src/devices/machine/wd_fdc.cpp @@ -1683,6 +1683,14 @@ bool wd_fdc_device_base::read_one_bit(const attotime &limit) return false; } +void wd_fdc_device_base::reset_data_sync() +{ + cur_live.data_separator_phase = false; + cur_live.bit_counter = 0; + + cur_live.data_reg = bitswap<8>(cur_live.shift_reg, 14, 12, 10, 8, 6, 4, 2, 0); +} + bool wd_fdc_device_base::write_one_bit(const attotime &limit) { bool bit = cur_live.shift_reg & 0x8000; @@ -1779,15 +1787,13 @@ void wd_fdc_device_base::live_run(attotime limit) if(!dden && cur_live.shift_reg == 0x4489) { cur_live.crc = 0x443b; - cur_live.data_separator_phase = false; - cur_live.bit_counter = 0; + reset_data_sync(); cur_live.state = READ_HEADER_BLOCK_HEADER; } if(dden && cur_live.shift_reg == 0xf57e) { cur_live.crc = 0xef21; - cur_live.data_separator_phase = false; - cur_live.bit_counter = 0; + reset_data_sync(); if(main_state == READ_ID) cur_live.state = READ_ID_BLOCK_TO_DMA; else @@ -1907,8 +1913,7 @@ void wd_fdc_device_base::live_run(attotime limit) if(cur_live.bit_counter >= 28*16 && cur_live.shift_reg == 0x4489) { cur_live.crc = 0x443b; - cur_live.data_separator_phase = false; - cur_live.bit_counter = 0; + reset_data_sync(); cur_live.state = READ_DATA_BLOCK_HEADER; } } else { @@ -1925,6 +1930,8 @@ void wd_fdc_device_base::live_run(attotime limit) cur_live.shift_reg == 0xf56e ? 0xafa5 : 0xbf84; + reset_data_sync(); + if(extended_ddam) { if(!(cur_live.data_reg & 1)) status |= S_DDM; @@ -1933,8 +1940,6 @@ void wd_fdc_device_base::live_run(attotime limit) } else if((cur_live.data_reg & 0xfe) == 0xf8) status |= S_DDM; - cur_live.data_separator_phase = false; - cur_live.bit_counter = 0; cur_live.state = READ_SECTOR_DATA; } } @@ -2033,7 +2038,10 @@ void wd_fdc_device_base::live_run(attotime limit) // FM resyncs && !(dden && (cur_live.shift_reg == 0xf57e // FM IDAM || cur_live.shift_reg == 0xf56f // FM DAM - || cur_live.shift_reg == 0xf56a)) // FM DDAM + || cur_live.shift_reg == 0xf56a // FM DDAM + || cur_live.shift_reg == 0xf56b // FM DDAM + || cur_live.shift_reg == 0xf56e // FM DDAM + || cur_live.shift_reg == 0xf56f)) // FM DDAM ) break; @@ -2050,8 +2058,7 @@ void wd_fdc_device_base::live_run(attotime limit) // MZ: TI99 "DISkASSEMBLER" copy protection requires a threshold of 8 bool output_byte = cur_live.bit_counter > 8; - cur_live.data_separator_phase = false; - cur_live.bit_counter = 0; + reset_data_sync(); if(output_byte) { live_delay(READ_TRACK_DATA_BYTE); diff --git a/src/devices/machine/wd_fdc.h b/src/devices/machine/wd_fdc.h index 0dd660a72ff..e870542fcbc 100644 --- a/src/devices/machine/wd_fdc.h +++ b/src/devices/machine/wd_fdc.h @@ -357,7 +357,7 @@ private: void live_run(attotime limit = attotime::never); bool read_one_bit(const attotime &limit); bool write_one_bit(const attotime &limit); - + void reset_data_sync(); void live_write_raw(uint16_t raw); void live_write_mfm(uint8_t mfm); void live_write_fm(uint8_t fm); -- cgit v1.2.3