Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Andrea Odetti 2022-03-12 14:15:48 +00:00
commit de2071476e
24 changed files with 74 additions and 119 deletions

View file

@ -39,7 +39,7 @@ public:
virtual ~Card(void) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral) = 0;
virtual void Init(void) = 0;
virtual void Destroy() = 0;
virtual void Reset(const bool powerCycle) = 0;
virtual void Update(const ULONG nExecutedCycles) = 0;
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper) = 0;
@ -74,7 +74,7 @@ public:
virtual ~EmptyCard(void) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral) {}
virtual void Init(void) {}
virtual void Destroy() {}
virtual void Reset(const bool powerCycle) {}
virtual void Update(const ULONG nExecutedCycles) {}
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper) {}
@ -90,7 +90,7 @@ public:
virtual ~DummyCard(void) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
virtual void Init(void) {}
virtual void Destroy() {}
virtual void Reset(const bool powerCycle) {}
virtual void Update(const ULONG nExecutedCycles);
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);

View file

@ -251,3 +251,25 @@ void CardManager::SaveSnapshot(YamlSaveHelper& yamlSaveHelper)
}
}
}
void CardManager::Reset(const bool powerCycle)
{
for (UINT i = SLOT0; i < NUM_SLOTS; ++i)
{
if (m_slot[i])
{
m_slot[i]->Reset(powerCycle);
}
}
}
void CardManager::Destroy()
{
for (UINT i = SLOT0; i < NUM_SLOTS; ++i)
{
if (m_slot[i])
{
m_slot[i]->Destroy();
}
}
}

View file

@ -58,6 +58,8 @@ public:
class LanguageCardUnit* GetLanguageCard(void) { return m_pLanguageCard; }
void InitializeIO(LPBYTE pCxRomPeripheral);
void Reset(const bool powerCycle);
void Destroy();
void Update(const ULONG nExecutedCycles);
void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);

View file

@ -2906,9 +2906,8 @@ Update_t CmdCursorLineUp (int nArgs)
static std::vector<LookAhead_t> aTopCandidates;
LookAhead_t tCandidate;
// if (! aBestTop.capacity() )
aTopCandidates.clear();
aTopCandidates.reserve( MAX_LOOK_AHEAD );
aTopCandidates.erase( aTopCandidates.begin(), aTopCandidates.end() );
WORD nTop = g_nDisasmTopAddress;
WORD iTop = 0;
@ -5317,7 +5316,8 @@ int _SearchMemoryFind(
WORD nAddressEnd )
{
int nFound = 0;
g_vMemorySearchResults.erase( g_vMemorySearchResults.begin(), g_vMemorySearchResults.end() );
g_vMemorySearchResults.clear();
g_vMemorySearchResults.push_back( NO_6502_TARGET );
WORD nAddress;
@ -5614,7 +5614,7 @@ Update_t _CmdMemorySearch (int nArgs, bool bTextIsAscii = true )
// must be numeric .. make sure not too big
if (pArg->nArgLen > 2)
{
vMemorySearchValues.erase( vMemorySearchValues.begin(), vMemorySearchValues.end() );
vMemorySearchValues.clear();
return HelpLastCommand();
}
@ -5661,7 +5661,7 @@ Update_t _CmdMemorySearch (int nArgs, bool bTextIsAscii = true )
}
_SearchMemoryFind( vMemorySearchValues, nAddressStart, nAddressEnd );
vMemorySearchValues.erase( vMemorySearchValues.begin(), vMemorySearchValues.end() );
vMemorySearchValues.clear();
return _SearchMemoryDisplay();
}
@ -7411,7 +7411,7 @@ int FindParam(LPCTSTR pLookupName, Match_e eMatch, int & iParam_, int iParamBegi
//===========================================================================
int FindCommand( LPCTSTR pName, CmdFuncPtr_t & pFunction_, int * iCommand_ )
{
g_vPotentialCommands.erase( g_vPotentialCommands.begin(), g_vPotentialCommands.end() );
g_vPotentialCommands.clear();
int nFound = 0;
int nLen = _tcslen( pName );
@ -7450,7 +7450,7 @@ int FindCommand( LPCTSTR pName, CmdFuncPtr_t & pFunction_, int * iCommand_ )
// *iCommand_ = iCommand;
nFound = 1; // Exact match takes precidence over fuzzy matches
g_vPotentialCommands.erase( g_vPotentialCommands.begin(), g_vPotentialCommands.end() );
g_vPotentialCommands.clear();
break;
}
}
@ -8513,7 +8513,7 @@ static void DebugEnd ()
g_hTraceFile = NULL;
}
g_vMemorySearchResults.erase( g_vMemorySearchResults.begin(), g_vMemorySearchResults.end() );
g_vMemorySearchResults.clear();
g_nAppMode = MODE_RUNNING;

