Support disconnecting drives from DiskII Interface card: -d1-disconnected, -d2-disconnected

This commit is contained in:
tomcw 2020-12-12 20:49:46 +00:00
parent 1e35d4448c
commit 469f9ba807
7 changed files with 42 additions and 9 deletions

View File

@ -134,6 +134,14 @@ bool ProcessCmdLine(LPSTR lpCmdLine)
lpNextArg = GetNextArg(lpNextArg); lpNextArg = GetNextArg(lpNextArg);
g_cmdLine.szImageName_drive[SLOT6][DRIVE_2] = lpCmdLine; g_cmdLine.szImageName_drive[SLOT6][DRIVE_2] = lpCmdLine;
} }
else if (strcmp(lpCmdLine, "-d1-disconnected") == 0)
{
g_cmdLine.driveConnected[SLOT6][DRIVE_1] = false;
}
else if (strcmp(lpCmdLine, "-d2-disconnected") == 0)
{
g_cmdLine.driveConnected[SLOT6][DRIVE_2] = false;
}
else if (strcmp(lpCmdLine, "-h1") == 0) else if (strcmp(lpCmdLine, "-h1") == 0)
{ {
lpCmdLine = GetCurrArg(lpNextArg); lpCmdLine = GetCurrArg(lpNextArg);

View File

@ -44,6 +44,8 @@ struct CmdLine
slotInsert[i] = CT_Empty; slotInsert[i] = CT_Empty;
szImageName_drive[i][DRIVE_1] = NULL; szImageName_drive[i][DRIVE_1] = NULL;
szImageName_drive[i][DRIVE_2] = NULL; szImageName_drive[i][DRIVE_2] = NULL;
driveConnected[i][DRIVE_1] = true;
driveConnected[i][DRIVE_2] = true;
} }
} }
@ -60,6 +62,7 @@ struct CmdLine
UINT bestWidth; UINT bestWidth;
UINT bestHeight; UINT bestHeight;
LPSTR szImageName_drive[NUM_SLOTS][NUM_DRIVES]; LPSTR szImageName_drive[NUM_SLOTS][NUM_DRIVES];
bool driveConnected[NUM_SLOTS][NUM_DRIVES];
LPSTR szImageName_harddisk[NUM_HARDDISKS]; LPSTR szImageName_harddisk[NUM_HARDDISKS];
LPSTR szSnapshotName; LPSTR szSnapshotName;
LPSTR szScreenshotFilename; LPSTR szScreenshotFilename;

View File

@ -355,6 +355,16 @@ void Disk2InterfaceCard::EjectDisk(const int drive)
Video_ResetScreenshotCounter(""); Video_ResetScreenshotCounter("");
} }
void Disk2InterfaceCard::UnplugDrive(const int drive)
{
if (!IsDriveValid(drive))
return;
EjectDisk(drive);
m_floppyDrive[drive].m_isConnected = false;
}
//=========================================================================== //===========================================================================
void Disk2InterfaceCard::WriteTrack(const int drive) void Disk2InterfaceCard::WriteTrack(const int drive)
@ -1552,6 +1562,12 @@ void Disk2InterfaceCard::ResetSwitches(void)
bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilename/*=""*/) bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilename/*=""*/)
{ {
if (!IsDriveConnected(drive))
{
MessageBox(g_hFrameWindow, "Drive not connected!", "Insert disk", MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_OK);
return false;
}
TCHAR directory[MAX_PATH]; TCHAR directory[MAX_PATH];
TCHAR filename[MAX_PATH]; TCHAR filename[MAX_PATH];
TCHAR title[40]; TCHAR title[40];

View File

@ -144,6 +144,7 @@ public:
ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary); ImageError_e InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary);
void EjectDisk(const int drive); void EjectDisk(const int drive);
void UnplugDrive(const int drive);
bool IsConditionForFullSpeed(void); bool IsConditionForFullSpeed(void);
void NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error); void NotifyInvalidImage(const int drive, LPCTSTR pszImageFilename, const ImageError_e Error);

View File

