Skip to content

Commit

Permalink
Fixed Atom data corruption during writes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
simonowen committed Jul 11, 2020
1 parent e0e8a79 commit ad1c145
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Base/AtaAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
1 change: 1 addition & 0 deletions Base/AtaAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Base/Atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ad1c145

Please sign in to comment.