diff --git a/src/debugger/gui/TiaOutputWidget.cxx b/src/debugger/gui/TiaOutputWidget.cxx index e05247819..ea4e42e8e 100644 --- a/src/debugger/gui/TiaOutputWidget.cxx +++ b/src/debugger/gui/TiaOutputWidget.cxx @@ -104,8 +104,10 @@ void TiaOutputWidget::saveSnapshot(int execDepth, const string& execPrefix) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaOutputWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) { + if (b == MouseButton::LEFT) + myZoom->setPos(x, y); // Grab right mouse button for command context menu - if(b == MouseButton::RIGHT) + else if(b == MouseButton::RIGHT) { myClickX = x; myClickY = y; diff --git a/src/debugger/gui/TiaZoomWidget.cxx b/src/debugger/gui/TiaZoomWidget.cxx index 2c3a0e41c..14b4373c6 100644 --- a/src/debugger/gui/TiaZoomWidget.cxx +++ b/src/debugger/gui/TiaZoomWidget.cxx @@ -17,6 +17,8 @@ #include "OSystem.hxx" #include "Console.hxx" +#include "Debugger.hxx" +#include "DebuggerParser.hxx" #include "TIA.hxx" #include "FrameBuffer.hxx" #include "FBSurface.hxx" @@ -49,10 +51,12 @@ TiaZoomWidget::TiaZoomWidget(GuiObject* boss, const GUI::Font& font, myXOff = myYOff = 0; myMouseMoving = false; - myXClick = myYClick = 0; + myClickX = myClickY = 0; // Create context menu for zoom levels VariantList l; + VarList::push_back(l, "Fill to scanline", "scanline"); + VarList::push_back(l, "Toggle breakpoint", "bp"); VarList::push_back(l, "2x zoom", "2"); VarList::push_back(l, "4x zoom", "4"); VarList::push_back(l, "8x zoom", "8"); @@ -81,10 +85,16 @@ void TiaZoomWidget::zoom(int level) if(myZoomLevel == level) return; + // TODO: zoom to center + //int x = myXOff + myNumCols / 2; + //int y = myYOff + myNumRows / 2; + myZoomLevel = level; myNumCols = ((_w - 4) >> 1) / myZoomLevel; myNumRows = (_h - 4) / myZoomLevel; + //setPos(x, y); + recalc(); } @@ -104,14 +114,15 @@ void TiaZoomWidget::recalc() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TiaZoomWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount) { + myClickX = x; + myClickY = y; + // Button 1 is for 'drag'/movement of the image // Button 2 is for context menu if(b == MouseButton::LEFT) { // Indicate mouse drag started/in progress myMouseMoving = true; - myXClick = x; - myYClick = y; } else if(b == MouseButton::RIGHT) { @@ -150,11 +161,8 @@ void TiaZoomWidget::handleMouseMoved(int x, int y) // myXClick = x; // myYClick = y; - - //cerr << diffx << " " << diffy << endl; - myXOff -= diffx; myYOff -= diffy; @@ -236,9 +244,37 @@ void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int { case ContextMenu::kItemSelectedCmd: { - int level = myMenu->getSelectedTag().toInt(); - if(level > 0) - zoom(level); + uInt32 ystart = instance().console().tia().ystart(); + const string& rmb = myMenu->getSelectedTag().toString(); + + if(rmb == "scanline") + { + ostringstream command; + int lines = myClickY / myZoomLevel + myYOff + ystart - instance().console().tia().scanlines(); + + if (lines < 0) + lines += instance().console().tia().scanlinesLastFrame(); + if(lines > 0) + { + command << "scanline #" << lines; + string message = instance().debugger().parser().run(command.str()); + instance().frameBuffer().showMessage(message); + } + } + else if(rmb == "bp") + { + ostringstream command; + int scanline = myClickY / myZoomLevel + myYOff + ystart; + command << "breakif _scan==#" << scanline; + string message = instance().debugger().parser().run(command.str()); + instance().frameBuffer().showMessage(message); + } + else + { + int level = myMenu->getSelectedTag().toInt(); + if(level > 0) + zoom(level); + } break; } } diff --git a/src/debugger/gui/TiaZoomWidget.hxx b/src/debugger/gui/TiaZoomWidget.hxx index 23269000a..8c048ee75 100644 --- a/src/debugger/gui/TiaZoomWidget.hxx +++ b/src/debugger/gui/TiaZoomWidget.hxx @@ -24,7 +24,6 @@ class ContextMenu; #include "Widget.hxx" #include "Command.hxx" - class TiaZoomWidget : public Widget, public CommandSender { public: @@ -61,7 +60,7 @@ class TiaZoomWidget : public Widget, public CommandSender int myXOff, myYOff; bool myMouseMoving; - int myXClick, myYClick; + int myClickX, myClickY; private: // Following constructors and assignment operators not supported