2018-10-26 18:23:30 +00:00
# pragma once
2019-12-19 19:42:30 +00:00
# include "Card.h"
2018-10-26 18:23:30 +00:00
//
// Language Card (base unit) for Apple //e and above
//
2019-12-19 19:42:30 +00:00
class LanguageCardUnit : public Card
2018-10-26 18:23:30 +00:00
{
public :
2021-12-11 15:26:09 +00:00
// in modern C++ this could be a 2nd constructor
static LanguageCardUnit * create ( UINT slot ) ;
2018-11-04 15:07:46 +00:00
virtual ~ LanguageCardUnit ( void ) ;
2018-10-26 18:23:30 +00:00
2022-03-11 22:17:03 +00:00
virtual void Destroy ( void ) { }
2024-03-22 21:36:50 +00:00
virtual void Reset ( const bool powerCycle ) ;
2021-11-13 18:13:01 +00:00
virtual void Update ( const ULONG nExecutedCycles ) { }
2021-11-11 21:45:55 +00:00
virtual void InitializeIO ( LPBYTE pCxRomPeripheral ) ;
2018-10-26 18:23:30 +00:00
virtual UINT GetActiveBank ( void ) { return 0 ; } // Always 0 as only 1x 16K bank
2021-12-18 21:31:17 +00:00
virtual void SaveSnapshot ( YamlSaveHelper & yamlSaveHelper ) { } // A no-op for //e - called from CardManager::SaveSnapshot()
2021-11-25 20:23:21 +00:00
virtual bool LoadSnapshot ( YamlLoadHelper & yamlLoadHelper , UINT version ) { _ASSERT ( 0 ) ; return false ; } // Not used for //e
2018-10-26 18:23:30 +00:00
BOOL GetLastRamWrite ( void ) { return m_uLastRamWrite ; }
void SetLastRamWrite ( BOOL count ) { m_uLastRamWrite = count ; }
2024-03-22 21:36:50 +00:00
UINT GetLCMemMode ( void ) { return m_memMode ; }
void SetLCMemMode ( UINT memMode ) { m_memMode = memMode ; }
void SetGlobalLCMemMode ( void ) ;
2019-12-19 19:42:30 +00:00
SS_CARDTYPE GetMemoryType ( void ) { return QueryType ( ) ; }
2019-10-08 21:12:35 +00:00
bool IsOpcodeRMWabs ( WORD addr ) ;
2018-10-26 18:23:30 +00:00
2018-11-09 20:51:51 +00:00
static BYTE __stdcall IO ( WORD PC , WORD uAddr , BYTE bWrite , BYTE uValue , ULONG nExecutedCycles ) ;
2018-10-26 18:23:30 +00:00
static const UINT kMemModeInitialState ;
2021-05-19 20:26:23 +00:00
static const UINT kSlot0 = SLOT0 ;
2018-10-26 18:23:30 +00:00
2021-12-11 15:26:09 +00:00
protected :
LanguageCardUnit ( SS_CARDTYPE type , UINT slot ) ;
2024-03-22 21:36:50 +00:00
LPBYTE m_pMemory ;
2018-10-26 18:23:30 +00:00
private :
UINT m_uLastRamWrite ;
2024-03-22 21:36:50 +00:00
UINT m_memMode ;
2018-10-26 18:23:30 +00:00
} ;
//
// Language Card (slot-0) for Apple II or II+
//
class LanguageCardSlot0 : public LanguageCardUnit
{
public :
2021-12-11 15:26:09 +00:00
// in modern C++ this could be a 2nd constructor
static LanguageCardSlot0 * create ( UINT slot ) ;
2018-10-26 18:23:30 +00:00
virtual ~ LanguageCardSlot0 ( void ) ;
2021-11-25 20:23:21 +00:00
virtual void SaveSnapshot ( YamlSaveHelper & yamlSaveHelper ) ;
virtual bool LoadSnapshot ( YamlLoadHelper & yamlLoadHelper , UINT version ) ;
2018-10-26 18:23:30 +00:00
static const UINT kMemBankSize = 16 * 1024 ;
2022-02-28 20:52:18 +00:00
static const std : : string & GetSnapshotCardName ( void ) ;
2018-10-26 18:23:30 +00:00
protected :
2021-12-11 15:26:09 +00:00
LanguageCardSlot0 ( SS_CARDTYPE type , UINT slot ) ;
2018-10-26 18:23:30 +00:00
void SaveLCState ( class YamlSaveHelper & yamlSaveHelper ) ;
void LoadLCState ( class YamlLoadHelper & yamlLoadHelper ) ;
private :
2022-02-28 20:52:18 +00:00
const std : : string & GetSnapshotMemStructName ( void ) ;
2018-10-26 18:23:30 +00:00
} ;
//
// Saturn 128K
//
class Saturn128K : public LanguageCardSlot0
{
public :
2021-12-11 15:26:09 +00:00
Saturn128K ( UINT slot , UINT banks ) ;
2018-10-26 18:23:30 +00:00
virtual ~ Saturn128K ( void ) ;
2021-11-11 21:45:55 +00:00
virtual void InitializeIO ( LPBYTE pCxRomPeripheral ) ;
2018-10-26 18:23:30 +00:00
virtual UINT GetActiveBank ( void ) ;
2021-11-25 20:23:21 +00:00
virtual void SaveSnapshot ( YamlSaveHelper & yamlSaveHelper ) ;
virtual bool LoadSnapshot ( YamlLoadHelper & yamlLoadHelper , UINT version ) ;
2018-10-26 18:23:30 +00:00
2024-03-22 21:36:50 +00:00
void SetMemMainLanguageCard ( void ) ;
2021-12-11 15:26:09 +00:00
static UINT GetSaturnMemorySize ( ) ;
static void SetSaturnMemorySize ( UINT banks ) ;
2018-11-09 20:51:51 +00:00
static BYTE __stdcall IO ( WORD PC , WORD uAddr , BYTE bWrite , BYTE uValue , ULONG nExecutedCycles ) ;
2018-11-04 15:07:46 +00:00
// "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)
2018-10-26 18:23:30 +00:00
static const UINT kMaxSaturnBanks = 8 ; // 8 * 16K = 128K
2022-02-28 20:52:18 +00:00
static const std : : string & GetSnapshotCardName ( void ) ;
2018-10-26 18:23:30 +00:00
private :
2022-02-28 20:52:18 +00:00
const std : : string & GetSnapshotMemStructName ( void ) ;
2018-10-26 18:23:30 +00:00
2021-12-11 15:26:09 +00:00
static UINT g_uSaturnBanksFromCmdLine ;
2018-10-26 18:23:30 +00:00
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 ] ;
} ;
2024-03-22 21:36:50 +00:00
//
// Language Card manager
//
class LanguageCardManager
{
public :
LanguageCardManager ( void ) :
m_pLanguageCard ( NULL ) ,
m_lastSlotToSetMainMemLC ( SLOT0 ) ,
m_lastSlotToSetMainMemLCFromSnapshot ( SLOT0 )
{ }
~ LanguageCardManager ( void ) { }
void Reset ( const bool powerCycle = false ) ;
UINT GetLastSlotToSetMainMemLC ( void ) { return m_lastSlotToSetMainMemLC ; }
void SetLastSlotToSetMainMemLC ( UINT slot ) { m_lastSlotToSetMainMemLC = slot ; }
void SetLastSlotToSetMainMemLCFromSnapshot ( UINT slot ) { m_lastSlotToSetMainMemLCFromSnapshot = slot ; }
LanguageCardUnit * GetLanguageCard ( void ) { return m_pLanguageCard ; }
bool SetLanguageCard ( SS_CARDTYPE type ) ;
void SetMemModeFromSnapshot ( void ) ;
private :
LanguageCardUnit * m_pLanguageCard ;
UINT m_lastSlotToSetMainMemLC ;
UINT m_lastSlotToSetMainMemLCFromSnapshot ;
} ;