From 183ec2bc8c126573938f7241112444fc30236163 Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 30 Dec 2019 19:52:49 +0000 Subject: [PATCH] WOZ: Alternate fix for Wasteland (#733) . apply extraLatchDelay on the last bitCell (if there's a latchDelay) Debugger: Extended 'videoinfo' command to show cycles as absolute or relative. --- source/Debugger/Debug.cpp | 4 ++++ source/Debugger/Debugger_Display.cpp | 3 ++- source/Debugger/Debugger_Display.h | 3 ++- source/Debugger/Debugger_Help.cpp | 3 ++- source/Disk.cpp | 16 ++++++++++------ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 5cb92047..525a5bb3 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -6873,6 +6873,10 @@ Update_t CmdVideoScannerInfo(int nArgs) g_videoScannerDisplayInfo.isHorzReal = true; else if (strcmp(g_aArgs[1].sArg, "apple") == 0) g_videoScannerDisplayInfo.isHorzReal = false; + else if (strcmp(g_aArgs[1].sArg, "abs") == 0) + g_videoScannerDisplayInfo.isAbsCycle = true; + else if (strcmp(g_aArgs[1].sArg, "rel") == 0) + g_videoScannerDisplayInfo.isAbsCycle = false; else return Help_Arg_1(CMD_VIDEO_SCANNER_INFO); } diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index 11f8f42f..261bb49d 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -3785,7 +3785,8 @@ void DrawVideoScannerInfo (int line) rect.left += nameWidth * nFontWidth; char sValue[10]; - sprintf_s(sValue, sizeof(sValue), "%08X", g_videoScannerDisplayInfo.cycleDelta); + const UINT cycles = g_videoScannerDisplayInfo.isAbsCycle ? (UINT)g_nCumulativeCycles : g_videoScannerDisplayInfo.cycleDelta; + sprintf_s(sValue, sizeof(sValue), "%08X", cycles); PrintText(sValue, rect); } diff --git a/source/Debugger/Debugger_Display.h b/source/Debugger/Debugger_Display.h index 89e1f652..ae7d11c8 100644 --- a/source/Debugger/Debugger_Display.h +++ b/source/Debugger/Debugger_Display.h @@ -102,12 +102,13 @@ class VideoScannerDisplayInfo { public: - VideoScannerDisplayInfo(void) : isDecimal(false), isHorzReal(false), + VideoScannerDisplayInfo(void) : isDecimal(false), isHorzReal(false), isAbsCycle(false), lastCumulativeCycles(0), cycleDelta(0) {} void Reset(void) { lastCumulativeCycles = g_nCumulativeCycles; cycleDelta = 0; } bool isDecimal; bool isHorzReal; + bool isAbsCycle; unsigned __int64 lastCumulativeCycles; UINT cycleDelta; diff --git a/source/Debugger/Debugger_Help.cpp b/source/Debugger/Debugger_Help.cpp index 57e1fa54..df934f45 100644 --- a/source/Debugger/Debugger_Help.cpp +++ b/source/Debugger/Debugger_Help.cpp @@ -1408,10 +1408,11 @@ Update_t CmdHelpSpecific (int nArgs) break; // Video-Scanner case CMD_VIDEO_SCANNER_INFO: - ConsoleColorizePrint(sText, " Usage: "); + ConsoleColorizePrint(sText, " Usage: "); ConsoleBufferPush(" Where:"); ConsoleBufferPush(" changes output to dec/hex"); ConsoleBufferPush(" alters horz value to hbl-l,visible,hbl-r or hbl-r+l,visible"); + ConsoleBufferPush(" changes cycle output to absolute/relative"); { char sText2[CONSOLE_WIDTH]; ConsolePrintFormat(sText2, " %sYellow%s=invisible (hbl or vbl active) / %sGreen%s=visible" diff --git a/source/Disk.cpp b/source/Disk.cpp index e3129668..f5330293 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -1091,6 +1091,8 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWriteWOZ(WORD pc, WORD addr, BYT drive.m_headWindow = 0; } + // NB. actual m_diskLastCycle for the last bitCell is minus floppy.m_extraCycles + // - but don't need this value; and it's correctly accounted for in GetBitCellDelta() m_diskLastCycle = g_nCumulativeCycles; if (!bWrite) @@ -1127,12 +1129,13 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain if (dbgWOZ) { dbgWOZ = 0; - DumpSectorWOZ(floppy); -// DumpTrackWOZ(floppy); // Enable as necessary +// DumpSectorWOZ(floppy); + DumpTrackWOZ(floppy); // Enable as necessary } #endif - UINT extraLatchDelay = (UINT)floppy.m_extraCycles ? 1 : 0; // GH#733 + // Only extraCycles of 2 & 3 can hold the latch for another bitCell period, eg. m_latchDelay: 3->5 or 7->9 + UINT extraLatchDelay = ((UINT)floppy.m_extraCycles >= 2) ? 2 : 0; // GH#733 (0,1->0; 2,3->2) for (UINT i = 0; i < bitCellRemainder; i++) { @@ -1171,8 +1174,9 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain if (m_latchDelay) { - m_latchDelay += extraLatchDelay; - extraLatchDelay = 0; + if (i == bitCellRemainder-1) // On last bitCell + m_latchDelay += extraLatchDelay; // +0 or +2 + extraLatchDelay = 0; // and always clear (even when not last bitCell) m_latchDelay -= 4; if (m_latchDelay < 0) @@ -1218,7 +1222,7 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain #endif } } - } + } // for #if LOG_DISK_NIBBLES_READ if (m_floppyLatch & 0x80)