Previous 199869 Revisions Next

r20289 Wednesday 16th January, 2013 at 04:37:30 UTC by Andrew Gardner
QT Debugger improvements.  [Andrew Gardner]
- Fixed disassembly window not following PC correctly.
- Switched font to Courier New since it seems more universal.
- Fixed gaps between rendered text characters.
- Plumbed mouse handling through the debugger core (clicking selects).
- Made the Enter key behave like old SDL debugger; silently steps.
[src/emu/debug]debugvw.c debugvw.h dvdisasm.c dvdisasm.h dvmemory.c dvmemory.h
[src/osd/sdl]debugqtmainwindow.c debugqtview.c debugqtview.h sdl.mak

trunk/src/osd/sdl/debugqtview.c
r20288r20289
33#include "debugqtview.h"
44
55
6DebuggerView::DebuggerView(const debug_view_type& type,
7                     running_machine* machine,
8                     QWidget* parent) :
9   QAbstractScrollArea(parent),
10   m_preferBottom(false),
11   m_view(NULL),
12   m_machine(machine)
6DebuggerView::DebuggerView(const debug_view_type& type,
7                           running_machine* machine,
8                           QWidget* parent) :
9    QAbstractScrollArea(parent),
10    m_preferBottom(false),
11    m_view(NULL),
12    m_machine(machine)
1313{
14   QFont viewFontRequest("Courier");
15   viewFontRequest.setFixedPitch(true);
16   viewFontRequest.setPointSize(12);
17   setFont(viewFontRequest);
14    // I like setting the font per-view since it doesn't override the menuing fonts.
15    QFont viewFontRequest("Courier New");
16    viewFontRequest.setFixedPitch(true);
17    viewFontRequest.setPointSize(11);
18    setFont(viewFontRequest);
1819
19   m_view = m_machine->debug_view().alloc_view(type,
20                                    DebuggerView::debuggerViewUpdate,
21                                    this);
20    m_view = m_machine->debug_view().alloc_view(type,
21                                                DebuggerView::debuggerViewUpdate,
22                                                this);
23
24    connect(verticalScrollBar(), SIGNAL(valueChanged(int)),
25            this, SLOT(verticalScrollSlot(int)));
26    connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
27            this, SLOT(horizontalScrollSlot(int)));
2228}
2329
2430
2531void DebuggerView::paintEvent(QPaintEvent* event)
2632{
27   // Tell the MAME debug view how much real estate is available
28   QFontMetrics actualFont = fontMetrics();
29   const int fontWidth = MAX(1, actualFont.maxWidth());
30   const int fontHeight = MAX(1, actualFont.height());
31   m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight));
33    // Tell the MAME debug view how much real estate is available
34    QFontMetrics actualFont = fontMetrics();
35    const int fontWidth = MAX(1, actualFont.maxWidth());
36    const int fontHeight = MAX(1, actualFont.height());
37    m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight));
3238
3339
34   // Handle the scroll bars
35   const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
36   const int scrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff;
37   bool atEnd = false;
38   if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
39   {
40      atEnd = true;
41   }
42   verticalScrollBar()->setRange(0, scrollSize);
43   if (m_preferBottom && atEnd)
44   {
45      verticalScrollBar()->setValue(scrollSize);
46   }
47   m_view->set_visible_position(debug_view_xy(0, verticalScrollBar()->value()));
40    // Handle the scroll bars
41    const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y;
42    const int scrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff;
43    bool atEnd = false;
44    if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
45    {
46        atEnd = true;
47    }
48    verticalScrollBar()->setRange(0, scrollSize);
49    if (m_preferBottom && atEnd)
50    {
51        verticalScrollBar()->setValue(scrollSize);
52    }
4853
4954
50   // Draw the viewport widget
51   QPainter painter(viewport());
52   painter.fillRect(0, 0, width(), height(), QBrush(Qt::white));
53   painter.setBackgroundMode(Qt::OpaqueMode);
54   painter.setBackground(QColor(255,255,255));
55    // Draw the viewport widget
56    QPainter painter(viewport());
57    painter.fillRect(0, 0, width(), height(), QBrush(Qt::white));
58    painter.setBackgroundMode(Qt::OpaqueMode);
59    painter.setBackground(QColor(255,255,255));
5560
56   // Background control
57   QBrush bgBrush;
58   bgBrush.setStyle(Qt::SolidPattern);
59   painter.setPen(QPen(QColor(0,0,0)));
61    // Background control
62    QBrush bgBrush;
63    bgBrush.setStyle(Qt::SolidPattern);
64    painter.setPen(QPen(QColor(0,0,0)));
6065
61   size_t viewDataOffset = 0;
62   const debug_view_xy& visibleCharDims = m_view->visible_size();
63   for (int y = 0; y < visibleCharDims.y; y++)
64   {
65      for (int x = 0; x < visibleCharDims.x; x++)
66      {
67         const unsigned char textAttr = m_view->viewdata()[viewDataOffset].attrib;
66    size_t viewDataOffset = 0;
67    const debug_view_xy& visibleCharDims = m_view->visible_size();
68    for (int y = 0; y < visibleCharDims.y; y++)
69    {
70        for (int x = 0; x < visibleCharDims.x; x++)
71        {
72            const unsigned char textAttr = m_view->viewdata()[viewDataOffset].attrib;
6873
69         if (x == 0 || textAttr != m_view->viewdata()[viewDataOffset-1].attrib)
70         {
71            // Text color handling
72            QColor fgColor(0,0,0);
73            QColor bgColor(255,255,255);
74            if (x == 0 || textAttr != m_view->viewdata()[viewDataOffset-1].attrib)
75            {
76                // Text color handling
77                QColor fgColor(0,0,0);
78                QColor bgColor(255,255,255);
7479
75            if(textAttr & DCA_ANCILLARY)
76            {
77               bgColor.setRgb(0xe0, 0xe0, 0xe0);
78            }
79            if(textAttr & DCA_SELECTED)
80            {
81               bgColor.setRgb(0xff, 0x80, 0x80);
82            }
83            if(textAttr & DCA_CURRENT)
84            {
85               bgColor.setRgb(0xff, 0xff, 0x00);
86            }
87            if(textAttr & DCA_CHANGED)
88            {
89               fgColor.setRgb(0xff, 0x00, 0x00);
90            }
91            if(textAttr & DCA_INVALID)
92            {
93               fgColor.setRgb(0x00, 0x00, 0xff);
94            }
95            if(textAttr & DCA_DISABLED)
96            {
97               fgColor.setRgb((fgColor.red()   + bgColor.red())   >> 1,
98                           (fgColor.green() + bgColor.green()) >> 1,
99                           (fgColor.blue()  + bgColor.blue())  >> 1);
100            }
101            if(textAttr & DCA_COMMENT)
102            {
103               fgColor.setRgb(0x00, 0x80, 0x00);
104            }
80                if(textAttr & DCA_ANCILLARY)
81                {
82                    bgColor.setRgb(0xe0, 0xe0, 0xe0);
83                }
84                if(textAttr & DCA_SELECTED)
85                {
86                    bgColor.setRgb(0xff, 0x80, 0x80);
87                }
88                if(textAttr & DCA_CURRENT)
89                {
90                    bgColor.setRgb(0xff, 0xff, 0x00);
91                }
92                if(textAttr & DCA_CHANGED)
93                {
94                    fgColor.setRgb(0xff, 0x00, 0x00);
95                }
96                if(textAttr & DCA_INVALID)
97                {
98                    fgColor.setRgb(0x00, 0x00, 0xff);
99                }
100                if(textAttr & DCA_DISABLED)
101                {
102                    fgColor.setRgb((fgColor.red()   + bgColor.red())   >> 1,
103                                   (fgColor.green() + bgColor.green()) >> 1,
104                                   (fgColor.blue()  + bgColor.blue())  >> 1);
105                }
106                if(textAttr & DCA_COMMENT)
107                {
108                    fgColor.setRgb(0x00, 0x80, 0x00);
109                }
105110
106            bgBrush.setColor(bgColor);
107            painter.setBackground(bgBrush);
108            painter.setPen(QPen(fgColor));
109         }
111                bgBrush.setColor(bgColor);
112                painter.setBackground(bgBrush);
113                painter.setPen(QPen(fgColor));
114            }
110115
111         // There is a touchy interplay between font height, drawing difference, visible position, etc
112         // To test, set the bgcolor to something crazy and see where stuff gets drawn
113         painter.drawText(x*fontWidth,
114                        y*fontHeight + fontHeight,
115                        QString(m_view->viewdata()[viewDataOffset].byte));
116         viewDataOffset++;
117      }
118   }
116            // Your character is not guaranteed to take up the entire fontWidth x fontHeight, so fill before.
117            painter.fillRect(x*fontWidth, y*fontHeight, fontWidth, fontHeight, bgBrush);
118
119            // There is a touchy interplay between font height, drawing difference, visible position, etc
120            // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed.
121            painter.drawText(x*fontWidth,
122                             (y*fontHeight + (fontHeight*0.80)),
123                             QString(m_view->viewdata()[viewDataOffset].byte));
124            viewDataOffset++;
125        }
126    }
119127}
120128
121129
122130void DebuggerView::keyPressEvent(QKeyEvent* event)
123131{
124   if (m_view == NULL)
125      return QWidget::keyPressEvent(event);
132    if (m_view == NULL)
133        return QWidget::keyPressEvent(event);
126134
127   Qt::KeyboardModifiers keyMods = QApplication::keyboardModifiers();
128   bool ctrlDown = keyMods.testFlag(Qt::ControlModifier);
135    Qt::KeyboardModifiers keyMods = QApplication::keyboardModifiers();
136    const bool ctrlDown = keyMods.testFlag(Qt::ControlModifier);
129137
130   int keyPress = -1;
131   switch (event->key())
138    int keyPress = -1;
139    switch (event->key())
140    {
141        case Qt::Key_Up:
142            keyPress = DCH_UP;
143            break;
144        case Qt::Key_Down:
145            keyPress = DCH_DOWN;
146            break;
147        case Qt::Key_Left:
148            keyPress = DCH_LEFT;
149            if (ctrlDown) keyPress = DCH_CTRLLEFT;
150            break;
151        case Qt::Key_Right:
152            keyPress = DCH_RIGHT;
153            if (ctrlDown) keyPress = DCH_CTRLRIGHT;
154            break;
155        case Qt::Key_PageUp:
156            keyPress = DCH_PUP;
157            break;
158        case Qt::Key_PageDown:
159            keyPress = DCH_PDOWN;
160            break;
161        case Qt::Key_Home:
162            keyPress = DCH_HOME;
163            if (ctrlDown) keyPress = DCH_CTRLHOME;
164            break;
165        case Qt::Key_End:
166            keyPress = DCH_END;
167            if (ctrlDown) keyPress = DCH_CTRLEND;
168            break;
169        case Qt::Key_0: keyPress = '0'; break;
170        case Qt::Key_1: keyPress = '1'; break;
171        case Qt::Key_2: keyPress = '2'; break;
172        case Qt::Key_3: keyPress = '3'; break;
173        case Qt::Key_4: keyPress = '4'; break;
174        case Qt::Key_5: keyPress = '5'; break;
175        case Qt::Key_6: keyPress = '6'; break;
176        case Qt::Key_7: keyPress = '7'; break;
177        case Qt::Key_8: keyPress = '8'; break;
178        case Qt::Key_9: keyPress = '9'; break;
179        case Qt::Key_A: keyPress = 'a'; break;
180        case Qt::Key_B: keyPress = 'b'; break;
181        case Qt::Key_C: keyPress = 'c'; break;
182        case Qt::Key_D: keyPress = 'd'; break;
183        case Qt::Key_E: keyPress = 'e'; break;
184        case Qt::Key_F: keyPress = 'f'; break;
185        default:
186            return QWidget::keyPressEvent(event);
187    }
188
189    m_view->set_cursor_visible(true);
190    m_view->process_char(keyPress);
191
192    // Catch the view up with the cursor
193    verticalScrollBar()->setValue(m_view->visible_position().y);
194
195    viewport()->update();
196    update();
197}
198
199
200void DebuggerView::mousePressEvent(QMouseEvent* event)
201{
202   if (event->button() == Qt::LeftButton)
132203   {
133      case Qt::Key_Up:
134         keyPress = DCH_UP;
135         break;
136      case Qt::Key_Down:
137         keyPress = DCH_DOWN;
138         break;
139      case Qt::Key_Left:
140         keyPress = DCH_LEFT;
141         if (ctrlDown) keyPress = DCH_CTRLLEFT;
142         break;
143      case Qt::Key_Right:
144         keyPress = DCH_RIGHT;
145         if (ctrlDown) keyPress = DCH_CTRLRIGHT;
146         break;
147      case Qt::Key_PageUp:
148         keyPress = DCH_PUP;
149         break;
150      case Qt::Key_PageDown:
151         keyPress = DCH_PDOWN;
152         break;
153      case Qt::Key_Home:
154         keyPress = DCH_HOME;
155         if (ctrlDown) keyPress = DCH_CTRLHOME;
156         break;
157      case Qt::Key_End:
158         keyPress = DCH_END;
159         if (ctrlDown) keyPress = DCH_CTRLEND;
160         break;
161      case Qt::Key_0: keyPress = '0'; break;
162      case Qt::Key_1: keyPress = '1'; break;
163      case Qt::Key_2: keyPress = '2'; break;
164      case Qt::Key_3: keyPress = '3'; break;
165      case Qt::Key_4: keyPress = '4'; break;
166      case Qt::Key_5: keyPress = '5'; break;
167      case Qt::Key_6: keyPress = '6'; break;
168      case Qt::Key_7: keyPress = '7'; break;
169      case Qt::Key_8: keyPress = '8'; break;
170      case Qt::Key_9: keyPress = '9'; break;
171      case Qt::Key_A: keyPress = 'a'; break;
172      case Qt::Key_B: keyPress = 'b'; break;
173      case Qt::Key_C: keyPress = 'c'; break;
174      case Qt::Key_D: keyPress = 'd'; break;
175      case Qt::Key_E: keyPress = 'e'; break;
176      case Qt::Key_F: keyPress = 'f'; break;
177      default:
178         return QWidget::keyPressEvent(event);
204      QFontMetrics actualFont = fontMetrics();
205      const int fontWidth = MAX(1, actualFont.maxWidth());
206      const int fontHeight = MAX(1, actualFont.height());
207     
208      debug_view_xy topLeft = m_view->visible_position();
209      debug_view_xy clickViewPosition;
210      clickViewPosition.x = topLeft.x + (event->x() / fontWidth);
211      clickViewPosition.y = topLeft.y + (event->y() / fontHeight);
212      m_view->process_click(DCK_LEFT_CLICK, clickViewPosition);
213
214      viewport()->update();
215      update();
179216   }
217}
180218
181   m_view->set_cursor_visible(true);
182   m_view->process_char(keyPress);
183219
184   // Catch the view up with the cursor
185   verticalScrollBar()->setValue(m_view->visible_position().y);
220void DebuggerView::verticalScrollSlot(int value)
221{
222    m_view->set_visible_position(debug_view_xy(horizontalScrollBar()->value(), value));
223}
186224
187   viewport()->update();
188   update();
225
226void DebuggerView::horizontalScrollSlot(int value)
227{
228    m_view->set_visible_position(debug_view_xy(value, verticalScrollBar()->value()));
189229}
190230
191231
192232void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate)
193233{
194   // Get a handle to the DebuggerView being updated & redraw
195   DebuggerView* dView = (DebuggerView*)osdPrivate;
196   dView->verticalScrollBar()->setValue(dView->view()->visible_position().y);
197   dView->viewport()->update();
198   dView->update();
234    // Get a handle to the DebuggerView being updated & redraw
235    DebuggerView* dView = (DebuggerView*)osdPrivate;
236    dView->verticalScrollBar()->setValue(dView->view()->visible_position().y);
237    dView->viewport()->update();
238    dView->update();
199239}
240
241
trunk/src/osd/sdl/debugqtview.h
r20288r20289
88
99class DebuggerView : public QAbstractScrollArea
1010{
11    Q_OBJECT
12   
1113public:
12   DebuggerView(const debug_view_type& type,
13               running_machine* machine,
14               QWidget* parent=NULL);
15   virtual ~DebuggerView() {}
14    DebuggerView(const debug_view_type& type,
15                 running_machine* machine,
16                 QWidget* parent=NULL);
17    virtual ~DebuggerView() {}
1618
17   void paintEvent(QPaintEvent* event);
19    void paintEvent(QPaintEvent* event);
1820
19   // Callback to allow MAME to refresh the view
20   static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate);
21    // Callback to allow MAME to refresh the view
22    static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate);
2123
22   // Setters and accessors
23   void setPreferBottom(bool pb) { m_preferBottom = pb; }
24   debug_view* view() { return m_view; }
24    // Setters and accessors
25    void setPreferBottom(bool pb) { m_preferBottom = pb; }
26    debug_view* view() { return m_view; }
2527
2628
2729protected:
28   void keyPressEvent(QKeyEvent* event);
30    void keyPressEvent(QKeyEvent* event);
31    void mousePressEvent(QMouseEvent* event);
2932
33private slots:
34    void verticalScrollSlot(int value);
35    void horizontalScrollSlot(int value);
3036
37
3138private:
32   bool m_preferBottom;
39    bool m_preferBottom;
3340
34   debug_view* m_view;
35   running_machine* m_machine;
41    debug_view* m_view;
42    running_machine* m_machine;
3643};
3744
3845
trunk/src/osd/sdl/sdl.mak
r20288r20289
635635   $(SDLOBJ)/debugqtdasmwindow.o \
636636   $(SDLOBJ)/debugqtmainwindow.o \
637637   $(SDLOBJ)/debugqtmemorywindow.o \
638   $(SDLOBJ)/debugqtview.moc.o \
638639   $(SDLOBJ)/debugqtwindow.moc.o \
639640   $(SDLOBJ)/debugqtlogwindow.moc.o \
640641   $(SDLOBJ)/debugqtdasmwindow.moc.o \
trunk/src/osd/sdl/debugqtmainwindow.c
r20288r20289
44#include "debug/dvdisasm.h"
55
66
7MainWindow::MainWindow(device_t* processor,
8                  running_machine* machine,
9                  QWidget* parent) :
10   WindowQt(machine, parent),
11   m_historyIndex(0),
12   m_inputHistory()
7MainWindow::MainWindow(device_t* processor,
8                       running_machine* machine,
9                       QWidget* parent) :
10    WindowQt(machine, parent),
11    m_historyIndex(0),
12    m_inputHistory()
1313{
14   setGeometry(300, 300, 1000, 600);
14    setGeometry(300, 300, 1000, 600);
1515
16   //
17   // The main frame and its input and log widgets
18   //
19   QFrame* mainWindowFrame = new QFrame(this);
16    //
17    // The main frame and its input and log widgets
18    //
19    QFrame* mainWindowFrame = new QFrame(this);
2020
21   // The input line
22   m_inputEdit = new QLineEdit(mainWindowFrame);
23   connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand()));
24   m_inputEdit->installEventFilter(this);
21    // The input line
22    m_inputEdit = new QLineEdit(mainWindowFrame);
23    connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand()));
24    m_inputEdit->installEventFilter(this);
2525
2626
27   // The log view
28   m_consoleView = new DebuggerView(DVT_CONSOLE,
29                              m_machine,
30                              mainWindowFrame);
31   m_consoleView->setFocusPolicy(Qt::NoFocus);
32   m_consoleView->setPreferBottom(true);
27    // The log view
28    m_consoleView = new DebuggerView(DVT_CONSOLE,
29                                     m_machine,
30                                     mainWindowFrame);
31    m_consoleView->setFocusPolicy(Qt::NoFocus);
32    m_consoleView->setPreferBottom(true);
3333
34   QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
35   vLayout->addWidget(m_consoleView);
36   vLayout->addWidget(m_inputEdit);
37   vLayout->setSpacing(3);
38   vLayout->setContentsMargins(4,0,4,2);
34    QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
35    vLayout->addWidget(m_consoleView);
36    vLayout->addWidget(m_inputEdit);
37    vLayout->setSpacing(3);
38    vLayout->setContentsMargins(4,0,4,2);
3939
40   setCentralWidget(mainWindowFrame);
40    setCentralWidget(mainWindowFrame);
4141
42   //
43   // Menu bars
44   //
45   // Create two commands
46   QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this);
47   QAction* runToCursorAct = new QAction("Run To Cursor", this);
48   breakpointSetAct->setShortcut(Qt::Key_F9);
49   runToCursorAct->setShortcut(Qt::Key_F4);
50   connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool)));
51   connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool)));
42    //
43    // Menu bars
44    //
45    // Create two commands
46    QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this);
47    QAction* runToCursorAct = new QAction("Run To Cursor", this);
48    breakpointSetAct->setShortcut(Qt::Key_F9);
49    runToCursorAct->setShortcut(Qt::Key_F4);
50    connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool)));
51    connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool)));
5252
53   // Right bar options
54   QActionGroup* rightBarGroup = new QActionGroup(this);
55   QAction* rightActRaw = new QAction("Raw Opcodes", this);
56   QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
57   QAction* rightActComments = new QAction("Comments", this);
58   rightActRaw->setCheckable(true);
59   rightActEncrypted->setCheckable(true);
60   rightActComments->setCheckable(true);
61   rightActRaw->setActionGroup(rightBarGroup);
62   rightActEncrypted->setActionGroup(rightBarGroup);
63   rightActComments->setActionGroup(rightBarGroup);
64   rightActRaw->setShortcut(QKeySequence("Ctrl+R"));
65   rightActEncrypted->setShortcut(QKeySequence("Ctrl+E"));
66   rightActComments->setShortcut(QKeySequence("Ctrl+C"));
67   rightActRaw->setChecked(true);
68   connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*)));
53    // Right bar options
54    QActionGroup* rightBarGroup = new QActionGroup(this);
55    QAction* rightActRaw = new QAction("Raw Opcodes", this);
56    QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
57    QAction* rightActComments = new QAction("Comments", this);
58    rightActRaw->setCheckable(true);
59    rightActEncrypted->setCheckable(true);
60    rightActComments->setCheckable(true);
61    rightActRaw->setActionGroup(rightBarGroup);
62    rightActEncrypted->setActionGroup(rightBarGroup);
63    rightActComments->setActionGroup(rightBarGroup);
64    rightActRaw->setShortcut(QKeySequence("Ctrl+R"));
65    rightActEncrypted->setShortcut(QKeySequence("Ctrl+E"));
66    rightActComments->setShortcut(QKeySequence("Ctrl+C"));
67    rightActRaw->setChecked(true);
68    connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*)));
6969
70   // Assemble the options menu
71   QMenu* optionsMenu = menuBar()->addMenu("&Options");
72   optionsMenu->addAction(breakpointSetAct);
73   optionsMenu->addAction(runToCursorAct);
74   optionsMenu->addSeparator();
75   optionsMenu->addActions(rightBarGroup->actions());
70    // Assemble the options menu
71    QMenu* optionsMenu = menuBar()->addMenu("&Options");
72    optionsMenu->addAction(breakpointSetAct);
73    optionsMenu->addAction(runToCursorAct);
74    optionsMenu->addSeparator();
75    optionsMenu->addActions(rightBarGroup->actions());
7676
7777
78   //
79   // Dock windows
80   //
81   QMenu* dockMenu = menuBar()->addMenu("Doc&ks");
78    //
79    // Dock windows
80    //
81    QMenu* dockMenu = menuBar()->addMenu("Doc&ks");
8282
83   setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
84   setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
83    setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
84    setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
8585
86   // The processor dock
87   QDockWidget* cpuDock = new QDockWidget("processor", this);
88   cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea);
89   m_procFrame = new ProcessorDockWidget(m_machine, cpuDock);
90   cpuDock->setWidget(dynamic_cast<QWidget*>(m_procFrame));
86    // The processor dock
87    QDockWidget* cpuDock = new QDockWidget("processor", this);
88    cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea);
89    m_procFrame = new ProcessorDockWidget(m_machine, cpuDock);
90    cpuDock->setWidget(dynamic_cast<QWidget*>(m_procFrame));
9191
92   addDockWidget(Qt::LeftDockWidgetArea, cpuDock);
93   dockMenu->addAction(cpuDock->toggleViewAction());
92    addDockWidget(Qt::LeftDockWidgetArea, cpuDock);
93    dockMenu->addAction(cpuDock->toggleViewAction());
9494
95   // The disassembly dock
96   QDockWidget* dasmDock = new QDockWidget("dasm", this);
97   dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
98   m_dasmFrame = new DasmDockWidget(m_machine, dasmDock);
99   dasmDock->setWidget(m_dasmFrame);
95    // The disassembly dock
96    QDockWidget* dasmDock = new QDockWidget("dasm", this);
97    dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
98    m_dasmFrame = new DasmDockWidget(m_machine, dasmDock);
99    dasmDock->setWidget(m_dasmFrame);
100100
101   addDockWidget(Qt::TopDockWidgetArea, dasmDock);
102   dockMenu->addAction(dasmDock->toggleViewAction());
101    addDockWidget(Qt::TopDockWidgetArea, dasmDock);
102    dockMenu->addAction(dasmDock->toggleViewAction());
103103
104   // Window title
105   astring title;
106   title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag());
107   setWindowTitle(title.cstr());
104    // Window title
105    astring title;
106    title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag());
107    setWindowTitle(title.cstr());
108108}
109109
110110
111111void MainWindow::setProcessor(device_t* processor)
112112{
113   // Cpu swap
114   m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_list().match_device(processor));
115   m_dasmFrame->view()->view()->set_source(*m_dasmFrame->view()->view()->source_list().match_device(processor));
113    // Cpu swap
114    m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_list().match_device(processor));
115    m_dasmFrame->view()->view()->set_source(*m_dasmFrame->view()->view()->source_list().match_device(processor));
116116
117   // Scrollbar refresh - seems I should be able to do in the DebuggerView
118   m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y);
119   m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y);
117    // Scrollbar refresh - seems I should be able to do in the DebuggerView
118    m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y);
119    m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y);
120120
121   // Window title
122   astring title;
123   title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag());
124   setWindowTitle(title.cstr());
121    // Window title
122    astring title;
123    title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag());
124    setWindowTitle(title.cstr());
125125}
126126
127127
128128// Used to intercept the user clicking 'X' in the upper corner
129129void MainWindow::closeEvent(QCloseEvent* event)
130130{
131   debugActQuit();
131    debugActQuit();
132132}
133133
134134
135135// Used to intercept the user hitting the up arrow in the input widget
136136bool MainWindow::eventFilter(QObject* obj, QEvent* event)
137137{
138   // Only filter keypresses
139   QKeyEvent* keyEvent = NULL;
140   if (event->type() == QEvent::KeyPress)
141   {
142      keyEvent = static_cast<QKeyEvent*>(event);
143   }
144   else
145   {
146      return QObject::eventFilter(obj, event);
147   }
138    // Only filter keypresses
139    QKeyEvent* keyEvent = NULL;
140    if (event->type() == QEvent::KeyPress)
141    {
142        keyEvent = static_cast<QKeyEvent*>(event);
143    }
144    else
145    {
146        return QObject::eventFilter(obj, event);
147    }
148148
149   // Catch up & down keys
150   if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down)
151   {
152      if (keyEvent->key() == Qt::Key_Up)
153      {
154         if (m_historyIndex > 0)
155            m_historyIndex--;
156      }
157      else if (keyEvent->key() == Qt::Key_Down)
158      {
159         if (m_historyIndex < m_inputHistory.size())
160            m_historyIndex++;
161      }
149    // Catch up & down keys
150    if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down)
151    {
152        if (keyEvent->key() == Qt::Key_Up)
153        {
154            if (m_historyIndex > 0)
155                m_historyIndex--;
156        }
157        else if (keyEvent->key() == Qt::Key_Down)
158        {
159            if (m_historyIndex < m_inputHistory.size())
160                m_historyIndex++;
161        }
162162
163      // Populate the input edit or clear it if you're at the end
164      if (m_historyIndex == m_inputHistory.size())
165      {
166         m_inputEdit->setText("");
167      }
168      else
169      {
170         m_inputEdit->setText(m_inputHistory[m_historyIndex]);
171      }
172   }
173   else if (keyEvent->key() == Qt::Key_Enter)
174   {
175      executeCommand(false);
176   }
177   else
178   {
179      return QObject::eventFilter(obj, event);
180   }
181
182   return true;
163        // Populate the input edit or clear it if you're at the end
164        if (m_historyIndex == m_inputHistory.size())
165        {
166            m_inputEdit->setText("");
167        }
168        else
169        {
170            m_inputEdit->setText(m_inputHistory[m_historyIndex]);
171        }
172    }
173    else if (keyEvent->key() == Qt::Key_Enter)
174    {
175        executeCommand(false);
176    }
177    else
178    {
179        return QObject::eventFilter(obj, event);
180    }
181   
182    return true;
183183}
184184
185185
186186void MainWindow::toggleBreakpointAtCursor(bool changedTo)
187187{
188   debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
189   if (dasmView->cursor_visible())
190   {
191      if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())
192      {
193         offs_t address = downcast<debug_view_disasm *>(dasmView)->selected_address();
194         device_debug *cpuinfo = dasmView->source()->device()->debug();
188    debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
189    if (dasmView->cursor_visible())
190    {
191        if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())
192        {
193            offs_t address = downcast<debug_view_disasm *>(dasmView)->selected_address();
194            device_debug *cpuinfo = dasmView->source()->device()->debug();
195195
196         // Find an existing breakpoint at this address
197         INT32 bpindex = -1;
198         for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
199               bp != NULL;
200               bp = bp->next())
201         {
202            if (address == bp->address())
203            {
204               bpindex = bp->index();
205               break;
206            }
207         }
196            // Find an existing breakpoint at this address
197            INT32 bpindex = -1;
198            for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first();
199                 bp != NULL;
200                 bp = bp->next())
201            {
202                if (address == bp->address())
203                {
204                    bpindex = bp->index();
205                    break;
206                }
207            }
208208
209         // If none exists, add a new one
210         astring command;
211         if (bpindex == -1)
212         {
213            command.printf("bpset 0x%X", address);
214         }
215         else
216         {
217            command.printf("bpclear 0x%X", bpindex);
218         }
219         debug_console_execute_command(*m_machine, command, 1);
220      }
221   }
209            // If none exists, add a new one
210            astring command;
211            if (bpindex == -1)
212            {
213                command.printf("bpset 0x%X", address);
214            }
215            else
216            {
217                command.printf("bpclear 0x%X", bpindex);
218            }
219            debug_console_execute_command(*m_machine, command, 1);
220        }
221    }
222222
223   refreshAll();
223    refreshAll();
224224}
225225
226226
227227void MainWindow::runToCursor(bool changedTo)
228228{
229   debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
230   if (dasmView->cursor_visible())
231   {
232      if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())
233      {
234         offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
235         astring command;
236         command.printf("go 0x%X", address);
237         debug_console_execute_command(*m_machine, command, 1);
238      }
239   }
229    debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
230    if (dasmView->cursor_visible())
231    {
232        if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device())
233        {
234            offs_t address = downcast<debug_view_disasm*>(dasmView)->selected_address();
235            astring command;
236            command.printf("go 0x%X", address);
237            debug_console_execute_command(*m_machine, command, 1);
238        }
239    }
240240}
241241
242242
243243void MainWindow::rightBarChanged(QAction* changedTo)
244244{
245   debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
246   if (changedTo->text() == "Raw Opcodes")
247   {
248      dasmView->set_right_column(DASM_RIGHTCOL_RAW);
249   }
250   else if (changedTo->text() == "Encrypted Opcodes")
251   {
252      dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
253   }
254   else if (changedTo->text() == "Comments")
255   {
256      dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS);
257   }
258   m_dasmFrame->view()->viewport()->update();
245    debug_view_disasm* dasmView = downcast<debug_view_disasm*>(m_dasmFrame->view()->view());
246    if (changedTo->text() == "Raw Opcodes")
247    {
248        dasmView->set_right_column(DASM_RIGHTCOL_RAW);
249    }
250    else if (changedTo->text() == "Encrypted Opcodes")
251    {
252        dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED);
253    }
254    else if (changedTo->text() == "Comments")
255    {
256        dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS);
257    }
258    m_dasmFrame->view()->viewport()->update();
259259}
260260
261261
262262void MainWindow::executeCommand(bool withClear)
263263{
264   debug_console_execute_command(*m_machine,
265                           m_inputEdit->text().toLocal8Bit().data(),
266                           true);
264    if (m_inputEdit->text() == "")
265    {
266        debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
267        return;
268    }
269   
270    debug_console_execute_command(*m_machine,
271                                  m_inputEdit->text().toLocal8Bit().data(),
272                                  true);
267273
268   // Add history & set the index to be the top of the stack
269   addToHistory(m_inputEdit->text());
274    // Add history & set the index to be the top of the stack
275    addToHistory(m_inputEdit->text());
270276
271   // Clear out the text and reset the history pointer only if asked
272   if (withClear)
273   {
274      m_inputEdit->clear();
275      m_historyIndex = m_inputHistory.size();
276   }
277    // Clear out the text and reset the history pointer only if asked
278    if (withClear)
279    {
280        m_inputEdit->clear();
281        m_historyIndex = m_inputHistory.size();
282    }
277283
278   // Refresh
279   m_consoleView->viewport()->update();
280   m_procFrame->view()->update();
281   m_dasmFrame->view()->update();
284    // Refresh
285    m_consoleView->viewport()->update();
286    m_procFrame->view()->update();
287    m_dasmFrame->view()->update();
282288}
283289
284290
285291void MainWindow::addToHistory(const QString& command)
286292{
287   if (command == "")
288      return;
293    if (command == "")
294        return;
295   
296    // Always push back when there is no previous history
297    if (m_inputHistory.size() == 0)
298    {
299        m_inputHistory.push_back(m_inputEdit->text());
300        return;
301    }
289302
290   // Always push back when there is no previous history
291   if (m_inputHistory.size() == 0)
292   {
293      m_inputHistory.push_back(m_inputEdit->text());
294      return;
295   }
296
297   // If there is previous history, make sure it's not what you just executed
298   if (m_inputHistory.back() != m_inputEdit->text())
299   {
300      m_inputHistory.push_back(m_inputEdit->text());
301   }
303    // If there is previous history, make sure it's not what you just executed
304    if (m_inputHistory.back() != m_inputEdit->text())
305    {
306        m_inputHistory.push_back(m_inputEdit->text());
307    }
302308}
trunk/src/emu/debug/dvmemory.h
r20288r20289
6060   address_space *space() const { return m_space; }
6161
6262private:
63   address_space *m_space;             // address space we reference (if any)
64   device_memory_interface *m_memintf;         // pointer to the memory interface of the device
65   void *              m_base;                 // pointer to memory base
66   offs_t              m_length;               // length of memory
67   offs_t              m_offsetxor;            // XOR to apply to offsets
68   endianness_t        m_endianness;           // endianness of memory
69   UINT8               m_prefsize;             // preferred bytes per chunk
63   address_space *m_space;            // address space we reference (if any)
64   device_memory_interface *m_memintf;         // pointer to the memory interface of the device
65   void *            m_base;               // pointer to memory base
66   offs_t            m_length;            // length of memory
67   offs_t            m_offsetxor;         // XOR to apply to offsets
68   endianness_t      m_endianness;         // endianness of memory
69   UINT8            m_prefsize;            // preferred bytes per chunk
7070};
7171
7272
r20288r20289
101101   virtual void view_notify(debug_view_notification type);
102102   virtual void view_update();
103103   virtual void view_char(int chval);
104   virtual void view_click(const int button, const debug_view_xy& pos);
104105
105106private:
106107   struct cursor_pos
r20288r20289
126127   void write(UINT8 size, offs_t offs, UINT64 data);
127128
128129   // internal state
129   debug_view_expression m_expression;         // expression describing the start address
130   UINT32              m_chunks_per_row;       // number of chunks displayed per line
131   UINT8               m_bytes_per_chunk;      // bytes per chunk
132   bool                m_reverse_view;         // reverse-endian view?
133   bool                m_ascii_view;           // display ASCII characters?
134   bool                m_no_translation;       // don't run addresses through the cpu translation hook
135   offs_t              m_maxaddr;              // (derived) maximum address to display
136   UINT32              m_bytes_per_row;        // (derived) number of bytes displayed per line
137   UINT32              m_byte_offset;          // (derived) offset of starting visible byte
138   astring             m_addrformat;           // (derived) format string to use to print addresses
130   debug_view_expression m_expression;         // expression describing the start address
131   UINT32            m_chunks_per_row;      // number of chunks displayed per line
132   UINT8            m_bytes_per_chunk;      // bytes per chunk
133   bool            m_reverse_view;         // reverse-endian view?
134   bool            m_ascii_view;         // display ASCII characters?
135   bool            m_no_translation;      // don't run addresses through the cpu translation hook
136   offs_t            m_maxaddr;            // (derived) maximum address to display
137   UINT32            m_bytes_per_row;      // (derived) number of bytes displayed per line
138   UINT32            m_byte_offset;         // (derived) offset of starting visible byte
139   astring            m_addrformat;         // (derived) format string to use to print addresses
139140
140141   struct section
141142   {
142143      bool contains(int x) const { return x >= m_pos && x < m_pos + m_width; }
143      INT32           m_pos;                  /* starting position */
144      INT32           m_width;                /* width of this section */
144      INT32         m_pos;               /* starting position */
145      INT32         m_width;            /* width of this section */
145146   };
146   section             m_section[3];           // (derived) 3 sections to manage
147   section            m_section[3];         // (derived) 3 sections to manage
147148
148149   struct memory_view_pos
149150   {
150      UINT8           m_spacing;              /* spacing between each entry */
151      UINT8           m_shift[24];            /* shift for each character */
151      UINT8         m_spacing;            /* spacing between each entry */
152      UINT8         m_shift[24];         /* shift for each character */
152153   };
153   static const memory_view_pos s_memory_pos_table[9]; // table for rendering at different chunk sizes
154   static const memory_view_pos s_memory_pos_table[9];   // table for rendering at different chunk sizes
154155
155156   // constants
156157   static const int MEM_MAX_LINE_WIDTH = 1024;
trunk/src/emu/debug/debugvw.h
r20288r20289
7272
7373
7474// attribute bits for debug_view_char.attrib
75const UINT8 DCA_NORMAL      = 0x00;     // in Windows: black on white
76const UINT8 DCA_CHANGED     = 0x01;     // in Windows: red foreground
77const UINT8 DCA_SELECTED    = 0x02;     // in Windows: light red background
78const UINT8 DCA_INVALID     = 0x04;     // in Windows: dark blue foreground
79const UINT8 DCA_DISABLED    = 0x08;     // in Windows: darker foreground
80const UINT8 DCA_ANCILLARY   = 0x10;     // in Windows: grey background
81const UINT8 DCA_CURRENT     = 0x20;     // in Windows: yellow background
82const UINT8 DCA_COMMENT     = 0x40;     // in Windows: green foreground
75const UINT8 DCA_NORMAL      = 0x00;      // in Windows: black on white
76const UINT8 DCA_CHANGED      = 0x01;      // in Windows: red foreground
77const UINT8 DCA_SELECTED   = 0x02;      // in Windows: light red background
78const UINT8 DCA_INVALID      = 0x04;      // in Windows: dark blue foreground
79const UINT8 DCA_DISABLED   = 0x08;      // in Windows: darker foreground
80const UINT8 DCA_ANCILLARY   = 0x10;      // in Windows: grey background
81const UINT8 DCA_CURRENT      = 0x20;      // in Windows: yellow background
82const UINT8 DCA_COMMENT      = 0x40;      // in Windows: green foreground
8383
8484
8585// special characters that can be passed to process_char()
86const int DCH_UP            = 1;        // up arrow
87const int DCH_DOWN          = 2;        // down arrow
88const int DCH_LEFT          = 3;        // left arrow
89const int DCH_RIGHT         = 4;        // right arrow
90const int DCH_PUP           = 5;        // page up
91const int DCH_PDOWN         = 6;        // page down
92const int DCH_HOME          = 7;        // home
93const int DCH_CTRLHOME      = 8;        // ctrl+home
94const int DCH_END           = 9;        // end
95const int DCH_CTRLEND       = 10;       // ctrl+end
96const int DCH_CTRLRIGHT     = 11;       // ctrl+right
97const int DCH_CTRLLEFT      = 12;       // ctrl+left
86const int DCH_UP         = 1;      // up arrow
87const int DCH_DOWN         = 2;      // down arrow
88const int DCH_LEFT         = 3;      // left arrow
89const int DCH_RIGHT         = 4;      // right arrow
90const int DCH_PUP         = 5;      // page up
91const int DCH_PDOWN         = 6;      // page down
92const int DCH_HOME         = 7;      // home
93const int DCH_CTRLHOME      = 8;      // ctrl+home
94const int DCH_END         = 9;      // end
95const int DCH_CTRLEND      = 10;      // ctrl+end
96const int DCH_CTRLRIGHT      = 11;      // ctrl+right
97const int DCH_CTRLLEFT      = 12;      // ctrl+left
9898
9999
100// special characters that can be passed to process_click()
101const int DCK_LEFT_CLICK   = 1;      // left instantaneous click
102const int DCK_RIGHT_CLICK   = 2;      // right instantaneous click
103const int DCK_MIDDLE_CLICK   = 3;      // middle instantaneous click
100104
105
101106//**************************************************************************
102107//  TYPE DEFINITIONS
103108//**************************************************************************
r20288r20289
113118// a single "character" in the debug view has an ASCII value and an attribute byte
114119struct debug_view_char
115120{
116   UINT8               byte;
117   UINT8               attrib;
121   UINT8            byte;
122   UINT8            attrib;
118123};
119124
120125
r20288r20289
124129public:
125130   debug_view_xy(int _x = 0, int _y = 0) : x(_x), y(_y) { }
126131
127   INT32                   x;
128   INT32                   y;
132   INT32               x;
133   INT32               y;
129134};
130135
131136
r20288r20289
149154
150155private:
151156   // internal state
152   debug_view_source *     m_next;                 // link to next item
153   astring                 m_name;                 // name of the source item
154   device_t *              m_device;               // associated device (if applicable)
155   bool                    m_is_octal;             // is view in octal or hex
157   debug_view_source *      m_next;               // link to next item
158   astring               m_name;               // name of the source item
159   device_t *            m_device;            // associated device (if applicable)
160   bool               m_is_octal;            // is view in octal or hex
156161};
157162
158163
r20288r20289
181186
182187private:
183188   // internal state
184   running_machine &       m_machine;              // reference to our machine
185   debug_view_source *     m_head;                 // head of the list
186   debug_view_source *     m_tail;                 // end of the tail
187   UINT32                  m_count;                // number of items in the list
189   running_machine &      m_machine;            // reference to our machine
190   debug_view_source *      m_head;               // head of the list
191   debug_view_source *      m_tail;               // end of the tail
192   UINT32               m_count;            // number of items in the list
188193};
189194
190195
r20288r20289
221226   void set_cursor_visible(bool visible = true);
222227   void set_source(const debug_view_source &source);
223228   void process_char(int character) { view_char(character); }
229   void process_click(int button, debug_view_xy pos) { view_click(button, pos); }
224230
225231protected:
226232   // internal updating helpers
r20288r20289
238244   virtual void view_update() = 0;
239245   virtual void view_notify(debug_view_notification type);
240246   virtual void view_char(int chval);
247   virtual void view_click(const int button, const debug_view_xy& pos);
241248
242249protected:
243250   // core view data
244   debug_view *            m_next;             // link to the next view
245   debug_view_type         m_type;             // type of view
246   const debug_view_source *m_source;          // currently selected data source
247   debug_view_source_list  m_source_list;      // list of available data sources
251   debug_view *         m_next;            // link to the next view
252   debug_view_type         m_type;            // type of view
253   const debug_view_source *m_source;         // currently selected data source
254   debug_view_source_list   m_source_list;      // list of available data sources
248255
249256   // OSD data
250   debug_view_osd_update_func m_osdupdate;     // callback for the update
251   void *                  m_osdprivate;       // OSD-managed private data
257   debug_view_osd_update_func m_osdupdate;      // callback for the update
258   void *               m_osdprivate;      // OSD-managed private data
252259
253260   // visibility info
254   debug_view_xy           m_visible;          // visible size (in rows and columns)
255   debug_view_xy           m_total;            // total size (in rows and columns)
256   debug_view_xy           m_topleft;          // top-left visible position (in rows and columns)
257   debug_view_xy           m_cursor;           // cursor position
258   bool                    m_supports_cursor;  // does this view support a cursor?
259   bool                    m_cursor_visible;   // is the cursor visible?
261   debug_view_xy         m_visible;         // visible size (in rows and columns)
262   debug_view_xy         m_total;         // total size (in rows and columns)
263   debug_view_xy         m_topleft;         // top-left visible position (in rows and columns)
264   debug_view_xy         m_cursor;         // cursor position
265   bool               m_supports_cursor;   // does this view support a cursor?
266   bool               m_cursor_visible;   // is the cursor visible?
260267
261268   // update info
262   bool                    m_recompute;        // does this view require a recomputation?
263   UINT8                   m_update_level;     // update level; updates when this hits 0
264   bool                    m_update_pending;   // true if there is a pending update
265   bool                    m_osd_update_pending; // true if there is a pending update
266   debug_view_char *       m_viewdata;         // current array of view data
267   int                     m_viewdata_size;    // number of elements of the viewdata array
269   bool               m_recompute;      // does this view require a recomputation?
270   UINT8               m_update_level;      // update level; updates when this hits 0
271   bool               m_update_pending;   // true if there is a pending update
272   bool               m_osd_update_pending; // true if there is a pending update
273   debug_view_char *      m_viewdata;         // current array of view data
274   int                  m_viewdata_size;   // number of elements of the viewdata array
268275
269276private:
270   running_machine &       m_machine;          // machine associated with this view
277   running_machine &      m_machine;         // machine associated with this view
271278};
272279
273280
r20288r20289
295302   debug_view *append(debug_view *view);
296303
297304   // internal state
298   running_machine &   m_machine;              // reference to our machine
299   debug_view *        m_viewlist;             // list of views
305   running_machine &   m_machine;            // reference to our machine
306   debug_view *      m_viewlist;            // list of views
300307};
301308
302309
r20288r20289
326333   bool recompute();
327334
328335   // internal state
329   running_machine &   m_machine;              // reference to the machine
330   bool                m_dirty;                // true if the expression needs to be re-evaluated
331   UINT64              m_result;               // last result from the expression
332   parsed_expression   m_parsed;               // parsed expression data
333   astring             m_string;               // copy of the expression string
336   running_machine &   m_machine;            // reference to the machine
337   bool            m_dirty;            // true if the expression needs to be re-evaluated
338   UINT64            m_result;            // last result from the expression
339   parsed_expression   m_parsed;            // parsed expression data
340   astring            m_string;            // copy of the expression string
334341};
335342
336343
trunk/src/emu/debug/dvdisasm.c
r20288r20289
5454
5555debug_view_disasm_source::debug_view_disasm_source(const char *name, device_t &device)
5656   : debug_view_source(name, &device),
57      m_device(device),
58      m_disasmintf(dynamic_cast<device_disasm_interface *>(&device)),
59      m_space(device.memory().space(AS_PROGRAM))
57     m_device(device),
58     m_disasmintf(dynamic_cast<device_disasm_interface *>(&device)),
59     m_space(device.memory().space(AS_PROGRAM))
6060{
6161}
6262
r20288r20289
7272
7373debug_view_disasm::debug_view_disasm(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate)
7474   : debug_view(machine, DVT_DISASSEMBLY, osdupdate, osdprivate),
75      m_right_column(DASM_RIGHTCOL_RAW),
76      m_backwards_steps(3),
77      m_dasm_width(DEFAULT_DASM_WIDTH),
78      m_last_direct_raw(NULL),
79      m_last_direct_decrypted(NULL),
80      m_last_change_count(0),
81      m_last_pcbyte(0),
82      m_divider1(0),
83      m_divider2(0),
84      m_divider3(0),
85      m_expression(machine),
86      m_allocated(0,0),
87      m_byteaddress(NULL),
88      m_dasm(NULL)
75     m_right_column(DASM_RIGHTCOL_RAW),
76     m_backwards_steps(3),
77     m_dasm_width(DEFAULT_DASM_WIDTH),
78     m_last_direct_raw(NULL),
79     m_last_direct_decrypted(NULL),
80     m_last_change_count(0),
81     m_last_pcbyte(0),
82     m_divider1(0),
83     m_divider2(0),
84     m_divider3(0),
85     m_expression(machine),
86     m_allocated(0,0),
87     m_byteaddress(NULL),
88     m_dasm(NULL)
8989{
9090   // fail if no available sources
9191   enumerate_sources();
r20288r20289
199199            m_cursor.y = temp;
200200         break;
201201
202      case DCH_HOME:              // set the active column to the PC
202      case DCH_HOME:            // set the active column to the PC
203203      {
204204         const debug_view_disasm_source &source = downcast<const debug_view_disasm_source &>(*m_source);
205205         offs_t pc = source.m_space.address_to_byte(source.m_device.safe_pc()) & source.m_space.logbytemask();
r20288r20289
232232
233233
234234//-------------------------------------------------
235//  view_click - handle a mouse click within the
236//  current view
237//-------------------------------------------------
238
239void debug_view_disasm::view_click(const int button, const debug_view_xy& pos)
240{
241   const debug_view_xy origcursor = m_cursor;
242   m_cursor = pos;
243
244   /* cursor popup|toggle */
245   bool cursorVisible = true;
246   if (m_cursor.y == origcursor.y)
247   {
248      cursorVisible = !m_cursor_visible;
249   }
250
251   /* send a cursor changed notification */
252   begin_update();
253   m_cursor_visible = cursorVisible;
254   view_notify(VIEW_NOTIFY_CURSOR_CHANGED);
255   m_update_pending = true;
256   end_update();
257}
258
259
260//-------------------------------------------------
235261//  find_pc_backwards - back up the specified
236262//  number of instructions from the given PC
237263//-------------------------------------------------
r20288r20289
367393      m_total.x = m_divider2 + 1 + char_num * maxbytes_clamped + (maxbytes_clamped / minbytes - 1) + 1;
368394   }
369395   else if (m_right_column == DASM_RIGHTCOL_COMMENTS)
370      m_total.x = m_divider2 + 1 + 50;        // DEBUG_COMMENT_MAX_LINE_LENGTH
396      m_total.x = m_divider2 + 1 + 50;      // DEBUG_COMMENT_MAX_LINE_LENGTH
371397   else
372398      m_total.x = m_divider2 + 1;
373399
trunk/src/emu/debug/dvdisasm.h
r20288r20289
7777
7878private:
7979   // internal state
80   device_t &          m_device;               // underlying device
81   device_disasm_interface *m_disasmintf;      // disassembly interface
82   address_space &     m_space;                // address space to display
80   device_t &         m_device;            // underlying device
81   device_disasm_interface *m_disasmintf;      // disassembly interface
82   address_space &      m_space;            // address space to display
8383};
8484
8585
r20288r20289
113113   virtual void view_update();
114114   virtual void view_notify(debug_view_notification type);
115115   virtual void view_char(int chval);
116   virtual void view_click(const int button, const debug_view_xy& pos);
116117
117118private:
118119   // internal helpers
r20288r20289
122123   bool recompute(offs_t pc, int startline, int lines);
123124
124125   // internal state
125   disasm_right_column m_right_column;         // right column contents
126   UINT32              m_backwards_steps;      // number of backwards steps
127   UINT32              m_dasm_width;           // width of the disassembly area
128   UINT8 *             m_last_direct_raw;      // last direct raw value
129   UINT8 *             m_last_direct_decrypted;// last direct decrypted value
130   UINT32              m_last_change_count;    // last comment change count
131   offs_t              m_last_pcbyte;          // last PC byte value
132   int                 m_divider1, m_divider2; // left and right divider columns
133   int                 m_divider3;             // comment divider column
134   debug_view_expression m_expression;         // expression-related information
135   debug_view_xy       m_allocated;            // allocated rows/columns
136   offs_t *            m_byteaddress;          // addresses of the instructions
137   char *              m_dasm;                 // disassembled instructions
126   disasm_right_column   m_right_column;         // right column contents
127   UINT32            m_backwards_steps;      // number of backwards steps
128   UINT32            m_dasm_width;         // width of the disassembly area
129   UINT8 *            m_last_direct_raw;      // last direct raw value
130   UINT8 *            m_last_direct_decrypted;// last direct decrypted value
131   UINT32            m_last_change_count;   // last comment change count
132   offs_t            m_last_pcbyte;         // last PC byte value
133   int               m_divider1, m_divider2;   // left and right divider columns
134   int               m_divider3;            // comment divider column
135   debug_view_expression m_expression;         // expression-related information
136   debug_view_xy      m_allocated;         // allocated rows/columns
137   offs_t *         m_byteaddress;         // addresses of the instructions
138   char *            m_dasm;               // disassembled instructions
138139
139140   // constants
140141   static const int DEFAULT_DASM_LINES = 1000;
trunk/src/emu/debug/dvmemory.c
r20288r20289
7474
7575debug_view_memory_source::debug_view_memory_source(const char *name, address_space &space)
7676   : debug_view_source(name, &space.device()),
77      m_space(&space),
78      m_memintf(dynamic_cast<device_memory_interface *>(&space.device())),
79      m_base(NULL),
80      m_length(0),
81      m_offsetxor(0),
82      m_endianness(space.endianness()),
83      m_prefsize(space.data_width() / 8)
77     m_space(&space),
78     m_memintf(dynamic_cast<device_memory_interface *>(&space.device())),
79     m_base(NULL),
80     m_length(0),
81     m_offsetxor(0),
82     m_endianness(space.endianness()),
83     m_prefsize(space.data_width() / 8)
8484{
8585}
8686
8787debug_view_memory_source::debug_view_memory_source(const char *name, memory_region &region)
8888   : debug_view_source(name),
89      m_space(NULL),
90      m_memintf(NULL),
91      m_base(region),
92      m_length(region.bytes()),
93      m_offsetxor(NATIVE_ENDIAN_VALUE_LE_BE(region.width() - 1, 0)),
94      m_endianness(region.endianness()),
95      m_prefsize(MIN(region.width(), 8))
89     m_space(NULL),
90     m_memintf(NULL),
91     m_base(region),
92     m_length(region.bytes()),
93     m_offsetxor(NATIVE_ENDIAN_VALUE_LE_BE(region.width() - 1, 0)),
94     m_endianness(region.endianness()),
95     m_prefsize(MIN(region.width(), 8))
9696{
9797}
9898
9999debug_view_memory_source::debug_view_memory_source(const char *name, void *base, int element_size, int num_elements)
100100   : debug_view_source(name),
101      m_space(NULL),
102      m_memintf(NULL),
103      m_base(base),
104      m_length(element_size * num_elements),
105      m_offsetxor(0),
106      m_endianness(ENDIANNESS_NATIVE),
107      m_prefsize(MIN(element_size, 8))
101     m_space(NULL),
102     m_memintf(NULL),
103     m_base(base),
104     m_length(element_size * num_elements),
105     m_offsetxor(0),
106     m_endianness(ENDIANNESS_NATIVE),
107     m_prefsize(MIN(element_size, 8))
108108{
109109}
110110
r20288r20289
120120
121121debug_view_memory::debug_view_memory(running_machine &machine, debug_view_osd_update_func osdupdate, void *osdprivate)
122122   : debug_view(machine, DVT_MEMORY, osdupdate, osdprivate),
123      m_expression(machine),
124      m_chunks_per_row(16),
125      m_bytes_per_chunk(1),
126      m_reverse_view(false),
127      m_ascii_view(true),
128      m_no_translation(false),
129      m_maxaddr(0),
130      m_bytes_per_row(16),
131      m_byte_offset(0)
123     m_expression(machine),
124     m_chunks_per_row(16),
125     m_bytes_per_chunk(1),
126     m_reverse_view(false),
127     m_ascii_view(true),
128     m_no_translation(false),
129     m_maxaddr(0),
130     m_bytes_per_row(16),
131     m_byte_offset(0)
132132{
133133   // fail if no available sources
134134   enumerate_sources();
r20288r20289
181181         break;
182182
183183      // add pretty much anything that's not a timer (we may wish to cull other items later)
184      // also, don't trim the front of the name, it's important to know which VIA6522 we're looking at, e.g.
185      if (strncmp(itemname, "timer/", 6))
184        // also, don't trim the front of the name, it's important to know which VIA6522 we're looking at, e.g.
185        if (strncmp(itemname, "timer/", 6))
186186      {
187         name.cpy(itemname);
187            name.cpy(itemname);
188188         m_source_list.append(*auto_alloc(machine(), debug_view_memory_source(name, base, valsize, valcount)));
189189      }
190190   }
r20288r20289
426426
427427
428428//-------------------------------------------------
429//  view_click - handle a mouse click within the
430//  current view
431//-------------------------------------------------
432
433void debug_view_memory::view_click(const int button, const debug_view_xy& pos)
434{
435   const debug_view_xy origcursor = m_cursor;
436   m_cursor = pos;
437
438   /* cursor popup|toggle */
439   bool cursorVisible = true;
440   if (m_cursor.y == origcursor.y)
441   {
442      cursorVisible = !m_cursor_visible;
443   }
444
445   /* send a cursor changed notification */
446   begin_update();
447   m_cursor_visible = cursorVisible;
448   view_notify(VIEW_NOTIFY_CURSOR_CHANGED);
449   m_update_pending = true;
450   end_update();
451}
452
453
454//-------------------------------------------------
429455//  recompute - recompute the internal data and
430456//  structure of the memory view
431457//-------------------------------------------------
r20288r20289
627653      {
628654         switch (size)
629655         {
630            case 1: data = debug_read_byte(*source.m_space, offs, !m_no_translation); break;
631            case 2: data = debug_read_word(*source.m_space, offs, !m_no_translation); break;
632            case 4: data = debug_read_dword(*source.m_space, offs, !m_no_translation); break;
633            case 8: data = debug_read_qword(*source.m_space, offs, !m_no_translation); break;
656            case 1:   data = debug_read_byte(*source.m_space, offs, !m_no_translation); break;
657            case 2:   data = debug_read_word(*source.m_space, offs, !m_no_translation); break;
658            case 4:   data = debug_read_dword(*source.m_space, offs, !m_no_translation); break;
659            case 8:   data = debug_read_qword(*source.m_space, offs, !m_no_translation); break;
634660         }
635661      }
636662      return ismapped;
r20288r20289
674700   {
675701      switch (size)
676702      {
677         case 1: debug_write_byte(*source.m_space, offs, data, !m_no_translation); break;
678         case 2: debug_write_word(*source.m_space, offs, data, !m_no_translation); break;
679         case 4: debug_write_dword(*source.m_space, offs, data, !m_no_translation); break;
680         case 8: debug_write_qword(*source.m_space, offs, data, !m_no_translation); break;
703         case 1:   debug_write_byte(*source.m_space, offs, data, !m_no_translation); break;
704         case 2:   debug_write_word(*source.m_space, offs, data, !m_no_translation); break;
705         case 4:   debug_write_dword(*source.m_space, offs, data, !m_no_translation); break;
706         case 8:   debug_write_qword(*source.m_space, offs, data, !m_no_translation); break;
681707      }
682708      return;
683709   }
trunk/src/emu/debug/debugvw.c
r20288r20289
6161
6262debug_view_source::debug_view_source(const char *name, device_t *device)
6363   : m_next(NULL),
64      m_name(name),
65      m_device(device),
66      m_is_octal(false)
64     m_name(name),
65     m_device(device),
66     m_is_octal(false)
6767{
6868   device_execute_interface *intf;
6969   if (device && device->interface(intf))
r20288r20289
9292
9393debug_view_source_list::debug_view_source_list(running_machine &machine)
9494   : m_machine(machine),
95      m_head(NULL),
96      m_tail(NULL),
97      m_count(0)
95     m_head(NULL),
96     m_tail(NULL),
97     m_count(0)
9898{
9999}
100100
r20288r20289
206206
207207debug_view::debug_view(running_machine &machine, debug_view_type type, debug_view_osd_update_func osdupdate, void *osdprivate)
208208   : m_next(NULL),
209      m_type(type),
210      m_source(NULL),
211      m_source_list(machine),
212      m_osdupdate(osdupdate),
213      m_osdprivate(osdprivate),
214      m_visible(10,10),
215      m_total(10,10),
216      m_topleft(0,0),
217      m_cursor(0,0),
218      m_supports_cursor(false),
219      m_cursor_visible(false),
220      m_recompute(true),
221      m_update_level(0),
222      m_update_pending(true),
223      m_osd_update_pending(true),
224      m_viewdata(NULL),
225      m_viewdata_size(0),
226      m_machine(machine)
209     m_type(type),
210     m_source(NULL),
211     m_source_list(machine),
212     m_osdupdate(osdupdate),
213     m_osdprivate(osdprivate),
214     m_visible(10,10),
215     m_total(10,10),
216     m_topleft(0,0),
217     m_cursor(0,0),
218     m_supports_cursor(false),
219     m_cursor_visible(false),
220     m_recompute(true),
221     m_update_level(0),
222     m_update_pending(true),
223     m_osd_update_pending(true),
224     m_viewdata(NULL),
225     m_viewdata_size(0),
226     m_machine(machine)
227227{
228228   // allocate memory for the buffer
229229   m_viewdata_size = m_visible.y * m_visible.x;
r20288r20289
429429}
430430
431431
432//-------------------------------------------------
433//  view_click - handle a mouse click within the
434//  current view
435//-------------------------------------------------
432436
437void debug_view::view_click(const int button, const debug_view_xy& pos)
438{
439   // default does nothing
440}
441
442
443
433444//**************************************************************************
434445//  DEBUG VIEW MANAGER
435446//**************************************************************************
r20288r20289
440451
441452debug_view_manager::debug_view_manager(running_machine &machine)
442453   : m_machine(machine),
443      m_viewlist(NULL)
454     m_viewlist(NULL)
444455{
445456}
446457
r20288r20289
562573
563574debug_view_expression::debug_view_expression(running_machine &machine)
564575   : m_machine(machine),
565      m_dirty(true),
566      m_result(0),
567      m_parsed(debug_cpu_get_global_symtable(machine)),
568      m_string("0")
576     m_dirty(true),
577     m_result(0),
578     m_parsed(debug_cpu_get_global_symtable(machine)),
579     m_string("0")
569580{
570581}
571582

Previous 199869 Revisions Next


© 1997-2024 The MAME Team