diff --git a/docs/Debugger_Changelog.txt b/docs/Debugger_Changelog.txt index b2ca5a72..e73683ac 100644 --- a/docs/Debugger_Changelog.txt +++ b/docs/Debugger_Changelog.txt @@ -1,6 +1,8 @@ /* - +.3 Added: Mouse Forward and Backward buttons move to previous and next bookmarks. +.2 Added: "Ctrl -" and "Ctrl +" now move to previous and next bookmarks respectively. +.1 Added support for Middle, Forward, and Backward mouse buttons. 2.9.1.0 Added: Bookmarks now have their own indicator (a number with a box around it) and replace the ":" seperator. Updated Debug_Font.bmp .18 Fixed: Resetting bookmarks wasn't setting the total bookmarks back to zero. diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 4e78252b..e4592ddd 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -50,7 +50,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define ALLOW_INPUT_LOWERCASE 1 // See /docs/Debugger_Changelog.txt for full details - const int DEBUGGER_VERSION = MAKE_VERSION(2,9,1,0); + const int DEBUGGER_VERSION = MAKE_VERSION(2,9,1,3); // Public _________________________________________________________________________________________ @@ -61,6 +61,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Bookmarks __________________________________________________________________ int g_nBookmarks = 0; Bookmark_t g_aBookmarks[ MAX_BOOKMARKS ]; + int g_nDebuggerMouseLastBookmark = 0; // Breakpoints ________________________________________________________________ // Any Speed Breakpoints @@ -325,6 +326,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA static int ParseInput ( LPTSTR pConsoleInput, bool bCook = true ); static Update_t ExecuteCommand ( int nArgs ); +// Bookmarks + Update_t _CmdBookmarkGotoPrev(); + Update_t _CmdBookmarkGotoNext(); + // Breakpoints void _BWZ_List ( const Breakpoint_t * aBreakWatchZero, const int iBWZ ); // bool bZeroBased = true ); void _BWZ_ListAll ( const Breakpoint_t * aBreakWatchZero, const int nMax ); @@ -463,7 +468,10 @@ bool _Bookmark_Add( const int iBookmark, const WORD nAddress ) // g_aBookmarks.at( iBookmark ) = nAddress; g_aBookmarks[ iBookmark ].nAddress = nAddress; g_aBookmarks[ iBookmark ].bSet = true; + g_nBookmarks++; + g_nDebuggerMouseLastBookmark = iBookmark; + return true; } @@ -558,6 +566,69 @@ int _Bookmark_Size() return g_nBookmarks; } +//=========================================================================== +Update_t _CmdBookmarkGotoPrev() +{ + Update_t bUpdateDisplay = UPDATE_NOTHING; + + if (g_nBookmarks) + { + WORD nAddressBook; + WORD nAddressBest = g_nDisasmTopAddress; + + // Find any bookmark that has an address < the top address + for( int iBookmark = 0; iBookmark < MAX_BOOKMARKS; iBookmark++ ) + { + nAddressBook = g_aBookmarks[ iBookmark ].nAddress; + + if ((g_aBookmarks[ iBookmark ].bSet) && (nAddressBook < g_nDisasmTopAddress)) // Can't use g_nDisasmCurAddress as the cursor would never move + { + // Found a candidate, if better then current keep it + if (((g_nDisasmTopAddress - nAddressBest) == 0) + || (nAddressBest < nAddressBook)) + nAddressBest = nAddressBook; + } + } + + int nArgs = 1; + g_aArgs[ 1 ].nValue = nAddressBest; + bUpdateDisplay = CmdUnassemble( nArgs ); + } + + return bUpdateDisplay; +} + +//=========================================================================== +Update_t _CmdBookmarkGotoNext() +{ + Update_t bUpdateDisplay = UPDATE_NOTHING; + + if (g_nBookmarks) + { + WORD nAddressBook; + WORD nAddressBest = g_nDisasmTopAddress; + + // Find any bookmark that has an address > the top address + for( int iBookmark = 0; iBookmark < MAX_BOOKMARKS; iBookmark++ ) + { + nAddressBook = g_aBookmarks[ iBookmark ].nAddress; + + if ((g_aBookmarks[ iBookmark ].bSet) && (nAddressBook > g_nDisasmTopAddress)) // Can't use g_nDisasmCurAddress as the cursor would never move + { + if (((g_nDisasmTopAddress - nAddressBest) == 0) + || (nAddressBest > nAddressBook)) + nAddressBest = nAddressBook; + } + } + + int nArgs = 1; + g_aArgs[ 1 ].nValue = nAddressBest; + bUpdateDisplay = CmdUnassemble( nArgs ); + } + + return bUpdateDisplay; +} + //=========================================================================== Update_t CmdBookmark (int nArgs) { @@ -9642,6 +9713,12 @@ void DebuggerProcessKey( int keycode ) break; default: + if ((keycode == VK_OEM_MINUS) && KeybGetCtrlStatus()) // KEY: Ctrl - + bUpdateDisplay |=_CmdBookmarkGotoPrev(); + else + if ((keycode == VK_OEM_PLUS) && KeybGetCapsStatus()) // KEY: Ctrl + + bUpdateDisplay |= _CmdBookmarkGotoNext(); + else if ((keycode >= '0') && (keycode <= '9')) { int nArgs = 1; @@ -9659,7 +9736,7 @@ void DebuggerProcessKey( int keycode ) { nArgs = 1; g_aArgs[ 1 ].nValue = iBookmark; - bUpdateDisplay |= CmdBookmarkGoto( nArgs ); + bUpdateDisplay |= CmdBookmarkGoto( nArgs ); // Ctrl-0 .. Ctrl-9 g_bIgnoreNextKey = true; } } @@ -9741,46 +9818,45 @@ void DebuggerCursorNext() //} -//=========================================================================== -void DebuggerMouseClick( int x, int y ) -{ - if (g_nAppMode != MODE_DEBUG) - return; - KeybUpdateCtrlShiftStatus(); + +// Mouse __________________________________________________________________________________________ + + + typedef void (*MouseClick_t)(const int x, const int y); + + int g_nDebuggerMouseCx; + int g_nDebuggerMouseCy; + + void onDebuggerMouseClickL( const int cx, const int cy ); + void onDebuggerMouseClickM( const int cx, const int cy ); + void onDebuggerMouseClickR( const int cx, const int cy ); + void onDebuggerMouseClickF( const int cx, const int cy ); + void onDebuggerMouseClickB( const int cx, const int cy ); + + // NOTE: Keep in sync with MouseButton_t and g_aDebuggerMouseProcessFunc ! +MouseClick_t g_aDebuggerMouseProcessFunc[ NUM_MOUSE_BUTTONS ] = +{ + &onDebuggerMouseClickL // MOUSE_BUTTON_LEFT + , &onDebuggerMouseClickM // MOUSE_BUTTON_MIDDLE + , &onDebuggerMouseClickR // MOUSE_BUTTON_RIGHT + , &onDebuggerMouseClickF // MOUSE_BUTTON_FORWARD + , &onDebuggerMouseClickB // MOUSE_BUTTON_BACKWARD +}; + + +//=========================================================================== +void onDebuggerMouseClickL( const int cx, const int cy ) +{ int iAltCtrlShift = 0; iAltCtrlShift |= KeybGetAltStatus() ? 1<<0 : 0; iAltCtrlShift |= KeybGetCtrlStatus() ? 1<<1 : 0; iAltCtrlShift |= KeybGetShiftStatus() ? 1<<2 : 0; - // GH#462 disasm click # + // GH#462 disasm click # if (iAltCtrlShift != g_bConfigDisasmClick) return; - int nFontWidth = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nFontWidthAvg * GetViewportScale(); - int nFontHeight = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight * GetViewportScale(); - - // do picking - - const int nOffsetX = IsFullScreen() ? GetFullScreenOffsetX() : Get3DBorderWidth(); - const int nOffsetY = IsFullScreen() ? GetFullScreenOffsetY() : Get3DBorderHeight(); - - const int nOffsetInScreenX = x - nOffsetX; - const int nOffsetInScreenY = y - nOffsetY; - - if (nOffsetInScreenX < 0 || nOffsetInScreenY < 0) - return; - - int cx = nOffsetInScreenX / nFontWidth; - int cy = nOffsetInScreenY / nFontHeight; - -#if _DEBUG - char sText[ CONSOLE_WIDTH ]; - sprintf( sText, "x:%d y:%d cx:%d cy:%d", x, y, cx, cy ); - ConsoleDisplayPush( sText ); - DebugDisplay(); -#endif - if (g_iWindowThis == WINDOW_CODE) { // Display_AssemblyLine -- need Tabs @@ -9869,6 +9945,90 @@ void DebuggerMouseClick( int x, int y ) } } +//=========================================================================== +void onDebuggerMouseClickM( const int cx, const int cy ) +{ + // Goto next bookmark + if (g_nBookmarks) + { + // Find next available bookmark + for( int iBookmark = 0; iBookmark < MAX_BOOKMARKS; iBookmark++ ) + { + g_nDebuggerMouseLastBookmark++; + g_nDebuggerMouseLastBookmark %= MAX_BOOKMARKS; + + //g_nDebuggerMouseLastBookmark %= MAX_BOOKMARKS + if (g_aBookmarks[ g_nDebuggerMouseLastBookmark ].bSet) + break; + } + + // Guaranteed to always have at least 1 bookmark + int nArgs = 1; + g_aArgs[ 1 ].nValue = g_nDebuggerMouseLastBookmark; + Update_t bUpdateDisplay = CmdBookmarkGoto( nArgs ); // Ctrl-0 .. Ctrl-9 + UpdateDisplay( bUpdateDisplay ); + //g_bIgnoreNextKey = true; ??? + } +} + +//=========================================================================== +void onDebuggerMouseClickR( const int cx, const int cy ) +{ +} + +//=========================================================================== +void onDebuggerMouseClickF( const int cx, const int cy ) +{ + // Forward = Goto Previous Bookmark + Update_t bUpdateDisplay = _CmdBookmarkGotoPrev(); + UpdateDisplay( bUpdateDisplay ); +} + + +//=========================================================================== +void onDebuggerMouseClickB( const int cx, const int cy ) +{ + // Back = Goto Next Bookmark + Update_t bUpdateDisplay = _CmdBookmarkGotoNext(); + UpdateDisplay( bUpdateDisplay ); +} + +//=========================================================================== +void DebuggerProcessMouseClick( int button, int x, int y ) +{ + if (g_nAppMode != MODE_DEBUG) + return; + + int nFontWidth = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nFontWidthAvg * GetViewportScale(); + int nFontHeight = g_aFontConfig[ FONT_DISASM_DEFAULT ]._nLineHeight * GetViewportScale(); + + // do picking + + const int nOffsetX = IsFullScreen() ? GetFullScreenOffsetX() : Get3DBorderWidth(); + const int nOffsetY = IsFullScreen() ? GetFullScreenOffsetY() : Get3DBorderHeight(); + + const int nOffsetInScreenX = x - nOffsetX; + const int nOffsetInScreenY = y - nOffsetY; + + if (nOffsetInScreenX < 0 || nOffsetInScreenY < 0) + return; + + g_nDebuggerMouseCx = nOffsetInScreenX / nFontWidth; + g_nDebuggerMouseCy = nOffsetInScreenY / nFontHeight; + +#if _DEBUG + char sText[ CONSOLE_WIDTH ]; + sprintf( sText, "#:%d x:%d y:%d cx:%d cy:%d", button, x, y, g_nDebuggerMouseCx, g_nDebuggerMouseCy ); + ConsoleDisplayPush( sText ); + DebugDisplay(); +#endif + + if( button < NUM_MOUSE_BUTTONS ) + if (g_aDebuggerMouseProcessFunc[ button ]) + g_aDebuggerMouseProcessFunc[ button ]( g_nDebuggerMouseCx, g_nDebuggerMouseCy ); + +} + //=========================================================================== bool IsDebugSteppingAtFullSpeed(void) { diff --git a/source/Debugger/Debug.h b/source/Debugger/Debug.h index 3237e4f6..ce72a396 100644 --- a/source/Debugger/Debug.h +++ b/source/Debugger/Debug.h @@ -193,6 +193,6 @@ void DebuggerUpdate(); void DebuggerCursorNext(); - void DebuggerMouseClick( int x, int y ); + void DebuggerProcessMouseClick( int button, int x, int y ); bool IsDebugSteppingAtFullSpeed(void); diff --git a/source/Frame.cpp b/source/Frame.cpp index c42e6172..3070f108 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -1594,7 +1594,7 @@ LRESULT CALLBACK FrameWndProc ( } } - DebuggerMouseClick( x, y ); + DebuggerProcessMouseClick( MOUSE_BUTTON_LEFT, x, y ); } RelayEvent(WM_LBUTTONDOWN,wparam,lparam); break; @@ -1784,6 +1784,33 @@ LRESULT CALLBACK FrameWndProc ( DrawFrameWindow(); break; + case WM_MBUTTONDOWN: +// case WM_MBUTTONUP: + KeybUpdateCtrlShiftStatus(); + if (g_nAppMode == MODE_DEBUG) + { + x = LOWORD(lparam); + y = HIWORD(lparam); + DebuggerProcessMouseClick( MOUSE_BUTTON_MIDDLE, x, y ); + } + break; + + case WM_XBUTTONDOWN: + KeybUpdateCtrlShiftStatus(); + if (g_nAppMode == MODE_DEBUG) + { + x = LOWORD(lparam); + y = HIWORD(lparam); + + //int button = GET_XBUTTON_WPARAM(wParam); + int button = 0; + if (wparam & MK_XBUTTON1) button = MOUSE_BUTTON_BACKWARD; + if (wparam & MK_XBUTTON2) button = MOUSE_BUTTON_FORWARD; + if( button ) + DebuggerProcessMouseClick( button, x, y ); + } + break; + case WM_RBUTTONDOWN: case WM_RBUTTONUP: x = LOWORD(lparam); @@ -1839,6 +1866,13 @@ LRESULT CALLBACK FrameWndProc ( else if (g_CardMgr.IsMouseCardInstalled()) g_CardMgr.GetMouseCard()->SetButton(BUTTON1, (message == WM_RBUTTONDOWN) ? BUTTON_DOWN : BUTTON_UP); + if ((g_nAppMode == MODE_DEBUG) && (WM_RBUTTONDOWN == message)) + { + x = LOWORD(lparam); + y = HIWORD(lparam); + DebuggerProcessMouseClick( MOUSE_BUTTON_RIGHT, x, y ); + } + RelayEvent(message,wparam,lparam); break;