From ad1c1450433f66386e59d1e3268aca9bbe74203b Mon Sep 17 00:00:00 2001 From: Simon Owen Date: Sat, 11 Jul 2020 12:15:51 +0100 Subject: [PATCH] Fixed Atom data corruption during writes The 16-bit data writes from Atom devices was losing the upper 8-bits, causing every other byte written to disk to be zero. This didn't affect Atom Lite devices as they drive the Compact Flash device in 8-bit mode. --- Base/AtaAdapter.cpp | 7 ++++++- Base/AtaAdapter.h | 1 + Base/Atom.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Base/AtaAdapter.cpp b/Base/AtaAdapter.cpp index 01ddfe21..64b68f50 100644 --- a/Base/AtaAdapter.cpp +++ b/Base/AtaAdapter.cpp @@ -46,13 +46,18 @@ WORD CAtaAdapter::InWord(WORD wPort_) return wRet; } -// 8-bit write (16-bit handled by derived class) void CAtaAdapter::Out(WORD wPort_, BYTE bVal_) { if (m_pDisk0) m_pDisk0->Out(wPort_, bVal_); if (m_pDisk1) m_pDisk1->Out(wPort_, bVal_); } +void CAtaAdapter::OutWord(WORD wPort_, WORD wVal_) +{ + if (m_pDisk0) m_pDisk0->Out(wPort_, wVal_); + if (m_pDisk1) m_pDisk1->Out(wPort_, wVal_); +} + void CAtaAdapter::Reset() { diff --git a/Base/AtaAdapter.h b/Base/AtaAdapter.h index ebf53c04..1f47b14d 100644 --- a/Base/AtaAdapter.h +++ b/Base/AtaAdapter.h @@ -47,6 +47,7 @@ class CAtaAdapter : public CIoDevice protected: WORD InWord(WORD wPort_); + void OutWord(WORD wPort_, WORD wVal_); protected: UINT m_uActive = 0; // active when non-zero, decremented by FrameEnd() diff --git a/Base/Atom.cpp b/Base/Atom.cpp index 14bdfd29..d779f35f 100644 --- a/Base/Atom.cpp +++ b/Base/Atom.cpp @@ -86,7 +86,7 @@ void CAtomDevice::Out(WORD wPort_, BYTE bVal_) break; m_uActive = HDD_ACTIVE_FRAMES; - CAtaAdapter::Out(m_bAddressLatch & ATOM_ADDR_MASK, (m_bWriteLatch << 8) | bVal_); + CAtaAdapter::OutWord(m_bAddressLatch & ATOM_ADDR_MASK, (m_bWriteLatch << 8) | bVal_); break; default: