MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / DataLatchReadWOZ

Method DataLatchReadWOZ

source/Disk.cpp:1413–1508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1411}
1412
1413void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder)
1414{
1415 // m_diskLastReadLatchCycle = g_nCumulativeCycles; // Not used by WOZ (only by NIB)
1416
1417#if LOG_DISK_NIBBLES_READ
1418 bool newLatchData = false;
1419#endif
1420
1421 FloppyDrive& drive = m_floppyDrive[m_currDrive];
1422 FloppyDisk& floppy = drive.m_disk;
1423
1424#if _DEBUG
1425 static int dbgWOZ = 0;
1426 if (dbgWOZ)
1427 {
1428 dbgWOZ = 0;
1429 DumpTrackWOZ(floppy); // Enable as necessary
1430 }
1431#endif
1432
1433 for (UINT i = 0; i < bitCellRemainder; i++)
1434 {
1435 BYTE n = floppy.m_trackimage[floppy.m_byte];
1436
1437 drive.m_headWindow <<= 1;
1438 drive.m_headWindow |= (n & floppy.m_bitMask) ? 1 : 0;
1439 BYTE outputBit = (drive.m_headWindow & 0xf) ? (drive.m_headWindow >> 1) & 1
1440 : (rand() < RAND_THRESHOLD(3, 10)) ? 1 : 0; // ~30% chance of a 1 bit (Ref: WOZ-2.0)
1441
1442 IncBitStream(floppy);
1443
1444 AddTrackSeamJitter(drive.m_phasePrecise, floppy);
1445
1446 m_shiftReg <<= 1;
1447 m_shiftReg |= outputBit;
1448
1449 if (m_latchDelay)
1450 {
1451 m_latchDelay -= 4;
1452 if (m_latchDelay < 0)
1453 m_latchDelay = 0;
1454
1455 if (m_shiftReg)
1456 {
1457 m_dbgLatchDelayedCnt = 0;
1458 }
1459 else // m_shiftReg==0
1460 {
1461 m_latchDelay += 4; // extend by 4us (so 7us again) - GH#662
1462
1463 m_dbgLatchDelayedCnt++;
1464#if LOG_DISK_NIBBLES_READ
1465 if (m_dbgLatchDelayedCnt >= 3)
1466 {
1467 LOG_DISK("read: latch held due to 0: PC=%04X, cnt=%02X\r\n", regs.pc, m_dbgLatchDelayedCnt);
1468 }
1469#endif
1470 }

Callers

nothing calls this directly

Calls 1

DecodeLatchNibbleReadMethod · 0.80

Tested by

no test coverage detected