Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Andrea Odetti 2022-03-13 16:43:57 +00:00
commit afc1477332
8 changed files with 32 additions and 43 deletions

View file

@ -160,6 +160,7 @@ void CardManager::RemoveInternal(UINT slot)
break;
}
UnregisterIoHandler(slot);
delete m_slot[slot];
m_slot[slot] = NULL;
}

View file

@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../Windows/AppleWin.h" // g_nAppMode, g_uScrollLockToggle, sg_PropertySheet
#include "../CardManager.h"
#include "../Memory.h"
#include "../Disk.h"
#include "../Log.h"
#include "../Registry.h"
@ -130,6 +131,7 @@ void CPropertySheetHelper::SetSlot(UINT slot, SS_CARDTYPE newCardType)
return;
GetCardMgr().Insert(slot, newCardType);
GetCardMgr().GetRef(slot).InitializeIO(GetCxRomPeripheral());
}
// Used by:

View file

@ -672,8 +672,6 @@ Update_t CmdBookmarkLoad (int nArgs)
//===========================================================================
Update_t CmdBookmarkSave (int nArgs)
{
TCHAR sText[ CONSOLE_WIDTH ];
g_ConfigState.Reset();
ConfigSave_PrepareHeader( PARAM_CAT_BOOKMARKS, CMD_BOOKMARK_CLEAR );
@ -683,12 +681,11 @@ Update_t CmdBookmarkSave (int nArgs)
{
if (g_aBookmarks[ iBookmark ].bSet)
{
sprintf( sText, "%s %x %04X\n"
g_ConfigState.PushLineFormat( "%s %x %04X\n"
, g_aCommands[ CMD_BOOKMARK_ADD ].m_sName
, iBookmark
, g_aBookmarks[ iBookmark ].nAddress
);
g_ConfigState.PushLine( sText );
}
iBookmark++;
}
@ -1768,8 +1765,6 @@ Update_t CmdBreakpointLoad (int nArgs)
//===========================================================================
Update_t CmdBreakpointSave (int nArgs)
{
TCHAR sText[ CONSOLE_WIDTH ];
g_ConfigState.Reset();
ConfigSave_PrepareHeader( PARAM_CAT_BREAKPOINTS, CMD_BREAKPOINT_CLEAR );
@ -1779,21 +1774,19 @@ Update_t CmdBreakpointSave (int nArgs)
{
if (g_aBreakpoints[ iBreakpoint ].bSet)
{
sprintf( sText, "%s %x %04X,%04X\n"
g_ConfigState.PushLineFormat( "%s %x %04X,%04X\n"
, g_aCommands[ CMD_BREAKPOINT_ADD_REG ].m_sName
, iBreakpoint
, g_aBreakpoints[ iBreakpoint ].nAddress
, g_aBreakpoints[ iBreakpoint ].nLength
);
g_ConfigState.PushLine( sText );
}
if (! g_aBreakpoints[ iBreakpoint ].bEnabled)
{
sprintf( sText, "%s %x\n"
g_ConfigState.PushLineFormat( "%s %x\n"
, g_aCommands[ CMD_BREAKPOINT_DISABLE ].m_sName
, iBreakpoint
);
g_ConfigState.PushLine( sText );
}
iBreakpoint++;
@ -2435,20 +2428,16 @@ bool ConfigSave_BufferToDisk ( const char *pFileName, ConfigSave_t eConfigSave )
//===========================================================================
void ConfigSave_PrepareHeader ( const Parameters_e eCategory, const Commands_e eCommandClear )
{
char sText[ CONSOLE_WIDTH ];
sprintf( sText, "%s %s = %s\n"
g_ConfigState.PushLineFormat( "%s %s = %s\n"
, g_aTokens[ TOKEN_COMMENT_EOL ].sToken
, g_aParameters[ PARAM_CATEGORY ].m_sName
, g_aParameters[ eCategory ].m_sName
);
g_ConfigState.PushLine( sText );
sprintf( sText, "%s %s\n"
g_ConfigState.PushLineFormat( "%s %s\n"
, g_aCommands[ eCommandClear ].m_sName
, g_aParameters[ PARAM_WILDSTAR ].m_sName
);
g_ConfigState.PushLine( sText );
}

View file

@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Util_Text.h"
#include "Util_MemoryTextFile.h"
#include "StrFormat.h"
// MemoryTextFile _________________________________________________________________________________
@ -121,9 +122,9 @@ void MemoryTextFile_t::GetLinePointers()
//===========================================================================
void MemoryTextFile_t::PushLine( char *pLine )
void MemoryTextFile_t::PushLine( const char *pLine )
{
char *pSrc = pLine;
const char *pSrc = pLine;
while (pSrc && *pSrc)
{
if (*pSrc == CHAR_CR)
@ -141,4 +142,10 @@ void MemoryTextFile_t::PushLine( char *pLine )
m_bDirty = true;
}
void MemoryTextFile_t::PushLineFormat( const char *pFormat, ... )
{
va_list va;
va_start(va, pFormat);
PushLine(StrFormatV(pFormat, va).c_str());
va_end(va);
}

View file

@ -1,5 +1,7 @@
#pragma once
#include "StrFormat.h"
// Memory Text File _________________________________________________________
class MemoryTextFile_t
@ -43,6 +45,7 @@ inline char *GetLine( const int iLine ) const
void GetLine( const int iLine, char *pLine, const int n );
void PushLine( char *pLine );
void PushLine( const char *pLine );
void PushLineFormat( const char *pFormat, ... ) ATTRIBUTE_FORMAT_PRINTF(2, 3); // 1 is "this"
};

View file

@ -74,10 +74,6 @@ Disk2InterfaceCard::Disk2InterfaceCard(UINT slot) :
ResetLogicStateSequencer();
// if created by user in Config->Disk, then MemInitializeIO() won't be called
if (GetCxRomPeripheral())
InitializeIO(GetCxRomPeripheral()); // During regular start-up, Initialize() will be called later by MemInitializeIO()
// Debug:
#if LOG_DISK_NIBBLES_USE_RUNTIME_VAR
m_bLogDisk_NibblesRW = false;
@ -92,9 +88,6 @@ Disk2InterfaceCard::~Disk2InterfaceCard(void)
{
EjectDiskInternal(DRIVE_1);
EjectDiskInternal(DRIVE_2);
// if destroyed by user in Config->Disk, then ensure that old object's reference is removed
UnregisterIoHandler(m_slot);
}
bool Disk2InterfaceCard::GetEnhanceDisk(void) { return m_enhanceDisk; }

View file

@ -143,19 +143,12 @@ HarddiskInterfaceCard::HarddiskInterfaceCard(UINT slot) :
m_notBusyCycle = 0;
m_saveDiskImage = true; // Save the DiskImage name to Registry
// if created by user in Config->Disk, then MemInitializeIO() won't be called
if (GetCxRomPeripheral())
InitializeIO(GetCxRomPeripheral()); // During regular start-up, Initialize() will be called later by MemInitializeIO()
}
HarddiskInterfaceCard::~HarddiskInterfaceCard(void)
{
CleanupDriveInternal(HARDDISK_1);
CleanupDriveInternal(HARDDISK_2);
// if destroyed by user in Config->Disk, then ensure that old object's reference is removed
UnregisterIoHandler(m_slot);
}
void HarddiskInterfaceCard::Reset(const bool powerCycle)

View file

@ -744,7 +744,7 @@ inline bool IsPotentialNoSlotClockAccess(const WORD address)
(SW_INTCXROM && (AddrHi == 0xC8)) ); // Internal ROM at [$C100-CFFF] && AddrHi == $C8
}
static bool IsCardInSlot(const UINT uSlot);
static bool IsCardInSlot(UINT slot);
// Enabling expansion ROM ($C800..$CFFF]:
// . Enable if: Enable1 && Enable2
@ -944,7 +944,6 @@ BYTE __stdcall IO_F8xx(WORD programcounter, WORD address, BYTE write, BYTE value
static struct SlotInfo
{
bool bHasCard;
iofunction IOReadCx;
iofunction IOWriteCx;
} g_SlotInfo[NUM_SLOTS] = {0};
@ -977,7 +976,6 @@ static void InitIoHandlers()
for (i=0; i<NUM_SLOTS; i++)
{
g_SlotInfo[i].bHasCard = false;
g_SlotInfo[i].IOReadCx = IO_Cxxx;
g_SlotInfo[i].IOWriteCx = IO_Cxxx;
ExpansionRom[i] = NULL;
@ -990,12 +988,17 @@ void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, io
_ASSERT(uSlot < NUM_SLOTS);
SlotParameters[uSlot] = lpSlotParameter;
if (IOReadC0 == NULL) IOReadC0 = IO_Null;
if (IOWriteC0 == NULL) IOWriteC0 = IO_Null;
IORead[uSlot+8] = IOReadC0;
IOWrite[uSlot+8] = IOWriteC0;
if (uSlot == 0) // Don't trash C0xx handlers
return;
//
if (IOReadCx == NULL) IOReadCx = IO_Cxxx;
if (IOWriteCx == NULL) IOWriteCx = IO_Cxxx;
@ -1005,7 +1008,6 @@ void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, io
IOWrite[uSlot*16+i] = IOWriteCx;
}
g_SlotInfo[uSlot].bHasCard = true;
g_SlotInfo[uSlot].IOReadCx = IOReadCx;
g_SlotInfo[uSlot].IOWriteCx = IOWriteCx;
@ -1016,7 +1018,6 @@ void RegisterIoHandler(UINT uSlot, iofunction IOReadC0, iofunction IOWriteC0, io
void UnregisterIoHandler(UINT uSlot)
{
RegisterIoHandler(uSlot, NULL, NULL, NULL, NULL, NULL, NULL);
g_SlotInfo[uSlot].bHasCard = false;
}
// From UTAIIe:5-28: Since INTCXROM==1 then state of SLOTC3ROM is not important
@ -1058,9 +1059,9 @@ static void IoHandlerCardsIn(void)
}
}
static bool IsCardInSlot(const UINT uSlot)
static bool IsCardInSlot(UINT slot)
{
return g_SlotInfo[uSlot].bHasCard;
return GetCardMgr().QuerySlot(slot) != CT_Empty;
}
//===========================================================================
@ -1478,8 +1479,8 @@ bool MemIsAddrCodeMemory(const USHORT addr)
if (addr <= APPLE_SLOT_END) // [$C100..C7FF]
{
const UINT uSlot = (addr >> 8) & 0x7;
return IsCardInSlot(uSlot);
UINT slot = (addr >> 8) & 0x7;
return IsCardInSlot(slot);
}
// [$C800..CFFF]