Refactor: move m_slot into Card class

This commit is contained in:
tomcw 2021-11-01 21:01:28 +00:00
parent 67b3c28833
commit d96ed5b8c5
14 changed files with 36 additions and 48 deletions

View File

@ -30,14 +30,17 @@ enum SLOTS { SLOT0=0, SLOT1, SLOT2, SLOT3, SLOT4, SLOT5, SLOT6, SLOT7, NUM_SLOTS
class Card
{
public:
Card(void) : m_type(CT_Empty) {}
Card(SS_CARDTYPE type) : m_type(type) {}
Card(void) : m_type(CT_Empty), m_slot(SLOT0) {}
Card(SS_CARDTYPE type, UINT slot) : m_type(type), m_slot(slot) {}
virtual ~Card(void) {}
virtual void Init(void) = 0;
virtual void Reset(const bool powerCycle) = 0;
SS_CARDTYPE QueryType(void) { return m_type; }
protected:
UINT m_slot;
private:
SS_CARDTYPE m_type;
};
@ -59,7 +62,7 @@ public:
class DummyCard : public Card // For cards that currently can't be instantiated (ie. don't exist as a class)
{
public:
DummyCard(SS_CARDTYPE type) : Card(type) {}
DummyCard(SS_CARDTYPE type, UINT slot) : Card(type, slot) {}
virtual ~DummyCard(void) {}
virtual void Init(void) {};

View File

@ -59,16 +59,16 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
m_slot[slot] = m_pSSC = new CSuperSerialCard(slot);
break;
case CT_MockingboardC:
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_GenericPrinter:
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_GenericHDD:
m_slot[slot] = new HarddiskInterfaceCard(slot);
break;
case CT_GenericClock:
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_MouseInterface:
_ASSERT(m_pMouseCard == NULL);
@ -76,19 +76,19 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
m_slot[slot] = m_pMouseCard = new CMouseInterface(slot);
break;
case CT_Z80:
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_Phasor:
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_Echo:
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_SAM:
m_slot[slot] = new SAMCard(slot);
break;
case CT_Uthernet:
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_FourPlay:
m_slot[slot] = new FourPlayCard(slot);
@ -106,7 +106,7 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
break;
}
}
m_slot[slot] = new DummyCard(type);
m_slot[slot] = new DummyCard(type, slot);
break;
case CT_LanguageCardIIe: // not a card
@ -153,13 +153,13 @@ void CardManager::InsertAuxInternal(SS_CARDTYPE type)
m_aux = new EmptyCard;
break;
case CT_80Col:
m_aux = new DummyCard(type);
m_aux = new DummyCard(type, SLOT_AUX);
break;
case CT_Extended80Col:
m_aux = new DummyCard(type);
m_aux = new DummyCard(type, SLOT_AUX);
break;
case CT_RamWorksIII:
m_aux = new DummyCard(type);
m_aux = new DummyCard(type, SLOT_AUX);
break;
default:
_ASSERT(0);

View File