View file

@ -79,7 +79,7 @@ void MemoryTextFile_t::GetLinePointers()
if (! m_bDirty)
return;
m_vLines.erase( m_vLines.begin(), m_vLines.end() );
m_vLines.clear();
char *pBegin = & m_vBuffer[ 0 ];
char *pLast = & m_vBuffer[ m_vBuffer.size()-1 ];

View file

@ -24,8 +24,8 @@
bool Read( const std::string & pFileName );
void Reset()
{
m_vBuffer.erase( m_vBuffer.begin(), m_vBuffer.end() );
m_vLines.erase( m_vLines.begin(), m_vLines.end() );
m_vBuffer.clear();
m_vLines.clear();
}
inline int GetNumLines()

View file

@ -127,13 +127,12 @@ public:
Disk2InterfaceCard(UINT slot);
virtual ~Disk2InterfaceCard(void);
virtual void Init(void) {};
virtual void Reset(const bool powerCycle);
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
virtual void Update(const ULONG nExecutedCycles);
void Destroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown()
virtual void Destroy(void); // no, doesn't "destroy" the disk image. DiskIIManagerShutdown()
void Boot(void);
void FlushCurrentTrack(const int drive);

View file

@ -11,7 +11,7 @@ public:
}
virtual ~FourPlayCard(void) {}
virtual void Init(void) {}
virtual void Destroy(void) {}
virtual void Reset(const bool powerCycle) {}
virtual void Update(const ULONG nExecutedCycles) {}

View file

@ -85,12 +85,11 @@ public:
HarddiskInterfaceCard(UINT slot);
virtual ~HarddiskInterfaceCard(void);
virtual void Init(void) {}
virtual void Reset(const bool powerCycle);
virtual void Update(const ULONG nExecutedCycles) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
void Destroy(void);
virtual void Destroy(void);
const std::string& GetFullName(const int iDrive);
const std::string& HarddiskGetFullPathName(const int iDrive);
void GetFilenameAndPathForSaveState(std::string& filename, std::string& path);

View file

@ -14,7 +14,7 @@ public:
virtual ~LanguageCardUnit(void);
virtual void Init(void) {}
virtual void Destroy(void) {}
virtual void Reset(const bool powerCycle) {}
virtual void Update(const ULONG nExecutedCycles) {}

View file

@ -146,7 +146,7 @@ CMouseInterface::CMouseInterface(UINT slot) :
// Uninitialize();
InitializeROM();
Reset();
Reset(true);
}
CMouseInterface::~CMouseInterface()
@ -193,7 +193,7 @@ void CMouseInterface::Uninitialize()
}
#endif
void CMouseInterface::Reset()
void CMouseInterface::Reset(const bool /* powerCycle */)
{
m_by6821A = 0;
m_by6821B = 0x40; // Set PB6

View file

@ -11,13 +11,12 @@ public:
CMouseInterface(UINT slot);
virtual ~CMouseInterface();
virtual void Init(void) {}
virtual void Reset(const bool powerCycle) {}
virtual void Destroy() {}
virtual void Reset(const bool powerCycle);
virtual void Update(const ULONG nExecutedCycles) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
// void Uninitialize();
void Reset();
UINT GetSlot(void) { return m_slot; }
static BYTE __stdcall IORead(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
static BYTE __stdcall IOWrite(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);

View file

@ -11,7 +11,7 @@ public:
}
virtual ~SAMCard(void) {}
virtual void Init(void) {}
virtual void Destroy(void) {}
virtual void Reset(const bool powerCycle) {}
virtual void Update(const ULONG nExecutedCycles) {}

View file

@ -18,7 +18,7 @@ public:
}
virtual ~SNESMAXCard(void) {}
virtual void Init(void) {}
virtual void Destroy(void) {}
virtual void Reset(const bool powerCycle) {}
virtual void Update(const ULONG nExecutedCycles) {}

View file

