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

Method LoadWriteProtect

source/Disk.cpp:1895–1932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1893//===========================================================================
1894
1895void __stdcall Disk2InterfaceCard::LoadWriteProtect(WORD, WORD, BYTE write, BYTE value, ULONG uExecutedCycles)
1896{
1897 // Don't change latch if drive off after 1 second drive-off delay (UTAIIe page 9-13)
1898 // "DRIVES OFF forces the data register to hold its present state." (UTAIIe page 9-12)
1899 // Note: Gemstone Warrior sets load mode with the drive off.
1900 if (!m_floppyDrive[m_currDrive].m_spinning) // GH#599
1901 return;
1902
1903 // Notes:
1904 // . Only READ-LOAD mode ($C08E,X & $C08D,X) can issue the SR (shift write-protect) operation - UTAIIe page 9-20, fig 9.11
1905 // . Phase 1 on also forces write protect in the Disk II drive (UTAIIe page 9-7) but we don't implement that.
1906 // . write mode doesn't prevent reading write protect (GH#537):
1907 // "If for some reason the above write protect check were entered with the READ/WRITE switch in WRITE,
1908 // the write protect switch would still be read correctly" (UTAIIe page 9-21)
1909 // . Sequencer "SR" (Shift Right) command shifts the data register right and loads QA (bit7) with write protect (UTAIIe page 9-21)
1910 // . A read or write will shift 'write protect' in QA.
1911 // . The LSS saturates the data register before the CPU can read an intermediate value: so set to 0xFF or 0x00 (GH#1078)
1912 FloppyDisk& floppy = m_floppyDrive[m_currDrive].m_disk;
1913 if (floppy.m_bWriteProtected)
1914 m_floppyLatch = 0xFF;
1915 else
1916 m_floppyLatch = 0x00;
1917
1918 if (m_writeStarted) // Prevent ResetLogicStateSequencer() from resetting m_writeStarted
1919 return;
1920
1921 if (ImageIsWOZ(floppy.m_imagehandle))
1922 {
1923#if LOG_DISK_NIBBLES_READ
1924 LOG_DISK("%08X: reset LSS: ~PC=%04X\r\n", (UINT32)g_nCumulativeCycles, regs.pc);
1925#endif
1926
1927 const UINT bitCellDelta = GetBitCellDelta(uExecutedCycles);
1928 UpdateBitStreamPosition(floppy, bitCellDelta); // Fix E7-copy protection
1929
1930 ResetLogicStateSequencer(); // "Set the sequencer to State 0" (UTAIIe page 9-21)
1931 }
1932}
1933
1934//===========================================================================
1935

Callers 2

IOReadMethod · 0.80
IOWriteMethod · 0.80

Calls 1

ImageIsWOZFunction · 0.85

Tested by

no test coverage detected