mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-02 20:41:38 +00:00
WL: try 2nd alt fix
This commit is contained in:
parent
e9c7d6bb0f
commit
c4f07c42d9
|
@ -872,7 +872,7 @@ void __stdcall Disk2InterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BY
|
||||||
|
|
||||||
if (!pFloppy->m_trackimagedata)
|
if (!pFloppy->m_trackimagedata)
|
||||||
{
|
{
|
||||||
m_floppyLatch = 0xFF;
|
m_floppyLatch = rand() & 0xFF; // GH#748
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1056,7 +1056,7 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWriteWOZ(WORD pc, WORD addr, BYT
|
||||||
if (!floppy.m_trackimagedata)
|
if (!floppy.m_trackimagedata)
|
||||||
{
|
{
|
||||||
_ASSERT(0); // Can't happen for WOZ - ReadTrack() should return an empty track
|
_ASSERT(0); // Can't happen for WOZ - ReadTrack() should return an empty track
|
||||||
m_floppyLatch = 0xFF;
|
m_floppyLatch = rand() & 0xFF; // GH#748
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,7 +1073,7 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWriteWOZ(WORD pc, WORD addr, BYT
|
||||||
// The first 1-bit will produce a latch nibble, and this 1-bit is unlikely to be the nibble's high bit.
|
// The first 1-bit will produce a latch nibble, and this 1-bit is unlikely to be the nibble's high bit.
|
||||||
// So we need to ensure we run enough bits through the sequencer to re-sync.
|
// So we need to ensure we run enough bits through the sequencer to re-sync.
|
||||||
// NB. For Planetfall 13 bitcells(NG) / 14 bitcells(OK)
|
// NB. For Planetfall 13 bitcells(NG) / 14 bitcells(OK)
|
||||||
const UINT significantBitCells = floppy.m_bitCount;
|
const UINT significantBitCells = 50; // 5x 10-bit sync FF nibbles
|
||||||
UINT bitCellDelta = GetBitCellDelta(ImageGetOptimalBitTiming(floppy.m_imagehandle));
|
UINT bitCellDelta = GetBitCellDelta(ImageGetOptimalBitTiming(floppy.m_imagehandle));
|
||||||
|
|
||||||
UINT bitCellRemainder;
|
UINT bitCellRemainder;
|
||||||
|
@ -1113,8 +1113,6 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWriteWOZ(WORD pc, WORD addr, BYT
|
||||||
FrameDrawDiskStatus((HDC)0);
|
FrameDrawDiskStatus((HDC)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int g_zeroFieldFlag = 1;
|
|
||||||
static int g_zeroFieldCount = 0;
|
|
||||||
void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder)
|
void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder)
|
||||||
{
|
{
|
||||||
// m_diskLastReadLatchCycle = g_nCumulativeCycles; // Not used by WOZ (only by NIB)
|
// m_diskLastReadLatchCycle = g_nCumulativeCycles; // Not used by WOZ (only by NIB)
|
||||||
|
@ -1137,8 +1135,11 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define WOZ_ALT2
|
||||||
|
#ifdef WOZ_ALT1
|
||||||
// Only extraCycles of 2 & 3 can hold the latch for another bitCell period, eg. m_latchDelay: 3->5 or 7->9
|
// 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)
|
UINT extraLatchDelay = ((UINT)floppy.m_extraCycles >= 2) ? 2 : 0; // GH#733 (0,1->0; 2,3->2)
|
||||||
|
#endif
|
||||||
|
|
||||||
for (UINT i = 0; i < bitCellRemainder; i++)
|
for (UINT i = 0; i < bitCellRemainder; i++)
|
||||||
{
|
{
|
||||||
|
@ -1149,23 +1150,6 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain
|
||||||
BYTE outputBit = (drive.m_headWindow & 0xf) ? (drive.m_headWindow >> 1) & 1
|
BYTE outputBit = (drive.m_headWindow & 0xf) ? (drive.m_headWindow >> 1) & 1
|
||||||
: (rand() < ((RAND_MAX * 3) / 10)) ? 1 : 0; // ~30% chance of a 1 bit (Ref: WOZ-2.0)
|
: (rand() < ((RAND_MAX * 3) / 10)) ? 1 : 0; // ~30% chance of a 1 bit (Ref: WOZ-2.0)
|
||||||
|
|
||||||
#if 0 // DEBUG: insert an extra 0-bit into the field of 317 zero bits
|
|
||||||
bool doInc = true;
|
|
||||||
if (drive.m_phase == 0 && floppy.m_bitOffset == (0x5811 + 92))
|
|
||||||
{
|
|
||||||
g_zeroFieldCount++;
|
|
||||||
if (regs.pc < 0x8ff)
|
|
||||||
{
|
|
||||||
if (g_zeroFieldFlag)
|
|
||||||
{
|
|
||||||
g_zeroFieldFlag = 0;
|
|
||||||
doInc = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (doInc)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
floppy.m_bitMask >>= 1;
|
floppy.m_bitMask >>= 1;
|
||||||
if (!floppy.m_bitMask)
|
if (!floppy.m_bitMask)
|
||||||
{
|
{
|
||||||
|
@ -1180,7 +1164,6 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain
|
||||||
floppy.m_bitOffset = 0;
|
floppy.m_bitOffset = 0;
|
||||||
floppy.m_byte = 0;
|
floppy.m_byte = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (m_resetSequencer)
|
if (m_resetSequencer)
|
||||||
{
|
{
|
||||||
|
@ -1195,9 +1178,11 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain
|
||||||
|
|
||||||
if (m_latchDelay)
|
if (m_latchDelay)
|
||||||
{
|
{
|
||||||
// if (i == bitCellRemainder-1) // On last bitCell
|
#ifdef WOZ_ALT1
|
||||||
// m_latchDelay += extraLatchDelay; // +0 or +2
|
if (i == bitCellRemainder-1) // On last bitCell
|
||||||
// extraLatchDelay = 0; // and always clear (even when not last bitCell)
|
m_latchDelay += extraLatchDelay; // +0 or +2
|
||||||
|
extraLatchDelay = 0; // and always clear (even when not last bitCell)
|
||||||
|
#endif
|
||||||
|
|
||||||
m_latchDelay -= 4;
|
m_latchDelay -= 4;
|
||||||
if (m_latchDelay < 0)
|
if (m_latchDelay < 0)
|
||||||
|
@ -1244,6 +1229,51 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // for
|
} // for
|
||||||
|
static int dbg=0;
|
||||||
|
#ifdef WOZ_ALT2
|
||||||
|
#if 0 // NG: LOA2 (not tested others)
|
||||||
|
if (m_latchDelay && m_shiftReg) // if m_shiftReg==0, then it was a zero bitCell, so hold latch
|
||||||
|
{
|
||||||
|
if (m_latchDelay <= (int)floppy.m_extraCycles) // "< 0" never occurs
|
||||||
|
{
|
||||||
|
m_floppyLatch = m_shiftReg;
|
||||||
|
_ASSERT((m_shiftReg & 0x80) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif (0) // NG: LOA2 (not tested others)
|
||||||
|
if (m_latchDelay && m_shiftReg) // if m_shiftReg==0, then it was a zero bitCell, so hold latch
|
||||||
|
{
|
||||||
|
m_latchDelay -= (UINT)floppy.m_extraCycles;
|
||||||
|
if (m_latchDelay <= 0) // or "< 0"
|
||||||
|
{
|
||||||
|
m_latchDelay = 0;
|
||||||
|
m_floppyLatch = m_shiftReg;
|
||||||
|
_ASSERT((m_shiftReg & 0x80) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif (0) // NG: LOA2 (not tested others)
|
||||||
|
if (m_latchDelay)
|
||||||
|
{
|
||||||
|
if (m_latchDelay <= (int)floppy.m_extraCycles) // "< 0" never occurs
|
||||||
|
{
|
||||||
|
m_floppyLatch = m_shiftReg;
|
||||||
|
_ASSERT((m_shiftReg & 0x80) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (m_latchDelay)
|
||||||
|
{
|
||||||
|
m_latchDelay -= (UINT)floppy.m_extraCycles;
|
||||||
|
if (m_latchDelay <= 0) // NG: Wasteland, OK: LOA1/2
|
||||||
|
{
|
||||||
|
_ASSERT(m_shiftReg);
|
||||||
|
m_latchDelay = 0;
|
||||||
|
m_floppyLatch = m_shiftReg;
|
||||||
|
_ASSERT((m_shiftReg & 0x80) == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LOG_DISK_NIBBLES_READ
|
#if LOG_DISK_NIBBLES_READ
|
||||||
if (m_floppyLatch & 0x80)
|
if (m_floppyLatch & 0x80)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user