@ -126,6 +126,10 @@ void CSuperSerialCard::InternalReset()
CSuperSerialCard::~CSuperSerialCard()
{
CloseComm();
delete [] m_pExpansionRom;
m_pExpansionRom = NULL;
}
//===========================================================================
@ -959,19 +963,15 @@ void CSuperSerialCard::InitializeIO(LPBYTE pCxRomPeripheral)
if (m_pExpansionRom == NULL)
{
m_pExpansionRom = new BYTE [SSC_FW_SIZE];
if (m_pExpansionRom)
memcpy(m_pExpansionRom, pData, SSC_FW_SIZE);
}
//
RegisterIoHandler(m_slot, &CSuperSerialCard::SSC_IORead, &CSuperSerialCard::SSC_IOWrite, NULL, NULL, this, m_pExpansionRom);
}
//===========================================================================
void CSuperSerialCard::CommReset()
void CSuperSerialCard::Reset(const bool /* powerCycle */)
{
CloseComm();
@ -980,16 +980,6 @@ void CSuperSerialCard::CommReset()
//===========================================================================
void CSuperSerialCard::CommDestroy()
{
CommReset();
delete [] m_pExpansionRom;
m_pExpansionRom = NULL;
}
//===========================================================================
// dwNewSerialPortItem is the drop-down list item
void CSuperSerialCard::CommSetSerialPort(DWORD dwNewSerialPortItem)
{

View file

@ -27,19 +27,16 @@ class CSuperSerialCard : public Card
public:
CSuperSerialCard(UINT slot);
virtual ~CSuperSerialCard();
virtual void Init(void) {}
virtual void Reset(const bool powerCycle) {}
virtual void Update(const ULONG nExecutedCycles) {}
void InitializeIO(LPBYTE pCxRomPeripheral);
void CommReset();
void CommDestroy();
void CommSetSerialPort(DWORD dwNewSerialPortItem);
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
virtual void Reset(const bool powerCycle);
virtual void Destroy() {}
static const std::string& GetSnapshotCardName(void);
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version);
void CommSetSerialPort(DWORD dwNewSerialPortItem);
std::string const& GetSerialPortChoices();
DWORD GetSerialPort() { return m_dwSerialPortItem; } // Drop-down list item
const std::string& GetSerialPortName() { return m_currentSerialPortName; }

View file

@ -341,7 +341,7 @@ pcap_t * TfePcapOpenAdapter(const std::string & interface_name)
return NULL;
}
if(g_fh) fprintf(g_fh, "PCAP: Succesfully opened adapter: '%s'\n", TfePcapDevice->name);
if(g_fh) fprintf(g_fh, "PCAP: Successfully opened adapter: '%s'\n", TfePcapDevice->name);
tfe_arch_enumadapter_close();
return TfePcapFP;

View file

