WOZ: Added debug dump sector & track functions

This commit is contained in:
tomcw 2019-08-03 17:51:19 +01:00
parent b770306496
commit d973fb6b97
2 changed files with 139 additions and 2 deletions

View File

@ -1100,8 +1100,6 @@ UINT Disk2InterfaceCard::DataLatchReadWriteCommonWOZ(ULONG uExecutedCycles)
void __stdcall Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, BYTE d, ULONG uExecutedCycles)
{
_ASSERT(!m_floppyWriteMode);
const UINT bitCellRemainder = DataLatchReadWriteCommonWOZ(uExecutedCycles);
if (!bitCellRemainder)
return;
@ -1115,6 +1113,15 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, BYTE d,
FloppyDrive& drive = m_floppyDrive[m_currDrive];
FloppyDisk& floppy = drive.m_disk;
#if _DEBUG
static int dbgWOZ = 0;
if (dbgWOZ)
{
DumpSectorWOZ(floppy);
//DumpTrackWOZ(floppy); // Enable as necessary
}
#endif
for (UINT i = 0; i < bitCellRemainder; i++)
{
BYTE n = floppy.m_trackimage[floppy.m_byte];
@ -1238,6 +1245,133 @@ void __stdcall Disk2InterfaceCard::DataLatchWriteWOZ(WORD pc, WORD addr, BYTE d,
//===========================================================================
#ifdef _DEBUG
// Dump nibbles from current position until 0xDEAA (ie. data epilogue)
void Disk2InterfaceCard::DumpSectorWOZ(FloppyDisk floppy) // pass a copy of m_floppy
{
BYTE shiftReg = 0;
UINT32 lastNibbles = 0;
UINT zeroCount = 0;
UINT nibbleCount = 0;
while (1)
{
BYTE n = floppy.m_trackimage[floppy.m_byte];
BYTE outputBit = (n & floppy.m_bitMask) ? 1 : 0;
floppy.m_bitMask >>= 1;
if (!floppy.m_bitMask)
{
floppy.m_bitMask = 1 << 7;
floppy.m_byte++;
}
floppy.m_bitOffset++;
if (floppy.m_bitOffset == floppy.m_bitCount)
{
floppy.m_bitMask = 1 << 7;
floppy.m_bitOffset = 0;
floppy.m_byte = 0;
}
if (shiftReg == 0 && outputBit == 0)
{
zeroCount++;
continue;
}
shiftReg <<= 1;
shiftReg |= outputBit;
if ((shiftReg & 0x80) == 0)
continue;
nibbleCount++;
char str[10];
sprintf(str, "%02X ", shiftReg);
OutputDebugString(str);
if ((nibbleCount & 0xf) == 0)
OutputDebugString("\n");
lastNibbles <<= 8;
lastNibbles |= shiftReg;
if ((lastNibbles & 0xffff) == 0xDEAA)
break;
shiftReg = 0;
zeroCount = 0;
}
}
// Dump nibbles from current position bitstream wraps to same position
void Disk2InterfaceCard::DumpTrackWOZ(FloppyDisk floppy) // pass a copy of m_floppy
{
#ifdef LOG_DISK_NIBBLES_READ
FormatTrack formatTrack;
#endif
BYTE shiftReg = 0;
UINT nibbleCount = 0;
floppy.m_bitMask = 1 << 7;
floppy.m_bitOffset = 0;
floppy.m_byte = 0;
const UINT startBitOffset = floppy.m_bitOffset;
while (1)
{
BYTE n = floppy.m_trackimage[floppy.m_byte];
BYTE outputBit = (n & floppy.m_bitMask) ? 1 : 0;
floppy.m_bitMask >>= 1;
if (!floppy.m_bitMask)
{
floppy.m_bitMask = 1 << 7;
floppy.m_byte++;
}
floppy.m_bitOffset++;
if (floppy.m_bitOffset == floppy.m_bitCount)
{
floppy.m_bitMask = 1 << 7;
floppy.m_bitOffset = 0;
floppy.m_byte = 0;
}
if (startBitOffset == floppy.m_bitOffset)
break;
if (shiftReg == 0 && outputBit == 0)
continue;
shiftReg <<= 1;
shiftReg |= outputBit;
if ((shiftReg & 0x80) == 0)
continue;
nibbleCount++;
char str[10];
sprintf(str, "%02X ", shiftReg);
OutputDebugString(str);
if ((nibbleCount % 32) == 0)
OutputDebugString("\n");
#ifdef LOG_DISK_NIBBLES_READ
formatTrack.DecodeLatchNibbleRead(shiftReg);
#endif
shiftReg = 0;
}
}
#endif
//===========================================================================
void Disk2InterfaceCard::Reset(const bool bIsPowerCycle/*=false*/)
{
// RESET forces all switches off (UTAIIe Table 9.1)

View File

@ -189,6 +189,9 @@ private:
void UpdateBitStreamPosition(FloppyDisk& floppy, const ULONG bitCellDelta);
void UpdateBitStreamOffsets(FloppyDisk& floppy);
UINT DataLatchReadWriteCommonWOZ(ULONG uExecutedCycles);
void DumpSectorWOZ(FloppyDisk floppy);
void DumpTrackWOZ(FloppyDisk floppy);
void SaveSnapshotFloppy(YamlSaveHelper& yamlSaveHelper, UINT unit);
void SaveSnapshotDriveUnit(YamlSaveHelper& yamlSaveHelper, UINT unit);
bool LoadSnapshotFloppy(YamlLoadHelper& yamlLoadHelper, UINT unit, UINT version, std::vector<BYTE>& track);