mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-19 10:29:29 +00:00
Cleanup disk status Track/Sector, fix to work with .WOZ and non .WOZ
This commit is contained in:
parent
3066617f34
commit
35476d2fb0
|
@ -103,32 +103,30 @@ Disk2InterfaceCard::~Disk2InterfaceCard(void)
|
|||
bool Disk2InterfaceCard::GetEnhanceDisk(void) { return m_enhanceDisk; }
|
||||
void Disk2InterfaceCard::SetEnhanceDisk(bool bEnhanceDisk) { m_enhanceDisk = bEnhanceDisk; }
|
||||
|
||||
// Returns true if Track, Sector is valid
|
||||
void Disk2InterfaceCard::GetLastReadTrackSector(const int drive, int& track, int& sector)
|
||||
void Disk2InterfaceCard::SetLastReadTrackSector(int track, int physical)
|
||||
{
|
||||
// IsDriveEmpty()
|
||||
FloppyDrive* pDrive = &m_floppyDrive[drive];
|
||||
FloppyDisk* pFloppy = &pDrive->m_disk;
|
||||
if (! pFloppy->m_imagehandle)
|
||||
{
|
||||
track = -1;
|
||||
sector = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
track = m_floppyDrive[drive].m_LastReadTrackSector[0];
|
||||
int physical = m_floppyDrive[drive].m_LastReadTrackSector[1];
|
||||
|
||||
// Some disk images have bogus sector numbers
|
||||
if ((physical >= 0) && (physical <= 15))
|
||||
{
|
||||
const int PhysicalToLogicalSectorNumber[16] = {0x00,0x07,0x0E,0x06,0x0D,0x05,0x0C,0x04, 0x0B,0x03,0x0A,0x02,0x09,0x01,0x08,0x0F};
|
||||
sector = PhysicalToLogicalSectorNumber[physical];
|
||||
}
|
||||
else
|
||||
sector = physical;
|
||||
|
||||
assert(track <= 80);
|
||||
|
||||
Win32Frame& WinFrame = Win32Frame::GetWin32Frame();
|
||||
|
||||
// IsDriveEmpty()
|
||||
FloppyDrive* pDrive = &m_floppyDrive[m_currDrive];
|
||||
FloppyDisk* pDisk = &pDrive->m_disk;
|
||||
if (! pDisk->m_imagehandle)
|
||||
WinFrame.SetLastReadTrackSector(m_slot, m_currDrive, -1, -1);
|
||||
else
|
||||
{
|
||||
int sector = physical;
|
||||
|
||||
// Some disk images have bogus sector numbers
|
||||
if ((physical >= 0) && (physical <= 15))
|
||||
{
|
||||
const int PhysicalToLogicalSectorNumber[16] = {0x00,0x07,0x0E,0x06,0x0D,0x05,0x0C,0x04, 0x0B,0x03,0x0A,0x02,0x09,0x01,0x08,0x0F};
|
||||
sector = PhysicalToLogicalSectorNumber[physical];
|
||||
}
|
||||
|
||||
WinFrame.SetLastReadTrackSector( m_slot, m_currDrive, track, sector );
|
||||
}
|
||||
}
|
||||
|
||||
int Disk2InterfaceCard::GetCurrentDrive(void) { return m_currDrive; }
|
||||
|
@ -1061,7 +1059,7 @@ void __stdcall Disk2InterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BY
|
|||
|
||||
if (!pFloppy->m_trackimagedata)
|
||||
{
|
||||
pDrive->SetLastReadTrackSector(0);
|
||||
SetLastReadTrackSector(-1,-1);
|
||||
return UpdateLatchForEmptyDrive(pDrive);
|
||||
}
|
||||
|
||||
|
@ -1124,11 +1122,10 @@ void __stdcall Disk2InterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BY
|
|||
{
|
||||
LOG_DISK("read %04X = %02X\r\n", pFloppy->m_byte, m_floppyLatch);
|
||||
}
|
||||
|
||||
m_formatTrack.DecodeLatchNibbleRead(m_floppyLatch);
|
||||
BYTE *VolTrkSecChk = m_formatTrack.GetLastReadVolumeTrackSectorChecksum();
|
||||
pDrive->SetLastReadTrackSector(VolTrkSecChk);
|
||||
#endif
|
||||
|
||||
m_formatTrack.DecodeLatchNibbleRead(m_floppyLatch); // GH #1215 Handle .DSK / .PO VTSC (non .WOZ)
|
||||
|
||||
}
|
||||
else if (!pFloppy->m_bWriteProtected) // && m_seqFunc.writeMode
|
||||
{
|
||||
|
@ -1145,7 +1142,6 @@ void __stdcall Disk2InterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BY
|
|||
#endif
|
||||
|
||||
m_formatTrack.DecodeLatchNibbleWrite(m_floppyLatch, uSpinNibbleCount, pFloppy, bIsSyncFF); // GH#125
|
||||
pDrive->SetLastReadTrackSector(m_formatTrack.GetLastReadVolumeTrackSectorChecksum());
|
||||
|
||||
#if LOG_DISK_NIBBLES_WRITE
|
||||
#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR
|
||||
|
@ -1162,10 +1158,6 @@ void __stdcall Disk2InterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BY
|
|||
|
||||
if (++pFloppy->m_byte >= pFloppy->m_nibbles)
|
||||
pFloppy->m_byte = 0;
|
||||
|
||||
// Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!!
|
||||
if ((pFloppy->m_byte & 0xFF) == 0)
|
||||
GetFrame().FrameDrawDiskStatus();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -1479,6 +1471,10 @@ void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemain
|
|||
}
|
||||
} // for
|
||||
|
||||
// GH #1215 Handle. WOZ VTSC
|
||||
if (m_floppyLatch & 0x80)
|
||||
m_formatTrack.DecodeLatchNibbleRead(m_floppyLatch);
|
||||
|
||||
#if LOG_DISK_NIBBLES_READ
|
||||
if (m_floppyLatch & 0x80)
|
||||
{
|
||||
|
|
|
@ -116,27 +116,9 @@ public:
|
|||
m_headWindow = 0;
|
||||
m_spinning = 0;
|
||||
m_writelight = 0;
|
||||
m_LastReadTrackSector[0] = -1;
|
||||
m_LastReadTrackSector[1] = -1;
|
||||
m_disk.clear();
|
||||
}
|
||||
|
||||
// NOTE: Managed by Disk2InterfaceCard::ReadWrite()
|
||||
void SetLastReadTrackSector(BYTE* pVolumeTrackSectorChecksum)
|
||||
{
|
||||
if (pVolumeTrackSectorChecksum)
|
||||
{
|
||||
m_LastReadTrackSector[0] = pVolumeTrackSectorChecksum[1];
|
||||
m_LastReadTrackSector[1] = pVolumeTrackSectorChecksum[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LastReadTrackSector[0] = -1;
|
||||
m_LastReadTrackSector[1] = -1;
|
||||
}
|
||||
assert(m_LastReadTrackSector[0] <= 80);
|
||||
}
|
||||
|
||||
public:
|
||||
bool m_isConnected;
|
||||
float m_phasePrecise; // Phase precise to half a phase (aka quarter track)
|
||||
|
@ -147,7 +129,6 @@ public:
|
|||
DWORD m_spinning;
|
||||
DWORD m_writelight;
|
||||
FloppyDisk m_disk;
|
||||
int m_LastReadTrackSector[2];
|
||||
};
|
||||
|
||||
class Disk2InterfaceCard : public Card
|
||||
|
@ -180,7 +161,7 @@ public:
|
|||
bool IsConditionForFullSpeed(void);
|
||||
void NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error);
|
||||
UINT GetCurrentFirmware(void) { return m_is13SectorFirmware ? 13 : 16; }
|
||||
void GetLastReadTrackSector(const int drive, int& track, int& sector);
|
||||
void SetLastReadTrackSector(int track, int sector);
|
||||
int GetCurrentDrive(void);
|
||||
int GetCurrentTrack(void);
|
||||
float GetCurrentPhase(void);
|
||||
|
|
|
@ -264,15 +264,22 @@ void FormatTrack::DecodeLatchNibble(BYTE floppylatch, bool bIsWrite, bool bIsSyn
|
|||
for (UINT i=0; i<4; i++)
|
||||
m_VolTrkSecChk[i] = ((m_VolTrkSecChk4and4[i*2] & 0x55) << 1) | (m_VolTrkSecChk4and4[i*2+1] & 0x55);
|
||||
|
||||
#if LOG_DISK_NIBBLES_READ
|
||||
// GH #1215
|
||||
m_pCard->SetLastReadTrackSector( m_VolTrkSecChk[1], m_VolTrkSecChk[2] );
|
||||
GetFrame().FrameDrawDiskStatus();
|
||||
|
||||
#if LOG_DISK_NIBBLES_ADDR
|
||||
const bool chk = (m_VolTrkSecChk[0] ^ m_VolTrkSecChk[1] ^ m_VolTrkSecChk[2] ^ m_VolTrkSecChk[3]) == 0;
|
||||
if (!bIsWrite)
|
||||
{
|
||||
BYTE addrPrologue = m_bAddressPrologueIsDOS3_2 ? (BYTE)kADDR_PROLOGUE_DOS3_2 : (BYTE)kADDR_PROLOGUE_DOS3_3;
|
||||
m_strReadD5AAxxDetected = StrFormat("read D5AA%02X detected - Vol:%02X Trk:%02X Sec:%02X Chk:%02X %s",
|
||||
addrPrologue, m_VolTrkSecChk[0], m_VolTrkSecChk[1], m_VolTrkSecChk[2], m_VolTrkSecChk[3], chk?"":"(bad)");
|
||||
// NOTE: We can NOT: assert(m_VolTrkSecChk[2] <= 0xF);
|
||||
// Since some disks have bogus sector numbers: PLASMA2-SYS.PO
|
||||
|
||||
// NOTE: We can NOT check for sector <= 15:
|
||||
// _ASSERT(m_VolTrkSecChk[2] <= 0xF);
|
||||
// Since some disks have bogus sector numbers
|
||||
|
||||
if (!m_bSuppressReadD5AAxxDetected)
|
||||
{
|
||||
LOG_DISK("%s\r\n", m_strReadD5AAxxDetected.c_str());
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define LOG_DISK_PHASES 1
|
||||
#define LOG_DISK_RW_MODE 1
|
||||
#define LOG_DISK_ENABLE_DRIVE 1
|
||||
#define LOG_DISK_NIBBLES_ADDR 1
|
||||
#define LOG_DISK_NIBBLES_SPIN 1
|
||||
#define LOG_DISK_NIBBLES_READ 1
|
||||
#define LOG_DISK_NIBBLES_WRITE 1
|
||||
|
|
|
@ -82,6 +82,15 @@ public:
|
|||
|
||||
bool g_bScrollLock_FullSpeed;
|
||||
|
||||
void SetLastReadTrackSector(UINT slot, int drive, int track, int sector)
|
||||
{
|
||||
assert((slot >= 0) && (slot <= 7));
|
||||
assert((drive >= 0) && (drive <= 1));
|
||||
|
||||
g_nTrack [ slot ][ drive ] = track;
|
||||
g_nSector[ slot ][ drive ] = sector;
|
||||
}
|
||||
|
||||
private:
|
||||
static BOOL CALLBACK DDEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext);
|
||||
LRESULT WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
|
||||
|
@ -93,7 +102,7 @@ private:
|
|||
|
||||
void Benchmark(void);
|
||||
void DisplayLogo(void);
|
||||
void GetTrackSector(UINT slot, int& drive1Track, int& drive2Track, int& activeFloppy);
|
||||
int GetActiveDrive(UINT slot);
|
||||
void CreateTrackSectorStrings(int track, int sector, std::string& strTrack, std::string& strSector);
|
||||
void DrawTrackSector(HDC dc, UINT slot, int drive1Track, int drive1Sector, int drive2Track, int drive2Sector);
|
||||
void FrameDrawDiskLEDS(HDC hdc); // overloaded Win32 only, call via GetWin32Frame()
|
||||
|
@ -227,6 +236,7 @@ private:
|
|||
const UINT yOffsetSlot5TrackInfo = D2FullUI::yOffsetSlot5TrackInfo;
|
||||
const UINT yOffsetSlot5SectorInfo = D2FullUI::yOffsetSlot5SectorInfo;
|
||||
|
||||
int g_nTrack [NUM_SLOTS][2];
|
||||
int g_nSector[NUM_SLOTS][2];
|
||||
Disk_Status_e g_eStatusDrive1;
|
||||
Disk_Status_e g_eStatusDrive2;
|
||||
|
|
|
@ -607,22 +607,17 @@ void Win32Frame::FrameDrawDiskStatus()
|
|||
FrameDrawDiskStatus((HDC)0);
|
||||
}
|
||||
|
||||
void Win32Frame::GetTrackSector(UINT slot, int& drive1Track, int& drive2Track, int& activeFloppy)
|
||||
int Win32Frame::GetActiveDrive(UINT slot)
|
||||
{
|
||||
drive1Track = -1;
|
||||
drive2Track = -1;
|
||||
activeFloppy = 0;
|
||||
g_nSector[slot][0] = -1;
|
||||
g_nSector[slot][1] = -1;
|
||||
int activeFloppy = 0;
|
||||
|
||||
if (GetCardMgr().QuerySlot(slot) != CT_Disk2)
|
||||
return;
|
||||
return activeFloppy;
|
||||
|
||||
Disk2InterfaceCard& disk2Card = dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(slot));
|
||||
activeFloppy = disk2Card.GetCurrentDrive();
|
||||
|
||||
disk2Card.GetLastReadTrackSector(0, drive1Track, g_nSector[slot][0]);
|
||||
disk2Card.GetLastReadTrackSector(1, drive2Track, g_nSector[slot][1]);
|
||||
return activeFloppy;
|
||||
}
|
||||
|
||||
void Win32Frame::CreateTrackSectorStrings(int track, int sector, std::string& strTrack, std::string& strSector)
|
||||
|
@ -677,8 +672,7 @@ void Win32Frame::FrameDrawDiskStatus( HDC passdc )
|
|||
if (g_windowMinimized) // Prevent DC leaks when app window is minimised (GH#820)
|
||||
return;
|
||||
|
||||
int nDrive1Track, nDrive2Track, nActiveFloppy;
|
||||
GetTrackSector(SLOT6, nDrive1Track, nDrive2Track, nActiveFloppy);
|
||||
int nSlot6ActiveFloppy = GetActiveDrive(SLOT6);
|
||||
|
||||
// Draw Track/Sector
|
||||
FrameReleaseDC();
|
||||
|
@ -699,10 +693,10 @@ void Win32Frame::FrameDrawDiskStatus( HDC passdc )
|
|||
return;
|
||||
|
||||
std::string strTrackDrive1, strSectorDrive1, strTrackDrive2, strSectorDrive2;
|
||||
CreateTrackSectorStrings(nDrive1Track, g_nSector[SLOT6][0], strTrackDrive1, strSectorDrive1);
|
||||
CreateTrackSectorStrings(nDrive2Track, g_nSector[SLOT6][1], strTrackDrive2, strSectorDrive2);
|
||||
CreateTrackSectorStrings(g_nTrack[SLOT6][0], g_nSector[SLOT6][0], strTrackDrive1, strSectorDrive1);
|
||||
CreateTrackSectorStrings(g_nTrack[SLOT6][1], g_nSector[SLOT6][1], strTrackDrive2, strSectorDrive2);
|
||||
|
||||
std::string text = ( nActiveFloppy == 0 )
|
||||
std::string text = (nSlot6ActiveFloppy == 0)
|
||||
? StrFormat( "%s/%s ", strTrackDrive1.c_str(), strSectorDrive1.c_str() )
|
||||
: StrFormat( "%s/%s ", strTrackDrive2.c_str(), strSectorDrive2.c_str() );
|
||||
|
||||
|
@ -721,13 +715,24 @@ void Win32Frame::FrameDrawDiskStatus( HDC passdc )
|
|||
if (g_nViewportScale == 1 || !GetWindowedModeShowDiskiiStatus())
|
||||
return;
|
||||
|
||||
DrawTrackSector(dc, SLOT6, nDrive1Track, g_nSector[SLOT6][0], nDrive2Track, g_nSector[SLOT6][1]);
|
||||
DrawTrackSector(
|
||||
dc,
|
||||
SLOT6,
|
||||
g_nTrack[SLOT6][0], g_nSector[SLOT6][0],
|
||||
g_nTrack[SLOT6][1], g_nSector[SLOT6][1]
|
||||
);
|
||||
|
||||
// Slot 5's Disk II
|
||||
if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2)
|
||||
{
|
||||
GetTrackSector(SLOT5, nDrive1Track, nDrive2Track, nActiveFloppy);
|
||||
DrawTrackSector(dc, SLOT5, nDrive1Track, g_nSector[SLOT5][0], nDrive2Track, g_nSector[SLOT5][1]);
|
||||
//GetTrackSector(SLOT5, nDrive1Track, nDrive2Track, nActiveFloppy);
|
||||
int nSlot5ActiveFloppy = GetActiveDrive(SLOT5);
|
||||
DrawTrackSector(
|
||||
dc,
|
||||
SLOT5,
|
||||
g_nTrack[SLOT5][0], g_nSector[SLOT5][0],
|
||||
g_nTrack[SLOT5][1], g_nSector[SLOT5][1]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user