diff --git a/source/CardManager.cpp b/source/CardManager.cpp index 5ae06174..67739753 100644 --- a/source/CardManager.cpp +++ b/source/CardManager.cpp @@ -160,6 +160,7 @@ void CardManager::RemoveInternal(UINT slot) break; } + UnregisterIoHandler(slot); delete m_slot[slot]; m_slot[slot] = NULL; } diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index 6f296976..475c7b44 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -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: diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index cbad04f8..cf1af179 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -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 ); } diff --git a/source/Debugger/Util_MemoryTextFile.cpp b/source/Debugger/Util_MemoryTextFile.cpp index 2816f1cb..750a4d15 100644 --- a/source/Debugger/Util_MemoryTextFile.cpp +++ b/source/Debugger/Util_MemoryTextFile.cpp @@ -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); +} diff --git a/source/Debugger/Util_MemoryTextFile.h b/source/Debugger/Util_MemoryTextFile.h index 7ee17563..85c041d8 100644 --- a/source/Debugger/Util_MemoryTextFile.h +++ b/source/Debugger/Util_MemoryTextFile.h @@ -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" }; diff --git a/source/Disk.cpp b/source/Disk.cpp index 65993c58..8dd5a6aa 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -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; } diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index fe373b3e..67a96c19 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -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) diff --git a/source/Memory.cpp b/source/Memory.cpp index 47961b2b..d7c81bfd 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -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> 8) & 0x7; - return IsCardInSlot(uSlot); + UINT slot = (addr >> 8) & 0x7; + return IsCardInSlot(slot); } // [$C800..CFFF]