Support 2nd Disk][ card and improved card management (#726) (PR #741)

Support 2nd Disk][ in slot-5, via command line:
- -s5 diskii
- -s5d1 \<imagefile\>
- -s5d2 \<imagefile\>

NB. there's currently no Configuration UI support, except the Drive icons' tooltips show what's in slot-5 & slot-6 (for drive-n). So there's no way to eject the disks or insert new disks. The use-case I'm supporting it Wasteland which just has the 4 disks in the 4 drives.

Improved card management:
- Added `class Card` (in Card.h) which all other cards (that exist as classes) derive from (eg. LC,SSC,Mouse,Disk2).
- Added `class CardManager` (in CardManager.cpp\h) which now manages the 8 slots (and aux slot).
- Added `class Disk2CardManager` (in Disk2CardManager.cpp\h) which provides methods for operations that act on all Disk2 instances at the same time.
- Currently limited to just 1x SSC and 1x Mouse card (why would you need more?). This simplifies things, meaning there's no need to have dedicated SSCManager / MouseCardManager objects.
- Currently the 2nd Disk2 card can only be put into slot-5. This limitation is just due to the complexity of the Configuration UI. Having a more general drop-down per slot UI would remove this limitation.
This commit is contained in:
TomCh
2019-12-19 19:42:30 +00:00
committed by GitHub
parent d2010860ef
commit 769d4c6927
41 changed files with 1169 additions and 418 deletions
+15 -7
View File
@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#include "../Applewin.h" // g_nAppMode, g_uScrollLockToggle, sg_PropertySheet
#include "../CardManager.h"
#include "../Disk.h"
#include "../Frame.h"
#include "../Log.h"
@@ -124,7 +125,11 @@ void CPropertySheetHelper::SetSlot(UINT slot, SS_CARDTYPE newCardType)
if (slot >= NUM_SLOTS)
return;
g_Slot[slot] = newCardType;
// Two paths:
// 1) Via Config dialog: card not inserted yet
// 2) Snapshot_LoadState_v2(): card already inserted
if (g_CardMgr.QuerySlot(slot) != newCardType)
g_CardMgr.Insert(slot, newCardType);
std::string slotText;
switch (slot)
@@ -139,7 +144,7 @@ void CPropertySheetHelper::SetSlot(UINT slot, SS_CARDTYPE newCardType)
case 7: slotText = REGVALUE_SLOT7; break;
}
REGSAVE(slotText.c_str(), (DWORD)g_Slot[slot]);
REGSAVE(slotText.c_str(), (DWORD)newCardType);
}
// Looks like a (bad) C&P from SaveStateSelectImage()
@@ -209,7 +214,10 @@ void CPropertySheetHelper::SaveStateUpdate()
void CPropertySheetHelper::GetDiskBaseNameWithAWS(std::string & pszFilename)
{
const std::string & pDiskName = sg_Disk2Card.GetBaseName(DRIVE_1);
if (g_CardMgr.QuerySlot(SLOT6) != CT_Disk2)
return;
const std::string & pDiskName = dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->GetBaseName(DRIVE_1);
if (!pDiskName.empty())
{
pszFilename = pDiskName + ".aws.yaml";
@@ -445,8 +453,8 @@ void CPropertySheetHelper::SaveCurrentConfig(void)
// NB. clone-type is encoded in g_Apple2Type
m_ConfigOld.m_Apple2Type = GetApple2Type();
m_ConfigOld.m_CpuType = GetMainCpu();
m_ConfigOld.m_Slot[4] = g_Slot[4];
m_ConfigOld.m_Slot[5] = g_Slot[5];
m_ConfigOld.m_Slot[SLOT4] = g_CardMgr.QuerySlot(SLOT4);
m_ConfigOld.m_Slot[SLOT5] = g_CardMgr.QuerySlot(SLOT5);
m_ConfigOld.m_bEnableHDD = HD_CardIsEnabled();
m_ConfigOld.m_bEnableTheFreezesF8Rom = sg_PropertySheet.GetTheFreezesF8Rom();
m_ConfigOld.m_videoRefreshRate = GetVideoRefreshRate();
@@ -464,8 +472,8 @@ void CPropertySheetHelper::RestoreCurrentConfig(void)
// NB. clone-type is encoded in g_Apple2Type
SetApple2Type(m_ConfigOld.m_Apple2Type);
SetMainCpu(m_ConfigOld.m_CpuType);
g_Slot[4] = m_ConfigOld.m_Slot[4];
g_Slot[5] = m_ConfigOld.m_Slot[5];
g_CardMgr.Insert(SLOT4, m_ConfigOld.m_Slot[SLOT4]);
g_CardMgr.Insert(SLOT5, m_ConfigOld.m_Slot[SLOT5]);
HD_SetEnabled(m_ConfigOld.m_bEnableHDD);
sg_PropertySheet.SetTheFreezesF8Rom(m_ConfigOld.m_bEnableTheFreezesF8Rom);
SetVideoRefreshRate(m_ConfigOld.m_videoRefreshRate);