@ -389,16 +389,17 @@ bool DoHardDiskInsert(const int nDrive, LPCSTR szFileName)
return res; return res;
} }
void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], bool& bBoot) void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], bool driveConnected[NUM_DRIVES], bool& bBoot)
{ {
_ASSERT(slot == 5 || slot == 6); _ASSERT(slot == 5 || slot == 6);
if (!szImageName_drive[DRIVE_1] && !szImageName_drive[DRIVE_2])
return;
bool bRes = true; bool bRes = true;
if (szImageName_drive[DRIVE_1]) if (!driveConnected[DRIVE_1])
{
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(slot)).UnplugDrive(DRIVE_1);
}
else if (szImageName_drive[DRIVE_1])
{ {
bRes = DoDiskInsert(slot, DRIVE_1, szImageName_drive[DRIVE_1]); bRes = DoDiskInsert(slot, DRIVE_1, szImageName_drive[DRIVE_1]);
LogFileOutput("Init: S%d, DoDiskInsert(D1), res=%d\n", slot, bRes); LogFileOutput("Init: S%d, DoDiskInsert(D1), res=%d\n", slot, bRes);
@ -406,7 +407,11 @@ void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], boo
bBoot = true; bBoot = true;
} }
if (szImageName_drive[DRIVE_2]) if (!driveConnected[DRIVE_2])
{
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(slot)).UnplugDrive(DRIVE_2);
}
else if (szImageName_drive[DRIVE_2])
{ {
bRes |= DoDiskInsert(slot, DRIVE_2, szImageName_drive[DRIVE_2]); bRes |= DoDiskInsert(slot, DRIVE_2, szImageName_drive[DRIVE_2]);
LogFileOutput("Init: S%d, DoDiskInsert(D2), res=%d\n", slot, bRes); LogFileOutput("Init: S%d, DoDiskInsert(D2), res=%d\n", slot, bRes);

View File

@ -7,7 +7,7 @@
void LoadConfiguration(); void LoadConfiguration();
bool DoDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileName); bool DoDiskInsert(const UINT slot, const int nDrive, LPCSTR szFileName);
bool DoHardDiskInsert(const int nDrive, LPCSTR szFileName); bool DoHardDiskInsert(const int nDrive, LPCSTR szFileName);
void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], bool& bBoot); void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], bool driveConnected[NUM_DRIVES], bool& bBoot);
void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot); void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot);
void UnplugHardDiskControllerCard(void); void UnplugHardDiskControllerCard(void);
void GetAppleWindowTitle(); void GetAppleWindowTitle();

View File

@ -880,10 +880,10 @@ static void RepeatInitialization(void)
// Post: may enable HDD, required for MemInitialize()->MemInitializeIO() // Post: may enable HDD, required for MemInitialize()->MemInitializeIO()
{ {
bool temp = false; bool temp = false;
InsertFloppyDisks(SLOT5, g_cmdLine.szImageName_drive[SLOT5], temp); InsertFloppyDisks(SLOT5, g_cmdLine.szImageName_drive[SLOT5], g_cmdLine.driveConnected[SLOT5], temp);
//g_cmdLine.szImageName_drive[SLOT5][DRIVE_1] = g_cmdLine.szImageName_drive[SLOT5][DRIVE_2] = NULL; // *Do* insert on a restart (since no way they could have changed) //g_cmdLine.szImageName_drive[SLOT5][DRIVE_1] = g_cmdLine.szImageName_drive[SLOT5][DRIVE_2] = NULL; // *Do* insert on a restart (since no way they could have changed)
InsertFloppyDisks(SLOT6, g_cmdLine.szImageName_drive[SLOT6], g_cmdLine.bBoot); InsertFloppyDisks(SLOT6, g_cmdLine.szImageName_drive[SLOT6], g_cmdLine.driveConnected[SLOT6], g_cmdLine.bBoot);
g_cmdLine.szImageName_drive[SLOT6][DRIVE_1] = g_cmdLine.szImageName_drive[SLOT6][DRIVE_2] = NULL; // Don't insert on a restart g_cmdLine.szImageName_drive[SLOT6][DRIVE_1] = g_cmdLine.szImageName_drive[SLOT6][DRIVE_2] = NULL; // Don't insert on a restart
InsertHardDisks(g_cmdLine.szImageName_harddisk, g_cmdLine.bBoot); InsertHardDisks(g_cmdLine.szImageName_harddisk, g_cmdLine.bBoot);