SAM card: refactor as a class, and support save/load state
This commit is contained in:
parent
f85e175328
commit
10a83eed61
6 changed files with 77 additions and 8 deletions
|
@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
#include "Disk.h"
|
||||
#include "FourPlay.h"
|
||||
#include "MouseInterface.h"
|
||||
#include "SAM.h"
|
||||
#include "SerialComms.h"
|
||||
#include "SNESMAX.h"
|
||||
|
||||
|
@ -83,7 +84,7 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
|
|||
m_slot[slot] = new DummyCard(type);
|
||||
break;
|
||||
case CT_SAM:
|
||||
m_slot[slot] = new DummyCard(type);
|
||||
m_slot[slot] = new SAMCard(slot);
|
||||
break;
|
||||
case CT_Uthernet:
|
||||
m_slot[slot] = new DummyCard(type);
|
||||
|
|
|
@ -33,10 +33,16 @@ public:
|
|||
SS_CARDTYPE QuerySlot(UINT slot) { _ASSERT(slot<NUM_SLOTS); return m_slot[slot]->QueryType(); }
|
||||
Card& GetRef(UINT slot)
|
||||
{
|
||||
SS_CARDTYPE t=QuerySlot(slot); _ASSERT((t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX) && m_slot[slot]);
|
||||
SS_CARDTYPE t=QuerySlot(slot);
|
||||
_ASSERT((t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX || t == CT_SAM) && m_slot[slot]);
|
||||
return *m_slot[slot];
|
||||
}
|
||||
Card* GetObj(UINT slot) { SS_CARDTYPE t=QuerySlot(slot); _ASSERT(t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX); return m_slot[slot]; }
|
||||
Card* GetObj(UINT slot)
|
||||
{
|
||||
SS_CARDTYPE t=QuerySlot(slot);
|
||||
_ASSERT(t==CT_SSC || t==CT_MouseInterface || t==CT_Disk2 || t == CT_FourPlay || t == CT_SNESMAX || t == CT_SAM);
|
||||
return m_slot[slot];
|
||||
}
|
||||
|
||||
void InsertAux(SS_CARDTYPE type);
|
||||
void RemoveAux(void);
|
||||
|
|
|
@ -1771,7 +1771,7 @@ void MemInitializeIO(void)
|
|||
}
|
||||
else if (GetCardMgr().QuerySlot(SLOT5) == CT_SAM)
|
||||
{
|
||||
ConfigureSAM(pCxRomPeripheral, SLOT5); // $C500 : SAM card
|
||||
dynamic_cast<SAMCard&>(GetCardMgr().GetRef(SLOT5)).InitializeIO(pCxRomPeripheral, SLOT5);
|
||||
}
|
||||
else if (GetCardMgr().QuerySlot(SLOT5) == CT_FourPlay)
|
||||
{
|
||||
|
|
|
@ -35,13 +35,14 @@
|
|||
#include "SAM.h"
|
||||
#include "Memory.h"
|
||||
#include "Speaker.h"
|
||||
#include "YamlHelper.h"
|
||||
|
||||
//
|
||||
// Write 8 bit data to speaker. Emulates a "SAM" speech card DAC
|
||||
//
|
||||
|
||||
|
||||
static BYTE __stdcall IOWrite_SAM(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles)
|
||||
BYTE __stdcall SAMCard::IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG nExecutedCycles)
|
||||
{
|
||||
// Emulate audio from a SAM / 8 bit DAC card
|
||||
// Only supportable if AppleWin is using WAVE output
|
||||
|
@ -86,7 +87,33 @@ static BYTE __stdcall IOWrite_SAM(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG
|
|||
return res;
|
||||
}
|
||||
|
||||
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot)
|
||||
void SAMCard::InitializeIO(LPBYTE pCxRomPeripheral, UINT slot)
|
||||
{
|
||||
RegisterIoHandler(uSlot, IO_Null, IOWrite_SAM, IO_Null, IO_Null, NULL, NULL);
|
||||
RegisterIoHandler(slot, IO_Null, IOWrite, IO_Null, IO_Null, NULL, NULL);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
static const UINT kUNIT_VERSION = 1;
|
||||
|
||||
std::string SAMCard::GetSnapshotCardName(void)
|
||||
{
|
||||
static const std::string name("SAM");
|
||||
return name;
|
||||
}
|
||||
|
||||
void SAMCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
||||
{
|
||||
YamlSaveHelper::Slot slot(yamlSaveHelper, GetSnapshotCardName(), m_slot, kUNIT_VERSION);
|
||||
|
||||
YamlSaveHelper::Label unit(yamlSaveHelper, "%s: null\n", SS_YAML_KEY_STATE);
|
||||
// NB. No state for this card
|
||||
}
|
||||
|
||||
bool SAMCard::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version)
|
||||
{
|
||||
if (version < 1 || version > kUNIT_VERSION)
|
||||
throw std::string("Card: wrong version");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
27
source/SAM.h
27
source/SAM.h
|
@ -1,3 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
void ConfigureSAM(LPBYTE pCxRomPeripheral, UINT uSlot);
|
||||
#include "Card.h"
|
||||
|
||||
class SAMCard : public Card
|
||||
{
|
||||
public:
|
||||
SAMCard(UINT slot) :
|
||||
Card(CT_SAM),
|
||||
m_slot(slot)
|
||||
{
|
||||
}
|
||||
virtual ~SAMCard(void) {}
|
||||
|
||||
virtual void Init(void) {};
|
||||
virtual void Reset(const bool powerCycle) {};
|
||||
|
||||
void InitializeIO(LPBYTE pCxRomPeripheral, UINT slot);
|
||||
|
||||
static BYTE __stdcall IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE value, ULONG nExecutedCycles);
|
||||
|
||||
static std::string GetSnapshotCardName(void);
|
||||
void SaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
||||
bool LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version);
|
||||
|
||||
private:
|
||||
UINT m_slot;
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
#include "MouseInterface.h"
|
||||
#include "ParallelPrinter.h"
|
||||
#include "Pravets.h"
|
||||
#include "SAM.h"
|
||||
#include "SerialComms.h"
|
||||
#include "SNESMAX.h"
|
||||
#include "Speaker.h"
|
||||
|
@ -361,6 +362,12 @@ static void ParseSlots(YamlLoadHelper& yamlLoadHelper, UINT unitVersion)
|
|||
GetCardMgr().Insert(slot, type);
|
||||
bRes = Phasor_LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == SAMCard::GetSnapshotCardName())
|
||||
{
|
||||
type = CT_SAM;
|
||||
GetCardMgr().Insert(slot, type);
|
||||
bRes = dynamic_cast<SAMCard&>(GetCardMgr().GetRef(slot)).LoadSnapshot(yamlLoadHelper, slot, cardVersion);
|
||||
}
|
||||
else if (card == Disk2InterfaceCard::GetSnapshotCardName())
|
||||
{
|
||||
type = CT_Disk2;
|
||||
|
@ -626,6 +633,9 @@ void Snapshot_SaveState(void)
|
|||
if (GetCardMgr().QuerySlot(SLOT4) == CT_Phasor)
|
||||
Phasor_SaveSnapshot(yamlSaveHelper, SLOT4);
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT5) == CT_SAM)
|
||||
dynamic_cast<SAMCard&>(GetCardMgr().GetRef(SLOT5)).SaveSnapshot(yamlSaveHelper);
|
||||
|
||||
if (GetCardMgr().QuerySlot(SLOT5) == CT_Disk2)
|
||||
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT5)).SaveSnapshot(yamlSaveHelper);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue