From 1af12fbbb13afa9958ea9bfcc4d058a1a0f3c51a Mon Sep 17 00:00:00 2001 From: tomcw Date: Sat, 3 Aug 2019 18:10:39 +0100 Subject: [PATCH] WOZ: Small refactor to call DataLatchReadWriteWOZ() for any WOZ data-latch access --- source/Disk.cpp | 34 +++++++++++++++++----------------- source/Disk.h | 5 +++-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/source/Disk.cpp b/source/Disk.cpp index 262edd6f..f0cc85d1 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -1098,12 +1098,8 @@ UINT Disk2InterfaceCard::DataLatchReadWriteCommonWOZ(ULONG uExecutedCycles) return bitCellRemainder; } -void __stdcall Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, BYTE d, ULONG uExecutedCycles) +void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder) { - const UINT bitCellRemainder = DataLatchReadWriteCommonWOZ(uExecutedCycles); - if (!bitCellRemainder) - return; - // m_diskLastReadLatchCycle = g_nCumulativeCycles; // Not used by WOZ (only by NIB) #if LOG_DISK_NIBBLES_READ @@ -1216,20 +1212,12 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, BYTE d, } } #endif - - // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! - if ((floppy.m_byte & 0xFF) == 0) - FrameDrawDiskStatus((HDC)0); } -void __stdcall Disk2InterfaceCard::DataLatchWriteWOZ(WORD pc, WORD addr, BYTE d, ULONG uExecutedCycles) +void Disk2InterfaceCard::DataLatchWriteWOZ(WORD pc, WORD addr, BYTE d, UINT bitCellRemainder) { _ASSERT(m_floppyWriteMode); - const UINT bitCellRemainder = DataLatchReadWriteCommonWOZ(uExecutedCycles); - if (!bitCellRemainder) - return; - FloppyDrive& drive = m_floppyDrive[m_currDrive]; FloppyDisk& floppy = drive.m_disk; @@ -1237,9 +1225,21 @@ void __stdcall Disk2InterfaceCard::DataLatchWriteWOZ(WORD pc, WORD addr, BYTE d, { //TODO } +} + +void __stdcall Disk2InterfaceCard::DataLatchReadWriteWOZ(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles) +{ + const UINT bitCellRemainder = DataLatchReadWriteCommonWOZ(uExecutedCycles); + if (!bitCellRemainder) + return; + + if (!bWrite) + DataLatchReadWOZ(pc, addr, bitCellRemainder); + else + DataLatchWriteWOZ(pc, addr, d, bitCellRemainder); // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! - if ((floppy.m_byte & 0xFF) == 0) + if ((m_floppyDrive[m_currDrive].m_disk.m_byte & 0xFF) == 0) FrameDrawDiskStatus((HDC)0); } @@ -1687,7 +1687,7 @@ BYTE __stdcall Disk2InterfaceCard::IORead(WORD pc, WORD addr, BYTE bWrite, BYTE if (!(addr & 1)) { if (isWOZ) - pCard->DataLatchReadWOZ(pc, addr, d, nExecutedCycles); + pCard->DataLatchReadWriteWOZ(pc, addr, bWrite, d, nExecutedCycles); return pCard->m_floppyLatch; } @@ -1729,7 +1729,7 @@ BYTE __stdcall Disk2InterfaceCard::IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE pCard->m_floppyLatch = d; if (isWOZ) - pCard->DataLatchWriteWOZ(pc, addr, d, nExecutedCycles); + pCard->DataLatchReadWriteWOZ(pc, addr, bWrite, d, nExecutedCycles); } return 0; diff --git a/source/Disk.h b/source/Disk.h index 00234557..8c8c3317 100644 --- a/source/Disk.h +++ b/source/Disk.h @@ -189,6 +189,8 @@ private: void UpdateBitStreamPosition(FloppyDisk& floppy, const ULONG bitCellDelta); void UpdateBitStreamOffsets(FloppyDisk& floppy); UINT DataLatchReadWriteCommonWOZ(ULONG uExecutedCycles); + void DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder); + void DataLatchWriteWOZ(WORD pc, WORD addr, BYTE d, UINT bitCellRemainder); void DumpSectorWOZ(FloppyDisk floppy); void DumpTrackWOZ(FloppyDisk floppy); @@ -203,8 +205,7 @@ private: void __stdcall ControlMotor(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles); void __stdcall Enable(WORD, WORD address, BYTE, BYTE, ULONG uExecutedCycles); void __stdcall ReadWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles); - void __stdcall DataLatchReadWOZ(WORD pc, WORD addr, BYTE d, ULONG uExecutedCycles); - void __stdcall DataLatchWriteWOZ(WORD pc, WORD addr, BYTE d, ULONG uExecutedCycles); + void __stdcall DataLatchReadWriteWOZ(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG uExecutedCycles); void __stdcall LoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG); void __stdcall SetReadMode(WORD, WORD, BYTE, BYTE, ULONG); void __stdcall SetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uExecutedCycles);