mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-20 15:17:50 +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:
+29
-15
@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
#include "CardManager.h"
|
||||
#include "Core.h"
|
||||
#include "Registry.h"
|
||||
|
||||
#include "Disk.h"
|
||||
#include "FourPlay.h"
|
||||
@@ -38,15 +39,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "SerialComms.h"
|
||||
#include "SNESMAX.h"
|
||||
|
||||
void CardManager::Insert(UINT slot, SS_CARDTYPE type)
|
||||
void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
|
||||
{
|
||||
if (type == CT_Empty)
|
||||
return Remove(slot);
|
||||
|
||||
RemoveInternal(slot);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CT_Empty:
|
||||
m_slot[slot] = new EmptyCard;
|
||||
break;
|
||||
case CT_Disk2:
|
||||
m_slot[slot] = new Disk2InterfaceCard(slot);
|
||||
break;
|
||||
@@ -113,16 +114,23 @@ void CardManager::Insert(UINT slot, SS_CARDTYPE type)
|
||||
}
|
||||
|
||||
if (m_slot[slot] == NULL)
|
||||
m_slot[slot] = new EmptyCard;
|
||||
Remove(slot); // creates a new EmptyCard
|
||||
}
|
||||
|
||||
void CardManager::Insert(UINT slot, SS_CARDTYPE type, bool updateRegistry/*=true*/)
|
||||
{
|
||||
InsertInternal(slot, type);
|
||||
if (updateRegistry)
|
||||
RegSetConfigSlotNewCardType(slot, type);
|
||||
}
|
||||
|
||||
void CardManager::RemoveInternal(UINT slot)
|
||||
{
|
||||
if (m_slot[slot] && m_slot[slot]->QueryType() == CT_MouseInterface)
|
||||
m_pMouseCard = NULL;
|
||||
m_pMouseCard = NULL; // NB. object deleted below: delete m_slot[slot]
|
||||
|
||||
if (m_slot[slot] && m_slot[slot]->QueryType() == CT_SSC)
|
||||
m_pSSC = NULL;
|
||||
m_pSSC = NULL; // NB. object deleted below: delete m_slot[slot]
|
||||
|
||||
delete m_slot[slot];
|
||||
m_slot[slot] = NULL;
|
||||
@@ -130,19 +138,18 @@ void CardManager::RemoveInternal(UINT slot)
|
||||
|
||||
void CardManager::Remove(UINT slot)
|
||||
{
|
||||
RemoveInternal(slot);
|
||||
m_slot[slot] = new EmptyCard;
|
||||
Insert(slot, CT_Empty);
|
||||
}
|
||||
|
||||
void CardManager::InsertAux(SS_CARDTYPE type)
|
||||
void CardManager::InsertAuxInternal(SS_CARDTYPE type)
|
||||
{
|
||||
if (type == CT_Empty)
|
||||
return RemoveAux();
|
||||
|
||||
RemoveAuxInternal();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CT_Empty:
|
||||
m_aux = new EmptyCard;
|
||||
break;
|
||||
case CT_80Col:
|
||||
m_aux = new DummyCard(type);
|
||||
break;
|
||||
@@ -159,6 +166,14 @@ void CardManager::InsertAux(SS_CARDTYPE type)
|
||||
|
||||
// for consistency m_aux must never be NULL
|
||||
_ASSERT(m_aux != NULL);
|
||||
if (m_aux == NULL)
|
||||
RemoveAux(); // creates a new EmptyCard
|
||||
}
|
||||
|
||||
void CardManager::InsertAux(SS_CARDTYPE type)
|
||||
{
|
||||
InsertAuxInternal(type);
|
||||
RegSetConfigSlotNewCardType(SLOT_AUX, type);
|
||||
}
|
||||
|
||||
void CardManager::RemoveAuxInternal()
|
||||
@@ -169,6 +184,5 @@ void CardManager::RemoveAuxInternal()
|
||||
|
||||
void CardManager::RemoveAux(void)
|
||||
{
|
||||
RemoveAuxInternal();
|
||||
m_aux = new EmptyCard;
|
||||
InsertAux(CT_Empty);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user