@ -188,12 +188,6 @@ Uthernet1::Uthernet1(UINT slot) : Card(CT_Uthernet, slot)
Init();
}
void Uthernet1::InitialiseBackend()
{
Destroy();
networkBackend = GetFrame().CreateNetworkBackend();
}
void Uthernet1::Init(void)
{
// Initialise all state member variables
@ -976,7 +970,9 @@ void Uthernet1::tfe_transmit(
static BYTE __stdcall TfeIoCxxx (WORD programcounter, WORD address, BYTE write, BYTE value, ULONG nCycles)
{
#ifdef _DEBUG
if (!IS_APPLE2)
const UINT slot = (address >> 8) & 0xf;
if (!IS_APPLE2 && slot == SLOT3)
{
// Derived from UTAIIe:5-28
//
@ -1015,18 +1011,13 @@ static BYTE __stdcall TfeIo (WORD programcounter, WORD address, BYTE write, BYTE
void Uthernet1::InitializeIO(LPBYTE pCxRomPeripheral)
{
InitialiseBackend();
networkBackend = GetFrame().CreateNetworkBackend();
if (networkBackend->isValid())
{
RegisterIoHandler(m_slot, TfeIo, TfeIo, TfeIoCxxx, TfeIoCxxx, this, NULL);
}
}
void Uthernet1::Destroy()
{
networkBackend.reset();
}
void Uthernet1::Reset(const bool powerCycle)
{
if (powerCycle)

View file

@ -123,15 +123,13 @@ class Uthernet1 : public Card
public:
Uthernet1(UINT slot);
virtual void Destroy(void) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
virtual void Init(void);
virtual void Reset(const bool powerCycle);
virtual void Update(const ULONG nExecutedCycles);
virtual void SaveSnapshot(YamlSaveHelper& yamlSaveHelper);
virtual bool LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version);
void Destroy();
BYTE tfe_read(WORD ioaddress);
void tfe_store(WORD ioaddress, BYTE byte);
@ -139,7 +137,7 @@ public:
private:
void InitialiseBackend();
void Init();
void tfe_sideeffects_write_pp_on_txframe(WORD ppaddress);
void tfe_sideeffects_write_pp(WORD ppaddress, int oddaddress);

View file

@ -288,11 +288,6 @@ Uthernet2::Uthernet2(UINT slot) : Card(CT_Uthernet2, slot)
Reset(true);
}
void Uthernet2::Destroy()
{
myNetworkBackend.reset();
}
void Uthernet2::setSocketModeRegister(const size_t i, const uint16_t address, const uint8_t value)
{
myMemory[address] = value;
@ -1077,7 +1072,6 @@ void Uthernet2::Reset(const bool powerCycle)
{
// dataAddress is NOT reset, see page 10 of Uthernet II
myDataAddress = 0;
myNetworkBackend.reset();
myNetworkBackend = GetFrame().CreateNetworkBackend();
}
@ -1168,10 +1162,6 @@ void Uthernet2::InitializeIO(LPBYTE pCxRomPeripheral)
RegisterIoHandler(m_slot, u2_C0, u2_C0, nullptr, nullptr, this, nullptr);
}
void Uthernet2::Init()
{
}
void Uthernet2::Update(const ULONG nExecutedCycles)
{
myNetworkBackend->update(nExecutedCycles);

View file

@ -56,10 +56,8 @@ public:
Uthernet2(UINT slot);
void Destroy();
virtual void Destroy(void) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral);
virtual void Init();
virtual void Reset(const bool powerCycle);
virtual void Update(const ULONG nExecutedCycles);
virtual void SaveSnapshot(YamlSaveHelper &yamlSaveHelper);

View file

@ -534,15 +534,9 @@ void GetAppleWindowTitle()
// todo: consolidate CtrlReset() and ResetMachineState()
void ResetMachineState()
{
GetCardMgr().GetDisk2CardMgr().Reset(true);
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
GetCardMgr().GetRef(SLOT7).Reset(true);
if (GetCardMgr().QuerySlot(SLOT3) == CT_VidHD)
GetCardMgr().GetRef(SLOT3).Reset(true);
if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet)
GetCardMgr().GetRef(SLOT3).Reset(true);
if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet2)
GetCardMgr().GetRef(SLOT3).Reset(true);
LogFileOutput("Apple II power-cycle\n");
GetCardMgr().Reset(true);
g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted
MemReset(); // calls CpuInitialize(), CNoSlotClock.Reset()
@ -551,14 +545,10 @@ void ResetMachineState()
dynamic_cast<Disk2InterfaceCard&>(GetCardMgr().GetRef(SLOT6)).Boot();
GetVideo().VideoResetState();
KeybReset();
if (GetCardMgr().IsSSCInstalled())
GetCardMgr().GetSSC()->CommReset();
PrintReset();
JoyReset();
MB_Reset(true);
SpkrReset();
if (GetCardMgr().IsMouseCardInstalled())
GetCardMgr().GetMouseCard()->Reset();
SetActiveCpu(GetMainCpu());
#ifdef USE_SPEECH_API
g_Speech.Reset();
@ -595,21 +585,9 @@ void CtrlReset()
}
GetPravets().Reset();
GetCardMgr().GetDisk2CardMgr().Reset();
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
GetCardMgr().GetRef(SLOT7).Reset(false);
if (GetCardMgr().QuerySlot(SLOT3) == CT_VidHD)
GetCardMgr().GetRef(SLOT3).Reset(false);
if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet)
GetCardMgr().GetRef(SLOT3).Reset(false);
if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet2)
GetCardMgr().GetRef(SLOT3).Reset(false);
GetCardMgr().Reset(false);
KeybReset();
if (GetCardMgr().IsSSCInstalled())
GetCardMgr().GetSSC()->CommReset();
MB_Reset(false);
if (GetCardMgr().IsMouseCardInstalled())
GetCardMgr().GetMouseCard()->Reset(); // Deassert any pending IRQs - GH#514
#ifdef USE_SPEECH_API
g_Speech.Reset();
#endif

View file

@ -19,7 +19,7 @@ public:
}
virtual ~VidHDCard(void) {}
virtual void Init(void) {}
virtual void Destroy(void) {}
virtual void Reset(const bool powerCycle);
virtual void Update(const ULONG nExecutedCycles) {}
virtual void InitializeIO(LPBYTE pCxRomPeripheral);

View file

@ -965,17 +965,9 @@ LRESULT Win32Frame::WndProc(
Snapshot_Shutdown();
DebugDestroy();
if (!g_bRestart) {
GetCardMgr().GetDisk2CardMgr().Destroy();
if (GetCardMgr().QuerySlot(SLOT7) == CT_GenericHDD)
dynamic_cast<HarddiskInterfaceCard&>(GetCardMgr().GetRef(SLOT7)).Destroy();
if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet)
dynamic_cast<Uthernet1&>(GetCardMgr().GetRef(SLOT3)).Destroy();
if (GetCardMgr().QuerySlot(SLOT3) == CT_Uthernet2)
dynamic_cast<Uthernet2&>(GetCardMgr().GetRef(SLOT3)).Destroy();
GetCardMgr().Destroy();
}
PrintDestroy();
if (GetCardMgr().IsSSCInstalled())
GetCardMgr().GetSSC()->CommDestroy();
CpuDestroy();
MemDestroy();
SpkrDestroy();