mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-10-24 23:02:25 +00:00
152 lines
4.3 KiB
C++
152 lines
4.3 KiB
C++
#pragma once
|
|
|
|
#include "Card.h"
|
|
|
|
//
|
|
// Language Card (base unit) for Apple //e and above
|
|
//
|
|
|
|
class LanguageCardUnit : public Card
|
|
{
|
|
public:
|
|
// in modern C++ this could be a 2nd constructor
|
|
static LanguageCardUnit * create(UINT slot);
|
|
|
|
virtual ~LanguageCardUnit();
|
|
|
|
virtual void Destroy() {}
|
|
virtual void Reset(const bool powerCycle);
|
|
virtual void Update(const ULONG nExecutedCycles) {}
|
|
|
|
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
|
|
virtual UINT GetActiveBank() { return 0; } // Always 0 as only 1x 16K bank
|
|
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper) { } // A no-op for //e - called from CardManager::SaveSnapshot()
|
|
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version) { _ASSERT(0); return false; } // Not used for //e
|
|
|
|
virtual void SetMainMemLanguageCardMemory();
|
|
|
|
bool GetLastRamWrite() const { return m_bLastRamWrite; }
|
|
void SetLastRamWrite(bool bLastRamWrite) { m_bLastRamWrite = bLastRamWrite; }
|
|
UINT GetLCMemMode() const { return m_memMode; }
|
|
void SetLCMemMode(UINT memMode) { m_memMode = memMode; }
|
|
SS_CARDTYPE GetMemoryType() { return QueryType(); }
|
|
bool IsOpcodeRMWabs(WORD addr);
|
|
uint8_t ReadByte(uint16_t phyAddr);
|
|
|
|
static BYTE __stdcall IO(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
|
|
|
|
static const UINT kMemModeInitialState;
|
|
static const UINT kSlot0 = SLOT0;
|
|
|
|
protected:
|
|
LanguageCardUnit(SS_CARDTYPE type, UINT slot);
|
|
|
|
LPBYTE m_pMemory;
|
|
|
|
private:
|
|
bool m_bLastRamWrite;
|
|
UINT m_memMode;
|
|
};
|
|
|
|
//
|
|
// Language Card (slot-0) for Apple II or II+
|
|
//
|
|
|
|
class LanguageCardSlot0 : public LanguageCardUnit
|
|
{
|
|
public:
|
|
// in modern C++ this could be a 2nd constructor
|
|
static LanguageCardSlot0 * create(UINT slot);
|
|
|
|
virtual ~LanguageCardSlot0();
|
|
|
|
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);
|
|
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version);
|
|
|
|
static const UINT kMemBankSize = 16*1024;
|
|
static const std::string& GetSnapshotCardName();
|
|
|
|
protected:
|
|
LanguageCardSlot0(SS_CARDTYPE type, UINT slot);
|
|
void SaveLCState(class YamlSaveHelper& yamlSaveHelper);
|
|
void LoadLCState(class YamlLoadHelper& yamlLoadHelper);
|
|
|
|
private:
|
|
const std::string& GetSnapshotMemStructName();
|
|
};
|
|
|
|
//
|
|
// Saturn 128K
|
|
//
|
|
|
|
class Saturn128K : public LanguageCardSlot0
|
|
{
|
|
public:
|
|
Saturn128K(UINT slot, UINT banks);
|
|
virtual ~Saturn128K();
|
|
|
|
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
|
|
virtual UINT GetActiveBank();
|
|
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);
|
|
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version);
|
|
|
|
virtual void SetMainMemLanguageCardMemory();
|
|
|
|
void SetMemMainLanguageCard();
|
|
uint8_t ReadByteFromBank(uint8_t bank, uint16_t phyAddr);
|
|
uint8_t GetSaturnMemorySize();
|
|
void SetSaturnMemorySize(uint8_t banks);
|
|
|
|
static uint8_t GetSaturnMemorySizeSlot0();
|
|
static void SetSaturnMemorySizeSlot0(uint8_t banks);
|
|
|
|
static BYTE __stdcall IO(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
|
|
|
|
// "The boards consist of 16K banks of memory (4 banks for the 64K board, 8 banks for the 128K), accessed one at a time" - Ref: "64K/128K RAM BOARD", Saturn Systems, Ch.1 Introduction(pg-5)
|
|
static const UINT kMaxSaturnBanks = 8; // 8 * 16K = 128K
|
|
static const std::string& GetSnapshotCardName();
|
|
|
|
private:
|
|
const std::string& GetSnapshotMemStructName();
|
|
|
|
static UINT g_uSaturnBanksFromCmdLine;
|
|
|
|
UINT m_uSaturnTotalBanks; // Will be > 0 if Saturn card is installed
|
|
UINT m_uSaturnActiveBank; // Saturn 128K Language Card Bank 0 .. 7
|
|
LPBYTE m_aSaturnBanks[kMaxSaturnBanks];
|
|
};
|
|
|
|
//
|
|
// Language Card manager
|
|
//
|
|
|
|
class LanguageCardManager
|
|
{
|
|
public:
|
|
LanguageCardManager() :
|
|
m_pLanguageCard(NULL),
|
|
m_lastSlotToSetMainMemLC(SLOT0),
|
|
m_lastSlotToSetMainMemLCFromSnapshot(SLOT0)
|
|
{}
|
|
~LanguageCardManager() {}
|
|
|
|
void Reset(const bool powerCycle = false);
|
|
|
|
UINT GetLastSlotToSetMainMemLC() { return m_lastSlotToSetMainMemLC; }
|
|
void SetLastSlotToSetMainMemLC(UINT slot) { m_lastSlotToSetMainMemLC = slot; }
|
|
void SetLastSlotToSetMainMemLCFromSnapshot(UINT slot) { m_lastSlotToSetMainMemLCFromSnapshot = slot; }
|
|
|
|
LanguageCardUnit* GetLanguageCard() { return m_pLanguageCard; }
|
|
bool SetLanguageCard(SS_CARDTYPE type);
|
|
|
|
void SetMemMode(const uint8_t slot);
|
|
void SetMemModeFromSnapshot();
|
|
|
|
uint8_t ReadByte(uint8_t slot, uint8_t bank, uint16_t phyAddr);
|
|
|
|
private:
|
|
LanguageCardUnit* m_pLanguageCard;
|
|
UINT m_lastSlotToSetMainMemLC;
|
|
UINT m_lastSlotToSetMainMemLCFromSnapshot;
|
|
};
|