2021-11-11 21:45:55 +00:00
|
|
|
/*
|
|
|
|
AppleWin : An Apple //e emulator for Windows
|
|
|
|
|
|
|
|
Copyright (C) 2021, Tom Charlesworth, Michael Pohoreski
|
|
|
|
|
|
|
|
AppleWin is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
AppleWin is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with AppleWin; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "Card.h"
|
|
|
|
|
2022-02-27 17:26:48 +00:00
|
|
|
#include "Uthernet1.h"
|
|
|
|
#include "Uthernet2.h"
|
2021-11-11 21:45:55 +00:00
|
|
|
#include "Mockingboard.h"
|
|
|
|
#include "ParallelPrinter.h"
|
|
|
|
#include "z80emu.h"
|
2022-01-30 21:25:40 +00:00
|
|
|
#include "FourPlay.h"
|
|
|
|
#include "LanguageCard.h"
|
|
|
|
#include "MouseInterface.h"
|
|
|
|
#include "SAM.h"
|
|
|
|
#include "SerialComms.h"
|
|
|
|
#include "SNESMAX.h"
|
|
|
|
#include "VidHD.h"
|
2023-01-28 19:58:12 +00:00
|
|
|
#include "z80emu.h"
|
2021-11-11 21:45:55 +00:00
|
|
|
|
2022-01-30 21:25:40 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
void Card::ThrowErrorInvalidSlot()
|
|
|
|
{
|
|
|
|
ThrowErrorInvalidSlot(m_type, m_slot);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Card::ThrowErrorInvalidSlot(SS_CARDTYPE type, UINT slot)
|
|
|
|
{
|
|
|
|
std::ostringstream msg;
|
|
|
|
msg << "The card '" << GetCardName(type);
|
|
|
|
msg << "' is not allowed in Slot " << slot << ".";
|
|
|
|
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Card::ThrowErrorInvalidVersion(UINT version)
|
|
|
|
{
|
|
|
|
ThrowErrorInvalidVersion(m_type, version);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Card::ThrowErrorInvalidVersion(SS_CARDTYPE type, UINT version)
|
|
|
|
{
|
|
|
|
std::ostringstream msg;
|
|
|
|
msg << "Version " << version;
|
|
|
|
msg << " is not supported for card '" << GetCardName(type) << "'.";
|
|
|
|
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
}
|
2021-11-11 21:45:55 +00:00
|
|
|
|
|
|
|
void DummyCard::InitializeIO(LPBYTE pCxRomPeripheral)
|
|
|
|
{
|
|
|
|
switch (QueryType())
|
|
|
|
{
|
|
|
|
case CT_GenericClock:
|
2023-01-28 19:58:12 +00:00
|
|
|
case CT_Echo:
|
2023-01-28 18:15:28 +00:00
|
|
|
default:
|
|
|
|
_ASSERT(0);
|
2021-11-11 21:45:55 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-13 18:13:01 +00:00
|
|
|
|
|
|
|
void DummyCard::Update(const ULONG nExecutedCycles)
|
|
|
|
{
|
|
|
|
switch (QueryType())
|
|
|
|
{
|
2023-01-28 19:58:12 +00:00
|
|
|
case CT_GenericClock:
|
|
|
|
case CT_Echo:
|
2023-01-28 18:15:28 +00:00
|
|
|
default:
|
|
|
|
_ASSERT(0);
|
2021-11-13 18:13:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-11-25 20:23:21 +00:00
|
|
|
|
|
|
|
void DummyCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
|
|
|
{
|
|
|
|
switch (QueryType())
|
|
|
|
{
|
2023-01-28 19:58:12 +00:00
|
|
|
case CT_GenericClock:
|
|
|
|
case CT_Echo:
|
2023-01-28 18:15:28 +00:00
|
|
|
default:
|
|
|
|
_ASSERT(0);
|
2021-11-25 20:23:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DummyCard::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version)
|
|
|
|
{
|
|
|
|
switch (QueryType())
|
|
|
|
{
|
2023-01-28 19:58:12 +00:00
|
|
|
case CT_GenericClock:
|
|
|
|
case CT_Echo:
|
2023-01-28 18:15:28 +00:00
|
|
|
default:
|
|
|
|
_ASSERT(0);
|
2021-11-25 20:23:21 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-30 21:25:40 +00:00
|
|
|
|
|
|
|
std::string Card::GetCardName(void)
|
|
|
|
{
|
|
|
|
return GetCardName(m_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Card::GetCardName(const SS_CARDTYPE cardType)
|
|
|
|
{
|
|
|
|
switch (cardType)
|
|
|
|
{
|
|
|
|
case CT_Empty:
|
|
|
|
return "Empty";
|
|
|
|
case CT_LanguageCard:
|
|
|
|
return LanguageCardSlot0::GetSnapshotCardName();
|
|
|
|
case CT_Saturn128K:
|
|
|
|
return Saturn128K::GetSnapshotCardName();
|
|
|
|
case CT_Disk2:
|
|
|
|
return Disk2InterfaceCard::GetSnapshotCardName();
|
|
|
|
case CT_SSC:
|
|
|
|
return CSuperSerialCard::GetSnapshotCardName();
|
|
|
|
case CT_MockingboardC:
|
2023-01-28 18:15:28 +00:00
|
|
|
return MockingboardCard::GetSnapshotCardName();
|
2022-01-30 21:25:40 +00:00
|
|
|
case CT_GenericPrinter:
|
2022-03-18 22:04:34 +00:00
|
|
|
return ParallelPrinterCard::GetSnapshotCardName();
|
2022-01-30 21:25:40 +00:00
|
|
|
case CT_GenericHDD:
|
|
|
|
return HarddiskInterfaceCard::GetSnapshotCardName();
|
|
|
|
case CT_GenericClock:
|
|
|
|
return "Clock";
|
|
|
|
case CT_MouseInterface:
|
|
|
|
return CMouseInterface::GetSnapshotCardName();
|
|
|
|
case CT_Z80:
|
2023-01-28 19:58:12 +00:00
|
|
|
return Z80Card::GetSnapshotCardName();
|
2022-01-30 21:25:40 +00:00
|
|
|
case CT_Phasor:
|
2023-01-28 18:15:28 +00:00
|
|
|
return MockingboardCard::GetSnapshotCardNamePhasor();
|
2022-01-30 21:25:40 +00:00
|
|
|
case CT_Echo:
|
|
|
|
return "Echo";
|
|
|
|
case CT_SAM:
|
|
|
|
return SAMCard::GetSnapshotCardName();
|
|
|
|
case CT_Uthernet:
|
2022-02-27 17:26:48 +00:00
|
|
|
return Uthernet1::GetSnapshotCardName();
|
2022-01-30 21:25:40 +00:00
|
|
|
case CT_FourPlay:
|
|
|
|
return FourPlayCard::GetSnapshotCardName();
|
|
|
|
case CT_SNESMAX:
|
|
|
|
return SNESMAXCard::GetSnapshotCardName();
|
|
|
|
case CT_VidHD:
|
|
|
|
return VidHDCard::GetSnapshotCardName();
|
2022-02-27 17:26:48 +00:00
|
|
|
case CT_Uthernet2:
|
|
|
|
return Uthernet2::GetSnapshotCardName();
|
2023-04-12 17:19:18 +00:00
|
|
|
case CT_MegaAudio:
|
|
|
|
return MockingboardCard::GetSnapshotCardNameMegaAudio();
|
2023-04-28 15:41:22 +00:00
|
|
|
case CT_SDMusic:
|
|
|
|
return MockingboardCard::GetSnapshotCardNameSDMusic();
|
2022-01-30 21:25:40 +00:00
|
|
|
default:
|
|
|
|
return "Unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SS_CARDTYPE Card::GetCardType(const std::string & card)
|
|
|
|
{
|
2022-03-18 22:04:34 +00:00
|
|
|
if (card == ParallelPrinterCard::GetSnapshotCardName())
|
2022-01-30 21:25:40 +00:00
|
|
|
{
|
|
|
|
return CT_GenericPrinter;
|
|
|
|
}
|
|
|
|
else if (card == CSuperSerialCard::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_SSC;
|
|
|
|
}
|
|
|
|
else if (card == CMouseInterface::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_MouseInterface;
|
|
|
|
}
|
2023-01-28 19:58:12 +00:00
|
|
|
else if (card == Z80Card::GetSnapshotCardName())
|
2022-01-30 21:25:40 +00:00
|
|
|
{
|
|
|
|
return CT_Z80;
|
|
|
|
}
|
2023-01-28 18:15:28 +00:00
|
|
|
else if (card == MockingboardCard::GetSnapshotCardName())
|
2022-01-30 21:25:40 +00:00
|
|
|
{
|
|
|
|
return CT_MockingboardC;
|
|
|
|
}
|
2023-01-28 18:15:28 +00:00
|
|
|
else if (card == MockingboardCard::GetSnapshotCardNamePhasor())
|
2022-01-30 21:25:40 +00:00
|
|
|
{
|
|
|
|
return CT_Phasor;
|
|
|
|
}
|
|
|
|
else if (card == SAMCard::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_SAM;
|
|
|
|
}
|
|
|
|
else if (card == Disk2InterfaceCard::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_Disk2;
|
|
|
|
}
|
|
|
|
else if (card == HarddiskInterfaceCard::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_GenericHDD;
|
|
|
|
}
|
2022-02-27 17:26:48 +00:00
|
|
|
else if (card == Uthernet1::GetSnapshotCardName())
|
2022-01-30 21:25:40 +00:00
|
|
|
{
|
|
|
|
return CT_Uthernet;
|
|
|
|
}
|
|
|
|
else if (card == LanguageCardSlot0::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_LanguageCard;
|
|
|
|
}
|
|
|
|
else if (card == Saturn128K::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_Saturn128K;
|
|
|
|
}
|
|
|
|
else if (card == FourPlayCard::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_FourPlay;
|
|
|
|
}
|
|
|
|
else if (card == SNESMAXCard::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_SNESMAX;
|
|
|
|
}
|
|
|
|
else if (card == VidHDCard::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_VidHD;
|
|
|
|
}
|
2022-02-27 17:26:48 +00:00
|
|
|
else if (card == Uthernet2::GetSnapshotCardName())
|
|
|
|
{
|
|
|
|
return CT_Uthernet2;
|
|
|
|
}
|
2023-04-12 17:19:18 +00:00
|
|
|
else if (card == MockingboardCard::GetSnapshotCardNameMegaAudio())
|
|
|
|
{
|
|
|
|
return CT_MegaAudio;
|
|
|
|
}
|
2023-04-28 15:41:22 +00:00
|
|
|
else if (card == MockingboardCard::GetSnapshotCardNameSDMusic())
|
|
|
|
{
|
|
|
|
return CT_SDMusic;
|
|
|
|
}
|
2022-01-30 21:25:40 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Slots: Unknown card: " + card); // todo: don't throw - just ignore & continue
|
|
|
|
}
|
2022-01-30 21:37:40 +00:00
|
|
|
}
|