@ -58,8 +58,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
const BYTE Disk2InterfaceCard::m_T00S00Pattern[] = {0xD5,0xAA,0x96,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xDE};
Disk2InterfaceCard::Disk2InterfaceCard(UINT slot) :
Card(CT_Disk2),
m_slot(slot)
Card(CT_Disk2, slot)
{
ResetSwitches();

View File

@ -246,7 +246,6 @@ private:
WORD m_magnetStates; // state bits for stepper motor magnet states (phases 0 - 3)
bool m_saveDiskImage;
UINT m_slot;
unsigned __int64 m_diskLastCycle;
unsigned __int64 m_diskLastReadLatchCycle;
FormatTrack m_formatTrack;

View File

@ -6,8 +6,7 @@ class FourPlayCard : public Card
{
public:
FourPlayCard(UINT slot) :
Card(CT_FourPlay),
m_slot(slot)
Card(CT_FourPlay, slot)
{
}
virtual ~FourPlayCard(void) {}
@ -27,6 +26,4 @@ public:
private:
static BYTE MyGetAsyncKeyState(int vKey);
UINT m_slot;
};

View File

@ -117,8 +117,7 @@ Overview
HarddiskInterfaceCard::HarddiskInterfaceCard(UINT slot) :
Card(CT_GenericHDD),
m_slot(slot)
Card(CT_GenericHDD, slot)
{
m_unitNum = HARDDISK_1 << 7; // b7=unit

View File

@ -127,7 +127,6 @@ private:
BYTE m_command;
bool m_saveDiskImage; // Save the DiskImage name to Registry
UINT m_slot;
HardDiskDrive m_hardDiskDrive[NUM_HARDDISKS];
};

View File

@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
const UINT LanguageCardUnit::kMemModeInitialState = MF_BANK2 | MF_WRITERAM; // !INTCXROM
LanguageCardUnit::LanguageCardUnit(SS_CARDTYPE type/*=CT_LanguageCardIIe*/) :
Card(type),
Card(type, kSlot0),
m_uLastRamWrite(0)
{
SetMemMainLanguageCard(NULL, true);

View File

@ -134,9 +134,8 @@ void M6821_Listener_A( void* objTo, BYTE byData )
//===========================================================================
CMouseInterface::CMouseInterface(UINT slot) :
Card(CT_MouseInterface),
Card(CT_MouseInterface, slot),
m_pSlotRom(NULL),
m_uSlot(slot),
m_syncEvent(slot, 0, SyncEventCallback) // use slot# as "unique" id for MouseInterfaces
{
m_6821.SetListenerB( this, M6821_Listener_B );
@ -177,7 +176,7 @@ void CMouseInterface::InitializeIO(LPBYTE pCxRomPeripheral)
// m_bActive = true;
m_bEnabled = true;
SetSlotRom(); // Pre: m_bActive == true
RegisterIoHandler(m_uSlot, &CMouseInterface::IORead, &CMouseInterface::IOWrite, NULL, NULL, this, NULL);
RegisterIoHandler(m_slot, &CMouseInterface::IORead, &CMouseInterface::IOWrite, NULL, NULL, this, NULL);
if (m_syncEvent.m_active) g_SynchronousEventMgr.Remove(m_syncEvent.m_id);
m_syncEvent.m_cyclesRemaining = NTSC_GetCyclesUntilVBlank(0);
@ -233,9 +232,9 @@ void CMouseInterface::SetSlotRom()
return;
UINT uOffset = (m_by6821B << 7) & 0x0700;
memcpy(pCxRomPeripheral+m_uSlot*256, m_pSlotRom+uOffset, 256);
memcpy(pCxRomPeripheral+m_slot*256, m_pSlotRom+uOffset, 256);
if (mem)
memcpy(mem+0xC000+m_uSlot*256, m_pSlotRom+uOffset, 256);
memcpy(mem+0xC000+m_slot*256, m_pSlotRom+uOffset, 256);
}
//===========================================================================
@ -657,7 +656,7 @@ void CMouseInterface::SaveSnapshot(class YamlSaveHelper& yamlSaveHelper)
// if (!m_bActive)
// return;
YamlSaveHelper::Slot slot(yamlSaveHelper, GetSnapshotCardName(), m_uSlot, 1);
YamlSaveHelper::Slot slot(yamlSaveHelper, GetSnapshotCardName(), m_slot, 1);
YamlSaveHelper::Label state(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE);
SaveSnapshotMC6821(yamlSaveHelper, SS_YAML_KEY_MC6821);

View File

@ -17,7 +17,7 @@ public:
void InitializeIO(LPBYTE pCxRomPeripheral);
// void Uninitialize();
void Reset();
UINT GetSlot(void) { return m_uSlot; }
UINT GetSlot(void) { return m_slot; }
static BYTE __stdcall IORead(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
static BYTE __stdcall IOWrite(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
@ -106,7 +106,6 @@ protected:
// bool m_bActive; // Mouse h/w is active within the Apple][ VM
bool m_bEnabled; // Windows' mouse events get passed to Apple]['s mouse h/w (m_bEnabled == true implies that m_bActive == true)
LPBYTE m_pSlotRom;
UINT m_uSlot;
SyncEvent m_syncEvent;
};

View File

@ -6,8 +6,7 @@ class SAMCard : public Card
{
public:
SAMCard(UINT slot) :
Card(CT_SAM),
m_slot(slot)
Card(CT_SAM, slot)
{
}
virtual ~SAMCard(void) {}
@ -24,5 +23,5 @@ public:
bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version);
private:
UINT m_slot;
// no state
};

View File

@ -7,8 +7,7 @@ class SNESMAXCard : public Card
{
public:
SNESMAXCard(UINT slot) :
Card(CT_SNESMAX),
m_slot(slot)
Card(CT_SNESMAX, slot)
{
m_buttonIndex = 0;
m_controller1Buttons = 0;
@ -32,8 +31,6 @@ public:
bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version);
private:
UINT m_slot;
UINT m_buttonIndex;
UINT m_controller1Buttons;
UINT m_controller2Buttons;

View File

@ -65,8 +65,7 @@ SSC_DIPSW CSuperSerialCard::m_DIPSWDefault =
//===========================================================================
CSuperSerialCard::CSuperSerialCard(UINT slot) :
Card(CT_SSC),
m_uSlot(slot),
Card(CT_SSC, slot),
m_aySerialPortChoices(NULL),
m_uTCPChoiceItemIdx(0),
m_bCfgSupportDCD(false),
@ -90,7 +89,7 @@ CSuperSerialCard::CSuperSerialCard(UINT slot) :
//
char serialPortName[CSuperSerialCard::SIZEOF_SERIALCHOICE_ITEM];
std::string& regSection = RegGetConfigSlotSection(m_uSlot);
std::string& regSection = RegGetConfigSlotSection(m_slot);
RegLoadString(regSection.c_str(), REGVALUE_SERIAL_PORT_NAME, TRUE, serialPortName, sizeof(serialPortName), TEXT(""));
SetSerialPortName(serialPortName);
@ -952,7 +951,7 @@ void CSuperSerialCard::InitializeIO(LPBYTE pCxRomPeripheral)
if(pData == NULL)
return;
memcpy(pCxRomPeripheral + m_uSlot*SSC_SLOT_FW_SIZE, pData+SSC_SLOT_FW_OFFSET, SSC_SLOT_FW_SIZE);
memcpy(pCxRomPeripheral + m_slot*SSC_SLOT_FW_SIZE, pData+SSC_SLOT_FW_OFFSET, SSC_SLOT_FW_SIZE);
// Expansion ROM
if (m_pExpansionRom == NULL)
@ -965,7 +964,7 @@ void CSuperSerialCard::InitializeIO(LPBYTE pCxRomPeripheral)
//
RegisterIoHandler(m_uSlot, &CSuperSerialCard::SSC_IORead, &CSuperSerialCard::SSC_IOWrite, NULL, NULL, this, m_pExpansionRom);
RegisterIoHandler(m_slot, &CSuperSerialCard::SSC_IORead, &CSuperSerialCard::SSC_IOWrite, NULL, NULL, this, m_pExpansionRom);
}
//===========================================================================
@ -1393,7 +1392,7 @@ void CSuperSerialCard::SetSerialPortName(const char* pSerialPortName)
void CSuperSerialCard::SetRegistrySerialPortName(void)
{
std::string& regSection = RegGetConfigSlotSection(m_uSlot);
std::string& regSection = RegGetConfigSlotSection(m_slot);
RegSaveString(regSection.c_str(), REGVALUE_SERIAL_PORT_NAME, TRUE, GetSerialPortName());
}
@ -1447,7 +1446,7 @@ void CSuperSerialCard::SaveSnapshotDIPSW(YamlSaveHelper& yamlSaveHelper, std::st
void CSuperSerialCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
{
YamlSaveHelper::Slot slot(yamlSaveHelper, GetSnapshotCardName(), m_uSlot, kUNIT_VERSION);
YamlSaveHelper::Slot slot(yamlSaveHelper, GetSnapshotCardName(), m_slot, kUNIT_VERSION);
YamlSaveHelper::Label unit(yamlSaveHelper, "%s:\n", SS_YAML_KEY_STATE);
SaveSnapshotDIPSW(yamlSaveHelper, SS_YAML_KEY_DIPSWDEFAULT, m_DIPSWDefault);

View File

@ -141,7 +141,6 @@ private:
OVERLAPPED m_o;
BYTE* m_pExpansionRom;
UINT m_uSlot;
bool m_bCfgSupportDCD;
UINT m_uDTR;