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
+37 -34
View File
@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h"
#include "Applewin.h"
#include "CardManager.h"
#include "CPU.h"
#include "Disk.h"
#include "Frame.h"
@@ -291,8 +292,8 @@ void SetExpansionMemType(const SS_CARDTYPE type)
newSlotAuxCard = type;
}
g_Slot[0] = newSlot0Card;
g_SlotAux = newSlotAuxCard;
g_CardMgr.Insert(SLOT0, newSlot0Card);
g_CardMgr.InsertAux(newSlotAuxCard);
}
void CreateLanguageCard(void)
@@ -302,9 +303,9 @@ void CreateLanguageCard(void)
if (IsApple2PlusOrClone(GetApple2Type()))
{
if (g_Slot[0] == CT_Saturn128K)
if (g_CardMgr.QuerySlot(SLOT0) == CT_Saturn128K)
g_pLanguageCard = new Saturn128K(g_uSaturnBanksFromCmdLine);
else if (g_Slot[0] == CT_LanguageCard)
else if (g_CardMgr.QuerySlot(SLOT0) == CT_LanguageCard)
g_pLanguageCard = new LanguageCardSlot0;
else
g_pLanguageCard = NULL;
@@ -318,9 +319,9 @@ void CreateLanguageCard(void)
SS_CARDTYPE GetCurrentExpansionMemType(void)
{
if (IsApple2PlusOrClone(GetApple2Type()))
return g_Slot[0];
return g_CardMgr.QuerySlot(SLOT0);
else
return g_SlotAux;
return g_CardMgr.QueryAux();
}
//
@@ -1048,7 +1049,7 @@ static void ResetPaging(BOOL initialize)
{
SetLastRamWrite(0);
if (IsApple2PlusOrClone(GetApple2Type()) && g_Slot[0] == CT_Empty)
if (IsApple2PlusOrClone(GetApple2Type()) && g_CardMgr.QuerySlot(SLOT0) == CT_Empty)
SetMemMode(0);
else
SetMemMode(LanguageCardUnit::kMemModeInitialState);
@@ -1467,7 +1468,7 @@ void MemInitialize()
SetExpansionMemTypeDefault();
#ifdef RAMWORKS
if (g_SlotAux == CT_RamWorksIII)
if (g_CardMgr.QueryAux() == CT_RamWorksIII)
{
// allocate memory for RAMWorks III - up to 8MB
g_uActiveBank = 0;
@@ -1572,7 +1573,7 @@ void MemInitializeCustomF8ROM(void)
const UINT F8RomSize = 0x800;
const UINT F8RomOffset = Apple2RomSize-F8RomSize;
if (IsApple2Original(GetApple2Type()) && g_Slot[0] == CT_LanguageCard)
if (IsApple2Original(GetApple2Type()) && g_CardMgr.QuerySlot(SLOT0) == CT_LanguageCard)
{
try
{
@@ -1654,13 +1655,13 @@ void MemInitializeIO(void)
else
RegisterIoHandler(LanguageCardUnit::kSlot0, IO_Null, IO_Null, NULL, NULL, NULL, NULL);
if (g_Slot[1] == CT_GenericPrinter)
PrintLoadRom(pCxRomPeripheral, 1); // $C100 : Parallel printer f/w
if (g_CardMgr.QuerySlot(SLOT1) == CT_GenericPrinter)
PrintLoadRom(pCxRomPeripheral, SLOT1); // $C100 : Parallel printer f/w
if (g_Slot[2] == CT_SSC)
sg_SSC.CommInitialize(pCxRomPeripheral, 2); // $C200 : SSC
if (g_CardMgr.QuerySlot(SLOT2) == CT_SSC)
dynamic_cast<CSuperSerialCard*>(g_CardMgr.GetObj(SLOT2))->CommInitialize(pCxRomPeripheral, SLOT2); // $C200 : SSC
if (g_Slot[3] == CT_Uthernet)
if (g_CardMgr.QuerySlot(SLOT3) == CT_Uthernet)
{
// Slot 3 contains the Uthernet card (which can coexist with an 80-col+Ram card in AUX slot)
// . Uthernet card has no ROM and only IO mapped at $C0Bx
@@ -1669,39 +1670,41 @@ void MemInitializeIO(void)
// Apple//e: Auxilary slot contains Extended 80 Column card or RamWorksIII card
if (g_Slot[4] == CT_MouseInterface)
if (g_CardMgr.QuerySlot(SLOT4) == CT_MouseInterface)
{
sg_Mouse.Initialize(pCxRomPeripheral, 4); // $C400 : Mouse f/w
dynamic_cast<CMouseInterface*>(g_CardMgr.GetObj(SLOT4))->Initialize(pCxRomPeripheral, SLOT4); // $C400 : Mouse f/w
}
else if (g_Slot[4] == CT_MockingboardC || g_Slot[4] == CT_Phasor)
else if (g_CardMgr.QuerySlot(SLOT4) == CT_MockingboardC || g_CardMgr.QuerySlot(SLOT4) == CT_Phasor)
{
const UINT uSlot4 = 4;
const UINT uSlot5 = 5;
MB_InitializeIO(pCxRomPeripheral, uSlot4, uSlot5);
MB_InitializeIO(pCxRomPeripheral, SLOT4, SLOT5);
}
else if (g_Slot[4] == CT_Z80)
else if (g_CardMgr.QuerySlot(SLOT4) == CT_Z80)
{
ConfigureSoftcard(pCxRomPeripheral, 4); // $C400 : Z80 card
ConfigureSoftcard(pCxRomPeripheral, SLOT4); // $C400 : Z80 card
}
// else if (g_Slot[4] == CT_GenericClock)
// else if (g_CardMgr.QuerySlot(SLOT4) == CT_GenericClock)
// {
// LoadRom_Clock_Generic(pCxRomPeripheral, 4);
// LoadRom_Clock_Generic(pCxRomPeripheral, SLOT4);
// }
if (g_Slot[5] == CT_Z80)
if (g_CardMgr.QuerySlot(SLOT5) == CT_Z80)
{
ConfigureSoftcard(pCxRomPeripheral, 5); // $C500 : Z80 card
ConfigureSoftcard(pCxRomPeripheral, SLOT5); // $C500 : Z80 card
}
else if (g_Slot[5] == CT_SAM)
else if (g_CardMgr.QuerySlot(SLOT5) == CT_SAM)
{
ConfigureSAM(pCxRomPeripheral, 5); // $C500 : Z80 card
ConfigureSAM(pCxRomPeripheral, SLOT5); // $C500 : Z80 card
}
else if (g_CardMgr.QuerySlot(SLOT5) == CT_Disk2)
{
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT5))->Initialize(pCxRomPeripheral, SLOT5); // $C500 : Disk][ card
}
if (g_Slot[6] == CT_Disk2)
sg_Disk2Card.Initialize(pCxRomPeripheral, 6); // $C600 : Disk][ card
if (g_CardMgr.QuerySlot(SLOT6) == CT_Disk2)
dynamic_cast<Disk2InterfaceCard*>(g_CardMgr.GetObj(SLOT6))->Initialize(pCxRomPeripheral, SLOT6); // $C600 : Disk][ card
if (g_Slot[7] == CT_GenericHDD)
HD_Load_Rom(pCxRomPeripheral, 7); // $C700 : HDD f/w
if (g_CardMgr.QuerySlot(SLOT7) == CT_GenericHDD)
HD_Load_Rom(pCxRomPeripheral, SLOT7); // $C700 : HDD f/w
//
@@ -2353,8 +2356,8 @@ static void MemLoadSnapshotAuxCommon(YamlLoadHelper& yamlLoadHelper, const std::
yamlLoadHelper.PopMap();
}
g_Slot[0] = CT_Empty;
g_SlotAux = type;
g_CardMgr.Remove(SLOT0);
g_CardMgr.InsertAux(type);
memaux = RWpages[g_uActiveBank];
// NB. MemUpdatePaging(TRUE) called at end of Snapshot_LoadState_v2()