diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 851cf0bd..7bd5b506 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -484,13 +484,17 @@ bool _Bookmark_Del( const WORD nAddress ) { // g_aBookmarks.at( iBookmark ) = NO_6502_TARGET; g_aBookmarks[ iBookmark ].bSet = false; + g_nBookmarks--; bDeleted = true; } } return bDeleted; } -bool Bookmark_Find( const WORD nAddress ) +// Returns: +// 0 if address does not have a bookmark set +// N+1 if there is an existing bookmark that has this address +int Bookmark_Find( const WORD nAddress ) { // Ugh, linear search // int nSize = g_aBookmarks.size(); @@ -500,10 +504,10 @@ bool Bookmark_Find( const WORD nAddress ) if (g_aBookmarks[ iBookmark ].nAddress == nAddress) { if (g_aBookmarks[ iBookmark ].bSet) - return true; + return iBookmark + 1; } } - return false; + return 0; } @@ -598,15 +602,26 @@ Update_t CmdBookmarkAdd (int nArgs ) ConsoleDisplayPush( sText ); return ConsoleUpdate(); } - - if ((iBookmark < MAX_BOOKMARKS) && (g_nBookmarks < MAX_BOOKMARKS)) + + // 2.9.0.16 Fixed: Replacing an existing bookmark incorrectly increased the total bookmark count. + int nOldBookmark = Bookmark_Find( nAddress ); + if (nOldBookmark) { - g_aBookmarks[iBookmark].bSet = true; - g_aBookmarks[iBookmark].nAddress = nAddress; - bAdded = true; - g_nBookmarks++; - iBookmark++; + _Bookmark_Del( nAddress ); } + + // 2.9.0.17 Fixed: If all bookmarks were used then setting a new one wouldn't update an existing one to the new address. + if (g_aBookmarks[ iBookmark ].bSet) + { + g_aBookmarks[ iBookmark ].nAddress = nAddress; + bAdded = true; + } + else + if (g_nBookmarks < MAX_BOOKMARKS) + { + bAdded = _Bookmark_Add( iBookmark, nAddress ); + iBookmark++; + } } if (!bAdded) diff --git a/source/Debugger/Debug.h b/source/Debugger/Debug.h index 70d1327b..91ac7d5c 100644 --- a/source/Debugger/Debug.h +++ b/source/Debugger/Debug.h @@ -135,7 +135,7 @@ // Prototypes _______________________________________________________________ // Bookmarks - bool Bookmark_Find( const WORD nAddress ); + int Bookmark_Find( const WORD nAddress ); // Breakpoints int CheckBreakpointsIO ();