mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-19 07:37:12 +00:00
Improve save-state card management (PR #983)
Initially all cards are removed before loading save-state. Use new Registry "Configuration/Slot 2" location to save SSC's port name. Use new Registry "Configuration/Slot 7" location to save HDV's image names. Use new Registry "Configuration/Slot n" (and "Configuration/Slot Auxiliary") locations to save all other card types. Command line: -s<slot> (eg. -s7 empty) now get persisted to the Registry. Only update 'HDV Starting Directory' for slot7 & drive1.
This commit is contained in:
+31
-46
@@ -286,6 +286,7 @@ static void ParseUnitApple2(YamlLoadHelper& yamlLoadHelper, UINT version)
|
||||
KeybLoadSnapshot(yamlLoadHelper, version);
|
||||
SpkrLoadSnapshot(yamlLoadHelper);
|
||||
GetVideo().VideoLoadSnapshot(yamlLoadHelper, version);
|
||||
m_ConfigNew.m_videoRefreshRate = GetVideo().GetVideoRefreshRate();
|
||||
MemLoadSnapshot(yamlLoadHelper, version);
|
||||
|
||||
// g_Apple2Type may've changed: so redraw frame (title, buttons, leds, etc)
|
||||
@@ -300,6 +301,8 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
||||
if (unitVersion != UNIT_SLOTS_VER)
|
||||
throw std::string(SS_YAML_KEY_UNIT ": Slots: Version mismatch");
|
||||
|
||||
bool cardInserted[NUM_SLOTS] = {};
|
||||
|
||||
while (1)
|
||||
{
|
||||
std::string scalar = yamlLoadHelper.GetMapNextSlotNumber();
|
||||
@@ -308,7 +311,7 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
||||
|
||||
const int slot = strtoul(scalar.c_str(), NULL, 10); // NB. aux slot supported as a different "unit"
|
||||
// NB. slot-0 only supported for Apple II or II+ (or similar clones)
|
||||
if (slot < 0 || slot > 7)
|
||||
if (slot < SLOT0 || slot > SLOT7)
|
||||
throw std::string("Slots: Invalid slot #: ") + scalar;
|
||||
|
||||
yamlLoadHelper.GetSubMap(scalar);
|
||||
@@ -324,8 +327,9 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
||||
|
||||
if (card == Printer_GetSnapshotCardName())
|
||||
{
|
||||
bRes = Printer_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
type = CT_GenericPrinter;
|
||||
GetCardMgr().Insert(slot, type);
|
||||
bRes = Printer_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == CSuperSerialCard::GetSnapshotCardName())
|
||||
{
|
||||
@@ -341,18 +345,21 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
||||
}
|
||||
else if (card == Z80_GetSnapshotCardName())
|
||||
{
|
||||
bRes = Z80_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
type = CT_Z80;
|
||||
GetCardMgr().Insert(slot, type);
|
||||
bRes = Z80_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == MB_GetSnapshotCardName())
|
||||
{
|
||||
bRes = MB_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
type = CT_MockingboardC;
|
||||
GetCardMgr().Insert(slot, type);
|
||||
bRes = MB_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == Phasor_GetSnapshotCardName())
|
||||
{
|
||||
bRes = Phasor_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
type = CT_Phasor;
|
||||
GetCardMgr().Insert(slot, type);
|
||||
bRes = Phasor_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == Disk2InterfaceCard::GetSnapshotCardName())
|
||||
{
|
||||
@@ -362,21 +369,21 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
||||
}
|
||||
else if (card == HD_GetSnapshotCardName())
|
||||
{
|
||||
bRes = HD_LoadSnapshot(yamlLoadHelper, slot, cardVersion, g_strSaveStatePath);
|
||||
m_ConfigNew.m_bEnableHDD = true;
|
||||
type = CT_GenericHDD;
|
||||
GetCardMgr().Insert(slot, type);
|
||||
bRes = HD_LoadSnapshot(yamlLoadHelper, slot, cardVersion, g_strSaveStatePath);
|
||||
}
|
||||
else if (card == LanguageCardSlot0::GetSnapshotCardName())
|
||||
{
|
||||
type = CT_LanguageCard;
|
||||
SetExpansionMemType(type);
|
||||
SetExpansionMemType(type); // calls GetCardMgr().Insert() & InsertAux()
|
||||
CreateLanguageCard();
|
||||
bRes = GetLanguageCard()->LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == Saturn128K::GetSnapshotCardName())
|
||||
{
|
||||
type = CT_Saturn128K;
|
||||
SetExpansionMemType(type);
|
||||
SetExpansionMemType(type); // calls GetCardMgr().Insert() & InsertAux()
|
||||
CreateLanguageCard();
|
||||
bRes = GetLanguageCard()->LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
@@ -397,14 +404,19 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
||||
throw std::string("Slots: Unknown card: " + card); // todo: don't throw - just ignore & continue
|
||||
}
|
||||
|
||||
if (bRes)
|
||||
{
|
||||
m_ConfigNew.m_Slot[slot] = type;
|
||||
}
|
||||
cardInserted[slot] = true;
|
||||
|
||||
yamlLoadHelper.PopMap();
|
||||
yamlLoadHelper.PopMap();
|
||||
}
|
||||
|
||||
// Save-state may not contain any info about empty slots, so ensure they are set to empty
|
||||
for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++)
|
||||
{
|
||||
if (cardInserted[slot])
|
||||
continue;
|
||||
GetCardMgr().Remove(slot);
|
||||
}
|
||||
}
|
||||
|
||||
//---
|
||||
@@ -466,44 +478,17 @@ static void Snapshot_LoadState_v2(void)
|
||||
|
||||
restart = true;
|
||||
|
||||
CConfigNeedingRestart ConfigOld;
|
||||
//ConfigOld.m_Slot[0] = CT_LanguageCard; // fixme: II/II+=LC, //e=empty
|
||||
ConfigOld.m_Slot[1] = CT_GenericPrinter; // fixme
|
||||
ConfigOld.m_Slot[2] = CT_SSC; // fixme
|
||||
//ConfigOld.m_Slot[3] = CT_Uthernet; // todo
|
||||
ConfigOld.m_Slot[6] = CT_Disk2; // fixme
|
||||
ConfigOld.m_Slot[7] = ConfigOld.m_bEnableHDD ? CT_GenericHDD : CT_Empty; // fixme
|
||||
//ConfigOld.m_SlotAux = ?; // fixme
|
||||
|
||||
for (UINT i=0; i<NUM_SLOTS; i++)
|
||||
m_ConfigNew.m_Slot[i] = CT_Empty;
|
||||
m_ConfigNew.m_SlotAux = CT_Empty;
|
||||
m_ConfigNew.m_bEnableHDD = false;
|
||||
//m_ConfigNew.m_bEnableTheFreezesF8Rom = ?; // todo: when support saving config
|
||||
|
||||
for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++)
|
||||
GetCardMgr().Remove(slot);
|
||||
GetCardMgr().RemoveAux();
|
||||
|
||||
MemReset(); // Also calls CpuInitialize()
|
||||
GetPravets().Reset();
|
||||
|
||||
if (GetCardMgr().IsSSCInstalled())
|
||||
{
|
||||
GetCardMgr().GetSSC()->CommReset();
|
||||
}
|
||||
else
|
||||
{
|
||||
_ASSERT(GetCardMgr().QuerySlot(SLOT2) == CT_Empty);
|
||||
ConfigOld.m_Slot[2] = CT_Empty;
|
||||
}
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT4) == CT_MouseInterface)
|
||||
GetCardMgr().Remove(SLOT4); // Remove Mouse card from slot-4
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2)
|
||||
GetCardMgr().Remove(SLOT5); // Remove Disk2 card from slot-5
|
||||
|
||||
GetCardMgr().GetDisk2CardMgr().Reset(false);
|
||||
|
||||
HD_Reset();
|
||||
HD_SetEnabled(false);
|
||||
HD_SetEnabled(false); // Set disabled & also removes card from slot 7
|
||||
|
||||
KeybReset();
|
||||
GetVideo().VideoResetState();
|
||||
@@ -530,7 +515,7 @@ static void Snapshot_LoadState_v2(void)
|
||||
// . A change in h/w via loading a save-state avoids this VM restart
|
||||
// The latter is the desired approach (as the former needs a "power-on" / F2 to start things again)
|
||||
|
||||
GetPropertySheet().ApplyNewConfig(m_ConfigNew, ConfigOld); // Mainly just saves (some) new state to Registry
|
||||
GetPropertySheet().ApplyNewConfigFromSnapshot(m_ConfigNew); // Saves new state to Registry (not slot/cards though)
|
||||
|
||||
MemInitializeROM();
|
||||
MemInitializeCustomROM();
|
||||
|
||||
Reference in New Issue
Block a user