mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-14 08:29:34 +00:00
Refactor Z80Card as a class
This commit is contained in:
parent
3abf0c1753
commit
f73f23c1c7
|
@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#include "SerialComms.h"
|
#include "SerialComms.h"
|
||||||
#include "SNESMAX.h"
|
#include "SNESMAX.h"
|
||||||
#include "VidHD.h"
|
#include "VidHD.h"
|
||||||
|
#include "z80emu.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -70,10 +71,7 @@ void DummyCard::InitializeIO(LPBYTE pCxRomPeripheral)
|
||||||
switch (QueryType())
|
switch (QueryType())
|
||||||
{
|
{
|
||||||
case CT_GenericClock:
|
case CT_GenericClock:
|
||||||
break; // nothing to do
|
case CT_Echo:
|
||||||
case CT_Z80:
|
|
||||||
Z80_InitializeIO(pCxRomPeripheral, m_slot);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
_ASSERT(0);
|
_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -83,8 +81,8 @@ void DummyCard::Update(const ULONG nExecutedCycles)
|
||||||
{
|
{
|
||||||
switch (QueryType())
|
switch (QueryType())
|
||||||
{
|
{
|
||||||
case CT_Z80:
|
case CT_GenericClock:
|
||||||
break; // nothing to do
|
case CT_Echo:
|
||||||
default:
|
default:
|
||||||
_ASSERT(0);
|
_ASSERT(0);
|
||||||
break;
|
break;
|
||||||
|
@ -95,8 +93,8 @@ void DummyCard::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
||||||
{
|
{
|
||||||
switch (QueryType())
|
switch (QueryType())
|
||||||
{
|
{
|
||||||
case CT_Z80:
|
case CT_GenericClock:
|
||||||
Z80_SaveSnapshot(yamlSaveHelper, m_slot);
|
case CT_Echo:
|
||||||
default:
|
default:
|
||||||
_ASSERT(0);
|
_ASSERT(0);
|
||||||
break;
|
break;
|
||||||
|
@ -107,8 +105,8 @@ bool DummyCard::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version)
|
||||||
{
|
{
|
||||||
switch (QueryType())
|
switch (QueryType())
|
||||||
{
|
{
|
||||||
case CT_Z80:
|
case CT_GenericClock:
|
||||||
return Z80_LoadSnapshot(yamlLoadHelper, m_slot, version);
|
case CT_Echo:
|
||||||
default:
|
default:
|
||||||
_ASSERT(0);
|
_ASSERT(0);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +143,7 @@ std::string Card::GetCardName(const SS_CARDTYPE cardType)
|
||||||
case CT_MouseInterface:
|
case CT_MouseInterface:
|
||||||
return CMouseInterface::GetSnapshotCardName();
|
return CMouseInterface::GetSnapshotCardName();
|
||||||
case CT_Z80:
|
case CT_Z80:
|
||||||
return Z80_GetSnapshotCardName();
|
return Z80Card::GetSnapshotCardName();
|
||||||
case CT_Phasor:
|
case CT_Phasor:
|
||||||
return MockingboardCard::GetSnapshotCardNamePhasor();
|
return MockingboardCard::GetSnapshotCardNamePhasor();
|
||||||
case CT_Echo:
|
case CT_Echo:
|
||||||
|
@ -181,7 +179,7 @@ SS_CARDTYPE Card::GetCardType(const std::string & card)
|
||||||
{
|
{
|
||||||
return CT_MouseInterface;
|
return CT_MouseInterface;
|
||||||
}
|
}
|
||||||
else if (card == Z80_GetSnapshotCardName())
|
else if (card == Z80Card::GetSnapshotCardName())
|
||||||
{
|
{
|
||||||
return CT_Z80;
|
return CT_Z80;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#include "VidHD.h"
|
#include "VidHD.h"
|
||||||
#include "LanguageCard.h"
|
#include "LanguageCard.h"
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
|
#include "z80emu.h"
|
||||||
|
|
||||||
void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
|
void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
|
||||||
{
|
{
|
||||||
|
@ -85,7 +86,9 @@ void CardManager::InsertInternal(UINT slot, SS_CARDTYPE type)
|
||||||
m_slot[slot] = m_pMouseCard = new CMouseInterface(slot);
|
m_slot[slot] = m_pMouseCard = new CMouseInterface(slot);
|
||||||
break;
|
break;
|
||||||
case CT_Z80:
|
case CT_Z80:
|
||||||
m_slot[slot] = new DummyCard(type, slot);
|
_ASSERT(m_pZ80Card == NULL);
|
||||||
|
if (m_pZ80Card) break; // Only support one Z80 card
|
||||||
|
m_slot[slot] = new Z80Card(slot);
|
||||||
break;
|
break;
|
||||||
case CT_Phasor:
|
case CT_Phasor:
|
||||||
m_slot[slot] = new MockingboardCard(slot, type);
|
m_slot[slot] = new MockingboardCard(slot, type);
|
||||||
|
|
|
@ -12,7 +12,8 @@ public:
|
||||||
m_pMouseCard(NULL),
|
m_pMouseCard(NULL),
|
||||||
m_pSSC(NULL),
|
m_pSSC(NULL),
|
||||||
m_pLanguageCard(NULL),
|
m_pLanguageCard(NULL),
|
||||||
m_pParallelPrinterCard(NULL)
|
m_pParallelPrinterCard(NULL),
|
||||||
|
m_pZ80Card(NULL)
|
||||||
{
|
{
|
||||||
InsertInternal(SLOT0, CT_Empty);
|
InsertInternal(SLOT0, CT_Empty);
|
||||||
InsertInternal(SLOT1, CT_GenericPrinter);
|
InsertInternal(SLOT1, CT_GenericPrinter);
|
||||||
|
@ -82,4 +83,5 @@ private:
|
||||||
class CSuperSerialCard* m_pSSC;
|
class CSuperSerialCard* m_pSSC;
|
||||||
class LanguageCardUnit* m_pLanguageCard;
|
class LanguageCardUnit* m_pLanguageCard;
|
||||||
class ParallelPrinterCard* m_pParallelPrinterCard;
|
class ParallelPrinterCard* m_pParallelPrinterCard;
|
||||||
|
class m_pZ80Card* m_pZ80Card;
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,5 +43,8 @@ DWORD z80_mainloop(ULONG uTotalCycles, ULONG uExecutedCycles);
|
||||||
BYTE z80_RDMEM(WORD Addr);
|
BYTE z80_RDMEM(WORD Addr);
|
||||||
void z80_WRMEM(WORD Addr, BYTE Value);
|
void z80_WRMEM(WORD Addr, BYTE Value);
|
||||||
|
|
||||||
#endif
|
const std::string& Z80_GetSnapshotCardName(void);
|
||||||
|
void Z80_SaveSnapshot(class YamlSaveHelper& yamlSaveHelper, const UINT uSlot);
|
||||||
|
bool Z80_LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT uSlot, UINT version);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -18,30 +18,39 @@
|
||||||
#include "z80emu.h"
|
#include "z80emu.h"
|
||||||
#include "CPU.h"
|
#include "CPU.h"
|
||||||
#include "Memory.h"
|
#include "Memory.h"
|
||||||
|
#include "Z80VICE/z80.h"
|
||||||
|
|
||||||
// Variaveis
|
|
||||||
static int g_uCPMZ80Slot = 0;
|
|
||||||
|
|
||||||
BYTE __stdcall CPMZ80_IONull(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles)
|
BYTE __stdcall Z80Card::IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE value, ULONG nExecutedCycles)
|
||||||
{
|
{
|
||||||
return IO_Null(PC, uAddr, bWrite, uValue, nExecutedCycles);
|
const UINT slot = (addr >> 8) & 0x7;
|
||||||
}
|
|
||||||
|
|
||||||
BYTE __stdcall CPMZ80_IOWrite(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles)
|
if ((addr & 0xFF00) == (0xC000 + (slot << 8)))
|
||||||
{
|
|
||||||
if ((uAddr & 0xFF00) == (0xC000 + (g_uCPMZ80Slot << 8)))
|
|
||||||
SetActiveCpu( GetActiveCpu() == CPU_Z80 ? GetMainCpu() : CPU_Z80 );
|
SetActiveCpu( GetActiveCpu() == CPU_Z80 ? GetMainCpu() : CPU_Z80 );
|
||||||
|
|
||||||
return IO_Null(PC, uAddr, bWrite, uValue, nExecutedCycles);
|
return IO_Null(pc, addr, bWrite, value, nExecutedCycles);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Z80Card::InitializeIO(LPBYTE pCxRomPeripheral)
|
||||||
|
{
|
||||||
|
memset(pCxRomPeripheral + (m_slot << 8), 0xFF, APPLE_SLOT_SIZE);
|
||||||
|
|
||||||
|
RegisterIoHandler(m_slot, IO_Null, IO_Null, IO_Null, &Z80Card::IOWrite, this, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
void Z80_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot)
|
const std::string& Z80Card::GetSnapshotCardName(void)
|
||||||
{
|
{
|
||||||
memset(pCxRomPeripheral + (uSlot << 8), 0xFF, APPLE_SLOT_SIZE);
|
return Z80_GetSnapshotCardName();
|
||||||
|
}
|
||||||
g_uCPMZ80Slot = uSlot;
|
|
||||||
|
void Z80Card::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
||||||
RegisterIoHandler(uSlot, CPMZ80_IONull, CPMZ80_IONull, CPMZ80_IONull, CPMZ80_IOWrite, NULL, NULL);
|
{
|
||||||
|
return Z80_SaveSnapshot(yamlSaveHelper, m_slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Z80Card::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version)
|
||||||
|
{
|
||||||
|
return Z80_LoadSnapshot(yamlLoadHelper, m_slot, version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/* Emulador do computador TK3000 //e (Microdigital)
|
#include "Card.h"
|
||||||
* por Fábio Belavenuto - Copyright (C) 2004
|
|
||||||
*
|
|
||||||
* Adaptado do emulador Applewin por Michael O'Brien
|
|
||||||
*
|
|
||||||
* Este arquivo é distribuido pela Licença Pública Geral GNU.
|
|
||||||
* Veja o arquivo Licenca.txt distribuido com este software.
|
|
||||||
*
|
|
||||||
* ESTE SOFTWARE NÃO OFERECE NENHUMA GARANTIA
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Emula a CPU Z80
|
class Z80Card : public Card
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Z80Card(UINT slot) :
|
||||||
|
Card(CT_Z80, slot)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~Z80Card(void) {}
|
||||||
|
|
||||||
// Protótipos
|
virtual void Destroy(void) {}
|
||||||
void Z80_InitializeIO(LPBYTE pCxRomPeripheral, UINT uSlot);
|
virtual void Reset(const bool powerCycle) {}
|
||||||
|
virtual void Update(const ULONG nExecutedCycles) {}
|
||||||
|
|
||||||
// NB. These are in z80.cpp:
|
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
|
||||||
const std::string& Z80_GetSnapshotCardName(void);
|
|
||||||
void Z80_SaveSnapshot(class YamlSaveHelper& yamlSaveHelper, const UINT uSlot);
|
static BYTE __stdcall IOWrite(WORD pc, WORD addr, BYTE bWrite, BYTE value, ULONG nExecutedCycles);
|
||||||
bool Z80_LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT uSlot, UINT version);
|
|
||||||
|
static const std::string& GetSnapshotCardName(void);
|
||||||
|
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);
|
||||||
|
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user