From 1be009a431dc0b7fd98f6a5ecc3cb76d20588328 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 17 Feb 2015 16:17:01 +1100 Subject: Make QT debugger file names match class names without redundant prefix --- src/osd/modules/debugger/debugqt.c | 14 +- src/osd/modules/debugger/qt/breakpointswindow.c | 130 ++++++ src/osd/modules/debugger/qt/breakpointswindow.h | 56 +++ src/osd/modules/debugger/qt/dasmwindow.c | 258 +++++++++++ src/osd/modules/debugger/qt/dasmwindow.h | 69 +++ src/osd/modules/debugger/qt/debuggerview.c | 382 ++++++++++++++++ src/osd/modules/debugger/qt/debuggerview.h | 46 ++ .../modules/debugger/qt/debugqtbreakpointswindow.c | 130 ------ .../modules/debugger/qt/debugqtbreakpointswindow.h | 56 --- src/osd/modules/debugger/qt/debugqtdasmwindow.c | 258 ----------- src/osd/modules/debugger/qt/debugqtdasmwindow.h | 69 --- .../debugger/qt/debugqtdeviceinformationwindow.c | 132 ------ .../debugger/qt/debugqtdeviceinformationwindow.h | 53 --- src/osd/modules/debugger/qt/debugqtdeviceswindow.c | 180 -------- src/osd/modules/debugger/qt/debugqtdeviceswindow.h | 79 ---- src/osd/modules/debugger/qt/debugqtlogwindow.c | 70 --- src/osd/modules/debugger/qt/debugqtlogwindow.h | 48 -- src/osd/modules/debugger/qt/debugqtmainwindow.c | 489 --------------------- src/osd/modules/debugger/qt/debugqtmainwindow.h | 194 -------- src/osd/modules/debugger/qt/debugqtmemorywindow.c | 395 ----------------- src/osd/modules/debugger/qt/debugqtmemorywindow.h | 96 ---- src/osd/modules/debugger/qt/debugqtview.c | 382 ---------------- src/osd/modules/debugger/qt/debugqtview.h | 46 -- src/osd/modules/debugger/qt/debugqtwindow.c | 272 ------------ src/osd/modules/debugger/qt/debugqtwindow.h | 98 ----- .../modules/debugger/qt/deviceinformationwindow.c | 132 ++++++ .../modules/debugger/qt/deviceinformationwindow.h | 53 +++ src/osd/modules/debugger/qt/deviceswindow.c | 180 ++++++++ src/osd/modules/debugger/qt/deviceswindow.h | 79 ++++ src/osd/modules/debugger/qt/logwindow.c | 70 +++ src/osd/modules/debugger/qt/logwindow.h | 48 ++ src/osd/modules/debugger/qt/mainwindow.c | 489 +++++++++++++++++++++ src/osd/modules/debugger/qt/mainwindow.h | 194 ++++++++ src/osd/modules/debugger/qt/memorywindow.c | 395 +++++++++++++++++ src/osd/modules/debugger/qt/memorywindow.h | 96 ++++ src/osd/modules/debugger/qt/windowqt.c | 272 ++++++++++++ src/osd/modules/debugger/qt/windowqt.h | 98 +++++ src/osd/sdl/sdl.mak | 36 +- 38 files changed, 3072 insertions(+), 3072 deletions(-) create mode 100644 src/osd/modules/debugger/qt/breakpointswindow.c create mode 100644 src/osd/modules/debugger/qt/breakpointswindow.h create mode 100644 src/osd/modules/debugger/qt/dasmwindow.c create mode 100644 src/osd/modules/debugger/qt/dasmwindow.h create mode 100644 src/osd/modules/debugger/qt/debuggerview.c create mode 100644 src/osd/modules/debugger/qt/debuggerview.h delete mode 100644 src/osd/modules/debugger/qt/debugqtbreakpointswindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtbreakpointswindow.h delete mode 100644 src/osd/modules/debugger/qt/debugqtdasmwindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtdasmwindow.h delete mode 100644 src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.h delete mode 100644 src/osd/modules/debugger/qt/debugqtdeviceswindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtdeviceswindow.h delete mode 100644 src/osd/modules/debugger/qt/debugqtlogwindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtlogwindow.h delete mode 100644 src/osd/modules/debugger/qt/debugqtmainwindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtmainwindow.h delete mode 100644 src/osd/modules/debugger/qt/debugqtmemorywindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtmemorywindow.h delete mode 100644 src/osd/modules/debugger/qt/debugqtview.c delete mode 100644 src/osd/modules/debugger/qt/debugqtview.h delete mode 100644 src/osd/modules/debugger/qt/debugqtwindow.c delete mode 100644 src/osd/modules/debugger/qt/debugqtwindow.h create mode 100644 src/osd/modules/debugger/qt/deviceinformationwindow.c create mode 100644 src/osd/modules/debugger/qt/deviceinformationwindow.h create mode 100644 src/osd/modules/debugger/qt/deviceswindow.c create mode 100644 src/osd/modules/debugger/qt/deviceswindow.h create mode 100644 src/osd/modules/debugger/qt/logwindow.c create mode 100644 src/osd/modules/debugger/qt/logwindow.h create mode 100644 src/osd/modules/debugger/qt/mainwindow.c create mode 100644 src/osd/modules/debugger/qt/mainwindow.h create mode 100644 src/osd/modules/debugger/qt/memorywindow.c create mode 100644 src/osd/modules/debugger/qt/memorywindow.h create mode 100644 src/osd/modules/debugger/qt/windowqt.c create mode 100644 src/osd/modules/debugger/qt/windowqt.h diff --git a/src/osd/modules/debugger/debugqt.c b/src/osd/modules/debugger/debugqt.c index ce675a0180d..22614949735 100644 --- a/src/osd/modules/debugger/debugqt.c +++ b/src/osd/modules/debugger/debugqt.c @@ -26,13 +26,13 @@ #include "debugger.h" #include "modules/lib/osdobj_common.h" -#include "qt/debugqtlogwindow.h" -#include "qt/debugqtmainwindow.h" -#include "qt/debugqtdasmwindow.h" -#include "qt/debugqtmemorywindow.h" -#include "qt/debugqtbreakpointswindow.h" -#include "qt/debugqtdeviceswindow.h" -#include "qt/debugqtdeviceinformationwindow.h" +#include "qt/logwindow.h" +#include "qt/mainwindow.h" +#include "qt/dasmwindow.h" +#include "qt/memorywindow.h" +#include "qt/breakpointswindow.h" +#include "qt/deviceswindow.h" +#include "qt/deviceinformationwindow.h" class debug_qt : public osd_module, public debug_module { diff --git a/src/osd/modules/debugger/qt/breakpointswindow.c b/src/osd/modules/debugger/qt/breakpointswindow.c new file mode 100644 index 00000000000..ff14fdfb67c --- /dev/null +++ b/src/osd/modules/debugger/qt/breakpointswindow.c @@ -0,0 +1,130 @@ +#define NO_MEM_TRACKING + +#include "breakpointswindow.h" + +#include "debug/debugcon.h" +#include "debug/debugcpu.h" +#include "debug/dvbpoints.h" +#include "debug/dvwpoints.h" + + +BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) : + WindowQt(machine, NULL) +{ + setWindowTitle("Debug: All Breakpoints"); + + if (parent != NULL) + { + QPoint parentPos = parent->pos(); + setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); + } + + // + // The main frame and its input and breakpoints widgets + // + QFrame* mainWindowFrame = new QFrame(this); + + // The main breakpoints view + m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); + + // Layout + QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); + vLayout->setObjectName("vlayout"); + vLayout->setSpacing(3); + vLayout->setContentsMargins(2,2,2,2); + vLayout->addWidget(m_breakpointsView); + + setCentralWidget(mainWindowFrame); + + // + // Menu bars + // + QActionGroup* typeGroup = new QActionGroup(this); + typeGroup->setObjectName("typegroup"); + QAction* typeBreak = new QAction("Breakpoints", this); + typeBreak->setObjectName("typebreak"); + QAction* typeWatch = new QAction("Watchpoints", this); + typeWatch->setObjectName("typewatch"); + typeBreak->setCheckable(true); + typeWatch->setCheckable(true); + typeBreak->setActionGroup(typeGroup); + typeWatch->setActionGroup(typeGroup); + typeBreak->setShortcut(QKeySequence("Ctrl+1")); + typeWatch->setShortcut(QKeySequence("Ctrl+2")); + typeBreak->setChecked(true); + connect(typeGroup, SIGNAL(triggered(QAction*)), this, SLOT(typeChanged(QAction*))); + + // Assemble the options menu + QMenu* optionsMenu = menuBar()->addMenu("&Options"); + optionsMenu->addActions(typeGroup->actions()); +} + + +BreakpointsWindow::~BreakpointsWindow() +{ +} + + +void BreakpointsWindow::typeChanged(QAction* changedTo) +{ + // Clean + delete m_breakpointsView; + m_breakpointsView = NULL; + + // Create + if (changedTo->text() == "Breakpoints") + { + m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); + setWindowTitle("Debug: All Breakpoints"); + } + else if (changedTo->text() == "Watchpoints") + { + m_breakpointsView = new DebuggerView(DVT_WATCH_POINTS, m_machine, this); + setWindowTitle("Debug: All Watchpoints"); + } + + // Re-register + QVBoxLayout* layout = findChild("vlayout"); + layout->addWidget(m_breakpointsView); +} + + + +//========================================================================= +// BreakpointsWindowQtConfig +//========================================================================= +void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget) +{ + WindowQtConfig::buildFromQWidget(widget); + BreakpointsWindow* window = dynamic_cast(widget); + + QActionGroup* typeGroup = window->findChild("typegroup"); + if (typeGroup->checkedAction()->text() == "Breakpoints") + m_bwType = 0; + else if (typeGroup->checkedAction()->text() == "Watchpoints") + m_bwType = 1; +} + + +void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget) +{ + WindowQtConfig::applyToQWidget(widget); + BreakpointsWindow* window = dynamic_cast(widget); + + QActionGroup* typeGroup = window->findChild("typegroup"); + typeGroup->actions()[m_bwType]->trigger(); +} + + +void BreakpointsWindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + WindowQtConfig::addToXmlDataNode(node); + xml_set_attribute_int(node, "bwtype", m_bwType); +} + + +void BreakpointsWindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + WindowQtConfig::recoverFromXmlNode(node); + m_bwType = xml_get_attribute_int(node, "bwtype", m_bwType); +} diff --git a/src/osd/modules/debugger/qt/breakpointswindow.h b/src/osd/modules/debugger/qt/breakpointswindow.h new file mode 100644 index 00000000000..fedad23b84a --- /dev/null +++ b/src/osd/modules/debugger/qt/breakpointswindow.h @@ -0,0 +1,56 @@ +#ifndef __DEBUG_QT_BREAK_POINTS_WINDOW_H__ +#define __DEBUG_QT_BREAK_POINTS_WINDOW_H__ + +#include + +#include "debuggerview.h" +#include "windowqt.h" + + +//============================================================ +// The Breakpoints Window. +//============================================================ +class BreakpointsWindow : public WindowQt +{ + Q_OBJECT + +public: + BreakpointsWindow(running_machine* machine, QWidget* parent=NULL); + virtual ~BreakpointsWindow(); + + +private slots: + void typeChanged(QAction* changedTo); + + +private: + // Widgets + DebuggerView* m_breakpointsView; +}; + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class BreakpointsWindowQtConfig : public WindowQtConfig +{ +public: + BreakpointsWindowQtConfig() : + WindowQtConfig(WIN_TYPE_BREAK_POINTS), + m_bwType(0) + { + } + + ~BreakpointsWindowQtConfig() {} + + // Settings + int m_bwType; + + void buildFromQWidget(QWidget* widget); + void applyToQWidget(QWidget* widget); + void addToXmlDataNode(xml_data_node* node) const; + void recoverFromXmlNode(xml_data_node* node); +}; + + +#endif diff --git a/src/osd/modules/debugger/qt/dasmwindow.c b/src/osd/modules/debugger/qt/dasmwindow.c new file mode 100644 index 00000000000..b88ace8613a --- /dev/null +++ b/src/osd/modules/debugger/qt/dasmwindow.c @@ -0,0 +1,258 @@ +#define NO_MEM_TRACKING + +#include "dasmwindow.h" + +#include "debug/debugcon.h" +#include "debug/debugcpu.h" +#include "debug/dvdisasm.h" + + +DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) : + WindowQt(machine, NULL) +{ + setWindowTitle("Debug: Disassembly View"); + + if (parent != NULL) + { + QPoint parentPos = parent->pos(); + setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); + } + + // + // The main frame and its input and log widgets + // + QFrame* mainWindowFrame = new QFrame(this); + + // The top frame & groupbox that contains the input widgets + QFrame* topSubFrame = new QFrame(mainWindowFrame); + + // The input edit + m_inputEdit = new QLineEdit(topSubFrame); + connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); + + // The cpu combo box + m_cpuComboBox = new QComboBox(topSubFrame); + m_cpuComboBox->setObjectName("cpu"); + m_cpuComboBox->setMinimumWidth(300); + connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int))); + + // The main disasm window + m_dasmView = new DebuggerView(DVT_DISASSEMBLY, + m_machine, + this); + + // Force a recompute of the disassembly region + downcast(m_dasmView->view())->set_expression("curpc"); + + // Populate the combo box & set the proper cpu + populateComboBox(); + //const debug_view_source *source = mem->views[0]->view->source_for_device(curcpu); + //gtk_combo_box_set_active(zone_w, mem->views[0]->view->source_list().indexof(*source)); + //mem->views[0]->view->set_source(*source); + + + // Layout + QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); + subLayout->addWidget(m_inputEdit); + subLayout->addWidget(m_cpuComboBox); + subLayout->setSpacing(3); + subLayout->setContentsMargins(2,2,2,2); + + QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); + vLayout->setSpacing(3); + vLayout->setContentsMargins(2,2,2,2); + vLayout->addWidget(topSubFrame); + vLayout->addWidget(m_dasmView); + + setCentralWidget(mainWindowFrame); + + // + // Menu bars + // + // Create two commands + QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); + QAction* runToCursorAct = new QAction("Run To Cursor", this); + breakpointSetAct->setShortcut(Qt::Key_F9); + runToCursorAct->setShortcut(Qt::Key_F4); + connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); + connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); + + // Right bar options + QActionGroup* rightBarGroup = new QActionGroup(this); + rightBarGroup->setObjectName("rightbargroup"); + QAction* rightActRaw = new QAction("Raw Opcodes", this); + QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); + QAction* rightActComments = new QAction("Comments", this); + rightActRaw->setCheckable(true); + rightActEncrypted->setCheckable(true); + rightActComments->setCheckable(true); + rightActRaw->setActionGroup(rightBarGroup); + rightActEncrypted->setActionGroup(rightBarGroup); + rightActComments->setActionGroup(rightBarGroup); + rightActRaw->setShortcut(QKeySequence("Ctrl+R")); + rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); + rightActComments->setShortcut(QKeySequence("Ctrl+C")); + rightActRaw->setChecked(true); + connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); + + // Assemble the options menu + QMenu* optionsMenu = menuBar()->addMenu("&Options"); + optionsMenu->addAction(breakpointSetAct); + optionsMenu->addAction(runToCursorAct); + optionsMenu->addSeparator(); + optionsMenu->addActions(rightBarGroup->actions()); +} + + +DasmWindow::~DasmWindow() +{ +} + + +void DasmWindow::cpuChanged(int index) +{ + m_dasmView->view()->set_source(*m_dasmView->view()->source_list().find(index)); + m_dasmView->viewport()->update(); +} + + +void DasmWindow::expressionSubmitted() +{ + const QString expression = m_inputEdit->text(); + downcast(m_dasmView->view())->set_expression(expression.toLocal8Bit().data()); + m_dasmView->viewport()->update(); +} + + +void DasmWindow::toggleBreakpointAtCursor(bool changedTo) +{ + if (m_dasmView->view()->cursor_visible()) + { + if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) + { + offs_t address = downcast(m_dasmView->view())->selected_address(); + device_debug *cpuinfo = m_dasmView->view()->source()->device()->debug(); + + // Find an existing breakpoint at this address + INT32 bpindex = -1; + for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); + bp != NULL; + bp = bp->next()) + { + if (address == bp->address()) + { + bpindex = bp->index(); + break; + } + } + + // If none exists, add a new one + astring command; + if (bpindex == -1) + { + command.printf("bpset 0x%X", address); + } + else + { + command.printf("bpclear 0x%X", bpindex); + } + debug_console_execute_command(*m_machine, command, 1); + } + } + + refreshAll(); +} + + +void DasmWindow::runToCursor(bool changedTo) +{ + if (m_dasmView->view()->cursor_visible()) + { + if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) + { + offs_t address = downcast(m_dasmView->view())->selected_address(); + astring command; + command.printf("go 0x%X", address); + debug_console_execute_command(*m_machine, command, 1); + } + } +} + + +void DasmWindow::rightBarChanged(QAction* changedTo) +{ + debug_view_disasm* dasmView = downcast(m_dasmView->view()); + if (changedTo->text() == "Raw Opcodes") + { + dasmView->set_right_column(DASM_RIGHTCOL_RAW); + } + else if (changedTo->text() == "Encrypted Opcodes") + { + dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); + } + else if (changedTo->text() == "Comments") + { + dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); + } + m_dasmView->viewport()->update(); +} + + +void DasmWindow::populateComboBox() +{ + if (m_dasmView == NULL) + return; + + m_cpuComboBox->clear(); + for (const debug_view_source* source = m_dasmView->view()->first_source(); + source != NULL; + source = source->next()) + { + m_cpuComboBox->addItem(source->name()); + } +} + + +//========================================================================= +// DasmWindowQtConfig +//========================================================================= +void DasmWindowQtConfig::buildFromQWidget(QWidget* widget) +{ + WindowQtConfig::buildFromQWidget(widget); + DasmWindow* window = dynamic_cast(widget); + QComboBox* cpu = window->findChild("cpu"); + m_cpu = cpu->currentIndex(); + + QActionGroup* rightBarGroup = window->findChild("rightbargroup"); + if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") + m_rightBar = 0; + else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") + m_rightBar = 1; + else if (rightBarGroup->checkedAction()->text() == "Comments") + m_rightBar = 2; +} + +void DasmWindowQtConfig::applyToQWidget(QWidget* widget) +{ + WindowQtConfig::applyToQWidget(widget); + DasmWindow* window = dynamic_cast(widget); + QComboBox* cpu = window->findChild("cpu"); + cpu->setCurrentIndex(m_cpu); + + QActionGroup* rightBarGroup = window->findChild("rightbargroup"); + rightBarGroup->actions()[m_rightBar]->trigger(); +} + +void DasmWindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + WindowQtConfig::addToXmlDataNode(node); + xml_set_attribute_int(node, "cpu", m_cpu); + xml_set_attribute_int(node, "rightbar", m_rightBar); +} + +void DasmWindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + WindowQtConfig::recoverFromXmlNode(node); + m_cpu = xml_get_attribute_int(node, "cpu", m_cpu); + m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); +} diff --git a/src/osd/modules/debugger/qt/dasmwindow.h b/src/osd/modules/debugger/qt/dasmwindow.h new file mode 100644 index 00000000000..0954f80d61f --- /dev/null +++ b/src/osd/modules/debugger/qt/dasmwindow.h @@ -0,0 +1,69 @@ +#ifndef __DEBUG_QT_DASM_WINDOW_H__ +#define __DEBUG_QT_DASM_WINDOW_H__ + +#include + +#include "debuggerview.h" +#include "windowqt.h" + + +//============================================================ +// The Disassembly Window. +//============================================================ +class DasmWindow : public WindowQt +{ + Q_OBJECT + +public: + DasmWindow(running_machine* machine, QWidget* parent=NULL); + virtual ~DasmWindow(); + + +private slots: + void cpuChanged(int index); + void expressionSubmitted(); + + void toggleBreakpointAtCursor(bool changedTo); + void runToCursor(bool changedTo); + void rightBarChanged(QAction* changedTo); + + +private: + void populateComboBox(); + + +private: + // Widgets + QLineEdit* m_inputEdit; + QComboBox* m_cpuComboBox; + DebuggerView* m_dasmView; +}; + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class DasmWindowQtConfig : public WindowQtConfig +{ +public: + DasmWindowQtConfig() : + WindowQtConfig(WIN_TYPE_DASM), + m_cpu(0), + m_rightBar(0) + { + } + + ~DasmWindowQtConfig() {} + + // Settings + int m_cpu; + int m_rightBar; + + void buildFromQWidget(QWidget* widget); + void applyToQWidget(QWidget* widget); + void addToXmlDataNode(xml_data_node* node) const; + void recoverFromXmlNode(xml_data_node* node); +}; + + +#endif diff --git a/src/osd/modules/debugger/qt/debuggerview.c b/src/osd/modules/debugger/qt/debuggerview.c new file mode 100644 index 00000000000..7befa5978f8 --- /dev/null +++ b/src/osd/modules/debugger/qt/debuggerview.c @@ -0,0 +1,382 @@ +#define NO_MEM_TRACKING + +#include "debuggerview.h" + +DebuggerView::DebuggerView(const debug_view_type& type, + running_machine* machine, + QWidget* parent) : + QAbstractScrollArea(parent), + m_preferBottom(false), + m_view(NULL), + m_machine(machine) +{ + // I like setting the font per-view since it doesn't override the menuing fonts. + QFont viewFontRequest("Courier New"); + viewFontRequest.setFixedPitch(true); + viewFontRequest.setPointSize(11); + setFont(viewFontRequest); + + m_view = m_machine->debug_view().alloc_view(type, + DebuggerView::debuggerViewUpdate, + this); + + connect(verticalScrollBar(), SIGNAL(valueChanged(int)), + this, SLOT(verticalScrollSlot(int))); + connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), + this, SLOT(horizontalScrollSlot(int))); +} + + +DebuggerView::~DebuggerView() +{ + if (m_machine && m_view) + m_machine->debug_view().free_view(*m_view); +} + +// TODO: remove this version no later than January 1, 2015 +#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) +void DebuggerView::paintEvent(QPaintEvent* event) +{ + // Tell the MAME debug view how much real estate is available + QFontMetrics actualFont = fontMetrics(); + const int fontWidth = MAX(1, actualFont.width('_')); + const int fontHeight = MAX(1, actualFont.height()); + m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); + + + // Handle the scroll bars + const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; + const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; + horizontalScrollBar()->setRange(0, horizontalScrollSize); + + // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly + const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; + + const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; + const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; + bool atEnd = false; + if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) + { + atEnd = true; + } + verticalScrollBar()->setRange(0, verticalScrollSize); + if (m_preferBottom && atEnd) + { + verticalScrollBar()->setValue(verticalScrollSize); + } + + + // Draw the viewport widget + QPainter painter(viewport()); + painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); + painter.setBackgroundMode(Qt::OpaqueMode); + painter.setBackground(QColor(255,255,255)); + + // Background control + QBrush bgBrush; + bgBrush.setStyle(Qt::SolidPattern); + painter.setPen(QPen(QColor(0,0,0))); + + size_t viewDataOffset = 0; + const debug_view_xy& visibleCharDims = m_view->visible_size(); + for (int y = 0; y < visibleCharDims.y; y++) + { + for (int x = 0; x < visibleCharDims.x; x++) + { + const unsigned char textAttr = m_view->viewdata()[viewDataOffset].attrib; + + if (x == 0 || textAttr != m_view->viewdata()[viewDataOffset-1].attrib) + { + // Text color handling + QColor fgColor(0,0,0); + QColor bgColor(255,255,255); + + if(textAttr & DCA_VISITED) + { + bgColor.setRgb(0xc6, 0xe2, 0xff); + } + if(textAttr & DCA_ANCILLARY) + { + bgColor.setRgb(0xe0, 0xe0, 0xe0); + } + if(textAttr & DCA_SELECTED) + { + bgColor.setRgb(0xff, 0x80, 0x80); + } + if(textAttr & DCA_CURRENT) + { + bgColor.setRgb(0xff, 0xff, 0x00); + } + if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) + { + bgColor.setRgb(0xff,0xc0,0x80); + } + if(textAttr & DCA_CHANGED) + { + fgColor.setRgb(0xff, 0x00, 0x00); + } + if(textAttr & DCA_INVALID) + { + fgColor.setRgb(0x00, 0x00, 0xff); + } + if(textAttr & DCA_DISABLED) + { + fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, + (fgColor.green() + bgColor.green()) >> 1, + (fgColor.blue() + bgColor.blue()) >> 1); + } + if(textAttr & DCA_COMMENT) + { + fgColor.setRgb(0x00, 0x80, 0x00); + } + + bgBrush.setColor(bgColor); + painter.setBackground(bgBrush); + painter.setPen(QPen(fgColor)); + } + + // Your character is not guaranteed to take up the entire fontWidth x fontHeight, so fill before. + painter.fillRect(x*fontWidth, y*fontHeight, fontWidth, fontHeight, bgBrush); + + // There is a touchy interplay between font height, drawing difference, visible position, etc + // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. + painter.drawText(x*fontWidth, + (y*fontHeight + (fontHeight*0.80)), + QString(m_view->viewdata()[viewDataOffset].byte)); + viewDataOffset++; + } + } +} +#else +void DebuggerView::paintEvent(QPaintEvent* event) +{ + // Tell the MAME debug view how much real estate is available + QFontMetrics actualFont = fontMetrics(); + const double fontWidth = actualFont.width(QString(100, '_')) / 100.; + const int fontHeight = MAX(1, actualFont.height()); + m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); + + + // Handle the scroll bars + const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; + const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; + horizontalScrollBar()->setRange(0, horizontalScrollSize); + + // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly + const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; + + const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; + const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; + bool atEnd = false; + if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) + { + atEnd = true; + } + verticalScrollBar()->setRange(0, verticalScrollSize); + if (m_preferBottom && atEnd) + { + verticalScrollBar()->setValue(verticalScrollSize); + } + + + // Draw the viewport widget + QPainter painter(viewport()); + painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); + painter.setBackgroundMode(Qt::OpaqueMode); + painter.setBackground(QColor(255,255,255)); + + // Background control + QBrush bgBrush; + bgBrush.setStyle(Qt::SolidPattern); + painter.setPen(QPen(QColor(0,0,0))); + + size_t viewDataOffset = 0; + const debug_view_xy& visibleCharDims = m_view->visible_size(); + const debug_view_char* viewdata = m_view->viewdata(); + for (int y = 0; y < visibleCharDims.y; y++) + { + int width = 1; + for (int x = 0; x < visibleCharDims.x; viewDataOffset += width, x += width) + { + const unsigned char textAttr = viewdata[viewDataOffset].attrib; + + // Text color handling + QColor fgColor(0,0,0); + QColor bgColor(255,255,255); + + if(textAttr & DCA_VISITED) + { + bgColor.setRgb(0xc6, 0xe2, 0xff); + } + if(textAttr & DCA_ANCILLARY) + { + bgColor.setRgb(0xe0, 0xe0, 0xe0); + } + if(textAttr & DCA_SELECTED) + { + bgColor.setRgb(0xff, 0x80, 0x80); + } + if(textAttr & DCA_CURRENT) + { + bgColor.setRgb(0xff, 0xff, 0x00); + } + if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) + { + bgColor.setRgb(0xff,0xc0,0x80); + } + if(textAttr & DCA_CHANGED) + { + fgColor.setRgb(0xff, 0x00, 0x00); + } + if(textAttr & DCA_INVALID) + { + fgColor.setRgb(0x00, 0x00, 0xff); + } + if(textAttr & DCA_DISABLED) + { + fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, + (fgColor.green() + bgColor.green()) >> 1, + (fgColor.blue() + bgColor.blue()) >> 1); + } + if(textAttr & DCA_COMMENT) + { + fgColor.setRgb(0x00, 0x80, 0x00); + } + + bgBrush.setColor(bgColor); + painter.setBackground(bgBrush); + painter.setPen(QPen(fgColor)); + + QString text(QChar(viewdata[viewDataOffset].byte)); + for (width = 1; x + width < visibleCharDims.x; width++) + { + if (textAttr != viewdata[viewDataOffset + width].attrib) + break; + text.append(QChar(viewdata[viewDataOffset + width].byte)); + } + + // Your characters are not guaranteed to take up the entire length x fontWidth x fontHeight, so fill before. + painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush); + + // There is a touchy interplay between font height, drawing difference, visible position, etc + // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. + painter.drawText(x*fontWidth, (y*fontHeight + (fontHeight*0.80)), text); + } + } +} +#endif + +void DebuggerView::keyPressEvent(QKeyEvent* event) +{ + if (m_view == NULL) + return QWidget::keyPressEvent(event); + + Qt::KeyboardModifiers keyMods = QApplication::keyboardModifiers(); + const bool ctrlDown = keyMods.testFlag(Qt::ControlModifier); + + int keyPress = -1; + switch (event->key()) + { + case Qt::Key_Up: + keyPress = DCH_UP; + break; + case Qt::Key_Down: + keyPress = DCH_DOWN; + break; + case Qt::Key_Left: + keyPress = DCH_LEFT; + if (ctrlDown) keyPress = DCH_CTRLLEFT; + break; + case Qt::Key_Right: + keyPress = DCH_RIGHT; + if (ctrlDown) keyPress = DCH_CTRLRIGHT; + break; + case Qt::Key_PageUp: + keyPress = DCH_PUP; + break; + case Qt::Key_PageDown: + keyPress = DCH_PDOWN; + break; + case Qt::Key_Home: + keyPress = DCH_HOME; + if (ctrlDown) keyPress = DCH_CTRLHOME; + break; + case Qt::Key_End: + keyPress = DCH_END; + if (ctrlDown) keyPress = DCH_CTRLEND; + break; + case Qt::Key_0: keyPress = '0'; break; + case Qt::Key_1: keyPress = '1'; break; + case Qt::Key_2: keyPress = '2'; break; + case Qt::Key_3: keyPress = '3'; break; + case Qt::Key_4: keyPress = '4'; break; + case Qt::Key_5: keyPress = '5'; break; + case Qt::Key_6: keyPress = '6'; break; + case Qt::Key_7: keyPress = '7'; break; + case Qt::Key_8: keyPress = '8'; break; + case Qt::Key_9: keyPress = '9'; break; + case Qt::Key_A: keyPress = 'a'; break; + case Qt::Key_B: keyPress = 'b'; break; + case Qt::Key_C: keyPress = 'c'; break; + case Qt::Key_D: keyPress = 'd'; break; + case Qt::Key_E: keyPress = 'e'; break; + case Qt::Key_F: keyPress = 'f'; break; + default: + return QWidget::keyPressEvent(event); + } + + m_view->set_cursor_visible(true); + m_view->process_char(keyPress); + + // Catch the view up with the cursor + verticalScrollBar()->setValue(m_view->visible_position().y); + + viewport()->update(); + update(); +} + + +void DebuggerView::mousePressEvent(QMouseEvent* event) +{ + if (m_view == NULL) + return; + + if (event->button() == Qt::LeftButton) + { + QFontMetrics actualFont = fontMetrics(); + const double fontWidth = actualFont.width(QString(100, '_')) / 100.; + const int fontHeight = MAX(1, actualFont.height()); + + debug_view_xy topLeft = m_view->visible_position(); + debug_view_xy clickViewPosition; + clickViewPosition.x = topLeft.x + (event->x() / fontWidth); + clickViewPosition.y = topLeft.y + (event->y() / fontHeight); + m_view->process_click(DCK_LEFT_CLICK, clickViewPosition); + + viewport()->update(); + update(); + } +} + + +void DebuggerView::verticalScrollSlot(int value) +{ + m_view->set_visible_position(debug_view_xy(horizontalScrollBar()->value(), value)); +} + + +void DebuggerView::horizontalScrollSlot(int value) +{ + m_view->set_visible_position(debug_view_xy(value, verticalScrollBar()->value())); +} + + +void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate) +{ + // Get a handle to the DebuggerView being updated & redraw + DebuggerView* dView = (DebuggerView*)osdPrivate; + dView->verticalScrollBar()->setValue(dView->view()->visible_position().y); + dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x); + dView->viewport()->update(); + dView->update(); +} diff --git a/src/osd/modules/debugger/qt/debuggerview.h b/src/osd/modules/debugger/qt/debuggerview.h new file mode 100644 index 00000000000..2e4e8d9603a --- /dev/null +++ b/src/osd/modules/debugger/qt/debuggerview.h @@ -0,0 +1,46 @@ +#ifndef __DEBUG_QT_DEBUGGER_VIEW_H__ +#define __DEBUG_QT_DEBUGGER_VIEW_H__ + +#include + +#include "debug/debugvw.h" + + +class DebuggerView : public QAbstractScrollArea +{ + Q_OBJECT + +public: + DebuggerView(const debug_view_type& type, + running_machine* machine, + QWidget* parent=NULL); + virtual ~DebuggerView(); + + void paintEvent(QPaintEvent* event); + + // Callback to allow MAME to refresh the view + static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate); + + // Setters and accessors + void setPreferBottom(bool pb) { m_preferBottom = pb; } + debug_view* view() { return m_view; } + + +protected: + void keyPressEvent(QKeyEvent* event); + void mousePressEvent(QMouseEvent* event); + +private slots: + void verticalScrollSlot(int value); + void horizontalScrollSlot(int value); + + +private: + bool m_preferBottom; + + debug_view* m_view; + running_machine* m_machine; +}; + + +#endif diff --git a/src/osd/modules/debugger/qt/debugqtbreakpointswindow.c b/src/osd/modules/debugger/qt/debugqtbreakpointswindow.c deleted file mode 100644 index 31000e26c51..00000000000 --- a/src/osd/modules/debugger/qt/debugqtbreakpointswindow.c +++ /dev/null @@ -1,130 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtbreakpointswindow.h" - -#include "debug/debugcon.h" -#include "debug/debugcpu.h" -#include "debug/dvbpoints.h" -#include "debug/dvwpoints.h" - - -BreakpointsWindow::BreakpointsWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) -{ - setWindowTitle("Debug: All Breakpoints"); - - if (parent != NULL) - { - QPoint parentPos = parent->pos(); - setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); - } - - // - // The main frame and its input and breakpoints widgets - // - QFrame* mainWindowFrame = new QFrame(this); - - // The main breakpoints view - m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); - - // Layout - QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); - vLayout->setObjectName("vlayout"); - vLayout->setSpacing(3); - vLayout->setContentsMargins(2,2,2,2); - vLayout->addWidget(m_breakpointsView); - - setCentralWidget(mainWindowFrame); - - // - // Menu bars - // - QActionGroup* typeGroup = new QActionGroup(this); - typeGroup->setObjectName("typegroup"); - QAction* typeBreak = new QAction("Breakpoints", this); - typeBreak->setObjectName("typebreak"); - QAction* typeWatch = new QAction("Watchpoints", this); - typeWatch->setObjectName("typewatch"); - typeBreak->setCheckable(true); - typeWatch->setCheckable(true); - typeBreak->setActionGroup(typeGroup); - typeWatch->setActionGroup(typeGroup); - typeBreak->setShortcut(QKeySequence("Ctrl+1")); - typeWatch->setShortcut(QKeySequence("Ctrl+2")); - typeBreak->setChecked(true); - connect(typeGroup, SIGNAL(triggered(QAction*)), this, SLOT(typeChanged(QAction*))); - - // Assemble the options menu - QMenu* optionsMenu = menuBar()->addMenu("&Options"); - optionsMenu->addActions(typeGroup->actions()); -} - - -BreakpointsWindow::~BreakpointsWindow() -{ -} - - -void BreakpointsWindow::typeChanged(QAction* changedTo) -{ - // Clean - delete m_breakpointsView; - m_breakpointsView = NULL; - - // Create - if (changedTo->text() == "Breakpoints") - { - m_breakpointsView = new DebuggerView(DVT_BREAK_POINTS, m_machine, this); - setWindowTitle("Debug: All Breakpoints"); - } - else if (changedTo->text() == "Watchpoints") - { - m_breakpointsView = new DebuggerView(DVT_WATCH_POINTS, m_machine, this); - setWindowTitle("Debug: All Watchpoints"); - } - - // Re-register - QVBoxLayout* layout = findChild("vlayout"); - layout->addWidget(m_breakpointsView); -} - - - -//========================================================================= -// BreakpointsWindowQtConfig -//========================================================================= -void BreakpointsWindowQtConfig::buildFromQWidget(QWidget* widget) -{ - WindowQtConfig::buildFromQWidget(widget); - BreakpointsWindow* window = dynamic_cast(widget); - - QActionGroup* typeGroup = window->findChild("typegroup"); - if (typeGroup->checkedAction()->text() == "Breakpoints") - m_bwType = 0; - else if (typeGroup->checkedAction()->text() == "Watchpoints") - m_bwType = 1; -} - - -void BreakpointsWindowQtConfig::applyToQWidget(QWidget* widget) -{ - WindowQtConfig::applyToQWidget(widget); - BreakpointsWindow* window = dynamic_cast(widget); - - QActionGroup* typeGroup = window->findChild("typegroup"); - typeGroup->actions()[m_bwType]->trigger(); -} - - -void BreakpointsWindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - WindowQtConfig::addToXmlDataNode(node); - xml_set_attribute_int(node, "bwtype", m_bwType); -} - - -void BreakpointsWindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - WindowQtConfig::recoverFromXmlNode(node); - m_bwType = xml_get_attribute_int(node, "bwtype", m_bwType); -} diff --git a/src/osd/modules/debugger/qt/debugqtbreakpointswindow.h b/src/osd/modules/debugger/qt/debugqtbreakpointswindow.h deleted file mode 100644 index 0506ca37abb..00000000000 --- a/src/osd/modules/debugger/qt/debugqtbreakpointswindow.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __DEBUG_QT_BREAK_POINTS_WINDOW_H__ -#define __DEBUG_QT_BREAK_POINTS_WINDOW_H__ - -#include - -#include "debugqtview.h" -#include "debugqtwindow.h" - - -//============================================================ -// The Breakpoints Window. -//============================================================ -class BreakpointsWindow : public WindowQt -{ - Q_OBJECT - -public: - BreakpointsWindow(running_machine* machine, QWidget* parent=NULL); - virtual ~BreakpointsWindow(); - - -private slots: - void typeChanged(QAction* changedTo); - - -private: - // Widgets - DebuggerView* m_breakpointsView; -}; - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class BreakpointsWindowQtConfig : public WindowQtConfig -{ -public: - BreakpointsWindowQtConfig() : - WindowQtConfig(WIN_TYPE_BREAK_POINTS), - m_bwType(0) - { - } - - ~BreakpointsWindowQtConfig() {} - - // Settings - int m_bwType; - - void buildFromQWidget(QWidget* widget); - void applyToQWidget(QWidget* widget); - void addToXmlDataNode(xml_data_node* node) const; - void recoverFromXmlNode(xml_data_node* node); -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtdasmwindow.c b/src/osd/modules/debugger/qt/debugqtdasmwindow.c deleted file mode 100644 index ca9a5045d69..00000000000 --- a/src/osd/modules/debugger/qt/debugqtdasmwindow.c +++ /dev/null @@ -1,258 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtdasmwindow.h" - -#include "debug/debugcon.h" -#include "debug/debugcpu.h" -#include "debug/dvdisasm.h" - - -DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) -{ - setWindowTitle("Debug: Disassembly View"); - - if (parent != NULL) - { - QPoint parentPos = parent->pos(); - setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); - } - - // - // The main frame and its input and log widgets - // - QFrame* mainWindowFrame = new QFrame(this); - - // The top frame & groupbox that contains the input widgets - QFrame* topSubFrame = new QFrame(mainWindowFrame); - - // The input edit - m_inputEdit = new QLineEdit(topSubFrame); - connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); - - // The cpu combo box - m_cpuComboBox = new QComboBox(topSubFrame); - m_cpuComboBox->setObjectName("cpu"); - m_cpuComboBox->setMinimumWidth(300); - connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int))); - - // The main disasm window - m_dasmView = new DebuggerView(DVT_DISASSEMBLY, - m_machine, - this); - - // Force a recompute of the disassembly region - downcast(m_dasmView->view())->set_expression("curpc"); - - // Populate the combo box & set the proper cpu - populateComboBox(); - //const debug_view_source *source = mem->views[0]->view->source_for_device(curcpu); - //gtk_combo_box_set_active(zone_w, mem->views[0]->view->source_list().indexof(*source)); - //mem->views[0]->view->set_source(*source); - - - // Layout - QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); - subLayout->addWidget(m_inputEdit); - subLayout->addWidget(m_cpuComboBox); - subLayout->setSpacing(3); - subLayout->setContentsMargins(2,2,2,2); - - QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); - vLayout->setSpacing(3); - vLayout->setContentsMargins(2,2,2,2); - vLayout->addWidget(topSubFrame); - vLayout->addWidget(m_dasmView); - - setCentralWidget(mainWindowFrame); - - // - // Menu bars - // - // Create two commands - QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); - QAction* runToCursorAct = new QAction("Run To Cursor", this); - breakpointSetAct->setShortcut(Qt::Key_F9); - runToCursorAct->setShortcut(Qt::Key_F4); - connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); - connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); - - // Right bar options - QActionGroup* rightBarGroup = new QActionGroup(this); - rightBarGroup->setObjectName("rightbargroup"); - QAction* rightActRaw = new QAction("Raw Opcodes", this); - QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); - QAction* rightActComments = new QAction("Comments", this); - rightActRaw->setCheckable(true); - rightActEncrypted->setCheckable(true); - rightActComments->setCheckable(true); - rightActRaw->setActionGroup(rightBarGroup); - rightActEncrypted->setActionGroup(rightBarGroup); - rightActComments->setActionGroup(rightBarGroup); - rightActRaw->setShortcut(QKeySequence("Ctrl+R")); - rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); - rightActComments->setShortcut(QKeySequence("Ctrl+C")); - rightActRaw->setChecked(true); - connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); - - // Assemble the options menu - QMenu* optionsMenu = menuBar()->addMenu("&Options"); - optionsMenu->addAction(breakpointSetAct); - optionsMenu->addAction(runToCursorAct); - optionsMenu->addSeparator(); - optionsMenu->addActions(rightBarGroup->actions()); -} - - -DasmWindow::~DasmWindow() -{ -} - - -void DasmWindow::cpuChanged(int index) -{ - m_dasmView->view()->set_source(*m_dasmView->view()->source_list().find(index)); - m_dasmView->viewport()->update(); -} - - -void DasmWindow::expressionSubmitted() -{ - const QString expression = m_inputEdit->text(); - downcast(m_dasmView->view())->set_expression(expression.toLocal8Bit().data()); - m_dasmView->viewport()->update(); -} - - -void DasmWindow::toggleBreakpointAtCursor(bool changedTo) -{ - if (m_dasmView->view()->cursor_visible()) - { - if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) - { - offs_t address = downcast(m_dasmView->view())->selected_address(); - device_debug *cpuinfo = m_dasmView->view()->source()->device()->debug(); - - // Find an existing breakpoint at this address - INT32 bpindex = -1; - for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - bp != NULL; - bp = bp->next()) - { - if (address == bp->address()) - { - bpindex = bp->index(); - break; - } - } - - // If none exists, add a new one - astring command; - if (bpindex == -1) - { - command.printf("bpset 0x%X", address); - } - else - { - command.printf("bpclear 0x%X", bpindex); - } - debug_console_execute_command(*m_machine, command, 1); - } - } - - refreshAll(); -} - - -void DasmWindow::runToCursor(bool changedTo) -{ - if (m_dasmView->view()->cursor_visible()) - { - if (debug_cpu_get_visible_cpu(*m_machine) == m_dasmView->view()->source()->device()) - { - offs_t address = downcast(m_dasmView->view())->selected_address(); - astring command; - command.printf("go 0x%X", address); - debug_console_execute_command(*m_machine, command, 1); - } - } -} - - -void DasmWindow::rightBarChanged(QAction* changedTo) -{ - debug_view_disasm* dasmView = downcast(m_dasmView->view()); - if (changedTo->text() == "Raw Opcodes") - { - dasmView->set_right_column(DASM_RIGHTCOL_RAW); - } - else if (changedTo->text() == "Encrypted Opcodes") - { - dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); - } - else if (changedTo->text() == "Comments") - { - dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); - } - m_dasmView->viewport()->update(); -} - - -void DasmWindow::populateComboBox() -{ - if (m_dasmView == NULL) - return; - - m_cpuComboBox->clear(); - for (const debug_view_source* source = m_dasmView->view()->first_source(); - source != NULL; - source = source->next()) - { - m_cpuComboBox->addItem(source->name()); - } -} - - -//========================================================================= -// DasmWindowQtConfig -//========================================================================= -void DasmWindowQtConfig::buildFromQWidget(QWidget* widget) -{ - WindowQtConfig::buildFromQWidget(widget); - DasmWindow* window = dynamic_cast(widget); - QComboBox* cpu = window->findChild("cpu"); - m_cpu = cpu->currentIndex(); - - QActionGroup* rightBarGroup = window->findChild("rightbargroup"); - if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") - m_rightBar = 0; - else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") - m_rightBar = 1; - else if (rightBarGroup->checkedAction()->text() == "Comments") - m_rightBar = 2; -} - -void DasmWindowQtConfig::applyToQWidget(QWidget* widget) -{ - WindowQtConfig::applyToQWidget(widget); - DasmWindow* window = dynamic_cast(widget); - QComboBox* cpu = window->findChild("cpu"); - cpu->setCurrentIndex(m_cpu); - - QActionGroup* rightBarGroup = window->findChild("rightbargroup"); - rightBarGroup->actions()[m_rightBar]->trigger(); -} - -void DasmWindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - WindowQtConfig::addToXmlDataNode(node); - xml_set_attribute_int(node, "cpu", m_cpu); - xml_set_attribute_int(node, "rightbar", m_rightBar); -} - -void DasmWindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - WindowQtConfig::recoverFromXmlNode(node); - m_cpu = xml_get_attribute_int(node, "cpu", m_cpu); - m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); -} diff --git a/src/osd/modules/debugger/qt/debugqtdasmwindow.h b/src/osd/modules/debugger/qt/debugqtdasmwindow.h deleted file mode 100644 index 7b31b676678..00000000000 --- a/src/osd/modules/debugger/qt/debugqtdasmwindow.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef __DEBUG_QT_DASM_WINDOW_H__ -#define __DEBUG_QT_DASM_WINDOW_H__ - -#include - -#include "debugqtview.h" -#include "debugqtwindow.h" - - -//============================================================ -// The Disassembly Window. -//============================================================ -class DasmWindow : public WindowQt -{ - Q_OBJECT - -public: - DasmWindow(running_machine* machine, QWidget* parent=NULL); - virtual ~DasmWindow(); - - -private slots: - void cpuChanged(int index); - void expressionSubmitted(); - - void toggleBreakpointAtCursor(bool changedTo); - void runToCursor(bool changedTo); - void rightBarChanged(QAction* changedTo); - - -private: - void populateComboBox(); - - -private: - // Widgets - QLineEdit* m_inputEdit; - QComboBox* m_cpuComboBox; - DebuggerView* m_dasmView; -}; - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class DasmWindowQtConfig : public WindowQtConfig -{ -public: - DasmWindowQtConfig() : - WindowQtConfig(WIN_TYPE_DASM), - m_cpu(0), - m_rightBar(0) - { - } - - ~DasmWindowQtConfig() {} - - // Settings - int m_cpu; - int m_rightBar; - - void buildFromQWidget(QWidget* widget); - void applyToQWidget(QWidget* widget); - void addToXmlDataNode(xml_data_node* node) const; - void recoverFromXmlNode(xml_data_node* node); -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.c b/src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.c deleted file mode 100644 index 66baf08bdfa..00000000000 --- a/src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.c +++ /dev/null @@ -1,132 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtdeviceinformationwindow.h" - - -DeviceInformationWindow::DeviceInformationWindow(running_machine* machine, device_t* device, QWidget* parent) : - WindowQt(machine, NULL) -{ - m_device = device; - - if (parent != NULL) - { - QPoint parentPos = parent->pos(); - setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); - } - - if(m_device) - fill_device_information(); -} - - -DeviceInformationWindow::~DeviceInformationWindow() -{ -} - -void DeviceInformationWindow::fill_device_information() -{ - char title[4069]; - sprintf(title, "Debug: Device %s", m_device->tag()); - setWindowTitle(title); - - - QFrame *mainWindowFrame = new QFrame(this); - QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame); - vLayout->setObjectName("vlayout"); - vLayout->setSpacing(3); - vLayout->setContentsMargins(2,2,2,2); - - QFrame *primaryFrame = new QFrame(mainWindowFrame); - primaryFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - QGridLayout *gl1 = new QGridLayout(primaryFrame); - gl1->addWidget(new QLabel(QString("Tag"), primaryFrame), 0, 0); - gl1->addWidget(new QLabel(QString(m_device->tag()), primaryFrame), 0, 1); - gl1->addWidget(new QLabel(QString("Name"), primaryFrame), 1, 0); - gl1->addWidget(new QLabel(QString(m_device->name()), primaryFrame), 1, 1); - gl1->addWidget(new QLabel(QString("Shortname"), primaryFrame), 2, 0); - gl1->addWidget(new QLabel(QString(m_device->shortname()), primaryFrame), 2, 1); - - int cpos = 3; - device_interface *intf = m_device->first_interface(); - if(intf) { - gl1->addWidget(new QLabel(QString("Interfaces"), primaryFrame), cpos, 0); - while(intf) { - gl1->addWidget(new QLabel(QString(intf->interface_type()), primaryFrame), cpos, 1); - cpos++; - intf = intf->interface_next(); - } - } - - vLayout->addWidget(primaryFrame); - - device_memory_interface *d_memory; - if(m_device->interface(d_memory)) { - QFrame *f = new QFrame(mainWindowFrame); - f->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - QVBoxLayout *vb = new QVBoxLayout(f); - bool first = true; - for(address_spacenum i=AS_0; ihas_space(i)) { - QFrame *ff = new QFrame(f); - QHBoxLayout *hb = new QHBoxLayout(ff); - if(first) { - hb->addWidget(new QLabel("Memory maps")); - first = false; - } - hb->addStretch(); - hb->addWidget(new QLabel(d_memory->space_config(i)->name())); - vb->addWidget(ff); - } - vLayout->addWidget(f); - } - - vLayout->addStretch(); - - setCentralWidget(mainWindowFrame); -} - -void DeviceInformationWindow::set_device(const char *tag) -{ - m_device = m_machine->device(tag); - if(!m_device) - m_device = &m_machine->root_device(); - fill_device_information(); -} - -const char *DeviceInformationWindow::device_tag() const -{ - return m_device->tag(); -} - - -//========================================================================= -// DeviceInformationWindowQtConfig -//========================================================================= -void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget* widget) -{ - WindowQtConfig::buildFromQWidget(widget); - DeviceInformationWindow* window = dynamic_cast(widget); - m_device_tag = window->device_tag(); -} - - -void DeviceInformationWindowQtConfig::applyToQWidget(QWidget* widget) -{ - WindowQtConfig::applyToQWidget(widget); - DeviceInformationWindow* window = dynamic_cast(widget); - window->set_device(m_device_tag.cstr()); -} - - -void DeviceInformationWindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - WindowQtConfig::addToXmlDataNode(node); - xml_set_attribute(node, "device-tag", m_device_tag); -} - - -void DeviceInformationWindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - WindowQtConfig::recoverFromXmlNode(node); - m_device_tag = xml_get_attribute_string(node, "device-tag", ":"); -} diff --git a/src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.h b/src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.h deleted file mode 100644 index cb7ade44c00..00000000000 --- a/src/osd/modules/debugger/qt/debugqtdeviceinformationwindow.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__ -#define __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__ - -#include - -#include "debugqtwindow.h" - -//============================================================ -// The Device Information Window. -//============================================================ -class DeviceInformationWindow : public WindowQt -{ - Q_OBJECT - -public: - DeviceInformationWindow(running_machine* machine, device_t* device = NULL, QWidget* parent=NULL); - virtual ~DeviceInformationWindow(); - - void set_device(const char *tag); - const char *device_tag() const; - -private: - device_t *m_device; - - void fill_device_information(); -}; - - - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class DeviceInformationWindowQtConfig : public WindowQtConfig -{ -public: - astring m_device_tag; - - DeviceInformationWindowQtConfig() : - WindowQtConfig(WIN_TYPE_DEVICE_INFORMATION) - { - } - - ~DeviceInformationWindowQtConfig() {} - - void buildFromQWidget(QWidget* widget); - void applyToQWidget(QWidget* widget); - void addToXmlDataNode(xml_data_node* node) const; - void recoverFromXmlNode(xml_data_node* node); -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtdeviceswindow.c b/src/osd/modules/debugger/qt/debugqtdeviceswindow.c deleted file mode 100644 index 09b2fa8d7a5..00000000000 --- a/src/osd/modules/debugger/qt/debugqtdeviceswindow.c +++ /dev/null @@ -1,180 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtdeviceswindow.h" -#include "debugqtdeviceinformationwindow.h" - -DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent) -{ - m_machine = machine; -} - -DevicesWindowModel::~DevicesWindowModel() -{ -} - -QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const -{ - if(!index.isValid() || role != Qt::DisplayRole) - return QVariant(); - - device_t *dev = static_cast(index.internalPointer()); - switch(index.column()) { - case 0: return dev == &m_machine->root_device() ? QString("") : QString(dev->basetag()); - case 1: return QString(dev->name()); - } - - return QVariant(); -} - -Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const -{ - if(!index.isValid()) - return 0; - - return QAbstractItemModel::flags(index); -} - -QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if(role != Qt::DisplayRole || section < 0 || section >= 2) - return QVariant(); - return QString(section ? "Name" : "Tag"); -} - -QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const -{ - if(!hasIndex(row, column, parent)) - return QModelIndex(); - - device_t *target = NULL; - - if(!parent.isValid()) { - if(row == 0) - target = &m_machine->root_device(); - - } else { - device_t *dparent = static_cast(parent.internalPointer()); - int count = row; - for(target = dparent->first_subdevice(); count && target; target = target->next()) - count--; - } - - if(target) - return createIndex(row, column, target); - - return QModelIndex(); -} - -QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const -{ - if(!index.isValid()) - return QModelIndex(); - - device_t *dchild = static_cast(index.internalPointer()); - device_t *dparent = dchild->owner(); - - if(!dparent) - return QModelIndex(); - - device_t *dpp = dparent->owner(); - int row = 0; - if(dpp) { - for(device_t *child = dpp->first_subdevice(); child && child != dparent; child = child->next()) - row++; - } - return createIndex(row, 0, dparent); -} - -int DevicesWindowModel::rowCount(const QModelIndex &parent) const -{ - if(!parent.isValid()) - return 1; - - device_t *dparent = static_cast(parent.internalPointer()); - int count = 0; - for(device_t *child = dparent->first_subdevice(); child; child = child->next()) - count++; - - return count; -} - -int DevicesWindowModel::columnCount(const QModelIndex &parent) const -{ - return 2; -} - - - -DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL), - m_devices_model(machine) -{ - m_selected_device = NULL; - - setWindowTitle("Debug: All Devices"); - - if (parent != NULL) - { - QPoint parentPos = parent->pos(); - setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); - } - - // - // The tree widget - // - m_devices_view = new QTreeView(this); - m_devices_view->setModel(&m_devices_model); - m_devices_view->expandAll(); - m_devices_view->resizeColumnToContents(0); - connect(m_devices_view->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &,const QModelIndex &)), this, SLOT(currentRowChanged(const QModelIndex &,const QModelIndex &))); - connect(m_devices_view, SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); - setCentralWidget(m_devices_view); -} - - -DevicesWindow::~DevicesWindow() -{ -} - - -void DevicesWindow::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) -{ - m_selected_device = static_cast(current.internalPointer()); -} - - -void DevicesWindow::activated(const QModelIndex &index) -{ - device_t *dev = static_cast(index.internalPointer()); - (new DeviceInformationWindow(m_machine, dev, this))->show(); -} - - - -//========================================================================= -// DevicesWindowQtConfig -//========================================================================= -void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget) -{ - WindowQtConfig::buildFromQWidget(widget); - // DevicesWindow* window = dynamic_cast(widget); -} - - -void DevicesWindowQtConfig::applyToQWidget(QWidget* widget) -{ - WindowQtConfig::applyToQWidget(widget); - // DevicesWindow* window = dynamic_cast(widget); -} - - -void DevicesWindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - WindowQtConfig::addToXmlDataNode(node); -} - - -void DevicesWindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - WindowQtConfig::recoverFromXmlNode(node); -} diff --git a/src/osd/modules/debugger/qt/debugqtdeviceswindow.h b/src/osd/modules/debugger/qt/debugqtdeviceswindow.h deleted file mode 100644 index f541f303efd..00000000000 --- a/src/osd/modules/debugger/qt/debugqtdeviceswindow.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __DEBUG_QT_DEVICES_WINDOW_H__ -#define __DEBUG_QT_DEVICES_WINDOW_H__ - -#include - -#include "debugqtwindow.h" - - -//============================================================ -// The model for the treeview -//============================================================ - -class DevicesWindowModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - explicit DevicesWindowModel(running_machine *machine, QObject *parent = 0); - ~DevicesWindowModel(); - - QVariant data(const QModelIndex &index, int role) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - -private: - running_machine *m_machine; -}; - -//============================================================ -// The Devices Window. -//============================================================ -class DevicesWindow : public WindowQt -{ - Q_OBJECT - -public: - DevicesWindow(running_machine* machine, QWidget* parent=NULL); - virtual ~DevicesWindow(); - -public slots: - void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous); - void activated(const QModelIndex &index); - -private: - QTreeView *m_devices_view; - DevicesWindowModel m_devices_model; - device_t *m_selected_device; -}; - - - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class DevicesWindowQtConfig : public WindowQtConfig -{ -public: - DevicesWindowQtConfig() : - WindowQtConfig(WIN_TYPE_DEVICES) - { - } - - ~DevicesWindowQtConfig() {} - - void buildFromQWidget(QWidget* widget); - void applyToQWidget(QWidget* widget); - void addToXmlDataNode(xml_data_node* node) const; - void recoverFromXmlNode(xml_data_node* node); -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtlogwindow.c b/src/osd/modules/debugger/qt/debugqtlogwindow.c deleted file mode 100644 index d9bc1e12b51..00000000000 --- a/src/osd/modules/debugger/qt/debugqtlogwindow.c +++ /dev/null @@ -1,70 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtlogwindow.h" - -#include "debug/debugcon.h" -#include "debug/debugcpu.h" -#include "debug/dvdisasm.h" - - -LogWindow::LogWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) -{ - setWindowTitle("Debug: Machine Log"); - - if (parent != NULL) - { - QPoint parentPos = parent->pos(); - setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); - } - - // - // The main frame and its input and log widgets - // - QFrame* mainWindowFrame = new QFrame(this); - - // The main log view - m_logView = new DebuggerView(DVT_LOG, - m_machine, - this); - - // Layout - QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); - vLayout->setSpacing(3); - vLayout->setContentsMargins(2,2,2,2); - vLayout->addWidget(m_logView); - - setCentralWidget(mainWindowFrame); -} - - -LogWindow::~LogWindow() -{ -} - - -//========================================================================= -// LogWindowQtConfig -//========================================================================= -void LogWindowQtConfig::buildFromQWidget(QWidget* widget) -{ - WindowQtConfig::buildFromQWidget(widget); -} - - -void LogWindowQtConfig::applyToQWidget(QWidget* widget) -{ - WindowQtConfig::applyToQWidget(widget); -} - - -void LogWindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - WindowQtConfig::addToXmlDataNode(node); -} - - -void LogWindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - WindowQtConfig::recoverFromXmlNode(node); -} diff --git a/src/osd/modules/debugger/qt/debugqtlogwindow.h b/src/osd/modules/debugger/qt/debugqtlogwindow.h deleted file mode 100644 index e936a5ae647..00000000000 --- a/src/osd/modules/debugger/qt/debugqtlogwindow.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef __DEBUG_QT_LOG_WINDOW_H__ -#define __DEBUG_QT_LOG_WINDOW_H__ - -#include - -#include "debugqtview.h" -#include "debugqtwindow.h" - - -//============================================================ -// The Log Window. -//============================================================ -class LogWindow : public WindowQt -{ - Q_OBJECT - -public: - LogWindow(running_machine* machine, QWidget* parent=NULL); - virtual ~LogWindow(); - - -private: - // Widgets - DebuggerView* m_logView; -}; - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class LogWindowQtConfig : public WindowQtConfig -{ -public: - LogWindowQtConfig() : - WindowQtConfig(WIN_TYPE_LOG) - { - } - - ~LogWindowQtConfig() {} - - void buildFromQWidget(QWidget* widget); - void applyToQWidget(QWidget* widget); - void addToXmlDataNode(xml_data_node* node) const; - void recoverFromXmlNode(xml_data_node* node); -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtmainwindow.c b/src/osd/modules/debugger/qt/debugqtmainwindow.c deleted file mode 100644 index 4a5b9594636..00000000000 --- a/src/osd/modules/debugger/qt/debugqtmainwindow.c +++ /dev/null @@ -1,489 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtmainwindow.h" - -#include "debug/debugcon.h" -#include "debug/debugcpu.h" -#include "debug/dvdisasm.h" - - -MainWindow::MainWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL), - m_historyIndex(0), - m_inputHistory() -{ - setGeometry(300, 300, 1000, 600); - - // - // The main frame and its input and log widgets - // - QFrame* mainWindowFrame = new QFrame(this); - - // The input line - m_inputEdit = new QLineEdit(mainWindowFrame); - connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand())); - m_inputEdit->installEventFilter(this); - - - // The log view - m_consoleView = new DebuggerView(DVT_CONSOLE, - m_machine, - mainWindowFrame); - m_consoleView->setFocusPolicy(Qt::NoFocus); - m_consoleView->setPreferBottom(true); - - QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); - vLayout->addWidget(m_consoleView); - vLayout->addWidget(m_inputEdit); - vLayout->setSpacing(3); - vLayout->setContentsMargins(4,0,4,2); - - setCentralWidget(mainWindowFrame); - - // - // Options Menu - // - // Create two commands - QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); - QAction* runToCursorAct = new QAction("Run To Cursor", this); - breakpointSetAct->setShortcut(Qt::Key_F9); - runToCursorAct->setShortcut(Qt::Key_F4); - connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); - connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); - - // Right bar options - QActionGroup* rightBarGroup = new QActionGroup(this); - rightBarGroup->setObjectName("rightbargroup"); - QAction* rightActRaw = new QAction("Raw Opcodes", this); - QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); - QAction* rightActComments = new QAction("Comments", this); - rightActRaw->setCheckable(true); - rightActEncrypted->setCheckable(true); - rightActComments->setCheckable(true); - rightActRaw->setActionGroup(rightBarGroup); - rightActEncrypted->setActionGroup(rightBarGroup); - rightActComments->setActionGroup(rightBarGroup); - rightActRaw->setShortcut(QKeySequence("Ctrl+R")); - rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); - rightActComments->setShortcut(QKeySequence("Ctrl+C")); - rightActRaw->setChecked(true); - connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); - - // Assemble the options menu - QMenu* optionsMenu = menuBar()->addMenu("&Options"); - optionsMenu->addAction(breakpointSetAct); - optionsMenu->addAction(runToCursorAct); - optionsMenu->addSeparator(); - optionsMenu->addActions(rightBarGroup->actions()); - - // - // Images menu - // - image_interface_iterator imageIterTest(m_machine->root_device()); - if (imageIterTest.first() != NULL) - { - createImagesMenu(); - } - - // - // Dock window menu - // - QMenu* dockMenu = menuBar()->addMenu("Doc&ks"); - - setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea); - setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - - // The processor dock - QDockWidget* cpuDock = new QDockWidget("processor", this); - cpuDock->setObjectName("cpudock"); - cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea); - m_procFrame = new ProcessorDockWidget(m_machine, cpuDock); - cpuDock->setWidget(dynamic_cast(m_procFrame)); - - addDockWidget(Qt::LeftDockWidgetArea, cpuDock); - dockMenu->addAction(cpuDock->toggleViewAction()); - - // The disassembly dock - QDockWidget* dasmDock = new QDockWidget("dasm", this); - dasmDock->setObjectName("dasmdock"); - dasmDock->setAllowedAreas(Qt::TopDockWidgetArea); - m_dasmFrame = new DasmDockWidget(m_machine, dasmDock); - dasmDock->setWidget(m_dasmFrame); - - addDockWidget(Qt::TopDockWidgetArea, dasmDock); - dockMenu->addAction(dasmDock->toggleViewAction()); -} - - -MainWindow::~MainWindow() -{ -} - - -void MainWindow::setProcessor(device_t* processor) -{ - // Cpu swap - m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_for_device(processor)); - m_dasmFrame->view()->view()->set_source(*m_dasmFrame->view()->view()->source_for_device(processor)); - - // Scrollbar refresh - seems I should be able to do in the DebuggerView - m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); - m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); - - // Window title - astring title; - title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag()); - setWindowTitle(title.cstr()); -} - - -// Used to intercept the user clicking 'X' in the upper corner -void MainWindow::closeEvent(QCloseEvent* event) -{ - debugActQuit(); - - // Insure the window doesn't disappear before we get a chance to save its parameters - event->ignore(); -} - - -// Used to intercept the user hitting the up arrow in the input widget -bool MainWindow::eventFilter(QObject* obj, QEvent* event) -{ - // Only filter keypresses - QKeyEvent* keyEvent = NULL; - if (event->type() == QEvent::KeyPress) - { - keyEvent = static_cast(event); - } - else - { - return QObject::eventFilter(obj, event); - } - - // Catch up & down keys - if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down) - { - if (keyEvent->key() == Qt::Key_Up) - { - if (m_historyIndex > 0) - m_historyIndex--; - } - else if (keyEvent->key() == Qt::Key_Down) - { - if (m_historyIndex < m_inputHistory.size()) - m_historyIndex++; - } - - // Populate the input edit or clear it if you're at the end - if (m_historyIndex == m_inputHistory.size()) - { - m_inputEdit->setText(""); - } - else - { - m_inputEdit->setText(m_inputHistory[m_historyIndex]); - } - } - else if (keyEvent->key() == Qt::Key_Enter) - { - executeCommand(false); - } - else - { - return QObject::eventFilter(obj, event); - } - - return true; -} - - -void MainWindow::toggleBreakpointAtCursor(bool changedTo) -{ - debug_view_disasm* dasmView = downcast(m_dasmFrame->view()->view()); - if (dasmView->cursor_visible()) - { - if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) - { - offs_t address = downcast(dasmView)->selected_address(); - device_debug *cpuinfo = dasmView->source()->device()->debug(); - - // Find an existing breakpoint at this address - INT32 bpindex = -1; - for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); - bp != NULL; - bp = bp->next()) - { - if (address == bp->address()) - { - bpindex = bp->index(); - break; - } - } - - // If none exists, add a new one - astring command; - if (bpindex == -1) - { - command.printf("bpset 0x%X", address); - } - else - { - command.printf("bpclear 0x%X", bpindex); - } - debug_console_execute_command(*m_machine, command, 1); - } - } - - refreshAll(); -} - - -void MainWindow::runToCursor(bool changedTo) -{ - debug_view_disasm* dasmView = downcast(m_dasmFrame->view()->view()); - if (dasmView->cursor_visible()) - { - if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) - { - offs_t address = downcast(dasmView)->selected_address(); - astring command; - command.printf("go 0x%X", address); - debug_console_execute_command(*m_machine, command, 1); - } - } -} - - -void MainWindow::rightBarChanged(QAction* changedTo) -{ - debug_view_disasm* dasmView = downcast(m_dasmFrame->view()->view()); - if (changedTo->text() == "Raw Opcodes") - { - dasmView->set_right_column(DASM_RIGHTCOL_RAW); - } - else if (changedTo->text() == "Encrypted Opcodes") - { - dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); - } - else if (changedTo->text() == "Comments") - { - dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); - } - m_dasmFrame->view()->viewport()->update(); -} - - -void MainWindow::executeCommand(bool withClear) -{ - QString command = m_inputEdit->text(); - - // A blank command is a "silent step" - if (command == "") - { - debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); - return; - } - - // Send along the command - debug_console_execute_command(*m_machine, - command.toLocal8Bit().data(), - true); - - // Add history & set the index to be the top of the stack - addToHistory(command); - - // Clear out the text and reset the history pointer only if asked - if (withClear) - { - m_inputEdit->clear(); - m_historyIndex = m_inputHistory.size(); - } - - // Refresh - m_consoleView->viewport()->update(); - refreshAll(); -} - - -void MainWindow::mountImage(bool changedTo) -{ - // The image interface index was assigned to the QAction's data memeber - const int imageIndex = dynamic_cast(sender())->data().toInt(); - image_interface_iterator iter(m_machine->root_device()); - device_image_interface *img = iter.byindex(imageIndex); - if (img == NULL) - { - debug_console_printf(*m_machine, "Something is wrong with the mount menu.\n"); - refreshAll(); - return; - } - - // File dialog - QString filename = QFileDialog::getOpenFileName(this, - "Select an image file", - QDir::currentPath(), - tr("All files (*.*)")); - - if (img->load(filename.toUtf8().data()) != IMAGE_INIT_PASS) - { - debug_console_printf(*m_machine, "Image could not be mounted.\n"); - refreshAll(); - return; - } - - // Activate the unmount menu option - QAction* unmountAct = sender()->parent()->findChild("unmount"); - unmountAct->setEnabled(true); - - // Set the mount name - QMenu* parentMenuItem = dynamic_cast(sender()->parent()); - QString baseString = parentMenuItem->title(); - baseString.truncate(baseString.lastIndexOf(QString(" : "))); - const QString newTitle = baseString + QString(" : ") + QString(img->filename()); - parentMenuItem->setTitle(newTitle); - - debug_console_printf(*m_machine, "Image %s mounted successfully.\n", filename.toUtf8().data()); - refreshAll(); -} - - -void MainWindow::unmountImage(bool changedTo) -{ - // The image interface index was assigned to the QAction's data memeber - const int imageIndex = dynamic_cast(sender())->data().toInt(); - image_interface_iterator iter(m_machine->root_device()); - device_image_interface *img = iter.byindex(imageIndex); - - img->unload(); - - // Deactivate the unmount menu option - dynamic_cast(sender())->setEnabled(false); - - // Set the mount name - QMenu* parentMenuItem = dynamic_cast(sender()->parent()); - QString baseString = parentMenuItem->title(); - baseString.truncate(baseString.lastIndexOf(QString(" : "))); - const QString newTitle = baseString + QString(" : ") + QString("[empty slot]"); - parentMenuItem->setTitle(newTitle); - - debug_console_printf(*m_machine, "Image successfully unmounted.\n"); - refreshAll(); -} - - -void MainWindow::debugActClose() -{ - m_machine->schedule_exit(); -} - - -void MainWindow::addToHistory(const QString& command) -{ - if (command == "") - return; - - // Always push back when there is no previous history - if (m_inputHistory.size() == 0) - { - m_inputHistory.push_back(m_inputEdit->text()); - return; - } - - // If there is previous history, make sure it's not what you just executed - if (m_inputHistory.back() != m_inputEdit->text()) - { - m_inputHistory.push_back(m_inputEdit->text()); - } -} - - -void MainWindow::createImagesMenu() -{ - QMenu* imagesMenu = menuBar()->addMenu("&Images"); - - int interfaceIndex = 0; - image_interface_iterator iter(m_machine->root_device()); - for (device_image_interface *img = iter.first(); img != NULL; img = iter.next()) - { - astring menuName; - menuName.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[empty slot]"); - - QMenu* interfaceMenu = imagesMenu->addMenu(menuName.cstr()); - interfaceMenu->setObjectName(img->device().name()); - - QAction* mountAct = new QAction("Mount...", interfaceMenu); - QAction* unmountAct = new QAction("Unmount", interfaceMenu); - mountAct->setObjectName("mount"); - mountAct->setData(QVariant(interfaceIndex)); - unmountAct->setObjectName("unmount"); - unmountAct->setData(QVariant(interfaceIndex)); - connect(mountAct, SIGNAL(triggered(bool)), this, SLOT(mountImage(bool))); - connect(unmountAct, SIGNAL(triggered(bool)), this, SLOT(unmountImage(bool))); - - if (!img->exists()) - unmountAct->setEnabled(false); - - interfaceMenu->addAction(mountAct); - interfaceMenu->addAction(unmountAct); - - // TODO: Cassette operations - - interfaceIndex++; - } -} - - -//========================================================================= -// MainWindowQtConfig -//========================================================================= -void MainWindowQtConfig::buildFromQWidget(QWidget* widget) -{ - WindowQtConfig::buildFromQWidget(widget); - MainWindow* window = dynamic_cast(widget); - m_windowState = window->saveState(); - - QActionGroup* rightBarGroup = window->findChild("rightbargroup"); - if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") - m_rightBar = 0; - else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") - m_rightBar = 1; - else if (rightBarGroup->checkedAction()->text() == "Comments") - m_rightBar = 2; -} - - -void MainWindowQtConfig::applyToQWidget(QWidget* widget) -{ - WindowQtConfig::applyToQWidget(widget); - MainWindow* window = dynamic_cast(widget); - window->restoreState(m_windowState); - - QActionGroup* rightBarGroup = window->findChild("rightbargroup"); - rightBarGroup->actions()[m_rightBar]->trigger(); -} - - -void MainWindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - WindowQtConfig::addToXmlDataNode(node); - xml_set_attribute_int(node, "rightbar", m_rightBar); - xml_set_attribute(node, "qtwindowstate", m_windowState.toPercentEncoding().data()); -} - - -void MainWindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - WindowQtConfig::recoverFromXmlNode(node); - const char* state = xml_get_attribute_string(node, "qtwindowstate", ""); - m_windowState = QByteArray::fromPercentEncoding(state); - m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); -} - -DasmDockWidget::~DasmDockWidget() -{ -} - -ProcessorDockWidget::~ProcessorDockWidget() -{ -} diff --git a/src/osd/modules/debugger/qt/debugqtmainwindow.h b/src/osd/modules/debugger/qt/debugqtmainwindow.h deleted file mode 100644 index 864f1c0f662..00000000000 --- a/src/osd/modules/debugger/qt/debugqtmainwindow.h +++ /dev/null @@ -1,194 +0,0 @@ -#ifndef __DEBUG_QT_MAIN_WINDOW_H__ -#define __DEBUG_QT_MAIN_WINDOW_H__ - -#include -#include - -#include "debug/dvdisasm.h" - -#include "debugqtview.h" -#include "debugqtwindow.h" - -class DasmDockWidget; -class ProcessorDockWidget; - - -//============================================================ -// The Main Window. Contains processor and dasm docks. -//============================================================ -class MainWindow : public WindowQt -{ - Q_OBJECT - -public: - MainWindow(running_machine* machine, QWidget* parent=NULL); - virtual ~MainWindow(); - - void setProcessor(device_t* processor); - - -protected: - // Used to intercept the user clicking 'X' in the upper corner - void closeEvent(QCloseEvent* event); - - // Used to intercept the user hitting the up arrow in the input widget - bool eventFilter(QObject* obj, QEvent* event); - - -private slots: - void toggleBreakpointAtCursor(bool changedTo); - void runToCursor(bool changedTo); - void rightBarChanged(QAction* changedTo); - - void executeCommand(bool withClear=true); - - void mountImage(bool changedTo); - void unmountImage(bool changedTo); - - // Closing the main window actually exits the program - void debugActClose(); - - -private: - // Widgets and docks - QLineEdit* m_inputEdit; - DebuggerView* m_consoleView; - ProcessorDockWidget* m_procFrame; - DasmDockWidget* m_dasmFrame; - - // Terminal history - int m_historyIndex; - std::vector m_inputHistory; - void addToHistory(const QString& command); - - void createImagesMenu(); -}; - - -//============================================================ -// Docks with the Main Window. Disassembly. -//============================================================ -class DasmDockWidget : public QWidget -{ - Q_OBJECT - -public: - DasmDockWidget(running_machine* machine, QWidget* parent=NULL) : - QWidget(parent), - m_machine(machine) - { - m_dasmView = new DebuggerView(DVT_DISASSEMBLY, - m_machine, - this); - - // Force a recompute of the disassembly region - downcast(m_dasmView->view())->set_expression("curpc"); - - QVBoxLayout* dvLayout = new QVBoxLayout(this); - dvLayout->addWidget(m_dasmView); - dvLayout->setContentsMargins(4,0,4,0); - } - - - virtual ~DasmDockWidget(); - - - DebuggerView* view() { return m_dasmView; } - - - QSize minimumSizeHint() const - { - return QSize(150,150); - } - - - QSize sizeHint() const - { - return QSize(150,200); - } - - -private: - DebuggerView* m_dasmView; - - running_machine* m_machine; -}; - - -//============================================================ -// Docks with the Main Window. Processor information. -//============================================================ -class ProcessorDockWidget : public QWidget -{ - Q_OBJECT - -public: - ProcessorDockWidget(running_machine* machine, - QWidget* parent=NULL) : - QWidget(parent), - m_processorView(NULL), - m_machine(machine) - { - m_processorView = new DebuggerView(DVT_STATE, - m_machine, - this); - m_processorView->setFocusPolicy(Qt::NoFocus); - - QVBoxLayout* cvLayout = new QVBoxLayout(this); - cvLayout->addWidget(m_processorView); - cvLayout->setContentsMargins(4,0,4,2); - } - - - virtual ~ProcessorDockWidget(); - - - DebuggerView* view() { return m_processorView; } - - - QSize minimumSizeHint() const - { - return QSize(150,300); - } - - - QSize sizeHint() const - { - return QSize(200,300); - } - - -private: - DebuggerView* m_processorView; - - running_machine* m_machine; -}; - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class MainWindowQtConfig : public WindowQtConfig -{ -public: - MainWindowQtConfig() : - WindowQtConfig(WIN_TYPE_MAIN), - m_rightBar(0), - m_windowState() - {} - - ~MainWindowQtConfig() {} - - // Settings - int m_rightBar; - QByteArray m_windowState; - - void buildFromQWidget(QWidget* widget); - void applyToQWidget(QWidget* widget); - void addToXmlDataNode(xml_data_node* node) const; - void recoverFromXmlNode(xml_data_node* node); -}; - - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtmemorywindow.c b/src/osd/modules/debugger/qt/debugqtmemorywindow.c deleted file mode 100644 index 9c3c0c20881..00000000000 --- a/src/osd/modules/debugger/qt/debugqtmemorywindow.c +++ /dev/null @@ -1,395 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtmemorywindow.h" - -#include "debug/dvmemory.h" -#include "debug/debugcon.h" -#include "debug/debugcpu.h" - - -MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) : - WindowQt(machine, NULL) -{ - setWindowTitle("Debug: Memory View"); - - if (parent != NULL) - { - QPoint parentPos = parent->pos(); - setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); - } - - // - // The main frame and its input and log widgets - // - QFrame* mainWindowFrame = new QFrame(this); - - // The top frame & groupbox that contains the input widgets - QFrame* topSubFrame = new QFrame(mainWindowFrame); - - // The input edit - m_inputEdit = new QLineEdit(topSubFrame); - connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); - - // The memory space combo box - m_memoryComboBox = new QComboBox(topSubFrame); - m_memoryComboBox->setObjectName("memoryregion"); - m_memoryComboBox->setMinimumWidth(300); - connect(m_memoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(memoryRegionChanged(int))); - - // The main memory window - m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this); - - // Layout - QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); - subLayout->addWidget(m_inputEdit); - subLayout->addWidget(m_memoryComboBox); - subLayout->setSpacing(3); - subLayout->setContentsMargins(2,2,2,2); - - QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); - vLayout->setSpacing(3); - vLayout->setContentsMargins(2,2,2,2); - vLayout->addWidget(topSubFrame); - vLayout->addWidget(m_memTable); - - setCentralWidget(mainWindowFrame); - - // - // Menu bars - // - // Create a byte-chunk group - QActionGroup* chunkGroup = new QActionGroup(this); - chunkGroup->setObjectName("chunkgroup"); - QAction* chunkActOne = new QAction("1-byte chunks", this); - chunkActOne->setObjectName("chunkActOne"); - QAction* chunkActTwo = new QAction("2-byte chunks", this); - chunkActTwo->setObjectName("chunkActTwo"); - QAction* chunkActFour = new QAction("4-byte chunks", this); - chunkActFour->setObjectName("chunkActFour"); - chunkActOne->setCheckable(true); - chunkActTwo->setCheckable(true); - chunkActFour->setCheckable(true); - chunkActOne->setActionGroup(chunkGroup); - chunkActTwo->setActionGroup(chunkGroup); - chunkActFour->setActionGroup(chunkGroup); - chunkActOne->setShortcut(QKeySequence("Ctrl+1")); - chunkActTwo->setShortcut(QKeySequence("Ctrl+2")); - chunkActFour->setShortcut(QKeySequence("Ctrl+4")); - chunkActOne->setChecked(true); - connect(chunkGroup, SIGNAL(triggered(QAction*)), this, SLOT(chunkChanged(QAction*))); - - // Create a address display group - QActionGroup* addressGroup = new QActionGroup(this); - addressGroup->setObjectName("addressgroup"); - QAction* addressActLogical = new QAction("Logical Addresses", this); - QAction* addressActPhysical = new QAction("Physical Addresses", this); - addressActLogical->setCheckable(true); - addressActPhysical->setCheckable(true); - addressActLogical->setActionGroup(addressGroup); - addressActPhysical->setActionGroup(addressGroup); - addressActLogical->setShortcut(QKeySequence("Ctrl+G")); - addressActPhysical->setShortcut(QKeySequence("Ctrl+Y")); - addressActLogical->setChecked(true); - connect(addressGroup, SIGNAL(triggered(QAction*)), this, SLOT(addressChanged(QAction*))); - - // Create a reverse view radio - QAction* reverseAct = new QAction("Reverse View", this); - reverseAct->setObjectName("reverse"); - reverseAct->setCheckable(true); - reverseAct->setShortcut(QKeySequence("Ctrl+R")); - connect(reverseAct, SIGNAL(toggled(bool)), this, SLOT(reverseChanged(bool))); - - // Create increase and decrease bytes-per-line actions - QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this); - QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this); - increaseBplAct->setShortcut(QKeySequence("Ctrl+P")); - decreaseBplAct->setShortcut(QKeySequence("Ctrl+O")); - connect(increaseBplAct, SIGNAL(triggered(bool)), this, SLOT(increaseBytesPerLine(bool))); - connect(decreaseBplAct, SIGNAL(triggered(bool)), this, SLOT(decreaseBytesPerLine(bool))); - - // Assemble the options menu - QMenu* optionsMenu = menuBar()->addMenu("&Options"); - optionsMenu->addActions(chunkGroup->actions()); - optionsMenu->addSeparator(); - optionsMenu->addActions(addressGroup->actions()); - optionsMenu->addSeparator(); - optionsMenu->addAction(reverseAct); - optionsMenu->addSeparator(); - optionsMenu->addAction(increaseBplAct); - optionsMenu->addAction(decreaseBplAct); - - - // - // Initialize - // - populateComboBox(); - - // Set to the current CPU's memory view - setToCurrentCpu(); -} - - -MemoryWindow::~MemoryWindow() -{ -} - - -void MemoryWindow::memoryRegionChanged(int index) -{ - m_memTable->view()->set_source(*m_memTable->view()->source_list().find(index)); - m_memTable->viewport()->update(); - - // Update the chunk size radio buttons to the memory region's default - debug_view_memory* memView = downcast(m_memTable->view()); - switch(memView->bytes_per_chunk()) - { - case 1: chunkSizeMenuItem("chunkActOne")->setChecked(true); break; - case 2: chunkSizeMenuItem("chunkActTwo")->setChecked(true); break; - case 4: chunkSizeMenuItem("chunkActFour")->setChecked(true); break; - default: break; - } -} - - -void MemoryWindow::expressionSubmitted() -{ - const QString expression = m_inputEdit->text(); - downcast(m_memTable->view())->set_expression(expression.toLocal8Bit().data()); - - // Make the cursor pop - m_memTable->view()->set_cursor_visible(true); - - // Check where the cursor is and adjust the scroll accordingly - debug_view_xy cursorPosition = m_memTable->view()->cursor_position(); - // TODO: check if the region is already visible? - m_memTable->verticalScrollBar()->setValue(cursorPosition.y); - - m_memTable->update(); - m_memTable->viewport()->update(); -} - - -void MemoryWindow::chunkChanged(QAction* changedTo) -{ - debug_view_memory* memView = downcast(m_memTable->view()); - if (changedTo->text() == "1-byte chunks") - { - memView->set_bytes_per_chunk(1); - } - else if (changedTo->text() == "2-byte chunks") - { - memView->set_bytes_per_chunk(2); - } - else if (changedTo->text() == "4-byte chunks") - { - memView->set_bytes_per_chunk(4); - } - m_memTable->viewport()->update(); -} - - -void MemoryWindow::addressChanged(QAction* changedTo) -{ - debug_view_memory* memView = downcast(m_memTable->view()); - if (changedTo->text() == "Logical Addresses") - { - memView->set_physical(false); - } - else if (changedTo->text() == "Physical Addresses") - { - memView->set_physical(true); - } - m_memTable->viewport()->update(); -} - - -void MemoryWindow::reverseChanged(bool changedTo) -{ - debug_view_memory* memView = downcast(m_memTable->view()); - memView->set_reverse(changedTo); - m_memTable->viewport()->update(); -} - - -void MemoryWindow::increaseBytesPerLine(bool changedTo) -{ - debug_view_memory* memView = downcast(m_memTable->view()); - memView->set_chunks_per_row(memView->chunks_per_row() + 1); - m_memTable->viewport()->update(); -} - - -void MemoryWindow::decreaseBytesPerLine(bool checked) -{ - debug_view_memory* memView = downcast(m_memTable->view()); - memView->set_chunks_per_row(memView->chunks_per_row() - 1); - m_memTable->viewport()->update(); -} - - -void MemoryWindow::populateComboBox() -{ - if (m_memTable == NULL) - return; - - m_memoryComboBox->clear(); - for (const debug_view_source* source = m_memTable->view()->first_source(); - source != NULL; - source = source->next()) - { - m_memoryComboBox->addItem(source->name()); - } -} - - -void MemoryWindow::setToCurrentCpu() -{ - device_t* curCpu = debug_cpu_get_visible_cpu(*m_machine); - const debug_view_source *source = m_memTable->view()->source_for_device(curCpu); - const int listIndex = m_memTable->view()->source_list().indexof(*source); - m_memoryComboBox->setCurrentIndex(listIndex); -} - - -// I have a hard time storing QActions as class members. This is a substitute. -QAction* MemoryWindow::chunkSizeMenuItem(const QString& itemName) -{ - QList menus = menuBar()->findChildren(); - for (int i = 0; i < menus.length(); i++) - { - if (menus[i]->title() != "&Options") continue; - QList actions = menus[i]->actions(); - for (int j = 0; j < actions.length(); j++) - { - if (actions[j]->objectName() == itemName) - return actions[j]; - } - } - return NULL; -} - - -//========================================================================= -// DebuggerMemView -//========================================================================= -void DebuggerMemView::mousePressEvent(QMouseEvent* event) -{ - const bool leftClick = event->button() == Qt::LeftButton; - const bool rightClick = event->button() == Qt::RightButton; - - if (leftClick || rightClick) - { - QFontMetrics actualFont = fontMetrics(); - const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = MAX(1, actualFont.height()); - - debug_view_xy topLeft = view()->visible_position(); - debug_view_xy clickViewPosition; - clickViewPosition.x = topLeft.x + (event->x() / fontWidth); - clickViewPosition.y = topLeft.y + (event->y() / fontHeight); - if (leftClick) - { - view()->process_click(DCK_LEFT_CLICK, clickViewPosition); - } - else if (rightClick) - { - // Display the last known PC to write to this memory location & copy it onto the clipboard - debug_view_memory* memView = downcast(view()); - const offs_t address = memView->addressAtCursorPosition(clickViewPosition); - const debug_view_memory_source* source = downcast(memView->source()); - address_space* addressSpace = source->space(); - const int nativeDataWidth = addressSpace->data_width() / 8; - const UINT64 memValue = debug_read_memory(*addressSpace, - addressSpace->address_to_byte(address), - nativeDataWidth, - true); - const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(), - address, - memValue); - if (pc != (offs_t)(-1)) - { - // TODO: You can specify a box that the tooltip stays alive within - might be good? - const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); - QToolTip::showText(QCursor::pos(), addressAndPc, NULL); - - // Copy the PC into the clipboard as well - QClipboard *clipboard = QApplication::clipboard(); - clipboard->setText(QString("%1").arg(pc, 2, 16)); - } - else - { - QToolTip::showText(QCursor::pos(), "UNKNOWN PC", NULL); - } - } - - viewport()->update(); - update(); - } -} - - -//========================================================================= -// MemoryWindowQtConfig -//========================================================================= -void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget) -{ - WindowQtConfig::buildFromQWidget(widget); - MemoryWindow* window = dynamic_cast(widget); - QComboBox* memoryRegion = window->findChild("memoryregion"); - m_memoryRegion = memoryRegion->currentIndex(); - - QAction* reverse = window->findChild("reverse"); - m_reverse = reverse->isChecked(); - - QActionGroup* addressGroup = window->findChild("addressgroup"); - if (addressGroup->checkedAction()->text() == "Logical Addresses") - m_addressMode = 0; - else if (addressGroup->checkedAction()->text() == "Physical Addresses") - m_addressMode = 1; - - QActionGroup* chunkGroup = window->findChild("chunkgroup"); - if (chunkGroup->checkedAction()->text() == "1-byte chunks") - m_chunkSize = 0; - else if (chunkGroup->checkedAction()->text() == "2-byte chunks") - m_chunkSize = 1; - else if (chunkGroup->checkedAction()->text() == "4-byte chunks") - m_chunkSize = 2; -} - - -void MemoryWindowQtConfig::applyToQWidget(QWidget* widget) -{ - WindowQtConfig::applyToQWidget(widget); - MemoryWindow* window = dynamic_cast(widget); - QComboBox* memoryRegion = window->findChild("memoryregion"); - memoryRegion->setCurrentIndex(m_memoryRegion); - - QAction* reverse = window->findChild("reverse"); - if (m_reverse) reverse->trigger(); - - QActionGroup* addressGroup = window->findChild("addressgroup"); - addressGroup->actions()[m_addressMode]->trigger(); - - QActionGroup* chunkGroup = window->findChild("chunkgroup"); - chunkGroup->actions()[m_chunkSize]->trigger(); -} - - -void MemoryWindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - WindowQtConfig::addToXmlDataNode(node); - xml_set_attribute_int(node, "memoryregion", m_memoryRegion); - xml_set_attribute_int(node, "reverse", m_reverse); - xml_set_attribute_int(node, "addressmode", m_addressMode); - xml_set_attribute_int(node, "chunksize", m_chunkSize); -} - - -void MemoryWindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - WindowQtConfig::recoverFromXmlNode(node); - m_memoryRegion = xml_get_attribute_int(node, "memoryregion", m_memoryRegion); - m_reverse = xml_get_attribute_int(node, "reverse", m_reverse); - m_addressMode = xml_get_attribute_int(node, "addressmode", m_addressMode); - m_chunkSize = xml_get_attribute_int(node, "chunksize", m_chunkSize); -} diff --git a/src/osd/modules/debugger/qt/debugqtmemorywindow.h b/src/osd/modules/debugger/qt/debugqtmemorywindow.h deleted file mode 100644 index 1f97c414eee..00000000000 --- a/src/osd/modules/debugger/qt/debugqtmemorywindow.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef __DEBUG_QT_MEMORY_WINDOW_H__ -#define __DEBUG_QT_MEMORY_WINDOW_H__ - -#include - -#include "debugqtview.h" -#include "debugqtwindow.h" - -class DebuggerMemView; - - -//============================================================ -// The Memory Window. -//============================================================ -class MemoryWindow : public WindowQt -{ - Q_OBJECT - -public: - MemoryWindow(running_machine* machine, QWidget* parent=NULL); - virtual ~MemoryWindow(); - - -private slots: - void memoryRegionChanged(int index); - void expressionSubmitted(); - void chunkChanged(QAction* changedTo); - void addressChanged(QAction* changedTo); - void reverseChanged(bool changedTo); - void increaseBytesPerLine(bool changedTo); - void decreaseBytesPerLine(bool checked=false); - - -private: - void populateComboBox(); - void setToCurrentCpu(); - QAction* chunkSizeMenuItem(const QString& itemName); - - -private: - // Widgets - QLineEdit* m_inputEdit; - QComboBox* m_memoryComboBox; - DebuggerMemView* m_memTable; -}; - - -//========================================================================= -// The mem window gets its own debugger view to handle right click pop-ups -//========================================================================= -class DebuggerMemView : public DebuggerView -{ -public: - DebuggerMemView(const debug_view_type& type, - running_machine* machine, - QWidget* parent=NULL) - : DebuggerView(type, machine, parent) - {} - virtual ~DebuggerMemView() {} - -protected: - void mousePressEvent(QMouseEvent* event); -}; - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class MemoryWindowQtConfig : public WindowQtConfig -{ -public: - MemoryWindowQtConfig() : - WindowQtConfig(WIN_TYPE_MEMORY), - m_reverse(0), - m_addressMode(0), - m_chunkSize(0), - m_memoryRegion(0) - { - } - - ~MemoryWindowQtConfig() {} - - // Settings - int m_reverse; - int m_addressMode; - int m_chunkSize; - int m_memoryRegion; - - void buildFromQWidget(QWidget* widget); - void applyToQWidget(QWidget* widget); - void addToXmlDataNode(xml_data_node* node) const; - void recoverFromXmlNode(xml_data_node* node); -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtview.c b/src/osd/modules/debugger/qt/debugqtview.c deleted file mode 100644 index 971bd44d17a..00000000000 --- a/src/osd/modules/debugger/qt/debugqtview.c +++ /dev/null @@ -1,382 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtview.h" - -DebuggerView::DebuggerView(const debug_view_type& type, - running_machine* machine, - QWidget* parent) : - QAbstractScrollArea(parent), - m_preferBottom(false), - m_view(NULL), - m_machine(machine) -{ - // I like setting the font per-view since it doesn't override the menuing fonts. - QFont viewFontRequest("Courier New"); - viewFontRequest.setFixedPitch(true); - viewFontRequest.setPointSize(11); - setFont(viewFontRequest); - - m_view = m_machine->debug_view().alloc_view(type, - DebuggerView::debuggerViewUpdate, - this); - - connect(verticalScrollBar(), SIGNAL(valueChanged(int)), - this, SLOT(verticalScrollSlot(int))); - connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), - this, SLOT(horizontalScrollSlot(int))); -} - - -DebuggerView::~DebuggerView() -{ - if (m_machine && m_view) - m_machine->debug_view().free_view(*m_view); -} - -// TODO: remove this version no later than January 1, 2015 -#if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) -void DebuggerView::paintEvent(QPaintEvent* event) -{ - // Tell the MAME debug view how much real estate is available - QFontMetrics actualFont = fontMetrics(); - const int fontWidth = MAX(1, actualFont.width('_')); - const int fontHeight = MAX(1, actualFont.height()); - m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); - - - // Handle the scroll bars - const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; - const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; - horizontalScrollBar()->setRange(0, horizontalScrollSize); - - // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly - const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; - - const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; - const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; - bool atEnd = false; - if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) - { - atEnd = true; - } - verticalScrollBar()->setRange(0, verticalScrollSize); - if (m_preferBottom && atEnd) - { - verticalScrollBar()->setValue(verticalScrollSize); - } - - - // Draw the viewport widget - QPainter painter(viewport()); - painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); - painter.setBackgroundMode(Qt::OpaqueMode); - painter.setBackground(QColor(255,255,255)); - - // Background control - QBrush bgBrush; - bgBrush.setStyle(Qt::SolidPattern); - painter.setPen(QPen(QColor(0,0,0))); - - size_t viewDataOffset = 0; - const debug_view_xy& visibleCharDims = m_view->visible_size(); - for (int y = 0; y < visibleCharDims.y; y++) - { - for (int x = 0; x < visibleCharDims.x; x++) - { - const unsigned char textAttr = m_view->viewdata()[viewDataOffset].attrib; - - if (x == 0 || textAttr != m_view->viewdata()[viewDataOffset-1].attrib) - { - // Text color handling - QColor fgColor(0,0,0); - QColor bgColor(255,255,255); - - if(textAttr & DCA_VISITED) - { - bgColor.setRgb(0xc6, 0xe2, 0xff); - } - if(textAttr & DCA_ANCILLARY) - { - bgColor.setRgb(0xe0, 0xe0, 0xe0); - } - if(textAttr & DCA_SELECTED) - { - bgColor.setRgb(0xff, 0x80, 0x80); - } - if(textAttr & DCA_CURRENT) - { - bgColor.setRgb(0xff, 0xff, 0x00); - } - if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) - { - bgColor.setRgb(0xff,0xc0,0x80); - } - if(textAttr & DCA_CHANGED) - { - fgColor.setRgb(0xff, 0x00, 0x00); - } - if(textAttr & DCA_INVALID) - { - fgColor.setRgb(0x00, 0x00, 0xff); - } - if(textAttr & DCA_DISABLED) - { - fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, - (fgColor.green() + bgColor.green()) >> 1, - (fgColor.blue() + bgColor.blue()) >> 1); - } - if(textAttr & DCA_COMMENT) - { - fgColor.setRgb(0x00, 0x80, 0x00); - } - - bgBrush.setColor(bgColor); - painter.setBackground(bgBrush); - painter.setPen(QPen(fgColor)); - } - - // Your character is not guaranteed to take up the entire fontWidth x fontHeight, so fill before. - painter.fillRect(x*fontWidth, y*fontHeight, fontWidth, fontHeight, bgBrush); - - // There is a touchy interplay between font height, drawing difference, visible position, etc - // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. - painter.drawText(x*fontWidth, - (y*fontHeight + (fontHeight*0.80)), - QString(m_view->viewdata()[viewDataOffset].byte)); - viewDataOffset++; - } - } -} -#else -void DebuggerView::paintEvent(QPaintEvent* event) -{ - // Tell the MAME debug view how much real estate is available - QFontMetrics actualFont = fontMetrics(); - const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = MAX(1, actualFont.height()); - m_view->set_visible_size(debug_view_xy(width()/fontWidth, height()/fontHeight)); - - - // Handle the scroll bars - const int horizontalScrollCharDiff = m_view->total_size().x - m_view->visible_size().x; - const int horizontalScrollSize = horizontalScrollCharDiff < 0 ? 0 : horizontalScrollCharDiff; - horizontalScrollBar()->setRange(0, horizontalScrollSize); - - // If the horizontal scroll bar appears, make sure to adjust the vertical scrollbar accordingly - const int verticalScrollAdjust = horizontalScrollSize > 0 ? 1 : 0; - - const int verticalScrollCharDiff = m_view->total_size().y - m_view->visible_size().y; - const int verticalScrollSize = verticalScrollCharDiff < 0 ? 0 : verticalScrollCharDiff+verticalScrollAdjust; - bool atEnd = false; - if (verticalScrollBar()->value() == verticalScrollBar()->maximum()) - { - atEnd = true; - } - verticalScrollBar()->setRange(0, verticalScrollSize); - if (m_preferBottom && atEnd) - { - verticalScrollBar()->setValue(verticalScrollSize); - } - - - // Draw the viewport widget - QPainter painter(viewport()); - painter.fillRect(0, 0, width(), height(), QBrush(Qt::white)); - painter.setBackgroundMode(Qt::OpaqueMode); - painter.setBackground(QColor(255,255,255)); - - // Background control - QBrush bgBrush; - bgBrush.setStyle(Qt::SolidPattern); - painter.setPen(QPen(QColor(0,0,0))); - - size_t viewDataOffset = 0; - const debug_view_xy& visibleCharDims = m_view->visible_size(); - const debug_view_char* viewdata = m_view->viewdata(); - for (int y = 0; y < visibleCharDims.y; y++) - { - int width = 1; - for (int x = 0; x < visibleCharDims.x; viewDataOffset += width, x += width) - { - const unsigned char textAttr = viewdata[viewDataOffset].attrib; - - // Text color handling - QColor fgColor(0,0,0); - QColor bgColor(255,255,255); - - if(textAttr & DCA_VISITED) - { - bgColor.setRgb(0xc6, 0xe2, 0xff); - } - if(textAttr & DCA_ANCILLARY) - { - bgColor.setRgb(0xe0, 0xe0, 0xe0); - } - if(textAttr & DCA_SELECTED) - { - bgColor.setRgb(0xff, 0x80, 0x80); - } - if(textAttr & DCA_CURRENT) - { - bgColor.setRgb(0xff, 0xff, 0x00); - } - if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT)) - { - bgColor.setRgb(0xff,0xc0,0x80); - } - if(textAttr & DCA_CHANGED) - { - fgColor.setRgb(0xff, 0x00, 0x00); - } - if(textAttr & DCA_INVALID) - { - fgColor.setRgb(0x00, 0x00, 0xff); - } - if(textAttr & DCA_DISABLED) - { - fgColor.setRgb((fgColor.red() + bgColor.red()) >> 1, - (fgColor.green() + bgColor.green()) >> 1, - (fgColor.blue() + bgColor.blue()) >> 1); - } - if(textAttr & DCA_COMMENT) - { - fgColor.setRgb(0x00, 0x80, 0x00); - } - - bgBrush.setColor(bgColor); - painter.setBackground(bgBrush); - painter.setPen(QPen(fgColor)); - - QString text(QChar(viewdata[viewDataOffset].byte)); - for (width = 1; x + width < visibleCharDims.x; width++) - { - if (textAttr != viewdata[viewDataOffset + width].attrib) - break; - text.append(QChar(viewdata[viewDataOffset + width].byte)); - } - - // Your characters are not guaranteed to take up the entire length x fontWidth x fontHeight, so fill before. - painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush); - - // There is a touchy interplay between font height, drawing difference, visible position, etc - // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. - painter.drawText(x*fontWidth, (y*fontHeight + (fontHeight*0.80)), text); - } - } -} -#endif - -void DebuggerView::keyPressEvent(QKeyEvent* event) -{ - if (m_view == NULL) - return QWidget::keyPressEvent(event); - - Qt::KeyboardModifiers keyMods = QApplication::keyboardModifiers(); - const bool ctrlDown = keyMods.testFlag(Qt::ControlModifier); - - int keyPress = -1; - switch (event->key()) - { - case Qt::Key_Up: - keyPress = DCH_UP; - break; - case Qt::Key_Down: - keyPress = DCH_DOWN; - break; - case Qt::Key_Left: - keyPress = DCH_LEFT; - if (ctrlDown) keyPress = DCH_CTRLLEFT; - break; - case Qt::Key_Right: - keyPress = DCH_RIGHT; - if (ctrlDown) keyPress = DCH_CTRLRIGHT; - break; - case Qt::Key_PageUp: - keyPress = DCH_PUP; - break; - case Qt::Key_PageDown: - keyPress = DCH_PDOWN; - break; - case Qt::Key_Home: - keyPress = DCH_HOME; - if (ctrlDown) keyPress = DCH_CTRLHOME; - break; - case Qt::Key_End: - keyPress = DCH_END; - if (ctrlDown) keyPress = DCH_CTRLEND; - break; - case Qt::Key_0: keyPress = '0'; break; - case Qt::Key_1: keyPress = '1'; break; - case Qt::Key_2: keyPress = '2'; break; - case Qt::Key_3: keyPress = '3'; break; - case Qt::Key_4: keyPress = '4'; break; - case Qt::Key_5: keyPress = '5'; break; - case Qt::Key_6: keyPress = '6'; break; - case Qt::Key_7: keyPress = '7'; break; - case Qt::Key_8: keyPress = '8'; break; - case Qt::Key_9: keyPress = '9'; break; - case Qt::Key_A: keyPress = 'a'; break; - case Qt::Key_B: keyPress = 'b'; break; - case Qt::Key_C: keyPress = 'c'; break; - case Qt::Key_D: keyPress = 'd'; break; - case Qt::Key_E: keyPress = 'e'; break; - case Qt::Key_F: keyPress = 'f'; break; - default: - return QWidget::keyPressEvent(event); - } - - m_view->set_cursor_visible(true); - m_view->process_char(keyPress); - - // Catch the view up with the cursor - verticalScrollBar()->setValue(m_view->visible_position().y); - - viewport()->update(); - update(); -} - - -void DebuggerView::mousePressEvent(QMouseEvent* event) -{ - if (m_view == NULL) - return; - - if (event->button() == Qt::LeftButton) - { - QFontMetrics actualFont = fontMetrics(); - const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = MAX(1, actualFont.height()); - - debug_view_xy topLeft = m_view->visible_position(); - debug_view_xy clickViewPosition; - clickViewPosition.x = topLeft.x + (event->x() / fontWidth); - clickViewPosition.y = topLeft.y + (event->y() / fontHeight); - m_view->process_click(DCK_LEFT_CLICK, clickViewPosition); - - viewport()->update(); - update(); - } -} - - -void DebuggerView::verticalScrollSlot(int value) -{ - m_view->set_visible_position(debug_view_xy(horizontalScrollBar()->value(), value)); -} - - -void DebuggerView::horizontalScrollSlot(int value) -{ - m_view->set_visible_position(debug_view_xy(value, verticalScrollBar()->value())); -} - - -void DebuggerView::debuggerViewUpdate(debug_view& debugView, void* osdPrivate) -{ - // Get a handle to the DebuggerView being updated & redraw - DebuggerView* dView = (DebuggerView*)osdPrivate; - dView->verticalScrollBar()->setValue(dView->view()->visible_position().y); - dView->horizontalScrollBar()->setValue(dView->view()->visible_position().x); - dView->viewport()->update(); - dView->update(); -} diff --git a/src/osd/modules/debugger/qt/debugqtview.h b/src/osd/modules/debugger/qt/debugqtview.h deleted file mode 100644 index 16ce1f48fbd..00000000000 --- a/src/osd/modules/debugger/qt/debugqtview.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __DEBUG_QT_VIEW_H__ -#define __DEBUG_QT_VIEW_H__ - -#include - -#include "debug/debugvw.h" - - -class DebuggerView : public QAbstractScrollArea -{ - Q_OBJECT - -public: - DebuggerView(const debug_view_type& type, - running_machine* machine, - QWidget* parent=NULL); - virtual ~DebuggerView(); - - void paintEvent(QPaintEvent* event); - - // Callback to allow MAME to refresh the view - static void debuggerViewUpdate(debug_view& debugView, void* osdPrivate); - - // Setters and accessors - void setPreferBottom(bool pb) { m_preferBottom = pb; } - debug_view* view() { return m_view; } - - -protected: - void keyPressEvent(QKeyEvent* event); - void mousePressEvent(QMouseEvent* event); - -private slots: - void verticalScrollSlot(int value); - void horizontalScrollSlot(int value); - - -private: - bool m_preferBottom; - - debug_view* m_view; - running_machine* m_machine; -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/debugqtwindow.c b/src/osd/modules/debugger/qt/debugqtwindow.c deleted file mode 100644 index 9570ad83d5e..00000000000 --- a/src/osd/modules/debugger/qt/debugqtwindow.c +++ /dev/null @@ -1,272 +0,0 @@ -#define NO_MEM_TRACKING - -#include "debugqtwindow.h" -#include "debugqtlogwindow.h" -#include "debugqtdasmwindow.h" -#include "debugqtmemorywindow.h" -#include "debugqtbreakpointswindow.h" -#include "debugqtdeviceswindow.h" - -bool WindowQt::s_refreshAll = false; -bool WindowQt::s_hideAll = false; - - -// Since all debug windows are intended to be top-level, this inherited -// constructor is always called with a NULL parent. The passed-in parent widget, -// however, is often used to place each child window & the code to do this can -// be found in most of the inherited classes. - -WindowQt::WindowQt(running_machine* machine, QWidget* parent) : - QMainWindow(parent), - m_machine(machine) -{ - setAttribute(Qt::WA_DeleteOnClose, true); - - // The Debug menu bar - QAction* debugActOpenMemory = new QAction("New &Memory Window", this); - debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M")); - connect(debugActOpenMemory, SIGNAL(triggered()), this, SLOT(debugActOpenMemory())); - - QAction* debugActOpenDasm = new QAction("New &Dasm Window", this); - debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D")); - connect(debugActOpenDasm, SIGNAL(triggered()), this, SLOT(debugActOpenDasm())); - - QAction* debugActOpenLog = new QAction("New &Log Window", this); - debugActOpenLog->setShortcut(QKeySequence("Ctrl+L")); - connect(debugActOpenLog, SIGNAL(triggered()), this, SLOT(debugActOpenLog())); - - QAction* debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this); - debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B")); - connect(debugActOpenPoints, SIGNAL(triggered()), this, SLOT(debugActOpenPoints())); - - QAction* debugActOpenDevices = new QAction("New D&evices Window", this); - debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D")); - connect(debugActOpenDevices, SIGNAL(triggered()), this, SLOT(debugActOpenDevices())); - - QAction* dbgActRun = new QAction("Run", this); - dbgActRun->setShortcut(Qt::Key_F5); - connect(dbgActRun, SIGNAL(triggered()), this, SLOT(debugActRun())); - - QAction* dbgActRunAndHide = new QAction("Run And Hide Debugger", this); - dbgActRunAndHide->setShortcut(Qt::Key_F12); - connect(dbgActRunAndHide, SIGNAL(triggered()), this, SLOT(debugActRunAndHide())); - - QAction* dbgActRunToNextCpu = new QAction("Run to Next CPU", this); - dbgActRunToNextCpu->setShortcut(Qt::Key_F6); - connect(dbgActRunToNextCpu, SIGNAL(triggered()), this, SLOT(debugActRunToNextCpu())); - - QAction* dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this); - dbgActRunNextInt->setShortcut(Qt::Key_F7); - connect(dbgActRunNextInt, SIGNAL(triggered()), this, SLOT(debugActRunNextInt())); - - QAction* dbgActRunNextVBlank = new QAction("Run to Next VBlank", this); - dbgActRunNextVBlank->setShortcut(Qt::Key_F8); - connect(dbgActRunNextVBlank, SIGNAL(triggered()), this, SLOT(debugActRunNextVBlank())); - - QAction* dbgActStepInto = new QAction("Step Into", this); - dbgActStepInto->setShortcut(Qt::Key_F11); - connect(dbgActStepInto, SIGNAL(triggered()), this, SLOT(debugActStepInto())); - - QAction* dbgActStepOver = new QAction("Step Over", this); - dbgActStepOver->setShortcut(Qt::Key_F10); - connect(dbgActStepOver, SIGNAL(triggered()), this, SLOT(debugActStepOver())); - - QAction* dbgActStepOut = new QAction("Step Out", this); - dbgActStepOut->setShortcut(QKeySequence("Shift+F11")); - connect(dbgActStepOut, SIGNAL(triggered()), this, SLOT(debugActStepOut())); - - QAction* dbgActSoftReset = new QAction("Soft Reset", this); - dbgActSoftReset->setShortcut(Qt::Key_F3); - connect(dbgActSoftReset, SIGNAL(triggered()), this, SLOT(debugActSoftReset())); - - QAction* dbgActHardReset = new QAction("Hard Reset", this); - dbgActHardReset->setShortcut(QKeySequence("Shift+F3")); - connect(dbgActHardReset, SIGNAL(triggered()), this, SLOT(debugActHardReset())); - - QAction* dbgActClose = new QAction("Close &Window", this); - dbgActClose->setShortcut(QKeySequence::Close); - connect(dbgActClose, SIGNAL(triggered()), this, SLOT(debugActClose())); - - QAction* dbgActQuit = new QAction("&Quit", this); - dbgActQuit->setShortcut(QKeySequence::Quit); - connect(dbgActQuit, SIGNAL(triggered()), this, SLOT(debugActQuit())); - - // Construct the menu - QMenu* debugMenu = menuBar()->addMenu("&Debug"); - debugMenu->addAction(debugActOpenMemory); - debugMenu->addAction(debugActOpenDasm); - debugMenu->addAction(debugActOpenLog); - debugMenu->addAction(debugActOpenPoints); - debugMenu->addAction(debugActOpenDevices); - debugMenu->addSeparator(); - debugMenu->addAction(dbgActRun); - debugMenu->addAction(dbgActRunAndHide); - debugMenu->addAction(dbgActRunToNextCpu); - debugMenu->addAction(dbgActRunNextInt); - debugMenu->addAction(dbgActRunNextVBlank); - debugMenu->addSeparator(); - debugMenu->addAction(dbgActStepInto); - debugMenu->addAction(dbgActStepOver); - debugMenu->addAction(dbgActStepOut); - debugMenu->addSeparator(); - debugMenu->addAction(dbgActSoftReset); - debugMenu->addAction(dbgActHardReset); - debugMenu->addSeparator(); - debugMenu->addAction(dbgActClose); - debugMenu->addAction(dbgActQuit); -} - - -WindowQt::~WindowQt() -{ -} - -void WindowQt::debugActOpenMemory() -{ - MemoryWindow* foo = new MemoryWindow(m_machine, this); - // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon - // foo->setWindowFlags(Qt::Dialog); - // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); - foo->show(); -} - - -void WindowQt::debugActOpenDasm() -{ - DasmWindow* foo = new DasmWindow(m_machine, this); - // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon - // foo->setWindowFlags(Qt::Dialog); - // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); - foo->show(); -} - - -void WindowQt::debugActOpenLog() -{ - LogWindow* foo = new LogWindow(m_machine, this); - // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon - // foo->setWindowFlags(Qt::Dialog); - // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); - foo->show(); -} - - -void WindowQt::debugActOpenPoints() -{ - BreakpointsWindow* foo = new BreakpointsWindow(m_machine, this); - // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon - // foo->setWindowFlags(Qt::Dialog); - // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); - foo->show(); -} - - -void WindowQt::debugActOpenDevices() -{ - DevicesWindow* foo = new DevicesWindow(m_machine, this); - // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon - // foo->setWindowFlags(Qt::Dialog); - // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); - foo->show(); -} - - -void WindowQt::debugActRun() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); -} - -void WindowQt::debugActRunAndHide() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); - hideAll(); -} - -void WindowQt::debugActRunToNextCpu() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device(); -} - -void WindowQt::debugActRunNextInt() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt(); -} - -void WindowQt::debugActRunNextVBlank() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank(); -} - -void WindowQt::debugActStepInto() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); -} - -void WindowQt::debugActStepOver() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over(); -} - -void WindowQt::debugActStepOut() -{ - debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out(); -} - -void WindowQt::debugActSoftReset() -{ - m_machine->schedule_soft_reset(); - debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); -} - -void WindowQt::debugActHardReset() -{ - m_machine->schedule_hard_reset(); -} - -void WindowQt::debugActClose() -{ - close(); -} - -void WindowQt::debugActQuit() -{ - m_machine->schedule_exit(); -} - - -//========================================================================= -// WindowQtConfig -//========================================================================= -void WindowQtConfig::buildFromQWidget(QWidget* widget) -{ - m_position.setX(widget->geometry().topLeft().x()); - m_position.setY(widget->geometry().topLeft().y()); - m_size.setX(widget->size().width()); - m_size.setY(widget->size().height()); -} - - -void WindowQtConfig::applyToQWidget(QWidget* widget) -{ - widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y()); -} - - -void WindowQtConfig::addToXmlDataNode(xml_data_node* node) const -{ - xml_set_attribute_int(node, "type", m_type); - xml_set_attribute_int(node, "position_x", m_position.x()); - xml_set_attribute_int(node, "position_y", m_position.y()); - xml_set_attribute_int(node, "size_x", m_size.x()); - xml_set_attribute_int(node, "size_y", m_size.y()); -} - - -void WindowQtConfig::recoverFromXmlNode(xml_data_node* node) -{ - m_size.setX(xml_get_attribute_int(node, "size_x", m_size.x())); - m_size.setY(xml_get_attribute_int(node, "size_y", m_size.y())); - m_position.setX(xml_get_attribute_int(node, "position_x", m_position.x())); - m_position.setY(xml_get_attribute_int(node, "position_y", m_position.y())); - m_type = (WindowQtConfig::WindowType)xml_get_attribute_int(node, "type", m_type); -} diff --git a/src/osd/modules/debugger/qt/debugqtwindow.h b/src/osd/modules/debugger/qt/debugqtwindow.h deleted file mode 100644 index ecaf1c24217..00000000000 --- a/src/osd/modules/debugger/qt/debugqtwindow.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __DEBUG_QT_WINDOW_H__ -#define __DEBUG_QT_WINDOW_H__ - -#include - -#include "emu.h" -#include "config.h" -#include "debugger.h" - - -//============================================================ -// The Qt window that everyone derives from. -//============================================================ -class WindowQt : public QMainWindow -{ - Q_OBJECT - -public: - WindowQt(running_machine* machine, QWidget* parent=NULL); - virtual ~WindowQt(); - - // The interface to an all-window refresh - void refreshAll() { s_refreshAll = true; } - bool wantsRefresh() { return s_refreshAll; } - void clearRefreshFlag() { s_refreshAll = false; } - - void hideAll() { s_hideAll = true; } - bool wantsHide() { return s_hideAll; } - void clearHideFlag() { s_hideAll = false; } - - -protected slots: - void debugActOpenMemory(); - void debugActOpenDasm(); - void debugActOpenLog(); - void debugActOpenPoints(); - void debugActOpenDevices(); - void debugActRun(); - void debugActRunAndHide(); - void debugActRunToNextCpu(); - void debugActRunNextInt(); - void debugActRunNextVBlank(); - void debugActStepInto(); - void debugActStepOver(); - void debugActStepOut(); - void debugActSoftReset(); - void debugActHardReset(); - virtual void debugActClose(); - void debugActQuit(); - - -protected: - running_machine* m_machine; - - static bool s_refreshAll; - static bool s_hideAll; -}; - - -//========================================================================= -// A way to store the configuration of a window long enough to read/write. -//========================================================================= -class WindowQtConfig -{ -public: - enum WindowType - { - WIN_TYPE_UNKNOWN, - WIN_TYPE_MAIN, - WIN_TYPE_MEMORY, - WIN_TYPE_DASM, - WIN_TYPE_LOG, - WIN_TYPE_BREAK_POINTS, - WIN_TYPE_DEVICES, - WIN_TYPE_DEVICE_INFORMATION - }; - -public: - WindowQtConfig(const WindowType& type=WIN_TYPE_UNKNOWN) : - m_type(type), - m_size(800, 600), - m_position(120, 120) - {} - virtual ~WindowQtConfig() {} - - // Settings - WindowType m_type; - QPoint m_size; - QPoint m_position; - - virtual void buildFromQWidget(QWidget* widget); - virtual void applyToQWidget(QWidget* widget); - virtual void addToXmlDataNode(xml_data_node* node) const; - virtual void recoverFromXmlNode(xml_data_node* node); -}; - - -#endif diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.c b/src/osd/modules/debugger/qt/deviceinformationwindow.c new file mode 100644 index 00000000000..cc2945b7613 --- /dev/null +++ b/src/osd/modules/debugger/qt/deviceinformationwindow.c @@ -0,0 +1,132 @@ +#define NO_MEM_TRACKING + +#include "deviceinformationwindow.h" + + +DeviceInformationWindow::DeviceInformationWindow(running_machine* machine, device_t* device, QWidget* parent) : + WindowQt(machine, NULL) +{ + m_device = device; + + if (parent != NULL) + { + QPoint parentPos = parent->pos(); + setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); + } + + if(m_device) + fill_device_information(); +} + + +DeviceInformationWindow::~DeviceInformationWindow() +{ +} + +void DeviceInformationWindow::fill_device_information() +{ + char title[4069]; + sprintf(title, "Debug: Device %s", m_device->tag()); + setWindowTitle(title); + + + QFrame *mainWindowFrame = new QFrame(this); + QVBoxLayout *vLayout = new QVBoxLayout(mainWindowFrame); + vLayout->setObjectName("vlayout"); + vLayout->setSpacing(3); + vLayout->setContentsMargins(2,2,2,2); + + QFrame *primaryFrame = new QFrame(mainWindowFrame); + primaryFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + QGridLayout *gl1 = new QGridLayout(primaryFrame); + gl1->addWidget(new QLabel(QString("Tag"), primaryFrame), 0, 0); + gl1->addWidget(new QLabel(QString(m_device->tag()), primaryFrame), 0, 1); + gl1->addWidget(new QLabel(QString("Name"), primaryFrame), 1, 0); + gl1->addWidget(new QLabel(QString(m_device->name()), primaryFrame), 1, 1); + gl1->addWidget(new QLabel(QString("Shortname"), primaryFrame), 2, 0); + gl1->addWidget(new QLabel(QString(m_device->shortname()), primaryFrame), 2, 1); + + int cpos = 3; + device_interface *intf = m_device->first_interface(); + if(intf) { + gl1->addWidget(new QLabel(QString("Interfaces"), primaryFrame), cpos, 0); + while(intf) { + gl1->addWidget(new QLabel(QString(intf->interface_type()), primaryFrame), cpos, 1); + cpos++; + intf = intf->interface_next(); + } + } + + vLayout->addWidget(primaryFrame); + + device_memory_interface *d_memory; + if(m_device->interface(d_memory)) { + QFrame *f = new QFrame(mainWindowFrame); + f->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + QVBoxLayout *vb = new QVBoxLayout(f); + bool first = true; + for(address_spacenum i=AS_0; ihas_space(i)) { + QFrame *ff = new QFrame(f); + QHBoxLayout *hb = new QHBoxLayout(ff); + if(first) { + hb->addWidget(new QLabel("Memory maps")); + first = false; + } + hb->addStretch(); + hb->addWidget(new QLabel(d_memory->space_config(i)->name())); + vb->addWidget(ff); + } + vLayout->addWidget(f); + } + + vLayout->addStretch(); + + setCentralWidget(mainWindowFrame); +} + +void DeviceInformationWindow::set_device(const char *tag) +{ + m_device = m_machine->device(tag); + if(!m_device) + m_device = &m_machine->root_device(); + fill_device_information(); +} + +const char *DeviceInformationWindow::device_tag() const +{ + return m_device->tag(); +} + + +//========================================================================= +// DeviceInformationWindowQtConfig +//========================================================================= +void DeviceInformationWindowQtConfig::buildFromQWidget(QWidget* widget) +{ + WindowQtConfig::buildFromQWidget(widget); + DeviceInformationWindow* window = dynamic_cast(widget); + m_device_tag = window->device_tag(); +} + + +void DeviceInformationWindowQtConfig::applyToQWidget(QWidget* widget) +{ + WindowQtConfig::applyToQWidget(widget); + DeviceInformationWindow* window = dynamic_cast(widget); + window->set_device(m_device_tag.cstr()); +} + + +void DeviceInformationWindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + WindowQtConfig::addToXmlDataNode(node); + xml_set_attribute(node, "device-tag", m_device_tag); +} + + +void DeviceInformationWindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + WindowQtConfig::recoverFromXmlNode(node); + m_device_tag = xml_get_attribute_string(node, "device-tag", ":"); +} diff --git a/src/osd/modules/debugger/qt/deviceinformationwindow.h b/src/osd/modules/debugger/qt/deviceinformationwindow.h new file mode 100644 index 00000000000..eb32398e9b3 --- /dev/null +++ b/src/osd/modules/debugger/qt/deviceinformationwindow.h @@ -0,0 +1,53 @@ +#ifndef __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__ +#define __DEBUG_QT_DEVICE_INFORMATION_WINDOW_H__ + +#include + +#include "windowqt.h" + +//============================================================ +// The Device Information Window. +//============================================================ +class DeviceInformationWindow : public WindowQt +{ + Q_OBJECT + +public: + DeviceInformationWindow(running_machine* machine, device_t* device = NULL, QWidget* parent=NULL); + virtual ~DeviceInformationWindow(); + + void set_device(const char *tag); + const char *device_tag() const; + +private: + device_t *m_device; + + void fill_device_information(); +}; + + + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class DeviceInformationWindowQtConfig : public WindowQtConfig +{ +public: + astring m_device_tag; + + DeviceInformationWindowQtConfig() : + WindowQtConfig(WIN_TYPE_DEVICE_INFORMATION) + { + } + + ~DeviceInformationWindowQtConfig() {} + + void buildFromQWidget(QWidget* widget); + void applyToQWidget(QWidget* widget); + void addToXmlDataNode(xml_data_node* node) const; + void recoverFromXmlNode(xml_data_node* node); +}; + + +#endif diff --git a/src/osd/modules/debugger/qt/deviceswindow.c b/src/osd/modules/debugger/qt/deviceswindow.c new file mode 100644 index 00000000000..ac1f46e347f --- /dev/null +++ b/src/osd/modules/debugger/qt/deviceswindow.c @@ -0,0 +1,180 @@ +#define NO_MEM_TRACKING + +#include "deviceswindow.h" +#include "deviceinformationwindow.h" + +DevicesWindowModel::DevicesWindowModel(running_machine *machine, QObject *parent) +{ + m_machine = machine; +} + +DevicesWindowModel::~DevicesWindowModel() +{ +} + +QVariant DevicesWindowModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid() || role != Qt::DisplayRole) + return QVariant(); + + device_t *dev = static_cast(index.internalPointer()); + switch(index.column()) { + case 0: return dev == &m_machine->root_device() ? QString("") : QString(dev->basetag()); + case 1: return QString(dev->name()); + } + + return QVariant(); +} + +Qt::ItemFlags DevicesWindowModel::flags(const QModelIndex &index) const +{ + if(!index.isValid()) + return 0; + + return QAbstractItemModel::flags(index); +} + +QVariant DevicesWindowModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(role != Qt::DisplayRole || section < 0 || section >= 2) + return QVariant(); + return QString(section ? "Name" : "Tag"); +} + +QModelIndex DevicesWindowModel::index(int row, int column, const QModelIndex &parent) const +{ + if(!hasIndex(row, column, parent)) + return QModelIndex(); + + device_t *target = NULL; + + if(!parent.isValid()) { + if(row == 0) + target = &m_machine->root_device(); + + } else { + device_t *dparent = static_cast(parent.internalPointer()); + int count = row; + for(target = dparent->first_subdevice(); count && target; target = target->next()) + count--; + } + + if(target) + return createIndex(row, column, target); + + return QModelIndex(); +} + +QModelIndex DevicesWindowModel::parent(const QModelIndex &index) const +{ + if(!index.isValid()) + return QModelIndex(); + + device_t *dchild = static_cast(index.internalPointer()); + device_t *dparent = dchild->owner(); + + if(!dparent) + return QModelIndex(); + + device_t *dpp = dparent->owner(); + int row = 0; + if(dpp) { + for(device_t *child = dpp->first_subdevice(); child && child != dparent; child = child->next()) + row++; + } + return createIndex(row, 0, dparent); +} + +int DevicesWindowModel::rowCount(const QModelIndex &parent) const +{ + if(!parent.isValid()) + return 1; + + device_t *dparent = static_cast(parent.internalPointer()); + int count = 0; + for(device_t *child = dparent->first_subdevice(); child; child = child->next()) + count++; + + return count; +} + +int DevicesWindowModel::columnCount(const QModelIndex &parent) const +{ + return 2; +} + + + +DevicesWindow::DevicesWindow(running_machine* machine, QWidget* parent) : + WindowQt(machine, NULL), + m_devices_model(machine) +{ + m_selected_device = NULL; + + setWindowTitle("Debug: All Devices"); + + if (parent != NULL) + { + QPoint parentPos = parent->pos(); + setGeometry(parentPos.x()+100, parentPos.y()+100, 600, 400); + } + + // + // The tree widget + // + m_devices_view = new QTreeView(this); + m_devices_view->setModel(&m_devices_model); + m_devices_view->expandAll(); + m_devices_view->resizeColumnToContents(0); + connect(m_devices_view->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &,const QModelIndex &)), this, SLOT(currentRowChanged(const QModelIndex &,const QModelIndex &))); + connect(m_devices_view, SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); + setCentralWidget(m_devices_view); +} + + +DevicesWindow::~DevicesWindow() +{ +} + + +void DevicesWindow::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous) +{ + m_selected_device = static_cast(current.internalPointer()); +} + + +void DevicesWindow::activated(const QModelIndex &index) +{ + device_t *dev = static_cast(index.internalPointer()); + (new DeviceInformationWindow(m_machine, dev, this))->show(); +} + + + +//========================================================================= +// DevicesWindowQtConfig +//========================================================================= +void DevicesWindowQtConfig::buildFromQWidget(QWidget* widget) +{ + WindowQtConfig::buildFromQWidget(widget); + // DevicesWindow* window = dynamic_cast(widget); +} + + +void DevicesWindowQtConfig::applyToQWidget(QWidget* widget) +{ + WindowQtConfig::applyToQWidget(widget); + // DevicesWindow* window = dynamic_cast(widget); +} + + +void DevicesWindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + WindowQtConfig::addToXmlDataNode(node); +} + + +void DevicesWindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + WindowQtConfig::recoverFromXmlNode(node); +} diff --git a/src/osd/modules/debugger/qt/deviceswindow.h b/src/osd/modules/debugger/qt/deviceswindow.h new file mode 100644 index 00000000000..bf647b27ec5 --- /dev/null +++ b/src/osd/modules/debugger/qt/deviceswindow.h @@ -0,0 +1,79 @@ +#ifndef __DEBUG_QT_DEVICES_WINDOW_H__ +#define __DEBUG_QT_DEVICES_WINDOW_H__ + +#include + +#include "windowqt.h" + + +//============================================================ +// The model for the treeview +//============================================================ + +class DevicesWindowModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + explicit DevicesWindowModel(running_machine *machine, QObject *parent = 0); + ~DevicesWindowModel(); + + QVariant data(const QModelIndex &index, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + +private: + running_machine *m_machine; +}; + +//============================================================ +// The Devices Window. +//============================================================ +class DevicesWindow : public WindowQt +{ + Q_OBJECT + +public: + DevicesWindow(running_machine* machine, QWidget* parent=NULL); + virtual ~DevicesWindow(); + +public slots: + void currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous); + void activated(const QModelIndex &index); + +private: + QTreeView *m_devices_view; + DevicesWindowModel m_devices_model; + device_t *m_selected_device; +}; + + + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class DevicesWindowQtConfig : public WindowQtConfig +{ +public: + DevicesWindowQtConfig() : + WindowQtConfig(WIN_TYPE_DEVICES) + { + } + + ~DevicesWindowQtConfig() {} + + void buildFromQWidget(QWidget* widget); + void applyToQWidget(QWidget* widget); + void addToXmlDataNode(xml_data_node* node) const; + void recoverFromXmlNode(xml_data_node* node); +}; + + +#endif diff --git a/src/osd/modules/debugger/qt/logwindow.c b/src/osd/modules/debugger/qt/logwindow.c new file mode 100644 index 00000000000..ac6fbd6fc12 --- /dev/null +++ b/src/osd/modules/debugger/qt/logwindow.c @@ -0,0 +1,70 @@ +#define NO_MEM_TRACKING + +#include "logwindow.h" + +#include "debug/debugcon.h" +#include "debug/debugcpu.h" +#include "debug/dvdisasm.h" + + +LogWindow::LogWindow(running_machine* machine, QWidget* parent) : + WindowQt(machine, NULL) +{ + setWindowTitle("Debug: Machine Log"); + + if (parent != NULL) + { + QPoint parentPos = parent->pos(); + setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); + } + + // + // The main frame and its input and log widgets + // + QFrame* mainWindowFrame = new QFrame(this); + + // The main log view + m_logView = new DebuggerView(DVT_LOG, + m_machine, + this); + + // Layout + QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); + vLayout->setSpacing(3); + vLayout->setContentsMargins(2,2,2,2); + vLayout->addWidget(m_logView); + + setCentralWidget(mainWindowFrame); +} + + +LogWindow::~LogWindow() +{ +} + + +//========================================================================= +// LogWindowQtConfig +//========================================================================= +void LogWindowQtConfig::buildFromQWidget(QWidget* widget) +{ + WindowQtConfig::buildFromQWidget(widget); +} + + +void LogWindowQtConfig::applyToQWidget(QWidget* widget) +{ + WindowQtConfig::applyToQWidget(widget); +} + + +void LogWindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + WindowQtConfig::addToXmlDataNode(node); +} + + +void LogWindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + WindowQtConfig::recoverFromXmlNode(node); +} diff --git a/src/osd/modules/debugger/qt/logwindow.h b/src/osd/modules/debugger/qt/logwindow.h new file mode 100644 index 00000000000..4179132dc1e --- /dev/null +++ b/src/osd/modules/debugger/qt/logwindow.h @@ -0,0 +1,48 @@ +#ifndef __DEBUG_QT_LOG_WINDOW_H__ +#define __DEBUG_QT_LOG_WINDOW_H__ + +#include + +#include "debuggerview.h" +#include "windowqt.h" + + +//============================================================ +// The Log Window. +//============================================================ +class LogWindow : public WindowQt +{ + Q_OBJECT + +public: + LogWindow(running_machine* machine, QWidget* parent=NULL); + virtual ~LogWindow(); + + +private: + // Widgets + DebuggerView* m_logView; +}; + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class LogWindowQtConfig : public WindowQtConfig +{ +public: + LogWindowQtConfig() : + WindowQtConfig(WIN_TYPE_LOG) + { + } + + ~LogWindowQtConfig() {} + + void buildFromQWidget(QWidget* widget); + void applyToQWidget(QWidget* widget); + void addToXmlDataNode(xml_data_node* node) const; + void recoverFromXmlNode(xml_data_node* node); +}; + + +#endif diff --git a/src/osd/modules/debugger/qt/mainwindow.c b/src/osd/modules/debugger/qt/mainwindow.c new file mode 100644 index 00000000000..f493741aced --- /dev/null +++ b/src/osd/modules/debugger/qt/mainwindow.c @@ -0,0 +1,489 @@ +#define NO_MEM_TRACKING + +#include "mainwindow.h" + +#include "debug/debugcon.h" +#include "debug/debugcpu.h" +#include "debug/dvdisasm.h" + + +MainWindow::MainWindow(running_machine* machine, QWidget* parent) : + WindowQt(machine, NULL), + m_historyIndex(0), + m_inputHistory() +{ + setGeometry(300, 300, 1000, 600); + + // + // The main frame and its input and log widgets + // + QFrame* mainWindowFrame = new QFrame(this); + + // The input line + m_inputEdit = new QLineEdit(mainWindowFrame); + connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand())); + m_inputEdit->installEventFilter(this); + + + // The log view + m_consoleView = new DebuggerView(DVT_CONSOLE, + m_machine, + mainWindowFrame); + m_consoleView->setFocusPolicy(Qt::NoFocus); + m_consoleView->setPreferBottom(true); + + QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); + vLayout->addWidget(m_consoleView); + vLayout->addWidget(m_inputEdit); + vLayout->setSpacing(3); + vLayout->setContentsMargins(4,0,4,2); + + setCentralWidget(mainWindowFrame); + + // + // Options Menu + // + // Create two commands + QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this); + QAction* runToCursorAct = new QAction("Run To Cursor", this); + breakpointSetAct->setShortcut(Qt::Key_F9); + runToCursorAct->setShortcut(Qt::Key_F4); + connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool))); + connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool))); + + // Right bar options + QActionGroup* rightBarGroup = new QActionGroup(this); + rightBarGroup->setObjectName("rightbargroup"); + QAction* rightActRaw = new QAction("Raw Opcodes", this); + QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this); + QAction* rightActComments = new QAction("Comments", this); + rightActRaw->setCheckable(true); + rightActEncrypted->setCheckable(true); + rightActComments->setCheckable(true); + rightActRaw->setActionGroup(rightBarGroup); + rightActEncrypted->setActionGroup(rightBarGroup); + rightActComments->setActionGroup(rightBarGroup); + rightActRaw->setShortcut(QKeySequence("Ctrl+R")); + rightActEncrypted->setShortcut(QKeySequence("Ctrl+E")); + rightActComments->setShortcut(QKeySequence("Ctrl+C")); + rightActRaw->setChecked(true); + connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*))); + + // Assemble the options menu + QMenu* optionsMenu = menuBar()->addMenu("&Options"); + optionsMenu->addAction(breakpointSetAct); + optionsMenu->addAction(runToCursorAct); + optionsMenu->addSeparator(); + optionsMenu->addActions(rightBarGroup->actions()); + + // + // Images menu + // + image_interface_iterator imageIterTest(m_machine->root_device()); + if (imageIterTest.first() != NULL) + { + createImagesMenu(); + } + + // + // Dock window menu + // + QMenu* dockMenu = menuBar()->addMenu("Doc&ks"); + + setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea); + setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); + + // The processor dock + QDockWidget* cpuDock = new QDockWidget("processor", this); + cpuDock->setObjectName("cpudock"); + cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea); + m_procFrame = new ProcessorDockWidget(m_machine, cpuDock); + cpuDock->setWidget(dynamic_cast(m_procFrame)); + + addDockWidget(Qt::LeftDockWidgetArea, cpuDock); + dockMenu->addAction(cpuDock->toggleViewAction()); + + // The disassembly dock + QDockWidget* dasmDock = new QDockWidget("dasm", this); + dasmDock->setObjectName("dasmdock"); + dasmDock->setAllowedAreas(Qt::TopDockWidgetArea); + m_dasmFrame = new DasmDockWidget(m_machine, dasmDock); + dasmDock->setWidget(m_dasmFrame); + + addDockWidget(Qt::TopDockWidgetArea, dasmDock); + dockMenu->addAction(dasmDock->toggleViewAction()); +} + + +MainWindow::~MainWindow() +{ +} + + +void MainWindow::setProcessor(device_t* processor) +{ + // Cpu swap + m_procFrame->view()->view()->set_source(*m_procFrame->view()->view()->source_for_device(processor)); + m_dasmFrame->view()->view()->set_source(*m_dasmFrame->view()->view()->source_for_device(processor)); + + // Scrollbar refresh - seems I should be able to do in the DebuggerView + m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); + m_dasmFrame->view()->verticalScrollBar()->setValue(m_dasmFrame->view()->view()->visible_position().y); + + // Window title + astring title; + title.printf("Debug: %s - %s '%s'", m_machine->system().name, processor->name(), processor->tag()); + setWindowTitle(title.cstr()); +} + + +// Used to intercept the user clicking 'X' in the upper corner +void MainWindow::closeEvent(QCloseEvent* event) +{ + debugActQuit(); + + // Insure the window doesn't disappear before we get a chance to save its parameters + event->ignore(); +} + + +// Used to intercept the user hitting the up arrow in the input widget +bool MainWindow::eventFilter(QObject* obj, QEvent* event) +{ + // Only filter keypresses + QKeyEvent* keyEvent = NULL; + if (event->type() == QEvent::KeyPress) + { + keyEvent = static_cast(event); + } + else + { + return QObject::eventFilter(obj, event); + } + + // Catch up & down keys + if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down) + { + if (keyEvent->key() == Qt::Key_Up) + { + if (m_historyIndex > 0) + m_historyIndex--; + } + else if (keyEvent->key() == Qt::Key_Down) + { + if (m_historyIndex < m_inputHistory.size()) + m_historyIndex++; + } + + // Populate the input edit or clear it if you're at the end + if (m_historyIndex == m_inputHistory.size()) + { + m_inputEdit->setText(""); + } + else + { + m_inputEdit->setText(m_inputHistory[m_historyIndex]); + } + } + else if (keyEvent->key() == Qt::Key_Enter) + { + executeCommand(false); + } + else + { + return QObject::eventFilter(obj, event); + } + + return true; +} + + +void MainWindow::toggleBreakpointAtCursor(bool changedTo) +{ + debug_view_disasm* dasmView = downcast(m_dasmFrame->view()->view()); + if (dasmView->cursor_visible()) + { + if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) + { + offs_t address = downcast(dasmView)->selected_address(); + device_debug *cpuinfo = dasmView->source()->device()->debug(); + + // Find an existing breakpoint at this address + INT32 bpindex = -1; + for (device_debug::breakpoint* bp = cpuinfo->breakpoint_first(); + bp != NULL; + bp = bp->next()) + { + if (address == bp->address()) + { + bpindex = bp->index(); + break; + } + } + + // If none exists, add a new one + astring command; + if (bpindex == -1) + { + command.printf("bpset 0x%X", address); + } + else + { + command.printf("bpclear 0x%X", bpindex); + } + debug_console_execute_command(*m_machine, command, 1); + } + } + + refreshAll(); +} + + +void MainWindow::runToCursor(bool changedTo) +{ + debug_view_disasm* dasmView = downcast(m_dasmFrame->view()->view()); + if (dasmView->cursor_visible()) + { + if (debug_cpu_get_visible_cpu(*m_machine) == dasmView->source()->device()) + { + offs_t address = downcast(dasmView)->selected_address(); + astring command; + command.printf("go 0x%X", address); + debug_console_execute_command(*m_machine, command, 1); + } + } +} + + +void MainWindow::rightBarChanged(QAction* changedTo) +{ + debug_view_disasm* dasmView = downcast(m_dasmFrame->view()->view()); + if (changedTo->text() == "Raw Opcodes") + { + dasmView->set_right_column(DASM_RIGHTCOL_RAW); + } + else if (changedTo->text() == "Encrypted Opcodes") + { + dasmView->set_right_column(DASM_RIGHTCOL_ENCRYPTED); + } + else if (changedTo->text() == "Comments") + { + dasmView->set_right_column(DASM_RIGHTCOL_COMMENTS); + } + m_dasmFrame->view()->viewport()->update(); +} + + +void MainWindow::executeCommand(bool withClear) +{ + QString command = m_inputEdit->text(); + + // A blank command is a "silent step" + if (command == "") + { + debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); + return; + } + + // Send along the command + debug_console_execute_command(*m_machine, + command.toLocal8Bit().data(), + true); + + // Add history & set the index to be the top of the stack + addToHistory(command); + + // Clear out the text and reset the history pointer only if asked + if (withClear) + { + m_inputEdit->clear(); + m_historyIndex = m_inputHistory.size(); + } + + // Refresh + m_consoleView->viewport()->update(); + refreshAll(); +} + + +void MainWindow::mountImage(bool changedTo) +{ + // The image interface index was assigned to the QAction's data memeber + const int imageIndex = dynamic_cast(sender())->data().toInt(); + image_interface_iterator iter(m_machine->root_device()); + device_image_interface *img = iter.byindex(imageIndex); + if (img == NULL) + { + debug_console_printf(*m_machine, "Something is wrong with the mount menu.\n"); + refreshAll(); + return; + } + + // File dialog + QString filename = QFileDialog::getOpenFileName(this, + "Select an image file", + QDir::currentPath(), + tr("All files (*.*)")); + + if (img->load(filename.toUtf8().data()) != IMAGE_INIT_PASS) + { + debug_console_printf(*m_machine, "Image could not be mounted.\n"); + refreshAll(); + return; + } + + // Activate the unmount menu option + QAction* unmountAct = sender()->parent()->findChild("unmount"); + unmountAct->setEnabled(true); + + // Set the mount name + QMenu* parentMenuItem = dynamic_cast(sender()->parent()); + QString baseString = parentMenuItem->title(); + baseString.truncate(baseString.lastIndexOf(QString(" : "))); + const QString newTitle = baseString + QString(" : ") + QString(img->filename()); + parentMenuItem->setTitle(newTitle); + + debug_console_printf(*m_machine, "Image %s mounted successfully.\n", filename.toUtf8().data()); + refreshAll(); +} + + +void MainWindow::unmountImage(bool changedTo) +{ + // The image interface index was assigned to the QAction's data memeber + const int imageIndex = dynamic_cast(sender())->data().toInt(); + image_interface_iterator iter(m_machine->root_device()); + device_image_interface *img = iter.byindex(imageIndex); + + img->unload(); + + // Deactivate the unmount menu option + dynamic_cast(sender())->setEnabled(false); + + // Set the mount name + QMenu* parentMenuItem = dynamic_cast(sender()->parent()); + QString baseString = parentMenuItem->title(); + baseString.truncate(baseString.lastIndexOf(QString(" : "))); + const QString newTitle = baseString + QString(" : ") + QString("[empty slot]"); + parentMenuItem->setTitle(newTitle); + + debug_console_printf(*m_machine, "Image successfully unmounted.\n"); + refreshAll(); +} + + +void MainWindow::debugActClose() +{ + m_machine->schedule_exit(); +} + + +void MainWindow::addToHistory(const QString& command) +{ + if (command == "") + return; + + // Always push back when there is no previous history + if (m_inputHistory.size() == 0) + { + m_inputHistory.push_back(m_inputEdit->text()); + return; + } + + // If there is previous history, make sure it's not what you just executed + if (m_inputHistory.back() != m_inputEdit->text()) + { + m_inputHistory.push_back(m_inputEdit->text()); + } +} + + +void MainWindow::createImagesMenu() +{ + QMenu* imagesMenu = menuBar()->addMenu("&Images"); + + int interfaceIndex = 0; + image_interface_iterator iter(m_machine->root_device()); + for (device_image_interface *img = iter.first(); img != NULL; img = iter.next()) + { + astring menuName; + menuName.format("%s : %s", img->device().name(), img->exists() ? img->filename() : "[empty slot]"); + + QMenu* interfaceMenu = imagesMenu->addMenu(menuName.cstr()); + interfaceMenu->setObjectName(img->device().name()); + + QAction* mountAct = new QAction("Mount...", interfaceMenu); + QAction* unmountAct = new QAction("Unmount", interfaceMenu); + mountAct->setObjectName("mount"); + mountAct->setData(QVariant(interfaceIndex)); + unmountAct->setObjectName("unmount"); + unmountAct->setData(QVariant(interfaceIndex)); + connect(mountAct, SIGNAL(triggered(bool)), this, SLOT(mountImage(bool))); + connect(unmountAct, SIGNAL(triggered(bool)), this, SLOT(unmountImage(bool))); + + if (!img->exists()) + unmountAct->setEnabled(false); + + interfaceMenu->addAction(mountAct); + interfaceMenu->addAction(unmountAct); + + // TODO: Cassette operations + + interfaceIndex++; + } +} + + +//========================================================================= +// MainWindowQtConfig +//========================================================================= +void MainWindowQtConfig::buildFromQWidget(QWidget* widget) +{ + WindowQtConfig::buildFromQWidget(widget); + MainWindow* window = dynamic_cast(widget); + m_windowState = window->saveState(); + + QActionGroup* rightBarGroup = window->findChild("rightbargroup"); + if (rightBarGroup->checkedAction()->text() == "Raw Opcodes") + m_rightBar = 0; + else if (rightBarGroup->checkedAction()->text() == "Encrypted Opcodes") + m_rightBar = 1; + else if (rightBarGroup->checkedAction()->text() == "Comments") + m_rightBar = 2; +} + + +void MainWindowQtConfig::applyToQWidget(QWidget* widget) +{ + WindowQtConfig::applyToQWidget(widget); + MainWindow* window = dynamic_cast(widget); + window->restoreState(m_windowState); + + QActionGroup* rightBarGroup = window->findChild("rightbargroup"); + rightBarGroup->actions()[m_rightBar]->trigger(); +} + + +void MainWindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + WindowQtConfig::addToXmlDataNode(node); + xml_set_attribute_int(node, "rightbar", m_rightBar); + xml_set_attribute(node, "qtwindowstate", m_windowState.toPercentEncoding().data()); +} + + +void MainWindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + WindowQtConfig::recoverFromXmlNode(node); + const char* state = xml_get_attribute_string(node, "qtwindowstate", ""); + m_windowState = QByteArray::fromPercentEncoding(state); + m_rightBar = xml_get_attribute_int(node, "rightbar", m_rightBar); +} + +DasmDockWidget::~DasmDockWidget() +{ +} + +ProcessorDockWidget::~ProcessorDockWidget() +{ +} diff --git a/src/osd/modules/debugger/qt/mainwindow.h b/src/osd/modules/debugger/qt/mainwindow.h new file mode 100644 index 00000000000..d3a6a6b33fc --- /dev/null +++ b/src/osd/modules/debugger/qt/mainwindow.h @@ -0,0 +1,194 @@ +#ifndef __DEBUG_QT_MAIN_WINDOW_H__ +#define __DEBUG_QT_MAIN_WINDOW_H__ + +#include +#include + +#include "debug/dvdisasm.h" + +#include "debuggerview.h" +#include "windowqt.h" + +class DasmDockWidget; +class ProcessorDockWidget; + + +//============================================================ +// The Main Window. Contains processor and dasm docks. +//============================================================ +class MainWindow : public WindowQt +{ + Q_OBJECT + +public: + MainWindow(running_machine* machine, QWidget* parent=NULL); + virtual ~MainWindow(); + + void setProcessor(device_t* processor); + + +protected: + // Used to intercept the user clicking 'X' in the upper corner + void closeEvent(QCloseEvent* event); + + // Used to intercept the user hitting the up arrow in the input widget + bool eventFilter(QObject* obj, QEvent* event); + + +private slots: + void toggleBreakpointAtCursor(bool changedTo); + void runToCursor(bool changedTo); + void rightBarChanged(QAction* changedTo); + + void executeCommand(bool withClear=true); + + void mountImage(bool changedTo); + void unmountImage(bool changedTo); + + // Closing the main window actually exits the program + void debugActClose(); + + +private: + // Widgets and docks + QLineEdit* m_inputEdit; + DebuggerView* m_consoleView; + ProcessorDockWidget* m_procFrame; + DasmDockWidget* m_dasmFrame; + + // Terminal history + int m_historyIndex; + std::vector m_inputHistory; + void addToHistory(const QString& command); + + void createImagesMenu(); +}; + + +//============================================================ +// Docks with the Main Window. Disassembly. +//============================================================ +class DasmDockWidget : public QWidget +{ + Q_OBJECT + +public: + DasmDockWidget(running_machine* machine, QWidget* parent=NULL) : + QWidget(parent), + m_machine(machine) + { + m_dasmView = new DebuggerView(DVT_DISASSEMBLY, + m_machine, + this); + + // Force a recompute of the disassembly region + downcast(m_dasmView->view())->set_expression("curpc"); + + QVBoxLayout* dvLayout = new QVBoxLayout(this); + dvLayout->addWidget(m_dasmView); + dvLayout->setContentsMargins(4,0,4,0); + } + + + virtual ~DasmDockWidget(); + + + DebuggerView* view() { return m_dasmView; } + + + QSize minimumSizeHint() const + { + return QSize(150,150); + } + + + QSize sizeHint() const + { + return QSize(150,200); + } + + +private: + DebuggerView* m_dasmView; + + running_machine* m_machine; +}; + + +//============================================================ +// Docks with the Main Window. Processor information. +//============================================================ +class ProcessorDockWidget : public QWidget +{ + Q_OBJECT + +public: + ProcessorDockWidget(running_machine* machine, + QWidget* parent=NULL) : + QWidget(parent), + m_processorView(NULL), + m_machine(machine) + { + m_processorView = new DebuggerView(DVT_STATE, + m_machine, + this); + m_processorView->setFocusPolicy(Qt::NoFocus); + + QVBoxLayout* cvLayout = new QVBoxLayout(this); + cvLayout->addWidget(m_processorView); + cvLayout->setContentsMargins(4,0,4,2); + } + + + virtual ~ProcessorDockWidget(); + + + DebuggerView* view() { return m_processorView; } + + + QSize minimumSizeHint() const + { + return QSize(150,300); + } + + + QSize sizeHint() const + { + return QSize(200,300); + } + + +private: + DebuggerView* m_processorView; + + running_machine* m_machine; +}; + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class MainWindowQtConfig : public WindowQtConfig +{ +public: + MainWindowQtConfig() : + WindowQtConfig(WIN_TYPE_MAIN), + m_rightBar(0), + m_windowState() + {} + + ~MainWindowQtConfig() {} + + // Settings + int m_rightBar; + QByteArray m_windowState; + + void buildFromQWidget(QWidget* widget); + void applyToQWidget(QWidget* widget); + void addToXmlDataNode(xml_data_node* node) const; + void recoverFromXmlNode(xml_data_node* node); +}; + + + +#endif diff --git a/src/osd/modules/debugger/qt/memorywindow.c b/src/osd/modules/debugger/qt/memorywindow.c new file mode 100644 index 00000000000..d04fa1071af --- /dev/null +++ b/src/osd/modules/debugger/qt/memorywindow.c @@ -0,0 +1,395 @@ +#define NO_MEM_TRACKING + +#include "memorywindow.h" + +#include "debug/dvmemory.h" +#include "debug/debugcon.h" +#include "debug/debugcpu.h" + + +MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) : + WindowQt(machine, NULL) +{ + setWindowTitle("Debug: Memory View"); + + if (parent != NULL) + { + QPoint parentPos = parent->pos(); + setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400); + } + + // + // The main frame and its input and log widgets + // + QFrame* mainWindowFrame = new QFrame(this); + + // The top frame & groupbox that contains the input widgets + QFrame* topSubFrame = new QFrame(mainWindowFrame); + + // The input edit + m_inputEdit = new QLineEdit(topSubFrame); + connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted())); + + // The memory space combo box + m_memoryComboBox = new QComboBox(topSubFrame); + m_memoryComboBox->setObjectName("memoryregion"); + m_memoryComboBox->setMinimumWidth(300); + connect(m_memoryComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(memoryRegionChanged(int))); + + // The main memory window + m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this); + + // Layout + QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame); + subLayout->addWidget(m_inputEdit); + subLayout->addWidget(m_memoryComboBox); + subLayout->setSpacing(3); + subLayout->setContentsMargins(2,2,2,2); + + QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame); + vLayout->setSpacing(3); + vLayout->setContentsMargins(2,2,2,2); + vLayout->addWidget(topSubFrame); + vLayout->addWidget(m_memTable); + + setCentralWidget(mainWindowFrame); + + // + // Menu bars + // + // Create a byte-chunk group + QActionGroup* chunkGroup = new QActionGroup(this); + chunkGroup->setObjectName("chunkgroup"); + QAction* chunkActOne = new QAction("1-byte chunks", this); + chunkActOne->setObjectName("chunkActOne"); + QAction* chunkActTwo = new QAction("2-byte chunks", this); + chunkActTwo->setObjectName("chunkActTwo"); + QAction* chunkActFour = new QAction("4-byte chunks", this); + chunkActFour->setObjectName("chunkActFour"); + chunkActOne->setCheckable(true); + chunkActTwo->setCheckable(true); + chunkActFour->setCheckable(true); + chunkActOne->setActionGroup(chunkGroup); + chunkActTwo->setActionGroup(chunkGroup); + chunkActFour->setActionGroup(chunkGroup); + chunkActOne->setShortcut(QKeySequence("Ctrl+1")); + chunkActTwo->setShortcut(QKeySequence("Ctrl+2")); + chunkActFour->setShortcut(QKeySequence("Ctrl+4")); + chunkActOne->setChecked(true); + connect(chunkGroup, SIGNAL(triggered(QAction*)), this, SLOT(chunkChanged(QAction*))); + + // Create a address display group + QActionGroup* addressGroup = new QActionGroup(this); + addressGroup->setObjectName("addressgroup"); + QAction* addressActLogical = new QAction("Logical Addresses", this); + QAction* addressActPhysical = new QAction("Physical Addresses", this); + addressActLogical->setCheckable(true); + addressActPhysical->setCheckable(true); + addressActLogical->setActionGroup(addressGroup); + addressActPhysical->setActionGroup(addressGroup); + addressActLogical->setShortcut(QKeySequence("Ctrl+G")); + addressActPhysical->setShortcut(QKeySequence("Ctrl+Y")); + addressActLogical->setChecked(true); + connect(addressGroup, SIGNAL(triggered(QAction*)), this, SLOT(addressChanged(QAction*))); + + // Create a reverse view radio + QAction* reverseAct = new QAction("Reverse View", this); + reverseAct->setObjectName("reverse"); + reverseAct->setCheckable(true); + reverseAct->setShortcut(QKeySequence("Ctrl+R")); + connect(reverseAct, SIGNAL(toggled(bool)), this, SLOT(reverseChanged(bool))); + + // Create increase and decrease bytes-per-line actions + QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this); + QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this); + increaseBplAct->setShortcut(QKeySequence("Ctrl+P")); + decreaseBplAct->setShortcut(QKeySequence("Ctrl+O")); + connect(increaseBplAct, SIGNAL(triggered(bool)), this, SLOT(increaseBytesPerLine(bool))); + connect(decreaseBplAct, SIGNAL(triggered(bool)), this, SLOT(decreaseBytesPerLine(bool))); + + // Assemble the options menu + QMenu* optionsMenu = menuBar()->addMenu("&Options"); + optionsMenu->addActions(chunkGroup->actions()); + optionsMenu->addSeparator(); + optionsMenu->addActions(addressGroup->actions()); + optionsMenu->addSeparator(); + optionsMenu->addAction(reverseAct); + optionsMenu->addSeparator(); + optionsMenu->addAction(increaseBplAct); + optionsMenu->addAction(decreaseBplAct); + + + // + // Initialize + // + populateComboBox(); + + // Set to the current CPU's memory view + setToCurrentCpu(); +} + + +MemoryWindow::~MemoryWindow() +{ +} + + +void MemoryWindow::memoryRegionChanged(int index) +{ + m_memTable->view()->set_source(*m_memTable->view()->source_list().find(index)); + m_memTable->viewport()->update(); + + // Update the chunk size radio buttons to the memory region's default + debug_view_memory* memView = downcast(m_memTable->view()); + switch(memView->bytes_per_chunk()) + { + case 1: chunkSizeMenuItem("chunkActOne")->setChecked(true); break; + case 2: chunkSizeMenuItem("chunkActTwo")->setChecked(true); break; + case 4: chunkSizeMenuItem("chunkActFour")->setChecked(true); break; + default: break; + } +} + + +void MemoryWindow::expressionSubmitted() +{ + const QString expression = m_inputEdit->text(); + downcast(m_memTable->view())->set_expression(expression.toLocal8Bit().data()); + + // Make the cursor pop + m_memTable->view()->set_cursor_visible(true); + + // Check where the cursor is and adjust the scroll accordingly + debug_view_xy cursorPosition = m_memTable->view()->cursor_position(); + // TODO: check if the region is already visible? + m_memTable->verticalScrollBar()->setValue(cursorPosition.y); + + m_memTable->update(); + m_memTable->viewport()->update(); +} + + +void MemoryWindow::chunkChanged(QAction* changedTo) +{ + debug_view_memory* memView = downcast(m_memTable->view()); + if (changedTo->text() == "1-byte chunks") + { + memView->set_bytes_per_chunk(1); + } + else if (changedTo->text() == "2-byte chunks") + { + memView->set_bytes_per_chunk(2); + } + else if (changedTo->text() == "4-byte chunks") + { + memView->set_bytes_per_chunk(4); + } + m_memTable->viewport()->update(); +} + + +void MemoryWindow::addressChanged(QAction* changedTo) +{ + debug_view_memory* memView = downcast(m_memTable->view()); + if (changedTo->text() == "Logical Addresses") + { + memView->set_physical(false); + } + else if (changedTo->text() == "Physical Addresses") + { + memView->set_physical(true); + } + m_memTable->viewport()->update(); +} + + +void MemoryWindow::reverseChanged(bool changedTo) +{ + debug_view_memory* memView = downcast(m_memTable->view()); + memView->set_reverse(changedTo); + m_memTable->viewport()->update(); +} + + +void MemoryWindow::increaseBytesPerLine(bool changedTo) +{ + debug_view_memory* memView = downcast(m_memTable->view()); + memView->set_chunks_per_row(memView->chunks_per_row() + 1); + m_memTable->viewport()->update(); +} + + +void MemoryWindow::decreaseBytesPerLine(bool checked) +{ + debug_view_memory* memView = downcast(m_memTable->view()); + memView->set_chunks_per_row(memView->chunks_per_row() - 1); + m_memTable->viewport()->update(); +} + + +void MemoryWindow::populateComboBox() +{ + if (m_memTable == NULL) + return; + + m_memoryComboBox->clear(); + for (const debug_view_source* source = m_memTable->view()->first_source(); + source != NULL; + source = source->next()) + { + m_memoryComboBox->addItem(source->name()); + } +} + + +void MemoryWindow::setToCurrentCpu() +{ + device_t* curCpu = debug_cpu_get_visible_cpu(*m_machine); + const debug_view_source *source = m_memTable->view()->source_for_device(curCpu); + const int listIndex = m_memTable->view()->source_list().indexof(*source); + m_memoryComboBox->setCurrentIndex(listIndex); +} + + +// I have a hard time storing QActions as class members. This is a substitute. +QAction* MemoryWindow::chunkSizeMenuItem(const QString& itemName) +{ + QList menus = menuBar()->findChildren(); + for (int i = 0; i < menus.length(); i++) + { + if (menus[i]->title() != "&Options") continue; + QList actions = menus[i]->actions(); + for (int j = 0; j < actions.length(); j++) + { + if (actions[j]->objectName() == itemName) + return actions[j]; + } + } + return NULL; +} + + +//========================================================================= +// DebuggerMemView +//========================================================================= +void DebuggerMemView::mousePressEvent(QMouseEvent* event) +{ + const bool leftClick = event->button() == Qt::LeftButton; + const bool rightClick = event->button() == Qt::RightButton; + + if (leftClick || rightClick) + { + QFontMetrics actualFont = fontMetrics(); + const double fontWidth = actualFont.width(QString(100, '_')) / 100.; + const int fontHeight = MAX(1, actualFont.height()); + + debug_view_xy topLeft = view()->visible_position(); + debug_view_xy clickViewPosition; + clickViewPosition.x = topLeft.x + (event->x() / fontWidth); + clickViewPosition.y = topLeft.y + (event->y() / fontHeight); + if (leftClick) + { + view()->process_click(DCK_LEFT_CLICK, clickViewPosition); + } + else if (rightClick) + { + // Display the last known PC to write to this memory location & copy it onto the clipboard + debug_view_memory* memView = downcast(view()); + const offs_t address = memView->addressAtCursorPosition(clickViewPosition); + const debug_view_memory_source* source = downcast(memView->source()); + address_space* addressSpace = source->space(); + const int nativeDataWidth = addressSpace->data_width() / 8; + const UINT64 memValue = debug_read_memory(*addressSpace, + addressSpace->address_to_byte(address), + nativeDataWidth, + true); + const offs_t pc = source->device()->debug()->track_mem_pc_from_space_address_data(addressSpace->spacenum(), + address, + memValue); + if (pc != (offs_t)(-1)) + { + // TODO: You can specify a box that the tooltip stays alive within - might be good? + const QString addressAndPc = QString("Address %1 written at PC=%2").arg(address, 2, 16).arg(pc, 2, 16); + QToolTip::showText(QCursor::pos(), addressAndPc, NULL); + + // Copy the PC into the clipboard as well + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(QString("%1").arg(pc, 2, 16)); + } + else + { + QToolTip::showText(QCursor::pos(), "UNKNOWN PC", NULL); + } + } + + viewport()->update(); + update(); + } +} + + +//========================================================================= +// MemoryWindowQtConfig +//========================================================================= +void MemoryWindowQtConfig::buildFromQWidget(QWidget* widget) +{ + WindowQtConfig::buildFromQWidget(widget); + MemoryWindow* window = dynamic_cast(widget); + QComboBox* memoryRegion = window->findChild("memoryregion"); + m_memoryRegion = memoryRegion->currentIndex(); + + QAction* reverse = window->findChild("reverse"); + m_reverse = reverse->isChecked(); + + QActionGroup* addressGroup = window->findChild("addressgroup"); + if (addressGroup->checkedAction()->text() == "Logical Addresses") + m_addressMode = 0; + else if (addressGroup->checkedAction()->text() == "Physical Addresses") + m_addressMode = 1; + + QActionGroup* chunkGroup = window->findChild("chunkgroup"); + if (chunkGroup->checkedAction()->text() == "1-byte chunks") + m_chunkSize = 0; + else if (chunkGroup->checkedAction()->text() == "2-byte chunks") + m_chunkSize = 1; + else if (chunkGroup->checkedAction()->text() == "4-byte chunks") + m_chunkSize = 2; +} + + +void MemoryWindowQtConfig::applyToQWidget(QWidget* widget) +{ + WindowQtConfig::applyToQWidget(widget); + MemoryWindow* window = dynamic_cast(widget); + QComboBox* memoryRegion = window->findChild("memoryregion"); + memoryRegion->setCurrentIndex(m_memoryRegion); + + QAction* reverse = window->findChild("reverse"); + if (m_reverse) reverse->trigger(); + + QActionGroup* addressGroup = window->findChild("addressgroup"); + addressGroup->actions()[m_addressMode]->trigger(); + + QActionGroup* chunkGroup = window->findChild("chunkgroup"); + chunkGroup->actions()[m_chunkSize]->trigger(); +} + + +void MemoryWindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + WindowQtConfig::addToXmlDataNode(node); + xml_set_attribute_int(node, "memoryregion", m_memoryRegion); + xml_set_attribute_int(node, "reverse", m_reverse); + xml_set_attribute_int(node, "addressmode", m_addressMode); + xml_set_attribute_int(node, "chunksize", m_chunkSize); +} + + +void MemoryWindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + WindowQtConfig::recoverFromXmlNode(node); + m_memoryRegion = xml_get_attribute_int(node, "memoryregion", m_memoryRegion); + m_reverse = xml_get_attribute_int(node, "reverse", m_reverse); + m_addressMode = xml_get_attribute_int(node, "addressmode", m_addressMode); + m_chunkSize = xml_get_attribute_int(node, "chunksize", m_chunkSize); +} diff --git a/src/osd/modules/debugger/qt/memorywindow.h b/src/osd/modules/debugger/qt/memorywindow.h new file mode 100644 index 00000000000..2dc731f4006 --- /dev/null +++ b/src/osd/modules/debugger/qt/memorywindow.h @@ -0,0 +1,96 @@ +#ifndef __DEBUG_QT_MEMORY_WINDOW_H__ +#define __DEBUG_QT_MEMORY_WINDOW_H__ + +#include + +#include "debuggerview.h" +#include "windowqt.h" + +class DebuggerMemView; + + +//============================================================ +// The Memory Window. +//============================================================ +class MemoryWindow : public WindowQt +{ + Q_OBJECT + +public: + MemoryWindow(running_machine* machine, QWidget* parent=NULL); + virtual ~MemoryWindow(); + + +private slots: + void memoryRegionChanged(int index); + void expressionSubmitted(); + void chunkChanged(QAction* changedTo); + void addressChanged(QAction* changedTo); + void reverseChanged(bool changedTo); + void increaseBytesPerLine(bool changedTo); + void decreaseBytesPerLine(bool checked=false); + + +private: + void populateComboBox(); + void setToCurrentCpu(); + QAction* chunkSizeMenuItem(const QString& itemName); + + +private: + // Widgets + QLineEdit* m_inputEdit; + QComboBox* m_memoryComboBox; + DebuggerMemView* m_memTable; +}; + + +//========================================================================= +// The mem window gets its own debugger view to handle right click pop-ups +//========================================================================= +class DebuggerMemView : public DebuggerView +{ +public: + DebuggerMemView(const debug_view_type& type, + running_machine* machine, + QWidget* parent=NULL) + : DebuggerView(type, machine, parent) + {} + virtual ~DebuggerMemView() {} + +protected: + void mousePressEvent(QMouseEvent* event); +}; + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class MemoryWindowQtConfig : public WindowQtConfig +{ +public: + MemoryWindowQtConfig() : + WindowQtConfig(WIN_TYPE_MEMORY), + m_reverse(0), + m_addressMode(0), + m_chunkSize(0), + m_memoryRegion(0) + { + } + + ~MemoryWindowQtConfig() {} + + // Settings + int m_reverse; + int m_addressMode; + int m_chunkSize; + int m_memoryRegion; + + void buildFromQWidget(QWidget* widget); + void applyToQWidget(QWidget* widget); + void addToXmlDataNode(xml_data_node* node) const; + void recoverFromXmlNode(xml_data_node* node); +}; + + +#endif diff --git a/src/osd/modules/debugger/qt/windowqt.c b/src/osd/modules/debugger/qt/windowqt.c new file mode 100644 index 00000000000..851a73a359f --- /dev/null +++ b/src/osd/modules/debugger/qt/windowqt.c @@ -0,0 +1,272 @@ +#define NO_MEM_TRACKING + +#include "windowqt.h" +#include "logwindow.h" +#include "dasmwindow.h" +#include "memorywindow.h" +#include "breakpointswindow.h" +#include "deviceswindow.h" + +bool WindowQt::s_refreshAll = false; +bool WindowQt::s_hideAll = false; + + +// Since all debug windows are intended to be top-level, this inherited +// constructor is always called with a NULL parent. The passed-in parent widget, +// however, is often used to place each child window & the code to do this can +// be found in most of the inherited classes. + +WindowQt::WindowQt(running_machine* machine, QWidget* parent) : + QMainWindow(parent), + m_machine(machine) +{ + setAttribute(Qt::WA_DeleteOnClose, true); + + // The Debug menu bar + QAction* debugActOpenMemory = new QAction("New &Memory Window", this); + debugActOpenMemory->setShortcut(QKeySequence("Ctrl+M")); + connect(debugActOpenMemory, SIGNAL(triggered()), this, SLOT(debugActOpenMemory())); + + QAction* debugActOpenDasm = new QAction("New &Dasm Window", this); + debugActOpenDasm->setShortcut(QKeySequence("Ctrl+D")); + connect(debugActOpenDasm, SIGNAL(triggered()), this, SLOT(debugActOpenDasm())); + + QAction* debugActOpenLog = new QAction("New &Log Window", this); + debugActOpenLog->setShortcut(QKeySequence("Ctrl+L")); + connect(debugActOpenLog, SIGNAL(triggered()), this, SLOT(debugActOpenLog())); + + QAction* debugActOpenPoints = new QAction("New &Break|Watchpoints Window", this); + debugActOpenPoints->setShortcut(QKeySequence("Ctrl+B")); + connect(debugActOpenPoints, SIGNAL(triggered()), this, SLOT(debugActOpenPoints())); + + QAction* debugActOpenDevices = new QAction("New D&evices Window", this); + debugActOpenDevices->setShortcut(QKeySequence("Shift+Ctrl+D")); + connect(debugActOpenDevices, SIGNAL(triggered()), this, SLOT(debugActOpenDevices())); + + QAction* dbgActRun = new QAction("Run", this); + dbgActRun->setShortcut(Qt::Key_F5); + connect(dbgActRun, SIGNAL(triggered()), this, SLOT(debugActRun())); + + QAction* dbgActRunAndHide = new QAction("Run And Hide Debugger", this); + dbgActRunAndHide->setShortcut(Qt::Key_F12); + connect(dbgActRunAndHide, SIGNAL(triggered()), this, SLOT(debugActRunAndHide())); + + QAction* dbgActRunToNextCpu = new QAction("Run to Next CPU", this); + dbgActRunToNextCpu->setShortcut(Qt::Key_F6); + connect(dbgActRunToNextCpu, SIGNAL(triggered()), this, SLOT(debugActRunToNextCpu())); + + QAction* dbgActRunNextInt = new QAction("Run to Next Interrupt on This CPU", this); + dbgActRunNextInt->setShortcut(Qt::Key_F7); + connect(dbgActRunNextInt, SIGNAL(triggered()), this, SLOT(debugActRunNextInt())); + + QAction* dbgActRunNextVBlank = new QAction("Run to Next VBlank", this); + dbgActRunNextVBlank->setShortcut(Qt::Key_F8); + connect(dbgActRunNextVBlank, SIGNAL(triggered()), this, SLOT(debugActRunNextVBlank())); + + QAction* dbgActStepInto = new QAction("Step Into", this); + dbgActStepInto->setShortcut(Qt::Key_F11); + connect(dbgActStepInto, SIGNAL(triggered()), this, SLOT(debugActStepInto())); + + QAction* dbgActStepOver = new QAction("Step Over", this); + dbgActStepOver->setShortcut(Qt::Key_F10); + connect(dbgActStepOver, SIGNAL(triggered()), this, SLOT(debugActStepOver())); + + QAction* dbgActStepOut = new QAction("Step Out", this); + dbgActStepOut->setShortcut(QKeySequence("Shift+F11")); + connect(dbgActStepOut, SIGNAL(triggered()), this, SLOT(debugActStepOut())); + + QAction* dbgActSoftReset = new QAction("Soft Reset", this); + dbgActSoftReset->setShortcut(Qt::Key_F3); + connect(dbgActSoftReset, SIGNAL(triggered()), this, SLOT(debugActSoftReset())); + + QAction* dbgActHardReset = new QAction("Hard Reset", this); + dbgActHardReset->setShortcut(QKeySequence("Shift+F3")); + connect(dbgActHardReset, SIGNAL(triggered()), this, SLOT(debugActHardReset())); + + QAction* dbgActClose = new QAction("Close &Window", this); + dbgActClose->setShortcut(QKeySequence::Close); + connect(dbgActClose, SIGNAL(triggered()), this, SLOT(debugActClose())); + + QAction* dbgActQuit = new QAction("&Quit", this); + dbgActQuit->setShortcut(QKeySequence::Quit); + connect(dbgActQuit, SIGNAL(triggered()), this, SLOT(debugActQuit())); + + // Construct the menu + QMenu* debugMenu = menuBar()->addMenu("&Debug"); + debugMenu->addAction(debugActOpenMemory); + debugMenu->addAction(debugActOpenDasm); + debugMenu->addAction(debugActOpenLog); + debugMenu->addAction(debugActOpenPoints); + debugMenu->addAction(debugActOpenDevices); + debugMenu->addSeparator(); + debugMenu->addAction(dbgActRun); + debugMenu->addAction(dbgActRunAndHide); + debugMenu->addAction(dbgActRunToNextCpu); + debugMenu->addAction(dbgActRunNextInt); + debugMenu->addAction(dbgActRunNextVBlank); + debugMenu->addSeparator(); + debugMenu->addAction(dbgActStepInto); + debugMenu->addAction(dbgActStepOver); + debugMenu->addAction(dbgActStepOut); + debugMenu->addSeparator(); + debugMenu->addAction(dbgActSoftReset); + debugMenu->addAction(dbgActHardReset); + debugMenu->addSeparator(); + debugMenu->addAction(dbgActClose); + debugMenu->addAction(dbgActQuit); +} + + +WindowQt::~WindowQt() +{ +} + +void WindowQt::debugActOpenMemory() +{ + MemoryWindow* foo = new MemoryWindow(m_machine, this); + // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon + // foo->setWindowFlags(Qt::Dialog); + // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); + foo->show(); +} + + +void WindowQt::debugActOpenDasm() +{ + DasmWindow* foo = new DasmWindow(m_machine, this); + // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon + // foo->setWindowFlags(Qt::Dialog); + // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); + foo->show(); +} + + +void WindowQt::debugActOpenLog() +{ + LogWindow* foo = new LogWindow(m_machine, this); + // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon + // foo->setWindowFlags(Qt::Dialog); + // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); + foo->show(); +} + + +void WindowQt::debugActOpenPoints() +{ + BreakpointsWindow* foo = new BreakpointsWindow(m_machine, this); + // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon + // foo->setWindowFlags(Qt::Dialog); + // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); + foo->show(); +} + + +void WindowQt::debugActOpenDevices() +{ + DevicesWindow* foo = new DevicesWindow(m_machine, this); + // A valiant effort, but it just doesn't wanna' hide behind the main window & not make a new toolbar icon + // foo->setWindowFlags(Qt::Dialog); + // foo->setWindowFlags(foo->windowFlags() & ~Qt::WindowStaysOnTopHint); + foo->show(); +} + + +void WindowQt::debugActRun() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); +} + +void WindowQt::debugActRunAndHide() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->go(); + hideAll(); +} + +void WindowQt::debugActRunToNextCpu() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device(); +} + +void WindowQt::debugActRunNextInt() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt(); +} + +void WindowQt::debugActRunNextVBlank() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank(); +} + +void WindowQt::debugActStepInto() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); +} + +void WindowQt::debugActStepOver() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over(); +} + +void WindowQt::debugActStepOut() +{ + debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out(); +} + +void WindowQt::debugActSoftReset() +{ + m_machine->schedule_soft_reset(); + debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step(); +} + +void WindowQt::debugActHardReset() +{ + m_machine->schedule_hard_reset(); +} + +void WindowQt::debugActClose() +{ + close(); +} + +void WindowQt::debugActQuit() +{ + m_machine->schedule_exit(); +} + + +//========================================================================= +// WindowQtConfig +//========================================================================= +void WindowQtConfig::buildFromQWidget(QWidget* widget) +{ + m_position.setX(widget->geometry().topLeft().x()); + m_position.setY(widget->geometry().topLeft().y()); + m_size.setX(widget->size().width()); + m_size.setY(widget->size().height()); +} + + +void WindowQtConfig::applyToQWidget(QWidget* widget) +{ + widget->setGeometry(m_position.x(), m_position.y(), m_size.x(), m_size.y()); +} + + +void WindowQtConfig::addToXmlDataNode(xml_data_node* node) const +{ + xml_set_attribute_int(node, "type", m_type); + xml_set_attribute_int(node, "position_x", m_position.x()); + xml_set_attribute_int(node, "position_y", m_position.y()); + xml_set_attribute_int(node, "size_x", m_size.x()); + xml_set_attribute_int(node, "size_y", m_size.y()); +} + + +void WindowQtConfig::recoverFromXmlNode(xml_data_node* node) +{ + m_size.setX(xml_get_attribute_int(node, "size_x", m_size.x())); + m_size.setY(xml_get_attribute_int(node, "size_y", m_size.y())); + m_position.setX(xml_get_attribute_int(node, "position_x", m_position.x())); + m_position.setY(xml_get_attribute_int(node, "position_y", m_position.y())); + m_type = (WindowQtConfig::WindowType)xml_get_attribute_int(node, "type", m_type); +} diff --git a/src/osd/modules/debugger/qt/windowqt.h b/src/osd/modules/debugger/qt/windowqt.h new file mode 100644 index 00000000000..6bb7f646522 --- /dev/null +++ b/src/osd/modules/debugger/qt/windowqt.h @@ -0,0 +1,98 @@ +#ifndef __DEBUG_QT_WINDOW_QT_H__ +#define __DEBUG_QT_WINDOW_QT_H__ + +#include + +#include "emu.h" +#include "config.h" +#include "debugger.h" + + +//============================================================ +// The Qt window that everyone derives from. +//============================================================ +class WindowQt : public QMainWindow +{ + Q_OBJECT + +public: + WindowQt(running_machine* machine, QWidget* parent=NULL); + virtual ~WindowQt(); + + // The interface to an all-window refresh + void refreshAll() { s_refreshAll = true; } + bool wantsRefresh() { return s_refreshAll; } + void clearRefreshFlag() { s_refreshAll = false; } + + void hideAll() { s_hideAll = true; } + bool wantsHide() { return s_hideAll; } + void clearHideFlag() { s_hideAll = false; } + + +protected slots: + void debugActOpenMemory(); + void debugActOpenDasm(); + void debugActOpenLog(); + void debugActOpenPoints(); + void debugActOpenDevices(); + void debugActRun(); + void debugActRunAndHide(); + void debugActRunToNextCpu(); + void debugActRunNextInt(); + void debugActRunNextVBlank(); + void debugActStepInto(); + void debugActStepOver(); + void debugActStepOut(); + void debugActSoftReset(); + void debugActHardReset(); + virtual void debugActClose(); + void debugActQuit(); + + +protected: + running_machine* m_machine; + + static bool s_refreshAll; + static bool s_hideAll; +}; + + +//========================================================================= +// A way to store the configuration of a window long enough to read/write. +//========================================================================= +class WindowQtConfig +{ +public: + enum WindowType + { + WIN_TYPE_UNKNOWN, + WIN_TYPE_MAIN, + WIN_TYPE_MEMORY, + WIN_TYPE_DASM, + WIN_TYPE_LOG, + WIN_TYPE_BREAK_POINTS, + WIN_TYPE_DEVICES, + WIN_TYPE_DEVICE_INFORMATION + }; + +public: + WindowQtConfig(const WindowType& type=WIN_TYPE_UNKNOWN) : + m_type(type), + m_size(800, 600), + m_position(120, 120) + {} + virtual ~WindowQtConfig() {} + + // Settings + WindowType m_type; + QPoint m_size; + QPoint m_position; + + virtual void buildFromQWidget(QWidget* widget); + virtual void applyToQWidget(QWidget* widget); + virtual void addToXmlDataNode(xml_data_node* node) const; + virtual void recoverFromXmlNode(xml_data_node* node); +}; + + +#endif diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index f44cdd76c08..41e945b728d 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -728,24 +728,24 @@ $(OSDOBJ)/%.moc.c: $(OSDSRC)/%.h $(MOC) $(MOCINCPATH) $(DEFS) $< -o $@ DEBUGOBJS = \ - $(OSDOBJ)/modules/debugger/qt/debugqtview.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtwindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtdeviceswindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtdeviceinformationwindow.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtview.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtwindow.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtlogwindow.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtdasmwindow.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtmainwindow.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtmemorywindow.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtbreakpointswindow.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtdeviceswindow.moc.o \ - $(OSDOBJ)/modules/debugger/qt/debugqtdeviceinformationwindow.moc.o + $(OSDOBJ)/modules/debugger/qt/debuggerview.o \ + $(OSDOBJ)/modules/debugger/qt/windowqt.o \ + $(OSDOBJ)/modules/debugger/qt/logwindow.o \ + $(OSDOBJ)/modules/debugger/qt/dasmwindow.o \ + $(OSDOBJ)/modules/debugger/qt/mainwindow.o \ + $(OSDOBJ)/modules/debugger/qt/memorywindow.o \ + $(OSDOBJ)/modules/debugger/qt/breakpointswindow.o \ + $(OSDOBJ)/modules/debugger/qt/deviceswindow.o \ + $(OSDOBJ)/modules/debugger/qt/deviceinformationwindow.o \ + $(OSDOBJ)/modules/debugger/qt/debuggerview.moc.o \ + $(OSDOBJ)/modules/debugger/qt/windowqt.moc.o \ + $(OSDOBJ)/modules/debugger/qt/logwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/dasmwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/mainwindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/memorywindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/breakpointswindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/deviceswindow.moc.o \ + $(OSDOBJ)/modules/debugger/qt/deviceinformationwindow.moc.o DEFS += -DUSE_QTDEBUG=1 -- cgit v1.2.3 From 87e38fd1d30e53413bc1f94f0dfd340051a71253 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 15 Feb 2015 09:07:58 +1100 Subject: Remove redundant filename prefix --- src/osd/modules/debugger/debugosx.m | 4 +- src/osd/modules/debugger/osx/breakpointsview.h | 27 ++ src/osd/modules/debugger/osx/breakpointsview.m | 30 ++ src/osd/modules/debugger/osx/consoleview.h | 27 ++ src/osd/modules/debugger/osx/consoleview.m | 30 ++ src/osd/modules/debugger/osx/debugcommandhistory.h | 38 ++ src/osd/modules/debugger/osx/debugcommandhistory.m | 116 +++++ src/osd/modules/debugger/osx/debugconsole.h | 58 +++ src/osd/modules/debugger/osx/debugconsole.m | 375 +++++++++++++++ .../modules/debugger/osx/debugosxbreakpointsview.h | 26 -- .../modules/debugger/osx/debugosxbreakpointsview.m | 30 -- src/osd/modules/debugger/osx/debugosxconsoleview.h | 26 -- src/osd/modules/debugger/osx/debugosxconsoleview.m | 30 -- .../debugger/osx/debugosxdebugcommandhistory.h | 38 -- .../debugger/osx/debugosxdebugcommandhistory.m | 116 ----- .../modules/debugger/osx/debugosxdebugconsole.h | 57 --- .../modules/debugger/osx/debugosxdebugconsole.m | 375 --------------- src/osd/modules/debugger/osx/debugosxdebugview.h | 68 --- src/osd/modules/debugger/osx/debugosxdebugview.m | 514 --------------------- .../debugger/osx/debugosxdebugwindowhandler.h | 98 ---- .../debugger/osx/debugosxdebugwindowhandler.m | 403 ---------------- .../modules/debugger/osx/debugosxdisassemblyview.h | 46 -- .../modules/debugger/osx/debugosxdisassemblyview.m | 370 --------------- .../debugger/osx/debugosxdisassemblyviewer.h | 31 -- .../debugger/osx/debugosxdisassemblyviewer.m | 138 ------ .../modules/debugger/osx/debugosxerrorlogview.h | 26 -- .../modules/debugger/osx/debugosxerrorlogview.m | 30 -- .../modules/debugger/osx/debugosxerrorlogviewer.h | 29 -- .../modules/debugger/osx/debugosxerrorlogviewer.m | 64 --- src/osd/modules/debugger/osx/debugosxmemoryview.h | 45 -- src/osd/modules/debugger/osx/debugosxmemoryview.m | 226 --------- .../modules/debugger/osx/debugosxmemoryviewer.h | 31 -- .../modules/debugger/osx/debugosxmemoryviewer.m | 135 ------ .../modules/debugger/osx/debugosxpointsviewer.h | 31 -- .../modules/debugger/osx/debugosxpointsviewer.m | 147 ------ .../modules/debugger/osx/debugosxregistersview.h | 33 -- .../modules/debugger/osx/debugosxregistersview.m | 71 --- .../modules/debugger/osx/debugosxwatchpointsview.h | 26 -- .../modules/debugger/osx/debugosxwatchpointsview.m | 30 -- src/osd/modules/debugger/osx/debugview.h | 68 +++ src/osd/modules/debugger/osx/debugview.m | 514 +++++++++++++++++++++ src/osd/modules/debugger/osx/debugwindowhandler.h | 98 ++++ src/osd/modules/debugger/osx/debugwindowhandler.m | 403 ++++++++++++++++ src/osd/modules/debugger/osx/disassemblyview.h | 47 ++ src/osd/modules/debugger/osx/disassemblyview.m | 370 +++++++++++++++ src/osd/modules/debugger/osx/disassemblyviewer.h | 32 ++ src/osd/modules/debugger/osx/disassemblyviewer.m | 138 ++++++ src/osd/modules/debugger/osx/errorlogview.h | 27 ++ src/osd/modules/debugger/osx/errorlogview.m | 30 ++ src/osd/modules/debugger/osx/errorlogviewer.h | 30 ++ src/osd/modules/debugger/osx/errorlogviewer.m | 64 +++ src/osd/modules/debugger/osx/memoryview.h | 46 ++ src/osd/modules/debugger/osx/memoryview.m | 226 +++++++++ src/osd/modules/debugger/osx/memoryviewer.h | 32 ++ src/osd/modules/debugger/osx/memoryviewer.m | 135 ++++++ src/osd/modules/debugger/osx/pointsviewer.h | 32 ++ src/osd/modules/debugger/osx/pointsviewer.m | 147 ++++++ src/osd/modules/debugger/osx/registersview.h | 34 ++ src/osd/modules/debugger/osx/registersview.m | 71 +++ src/osd/modules/debugger/osx/watchpointsview.h | 27 ++ src/osd/modules/debugger/osx/watchpointsview.m | 30 ++ src/osd/sdl/sdl.mak | 30 +- 62 files changed, 3319 insertions(+), 3307 deletions(-) create mode 100644 src/osd/modules/debugger/osx/breakpointsview.h create mode 100644 src/osd/modules/debugger/osx/breakpointsview.m create mode 100644 src/osd/modules/debugger/osx/consoleview.h create mode 100644 src/osd/modules/debugger/osx/consoleview.m create mode 100644 src/osd/modules/debugger/osx/debugcommandhistory.h create mode 100644 src/osd/modules/debugger/osx/debugcommandhistory.m create mode 100644 src/osd/modules/debugger/osx/debugconsole.h create mode 100644 src/osd/modules/debugger/osx/debugconsole.m delete mode 100644 src/osd/modules/debugger/osx/debugosxbreakpointsview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxbreakpointsview.m delete mode 100644 src/osd/modules/debugger/osx/debugosxconsoleview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxconsoleview.m delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugcommandhistory.h delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugcommandhistory.m delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugconsole.h delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugconsole.m delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugview.m delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugwindowhandler.h delete mode 100644 src/osd/modules/debugger/osx/debugosxdebugwindowhandler.m delete mode 100644 src/osd/modules/debugger/osx/debugosxdisassemblyview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxdisassemblyview.m delete mode 100644 src/osd/modules/debugger/osx/debugosxdisassemblyviewer.h delete mode 100644 src/osd/modules/debugger/osx/debugosxdisassemblyviewer.m delete mode 100644 src/osd/modules/debugger/osx/debugosxerrorlogview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxerrorlogview.m delete mode 100644 src/osd/modules/debugger/osx/debugosxerrorlogviewer.h delete mode 100644 src/osd/modules/debugger/osx/debugosxerrorlogviewer.m delete mode 100644 src/osd/modules/debugger/osx/debugosxmemoryview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxmemoryview.m delete mode 100644 src/osd/modules/debugger/osx/debugosxmemoryviewer.h delete mode 100644 src/osd/modules/debugger/osx/debugosxmemoryviewer.m delete mode 100644 src/osd/modules/debugger/osx/debugosxpointsviewer.h delete mode 100644 src/osd/modules/debugger/osx/debugosxpointsviewer.m delete mode 100644 src/osd/modules/debugger/osx/debugosxregistersview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxregistersview.m delete mode 100644 src/osd/modules/debugger/osx/debugosxwatchpointsview.h delete mode 100644 src/osd/modules/debugger/osx/debugosxwatchpointsview.m create mode 100644 src/osd/modules/debugger/osx/debugview.h create mode 100644 src/osd/modules/debugger/osx/debugview.m create mode 100644 src/osd/modules/debugger/osx/debugwindowhandler.h create mode 100644 src/osd/modules/debugger/osx/debugwindowhandler.m create mode 100644 src/osd/modules/debugger/osx/disassemblyview.h create mode 100644 src/osd/modules/debugger/osx/disassemblyview.m create mode 100644 src/osd/modules/debugger/osx/disassemblyviewer.h create mode 100644 src/osd/modules/debugger/osx/disassemblyviewer.m create mode 100644 src/osd/modules/debugger/osx/errorlogview.h create mode 100644 src/osd/modules/debugger/osx/errorlogview.m create mode 100644 src/osd/modules/debugger/osx/errorlogviewer.h create mode 100644 src/osd/modules/debugger/osx/errorlogviewer.m create mode 100644 src/osd/modules/debugger/osx/memoryview.h create mode 100644 src/osd/modules/debugger/osx/memoryview.m create mode 100644 src/osd/modules/debugger/osx/memoryviewer.h create mode 100644 src/osd/modules/debugger/osx/memoryviewer.m create mode 100644 src/osd/modules/debugger/osx/pointsviewer.h create mode 100644 src/osd/modules/debugger/osx/pointsviewer.m create mode 100644 src/osd/modules/debugger/osx/registersview.h create mode 100644 src/osd/modules/debugger/osx/registersview.m create mode 100644 src/osd/modules/debugger/osx/watchpointsview.h create mode 100644 src/osd/modules/debugger/osx/watchpointsview.m diff --git a/src/osd/modules/debugger/debugosx.m b/src/osd/modules/debugger/debugosx.m index 440a201a2bf..7e713fc2e60 100644 --- a/src/osd/modules/debugger/debugosx.m +++ b/src/osd/modules/debugger/debugosx.m @@ -30,8 +30,8 @@ #include "osdsdl.h" #include "debug_module.h" -#import "osx/debugosxdebugconsole.h" -#import "osx/debugosxdebugwindowhandler.h" +#import "osx/debugconsole.h" +#import "osx/debugwindowhandler.h" //============================================================ diff --git a/src/osd/modules/debugger/osx/breakpointsview.h b/src/osd/modules/debugger/osx/breakpointsview.h new file mode 100644 index 00000000000..f2701200e25 --- /dev/null +++ b/src/osd/modules/debugger/osx/breakpointsview.h @@ -0,0 +1,27 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxbreakpointsview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugview.h" + +#include "emu.h" + +#import + + +@interface MAMEBreakpointsView : MAMEDebugView +{ +} + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; + +@end diff --git a/src/osd/modules/debugger/osx/breakpointsview.m b/src/osd/modules/debugger/osx/breakpointsview.m new file mode 100644 index 00000000000..d84f1efbce1 --- /dev/null +++ b/src/osd/modules/debugger/osx/breakpointsview.m @@ -0,0 +1,30 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxbreakpointsview.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "breakpointsview.h" + +#include "debug/debugvw.h" + + +@implementation MAMEBreakpointsView + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { + if (!(self = [super initWithFrame:f type:DVT_BREAK_POINTS machine:m])) + return nil; + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + +@end diff --git a/src/osd/modules/debugger/osx/consoleview.h b/src/osd/modules/debugger/osx/consoleview.h new file mode 100644 index 00000000000..9ff4f15fa9f --- /dev/null +++ b/src/osd/modules/debugger/osx/consoleview.h @@ -0,0 +1,27 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxconsoleview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugview.h" + +#include "emu.h" + +#import + + +@interface MAMEConsoleView : MAMEDebugView +{ +} + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; + +@end diff --git a/src/osd/modules/debugger/osx/consoleview.m b/src/osd/modules/debugger/osx/consoleview.m new file mode 100644 index 00000000000..b0777cd2a84 --- /dev/null +++ b/src/osd/modules/debugger/osx/consoleview.m @@ -0,0 +1,30 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxconsoleview.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "consoleview.h" + +#include "debug/debugvw.h" + + +@implementation MAMEConsoleView + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { + if (!(self = [super initWithFrame:f type:DVT_CONSOLE machine:m])) + return nil; + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + +@end diff --git a/src/osd/modules/debugger/osx/debugcommandhistory.h b/src/osd/modules/debugger/osx/debugcommandhistory.h new file mode 100644 index 00000000000..3cb0f23d06c --- /dev/null +++ b/src/osd/modules/debugger/osx/debugcommandhistory.h @@ -0,0 +1,38 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugcommandhistory.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import + + +@interface MAMEDebugCommandHistory : NSObject +{ + NSInteger length, position; + NSString *current; + NSMutableArray *history; +} + ++ (NSInteger)defaultLength; + +- (id)init; + +- (NSInteger)length; +- (void)setLength:(NSInteger)l; + +- (void)add:(NSString *)entry; +- (NSString *)previous:(NSString *)cur; +- (NSString *)next:(NSString *)cur; +- (void)edit; +- (void)reset; +- (void)clear; + +@end diff --git a/src/osd/modules/debugger/osx/debugcommandhistory.m b/src/osd/modules/debugger/osx/debugcommandhistory.m new file mode 100644 index 00000000000..b7f9e4bf91d --- /dev/null +++ b/src/osd/modules/debugger/osx/debugcommandhistory.m @@ -0,0 +1,116 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugcommandhistory.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +//============================================================ +// MAMEDebugView class +//============================================================ + +#import "debugcommandhistory.h" + + +@implementation MAMEDebugCommandHistory + ++ (NSInteger)defaultLength { + return 100; +} + + +- (id)init { + if (!(self = [super init])) + return nil; + length = [[self class] defaultLength]; + position = -1; + current = nil; + history = [[NSMutableArray alloc] initWithCapacity:length]; + return self; +} + + +- (void)dealloc { + if (current != nil) + [current release]; + if (history != nil) + [history release]; + [super dealloc]; +} + + +- (NSInteger)length { + return length; +} + + +- (void)setLength:(NSInteger)l { + length = l; + if ([history count] > length) + [history removeObjectsInRange:NSMakeRange(length, [history count] - length)]; +} + + +- (void)add:(NSString *)entry { + if (([history count] == 0) || ![[history objectAtIndex:0] isEqualToString:entry]) { + [history insertObject:entry atIndex:0]; + while ([history count] > length) + [history removeLastObject]; + } + position = 0; +} + + +- (NSString *)previous:(NSString *)cur { + if ((position + 1) < [history count]) { + if (position < 0) { + [current autorelease]; + current = [cur copy]; + } + return [history objectAtIndex:++position]; + } else { + return nil; + } +} + + +- (NSString *)next:(NSString *)cur { + if (position > 0) { + return [history objectAtIndex:--position]; + } else if ((position == 0) && (current != nil) && ![current isEqualToString:[history objectAtIndex:0]]) { + position--; + return [[current retain] autorelease]; + } else { + return nil; + } +} + + +- (void)edit { + if (position == 0) + position--; +} + +- (void)reset { + position = -1; + if (current != nil) { + [current release]; + current = nil; + } +} + + +- (void)clear { + position = -1; + if (current != nil) { + [current release]; + current = nil; + } + [history removeAllObjects]; +} + +@end diff --git a/src/osd/modules/debugger/osx/debugconsole.h b/src/osd/modules/debugger/osx/debugconsole.h new file mode 100644 index 00000000000..862c035cbb4 --- /dev/null +++ b/src/osd/modules/debugger/osx/debugconsole.h @@ -0,0 +1,58 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugconsole.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugwindowhandler.h" + +#include "emu.h" + +#import + + +@class MAMEDebugCommandHistory, MAMEDebugView, MAMEDisassemblyView, MAMERegistersView; + +@interface MAMEDebugConsole : MAMEDebugWindowHandler +{ + MAMEDebugCommandHistory *history; + NSMutableArray *auxiliaryWindows; + + MAMERegistersView *regView; + MAMEDisassemblyView *dasmView; + MAMEDebugView *consoleView; + NSTextField *commandField; +} + +- (id)initWithMachine:(running_machine &)m; + +- (void)setCPU:(device_t *)device; + +- (IBAction)doCommand:(id)sender; + +- (IBAction)debugNewMemoryWindow:(id)sender; +- (IBAction)debugNewDisassemblyWindow:(id)sender; +- (IBAction)debugNewErrorLogWindow:(id)sender; +- (IBAction)debugNewPointsWindow:(id)sender; + +- (void)showDebugger:(NSNotification *)notification; +- (void)auxiliaryWindowWillClose:(NSNotification *)notification; + +- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor; +- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command; + +- (void)windowWillClose:(NSNotification *)notification; + +- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)min ofSubviewAt:(NSInteger)offs; +- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)max ofSubviewAt:(NSInteger)offs; +- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview; +- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize; + +@end diff --git a/src/osd/modules/debugger/osx/debugconsole.m b/src/osd/modules/debugger/osx/debugconsole.m new file mode 100644 index 00000000000..d3aec2bb88a --- /dev/null +++ b/src/osd/modules/debugger/osx/debugconsole.m @@ -0,0 +1,375 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugconsole.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugconsole.h" + +#import "debugcommandhistory.h" +#import "consoleview.h" +#import "debugview.h" +#import "disassemblyview.h" +#import "disassemblyviewer.h" +#import "errorlogviewer.h" +#import "memoryviewer.h" +#import "pointsviewer.h" +#import "registersview.h" + +#include "debug/debugcon.h" +#include "debug/debugcpu.h" + + +@implementation MAMEDebugConsole + +- (id)initWithMachine:(running_machine &)m { + NSSplitView *regSplit, *dasmSplit; + NSScrollView *regScroll, *dasmScroll, *consoleScroll; + NSView *consoleContainer; + NSPopUpButton *actionButton; + NSRect rct; + + // initialise superclass + if (!(self = [super initWithMachine:m title:@"Debug"])) + return nil; + history = [[MAMEDebugCommandHistory alloc] init]; + auxiliaryWindows = [[NSMutableArray alloc] init]; + + // create the register view + regView = [[MAMERegistersView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; + regScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [regScroll setDrawsBackground:YES]; + [regScroll setHasHorizontalScroller:YES]; + [regScroll setHasVerticalScroller:YES]; + [regScroll setAutohidesScrollers:YES]; + [regScroll setBorderType:NSBezelBorder]; + [regScroll setDocumentView:regView]; + [regView release]; + + // create the disassembly view + dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) + machine:*machine + useConsole:YES]; + [dasmView setExpression:@"curpc"]; + dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [dasmScroll setDrawsBackground:YES]; + [dasmScroll setHasHorizontalScroller:YES]; + [dasmScroll setHasVerticalScroller:YES]; + [dasmScroll setAutohidesScrollers:YES]; + [dasmScroll setBorderType:NSBezelBorder]; + [dasmScroll setDocumentView:dasmView]; + [dasmView release]; + + // create the console view + consoleView = [[MAMEConsoleView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; + consoleScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [consoleScroll setDrawsBackground:YES]; + [consoleScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [consoleScroll setHasHorizontalScroller:YES]; + [consoleScroll setHasVerticalScroller:YES]; + [consoleScroll setAutohidesScrollers:YES]; + [consoleScroll setBorderType:NSBezelBorder]; + [consoleScroll setDocumentView:consoleView]; + [consoleView release]; + + // create the command field + commandField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; + [commandField setAutoresizingMask:(NSViewWidthSizable | NSViewMaxYMargin)]; + [commandField setFont:[[MAMEDebugView class] defaultFont]]; + [commandField setFocusRingType:NSFocusRingTypeNone]; + [commandField setTarget:self]; + [commandField setAction:@selector(doCommand:)]; + [commandField setDelegate:self]; + rct = [commandField frame]; + [commandField setFrame:NSMakeRect(rct.size.height, 0, rct.size.width - rct.size.height, rct.size.height)]; + + // create the action pull-down button + actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, 0, rct.size.height, rct.size.height)]; + [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMaxYMargin)]; + [dasmView insertActionItemsInMenu:[actionButton menu] atIndex:1]; + + // create the container for the console and command input field + consoleContainer = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [consoleScroll setFrame:NSMakeRect(0, + rct.size.height, + 100, + [consoleContainer bounds].size.height - rct.size.height)]; + [consoleContainer addSubview:consoleScroll]; + [consoleContainer addSubview:commandField]; + [consoleContainer addSubview:actionButton]; + [consoleScroll release]; + [commandField release]; + [actionButton release]; + + // create the split between the disassembly and the console + dasmSplit = [[NSSplitView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [dasmSplit setDelegate:self]; + [dasmSplit setVertical:NO]; + [dasmSplit addSubview:dasmScroll]; + [dasmSplit addSubview:consoleContainer]; + [dasmScroll release]; + [consoleContainer release]; + + // create the split between the registers and the console + regSplit = [[NSSplitView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [regSplit setDelegate:self]; + [regSplit setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [regSplit setVertical:YES]; + [regSplit addSubview:regScroll]; + [regSplit addSubview:dasmSplit]; + [regScroll release]; + [dasmSplit release]; + + // put the split views in the window and get them into a half-reasonable state + [window setContentView:regSplit]; + [regSplit release]; + [regSplit adjustSubviews]; + [dasmSplit adjustSubviews]; + + // keyboard focus should start on the command field + [window makeFirstResponder:commandField]; + + // calculate the optimal size for everything + { + NSRect available = [[NSScreen mainScreen] visibleFrame]; + NSRect windowFrame = [window frame]; + NSSize regCurrent = [regScroll frame].size; + NSSize regSize = [NSScrollView frameSizeForContentSize:[regView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[regScroll borderType]]; + NSSize dasmCurrent = [dasmScroll frame].size; + NSSize dasmSize = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[dasmScroll borderType]]; + NSSize consoleCurrent = [consoleContainer frame].size; + NSSize consoleSize = [NSScrollView frameSizeForContentSize:[consoleView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[consoleScroll borderType]]; + NSSize adjustment; + NSRect lhsFrame, rhsFrame; + + consoleSize.width += consoleCurrent.width - [consoleScroll frame].size.width; + consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height; + adjustment.width = regSize.width - regCurrent.width; + adjustment.height = regSize.height - regCurrent.height; + adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width); + + windowFrame.size.width += adjustment.width; + windowFrame.size.height += adjustment.height; // not used - better to go for fixed height + windowFrame.size.height = MIN(512.0, available.size.height); + windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); + windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; + windowFrame.origin.y = available.origin.y; + [window setFrame:windowFrame display:YES]; + + lhsFrame = [regScroll frame]; + rhsFrame = [dasmSplit frame]; + adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2); + rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width; + rhsFrame.size.width += lhsFrame.size.width - adjustment.width; + lhsFrame.size.width = adjustment.width; + [regScroll setFrame:lhsFrame]; + [dasmSplit setFrame:rhsFrame]; + } + + // select the current processor + [self setCPU:machine->firstcpu]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(auxiliaryWindowWillClose:) + name:MAMEAuxiliaryDebugWindowWillCloseNotification + object:nil]; + + // don't forget the return value + return self; +} + + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + if (history != nil) + [history release]; + if (auxiliaryWindows != nil) + [auxiliaryWindows release]; + + [super dealloc]; +} + + +- (void)setCPU:(device_t *)device { + [regView selectSubviewForCPU:device]; + [dasmView selectSubviewForCPU:device]; + [window setTitle:[NSString stringWithFormat:@"Debug: %s - %s '%s'", + device->machine().system().name, + device->name(), + device->tag()]]; +} + + +- (IBAction)doCommand:(id)sender { + NSString *command = [sender stringValue]; + if ([command length] == 0) { + debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); + [history reset]; + } else { + debug_console_execute_command(*machine, [command UTF8String], 1); + [history add:command]; + [history edit]; + } + [sender setStringValue:@""]; +} + + +- (IBAction)debugNewMemoryWindow:(id)sender { + MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + [win activate]; +} + + +- (IBAction)debugNewDisassemblyWindow:(id)sender { + MAMEDisassemblyViewer *win = [[MAMEDisassemblyViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + [win activate]; +} + + +- (IBAction)debugNewErrorLogWindow:(id)sender { + MAMEErrorLogViewer *win = [[MAMEErrorLogViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + [win activate]; +} + + +- (IBAction)debugNewPointsWindow:(id)sender{ + MAMEPointsViewer *win = [[MAMEPointsViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + [win activate]; +} + + +- (void)showDebugger:(NSNotification *)notification { + device_t *device = (device_t * )[[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue]; + if (&device->machine() == machine) { + [self setCPU:device]; + [window makeKeyAndOrderFront:self]; + } +} + + +- (void)auxiliaryWindowWillClose:(NSNotification *)notification { + [auxiliaryWindows removeObjectIdenticalTo:[notification object]]; +} + + +- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor { + if (control == commandField) + [history edit]; + + return YES; +} + + +- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { + if (control == commandField) { + if (command == @selector(cancelOperation:)) { + [commandField setStringValue:@""]; + [history reset]; + return YES; + } else if (command == @selector(moveUp:)) { + NSString *hist = [history previous:[commandField stringValue]]; + if (hist != nil) { + [commandField setStringValue:hist]; + [commandField selectText:self]; + [(NSText *)[window firstResponder] setSelectedRange:NSMakeRange([hist length], 0)]; + } + return YES; + } else if (command == @selector(moveDown:)) { + NSString *hist = [history next:[commandField stringValue]]; + if (hist != nil) { + [commandField setStringValue:hist]; + [commandField selectText:self]; + [(NSText *)[window firstResponder] setSelectedRange:NSMakeRange([hist length], 0)]; + } + return YES; + } + } + return NO; +} + + +- (void)windowWillClose:(NSNotification *)notification { + if ([notification object] != window) + return; + [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification object:self]; + debug_cpu_get_visible_cpu(*machine)->debug()->go(); +} + + +- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)min ofSubviewAt:(NSInteger)offs { + return (min < 100) ? 100 : min; +} + + +- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)max ofSubviewAt:(NSInteger)offs { + NSSize sz = [sender bounds].size; + CGFloat allowed = ([sender isVertical] ? sz.width : sz.height) - 100 - [sender dividerThickness]; + return (max > allowed) ? allowed : max; +} + + +- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview { + // allow registers or disassembly to be collapsed, but not console + return [[sender subviews] indexOfObjectIdenticalTo:subview] == 0; +} + + +- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize { + // This can only deal with a single split, but that's all we use, anyway + NSRect first, second; + [sender adjustSubviews]; + first = [[[sender subviews] objectAtIndex:0] frame]; + second = [[[sender subviews] objectAtIndex:1] frame]; + if ([sender isVertical]) { + if (first.size.width < 100) { + CGFloat diff = 100 - first.size.width; + first.size.width = 100; + second.origin.x += diff; + second.size.width -= diff; + } else if (second.size.width < 100) { + CGFloat diff = 100 - second.size.width; + second.size.width = 100; + second.origin.x -= diff; + first.size.width -= diff; + } + } else { + if (first.size.height < 100) { + CGFloat diff = 100 - first.size.height; + first.size.height = 100; + second.origin.y += diff; + second.size.height -= diff; + } else if (second.size.height < 100) { + CGFloat diff = 100 - second.size.height; + second.size.height = 100; + second.origin.y -= diff; + first.size.height -= diff; + } + } + [[[sender subviews] objectAtIndex:0] setFrame:first]; + [[[sender subviews] objectAtIndex:1] setFrame:second]; +} + +@end diff --git a/src/osd/modules/debugger/osx/debugosxbreakpointsview.h b/src/osd/modules/debugger/osx/debugosxbreakpointsview.h deleted file mode 100644 index 16dd78f8420..00000000000 --- a/src/osd/modules/debugger/osx/debugosxbreakpointsview.h +++ /dev/null @@ -1,26 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxbreakpointsview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugview.h" - -#include "emu.h" - -#import - - -@interface MAMEBreakpointsView : MAMEDebugView -{ -} - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxbreakpointsview.m b/src/osd/modules/debugger/osx/debugosxbreakpointsview.m deleted file mode 100644 index a244e17fe7e..00000000000 --- a/src/osd/modules/debugger/osx/debugosxbreakpointsview.m +++ /dev/null @@ -1,30 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxbreakpointsview.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxbreakpointsview.h" - -#include "debug/debugvw.h" - - -@implementation MAMEBreakpointsView - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { - if (!(self = [super initWithFrame:f type:DVT_BREAK_POINTS machine:m])) - return nil; - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxconsoleview.h b/src/osd/modules/debugger/osx/debugosxconsoleview.h deleted file mode 100644 index 0c9740f02db..00000000000 --- a/src/osd/modules/debugger/osx/debugosxconsoleview.h +++ /dev/null @@ -1,26 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxconsoleview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugview.h" - -#include "emu.h" - -#import - - -@interface MAMEConsoleView : MAMEDebugView -{ -} - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxconsoleview.m b/src/osd/modules/debugger/osx/debugosxconsoleview.m deleted file mode 100644 index 746fa26cf93..00000000000 --- a/src/osd/modules/debugger/osx/debugosxconsoleview.m +++ /dev/null @@ -1,30 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxconsoleview.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxconsoleview.h" - -#include "debug/debugvw.h" - - -@implementation MAMEConsoleView - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { - if (!(self = [super initWithFrame:f type:DVT_CONSOLE machine:m])) - return nil; - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugcommandhistory.h b/src/osd/modules/debugger/osx/debugosxdebugcommandhistory.h deleted file mode 100644 index 3cb0f23d06c..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugcommandhistory.h +++ /dev/null @@ -1,38 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugcommandhistory.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" - -#import - - -@interface MAMEDebugCommandHistory : NSObject -{ - NSInteger length, position; - NSString *current; - NSMutableArray *history; -} - -+ (NSInteger)defaultLength; - -- (id)init; - -- (NSInteger)length; -- (void)setLength:(NSInteger)l; - -- (void)add:(NSString *)entry; -- (NSString *)previous:(NSString *)cur; -- (NSString *)next:(NSString *)cur; -- (void)edit; -- (void)reset; -- (void)clear; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugcommandhistory.m b/src/osd/modules/debugger/osx/debugosxdebugcommandhistory.m deleted file mode 100644 index 0d9967370a5..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugcommandhistory.m +++ /dev/null @@ -1,116 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugcommandhistory.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -//============================================================ -// MAMEDebugView class -//============================================================ - -#import "debugosxdebugcommandhistory.h" - - -@implementation MAMEDebugCommandHistory - -+ (NSInteger)defaultLength { - return 100; -} - - -- (id)init { - if (!(self = [super init])) - return nil; - length = [[self class] defaultLength]; - position = -1; - current = nil; - history = [[NSMutableArray alloc] initWithCapacity:length]; - return self; -} - - -- (void)dealloc { - if (current != nil) - [current release]; - if (history != nil) - [history release]; - [super dealloc]; -} - - -- (NSInteger)length { - return length; -} - - -- (void)setLength:(NSInteger)l { - length = l; - if ([history count] > length) - [history removeObjectsInRange:NSMakeRange(length, [history count] - length)]; -} - - -- (void)add:(NSString *)entry { - if (([history count] == 0) || ![[history objectAtIndex:0] isEqualToString:entry]) { - [history insertObject:entry atIndex:0]; - while ([history count] > length) - [history removeLastObject]; - } - position = 0; -} - - -- (NSString *)previous:(NSString *)cur { - if ((position + 1) < [history count]) { - if (position < 0) { - [current autorelease]; - current = [cur copy]; - } - return [history objectAtIndex:++position]; - } else { - return nil; - } -} - - -- (NSString *)next:(NSString *)cur { - if (position > 0) { - return [history objectAtIndex:--position]; - } else if ((position == 0) && (current != nil) && ![current isEqualToString:[history objectAtIndex:0]]) { - position--; - return [[current retain] autorelease]; - } else { - return nil; - } -} - - -- (void)edit { - if (position == 0) - position--; -} - -- (void)reset { - position = -1; - if (current != nil) { - [current release]; - current = nil; - } -} - - -- (void)clear { - position = -1; - if (current != nil) { - [current release]; - current = nil; - } - [history removeAllObjects]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugconsole.h b/src/osd/modules/debugger/osx/debugosxdebugconsole.h deleted file mode 100644 index 941a6ab2b9e..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugconsole.h +++ /dev/null @@ -1,57 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugconsole.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugwindowhandler.h" - -#include "emu.h" - -#import - - -@class MAMEDebugCommandHistory, MAMEDebugView, MAMEDisassemblyView, MAMERegistersView; - -@interface MAMEDebugConsole : MAMEDebugWindowHandler -{ - MAMEDebugCommandHistory *history; - NSMutableArray *auxiliaryWindows; - - MAMERegistersView *regView; - MAMEDisassemblyView *dasmView; - MAMEDebugView *consoleView; - NSTextField *commandField; -} - -- (id)initWithMachine:(running_machine &)m; - -- (void)setCPU:(device_t *)device; - -- (IBAction)doCommand:(id)sender; - -- (IBAction)debugNewMemoryWindow:(id)sender; -- (IBAction)debugNewDisassemblyWindow:(id)sender; -- (IBAction)debugNewErrorLogWindow:(id)sender; -- (IBAction)debugNewPointsWindow:(id)sender; - -- (void)showDebugger:(NSNotification *)notification; -- (void)auxiliaryWindowWillClose:(NSNotification *)notification; - -- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor; -- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command; - -- (void)windowWillClose:(NSNotification *)notification; - -- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)min ofSubviewAt:(NSInteger)offs; -- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)max ofSubviewAt:(NSInteger)offs; -- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview; -- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugconsole.m b/src/osd/modules/debugger/osx/debugosxdebugconsole.m deleted file mode 100644 index 2b6785b3b9e..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugconsole.m +++ /dev/null @@ -1,375 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugconsole.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxdebugconsole.h" - -#import "debugosxdebugcommandhistory.h" -#import "debugosxconsoleview.h" -#import "debugosxdebugview.h" -#import "debugosxdisassemblyview.h" -#import "debugosxdisassemblyviewer.h" -#import "debugosxerrorlogviewer.h" -#import "debugosxmemoryviewer.h" -#import "debugosxpointsviewer.h" -#import "debugosxregistersview.h" - -#include "debug/debugcon.h" -#include "debug/debugcpu.h" - - -@implementation MAMEDebugConsole - -- (id)initWithMachine:(running_machine &)m { - NSSplitView *regSplit, *dasmSplit; - NSScrollView *regScroll, *dasmScroll, *consoleScroll; - NSView *consoleContainer; - NSPopUpButton *actionButton; - NSRect rct; - - // initialise superclass - if (!(self = [super initWithMachine:m title:@"Debug"])) - return nil; - history = [[MAMEDebugCommandHistory alloc] init]; - auxiliaryWindows = [[NSMutableArray alloc] init]; - - // create the register view - regView = [[MAMERegistersView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; - regScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - [regScroll setDrawsBackground:YES]; - [regScroll setHasHorizontalScroller:YES]; - [regScroll setHasVerticalScroller:YES]; - [regScroll setAutohidesScrollers:YES]; - [regScroll setBorderType:NSBezelBorder]; - [regScroll setDocumentView:regView]; - [regView release]; - - // create the disassembly view - dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) - machine:*machine - useConsole:YES]; - [dasmView setExpression:@"curpc"]; - dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - [dasmScroll setDrawsBackground:YES]; - [dasmScroll setHasHorizontalScroller:YES]; - [dasmScroll setHasVerticalScroller:YES]; - [dasmScroll setAutohidesScrollers:YES]; - [dasmScroll setBorderType:NSBezelBorder]; - [dasmScroll setDocumentView:dasmView]; - [dasmView release]; - - // create the console view - consoleView = [[MAMEConsoleView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; - consoleScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - [consoleScroll setDrawsBackground:YES]; - [consoleScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [consoleScroll setHasHorizontalScroller:YES]; - [consoleScroll setHasVerticalScroller:YES]; - [consoleScroll setAutohidesScrollers:YES]; - [consoleScroll setBorderType:NSBezelBorder]; - [consoleScroll setDocumentView:consoleView]; - [consoleView release]; - - // create the command field - commandField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; - [commandField setAutoresizingMask:(NSViewWidthSizable | NSViewMaxYMargin)]; - [commandField setFont:[[MAMEDebugView class] defaultFont]]; - [commandField setFocusRingType:NSFocusRingTypeNone]; - [commandField setTarget:self]; - [commandField setAction:@selector(doCommand:)]; - [commandField setDelegate:self]; - rct = [commandField frame]; - [commandField setFrame:NSMakeRect(rct.size.height, 0, rct.size.width - rct.size.height, rct.size.height)]; - - // create the action pull-down button - actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, 0, rct.size.height, rct.size.height)]; - [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMaxYMargin)]; - [dasmView insertActionItemsInMenu:[actionButton menu] atIndex:1]; - - // create the container for the console and command input field - consoleContainer = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - [consoleScroll setFrame:NSMakeRect(0, - rct.size.height, - 100, - [consoleContainer bounds].size.height - rct.size.height)]; - [consoleContainer addSubview:consoleScroll]; - [consoleContainer addSubview:commandField]; - [consoleContainer addSubview:actionButton]; - [consoleScroll release]; - [commandField release]; - [actionButton release]; - - // create the split between the disassembly and the console - dasmSplit = [[NSSplitView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - [dasmSplit setDelegate:self]; - [dasmSplit setVertical:NO]; - [dasmSplit addSubview:dasmScroll]; - [dasmSplit addSubview:consoleContainer]; - [dasmScroll release]; - [consoleContainer release]; - - // create the split between the registers and the console - regSplit = [[NSSplitView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - [regSplit setDelegate:self]; - [regSplit setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [regSplit setVertical:YES]; - [regSplit addSubview:regScroll]; - [regSplit addSubview:dasmSplit]; - [regScroll release]; - [dasmSplit release]; - - // put the split views in the window and get them into a half-reasonable state - [window setContentView:regSplit]; - [regSplit release]; - [regSplit adjustSubviews]; - [dasmSplit adjustSubviews]; - - // keyboard focus should start on the command field - [window makeFirstResponder:commandField]; - - // calculate the optimal size for everything - { - NSRect available = [[NSScreen mainScreen] visibleFrame]; - NSRect windowFrame = [window frame]; - NSSize regCurrent = [regScroll frame].size; - NSSize regSize = [NSScrollView frameSizeForContentSize:[regView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[regScroll borderType]]; - NSSize dasmCurrent = [dasmScroll frame].size; - NSSize dasmSize = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[dasmScroll borderType]]; - NSSize consoleCurrent = [consoleContainer frame].size; - NSSize consoleSize = [NSScrollView frameSizeForContentSize:[consoleView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[consoleScroll borderType]]; - NSSize adjustment; - NSRect lhsFrame, rhsFrame; - - consoleSize.width += consoleCurrent.width - [consoleScroll frame].size.width; - consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height; - adjustment.width = regSize.width - regCurrent.width; - adjustment.height = regSize.height - regCurrent.height; - adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width); - - windowFrame.size.width += adjustment.width; - windowFrame.size.height += adjustment.height; // not used - better to go for fixed height - windowFrame.size.height = MIN(512.0, available.size.height); - windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); - windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; - windowFrame.origin.y = available.origin.y; - [window setFrame:windowFrame display:YES]; - - lhsFrame = [regScroll frame]; - rhsFrame = [dasmSplit frame]; - adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2); - rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width; - rhsFrame.size.width += lhsFrame.size.width - adjustment.width; - lhsFrame.size.width = adjustment.width; - [regScroll setFrame:lhsFrame]; - [dasmSplit setFrame:rhsFrame]; - } - - // select the current processor - [self setCPU:machine->firstcpu]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(auxiliaryWindowWillClose:) - name:MAMEAuxiliaryDebugWindowWillCloseNotification - object:nil]; - - // don't forget the return value - return self; -} - - -- (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - if (history != nil) - [history release]; - if (auxiliaryWindows != nil) - [auxiliaryWindows release]; - - [super dealloc]; -} - - -- (void)setCPU:(device_t *)device { - [regView selectSubviewForCPU:device]; - [dasmView selectSubviewForCPU:device]; - [window setTitle:[NSString stringWithFormat:@"Debug: %s - %s '%s'", - device->machine().system().name, - device->name(), - device->tag()]]; -} - - -- (IBAction)doCommand:(id)sender { - NSString *command = [sender stringValue]; - if ([command length] == 0) { - debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); - [history reset]; - } else { - debug_console_execute_command(*machine, [command UTF8String], 1); - [history add:command]; - [history edit]; - } - [sender setStringValue:@""]; -} - - -- (IBAction)debugNewMemoryWindow:(id)sender { - MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self]; - [auxiliaryWindows addObject:win]; - [win release]; - [win activate]; -} - - -- (IBAction)debugNewDisassemblyWindow:(id)sender { - MAMEDisassemblyViewer *win = [[MAMEDisassemblyViewer alloc] initWithMachine:*machine console:self]; - [auxiliaryWindows addObject:win]; - [win release]; - [win activate]; -} - - -- (IBAction)debugNewErrorLogWindow:(id)sender { - MAMEErrorLogViewer *win = [[MAMEErrorLogViewer alloc] initWithMachine:*machine console:self]; - [auxiliaryWindows addObject:win]; - [win release]; - [win activate]; -} - - -- (IBAction)debugNewPointsWindow:(id)sender{ - MAMEPointsViewer *win = [[MAMEPointsViewer alloc] initWithMachine:*machine console:self]; - [auxiliaryWindows addObject:win]; - [win release]; - [win activate]; -} - - -- (void)showDebugger:(NSNotification *)notification { - device_t *device = (device_t * )[[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue]; - if (&device->machine() == machine) { - [self setCPU:device]; - [window makeKeyAndOrderFront:self]; - } -} - - -- (void)auxiliaryWindowWillClose:(NSNotification *)notification { - [auxiliaryWindows removeObjectIdenticalTo:[notification object]]; -} - - -- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor { - if (control == commandField) - [history edit]; - - return YES; -} - - -- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { - if (control == commandField) { - if (command == @selector(cancelOperation:)) { - [commandField setStringValue:@""]; - [history reset]; - return YES; - } else if (command == @selector(moveUp:)) { - NSString *hist = [history previous:[commandField stringValue]]; - if (hist != nil) { - [commandField setStringValue:hist]; - [commandField selectText:self]; - [(NSText *)[window firstResponder] setSelectedRange:NSMakeRange([hist length], 0)]; - } - return YES; - } else if (command == @selector(moveDown:)) { - NSString *hist = [history next:[commandField stringValue]]; - if (hist != nil) { - [commandField setStringValue:hist]; - [commandField selectText:self]; - [(NSText *)[window firstResponder] setSelectedRange:NSMakeRange([hist length], 0)]; - } - return YES; - } - } - return NO; -} - - -- (void)windowWillClose:(NSNotification *)notification { - if ([notification object] != window) - return; - [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification object:self]; - debug_cpu_get_visible_cpu(*machine)->debug()->go(); -} - - -- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)min ofSubviewAt:(NSInteger)offs { - return (min < 100) ? 100 : min; -} - - -- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)max ofSubviewAt:(NSInteger)offs { - NSSize sz = [sender bounds].size; - CGFloat allowed = ([sender isVertical] ? sz.width : sz.height) - 100 - [sender dividerThickness]; - return (max > allowed) ? allowed : max; -} - - -- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview { - // allow registers or disassembly to be collapsed, but not console - return [[sender subviews] indexOfObjectIdenticalTo:subview] == 0; -} - - -- (void)splitView:(NSSplitView *)sender resizeSubviewsWithOldSize:(NSSize)oldSize { - // This can only deal with a single split, but that's all we use, anyway - NSRect first, second; - [sender adjustSubviews]; - first = [[[sender subviews] objectAtIndex:0] frame]; - second = [[[sender subviews] objectAtIndex:1] frame]; - if ([sender isVertical]) { - if (first.size.width < 100) { - CGFloat diff = 100 - first.size.width; - first.size.width = 100; - second.origin.x += diff; - second.size.width -= diff; - } else if (second.size.width < 100) { - CGFloat diff = 100 - second.size.width; - second.size.width = 100; - second.origin.x -= diff; - first.size.width -= diff; - } - } else { - if (first.size.height < 100) { - CGFloat diff = 100 - first.size.height; - first.size.height = 100; - second.origin.y += diff; - second.size.height -= diff; - } else if (second.size.height < 100) { - CGFloat diff = 100 - second.size.height; - second.size.height = 100; - second.origin.y -= diff; - first.size.height -= diff; - } - } - [[[sender subviews] objectAtIndex:0] setFrame:first]; - [[[sender subviews] objectAtIndex:1] setFrame:second]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugview.h b/src/osd/modules/debugger/osx/debugosxdebugview.h deleted file mode 100644 index 06c25ea7c21..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugview.h +++ /dev/null @@ -1,68 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" - -#include "emu.h" -#include "debug/debugvw.h" - -#import - - -@interface MAMEDebugView : NSView -{ - int type; - running_machine *machine; - debug_view *view; - - INT32 totalWidth, totalHeight, originLeft, originTop; - - NSFont *font; - CGFloat fontWidth, fontHeight, fontAscent; - - NSTextStorage *text; - NSTextContainer *textContainer; - NSLayoutManager *layoutManager; -} - -+ (NSFont *)defaultFont; - -- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m; - -- (void)update; - -- (NSSize)maximumFrameSize; - -- (NSFont *)font; -- (void)setFont:(NSFont *)f; - -- (void)windowDidBecomeKey:(NSNotification *)notification; -- (void)windowDidResignKey:(NSNotification *)notification; - -@end - - -@protocol MAMEDebugViewSubviewSupport - -- (NSString *)selectedSubviewName; -- (int)selectedSubviewIndex; -- (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; - -@end - - -@protocol MAMEDebugViewExpressionSupport - -- (NSString *)expression; -- (void)setExpression:(NSString *)exp; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugview.m b/src/osd/modules/debugger/osx/debugosxdebugview.m deleted file mode 100644 index b9c6d49098d..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugview.m +++ /dev/null @@ -1,514 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxdebugview.h" - -#include "debug/debugcpu.h" - - -static void debugwin_view_update(debug_view &view, void *osdprivate) -{ - [(MAMEDebugView *)osdprivate update]; -} - - -@implementation MAMEDebugView - -- (NSColor *)foregroundForAttribute:(UINT8)attrib { - const CGFloat alpha = (attrib & DCA_DISABLED) ? 0.5 : 1.0; - if (attrib & DCA_COMMENT) - return [NSColor colorWithCalibratedRed:0.0 green:0.375 blue:0.0 alpha:1.0]; - else if (attrib & DCA_INVALID) - return [NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:alpha]; - else if (attrib & DCA_CHANGED) - return [NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:alpha]; - else - return [NSColor colorWithCalibratedWhite:0.0 alpha:alpha]; -} - - -- (NSColor *)backgroundForAttribute:(UINT8)attrib { - if ((attrib & DCA_SELECTED) && (attrib & DCA_CURRENT)) { - if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self)) - return [NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0]; - else - return [NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0]; - } else if (attrib & DCA_CURRENT) { - return [NSColor colorWithCalibratedRed:1.0 green:0.625 blue:0.625 alpha:1.0]; - } else if (attrib & DCA_SELECTED) { - if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self)) - return [NSColor colorWithCalibratedRed:0.75 green:0.875 blue:1.0 alpha:1.0]; - else - return [NSColor colorWithCalibratedWhite:0.875 alpha:1.0]; - } else if (attrib & DCA_ANCILLARY) { - return [NSColor colorWithCalibratedWhite:0.75 alpha:1.0]; - } else { - return [NSColor colorWithCalibratedWhite:1.0 alpha:1.0]; - } -} - - -- (debug_view_xy)convertLocation:(NSPoint)location { - debug_view_xy position; - - position.y = lround(floor(location.y / fontHeight)); - if (position.y < 0) - position.y = 0; - else if (position.y >= totalHeight) - position.y = totalHeight - 1; - - debug_view_xy const origin = view->visible_position(); - debug_view_xy const size = view->visible_size(); - debug_view_char const *data = view->viewdata(); - if (!data || (position.y < origin.y) || (position.y >= origin.y + size.y)) - { - // y coordinate outside visible area, x will be a guess - position.x = lround(floor(location.x / fontWidth)); - } - else - { - data += ((position.y - view->visible_position().y) * view->visible_size().x); - int attr = -1; - NSUInteger start = 0, length = 0; - for (UINT32 col = origin.x; col < origin.x + size.x; col++) - { - [[text mutableString] appendFormat:@"%c", data[col - origin.x].byte]; - if ((start < length) && (attr != data[col - origin.x].attrib)) - { - NSRange const run = NSMakeRange(start, length - start); - [text addAttribute:NSFontAttributeName - value:font - range:NSMakeRange(0, length)]; - [text addAttribute:NSForegroundColorAttributeName - value:[self foregroundForAttribute:attr] - range:run]; - start = length; - } - attr = data[col - origin.x].attrib; - length = [text length]; - } - if (start < length) - { - NSRange const run = NSMakeRange(start, length - start); - [text addAttribute:NSFontAttributeName - value:font - range:NSMakeRange(0, length)]; - [text addAttribute:NSForegroundColorAttributeName - value:[self foregroundForAttribute:attr] - range:run]; - } - CGFloat fraction; - NSUInteger const glyph = [layoutManager glyphIndexForPoint:NSMakePoint(location.x, fontHeight / 2) - inTextContainer:textContainer - fractionOfDistanceThroughGlyph:&fraction]; - position.x = [layoutManager characterIndexForGlyphAtIndex:glyph]; // FIXME: assumes 1:1 character mapping - [text deleteCharactersInRange:NSMakeRange(0, length)]; - } - if (position.x < 0) - position.x = 0; - else if (position.x >= totalWidth) - position.x = totalWidth - 1; - - return position; -} - - -- (void)convertBounds:(NSRect)b toPosition:(debug_view_xy *)origin size:(debug_view_xy *)size { - origin->x = lround(floor(b.origin.x / fontWidth)); - origin->y = lround(floor(b.origin.y / fontHeight)); - - // FIXME: this is not using proper font metrics horizontally - size->x = lround(ceil((b.origin.x + b.size.width) / fontWidth)) - origin->x; - size->y = lround(ceil((b.origin.y + b.size.height) / fontHeight)) - origin->y; -} - - -- (void)recomputeVisible { - if ([self window] != nil) { - debug_view_xy origin, size; - - // this gets all the characters that are at least paritally visible - [self convertBounds:[self visibleRect] toPosition:&origin size:&size]; - - // need to render entire lines or we get screwed up characters when widening views - origin.x = 0; - size.x = totalWidth; - - // tell them what we think - view->set_visible_size(size); - view->set_visible_position(origin); - originLeft = origin.x; - originTop = origin.y; - } -} - - -- (void)typeCharacterAndScrollToCursor:(char)ch { - if (view->cursor_supported()) { - debug_view_xy oldPos = view->cursor_position(); - view->process_char(ch); - { - debug_view_xy newPos = view->cursor_position(); - if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) { - [self scrollRectToVisible:NSMakeRect(newPos.x * fontWidth, // FIXME - use proper metrics - newPos.y * fontHeight, - fontWidth, - fontHeight)]; - } - } - } else { - view->process_char(ch); - } -} - - -+ (NSFont *)defaultFont { - return [NSFont userFixedPitchFontOfSize:0]; -} - - -- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m { - if (!(self = [super initWithFrame:f])) - return nil; - type = t; - machine = &m; - view = machine->debug_view().alloc_view((debug_view_type)type, debugwin_view_update, self); - if (view == nil) { - [self release]; - return nil; - } - totalWidth = totalHeight = 0; - originLeft = originTop = 0; - - text = [[NSTextStorage alloc] init]; - textContainer = [[NSTextContainer alloc] init]; - layoutManager = [[NSLayoutManager alloc] init]; - [layoutManager addTextContainer:textContainer]; - [textContainer release]; - [text addLayoutManager:layoutManager]; - [layoutManager release]; - - [self setFont:[[self class] defaultFont]]; - - return self; -} - - -- (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - if (font != nil) [font release]; - if (text != nil) [text release]; - [super dealloc]; -} - - -- (void)update { - debug_view_xy newSize, newOrigin; - - // resize our frame if the total size has changed - newSize = view->total_size(); - if ((newSize.x != totalWidth) || (newSize.y != totalHeight)) { - [self setFrameSize:NSMakeSize(fontWidth * newSize.x, fontHeight * newSize.y)]; // FIXME: metrics - totalWidth = newSize.x; - totalHeight = newSize.y; - } - - // scroll the view if we're being told to - newOrigin = view->visible_position(); - if (newOrigin.y != originTop) { - [self scrollPoint:NSMakePoint([self visibleRect].origin.x, newOrigin.y * fontHeight)]; - originTop = newOrigin.y; - } - - // recompute the visible area and mark as dirty - [self recomputeVisible]; - [self setNeedsDisplay:YES]; -} - - -- (NSSize)maximumFrameSize { - debug_view_xy max = view->total_size(); - return NSMakeSize(max.x * fontWidth, max.y * fontHeight); -} - - -- (NSFont *)font { - return [[font retain] autorelease]; -} - - -- (void)setFont:(NSFont *)f { - [font autorelease]; - font = [f retain]; - fontWidth = [font maximumAdvancement].width; - fontHeight = ceil([font ascender] - [font descender]); - fontAscent = [font ascender]; - [[self enclosingScrollView] setLineScroll:fontHeight]; - totalWidth = totalHeight = 0; - [self update]; -} - - -- (void)windowDidBecomeKey:(NSNotification *)notification { - NSWindow *win = [notification object]; - if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported()) - [self setNeedsDisplay:YES]; -} - - -- (void)windowDidResignKey:(NSNotification *)notification { - NSWindow *win = [notification object]; - if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported()) - [self setNeedsDisplay:YES]; -} - - -- (BOOL)acceptsFirstResponder { - return view->cursor_supported(); -} - - -- (BOOL)becomeFirstResponder { - if (view->cursor_supported()) { - debug_view_xy pos; - view->set_cursor_visible(true); - pos = view->cursor_position(); - [self scrollRectToVisible:NSMakeRect(pos.x * fontWidth, pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics - [self setNeedsDisplay:YES]; - return [super becomeFirstResponder]; - } else { - return NO; - } -} - - -- (BOOL)resignFirstResponder { - if (view->cursor_supported()) - [self setNeedsDisplay:YES]; - return [super resignFirstResponder]; -} - - -- (void)viewDidMoveToSuperview { - [[self enclosingScrollView] setLineScroll:fontHeight]; - [super viewDidMoveToSuperview]; -} - - -- (void)viewDidMoveToWindow { - [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:nil]; - if ([self window] != nil) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(windowDidBecomeKey:) - name:NSWindowDidBecomeKeyNotification - object:[self window]]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(windowDidResignKey:) - name:NSWindowDidResignKeyNotification - object:[self window]]; - [self recomputeVisible]; - } -} - - -- (BOOL)isFlipped { - return YES; -} - - -- (void)drawRect:(NSRect)dirtyRect { - debug_view_xy position, clip; - - // work out how much we need to draw - [self recomputeVisible]; - debug_view_xy const origin = view->visible_position(); - debug_view_xy const size = view->visible_size(); - [self convertBounds:dirtyRect toPosition:&position size:&clip]; - - // this gets the text for the whole visible area - debug_view_char const *data = view->viewdata(); - if (!data) - return; - - data += ((position.y - origin.y) * size.x); - for (UINT32 row = position.y; row < position.y + clip.y; row++, data += size.x) - { - if ((row < origin.y) || (row >= origin.y + size.y)) - continue; - - // render entire lines to get character alignment right - int attr = -1; - NSUInteger start = 0, length = 0; - for (UINT32 col = origin.x; col < origin.x + size.x; col++) - { - [[text mutableString] appendFormat:@"%c", data[col - origin.x].byte]; - if ((start < length) && (attr != data[col - origin.x].attrib)) - { - NSRange const run = NSMakeRange(start, length - start); - [text addAttribute:NSFontAttributeName - value:font - range:NSMakeRange(0, length)]; - [text addAttribute:NSForegroundColorAttributeName - value:[self foregroundForAttribute:attr] - range:run]; - NSRange const glyphs = [layoutManager glyphRangeForCharacterRange:run - actualCharacterRange:NULL]; - NSRect const box = [layoutManager boundingRectForGlyphRange:glyphs - inTextContainer:textContainer]; - [[self backgroundForAttribute:attr] set]; - [NSBezierPath fillRect:NSMakeRect(box.origin.x, - row * fontHeight, - box.size.width, - fontHeight)]; - start = length; - } - attr = data[col - origin.x].attrib; - length = [text length]; - } - if (start < length) - { - NSRange const run = NSMakeRange(start, length - start); - [text addAttribute:NSFontAttributeName - value:font - range:NSMakeRange(0, length)]; - [text addAttribute:NSForegroundColorAttributeName - value:[self foregroundForAttribute:attr] - range:run]; - NSRange const glyphs = [layoutManager glyphRangeForCharacterRange:run - actualCharacterRange:NULL]; - NSRect const box = [layoutManager boundingRectForGlyphRange:glyphs - inTextContainer:textContainer]; - [[self backgroundForAttribute:attr] set]; - [NSBezierPath fillRect:NSMakeRect(box.origin.x, - row * fontHeight, - box.size.width, - fontHeight)]; - } - [layoutManager drawGlyphsForGlyphRange:[layoutManager glyphRangeForTextContainer:textContainer] - atPoint:NSMakePoint(0, row * fontHeight)]; - [text deleteCharactersInRange:NSMakeRange(0, length)]; - } -} - - -- (void)mouseDown:(NSEvent *)event { - NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; - view->process_click(DCK_LEFT_CLICK, [self convertLocation:location]); - [self setNeedsDisplay:YES]; -} - - -- (void)rightMouseDown:(NSEvent *)event { - NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; - view->process_click(DCK_RIGHT_CLICK, [self convertLocation:location]); - [self setNeedsDisplay:YES]; - [super rightMouseDown:event]; -} - - -- (void)keyDown:(NSEvent *)event { - NSUInteger modifiers = [event modifierFlags]; - NSString *str = [event charactersIgnoringModifiers]; - - if ([str length] == 1) { - if (modifiers & NSNumericPadKeyMask) { - switch ([str characterAtIndex:0]) { - case NSUpArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - view->process_char(DCH_CTRLHOME); - else - view->process_char(DCH_UP); - return; - case NSDownArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - view->process_char(DCH_CTRLEND); - else - view->process_char(DCH_DOWN); - return; - case NSLeftArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - [self typeCharacterAndScrollToCursor:DCH_HOME]; - else if (modifiers & NSAlternateKeyMask) - [self typeCharacterAndScrollToCursor:DCH_CTRLLEFT]; - else - [self typeCharacterAndScrollToCursor:DCH_LEFT]; - return; - case NSRightArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - [self typeCharacterAndScrollToCursor:DCH_END]; - else if (modifiers & NSAlternateKeyMask) - [self typeCharacterAndScrollToCursor:DCH_CTRLRIGHT]; - else - [self typeCharacterAndScrollToCursor:DCH_RIGHT]; - return; - default: - [self interpretKeyEvents:[NSArray arrayWithObject:event]]; - return; - } - } else if (modifiers & NSFunctionKeyMask) { - switch ([str characterAtIndex:0]) { - case NSPageUpFunctionKey: - if (modifiers & NSAlternateKeyMask) { - view->process_char(DCH_PUP); - return; - } - case NSPageDownFunctionKey: - if (modifiers & NSAlternateKeyMask) { - view->process_char(DCH_PDOWN); - return; - } - default: - ; - } - [super keyDown:event]; - return; - } - } - [self interpretKeyEvents:[NSArray arrayWithObject:event]]; -} - - -- (void)insertTab:(id)sender { - if ([[self window] firstResponder] == self) - [[self window] selectNextKeyView:self]; -} - - -- (void)insertBacktab:(id)sender { - if ([[self window] firstResponder] == self) - [[self window] selectPreviousKeyView:self]; -} - - -- (void)insertNewline:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); -} - - -- (void)insertText:(id)string { - NSUInteger len; - NSRange found; - if ([string isKindOfClass:[NSAttributedString class]]) - string = [string string]; - for (len = [string length], found = NSMakeRange(0, 0); - found.location < len; - found.location += found.length) { - found = [string rangeOfComposedCharacterSequenceAtIndex:found.location]; - if (found.length == 1) { - unichar ch = [string characterAtIndex:found.location]; - if ((ch >= 32) && (ch < 127)) - [self typeCharacterAndScrollToCursor:ch]; - } - } -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugwindowhandler.h b/src/osd/modules/debugger/osx/debugosxdebugwindowhandler.h deleted file mode 100644 index ba0f75fadad..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugwindowhandler.h +++ /dev/null @@ -1,98 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugwindowhandler.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" - -#include "emu.h" - -#import - - -@protocol MAMEDebugViewExpressionSupport; -@class MAMEDebugCommandHistory, MAMEDebugConsole; - - -extern NSString *const MAMEHideDebuggerNotification; -extern NSString *const MAMEShowDebuggerNotification; -extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification; - - -@interface MAMEDebugWindowHandler : NSObject -{ - NSWindow *window; - running_machine *machine; -} - -+ (void)addCommonActionItems:(NSMenu *)menu; -+ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame; - -- (id)initWithMachine:(running_machine &)m title:(NSString *)t; - -- (void)activate; - -- (IBAction)debugRun:(id)sender; -- (IBAction)debugRunAndHide:(id)sender; -- (IBAction)debugRunToNextCPU:(id)sender; -- (IBAction)debugRunToNextInterrupt:(id)sender; -- (IBAction)debugRunToNextVBLANK:(id)sender; - -- (IBAction)debugStepInto:(id)sender; -- (IBAction)debugStepOver:(id)sender; -- (IBAction)debugStepOut:(id)sender; - -- (IBAction)debugSoftReset:(id)sender; -- (IBAction)debugHardReset:(id)sender; - -- (IBAction)debugExit:(id)sender; - -- (void)showDebugger:(NSNotification *)notification; -- (void)hideDebugger:(NSNotification *)notification; - -@end - - -@interface MAMEAuxiliaryDebugWindowHandler : MAMEDebugWindowHandler -{ - MAMEDebugConsole *console; -} - -+ (void)cascadeWindow:(NSWindow *)window; - -- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c; - -- (IBAction)debugNewMemoryWindow:(id)sender; -- (IBAction)debugNewDisassemblyWindow:(id)sender; -- (IBAction)debugNewErrorLogWindow:(id)sender; -- (IBAction)debugNewPointsWindow:(id)sender; - -- (void)windowWillClose:(NSNotification *)notification; - -- (void)cascadeWindowWithDesiredSize:(NSSize)desired forView:(NSView *)view; - -@end - - -@interface MAMEExpressionAuxiliaryDebugWindowHandler : MAMEAuxiliaryDebugWindowHandler -{ - MAMEDebugCommandHistory *history; - NSTextField *expressionField; -} - -- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c; - -- (id )documentView; - -- (IBAction)doExpression:(id)sender; - -- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor; -- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdebugwindowhandler.m b/src/osd/modules/debugger/osx/debugosxdebugwindowhandler.m deleted file mode 100644 index edfbb2a27fb..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdebugwindowhandler.m +++ /dev/null @@ -1,403 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdebugwindowhandler.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxdebugwindowhandler.h" - -#import "debugosxdebugcommandhistory.h" -#import "debugosxdebugview.h" - -#include "debug/debugcpu.h" - - -//============================================================ -// NOTIFICATIONS -//============================================================ - -NSString *const MAMEHideDebuggerNotification = @"MAMEHideDebuggerNotification"; -NSString *const MAMEShowDebuggerNotification = @"MAMEShowDebuggerNotification"; -NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryDebugWindowWillCloseNotification"; - - -//============================================================ -// MAMEDebugWindowHandler class -//============================================================ - -@implementation MAMEDebugWindowHandler - -+ (void)addCommonActionItems:(NSMenu *)menu { - { - NSMenuItem *runParentItem = [menu addItemWithTitle:@"Run" - action:@selector(debugRun:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF5FunctionKey]]; - NSMenu *runMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Run"]; - [runParentItem setSubmenu:runMenu]; - [runMenu release]; - [runParentItem setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"and Hide Debugger" - action:@selector(debugRunAndHide:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF12FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"to Next CPU" - action:@selector(debugRunToNextCPU:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF6FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"until Next Interrupt on Current CPU" - action:@selector(debugRunToNextInterrupt:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF7FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"until Next VBLANK" - action:@selector(debugRunToNextVBLANK:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF8FunctionKey]] - setKeyEquivalentModifierMask:0]; - } - { - NSMenuItem *stepParentItem = [menu addItemWithTitle:@"Step" action:NULL keyEquivalent:@""]; - NSMenu *stepMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Step"]; - [stepParentItem setSubmenu:stepMenu]; - [stepMenu release]; - [[stepMenu addItemWithTitle:@"Into" - action:@selector(debugStepInto:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF11FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[stepMenu addItemWithTitle:@"Over" - action:@selector(debugStepOver:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[stepMenu addItemWithTitle:@"Out" - action:@selector(debugStepOut:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] - setKeyEquivalentModifierMask:NSShiftKeyMask]; - } - { - NSMenuItem *resetParentItem = [menu addItemWithTitle:@"Reset" action:NULL keyEquivalent:@""]; - NSMenu *resetMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Reset"]; - [resetParentItem setSubmenu:resetMenu]; - [resetMenu release]; - [[resetMenu addItemWithTitle:@"Soft" - action:@selector(debugSoftReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[resetMenu addItemWithTitle:@"Hard" - action:@selector(debugHardReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] - setKeyEquivalentModifierMask:NSShiftKeyMask]; - } - [menu addItem:[NSMenuItem separatorItem]]; - { - NSMenuItem *newParentItem = [menu addItemWithTitle:@"New" action:NULL keyEquivalent:@""]; - NSMenu *newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"New"]; - [newParentItem setSubmenu:newMenu]; - [newMenu release]; - [newMenu addItemWithTitle:@"Memory Window" - action:@selector(debugNewMemoryWindow:) - keyEquivalent:@"d"]; - [newMenu addItemWithTitle:@"Disassembly Window" - action:@selector(debugNewDisassemblyWindow:) - keyEquivalent:@"a"]; - [newMenu addItemWithTitle:@"Error Log Window" - action:@selector(debugNewErrorLogWindow:) - keyEquivalent:@"l"]; - [newMenu addItemWithTitle:@"(Break|Watch)points Window" - action:@selector(debugNewPointsWindow:) - keyEquivalent:@"b"]; - } - [menu addItem:[NSMenuItem separatorItem]]; - [menu addItemWithTitle:@"Close Window" action:@selector(performClose:) keyEquivalent:@"w"]; - [menu addItemWithTitle:@"Exit" action:@selector(debugExit:) keyEquivalent:@""]; -} - - -+ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame { - NSPopUpButton *actionButton = [[NSPopUpButton alloc] initWithFrame:frame pullsDown:YES]; - [actionButton setTitle:@""]; - [actionButton addItemWithTitle:@""]; - [actionButton setBezelStyle:NSShadowlessSquareBezelStyle]; - [actionButton setFocusRingType:NSFocusRingTypeNone]; - [[actionButton cell] setArrowPosition:NSPopUpArrowAtCenter]; - [[self class] addCommonActionItems:[actionButton menu]]; - return actionButton; -} - - -- (id)initWithMachine:(running_machine &)m title:(NSString *)t { - if (!(self = [super init])) - return nil; - - window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 320, 240) - styleMask:(NSTitledWindowMask | - NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSResizableWindowMask) - backing:NSBackingStoreBuffered - defer:YES]; - [window setReleasedWhenClosed:NO]; - [window setDelegate:self]; - [window setTitle:t]; - [window setContentMinSize:NSMakeSize(320, 240)]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(showDebugger:) - name:MAMEShowDebuggerNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(hideDebugger:) - name:MAMEHideDebuggerNotification - object:nil]; - - machine = &m; - - return self; -} - - -- (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - if (window != nil) - [window release]; - - [super dealloc]; -} - - -- (void)activate { - [window makeKeyAndOrderFront:self]; -} - - -- (IBAction)debugRun:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->go(); -} - - -- (IBAction)debugRunAndHide:(id)sender { - [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification object:self]; - debug_cpu_get_visible_cpu(*machine)->debug()->go(); -} - - -- (IBAction)debugRunToNextCPU:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->go_next_device(); -} - - -- (IBAction)debugRunToNextInterrupt:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->go_interrupt(); -} - - -- (IBAction)debugRunToNextVBLANK:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->go_vblank(); -} - - -- (IBAction)debugStepInto:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); -} - - -- (IBAction)debugStepOver:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->single_step_over(); -} - - -- (IBAction)debugStepOut:(id)sender { - debug_cpu_get_visible_cpu(*machine)->debug()->single_step_out(); -} - - -- (IBAction)debugSoftReset:(id)sender { - machine->schedule_soft_reset(); - debug_cpu_get_visible_cpu(*machine)->debug()->go(); -} - - -- (IBAction)debugHardReset:(id)sender { - machine->schedule_hard_reset(); -} - - -- (IBAction)debugExit:(id)sender { - machine->schedule_exit(); -} - - -- (void)showDebugger:(NSNotification *)notification { - device_t *device = (device_t *) [[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue]; - if (&device->machine() == machine) { - if (![window isVisible] && ![window isMiniaturized]) - [window orderFront:self]; - } -} - - -- (void)hideDebugger:(NSNotification *)notification { - [window orderOut:self]; -} - -@end - - -//============================================================ -// MAMEAuxiliaryDebugWindowHandler class -//============================================================ - -@implementation MAMEAuxiliaryDebugWindowHandler - -+ (void)cascadeWindow:(NSWindow *)window { - static NSPoint lastPosition = { 0, 0 }; - if (NSEqualPoints(lastPosition, NSZeroPoint)) { - NSRect available = [[NSScreen mainScreen] visibleFrame]; - lastPosition = NSMakePoint(available.origin.x + 12, available.origin.y + available.size.height - 8); - } - lastPosition = [window cascadeTopLeftFromPoint:lastPosition]; -} - - -- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c { - if (!(self = [super initWithMachine:m title:t])) - return nil; - console = c; - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - - -- (IBAction)debugNewMemoryWindow:(id)sender { - [console debugNewMemoryWindow:sender]; -} - - -- (IBAction)debugNewDisassemblyWindow:(id)sender { - [console debugNewDisassemblyWindow:sender]; -} - - -- (IBAction)debugNewErrorLogWindow:(id)sender { - [console debugNewErrorLogWindow:sender]; -} - - -- (IBAction)debugNewPointsWindow:(id)sender { - [console debugNewPointsWindow:sender]; -} - - -- (void)windowWillClose:(NSNotification *)notification { - [[NSNotificationCenter defaultCenter] postNotificationName:MAMEAuxiliaryDebugWindowWillCloseNotification - object:self]; -} - -- (void)cascadeWindowWithDesiredSize:(NSSize)desired forView:(NSView *)view { - NSRect available = [[NSScreen mainScreen] visibleFrame]; - NSRect windowFrame = [window frame]; - NSSize current = [view frame].size; - - desired.width -= current.width; - desired.height -= current.height; - - windowFrame.size.width += desired.width; - windowFrame.size.height += desired.height; - windowFrame.size.height = MIN(MIN(windowFrame.size.height, 240), available.size.height); - windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); - windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; - windowFrame.origin.y = available.origin.y; - [window setFrame:windowFrame display:YES]; - [[self class] cascadeWindow:window]; - - windowFrame = [[window contentView] frame]; - desired = [window contentMinSize]; - [window setContentMinSize:NSMakeSize(MIN(windowFrame.size.width, desired.width), - MIN(windowFrame.size.height, desired.height))]; -} - -@end - - -//============================================================ -// MAMEExpreesionAuxiliaryDebugWindowHandler class -//============================================================ - -@implementation MAMEExpressionAuxiliaryDebugWindowHandler - -- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c { - if (!(self = [super initWithMachine:m title:t console:c])) - return nil; - history = [[MAMEDebugCommandHistory alloc] init]; - return self; -} - - -- (void)dealloc { - if (history != nil) - [history release]; - [super dealloc]; -} - - -- (id )documentView { - return nil; -} - - -- (IBAction)doExpression:(id)sender { - NSString *expr = [sender stringValue]; - if ([expr length] > 0) { - [history add:expr]; - [[self documentView] setExpression:expr]; - } else { - [sender setStringValue:[[self documentView] expression]]; - [history reset]; - } - [sender selectText:self]; -} - - -- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor -{ - if (control == expressionField) - [history edit]; - - return YES; -} - - -- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { - if (control == expressionField) { - if (command == @selector(cancelOperation:)) { - [history reset]; - [expressionField setStringValue:[[self documentView] expression]]; - [expressionField selectText:self]; - return YES; - } else if (command == @selector(moveUp:)) { - NSString *hist = [history previous:[expressionField stringValue]]; - if (hist != nil) { - [expressionField setStringValue:hist]; - [expressionField selectText:self]; - } - return YES; - } else if (command == @selector(moveDown:)) { - NSString *hist = [history next:[expressionField stringValue]]; - if (hist != nil) { - [expressionField setStringValue:hist]; - [expressionField selectText:self]; - } - return YES; - } - } - return NO; -} - -@end \ No newline at end of file diff --git a/src/osd/modules/debugger/osx/debugosxdisassemblyview.h b/src/osd/modules/debugger/osx/debugosxdisassemblyview.h deleted file mode 100644 index 32e61a967e6..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdisassemblyview.h +++ /dev/null @@ -1,46 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdisassemblyview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugview.h" - -#include "emu.h" - -#import - - -@interface MAMEDisassemblyView : MAMEDebugView -{ - BOOL useConsole; -} - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc; - -- (NSSize)maximumFrameSize; - -- (NSString *)selectedSubviewName; -- (int)selectedSubviewIndex; -- (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; - -- (NSString *)expression; -- (void)setExpression:(NSString *)exp; - -- (IBAction)debugToggleBreakpoint:(id)sender; -- (IBAction)debugToggleBreakpointEnable:(id)sender; -- (IBAction)debugRunToCursor:(id)sender; - -- (IBAction)showRightColumn:(id)sender; - -- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; -- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdisassemblyview.m b/src/osd/modules/debugger/osx/debugosxdisassemblyview.m deleted file mode 100644 index 7a482cd8504..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdisassemblyview.m +++ /dev/null @@ -1,370 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdisassemblyview.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxdisassemblyview.h" - -#include "debug/debugcon.h" -#include "debug/debugcpu.h" -#include "debug/debugvw.h" -#include "debug/dvdisasm.h" - - -@implementation MAMEDisassemblyView - -- (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address inAddressSpace:(address_space &)space { - device_debug *cpuinfo = space.device().debug(); - device_debug::breakpoint *bp; - for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) {} - return bp; -} - -- (void)createContextMenu { - NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"]; - NSMenuItem *item; - - item = [contextMenu addItemWithTitle:@"Toggle Breakpoint" - action:@selector(debugToggleBreakpoint:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; - [item setKeyEquivalentModifierMask:0]; - [item setTarget:self]; - - item = [contextMenu addItemWithTitle:@"Disable Breakpoint" - action:@selector(debugToggleBreakpointEnable:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; - [item setKeyEquivalentModifierMask:NSShiftKeyMask]; - [item setTarget:self]; - - [contextMenu addItem:[NSMenuItem separatorItem]]; - - item = [contextMenu addItemWithTitle:@"Run to Cursor" - action:@selector(debugRunToCursor:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; - [item setKeyEquivalentModifierMask:0]; - [item setTarget:self]; - - [contextMenu addItem:[NSMenuItem separatorItem]]; - - item = [contextMenu addItemWithTitle:@"Raw Opcodes" - action:@selector(showRightColumn:) - keyEquivalent:@"r"]; - [item setTarget:self]; - [item setTag:DASM_RIGHTCOL_RAW]; - - item = [contextMenu addItemWithTitle:@"Encrypted Opcodes" - action:@selector(showRightColumn:) - keyEquivalent:@"e"]; - [item setTarget:self]; - [item setTag:DASM_RIGHTCOL_ENCRYPTED]; - - item = [contextMenu addItemWithTitle:@"Comments" - action:@selector(showRightColumn:) - keyEquivalent:@"n"]; - [item setTarget:self]; - [item setTag:DASM_RIGHTCOL_COMMENTS]; - - [self setMenu:contextMenu]; - [contextMenu release]; -} - - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc { - if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m])) - return nil; - useConsole = uc; - [self createContextMenu]; - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - - -- (BOOL)validateMenuItem:(NSMenuItem *)item { - SEL action = [item action]; - BOOL inContextMenu = ([item menu] == [self menu]); - BOOL haveCursor = NO, isCurrent = NO; - device_debug::breakpoint *breakpoint = NULL; - - if (view->cursor_visible()) { - if (debug_cpu_get_visible_cpu(*machine) == view->source()->device()) { - isCurrent = YES; - if (!useConsole || isCurrent) { - offs_t address = downcast(view)->selected_address(); - haveCursor = YES; - breakpoint = [self findBreakpointAtAddress:address inAddressSpace:downcast(view->source())->space()]; - } - } - } - - if (action == @selector(debugToggleBreakpoint:)) { - if (haveCursor) { - if (breakpoint != NULL) { - if (inContextMenu) - [item setTitle:@"Clear Breakpoint"]; - else - [item setTitle:@"Clear Breakpoint at Cursor"]; - } else { - if (inContextMenu) - [item setTitle:@"Set Breakpoint"]; - else - [item setTitle:@"Set Breakpoint at Cursor"]; - } - } else { - if (inContextMenu) - [item setTitle:@"Toggle Breakpoint"]; - else - [item setTitle:@"Toggle Breakpoint at Cursor"]; - } - return haveCursor; - } else if (action == @selector(debugToggleBreakpointEnable:)) { - if ((breakpoint != NULL) && !breakpoint->enabled()) { - if (inContextMenu) - [item setTitle:@"Enable Breakpoint"]; - else - [item setTitle:@"Enable Breakpoint at Cursor"]; - } else { - if (inContextMenu) - [item setTitle:@"Disable Breakpoint"]; - else - [item setTitle:@"Disable Breakpoint at Cursor"]; - } - return (breakpoint != NULL); - } else if (action == @selector(debugRunToCursor:)) { - return isCurrent; - } else if (action == @selector(showRightColumn:)) { - [item setState:((downcast(view)->right_column() == [item tag]) ? NSOnState : NSOffState)]; - return YES; - } else { - return YES; - } -} - - -- (NSSize)maximumFrameSize { - debug_view_xy max; - device_t *curcpu = debug_cpu_get_visible_cpu(*machine); - const debug_view_source *source = view->source_for_device(curcpu); - - max.x = max.y = 0; - for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) - { - debug_view_xy current; - view->set_source(*source); - current = view->total_size(); - if (current.x > max.x) - max.x = current.x; - if (current.y > max.y) - max.y = current.y; - } - view->set_source(*source); - return NSMakeSize(max.x * fontWidth, max.y * fontHeight); -} - - -- (NSString *)selectedSubviewName { - const debug_view_source *source = view->source(); - if (source != NULL) - return [NSString stringWithUTF8String:source->name()]; - else - return @""; -} - - -- (int)selectedSubviewIndex { - const debug_view_source *source = view->source(); - if (source != NULL) - return view->source_list().indexof(*source); - else - return -1; -} - - -- (void)selectSubviewAtIndex:(int)index { - const int selected = view->source_list().indexof(*view->source()); - if (selected != index) { - view->set_source(*view->source_list().find(index)); - if ([[self window] firstResponder] != self) - view->set_cursor_visible(false); - } -} - - -- (void)selectSubviewForCPU:(device_t *)device { - const debug_view_source *selected = view->source(); - const debug_view_source *source = view->source_for_device(device); - if ( selected != source ) { - view->set_source(*source); - if ([[self window] firstResponder] != self) - view->set_cursor_visible(false); - } -} - - -- (NSString *)expression { - return [NSString stringWithUTF8String:downcast(view)->expression()]; -} - - -- (void)setExpression:(NSString *)exp { - downcast(view)->set_expression([exp UTF8String]); -} - - -- (IBAction)debugToggleBreakpoint:(id)sender { - if (view->cursor_visible()) { - address_space &space = downcast(view->source())->space(); - if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) { - offs_t address = downcast(view)->selected_address(); - device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; - - // if it doesn't exist, add a new one - if (useConsole) { - NSString *command; - if (bp == NULL) - command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address]; - else - command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()]; - debug_console_execute_command(*machine, [command UTF8String], 1); - } else { - if (bp == NULL) - space.device().debug()->breakpoint_set(address, NULL, NULL); - else - space.device().debug()->breakpoint_clear(bp->index()); - } - } - } -} - - -- (IBAction)debugToggleBreakpointEnable:(id)sender { - if (view->cursor_visible()) { - address_space &space = downcast(view->source())->space(); - if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) { - offs_t address = downcast(view)->selected_address(); - device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; - - if (bp != NULL) { - NSString *command; - if (useConsole) { - if (bp->enabled()) - command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()]; - else - command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()]; - debug_console_execute_command(*machine, [command UTF8String], 1); - } else { - space.device().debug()->breakpoint_enable(bp->index(), !bp->enabled()); - } - } - } - } -} - - -- (IBAction)debugRunToCursor:(id)sender { - if (view->cursor_visible()) { - address_space &space = downcast(view->source())->space(); - if (debug_cpu_get_visible_cpu(*machine) == &space.device()) { - offs_t address = downcast(view)->selected_address(); - if (useConsole) { - NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)address]; - debug_console_execute_command(*machine, [command UTF8String], 1); - } else { - debug_cpu_get_visible_cpu(*machine)->debug()->go(address); - } - } - } -} - - -- (IBAction)showRightColumn:(id)sender { - downcast(view)->set_right_column((disasm_right_column) [sender tag]); -} - - -- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { - { - NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor" - action:@selector(debugToggleBreakpoint:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] - atIndex:index++]; - [breakItem setKeyEquivalentModifierMask:0]; - [breakItem setTarget:self]; - } - { - NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor" - action:@selector(debugToggleBreakpointEnable:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] - atIndex:index++]; - [disableItem setKeyEquivalentModifierMask:NSShiftKeyMask]; - [disableItem setAlternate:YES]; - [disableItem setTarget:self]; - } - { - NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu]; - NSMenuItem *runItem; - if (runMenu != nil) { - runItem = [runMenu addItemWithTitle:@"to Cursor" - action:@selector(debugRunToCursor:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; - } else { - runItem = [menu insertItemWithTitle:@"Run to Cursor" - action:@selector(debugRunToCursor:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey] - atIndex:index++]; - } - [runItem setKeyEquivalentModifierMask:0]; - [runItem setTarget:self]; - } - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; - { - NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes" - action:@selector(showRightColumn:) - keyEquivalent:@"r" - atIndex:index++]; - [rawItem setTarget:self]; - [rawItem setTag:DASM_RIGHTCOL_RAW]; - } - { - NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes" - action:@selector(showRightColumn:) - keyEquivalent:@"e" - atIndex:index++]; - [encItem setTarget:self]; - [encItem setTag:DASM_RIGHTCOL_ENCRYPTED]; - } - { - NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments" - action:@selector(showRightColumn:) - keyEquivalent:@"n" - atIndex:index++]; - [commentsItem setTarget:self]; - [commentsItem setTag:DASM_RIGHTCOL_COMMENTS]; - } - if (index < [menu numberOfItems]) - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; -} - - -- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { - for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) - { - [[menu insertItemWithTitle:[NSString stringWithUTF8String:source->name()] - action:NULL - keyEquivalent:@"" - atIndex:index++] setTag:view->source_list().indexof(*source)]; - } - if (index < [menu numberOfItems]) - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdisassemblyviewer.h b/src/osd/modules/debugger/osx/debugosxdisassemblyviewer.h deleted file mode 100644 index fa4f76bd813..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdisassemblyviewer.h +++ /dev/null @@ -1,31 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdisassemblyviewer.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugwindowhandler.h" - -#include "emu.h" - -#import - - -@class MAMEDebugConsole, MAMEDisassemblyView; - -@interface MAMEDisassemblyViewer : MAMEExpressionAuxiliaryDebugWindowHandler -{ - MAMEDisassemblyView *dasmView; -} - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; - -- (IBAction)changeSubview:(id)sender; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxdisassemblyviewer.m b/src/osd/modules/debugger/osx/debugosxdisassemblyviewer.m deleted file mode 100644 index 3a965fe1404..00000000000 --- a/src/osd/modules/debugger/osx/debugosxdisassemblyviewer.m +++ /dev/null @@ -1,138 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxdisassemblyviewer.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxdisassemblyviewer.h" - -#import "debugosxdebugview.h" -#import "debugosxdisassemblyview.h" - -#include "debug/debugcpu.h" - - -@implementation MAMEDisassemblyViewer - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { - NSScrollView *dasmScroll; - NSView *expressionContainer; - NSPopUpButton *actionButton, *subviewButton; - NSRect contentBounds, expressionFrame; - - if (!(self = [super initWithMachine:m title:@"Disassembly" console:c])) - return nil; - contentBounds = [[window contentView] bounds]; - - // create the expression field - expressionField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; - [expressionField setAutoresizingMask:(NSViewWidthSizable | NSViewMaxXMargin | NSViewMinYMargin)]; - [expressionField setFont:[[MAMEDebugView class] defaultFont]]; - [expressionField setFocusRingType:NSFocusRingTypeNone]; - [expressionField setTarget:self]; - [expressionField setAction:@selector(doExpression:)]; - [expressionField setDelegate:self]; - expressionFrame = [expressionField frame]; - expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2; - [expressionField setFrameSize:expressionFrame.size]; - - // create the subview popup - subviewButton = [[NSPopUpButton alloc] initWithFrame:NSOffsetRect(expressionFrame, - expressionFrame.size.width, - 0)]; - [subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinXMargin | NSViewMinYMargin)]; - [subviewButton setBezelStyle:NSShadowlessSquareBezelStyle]; - [subviewButton setFocusRingType:NSFocusRingTypeNone]; - [subviewButton setFont:[[MAMEDebugView class] defaultFont]]; - [subviewButton setTarget:self]; - [subviewButton setAction:@selector(changeSubview:)]; - [[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom]; - - // create a container for the expression field and subview popup - expressionFrame = NSMakeRect(expressionFrame.size.height, - contentBounds.size.height - expressionFrame.size.height, - contentBounds.size.width - expressionFrame.size.height, - expressionFrame.size.height); - expressionContainer = [[NSView alloc] initWithFrame:expressionFrame]; - [expressionContainer setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; - [expressionContainer addSubview:expressionField]; - [expressionField release]; - [expressionContainer addSubview:subviewButton]; - [subviewButton release]; - [[window contentView] addSubview:expressionContainer]; - [expressionContainer release]; - - // create the disassembly view - dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) - machine:*machine - useConsole:NO]; - [dasmView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0]; - dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, - 0, - contentBounds.size.width, - expressionFrame.origin.y)]; - [dasmScroll setDrawsBackground:YES]; - [dasmScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [dasmScroll setHasHorizontalScroller:YES]; - [dasmScroll setHasVerticalScroller:YES]; - [dasmScroll setAutohidesScrollers:YES]; - [dasmScroll setBorderType:NSNoBorder]; - [dasmScroll setDocumentView:dasmView]; - [dasmView release]; - [[window contentView] addSubview:dasmScroll]; - [dasmScroll release]; - - // create the action popup - actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, - expressionFrame.origin.y, - expressionFrame.size.height, - expressionFrame.size.height)]; - [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; - [dasmView insertActionItemsInMenu:[actionButton menu] atIndex:1]; - [[window contentView] addSubview:actionButton]; - [actionButton release]; - - // set default state - [dasmView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)]; - [dasmView setExpression:@"curpc"]; - [expressionField setStringValue:@"curpc"]; - [expressionField selectText:self]; - [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[dasmView selectedSubviewIndex]]]; - [window makeFirstResponder:expressionField]; - [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; - - // calculate the optimal size for everything - { - NSSize desired = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[dasmScroll borderType]]; - [self cascadeWindowWithDesiredSize:desired forView:dasmScroll]; - } - - // don't forget the result - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - - -- (id )documentView { - return dasmView; -} - - -- (IBAction)changeSubview:(id)sender { - [dasmView selectSubviewAtIndex:[[sender selectedItem] tag]]; - [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxerrorlogview.h b/src/osd/modules/debugger/osx/debugosxerrorlogview.h deleted file mode 100644 index 7f85a06147f..00000000000 --- a/src/osd/modules/debugger/osx/debugosxerrorlogview.h +++ /dev/null @@ -1,26 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxerrorlogview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugview.h" - -#include "emu.h" - -#import - - -@interface MAMEErrorLogView : MAMEDebugView -{ -} - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxerrorlogview.m b/src/osd/modules/debugger/osx/debugosxerrorlogview.m deleted file mode 100644 index 49ffac807b0..00000000000 --- a/src/osd/modules/debugger/osx/debugosxerrorlogview.m +++ /dev/null @@ -1,30 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxerrorlogview.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxerrorlogview.h" - -#include "debug/debugvw.h" - - -@implementation MAMEErrorLogView - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { - if (!(self = [super initWithFrame:f type:DVT_LOG machine:m])) - return nil; - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxerrorlogviewer.h b/src/osd/modules/debugger/osx/debugosxerrorlogviewer.h deleted file mode 100644 index caab178d854..00000000000 --- a/src/osd/modules/debugger/osx/debugosxerrorlogviewer.h +++ /dev/null @@ -1,29 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxerrorlogviewer.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugwindowhandler.h" - -#include "emu.h" - -#import - - -@class MAMEDebugConsole, MAMEErrorLogView; - -@interface MAMEErrorLogViewer : MAMEAuxiliaryDebugWindowHandler -{ - MAMEErrorLogView *logView; -} - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxerrorlogviewer.m b/src/osd/modules/debugger/osx/debugosxerrorlogviewer.m deleted file mode 100644 index b0abaeaeca6..00000000000 --- a/src/osd/modules/debugger/osx/debugosxerrorlogviewer.m +++ /dev/null @@ -1,64 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxerrorlogviewer.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxerrorlogviewer.h" - -#import "debugosxerrorlogview.h" - - -@implementation MAMEErrorLogViewer - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { - NSScrollView *logScroll; - NSString *title; - - title = [NSString stringWithFormat:@"Error Log: %@ [%@]", - [NSString stringWithUTF8String:m.system().description], - [NSString stringWithUTF8String:m.system().name]]; - if (!(self = [super initWithMachine:m title:title console:c])) - return nil; - - // create the error log view - logView = [[MAMEErrorLogView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; - logScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; - [logScroll setDrawsBackground:YES]; - [logScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [logScroll setHasHorizontalScroller:YES]; - [logScroll setHasVerticalScroller:YES]; - [logScroll setAutohidesScrollers:YES]; - [logScroll setBorderType:NSNoBorder]; - [logScroll setDocumentView:logView]; - [logView release]; - [window setContentView:logScroll]; - [logScroll release]; - - // calculate the optimal size for everything - { - NSSize desired = [NSScrollView frameSizeForContentSize:[logView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[logScroll borderType]]; - - // this thing starts with no content, so its prefered height may be very small - desired.height = MAX(desired.height, 240); - [self cascadeWindowWithDesiredSize:desired forView:logScroll]; - } - - // don't forget the result - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxmemoryview.h b/src/osd/modules/debugger/osx/debugosxmemoryview.h deleted file mode 100644 index 45f39787c5a..00000000000 --- a/src/osd/modules/debugger/osx/debugosxmemoryview.h +++ /dev/null @@ -1,45 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxmemoryview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugview.h" - -#include "emu.h" - -#import - - -@interface MAMEMemoryView : MAMEDebugView -{ -} - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - -- (NSSize)maximumFrameSize; - -- (NSString *)selectedSubviewName; -- (int)selectedSubviewIndex; -- (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; - -- (NSString *)expression; -- (void)setExpression:(NSString *)exp; - -- (IBAction)showChunkSize:(id)sender; -- (IBAction)showPhysicalAddresses:(id)sender; -- (IBAction)showReverseView:(id)sender; -- (IBAction)showReverseViewToggle:(id)sender; -- (IBAction)changeBytesPerLine:(id)sender; - -- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; -- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxmemoryview.m b/src/osd/modules/debugger/osx/debugosxmemoryview.m deleted file mode 100644 index 3bebe290c79..00000000000 --- a/src/osd/modules/debugger/osx/debugosxmemoryview.m +++ /dev/null @@ -1,226 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxmemoryview.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxmemoryview.h" - -#include "debug/debugcpu.h" -#include "debug/debugvw.h" -#include "debug/dvmemory.h" - - -@implementation MAMEMemoryView - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { - NSMenu *contextMenu; - - if (!(self = [super initWithFrame:f type:DVT_MEMORY machine:m])) - return nil; - - contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Memory"]; - [self insertActionItemsInMenu:contextMenu atIndex:0]; - [self setMenu:contextMenu]; - [contextMenu release]; - - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - - -- (BOOL)validateMenuItem:(NSMenuItem *)item { - SEL action = [item action]; - NSInteger tag = [item tag]; - debug_view_memory *memview = downcast(view); - - if (action == @selector(showChunkSize:)) { - [item setState:((tag == memview->bytes_per_chunk()) ? NSOnState : NSOffState)]; - } else if (action == @selector(showPhysicalAddresses:)) { - [item setState:((tag == memview->physical()) ? NSOnState : NSOffState)]; - } else if (action == @selector(showReverseView:)) { - [item setState:((tag == memview->reverse()) ? NSOnState : NSOffState)]; - } else if (action == @selector(showReverseViewToggle:)) { - [item setState:(memview->reverse() ? NSOnState : NSOffState)]; - } - return YES; -} - - -- (NSSize)maximumFrameSize { - debug_view_xy max; - device_t *curcpu = debug_cpu_get_visible_cpu(*machine); - debug_view_source const *source = view->source_for_device(curcpu); - - max.x = max.y = 0; - for (const debug_view_source *source = view->source_list().first(); - source != NULL; - source = source->next()) - { - debug_view_xy current; - view->set_source(*source); - current = view->total_size(); - if (current.x > max.x) - max.x = current.x; - if (current.y > max.y) - max.y = current.y; - } - view->set_source(*source); - return NSMakeSize(max.x * fontWidth, max.y * fontHeight); -} - - -- (NSString *)selectedSubviewName { - debug_view_source const *source = view->source(); - if (source != NULL) - return [NSString stringWithUTF8String:source->name()]; - else - return @""; -} - - -- (int)selectedSubviewIndex { - debug_view_source const *source = view->source(); - if (source != NULL) - return view->source_list().indexof(*source); - else - return -1; -} - - -- (void)selectSubviewAtIndex:(int)index { - int const selected = view->source_list().indexof(*view->source()); - if (selected != index) { - view->set_source(*view->source_list().find(index)); - if ([[self window] firstResponder] != self) - view->set_cursor_visible(false); - } -} - - -- (void)selectSubviewForCPU:(device_t *)device { - debug_view_source const *selected = view->source(); - debug_view_source const *source = view->source_for_device(device); - if ( selected != source ) { - view->set_source(*source); - if ([[self window] firstResponder] != self) - view->set_cursor_visible(false); - } -} - - -- (NSString *)expression { - return [NSString stringWithUTF8String:downcast(view)->expression()]; -} - - -- (void)setExpression:(NSString *)exp { - downcast(view)->set_expression([exp UTF8String]); -} - - -- (IBAction)showChunkSize:(id)sender { - downcast(view)->set_bytes_per_chunk([sender tag]); -} - - -- (IBAction)showPhysicalAddresses:(id)sender { - downcast(view)->set_physical([sender tag]); -} - - -- (IBAction)showReverseView:(id)sender { - downcast(view)->set_reverse([sender tag]); -} - - -- (IBAction)showReverseViewToggle:(id)sender { - downcast(view)->set_reverse(!downcast(view)->reverse()); -} - - -- (IBAction)changeBytesPerLine:(id)sender { - debug_view_memory *const memView = downcast(view); - memView->set_chunks_per_row(memView->chunks_per_row() + [sender tag]); -} - - -- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { - NSInteger tag; - for (tag = 1; tag <= 8; tag <<= 1) { - NSString *title = [NSString stringWithFormat:@"%ld-byte Chunks", (long)tag]; - NSMenuItem *chunkItem = [menu insertItemWithTitle:title - action:@selector(showChunkSize:) - keyEquivalent:[NSString stringWithFormat:@"%ld", (long)tag] - atIndex:index++]; - [chunkItem setTarget:self]; - [chunkItem setTag:tag]; - } - - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; - - NSMenuItem *logicalItem = [menu insertItemWithTitle:@"Logical Addresses" - action:@selector(showPhysicalAddresses:) - keyEquivalent:@"v" - atIndex:index++]; - [logicalItem setTarget:self]; - [logicalItem setTag:FALSE]; - - NSMenuItem *physicalItem = [menu insertItemWithTitle:@"Physical Addresses" - action:@selector(showPhysicalAddresses:) - keyEquivalent:@"y" - atIndex:index++]; - [physicalItem setTarget:self]; - [physicalItem setTag:TRUE]; - - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; - - NSMenuItem *reverseItem = [menu insertItemWithTitle:@"Reverse View" - action:@selector(showReverseViewToggle:) - keyEquivalent:@"r" - atIndex:index++]; - [reverseItem setTarget:self]; - - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; - - NSMenuItem *increaseItem = [menu insertItemWithTitle:@"Increase Bytes Per Line" - action:@selector(changeBytesPerLine:) - keyEquivalent:@"p" - atIndex:index++]; - [increaseItem setTarget:self]; - [increaseItem setTag:1]; - - NSMenuItem *decreaseItem = [menu insertItemWithTitle:@"Decrease Bytes Per Line" - action:@selector(changeBytesPerLine:) - keyEquivalent:@"o" - atIndex:index++]; - [decreaseItem setTarget:self]; - [decreaseItem setTag:-1]; - - if (index < [menu numberOfItems]) - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; -} - - -- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { - for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) - { - [[menu insertItemWithTitle:[NSString stringWithUTF8String:source->name()] - action:NULL - keyEquivalent:@"" - atIndex:index++] setTag:view->source_list().indexof(*source)]; - } - if (index < [menu numberOfItems]) - [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxmemoryviewer.h b/src/osd/modules/debugger/osx/debugosxmemoryviewer.h deleted file mode 100644 index 4ea37140fdc..00000000000 --- a/src/osd/modules/debugger/osx/debugosxmemoryviewer.h +++ /dev/null @@ -1,31 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxmemoryviewer.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugwindowhandler.h" - -#include "emu.h" - -#import - - -@class MAMEDebugConsole, MAMEMemoryView; - -@interface MAMEMemoryViewer : MAMEExpressionAuxiliaryDebugWindowHandler -{ - MAMEMemoryView *memoryView; -} - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; - -- (IBAction)changeSubview:(id)sender; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxmemoryviewer.m b/src/osd/modules/debugger/osx/debugosxmemoryviewer.m deleted file mode 100644 index d3413e58a99..00000000000 --- a/src/osd/modules/debugger/osx/debugosxmemoryviewer.m +++ /dev/null @@ -1,135 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxmemoryviewer.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxmemoryviewer.h" - -#import "debugosxdebugview.h" -#import "debugosxmemoryview.h" - -#include "debug/debugcpu.h" - - -@implementation MAMEMemoryViewer - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { - NSScrollView *memoryScroll; - NSView *expressionContainer; - NSPopUpButton *actionButton, *subviewButton; - NSRect contentBounds, expressionFrame; - - if (!(self = [super initWithMachine:m title:@"Memory" console:c])) - return nil; - contentBounds = [[window contentView] bounds]; - - // create the expression field - expressionField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; - [expressionField setAutoresizingMask:(NSViewWidthSizable | NSViewMaxXMargin | NSViewMinYMargin)]; - [expressionField setFont:[[MAMEDebugView class] defaultFont]]; - [expressionField setFocusRingType:NSFocusRingTypeNone]; - [expressionField setTarget:self]; - [expressionField setAction:@selector(doExpression:)]; - [expressionField setDelegate:self]; - expressionFrame = [expressionField frame]; - expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2; - [expressionField setFrameSize:expressionFrame.size]; - - // create the subview popup - subviewButton = [[NSPopUpButton alloc] initWithFrame:NSOffsetRect(expressionFrame, - expressionFrame.size.width, - 0)]; - [subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinXMargin | NSViewMinYMargin)]; - [subviewButton setBezelStyle:NSShadowlessSquareBezelStyle]; - [subviewButton setFocusRingType:NSFocusRingTypeNone]; - [subviewButton setFont:[[MAMEDebugView class] defaultFont]]; - [subviewButton setTarget:self]; - [subviewButton setAction:@selector(changeSubview:)]; - [[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom]; - - // create a container for the expression field and subview popup - expressionFrame = NSMakeRect(expressionFrame.size.height, - contentBounds.size.height - expressionFrame.size.height, - contentBounds.size.width - expressionFrame.size.height, - expressionFrame.size.height); - expressionContainer = [[NSView alloc] initWithFrame:expressionFrame]; - [expressionContainer setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; - [expressionContainer addSubview:expressionField]; - [expressionField release]; - [expressionContainer addSubview:subviewButton]; - [subviewButton release]; - [[window contentView] addSubview:expressionContainer]; - [expressionContainer release]; - - // create the memory view - memoryView = [[MAMEMemoryView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) - machine:*machine]; - [memoryView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0]; - memoryScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, - 0, - contentBounds.size.width, - expressionFrame.origin.y)]; - [memoryScroll setDrawsBackground:YES]; - [memoryScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [memoryScroll setHasHorizontalScroller:YES]; - [memoryScroll setHasVerticalScroller:YES]; - [memoryScroll setAutohidesScrollers:YES]; - [memoryScroll setBorderType:NSNoBorder]; - [memoryScroll setDocumentView:memoryView]; - [memoryView release]; - [[window contentView] addSubview:memoryScroll]; - [memoryScroll release]; - - // create the action popup - actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, - expressionFrame.origin.y, - expressionFrame.size.height, - expressionFrame.size.height)]; - [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; - [memoryView insertActionItemsInMenu:[actionButton menu] atIndex:1]; - [[window contentView] addSubview:actionButton]; - [actionButton release]; - - // set default state - [memoryView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)]; - [memoryView setExpression:@"0"]; - [expressionField setStringValue:@"0"]; - [expressionField selectText:self]; - [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[memoryView selectedSubviewIndex]]]; - [window makeFirstResponder:expressionField]; - [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]]; - - // calculate the optimal size for everything - NSSize const desired = [NSScrollView frameSizeForContentSize:[memoryView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[memoryScroll borderType]]; - [self cascadeWindowWithDesiredSize:desired forView:memoryScroll]; - - // don't forget the result - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - - -- (id )documentView { - return memoryView; -} - - -- (IBAction)changeSubview:(id)sender { - [memoryView selectSubviewAtIndex:[[sender selectedItem] tag]]; - [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxpointsviewer.h b/src/osd/modules/debugger/osx/debugosxpointsviewer.h deleted file mode 100644 index 885affcc0a6..00000000000 --- a/src/osd/modules/debugger/osx/debugosxpointsviewer.h +++ /dev/null @@ -1,31 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxpointsviewer.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugwindowhandler.h" - -#include "emu.h" - -#import - - -@class MAMEDebugConsole; - -@interface MAMEPointsViewer : MAMEAuxiliaryDebugWindowHandler -{ - NSTabView *tabs; -} - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; - -- (IBAction)changeSubview:(id)sender; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxpointsviewer.m b/src/osd/modules/debugger/osx/debugosxpointsviewer.m deleted file mode 100644 index b5667581af1..00000000000 --- a/src/osd/modules/debugger/osx/debugosxpointsviewer.m +++ /dev/null @@ -1,147 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxpointsviewer.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxpointsviewer.h" - -#import "debugosxbreakpointsview.h" -#import "debugosxwatchpointsview.h" - - -@implementation MAMEPointsViewer - -- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { - MAMEDebugView *breakView, *watchView; - NSScrollView *breakScroll, *watchScroll; - NSTabViewItem *breakTab, *watchTab; - NSPopUpButton *actionButton, *subviewButton; - NSRect contentBounds; - - if (!(self = [super initWithMachine:m title:@"(Break|Watch)points" console:c])) - return nil; - contentBounds = [[window contentView] bounds]; - - // create the subview popup - subviewButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(19, - contentBounds.size.height - 19, - contentBounds.size.width - 19, - 19)]; - [subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; - [subviewButton setBezelStyle:NSShadowlessSquareBezelStyle]; - [subviewButton setFocusRingType:NSFocusRingTypeNone]; - [subviewButton setFont:[[MAMEDebugView class] defaultFont]]; - [subviewButton setTarget:self]; - [subviewButton setAction:@selector(changeSubview:)]; - [[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom]; - [[[subviewButton menu] addItemWithTitle:@"All Breakpoints" - action:NULL - keyEquivalent:@""] setTag:0]; - [[[subviewButton menu] addItemWithTitle:@"All Watchpoints" - action:NULL - keyEquivalent:@""] setTag:1]; - [[window contentView] addSubview:subviewButton]; - [subviewButton release]; - - // create the action popup - actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, - contentBounds.size.height - 19, - 19, - 19)]; - [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; - [[window contentView] addSubview:actionButton]; - [actionButton release]; - - // create the breakpoints view - breakView = [[MAMEBreakpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) - machine:*machine]; - breakScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, - 0, - contentBounds.size.width, - contentBounds.size.height - 19)]; - [breakScroll setDrawsBackground:YES]; - [breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [breakScroll setHasHorizontalScroller:YES]; - [breakScroll setHasVerticalScroller:YES]; - [breakScroll setAutohidesScrollers:YES]; - [breakScroll setBorderType:NSNoBorder]; - [breakScroll setDocumentView:breakView]; - [breakView release]; - breakTab = [[NSTabViewItem alloc] initWithIdentifier:nil]; - [breakTab setView:breakScroll]; - [breakScroll release]; - - // create the breakpoints view - watchView = [[MAMEWatchpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) - machine:*machine]; - watchScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, - 0, - contentBounds.size.width, - contentBounds.size.height - 19)]; - [watchScroll setDrawsBackground:YES]; - [watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [watchScroll setHasHorizontalScroller:YES]; - [watchScroll setHasVerticalScroller:YES]; - [watchScroll setAutohidesScrollers:YES]; - [watchScroll setBorderType:NSNoBorder]; - [watchScroll setDocumentView:watchView]; - [watchView release]; - watchTab = [[NSTabViewItem alloc] initWithIdentifier:nil]; - [watchTab setView:watchScroll]; - [watchScroll release]; - - // create a tabless tabview for the two subviews - tabs = [[NSTabView alloc] initWithFrame:NSMakeRect(0, - 0, - contentBounds.size.width, - contentBounds.size.height - 19)]; - [tabs setTabViewType:NSNoTabsNoBorder]; - [tabs setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [tabs addTabViewItem:breakTab]; - [breakTab release]; - [tabs addTabViewItem:watchTab]; - [watchTab release]; - [[window contentView] addSubview:tabs]; - [tabs release]; - - // set default state - [subviewButton selectItemAtIndex:0]; - [tabs selectFirstTabViewItem:self]; - [window makeFirstResponder:subviewButton]; - [window setTitle:[[subviewButton selectedItem] title]]; - - // calculate the optimal size for everything - NSSize const breakDesired = [NSScrollView frameSizeForContentSize:[breakView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[breakScroll borderType]]; - NSSize const watchDesired = [NSScrollView frameSizeForContentSize:[watchView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[watchScroll borderType]]; - NSSize const desired = NSMakeSize(MAX(breakDesired.width, watchDesired.width), - MAX(breakDesired.height, watchDesired.height)); - [self cascadeWindowWithDesiredSize:desired forView:tabs]; - - // don't forget the result - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - - -- (IBAction)changeSubview:(id)sender { - [tabs selectTabViewItemAtIndex:[[sender selectedItem] tag]]; - [window setTitle:[[sender selectedItem] title]]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxregistersview.h b/src/osd/modules/debugger/osx/debugosxregistersview.h deleted file mode 100644 index 5951cef4dc2..00000000000 --- a/src/osd/modules/debugger/osx/debugosxregistersview.h +++ /dev/null @@ -1,33 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxregistersview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugview.h" - -#include "emu.h" - -#import - - -@interface MAMERegistersView : MAMEDebugView -{ -} - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - -- (NSSize)maximumFrameSize; - -- (NSString *)selectedSubviewName; -- (int)selectedSubviewIndex; -- (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxregistersview.m b/src/osd/modules/debugger/osx/debugosxregistersview.m deleted file mode 100644 index 49c635250eb..00000000000 --- a/src/osd/modules/debugger/osx/debugosxregistersview.m +++ /dev/null @@ -1,71 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxregistersview.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxregistersview.h" - -#include "debug/debugcpu.h" -#include "debug/debugvw.h" - - -@implementation MAMERegistersView - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { - if (!(self = [super initWithFrame:f type:DVT_STATE machine:m])) - return nil; - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - - -- (NSSize)maximumFrameSize { - debug_view_xy max; - device_t *curcpu = debug_cpu_get_visible_cpu(*machine); - const debug_view_source *source = view->source_for_device(curcpu); - - max.x = max.y = 0; - for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) - { - debug_view_xy current; - view->set_source(*source); - current = view->total_size(); - if (current.x > max.x) - max.x = current.x; - if (current.y > max.y) - max.y = current.y; - } - view->set_source(*source); - return NSMakeSize(max.x * fontWidth, max.y * fontHeight); -} - - -- (NSString *)selectedSubviewName { - return @""; -} - - -- (int)selectedSubviewIndex { - return -1; -} - - -- (void)selectSubviewAtIndex:(int)index { -} - - -- (void)selectSubviewForCPU:(device_t *)device { - view->set_source(*view->source_for_device(device)); -} - -@end diff --git a/src/osd/modules/debugger/osx/debugosxwatchpointsview.h b/src/osd/modules/debugger/osx/debugosxwatchpointsview.h deleted file mode 100644 index 02a2c885dfc..00000000000 --- a/src/osd/modules/debugger/osx/debugosxwatchpointsview.h +++ /dev/null @@ -1,26 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxwatchpointsview.h - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosx.h" -#import "debugosxdebugview.h" - -#include "emu.h" - -#import - - -@interface MAMEWatchpointsView : MAMEDebugView -{ -} - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - -@end diff --git a/src/osd/modules/debugger/osx/debugosxwatchpointsview.m b/src/osd/modules/debugger/osx/debugosxwatchpointsview.m deleted file mode 100644 index a023351eb77..00000000000 --- a/src/osd/modules/debugger/osx/debugosxwatchpointsview.m +++ /dev/null @@ -1,30 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Vas Crabb -//============================================================ -// -// debugosxwatchpointsview.m - MacOS X Cocoa debug window handling -// -// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. -// Visit http://mamedev.org for licensing and usage restrictions. -// -//============================================================ - -#import "debugosxwatchpointsview.h" - -#include "debug/debugvw.h" - - -@implementation MAMEWatchpointsView - -- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { - if (!(self = [super initWithFrame:f type:DVT_WATCH_POINTS machine:m])) - return nil; - return self; -} - - -- (void)dealloc { - [super dealloc]; -} - -@end diff --git a/src/osd/modules/debugger/osx/debugview.h b/src/osd/modules/debugger/osx/debugview.h new file mode 100644 index 00000000000..06c25ea7c21 --- /dev/null +++ b/src/osd/modules/debugger/osx/debugview.h @@ -0,0 +1,68 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#include "emu.h" +#include "debug/debugvw.h" + +#import + + +@interface MAMEDebugView : NSView +{ + int type; + running_machine *machine; + debug_view *view; + + INT32 totalWidth, totalHeight, originLeft, originTop; + + NSFont *font; + CGFloat fontWidth, fontHeight, fontAscent; + + NSTextStorage *text; + NSTextContainer *textContainer; + NSLayoutManager *layoutManager; +} + ++ (NSFont *)defaultFont; + +- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m; + +- (void)update; + +- (NSSize)maximumFrameSize; + +- (NSFont *)font; +- (void)setFont:(NSFont *)f; + +- (void)windowDidBecomeKey:(NSNotification *)notification; +- (void)windowDidResignKey:(NSNotification *)notification; + +@end + + +@protocol MAMEDebugViewSubviewSupport + +- (NSString *)selectedSubviewName; +- (int)selectedSubviewIndex; +- (void)selectSubviewAtIndex:(int)index; +- (void)selectSubviewForCPU:(device_t *)device; + +@end + + +@protocol MAMEDebugViewExpressionSupport + +- (NSString *)expression; +- (void)setExpression:(NSString *)exp; + +@end diff --git a/src/osd/modules/debugger/osx/debugview.m b/src/osd/modules/debugger/osx/debugview.m new file mode 100644 index 00000000000..c70801c3f75 --- /dev/null +++ b/src/osd/modules/debugger/osx/debugview.m @@ -0,0 +1,514 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugview.h" + +#include "debug/debugcpu.h" + + +static void debugwin_view_update(debug_view &view, void *osdprivate) +{ + [(MAMEDebugView *)osdprivate update]; +} + + +@implementation MAMEDebugView + +- (NSColor *)foregroundForAttribute:(UINT8)attrib { + const CGFloat alpha = (attrib & DCA_DISABLED) ? 0.5 : 1.0; + if (attrib & DCA_COMMENT) + return [NSColor colorWithCalibratedRed:0.0 green:0.375 blue:0.0 alpha:1.0]; + else if (attrib & DCA_INVALID) + return [NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:alpha]; + else if (attrib & DCA_CHANGED) + return [NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:alpha]; + else + return [NSColor colorWithCalibratedWhite:0.0 alpha:alpha]; +} + + +- (NSColor *)backgroundForAttribute:(UINT8)attrib { + if ((attrib & DCA_SELECTED) && (attrib & DCA_CURRENT)) { + if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self)) + return [NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0]; + else + return [NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0]; + } else if (attrib & DCA_CURRENT) { + return [NSColor colorWithCalibratedRed:1.0 green:0.625 blue:0.625 alpha:1.0]; + } else if (attrib & DCA_SELECTED) { + if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self)) + return [NSColor colorWithCalibratedRed:0.75 green:0.875 blue:1.0 alpha:1.0]; + else + return [NSColor colorWithCalibratedWhite:0.875 alpha:1.0]; + } else if (attrib & DCA_ANCILLARY) { + return [NSColor colorWithCalibratedWhite:0.75 alpha:1.0]; + } else { + return [NSColor colorWithCalibratedWhite:1.0 alpha:1.0]; + } +} + + +- (debug_view_xy)convertLocation:(NSPoint)location { + debug_view_xy position; + + position.y = lround(floor(location.y / fontHeight)); + if (position.y < 0) + position.y = 0; + else if (position.y >= totalHeight) + position.y = totalHeight - 1; + + debug_view_xy const origin = view->visible_position(); + debug_view_xy const size = view->visible_size(); + debug_view_char const *data = view->viewdata(); + if (!data || (position.y < origin.y) || (position.y >= origin.y + size.y)) + { + // y coordinate outside visible area, x will be a guess + position.x = lround(floor(location.x / fontWidth)); + } + else + { + data += ((position.y - view->visible_position().y) * view->visible_size().x); + int attr = -1; + NSUInteger start = 0, length = 0; + for (UINT32 col = origin.x; col < origin.x + size.x; col++) + { + [[text mutableString] appendFormat:@"%c", data[col - origin.x].byte]; + if ((start < length) && (attr != data[col - origin.x].attrib)) + { + NSRange const run = NSMakeRange(start, length - start); + [text addAttribute:NSFontAttributeName + value:font + range:NSMakeRange(0, length)]; + [text addAttribute:NSForegroundColorAttributeName + value:[self foregroundForAttribute:attr] + range:run]; + start = length; + } + attr = data[col - origin.x].attrib; + length = [text length]; + } + if (start < length) + { + NSRange const run = NSMakeRange(start, length - start); + [text addAttribute:NSFontAttributeName + value:font + range:NSMakeRange(0, length)]; + [text addAttribute:NSForegroundColorAttributeName + value:[self foregroundForAttribute:attr] + range:run]; + } + CGFloat fraction; + NSUInteger const glyph = [layoutManager glyphIndexForPoint:NSMakePoint(location.x, fontHeight / 2) + inTextContainer:textContainer + fractionOfDistanceThroughGlyph:&fraction]; + position.x = [layoutManager characterIndexForGlyphAtIndex:glyph]; // FIXME: assumes 1:1 character mapping + [text deleteCharactersInRange:NSMakeRange(0, length)]; + } + if (position.x < 0) + position.x = 0; + else if (position.x >= totalWidth) + position.x = totalWidth - 1; + + return position; +} + + +- (void)convertBounds:(NSRect)b toPosition:(debug_view_xy *)origin size:(debug_view_xy *)size { + origin->x = lround(floor(b.origin.x / fontWidth)); + origin->y = lround(floor(b.origin.y / fontHeight)); + + // FIXME: this is not using proper font metrics horizontally + size->x = lround(ceil((b.origin.x + b.size.width) / fontWidth)) - origin->x; + size->y = lround(ceil((b.origin.y + b.size.height) / fontHeight)) - origin->y; +} + + +- (void)recomputeVisible { + if ([self window] != nil) { + debug_view_xy origin, size; + + // this gets all the characters that are at least paritally visible + [self convertBounds:[self visibleRect] toPosition:&origin size:&size]; + + // need to render entire lines or we get screwed up characters when widening views + origin.x = 0; + size.x = totalWidth; + + // tell them what we think + view->set_visible_size(size); + view->set_visible_position(origin); + originLeft = origin.x; + originTop = origin.y; + } +} + + +- (void)typeCharacterAndScrollToCursor:(char)ch { + if (view->cursor_supported()) { + debug_view_xy oldPos = view->cursor_position(); + view->process_char(ch); + { + debug_view_xy newPos = view->cursor_position(); + if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) { + [self scrollRectToVisible:NSMakeRect(newPos.x * fontWidth, // FIXME - use proper metrics + newPos.y * fontHeight, + fontWidth, + fontHeight)]; + } + } + } else { + view->process_char(ch); + } +} + + ++ (NSFont *)defaultFont { + return [NSFont userFixedPitchFontOfSize:0]; +} + + +- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m { + if (!(self = [super initWithFrame:f])) + return nil; + type = t; + machine = &m; + view = machine->debug_view().alloc_view((debug_view_type)type, debugwin_view_update, self); + if (view == nil) { + [self release]; + return nil; + } + totalWidth = totalHeight = 0; + originLeft = originTop = 0; + + text = [[NSTextStorage alloc] init]; + textContainer = [[NSTextContainer alloc] init]; + layoutManager = [[NSLayoutManager alloc] init]; + [layoutManager addTextContainer:textContainer]; + [textContainer release]; + [text addLayoutManager:layoutManager]; + [layoutManager release]; + + [self setFont:[[self class] defaultFont]]; + + return self; +} + + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + if (font != nil) [font release]; + if (text != nil) [text release]; + [super dealloc]; +} + + +- (void)update { + debug_view_xy newSize, newOrigin; + + // resize our frame if the total size has changed + newSize = view->total_size(); + if ((newSize.x != totalWidth) || (newSize.y != totalHeight)) { + [self setFrameSize:NSMakeSize(fontWidth * newSize.x, fontHeight * newSize.y)]; // FIXME: metrics + totalWidth = newSize.x; + totalHeight = newSize.y; + } + + // scroll the view if we're being told to + newOrigin = view->visible_position(); + if (newOrigin.y != originTop) { + [self scrollPoint:NSMakePoint([self visibleRect].origin.x, newOrigin.y * fontHeight)]; + originTop = newOrigin.y; + } + + // recompute the visible area and mark as dirty + [self recomputeVisible]; + [self setNeedsDisplay:YES]; +} + + +- (NSSize)maximumFrameSize { + debug_view_xy max = view->total_size(); + return NSMakeSize(max.x * fontWidth, max.y * fontHeight); +} + + +- (NSFont *)font { + return [[font retain] autorelease]; +} + + +- (void)setFont:(NSFont *)f { + [font autorelease]; + font = [f retain]; + fontWidth = [font maximumAdvancement].width; + fontHeight = ceil([font ascender] - [font descender]); + fontAscent = [font ascender]; + [[self enclosingScrollView] setLineScroll:fontHeight]; + totalWidth = totalHeight = 0; + [self update]; +} + + +- (void)windowDidBecomeKey:(NSNotification *)notification { + NSWindow *win = [notification object]; + if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported()) + [self setNeedsDisplay:YES]; +} + + +- (void)windowDidResignKey:(NSNotification *)notification { + NSWindow *win = [notification object]; + if ((win == [self window]) && ([win firstResponder] == self) && view->cursor_supported()) + [self setNeedsDisplay:YES]; +} + + +- (BOOL)acceptsFirstResponder { + return view->cursor_supported(); +} + + +- (BOOL)becomeFirstResponder { + if (view->cursor_supported()) { + debug_view_xy pos; + view->set_cursor_visible(true); + pos = view->cursor_position(); + [self scrollRectToVisible:NSMakeRect(pos.x * fontWidth, pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics + [self setNeedsDisplay:YES]; + return [super becomeFirstResponder]; + } else { + return NO; + } +} + + +- (BOOL)resignFirstResponder { + if (view->cursor_supported()) + [self setNeedsDisplay:YES]; + return [super resignFirstResponder]; +} + + +- (void)viewDidMoveToSuperview { + [[self enclosingScrollView] setLineScroll:fontHeight]; + [super viewDidMoveToSuperview]; +} + + +- (void)viewDidMoveToWindow { + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:nil]; + if ([self window] != nil) { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(windowDidBecomeKey:) + name:NSWindowDidBecomeKeyNotification + object:[self window]]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(windowDidResignKey:) + name:NSWindowDidResignKeyNotification + object:[self window]]; + [self recomputeVisible]; + } +} + + +- (BOOL)isFlipped { + return YES; +} + + +- (void)drawRect:(NSRect)dirtyRect { + debug_view_xy position, clip; + + // work out how much we need to draw + [self recomputeVisible]; + debug_view_xy const origin = view->visible_position(); + debug_view_xy const size = view->visible_size(); + [self convertBounds:dirtyRect toPosition:&position size:&clip]; + + // this gets the text for the whole visible area + debug_view_char const *data = view->viewdata(); + if (!data) + return; + + data += ((position.y - origin.y) * size.x); + for (UINT32 row = position.y; row < position.y + clip.y; row++, data += size.x) + { + if ((row < origin.y) || (row >= origin.y + size.y)) + continue; + + // render entire lines to get character alignment right + int attr = -1; + NSUInteger start = 0, length = 0; + for (UINT32 col = origin.x; col < origin.x + size.x; col++) + { + [[text mutableString] appendFormat:@"%c", data[col - origin.x].byte]; + if ((start < length) && (attr != data[col - origin.x].attrib)) + { + NSRange const run = NSMakeRange(start, length - start); + [text addAttribute:NSFontAttributeName + value:font + range:NSMakeRange(0, length)]; + [text addAttribute:NSForegroundColorAttributeName + value:[self foregroundForAttribute:attr] + range:run]; + NSRange const glyphs = [layoutManager glyphRangeForCharacterRange:run + actualCharacterRange:NULL]; + NSRect const box = [layoutManager boundingRectForGlyphRange:glyphs + inTextContainer:textContainer]; + [[self backgroundForAttribute:attr] set]; + [NSBezierPath fillRect:NSMakeRect(box.origin.x, + row * fontHeight, + box.size.width, + fontHeight)]; + start = length; + } + attr = data[col - origin.x].attrib; + length = [text length]; + } + if (start < length) + { + NSRange const run = NSMakeRange(start, length - start); + [text addAttribute:NSFontAttributeName + value:font + range:NSMakeRange(0, length)]; + [text addAttribute:NSForegroundColorAttributeName + value:[self foregroundForAttribute:attr] + range:run]; + NSRange const glyphs = [layoutManager glyphRangeForCharacterRange:run + actualCharacterRange:NULL]; + NSRect const box = [layoutManager boundingRectForGlyphRange:glyphs + inTextContainer:textContainer]; + [[self backgroundForAttribute:attr] set]; + [NSBezierPath fillRect:NSMakeRect(box.origin.x, + row * fontHeight, + box.size.width, + fontHeight)]; + } + [layoutManager drawGlyphsForGlyphRange:[layoutManager glyphRangeForTextContainer:textContainer] + atPoint:NSMakePoint(0, row * fontHeight)]; + [text deleteCharactersInRange:NSMakeRange(0, length)]; + } +} + + +- (void)mouseDown:(NSEvent *)event { + NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; + view->process_click(DCK_LEFT_CLICK, [self convertLocation:location]); + [self setNeedsDisplay:YES]; +} + + +- (void)rightMouseDown:(NSEvent *)event { + NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; + view->process_click(DCK_RIGHT_CLICK, [self convertLocation:location]); + [self setNeedsDisplay:YES]; + [super rightMouseDown:event]; +} + + +- (void)keyDown:(NSEvent *)event { + NSUInteger modifiers = [event modifierFlags]; + NSString *str = [event charactersIgnoringModifiers]; + + if ([str length] == 1) { + if (modifiers & NSNumericPadKeyMask) { + switch ([str characterAtIndex:0]) { + case NSUpArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + view->process_char(DCH_CTRLHOME); + else + view->process_char(DCH_UP); + return; + case NSDownArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + view->process_char(DCH_CTRLEND); + else + view->process_char(DCH_DOWN); + return; + case NSLeftArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + [self typeCharacterAndScrollToCursor:DCH_HOME]; + else if (modifiers & NSAlternateKeyMask) + [self typeCharacterAndScrollToCursor:DCH_CTRLLEFT]; + else + [self typeCharacterAndScrollToCursor:DCH_LEFT]; + return; + case NSRightArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + [self typeCharacterAndScrollToCursor:DCH_END]; + else if (modifiers & NSAlternateKeyMask) + [self typeCharacterAndScrollToCursor:DCH_CTRLRIGHT]; + else + [self typeCharacterAndScrollToCursor:DCH_RIGHT]; + return; + default: + [self interpretKeyEvents:[NSArray arrayWithObject:event]]; + return; + } + } else if (modifiers & NSFunctionKeyMask) { + switch ([str characterAtIndex:0]) { + case NSPageUpFunctionKey: + if (modifiers & NSAlternateKeyMask) { + view->process_char(DCH_PUP); + return; + } + case NSPageDownFunctionKey: + if (modifiers & NSAlternateKeyMask) { + view->process_char(DCH_PDOWN); + return; + } + default: + ; + } + [super keyDown:event]; + return; + } + } + [self interpretKeyEvents:[NSArray arrayWithObject:event]]; +} + + +- (void)insertTab:(id)sender { + if ([[self window] firstResponder] == self) + [[self window] selectNextKeyView:self]; +} + + +- (void)insertBacktab:(id)sender { + if ([[self window] firstResponder] == self) + [[self window] selectPreviousKeyView:self]; +} + + +- (void)insertNewline:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); +} + + +- (void)insertText:(id)string { + NSUInteger len; + NSRange found; + if ([string isKindOfClass:[NSAttributedString class]]) + string = [string string]; + for (len = [string length], found = NSMakeRange(0, 0); + found.location < len; + found.location += found.length) { + found = [string rangeOfComposedCharacterSequenceAtIndex:found.location]; + if (found.length == 1) { + unichar ch = [string characterAtIndex:found.location]; + if ((ch >= 32) && (ch < 127)) + [self typeCharacterAndScrollToCursor:ch]; + } + } +} + +@end diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.h b/src/osd/modules/debugger/osx/debugwindowhandler.h new file mode 100644 index 00000000000..ba0f75fadad --- /dev/null +++ b/src/osd/modules/debugger/osx/debugwindowhandler.h @@ -0,0 +1,98 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugwindowhandler.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#include "emu.h" + +#import + + +@protocol MAMEDebugViewExpressionSupport; +@class MAMEDebugCommandHistory, MAMEDebugConsole; + + +extern NSString *const MAMEHideDebuggerNotification; +extern NSString *const MAMEShowDebuggerNotification; +extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification; + + +@interface MAMEDebugWindowHandler : NSObject +{ + NSWindow *window; + running_machine *machine; +} + ++ (void)addCommonActionItems:(NSMenu *)menu; ++ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame; + +- (id)initWithMachine:(running_machine &)m title:(NSString *)t; + +- (void)activate; + +- (IBAction)debugRun:(id)sender; +- (IBAction)debugRunAndHide:(id)sender; +- (IBAction)debugRunToNextCPU:(id)sender; +- (IBAction)debugRunToNextInterrupt:(id)sender; +- (IBAction)debugRunToNextVBLANK:(id)sender; + +- (IBAction)debugStepInto:(id)sender; +- (IBAction)debugStepOver:(id)sender; +- (IBAction)debugStepOut:(id)sender; + +- (IBAction)debugSoftReset:(id)sender; +- (IBAction)debugHardReset:(id)sender; + +- (IBAction)debugExit:(id)sender; + +- (void)showDebugger:(NSNotification *)notification; +- (void)hideDebugger:(NSNotification *)notification; + +@end + + +@interface MAMEAuxiliaryDebugWindowHandler : MAMEDebugWindowHandler +{ + MAMEDebugConsole *console; +} + ++ (void)cascadeWindow:(NSWindow *)window; + +- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c; + +- (IBAction)debugNewMemoryWindow:(id)sender; +- (IBAction)debugNewDisassemblyWindow:(id)sender; +- (IBAction)debugNewErrorLogWindow:(id)sender; +- (IBAction)debugNewPointsWindow:(id)sender; + +- (void)windowWillClose:(NSNotification *)notification; + +- (void)cascadeWindowWithDesiredSize:(NSSize)desired forView:(NSView *)view; + +@end + + +@interface MAMEExpressionAuxiliaryDebugWindowHandler : MAMEAuxiliaryDebugWindowHandler +{ + MAMEDebugCommandHistory *history; + NSTextField *expressionField; +} + +- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c; + +- (id )documentView; + +- (IBAction)doExpression:(id)sender; + +- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor; +- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command; + +@end diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.m b/src/osd/modules/debugger/osx/debugwindowhandler.m new file mode 100644 index 00000000000..3b4ed3eb590 --- /dev/null +++ b/src/osd/modules/debugger/osx/debugwindowhandler.m @@ -0,0 +1,403 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdebugwindowhandler.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugwindowhandler.h" + +#import "debugcommandhistory.h" +#import "debugview.h" + +#include "debug/debugcpu.h" + + +//============================================================ +// NOTIFICATIONS +//============================================================ + +NSString *const MAMEHideDebuggerNotification = @"MAMEHideDebuggerNotification"; +NSString *const MAMEShowDebuggerNotification = @"MAMEShowDebuggerNotification"; +NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryDebugWindowWillCloseNotification"; + + +//============================================================ +// MAMEDebugWindowHandler class +//============================================================ + +@implementation MAMEDebugWindowHandler + ++ (void)addCommonActionItems:(NSMenu *)menu { + { + NSMenuItem *runParentItem = [menu addItemWithTitle:@"Run" + action:@selector(debugRun:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF5FunctionKey]]; + NSMenu *runMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Run"]; + [runParentItem setSubmenu:runMenu]; + [runMenu release]; + [runParentItem setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"and Hide Debugger" + action:@selector(debugRunAndHide:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF12FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"to Next CPU" + action:@selector(debugRunToNextCPU:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF6FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"until Next Interrupt on Current CPU" + action:@selector(debugRunToNextInterrupt:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF7FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"until Next VBLANK" + action:@selector(debugRunToNextVBLANK:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF8FunctionKey]] + setKeyEquivalentModifierMask:0]; + } + { + NSMenuItem *stepParentItem = [menu addItemWithTitle:@"Step" action:NULL keyEquivalent:@""]; + NSMenu *stepMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Step"]; + [stepParentItem setSubmenu:stepMenu]; + [stepMenu release]; + [[stepMenu addItemWithTitle:@"Into" + action:@selector(debugStepInto:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF11FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[stepMenu addItemWithTitle:@"Over" + action:@selector(debugStepOver:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[stepMenu addItemWithTitle:@"Out" + action:@selector(debugStepOut:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] + setKeyEquivalentModifierMask:NSShiftKeyMask]; + } + { + NSMenuItem *resetParentItem = [menu addItemWithTitle:@"Reset" action:NULL keyEquivalent:@""]; + NSMenu *resetMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Reset"]; + [resetParentItem setSubmenu:resetMenu]; + [resetMenu release]; + [[resetMenu addItemWithTitle:@"Soft" + action:@selector(debugSoftReset:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[resetMenu addItemWithTitle:@"Hard" + action:@selector(debugHardReset:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] + setKeyEquivalentModifierMask:NSShiftKeyMask]; + } + [menu addItem:[NSMenuItem separatorItem]]; + { + NSMenuItem *newParentItem = [menu addItemWithTitle:@"New" action:NULL keyEquivalent:@""]; + NSMenu *newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"New"]; + [newParentItem setSubmenu:newMenu]; + [newMenu release]; + [newMenu addItemWithTitle:@"Memory Window" + action:@selector(debugNewMemoryWindow:) + keyEquivalent:@"d"]; + [newMenu addItemWithTitle:@"Disassembly Window" + action:@selector(debugNewDisassemblyWindow:) + keyEquivalent:@"a"]; + [newMenu addItemWithTitle:@"Error Log Window" + action:@selector(debugNewErrorLogWindow:) + keyEquivalent:@"l"]; + [newMenu addItemWithTitle:@"(Break|Watch)points Window" + action:@selector(debugNewPointsWindow:) + keyEquivalent:@"b"]; + } + [menu addItem:[NSMenuItem separatorItem]]; + [menu addItemWithTitle:@"Close Window" action:@selector(performClose:) keyEquivalent:@"w"]; + [menu addItemWithTitle:@"Exit" action:@selector(debugExit:) keyEquivalent:@""]; +} + + ++ (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame { + NSPopUpButton *actionButton = [[NSPopUpButton alloc] initWithFrame:frame pullsDown:YES]; + [actionButton setTitle:@""]; + [actionButton addItemWithTitle:@""]; + [actionButton setBezelStyle:NSShadowlessSquareBezelStyle]; + [actionButton setFocusRingType:NSFocusRingTypeNone]; + [[actionButton cell] setArrowPosition:NSPopUpArrowAtCenter]; + [[self class] addCommonActionItems:[actionButton menu]]; + return actionButton; +} + + +- (id)initWithMachine:(running_machine &)m title:(NSString *)t { + if (!(self = [super init])) + return nil; + + window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 320, 240) + styleMask:(NSTitledWindowMask | + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask) + backing:NSBackingStoreBuffered + defer:YES]; + [window setReleasedWhenClosed:NO]; + [window setDelegate:self]; + [window setTitle:t]; + [window setContentMinSize:NSMakeSize(320, 240)]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(showDebugger:) + name:MAMEShowDebuggerNotification + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(hideDebugger:) + name:MAMEHideDebuggerNotification + object:nil]; + + machine = &m; + + return self; +} + + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + if (window != nil) + [window release]; + + [super dealloc]; +} + + +- (void)activate { + [window makeKeyAndOrderFront:self]; +} + + +- (IBAction)debugRun:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->go(); +} + + +- (IBAction)debugRunAndHide:(id)sender { + [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification object:self]; + debug_cpu_get_visible_cpu(*machine)->debug()->go(); +} + + +- (IBAction)debugRunToNextCPU:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->go_next_device(); +} + + +- (IBAction)debugRunToNextInterrupt:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->go_interrupt(); +} + + +- (IBAction)debugRunToNextVBLANK:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->go_vblank(); +} + + +- (IBAction)debugStepInto:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->single_step(); +} + + +- (IBAction)debugStepOver:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->single_step_over(); +} + + +- (IBAction)debugStepOut:(id)sender { + debug_cpu_get_visible_cpu(*machine)->debug()->single_step_out(); +} + + +- (IBAction)debugSoftReset:(id)sender { + machine->schedule_soft_reset(); + debug_cpu_get_visible_cpu(*machine)->debug()->go(); +} + + +- (IBAction)debugHardReset:(id)sender { + machine->schedule_hard_reset(); +} + + +- (IBAction)debugExit:(id)sender { + machine->schedule_exit(); +} + + +- (void)showDebugger:(NSNotification *)notification { + device_t *device = (device_t *) [[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue]; + if (&device->machine() == machine) { + if (![window isVisible] && ![window isMiniaturized]) + [window orderFront:self]; + } +} + + +- (void)hideDebugger:(NSNotification *)notification { + [window orderOut:self]; +} + +@end + + +//============================================================ +// MAMEAuxiliaryDebugWindowHandler class +//============================================================ + +@implementation MAMEAuxiliaryDebugWindowHandler + ++ (void)cascadeWindow:(NSWindow *)window { + static NSPoint lastPosition = { 0, 0 }; + if (NSEqualPoints(lastPosition, NSZeroPoint)) { + NSRect available = [[NSScreen mainScreen] visibleFrame]; + lastPosition = NSMakePoint(available.origin.x + 12, available.origin.y + available.size.height - 8); + } + lastPosition = [window cascadeTopLeftFromPoint:lastPosition]; +} + + +- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c { + if (!(self = [super initWithMachine:m title:t])) + return nil; + console = c; + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + + +- (IBAction)debugNewMemoryWindow:(id)sender { + [console debugNewMemoryWindow:sender]; +} + + +- (IBAction)debugNewDisassemblyWindow:(id)sender { + [console debugNewDisassemblyWindow:sender]; +} + + +- (IBAction)debugNewErrorLogWindow:(id)sender { + [console debugNewErrorLogWindow:sender]; +} + + +- (IBAction)debugNewPointsWindow:(id)sender { + [console debugNewPointsWindow:sender]; +} + + +- (void)windowWillClose:(NSNotification *)notification { + [[NSNotificationCenter defaultCenter] postNotificationName:MAMEAuxiliaryDebugWindowWillCloseNotification + object:self]; +} + +- (void)cascadeWindowWithDesiredSize:(NSSize)desired forView:(NSView *)view { + NSRect available = [[NSScreen mainScreen] visibleFrame]; + NSRect windowFrame = [window frame]; + NSSize current = [view frame].size; + + desired.width -= current.width; + desired.height -= current.height; + + windowFrame.size.width += desired.width; + windowFrame.size.height += desired.height; + windowFrame.size.height = MIN(MIN(windowFrame.size.height, 240), available.size.height); + windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); + windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; + windowFrame.origin.y = available.origin.y; + [window setFrame:windowFrame display:YES]; + [[self class] cascadeWindow:window]; + + windowFrame = [[window contentView] frame]; + desired = [window contentMinSize]; + [window setContentMinSize:NSMakeSize(MIN(windowFrame.size.width, desired.width), + MIN(windowFrame.size.height, desired.height))]; +} + +@end + + +//============================================================ +// MAMEExpreesionAuxiliaryDebugWindowHandler class +//============================================================ + +@implementation MAMEExpressionAuxiliaryDebugWindowHandler + +- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c { + if (!(self = [super initWithMachine:m title:t console:c])) + return nil; + history = [[MAMEDebugCommandHistory alloc] init]; + return self; +} + + +- (void)dealloc { + if (history != nil) + [history release]; + [super dealloc]; +} + + +- (id )documentView { + return nil; +} + + +- (IBAction)doExpression:(id)sender { + NSString *expr = [sender stringValue]; + if ([expr length] > 0) { + [history add:expr]; + [[self documentView] setExpression:expr]; + } else { + [sender setStringValue:[[self documentView] expression]]; + [history reset]; + } + [sender selectText:self]; +} + + +- (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor +{ + if (control == expressionField) + [history edit]; + + return YES; +} + + +- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command { + if (control == expressionField) { + if (command == @selector(cancelOperation:)) { + [history reset]; + [expressionField setStringValue:[[self documentView] expression]]; + [expressionField selectText:self]; + return YES; + } else if (command == @selector(moveUp:)) { + NSString *hist = [history previous:[expressionField stringValue]]; + if (hist != nil) { + [expressionField setStringValue:hist]; + [expressionField selectText:self]; + } + return YES; + } else if (command == @selector(moveDown:)) { + NSString *hist = [history next:[expressionField stringValue]]; + if (hist != nil) { + [expressionField setStringValue:hist]; + [expressionField selectText:self]; + } + return YES; + } + } + return NO; +} + +@end \ No newline at end of file diff --git a/src/osd/modules/debugger/osx/disassemblyview.h b/src/osd/modules/debugger/osx/disassemblyview.h new file mode 100644 index 00000000000..6c261dcaa60 --- /dev/null +++ b/src/osd/modules/debugger/osx/disassemblyview.h @@ -0,0 +1,47 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdisassemblyview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugview.h" + +#include "emu.h" + +#import + + +@interface MAMEDisassemblyView : MAMEDebugView +{ + BOOL useConsole; +} + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc; + +- (NSSize)maximumFrameSize; + +- (NSString *)selectedSubviewName; +- (int)selectedSubviewIndex; +- (void)selectSubviewAtIndex:(int)index; +- (void)selectSubviewForCPU:(device_t *)device; + +- (NSString *)expression; +- (void)setExpression:(NSString *)exp; + +- (IBAction)debugToggleBreakpoint:(id)sender; +- (IBAction)debugToggleBreakpointEnable:(id)sender; +- (IBAction)debugRunToCursor:(id)sender; + +- (IBAction)showRightColumn:(id)sender; + +- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; +- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; + +@end diff --git a/src/osd/modules/debugger/osx/disassemblyview.m b/src/osd/modules/debugger/osx/disassemblyview.m new file mode 100644 index 00000000000..2592aeefdfc --- /dev/null +++ b/src/osd/modules/debugger/osx/disassemblyview.m @@ -0,0 +1,370 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdisassemblyview.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "disassemblyview.h" + +#include "debug/debugcon.h" +#include "debug/debugcpu.h" +#include "debug/debugvw.h" +#include "debug/dvdisasm.h" + + +@implementation MAMEDisassemblyView + +- (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address inAddressSpace:(address_space &)space { + device_debug *cpuinfo = space.device().debug(); + device_debug::breakpoint *bp; + for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) {} + return bp; +} + +- (void)createContextMenu { + NSMenu *contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Disassembly"]; + NSMenuItem *item; + + item = [contextMenu addItemWithTitle:@"Toggle Breakpoint" + action:@selector(debugToggleBreakpoint:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; + [item setKeyEquivalentModifierMask:0]; + [item setTarget:self]; + + item = [contextMenu addItemWithTitle:@"Disable Breakpoint" + action:@selector(debugToggleBreakpointEnable:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; + [item setKeyEquivalentModifierMask:NSShiftKeyMask]; + [item setTarget:self]; + + [contextMenu addItem:[NSMenuItem separatorItem]]; + + item = [contextMenu addItemWithTitle:@"Run to Cursor" + action:@selector(debugRunToCursor:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; + [item setKeyEquivalentModifierMask:0]; + [item setTarget:self]; + + [contextMenu addItem:[NSMenuItem separatorItem]]; + + item = [contextMenu addItemWithTitle:@"Raw Opcodes" + action:@selector(showRightColumn:) + keyEquivalent:@"r"]; + [item setTarget:self]; + [item setTag:DASM_RIGHTCOL_RAW]; + + item = [contextMenu addItemWithTitle:@"Encrypted Opcodes" + action:@selector(showRightColumn:) + keyEquivalent:@"e"]; + [item setTarget:self]; + [item setTag:DASM_RIGHTCOL_ENCRYPTED]; + + item = [contextMenu addItemWithTitle:@"Comments" + action:@selector(showRightColumn:) + keyEquivalent:@"n"]; + [item setTarget:self]; + [item setTag:DASM_RIGHTCOL_COMMENTS]; + + [self setMenu:contextMenu]; + [contextMenu release]; +} + + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc { + if (!(self = [super initWithFrame:f type:DVT_DISASSEMBLY machine:m])) + return nil; + useConsole = uc; + [self createContextMenu]; + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + + +- (BOOL)validateMenuItem:(NSMenuItem *)item { + SEL action = [item action]; + BOOL inContextMenu = ([item menu] == [self menu]); + BOOL haveCursor = NO, isCurrent = NO; + device_debug::breakpoint *breakpoint = NULL; + + if (view->cursor_visible()) { + if (debug_cpu_get_visible_cpu(*machine) == view->source()->device()) { + isCurrent = YES; + if (!useConsole || isCurrent) { + offs_t address = downcast(view)->selected_address(); + haveCursor = YES; + breakpoint = [self findBreakpointAtAddress:address inAddressSpace:downcast(view->source())->space()]; + } + } + } + + if (action == @selector(debugToggleBreakpoint:)) { + if (haveCursor) { + if (breakpoint != NULL) { + if (inContextMenu) + [item setTitle:@"Clear Breakpoint"]; + else + [item setTitle:@"Clear Breakpoint at Cursor"]; + } else { + if (inContextMenu) + [item setTitle:@"Set Breakpoint"]; + else + [item setTitle:@"Set Breakpoint at Cursor"]; + } + } else { + if (inContextMenu) + [item setTitle:@"Toggle Breakpoint"]; + else + [item setTitle:@"Toggle Breakpoint at Cursor"]; + } + return haveCursor; + } else if (action == @selector(debugToggleBreakpointEnable:)) { + if ((breakpoint != NULL) && !breakpoint->enabled()) { + if (inContextMenu) + [item setTitle:@"Enable Breakpoint"]; + else + [item setTitle:@"Enable Breakpoint at Cursor"]; + } else { + if (inContextMenu) + [item setTitle:@"Disable Breakpoint"]; + else + [item setTitle:@"Disable Breakpoint at Cursor"]; + } + return (breakpoint != NULL); + } else if (action == @selector(debugRunToCursor:)) { + return isCurrent; + } else if (action == @selector(showRightColumn:)) { + [item setState:((downcast(view)->right_column() == [item tag]) ? NSOnState : NSOffState)]; + return YES; + } else { + return YES; + } +} + + +- (NSSize)maximumFrameSize { + debug_view_xy max; + device_t *curcpu = debug_cpu_get_visible_cpu(*machine); + const debug_view_source *source = view->source_for_device(curcpu); + + max.x = max.y = 0; + for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) + { + debug_view_xy current; + view->set_source(*source); + current = view->total_size(); + if (current.x > max.x) + max.x = current.x; + if (current.y > max.y) + max.y = current.y; + } + view->set_source(*source); + return NSMakeSize(max.x * fontWidth, max.y * fontHeight); +} + + +- (NSString *)selectedSubviewName { + const debug_view_source *source = view->source(); + if (source != NULL) + return [NSString stringWithUTF8String:source->name()]; + else + return @""; +} + + +- (int)selectedSubviewIndex { + const debug_view_source *source = view->source(); + if (source != NULL) + return view->source_list().indexof(*source); + else + return -1; +} + + +- (void)selectSubviewAtIndex:(int)index { + const int selected = view->source_list().indexof(*view->source()); + if (selected != index) { + view->set_source(*view->source_list().find(index)); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } +} + + +- (void)selectSubviewForCPU:(device_t *)device { + const debug_view_source *selected = view->source(); + const debug_view_source *source = view->source_for_device(device); + if ( selected != source ) { + view->set_source(*source); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } +} + + +- (NSString *)expression { + return [NSString stringWithUTF8String:downcast(view)->expression()]; +} + + +- (void)setExpression:(NSString *)exp { + downcast(view)->set_expression([exp UTF8String]); +} + + +- (IBAction)debugToggleBreakpoint:(id)sender { + if (view->cursor_visible()) { + address_space &space = downcast(view->source())->space(); + if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) { + offs_t address = downcast(view)->selected_address(); + device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; + + // if it doesn't exist, add a new one + if (useConsole) { + NSString *command; + if (bp == NULL) + command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address]; + else + command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()]; + debug_console_execute_command(*machine, [command UTF8String], 1); + } else { + if (bp == NULL) + space.device().debug()->breakpoint_set(address, NULL, NULL); + else + space.device().debug()->breakpoint_clear(bp->index()); + } + } + } +} + + +- (IBAction)debugToggleBreakpointEnable:(id)sender { + if (view->cursor_visible()) { + address_space &space = downcast(view->source())->space(); + if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) { + offs_t address = downcast(view)->selected_address(); + device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; + + if (bp != NULL) { + NSString *command; + if (useConsole) { + if (bp->enabled()) + command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()]; + else + command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()]; + debug_console_execute_command(*machine, [command UTF8String], 1); + } else { + space.device().debug()->breakpoint_enable(bp->index(), !bp->enabled()); + } + } + } + } +} + + +- (IBAction)debugRunToCursor:(id)sender { + if (view->cursor_visible()) { + address_space &space = downcast(view->source())->space(); + if (debug_cpu_get_visible_cpu(*machine) == &space.device()) { + offs_t address = downcast(view)->selected_address(); + if (useConsole) { + NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)address]; + debug_console_execute_command(*machine, [command UTF8String], 1); + } else { + debug_cpu_get_visible_cpu(*machine)->debug()->go(address); + } + } + } +} + + +- (IBAction)showRightColumn:(id)sender { + downcast(view)->set_right_column((disasm_right_column) [sender tag]); +} + + +- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { + { + NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor" + action:@selector(debugToggleBreakpoint:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] + atIndex:index++]; + [breakItem setKeyEquivalentModifierMask:0]; + [breakItem setTarget:self]; + } + { + NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor" + action:@selector(debugToggleBreakpointEnable:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] + atIndex:index++]; + [disableItem setKeyEquivalentModifierMask:NSShiftKeyMask]; + [disableItem setAlternate:YES]; + [disableItem setTarget:self]; + } + { + NSMenu *runMenu = [[menu itemWithTitle:@"Run"] submenu]; + NSMenuItem *runItem; + if (runMenu != nil) { + runItem = [runMenu addItemWithTitle:@"to Cursor" + action:@selector(debugRunToCursor:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; + } else { + runItem = [menu insertItemWithTitle:@"Run to Cursor" + action:@selector(debugRunToCursor:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey] + atIndex:index++]; + } + [runItem setKeyEquivalentModifierMask:0]; + [runItem setTarget:self]; + } + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; + { + NSMenuItem *rawItem = [menu insertItemWithTitle:@"Show Raw Opcodes" + action:@selector(showRightColumn:) + keyEquivalent:@"r" + atIndex:index++]; + [rawItem setTarget:self]; + [rawItem setTag:DASM_RIGHTCOL_RAW]; + } + { + NSMenuItem *encItem = [menu insertItemWithTitle:@"Show Encrypted Opcodes" + action:@selector(showRightColumn:) + keyEquivalent:@"e" + atIndex:index++]; + [encItem setTarget:self]; + [encItem setTag:DASM_RIGHTCOL_ENCRYPTED]; + } + { + NSMenuItem *commentsItem = [menu insertItemWithTitle:@"Show Comments" + action:@selector(showRightColumn:) + keyEquivalent:@"n" + atIndex:index++]; + [commentsItem setTarget:self]; + [commentsItem setTag:DASM_RIGHTCOL_COMMENTS]; + } + if (index < [menu numberOfItems]) + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; +} + + +- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { + for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) + { + [[menu insertItemWithTitle:[NSString stringWithUTF8String:source->name()] + action:NULL + keyEquivalent:@"" + atIndex:index++] setTag:view->source_list().indexof(*source)]; + } + if (index < [menu numberOfItems]) + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; +} + +@end diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.h b/src/osd/modules/debugger/osx/disassemblyviewer.h new file mode 100644 index 00000000000..fc2598249aa --- /dev/null +++ b/src/osd/modules/debugger/osx/disassemblyviewer.h @@ -0,0 +1,32 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdisassemblyviewer.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugwindowhandler.h" + +#include "emu.h" + +#import + + +@class MAMEDebugConsole, MAMEDisassemblyView; + +@interface MAMEDisassemblyViewer : MAMEExpressionAuxiliaryDebugWindowHandler +{ + MAMEDisassemblyView *dasmView; +} + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; + +- (IBAction)changeSubview:(id)sender; + +@end diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.m b/src/osd/modules/debugger/osx/disassemblyviewer.m new file mode 100644 index 00000000000..6b4272202bb --- /dev/null +++ b/src/osd/modules/debugger/osx/disassemblyviewer.m @@ -0,0 +1,138 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxdisassemblyviewer.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "disassemblyviewer.h" + +#import "debugview.h" +#import "disassemblyview.h" + +#include "debug/debugcpu.h" + + +@implementation MAMEDisassemblyViewer + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { + NSScrollView *dasmScroll; + NSView *expressionContainer; + NSPopUpButton *actionButton, *subviewButton; + NSRect contentBounds, expressionFrame; + + if (!(self = [super initWithMachine:m title:@"Disassembly" console:c])) + return nil; + contentBounds = [[window contentView] bounds]; + + // create the expression field + expressionField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; + [expressionField setAutoresizingMask:(NSViewWidthSizable | NSViewMaxXMargin | NSViewMinYMargin)]; + [expressionField setFont:[[MAMEDebugView class] defaultFont]]; + [expressionField setFocusRingType:NSFocusRingTypeNone]; + [expressionField setTarget:self]; + [expressionField setAction:@selector(doExpression:)]; + [expressionField setDelegate:self]; + expressionFrame = [expressionField frame]; + expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2; + [expressionField setFrameSize:expressionFrame.size]; + + // create the subview popup + subviewButton = [[NSPopUpButton alloc] initWithFrame:NSOffsetRect(expressionFrame, + expressionFrame.size.width, + 0)]; + [subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinXMargin | NSViewMinYMargin)]; + [subviewButton setBezelStyle:NSShadowlessSquareBezelStyle]; + [subviewButton setFocusRingType:NSFocusRingTypeNone]; + [subviewButton setFont:[[MAMEDebugView class] defaultFont]]; + [subviewButton setTarget:self]; + [subviewButton setAction:@selector(changeSubview:)]; + [[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom]; + + // create a container for the expression field and subview popup + expressionFrame = NSMakeRect(expressionFrame.size.height, + contentBounds.size.height - expressionFrame.size.height, + contentBounds.size.width - expressionFrame.size.height, + expressionFrame.size.height); + expressionContainer = [[NSView alloc] initWithFrame:expressionFrame]; + [expressionContainer setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; + [expressionContainer addSubview:expressionField]; + [expressionField release]; + [expressionContainer addSubview:subviewButton]; + [subviewButton release]; + [[window contentView] addSubview:expressionContainer]; + [expressionContainer release]; + + // create the disassembly view + dasmView = [[MAMEDisassemblyView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) + machine:*machine + useConsole:NO]; + [dasmView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0]; + dasmScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, + 0, + contentBounds.size.width, + expressionFrame.origin.y)]; + [dasmScroll setDrawsBackground:YES]; + [dasmScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [dasmScroll setHasHorizontalScroller:YES]; + [dasmScroll setHasVerticalScroller:YES]; + [dasmScroll setAutohidesScrollers:YES]; + [dasmScroll setBorderType:NSNoBorder]; + [dasmScroll setDocumentView:dasmView]; + [dasmView release]; + [[window contentView] addSubview:dasmScroll]; + [dasmScroll release]; + + // create the action popup + actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, + expressionFrame.origin.y, + expressionFrame.size.height, + expressionFrame.size.height)]; + [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; + [dasmView insertActionItemsInMenu:[actionButton menu] atIndex:1]; + [[window contentView] addSubview:actionButton]; + [actionButton release]; + + // set default state + [dasmView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)]; + [dasmView setExpression:@"curpc"]; + [expressionField setStringValue:@"curpc"]; + [expressionField selectText:self]; + [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[dasmView selectedSubviewIndex]]]; + [window makeFirstResponder:expressionField]; + [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; + + // calculate the optimal size for everything + { + NSSize desired = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[dasmScroll borderType]]; + [self cascadeWindowWithDesiredSize:desired forView:dasmScroll]; + } + + // don't forget the result + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + + +- (id )documentView { + return dasmView; +} + + +- (IBAction)changeSubview:(id)sender { + [dasmView selectSubviewAtIndex:[[sender selectedItem] tag]]; + [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; +} + +@end diff --git a/src/osd/modules/debugger/osx/errorlogview.h b/src/osd/modules/debugger/osx/errorlogview.h new file mode 100644 index 00000000000..168511c1819 --- /dev/null +++ b/src/osd/modules/debugger/osx/errorlogview.h @@ -0,0 +1,27 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxerrorlogview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugview.h" + +#include "emu.h" + +#import + + +@interface MAMEErrorLogView : MAMEDebugView +{ +} + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; + +@end diff --git a/src/osd/modules/debugger/osx/errorlogview.m b/src/osd/modules/debugger/osx/errorlogview.m new file mode 100644 index 00000000000..6ba563b071a --- /dev/null +++ b/src/osd/modules/debugger/osx/errorlogview.m @@ -0,0 +1,30 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxerrorlogview.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "errorlogview.h" + +#include "debug/debugvw.h" + + +@implementation MAMEErrorLogView + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { + if (!(self = [super initWithFrame:f type:DVT_LOG machine:m])) + return nil; + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + +@end diff --git a/src/osd/modules/debugger/osx/errorlogviewer.h b/src/osd/modules/debugger/osx/errorlogviewer.h new file mode 100644 index 00000000000..c2728298c14 --- /dev/null +++ b/src/osd/modules/debugger/osx/errorlogviewer.h @@ -0,0 +1,30 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxerrorlogviewer.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugwindowhandler.h" + +#include "emu.h" + +#import + + +@class MAMEDebugConsole, MAMEErrorLogView; + +@interface MAMEErrorLogViewer : MAMEAuxiliaryDebugWindowHandler +{ + MAMEErrorLogView *logView; +} + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; + +@end diff --git a/src/osd/modules/debugger/osx/errorlogviewer.m b/src/osd/modules/debugger/osx/errorlogviewer.m new file mode 100644 index 00000000000..44189922f91 --- /dev/null +++ b/src/osd/modules/debugger/osx/errorlogviewer.m @@ -0,0 +1,64 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxerrorlogviewer.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "errorlogviewer.h" + +#import "errorlogview.h" + + +@implementation MAMEErrorLogViewer + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { + NSScrollView *logScroll; + NSString *title; + + title = [NSString stringWithFormat:@"Error Log: %@ [%@]", + [NSString stringWithUTF8String:m.system().description], + [NSString stringWithUTF8String:m.system().name]]; + if (!(self = [super initWithMachine:m title:title console:c])) + return nil; + + // create the error log view + logView = [[MAMEErrorLogView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) machine:*machine]; + logScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [logScroll setDrawsBackground:YES]; + [logScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [logScroll setHasHorizontalScroller:YES]; + [logScroll setHasVerticalScroller:YES]; + [logScroll setAutohidesScrollers:YES]; + [logScroll setBorderType:NSNoBorder]; + [logScroll setDocumentView:logView]; + [logView release]; + [window setContentView:logScroll]; + [logScroll release]; + + // calculate the optimal size for everything + { + NSSize desired = [NSScrollView frameSizeForContentSize:[logView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[logScroll borderType]]; + + // this thing starts with no content, so its prefered height may be very small + desired.height = MAX(desired.height, 240); + [self cascadeWindowWithDesiredSize:desired forView:logScroll]; + } + + // don't forget the result + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + +@end diff --git a/src/osd/modules/debugger/osx/memoryview.h b/src/osd/modules/debugger/osx/memoryview.h new file mode 100644 index 00000000000..a0cb51ba7c1 --- /dev/null +++ b/src/osd/modules/debugger/osx/memoryview.h @@ -0,0 +1,46 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxmemoryview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugview.h" + +#include "emu.h" + +#import + + +@interface MAMEMemoryView : MAMEDebugView +{ +} + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; + +- (NSSize)maximumFrameSize; + +- (NSString *)selectedSubviewName; +- (int)selectedSubviewIndex; +- (void)selectSubviewAtIndex:(int)index; +- (void)selectSubviewForCPU:(device_t *)device; + +- (NSString *)expression; +- (void)setExpression:(NSString *)exp; + +- (IBAction)showChunkSize:(id)sender; +- (IBAction)showPhysicalAddresses:(id)sender; +- (IBAction)showReverseView:(id)sender; +- (IBAction)showReverseViewToggle:(id)sender; +- (IBAction)changeBytesPerLine:(id)sender; + +- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; +- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index; + +@end diff --git a/src/osd/modules/debugger/osx/memoryview.m b/src/osd/modules/debugger/osx/memoryview.m new file mode 100644 index 00000000000..b35701df757 --- /dev/null +++ b/src/osd/modules/debugger/osx/memoryview.m @@ -0,0 +1,226 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxmemoryview.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "memoryview.h" + +#include "debug/debugcpu.h" +#include "debug/debugvw.h" +#include "debug/dvmemory.h" + + +@implementation MAMEMemoryView + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { + NSMenu *contextMenu; + + if (!(self = [super initWithFrame:f type:DVT_MEMORY machine:m])) + return nil; + + contextMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Memory"]; + [self insertActionItemsInMenu:contextMenu atIndex:0]; + [self setMenu:contextMenu]; + [contextMenu release]; + + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + + +- (BOOL)validateMenuItem:(NSMenuItem *)item { + SEL action = [item action]; + NSInteger tag = [item tag]; + debug_view_memory *memview = downcast(view); + + if (action == @selector(showChunkSize:)) { + [item setState:((tag == memview->bytes_per_chunk()) ? NSOnState : NSOffState)]; + } else if (action == @selector(showPhysicalAddresses:)) { + [item setState:((tag == memview->physical()) ? NSOnState : NSOffState)]; + } else if (action == @selector(showReverseView:)) { + [item setState:((tag == memview->reverse()) ? NSOnState : NSOffState)]; + } else if (action == @selector(showReverseViewToggle:)) { + [item setState:(memview->reverse() ? NSOnState : NSOffState)]; + } + return YES; +} + + +- (NSSize)maximumFrameSize { + debug_view_xy max; + device_t *curcpu = debug_cpu_get_visible_cpu(*machine); + debug_view_source const *source = view->source_for_device(curcpu); + + max.x = max.y = 0; + for (const debug_view_source *source = view->source_list().first(); + source != NULL; + source = source->next()) + { + debug_view_xy current; + view->set_source(*source); + current = view->total_size(); + if (current.x > max.x) + max.x = current.x; + if (current.y > max.y) + max.y = current.y; + } + view->set_source(*source); + return NSMakeSize(max.x * fontWidth, max.y * fontHeight); +} + + +- (NSString *)selectedSubviewName { + debug_view_source const *source = view->source(); + if (source != NULL) + return [NSString stringWithUTF8String:source->name()]; + else + return @""; +} + + +- (int)selectedSubviewIndex { + debug_view_source const *source = view->source(); + if (source != NULL) + return view->source_list().indexof(*source); + else + return -1; +} + + +- (void)selectSubviewAtIndex:(int)index { + int const selected = view->source_list().indexof(*view->source()); + if (selected != index) { + view->set_source(*view->source_list().find(index)); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } +} + + +- (void)selectSubviewForCPU:(device_t *)device { + debug_view_source const *selected = view->source(); + debug_view_source const *source = view->source_for_device(device); + if ( selected != source ) { + view->set_source(*source); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } +} + + +- (NSString *)expression { + return [NSString stringWithUTF8String:downcast(view)->expression()]; +} + + +- (void)setExpression:(NSString *)exp { + downcast(view)->set_expression([exp UTF8String]); +} + + +- (IBAction)showChunkSize:(id)sender { + downcast(view)->set_bytes_per_chunk([sender tag]); +} + + +- (IBAction)showPhysicalAddresses:(id)sender { + downcast(view)->set_physical([sender tag]); +} + + +- (IBAction)showReverseView:(id)sender { + downcast(view)->set_reverse([sender tag]); +} + + +- (IBAction)showReverseViewToggle:(id)sender { + downcast(view)->set_reverse(!downcast(view)->reverse()); +} + + +- (IBAction)changeBytesPerLine:(id)sender { + debug_view_memory *const memView = downcast(view); + memView->set_chunks_per_row(memView->chunks_per_row() + [sender tag]); +} + + +- (void)insertActionItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { + NSInteger tag; + for (tag = 1; tag <= 8; tag <<= 1) { + NSString *title = [NSString stringWithFormat:@"%ld-byte Chunks", (long)tag]; + NSMenuItem *chunkItem = [menu insertItemWithTitle:title + action:@selector(showChunkSize:) + keyEquivalent:[NSString stringWithFormat:@"%ld", (long)tag] + atIndex:index++]; + [chunkItem setTarget:self]; + [chunkItem setTag:tag]; + } + + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; + + NSMenuItem *logicalItem = [menu insertItemWithTitle:@"Logical Addresses" + action:@selector(showPhysicalAddresses:) + keyEquivalent:@"v" + atIndex:index++]; + [logicalItem setTarget:self]; + [logicalItem setTag:FALSE]; + + NSMenuItem *physicalItem = [menu insertItemWithTitle:@"Physical Addresses" + action:@selector(showPhysicalAddresses:) + keyEquivalent:@"y" + atIndex:index++]; + [physicalItem setTarget:self]; + [physicalItem setTag:TRUE]; + + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; + + NSMenuItem *reverseItem = [menu insertItemWithTitle:@"Reverse View" + action:@selector(showReverseViewToggle:) + keyEquivalent:@"r" + atIndex:index++]; + [reverseItem setTarget:self]; + + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; + + NSMenuItem *increaseItem = [menu insertItemWithTitle:@"Increase Bytes Per Line" + action:@selector(changeBytesPerLine:) + keyEquivalent:@"p" + atIndex:index++]; + [increaseItem setTarget:self]; + [increaseItem setTag:1]; + + NSMenuItem *decreaseItem = [menu insertItemWithTitle:@"Decrease Bytes Per Line" + action:@selector(changeBytesPerLine:) + keyEquivalent:@"o" + atIndex:index++]; + [decreaseItem setTarget:self]; + [decreaseItem setTag:-1]; + + if (index < [menu numberOfItems]) + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; +} + + +- (void)insertSubviewItemsInMenu:(NSMenu *)menu atIndex:(NSInteger)index { + for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) + { + [[menu insertItemWithTitle:[NSString stringWithUTF8String:source->name()] + action:NULL + keyEquivalent:@"" + atIndex:index++] setTag:view->source_list().indexof(*source)]; + } + if (index < [menu numberOfItems]) + [menu insertItem:[NSMenuItem separatorItem] atIndex:index++]; +} + +@end diff --git a/src/osd/modules/debugger/osx/memoryviewer.h b/src/osd/modules/debugger/osx/memoryviewer.h new file mode 100644 index 00000000000..45db9c21051 --- /dev/null +++ b/src/osd/modules/debugger/osx/memoryviewer.h @@ -0,0 +1,32 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxmemoryviewer.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugwindowhandler.h" + +#include "emu.h" + +#import + + +@class MAMEDebugConsole, MAMEMemoryView; + +@interface MAMEMemoryViewer : MAMEExpressionAuxiliaryDebugWindowHandler +{ + MAMEMemoryView *memoryView; +} + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; + +- (IBAction)changeSubview:(id)sender; + +@end diff --git a/src/osd/modules/debugger/osx/memoryviewer.m b/src/osd/modules/debugger/osx/memoryviewer.m new file mode 100644 index 00000000000..044f0f442df --- /dev/null +++ b/src/osd/modules/debugger/osx/memoryviewer.m @@ -0,0 +1,135 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxmemoryviewer.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "memoryviewer.h" + +#import "debugview.h" +#import "memoryview.h" + +#include "debug/debugcpu.h" + + +@implementation MAMEMemoryViewer + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { + NSScrollView *memoryScroll; + NSView *expressionContainer; + NSPopUpButton *actionButton, *subviewButton; + NSRect contentBounds, expressionFrame; + + if (!(self = [super initWithMachine:m title:@"Memory" console:c])) + return nil; + contentBounds = [[window contentView] bounds]; + + // create the expression field + expressionField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; + [expressionField setAutoresizingMask:(NSViewWidthSizable | NSViewMaxXMargin | NSViewMinYMargin)]; + [expressionField setFont:[[MAMEDebugView class] defaultFont]]; + [expressionField setFocusRingType:NSFocusRingTypeNone]; + [expressionField setTarget:self]; + [expressionField setAction:@selector(doExpression:)]; + [expressionField setDelegate:self]; + expressionFrame = [expressionField frame]; + expressionFrame.size.width = (contentBounds.size.width - expressionFrame.size.height) / 2; + [expressionField setFrameSize:expressionFrame.size]; + + // create the subview popup + subviewButton = [[NSPopUpButton alloc] initWithFrame:NSOffsetRect(expressionFrame, + expressionFrame.size.width, + 0)]; + [subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinXMargin | NSViewMinYMargin)]; + [subviewButton setBezelStyle:NSShadowlessSquareBezelStyle]; + [subviewButton setFocusRingType:NSFocusRingTypeNone]; + [subviewButton setFont:[[MAMEDebugView class] defaultFont]]; + [subviewButton setTarget:self]; + [subviewButton setAction:@selector(changeSubview:)]; + [[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom]; + + // create a container for the expression field and subview popup + expressionFrame = NSMakeRect(expressionFrame.size.height, + contentBounds.size.height - expressionFrame.size.height, + contentBounds.size.width - expressionFrame.size.height, + expressionFrame.size.height); + expressionContainer = [[NSView alloc] initWithFrame:expressionFrame]; + [expressionContainer setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; + [expressionContainer addSubview:expressionField]; + [expressionField release]; + [expressionContainer addSubview:subviewButton]; + [subviewButton release]; + [[window contentView] addSubview:expressionContainer]; + [expressionContainer release]; + + // create the memory view + memoryView = [[MAMEMemoryView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) + machine:*machine]; + [memoryView insertSubviewItemsInMenu:[subviewButton menu] atIndex:0]; + memoryScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, + 0, + contentBounds.size.width, + expressionFrame.origin.y)]; + [memoryScroll setDrawsBackground:YES]; + [memoryScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [memoryScroll setHasHorizontalScroller:YES]; + [memoryScroll setHasVerticalScroller:YES]; + [memoryScroll setAutohidesScrollers:YES]; + [memoryScroll setBorderType:NSNoBorder]; + [memoryScroll setDocumentView:memoryView]; + [memoryView release]; + [[window contentView] addSubview:memoryScroll]; + [memoryScroll release]; + + // create the action popup + actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, + expressionFrame.origin.y, + expressionFrame.size.height, + expressionFrame.size.height)]; + [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; + [memoryView insertActionItemsInMenu:[actionButton menu] atIndex:1]; + [[window contentView] addSubview:actionButton]; + [actionButton release]; + + // set default state + [memoryView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)]; + [memoryView setExpression:@"0"]; + [expressionField setStringValue:@"0"]; + [expressionField selectText:self]; + [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[memoryView selectedSubviewIndex]]]; + [window makeFirstResponder:expressionField]; + [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]]; + + // calculate the optimal size for everything + NSSize const desired = [NSScrollView frameSizeForContentSize:[memoryView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[memoryScroll borderType]]; + [self cascadeWindowWithDesiredSize:desired forView:memoryScroll]; + + // don't forget the result + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + + +- (id )documentView { + return memoryView; +} + + +- (IBAction)changeSubview:(id)sender { + [memoryView selectSubviewAtIndex:[[sender selectedItem] tag]]; + [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]]; +} + +@end diff --git a/src/osd/modules/debugger/osx/pointsviewer.h b/src/osd/modules/debugger/osx/pointsviewer.h new file mode 100644 index 00000000000..5df282ef850 --- /dev/null +++ b/src/osd/modules/debugger/osx/pointsviewer.h @@ -0,0 +1,32 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxpointsviewer.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugwindowhandler.h" + +#include "emu.h" + +#import + + +@class MAMEDebugConsole; + +@interface MAMEPointsViewer : MAMEAuxiliaryDebugWindowHandler +{ + NSTabView *tabs; +} + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; + +- (IBAction)changeSubview:(id)sender; + +@end diff --git a/src/osd/modules/debugger/osx/pointsviewer.m b/src/osd/modules/debugger/osx/pointsviewer.m new file mode 100644 index 00000000000..27c8f36417e --- /dev/null +++ b/src/osd/modules/debugger/osx/pointsviewer.m @@ -0,0 +1,147 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxpointsviewer.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "pointsviewer.h" + +#import "breakpointsview.h" +#import "watchpointsview.h" + + +@implementation MAMEPointsViewer + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { + MAMEDebugView *breakView, *watchView; + NSScrollView *breakScroll, *watchScroll; + NSTabViewItem *breakTab, *watchTab; + NSPopUpButton *actionButton, *subviewButton; + NSRect contentBounds; + + if (!(self = [super initWithMachine:m title:@"(Break|Watch)points" console:c])) + return nil; + contentBounds = [[window contentView] bounds]; + + // create the subview popup + subviewButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(19, + contentBounds.size.height - 19, + contentBounds.size.width - 19, + 19)]; + [subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; + [subviewButton setBezelStyle:NSShadowlessSquareBezelStyle]; + [subviewButton setFocusRingType:NSFocusRingTypeNone]; + [subviewButton setFont:[[MAMEDebugView class] defaultFont]]; + [subviewButton setTarget:self]; + [subviewButton setAction:@selector(changeSubview:)]; + [[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom]; + [[[subviewButton menu] addItemWithTitle:@"All Breakpoints" + action:NULL + keyEquivalent:@""] setTag:0]; + [[[subviewButton menu] addItemWithTitle:@"All Watchpoints" + action:NULL + keyEquivalent:@""] setTag:1]; + [[window contentView] addSubview:subviewButton]; + [subviewButton release]; + + // create the action popup + actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0, + contentBounds.size.height - 19, + 19, + 19)]; + [actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; + [[window contentView] addSubview:actionButton]; + [actionButton release]; + + // create the breakpoints view + breakView = [[MAMEBreakpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) + machine:*machine]; + breakScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, + 0, + contentBounds.size.width, + contentBounds.size.height - 19)]; + [breakScroll setDrawsBackground:YES]; + [breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [breakScroll setHasHorizontalScroller:YES]; + [breakScroll setHasVerticalScroller:YES]; + [breakScroll setAutohidesScrollers:YES]; + [breakScroll setBorderType:NSNoBorder]; + [breakScroll setDocumentView:breakView]; + [breakView release]; + breakTab = [[NSTabViewItem alloc] initWithIdentifier:nil]; + [breakTab setView:breakScroll]; + [breakScroll release]; + + // create the breakpoints view + watchView = [[MAMEWatchpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) + machine:*machine]; + watchScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, + 0, + contentBounds.size.width, + contentBounds.size.height - 19)]; + [watchScroll setDrawsBackground:YES]; + [watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [watchScroll setHasHorizontalScroller:YES]; + [watchScroll setHasVerticalScroller:YES]; + [watchScroll setAutohidesScrollers:YES]; + [watchScroll setBorderType:NSNoBorder]; + [watchScroll setDocumentView:watchView]; + [watchView release]; + watchTab = [[NSTabViewItem alloc] initWithIdentifier:nil]; + [watchTab setView:watchScroll]; + [watchScroll release]; + + // create a tabless tabview for the two subviews + tabs = [[NSTabView alloc] initWithFrame:NSMakeRect(0, + 0, + contentBounds.size.width, + contentBounds.size.height - 19)]; + [tabs setTabViewType:NSNoTabsNoBorder]; + [tabs setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [tabs addTabViewItem:breakTab]; + [breakTab release]; + [tabs addTabViewItem:watchTab]; + [watchTab release]; + [[window contentView] addSubview:tabs]; + [tabs release]; + + // set default state + [subviewButton selectItemAtIndex:0]; + [tabs selectFirstTabViewItem:self]; + [window makeFirstResponder:subviewButton]; + [window setTitle:[[subviewButton selectedItem] title]]; + + // calculate the optimal size for everything + NSSize const breakDesired = [NSScrollView frameSizeForContentSize:[breakView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[breakScroll borderType]]; + NSSize const watchDesired = [NSScrollView frameSizeForContentSize:[watchView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[watchScroll borderType]]; + NSSize const desired = NSMakeSize(MAX(breakDesired.width, watchDesired.width), + MAX(breakDesired.height, watchDesired.height)); + [self cascadeWindowWithDesiredSize:desired forView:tabs]; + + // don't forget the result + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + + +- (IBAction)changeSubview:(id)sender { + [tabs selectTabViewItemAtIndex:[[sender selectedItem] tag]]; + [window setTitle:[[sender selectedItem] title]]; +} + +@end diff --git a/src/osd/modules/debugger/osx/registersview.h b/src/osd/modules/debugger/osx/registersview.h new file mode 100644 index 00000000000..5b1ab6a54e5 --- /dev/null +++ b/src/osd/modules/debugger/osx/registersview.h @@ -0,0 +1,34 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxregistersview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugview.h" + +#include "emu.h" + +#import + + +@interface MAMERegistersView : MAMEDebugView +{ +} + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; + +- (NSSize)maximumFrameSize; + +- (NSString *)selectedSubviewName; +- (int)selectedSubviewIndex; +- (void)selectSubviewAtIndex:(int)index; +- (void)selectSubviewForCPU:(device_t *)device; + +@end diff --git a/src/osd/modules/debugger/osx/registersview.m b/src/osd/modules/debugger/osx/registersview.m new file mode 100644 index 00000000000..ba2cf93cd09 --- /dev/null +++ b/src/osd/modules/debugger/osx/registersview.m @@ -0,0 +1,71 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxregistersview.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "registersview.h" + +#include "debug/debugcpu.h" +#include "debug/debugvw.h" + + +@implementation MAMERegistersView + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { + if (!(self = [super initWithFrame:f type:DVT_STATE machine:m])) + return nil; + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + + +- (NSSize)maximumFrameSize { + debug_view_xy max; + device_t *curcpu = debug_cpu_get_visible_cpu(*machine); + const debug_view_source *source = view->source_for_device(curcpu); + + max.x = max.y = 0; + for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) + { + debug_view_xy current; + view->set_source(*source); + current = view->total_size(); + if (current.x > max.x) + max.x = current.x; + if (current.y > max.y) + max.y = current.y; + } + view->set_source(*source); + return NSMakeSize(max.x * fontWidth, max.y * fontHeight); +} + + +- (NSString *)selectedSubviewName { + return @""; +} + + +- (int)selectedSubviewIndex { + return -1; +} + + +- (void)selectSubviewAtIndex:(int)index { +} + + +- (void)selectSubviewForCPU:(device_t *)device { + view->set_source(*view->source_for_device(device)); +} + +@end diff --git a/src/osd/modules/debugger/osx/watchpointsview.h b/src/osd/modules/debugger/osx/watchpointsview.h new file mode 100644 index 00000000000..23379de570c --- /dev/null +++ b/src/osd/modules/debugger/osx/watchpointsview.h @@ -0,0 +1,27 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxwatchpointsview.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugview.h" + +#include "emu.h" + +#import + + +@interface MAMEWatchpointsView : MAMEDebugView +{ +} + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; + +@end diff --git a/src/osd/modules/debugger/osx/watchpointsview.m b/src/osd/modules/debugger/osx/watchpointsview.m new file mode 100644 index 00000000000..34dc5858a48 --- /dev/null +++ b/src/osd/modules/debugger/osx/watchpointsview.m @@ -0,0 +1,30 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// debugosxwatchpointsview.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "watchpointsview.h" + +#include "debug/debugvw.h" + + +@implementation MAMEWatchpointsView + +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m { + if (!(self = [super initWithFrame:f type:DVT_WATCH_POINTS machine:m])) + return nil; + return self; +} + + +- (void)dealloc { + [super dealloc]; +} + +@end diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 41e945b728d..423e4422954 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -289,21 +289,21 @@ OBJDIRS += $(OSDOBJ)/modules/debugger/osx DEBUGOBJS = \ $(OSDOBJ)/modules/debugger/debugosx.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxbreakpointsview.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxconsoleview.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxdebugcommandhistory.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxdebugconsole.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxdebugview.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxdebugwindowhandler.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxdisassemblyview.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxdisassemblyviewer.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxerrorlogview.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxerrorlogviewer.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxmemoryview.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxmemoryviewer.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxpointsviewer.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxregistersview.o \ - $(OSDOBJ)/modules/debugger/osx/debugosxwatchpointsview.o + $(OSDOBJ)/modules/debugger/osx/breakpointsview.o \ + $(OSDOBJ)/modules/debugger/osx/consoleview.o \ + $(OSDOBJ)/modules/debugger/osx/debugcommandhistory.o \ + $(OSDOBJ)/modules/debugger/osx/debugconsole.o \ + $(OSDOBJ)/modules/debugger/osx/debugview.o \ + $(OSDOBJ)/modules/debugger/osx/debugwindowhandler.o \ + $(OSDOBJ)/modules/debugger/osx/disassemblyview.o \ + $(OSDOBJ)/modules/debugger/osx/disassemblyviewer.o \ + $(OSDOBJ)/modules/debugger/osx/errorlogview.o \ + $(OSDOBJ)/modules/debugger/osx/errorlogviewer.o \ + $(OSDOBJ)/modules/debugger/osx/memoryview.o \ + $(OSDOBJ)/modules/debugger/osx/memoryviewer.o \ + $(OSDOBJ)/modules/debugger/osx/pointsviewer.o \ + $(OSDOBJ)/modules/debugger/osx/registersview.o \ + $(OSDOBJ)/modules/debugger/osx/watchpointsview.o endif -- cgit v1.2.3 From e05a076b9426eb098428b14f5acc0ec3c8a5cd91 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 17 Feb 2015 02:07:33 +1100 Subject: * Map visited to a background colour * Allocate colours once only * Make disassembly view context menu easier to use again * Console feedback for breakpoint changes * Update views for breakpoint changes * Map Option-/Command-click to middle/right click * Disassembly/memory views inherit focus from parent window --- src/osd/modules/debugger/debugosx.m | 6 +- src/osd/modules/debugger/osx/debugconsole.h | 3 + src/osd/modules/debugger/osx/debugconsole.m | 136 +++++++----- src/osd/modules/debugger/osx/debugview.h | 2 +- src/osd/modules/debugger/osx/debugview.m | 251 +++++++++++++--------- src/osd/modules/debugger/osx/debugwindowhandler.h | 3 + src/osd/modules/debugger/osx/debugwindowhandler.m | 23 +- src/osd/modules/debugger/osx/disassemblyview.h | 6 +- src/osd/modules/debugger/osx/disassemblyview.m | 108 ++++++++-- src/osd/modules/debugger/osx/disassemblyviewer.h | 4 + src/osd/modules/debugger/osx/disassemblyviewer.m | 37 +++- src/osd/modules/debugger/osx/memoryview.h | 6 +- src/osd/modules/debugger/osx/memoryview.m | 50 ++++- src/osd/modules/debugger/osx/memoryviewer.h | 4 + src/osd/modules/debugger/osx/memoryviewer.m | 38 +++- src/osd/modules/debugger/osx/registersview.h | 2 +- src/osd/modules/debugger/osx/registersview.m | 2 +- 17 files changed, 483 insertions(+), 198 deletions(-) diff --git a/src/osd/modules/debugger/debugosx.m b/src/osd/modules/debugger/debugosx.m index 7e713fc2e60..460a666a5fb 100644 --- a/src/osd/modules/debugger/debugosx.m +++ b/src/osd/modules/debugger/debugosx.m @@ -12,11 +12,11 @@ // TODO: // * Automatic scrolling for console and log views -// * Using alpha for disabled foreground colours doesn't really work -// * New windows created from auxiliary windows should inherit focus rather than pointing at current CPU // * Keyboard shortcuts in error log windows // * Don't accept keyboard input while the game is running // * Interior focus rings - standard/exterior focus rings look really ugly here +// * Improve automatic window sizing - it isn't working all that well +// * Updates causing debug views' widths to change are sometimes obscured by the scroll views' opaque backgrounds // * Scroll views with content narrower than clipping area are flaky under Tiger - nothing I can do about this @@ -97,6 +97,8 @@ void debugger_osx::wait_for_debugger(device_t &device, bool firststop) if (firststop) { NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:[NSValue valueWithPointer:&device], @"MAMEDebugDevice", + [NSValue valueWithPointer:m_machine], + @"MAMEDebugMachine", nil]; [[NSNotificationCenter defaultCenter] postNotificationName:MAMEShowDebuggerNotification object:m_console diff --git a/src/osd/modules/debugger/osx/debugconsole.h b/src/osd/modules/debugger/osx/debugconsole.h index 862c035cbb4..24ed021fcb4 100644 --- a/src/osd/modules/debugger/osx/debugconsole.h +++ b/src/osd/modules/debugger/osx/debugconsole.h @@ -42,6 +42,9 @@ - (IBAction)debugNewErrorLogWindow:(id)sender; - (IBAction)debugNewPointsWindow:(id)sender; +- (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression; +- (void)debugNewDisassemblyWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression; + - (void)showDebugger:(NSNotification *)notification; - (void)auxiliaryWindowWillClose:(NSNotification *)notification; diff --git a/src/osd/modules/debugger/osx/debugconsole.m b/src/osd/modules/debugger/osx/debugconsole.m index d3aec2bb88a..3df65689e4f 100644 --- a/src/osd/modules/debugger/osx/debugconsole.m +++ b/src/osd/modules/debugger/osx/debugconsole.m @@ -135,50 +135,47 @@ [window makeFirstResponder:commandField]; // calculate the optimal size for everything - { - NSRect available = [[NSScreen mainScreen] visibleFrame]; - NSRect windowFrame = [window frame]; - NSSize regCurrent = [regScroll frame].size; - NSSize regSize = [NSScrollView frameSizeForContentSize:[regView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[regScroll borderType]]; - NSSize dasmCurrent = [dasmScroll frame].size; - NSSize dasmSize = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] + NSRect available = [[NSScreen mainScreen] visibleFrame]; + NSRect windowFrame = [window frame]; + NSSize regCurrent = [regScroll frame].size; + NSSize regSize = [NSScrollView frameSizeForContentSize:[regView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[regScroll borderType]]; + NSSize dasmCurrent = [dasmScroll frame].size; + NSSize dasmSize = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[dasmScroll borderType]]; + NSSize consoleCurrent = [consoleContainer frame].size; + NSSize consoleSize = [NSScrollView frameSizeForContentSize:[consoleView maximumFrameSize] hasHorizontalScroller:YES hasVerticalScroller:YES - borderType:[dasmScroll borderType]]; - NSSize consoleCurrent = [consoleContainer frame].size; - NSSize consoleSize = [NSScrollView frameSizeForContentSize:[consoleView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[consoleScroll borderType]]; - NSSize adjustment; - NSRect lhsFrame, rhsFrame; - - consoleSize.width += consoleCurrent.width - [consoleScroll frame].size.width; - consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height; - adjustment.width = regSize.width - regCurrent.width; - adjustment.height = regSize.height - regCurrent.height; - adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width); - - windowFrame.size.width += adjustment.width; - windowFrame.size.height += adjustment.height; // not used - better to go for fixed height - windowFrame.size.height = MIN(512.0, available.size.height); - windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); - windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; - windowFrame.origin.y = available.origin.y; - [window setFrame:windowFrame display:YES]; - - lhsFrame = [regScroll frame]; - rhsFrame = [dasmSplit frame]; - adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2); - rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width; - rhsFrame.size.width += lhsFrame.size.width - adjustment.width; - lhsFrame.size.width = adjustment.width; - [regScroll setFrame:lhsFrame]; - [dasmSplit setFrame:rhsFrame]; - } + borderType:[consoleScroll borderType]]; + NSSize adjustment; + + consoleSize.width += consoleCurrent.width - [consoleScroll frame].size.width; + consoleSize.height += consoleCurrent.height - [consoleScroll frame].size.height; + adjustment.width = regSize.width - regCurrent.width; + adjustment.height = regSize.height - regCurrent.height; + adjustment.width += MAX(dasmSize.width - dasmCurrent.width, consoleSize.width - consoleCurrent.width); + + windowFrame.size.width += adjustment.width; + windowFrame.size.height += adjustment.height; // not used - better to go for fixed height + windowFrame.size.height = MIN(512.0, available.size.height); + windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); + windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; + windowFrame.origin.y = available.origin.y; + [window setFrame:windowFrame display:YES]; + + NSRect lhsFrame = [regScroll frame]; + NSRect rhsFrame = [dasmSplit frame]; + adjustment.width = MIN(regSize.width, ([regSplit frame].size.width - [regSplit dividerThickness]) / 2); + rhsFrame.origin.x -= lhsFrame.size.width - adjustment.width; + rhsFrame.size.width += lhsFrame.size.width - adjustment.width; + lhsFrame.size.width = adjustment.width; + [regScroll setFrame:lhsFrame]; + [dasmSplit setFrame:rhsFrame]; // select the current processor [self setCPU:machine->firstcpu]; @@ -206,8 +203,8 @@ - (void)setCPU:(device_t *)device { - [regView selectSubviewForCPU:device]; - [dasmView selectSubviewForCPU:device]; + [regView selectSubviewForDevice:device]; + [dasmView selectSubviewForDevice:device]; [window setTitle:[NSString stringWithFormat:@"Debug: %s - %s '%s'", device->machine().system().name, device->name(), @@ -261,9 +258,44 @@ } +- (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression { + MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + if ([win selectSubviewForSpace:space]) + { + if (expression != nil) + [win setExpression:expression]; + } + else + { + [win selectSubviewForDevice:device]; + } + [win activate]; +} + + +- (void)debugNewDisassemblyWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression { + MAMEDisassemblyViewer *win = [[MAMEDisassemblyViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + if ([win selectSubviewForSpace:space]) + { + if (expression != nil) + [win setExpression:expression]; + } + else + { + [win selectSubviewForDevice:device]; + } + [win activate]; +} + + - (void)showDebugger:(NSNotification *)notification { device_t *device = (device_t * )[[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue]; - if (&device->machine() == machine) { + if (&device->machine() == machine) + { [self setCPU:device]; [window makeKeyAndOrderFront:self]; } @@ -312,10 +344,16 @@ - (void)windowWillClose:(NSNotification *)notification { - if ([notification object] != window) - return; - [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification object:self]; - debug_cpu_get_visible_cpu(*machine)->debug()->go(); + if ([notification object] == window) + { + NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:[NSValue valueWithPointer:machine], + @"MAMEDebugMachine", + nil]; + [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification + object:self + userInfo:info]; + debug_cpu_get_visible_cpu(*machine)->debug()->go(); + } } diff --git a/src/osd/modules/debugger/osx/debugview.h b/src/osd/modules/debugger/osx/debugview.h index 06c25ea7c21..56afd03351b 100644 --- a/src/osd/modules/debugger/osx/debugview.h +++ b/src/osd/modules/debugger/osx/debugview.h @@ -55,7 +55,7 @@ - (NSString *)selectedSubviewName; - (int)selectedSubviewIndex; - (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; +- (BOOL)selectSubviewForDevice:(device_t *)device; @end diff --git a/src/osd/modules/debugger/osx/debugview.m b/src/osd/modules/debugger/osx/debugview.m index c70801c3f75..2167e4321be 100644 --- a/src/osd/modules/debugger/osx/debugview.m +++ b/src/osd/modules/debugger/osx/debugview.m @@ -14,6 +14,24 @@ #include "debug/debugcpu.h" +static NSColor *DefaultForeground; +static NSColor *ChangedForeground; +static NSColor *InvalidForeground; +static NSColor *CommentForeground; +static NSColor *DisabledChangedForeground; +static NSColor *DisabledInvalidForeground; +static NSColor *DisabledCommentForeground; + +static NSColor *DefaultBackground; +static NSColor *VisitedBackground; +static NSColor *AncillaryBackground; +static NSColor *SelectedBackground; +static NSColor *CurrentBackground; +static NSColor *SelectedCurrentBackground; +static NSColor *InactiveSelectedBackground; +static NSColor *InactiveSelectedCurrentBackground; + + static void debugwin_view_update(debug_view &view, void *osdprivate) { [(MAMEDebugView *)osdprivate update]; @@ -22,37 +40,52 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) @implementation MAMEDebugView ++ (void)initialize { + DefaultForeground = [[NSColor colorWithCalibratedWhite:0.0 alpha:1.0] retain]; + ChangedForeground = [[NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:1.0] retain]; + InvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:1.0] retain]; + CommentForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.375 blue:0.0 alpha:1.0] retain]; + DisabledChangedForeground = [[NSColor colorWithCalibratedRed:0.5 green:0.125 blue:0.125 alpha:1.0] retain]; + DisabledInvalidForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.5 alpha:1.0] retain]; + DisabledCommentForeground = [[NSColor colorWithCalibratedRed:0.0 green:0.25 blue:0.0 alpha:1.0] retain]; + + DefaultBackground = [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] retain]; + VisitedBackground = [[NSColor colorWithCalibratedRed:0.75 green:1.0 blue:0.75 alpha:1.0] retain]; + AncillaryBackground = [[NSColor colorWithCalibratedWhite:0.75 alpha:1.0] retain]; + SelectedBackground = [[NSColor colorWithCalibratedRed:0.75 green:0.875 blue:1.0 alpha:1.0] retain]; + CurrentBackground = [[NSColor colorWithCalibratedRed:1.0 green:0.75 blue:0.75 alpha:1.0] retain]; + SelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0] retain]; + InactiveSelectedBackground = [[NSColor colorWithCalibratedWhite:0.875 alpha:1.0] retain]; + InactiveSelectedCurrentBackground = [[NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0] retain]; +} + + - (NSColor *)foregroundForAttribute:(UINT8)attrib { - const CGFloat alpha = (attrib & DCA_DISABLED) ? 0.5 : 1.0; if (attrib & DCA_COMMENT) - return [NSColor colorWithCalibratedRed:0.0 green:0.375 blue:0.0 alpha:1.0]; + return (attrib & DCA_DISABLED) ? DisabledCommentForeground : CommentForeground; else if (attrib & DCA_INVALID) - return [NSColor colorWithCalibratedRed:0.0 green:0.0 blue:1.0 alpha:alpha]; + return (attrib & DCA_DISABLED) ? DisabledInvalidForeground : InvalidForeground; else if (attrib & DCA_CHANGED) - return [NSColor colorWithCalibratedRed:0.875 green:0.0 blue:0.0 alpha:alpha]; + return (attrib & DCA_DISABLED) ? DisabledChangedForeground : ChangedForeground; else - return [NSColor colorWithCalibratedWhite:0.0 alpha:alpha]; + return DefaultForeground; } - (NSColor *)backgroundForAttribute:(UINT8)attrib { - if ((attrib & DCA_SELECTED) && (attrib & DCA_CURRENT)) { - if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self)) - return [NSColor colorWithCalibratedRed:0.875 green:0.625 blue:0.875 alpha:1.0]; - else - return [NSColor colorWithCalibratedRed:0.875 green:0.5 blue:0.625 alpha:1.0]; - } else if (attrib & DCA_CURRENT) { - return [NSColor colorWithCalibratedRed:1.0 green:0.625 blue:0.625 alpha:1.0]; - } else if (attrib & DCA_SELECTED) { - if ([[self window] isKeyWindow] && ([[self window] firstResponder] == self)) - return [NSColor colorWithCalibratedRed:0.75 green:0.875 blue:1.0 alpha:1.0]; - else - return [NSColor colorWithCalibratedWhite:0.875 alpha:1.0]; - } else if (attrib & DCA_ANCILLARY) { - return [NSColor colorWithCalibratedWhite:0.75 alpha:1.0]; - } else { - return [NSColor colorWithCalibratedWhite:1.0 alpha:1.0]; - } + BOOL const active = [[self window] isKeyWindow] && ([[self window] firstResponder] == self); + if ((attrib & DCA_SELECTED) && (attrib & DCA_CURRENT)) + return active ? SelectedCurrentBackground : InactiveSelectedCurrentBackground; + else if (attrib & DCA_CURRENT) + return CurrentBackground; + else if (attrib & DCA_SELECTED) + return active ? SelectedBackground : InactiveSelectedBackground; + else if (attrib & DCA_ANCILLARY) + return AncillaryBackground; + else if (attrib & DCA_VISITED) + return VisitedBackground; + else + return DefaultBackground; } @@ -71,7 +104,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) if (!data || (position.y < origin.y) || (position.y >= origin.y + size.y)) { // y coordinate outside visible area, x will be a guess - position.x = lround(floor(location.x / fontWidth)); + position.x = lround(floor((location.x - [textContainer lineFragmentPadding]) / fontWidth)); } else { @@ -121,26 +154,18 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) } -- (void)convertBounds:(NSRect)b toPosition:(debug_view_xy *)origin size:(debug_view_xy *)size { - origin->x = lround(floor(b.origin.x / fontWidth)); - origin->y = lround(floor(b.origin.y / fontHeight)); - - // FIXME: this is not using proper font metrics horizontally - size->x = lround(ceil((b.origin.x + b.size.width) / fontWidth)) - origin->x; - size->y = lround(ceil((b.origin.y + b.size.height) / fontHeight)) - origin->y; +- (void)convertBounds:(NSRect)b toFirstAffectedLine:(INT32 *)f count:(INT32 *)c { + *f = lround(floor(b.origin.y / fontHeight)); + *c = lround(ceil((b.origin.y + b.size.height) / fontHeight)) - *f; } - (void)recomputeVisible { - if ([self window] != nil) { - debug_view_xy origin, size; - - // this gets all the characters that are at least paritally visible - [self convertBounds:[self visibleRect] toPosition:&origin size:&size]; - - // need to render entire lines or we get screwed up characters when widening views - origin.x = 0; - size.x = totalWidth; + if ([self window] != nil) + { + // this gets all the lines that are at least partially visible + debug_view_xy origin(0, 0), size(totalWidth, totalHeight); + [self convertBounds:[self visibleRect] toFirstAffectedLine:&origin.y count:&size.y]; // tell them what we think view->set_visible_size(size); @@ -152,17 +177,18 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)typeCharacterAndScrollToCursor:(char)ch { - if (view->cursor_supported()) { - debug_view_xy oldPos = view->cursor_position(); + if (view->cursor_supported()) + { + debug_view_xy const oldPos = view->cursor_position(); view->process_char(ch); + debug_view_xy const newPos = view->cursor_position(); + if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) { - debug_view_xy newPos = view->cursor_position(); - if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) { - [self scrollRectToVisible:NSMakeRect(newPos.x * fontWidth, // FIXME - use proper metrics - newPos.y * fontHeight, - fontWidth, - fontHeight)]; - } + // FIXME - use proper font metrics + [self scrollRectToVisible:NSMakeRect((newPos.x * fontWidth) + [textContainer lineFragmentPadding], + newPos.y * fontHeight, + fontWidth, + fontHeight)]; } } else { view->process_char(ch); @@ -211,19 +237,21 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)update { - debug_view_xy newSize, newOrigin; - // resize our frame if the total size has changed - newSize = view->total_size(); - if ((newSize.x != totalWidth) || (newSize.y != totalHeight)) { - [self setFrameSize:NSMakeSize(fontWidth * newSize.x, fontHeight * newSize.y)]; // FIXME: metrics + debug_view_xy const newSize = view->total_size(); + BOOL const resized = (newSize.x != totalWidth) || (newSize.y != totalHeight); + if (resized) + { + [self setFrameSize:NSMakeSize((fontWidth * newSize.x) + (2 * [textContainer lineFragmentPadding]), + fontHeight * newSize.y)]; totalWidth = newSize.x; totalHeight = newSize.y; } // scroll the view if we're being told to - newOrigin = view->visible_position(); - if (newOrigin.y != originTop) { + debug_view_xy const newOrigin = view->visible_position(); + if (newOrigin.y != originTop) + { [self scrollPoint:NSMakePoint([self visibleRect].origin.x, newOrigin.y * fontHeight)]; originTop = newOrigin.y; } @@ -235,8 +263,9 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (NSSize)maximumFrameSize { - debug_view_xy max = view->total_size(); - return NSMakeSize(max.x * fontWidth, max.y * fontHeight); + debug_view_xy const max = view->total_size(); + return NSMakeSize((max.x * fontWidth) + (2 * [textContainer lineFragmentPadding]), + max.y * fontHeight); } @@ -281,7 +310,7 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) debug_view_xy pos; view->set_cursor_visible(true); pos = view->cursor_position(); - [self scrollRectToVisible:NSMakeRect(pos.x * fontWidth, pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics + [self scrollRectToVisible:NSMakeRect((pos.x * fontWidth) + [textContainer lineFragmentPadding], pos.y * fontHeight, fontWidth, fontHeight)]; // FIXME: metrics [self setNeedsDisplay:YES]; return [super becomeFirstResponder]; } else { @@ -326,21 +355,21 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)drawRect:(NSRect)dirtyRect { - debug_view_xy position, clip; + INT32 position, clip; // work out how much we need to draw [self recomputeVisible]; debug_view_xy const origin = view->visible_position(); debug_view_xy const size = view->visible_size(); - [self convertBounds:dirtyRect toPosition:&position size:&clip]; + [self convertBounds:dirtyRect toFirstAffectedLine:&position count:&clip]; // this gets the text for the whole visible area debug_view_char const *data = view->viewdata(); if (!data) return; - data += ((position.y - origin.y) * size.x); - for (UINT32 row = position.y; row < position.y + clip.y; row++, data += size.x) + data += ((position - origin.y) * size.x); + for (UINT32 row = position; row < position + clip; row++, data += size.x) { if ((row < origin.y) || (row >= origin.y + size.y)) continue; @@ -402,15 +431,23 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) - (void)mouseDown:(NSEvent *)event { NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; - view->process_click(DCK_LEFT_CLICK, [self convertLocation:location]); + NSUInteger const modifiers = [event modifierFlags]; + view->process_click((modifiers & NSCommandKeyMask) ? DCK_RIGHT_CLICK + : (modifiers & NSAlternateKeyMask) ? DCK_MIDDLE_CLICK + : DCK_LEFT_CLICK, + [self convertLocation:location]); [self setNeedsDisplay:YES]; } - (void)rightMouseDown:(NSEvent *)event { NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil]; - view->process_click(DCK_RIGHT_CLICK, [self convertLocation:location]); - [self setNeedsDisplay:YES]; + if (view->cursor_supported()) + { + view->set_cursor_position([self convertLocation:location]); + view->set_cursor_visible(true); + [self setNeedsDisplay:YES]; + } [super rightMouseDown:event]; } @@ -419,50 +456,58 @@ static void debugwin_view_update(debug_view &view, void *osdprivate) NSUInteger modifiers = [event modifierFlags]; NSString *str = [event charactersIgnoringModifiers]; - if ([str length] == 1) { - if (modifiers & NSNumericPadKeyMask) { - switch ([str characterAtIndex:0]) { - case NSUpArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - view->process_char(DCH_CTRLHOME); - else - view->process_char(DCH_UP); - return; - case NSDownArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - view->process_char(DCH_CTRLEND); - else - view->process_char(DCH_DOWN); - return; - case NSLeftArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - [self typeCharacterAndScrollToCursor:DCH_HOME]; - else if (modifiers & NSAlternateKeyMask) - [self typeCharacterAndScrollToCursor:DCH_CTRLLEFT]; - else - [self typeCharacterAndScrollToCursor:DCH_LEFT]; - return; - case NSRightArrowFunctionKey: - if (modifiers & NSCommandKeyMask) - [self typeCharacterAndScrollToCursor:DCH_END]; - else if (modifiers & NSAlternateKeyMask) - [self typeCharacterAndScrollToCursor:DCH_CTRLRIGHT]; - else - [self typeCharacterAndScrollToCursor:DCH_RIGHT]; - return; - default: - [self interpretKeyEvents:[NSArray arrayWithObject:event]]; - return; + if ([str length] == 1) + { + if (modifiers & NSNumericPadKeyMask) + { + switch ([str characterAtIndex:0]) + { + case NSUpArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + view->process_char(DCH_CTRLHOME); + else + view->process_char(DCH_UP); + return; + case NSDownArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + view->process_char(DCH_CTRLEND); + else + view->process_char(DCH_DOWN); + return; + case NSLeftArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + [self typeCharacterAndScrollToCursor:DCH_HOME]; + else if (modifiers & NSAlternateKeyMask) + [self typeCharacterAndScrollToCursor:DCH_CTRLLEFT]; + else + [self typeCharacterAndScrollToCursor:DCH_LEFT]; + return; + case NSRightArrowFunctionKey: + if (modifiers & NSCommandKeyMask) + [self typeCharacterAndScrollToCursor:DCH_END]; + else if (modifiers & NSAlternateKeyMask) + [self typeCharacterAndScrollToCursor:DCH_CTRLRIGHT]; + else + [self typeCharacterAndScrollToCursor:DCH_RIGHT]; + return; + default: + [self interpretKeyEvents:[NSArray arrayWithObject:event]]; + return; } - } else if (modifiers & NSFunctionKeyMask) { - switch ([str characterAtIndex:0]) { + } + else if (modifiers & NSFunctionKeyMask) + { + switch ([str characterAtIndex:0]) + { case NSPageUpFunctionKey: - if (modifiers & NSAlternateKeyMask) { + if (modifiers & NSAlternateKeyMask) + { view->process_char(DCH_PUP); return; } case NSPageDownFunctionKey: - if (modifiers & NSAlternateKeyMask) { + if (modifiers & NSAlternateKeyMask) + { view->process_char(DCH_PDOWN); return; } diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.h b/src/osd/modules/debugger/osx/debugwindowhandler.h index ba0f75fadad..4c157d825f8 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.h +++ b/src/osd/modules/debugger/osx/debugwindowhandler.h @@ -90,6 +90,9 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification; - (id )documentView; +- (NSString *)expression; +- (void)setExpression:(NSString *)expression; + - (IBAction)doExpression:(id)sender; - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor; diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.m b/src/osd/modules/debugger/osx/debugwindowhandler.m index 3b4ed3eb590..d26ca25979b 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.m +++ b/src/osd/modules/debugger/osx/debugwindowhandler.m @@ -231,8 +231,9 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD - (void)showDebugger:(NSNotification *)notification { - device_t *device = (device_t *) [[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue]; - if (&device->machine() == machine) { + running_machine *m = (running_machine *)[[[notification userInfo] objectForKey:@"MAMEDebugMachine"] pointerValue]; + if (m == machine) + { if (![window isVisible] && ![window isMiniaturized]) [window orderFront:self]; } @@ -240,7 +241,9 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD - (void)hideDebugger:(NSNotification *)notification { - [window orderOut:self]; + running_machine *m = (running_machine *)[[[notification userInfo] objectForKey:@"MAMEDebugMachine"] pointerValue]; + if (m == machine) + [window orderOut:self]; } @end @@ -309,9 +312,9 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD desired.height -= current.height; windowFrame.size.width += desired.width; + windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); windowFrame.size.height += desired.height; windowFrame.size.height = MIN(MIN(windowFrame.size.height, 240), available.size.height); - windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; windowFrame.origin.y = available.origin.y; [window setFrame:windowFrame display:YES]; @@ -352,6 +355,18 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD } +- (NSString *)expression { + return [[self documentView] expression]; +} + +- (void)setExpression:(NSString *)expression { + [history add:expression]; + [[self documentView] setExpression:expression]; + [expressionField setStringValue:expression]; + [expressionField selectText:self]; +} + + - (IBAction)doExpression:(id)sender { NSString *expr = [sender stringValue]; if ([expr length] > 0) { diff --git a/src/osd/modules/debugger/osx/disassemblyview.h b/src/osd/modules/debugger/osx/disassemblyview.h index 6c261dcaa60..534f6f7fb40 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.h +++ b/src/osd/modules/debugger/osx/disassemblyview.h @@ -14,6 +14,7 @@ #import "debugview.h" #include "emu.h" +#include "debug/dvdisasm.h" #import @@ -30,11 +31,14 @@ - (NSString *)selectedSubviewName; - (int)selectedSubviewIndex; - (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; +- (BOOL)selectSubviewForDevice:(device_t *)device; +- (BOOL)selectSubviewForSpace:(address_space *)space; - (NSString *)expression; - (void)setExpression:(NSString *)exp; +- (debug_view_disasm_source const *)source; + - (IBAction)debugToggleBreakpoint:(id)sender; - (IBAction)debugToggleBreakpointEnable:(id)sender; - (IBAction)debugRunToCursor:(id)sender; diff --git a/src/osd/modules/debugger/osx/disassemblyview.m b/src/osd/modules/debugger/osx/disassemblyview.m index 2592aeefdfc..16f70404c41 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.m +++ b/src/osd/modules/debugger/osx/disassemblyview.m @@ -11,10 +11,10 @@ #import "disassemblyview.h" +#include "debugger.h" #include "debug/debugcon.h" #include "debug/debugcpu.h" #include "debug/debugvw.h" -#include "debug/dvdisasm.h" @implementation MAMEDisassemblyView @@ -199,13 +199,43 @@ } -- (void)selectSubviewForCPU:(device_t *)device { - const debug_view_source *selected = view->source(); - const debug_view_source *source = view->source_for_device(device); - if ( selected != source ) { - view->set_source(*source); - if ([[self window] firstResponder] != self) - view->set_cursor_visible(false); +- (BOOL)selectSubviewForDevice:(device_t *)device { + debug_view_source const *const source = view->source_for_device(device); + if (source != NULL) + { + if (view->source() != source) + { + view->set_source(*source); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } + return YES; + } + else + { + return NO; + } +} + + +- (BOOL)selectSubviewForSpace:(address_space *)space { + if (space == NULL) return NO; + debug_view_disasm_source const *source = downcast(view->first_source()); + while ((source != NULL) && (&source->space() != space)) + source = downcast(source->next()); + if (source != NULL) + { + if (view->source() != source) + { + view->set_source(*source); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } + return YES; + } + else + { + return NO; } } @@ -220,50 +250,82 @@ } +- (debug_view_disasm_source const *)source { + return downcast(view->source()); +} + + - (IBAction)debugToggleBreakpoint:(id)sender { - if (view->cursor_visible()) { + if (view->cursor_visible()) + { address_space &space = downcast(view->source())->space(); - if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) { - offs_t address = downcast(view)->selected_address(); + if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) + { + offs_t const address = downcast(view)->selected_address(); device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; // if it doesn't exist, add a new one - if (useConsole) { + if (useConsole) + { NSString *command; if (bp == NULL) command = [NSString stringWithFormat:@"bpset %lX", (unsigned long)address]; else command = [NSString stringWithFormat:@"bpclear %X", (unsigned)bp->index()]; debug_console_execute_command(*machine, [command UTF8String], 1); - } else { + } + else + { if (bp == NULL) - space.device().debug()->breakpoint_set(address, NULL, NULL); + { + UINT32 const bpnum = space.device().debug()->breakpoint_set(address, NULL, NULL); + debug_console_printf(*machine, "Breakpoint %X set\n", bpnum); + } else - space.device().debug()->breakpoint_clear(bp->index()); + { + int const bpnum = bp->index(); + space.device().debug()->breakpoint_clear(bpnum); + debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum); + } } + + // fail to do this and the display doesn't update + machine->debug_view().update_all(); + debugger_refresh_display(*machine); } } } - (IBAction)debugToggleBreakpointEnable:(id)sender { - if (view->cursor_visible()) { + if (view->cursor_visible()) + { address_space &space = downcast(view->source())->space(); - if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) { - offs_t address = downcast(view)->selected_address(); + if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) + { + offs_t const address = downcast(view)->selected_address(); device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; - - if (bp != NULL) { - NSString *command; - if (useConsole) { + if (bp != NULL) + { + if (useConsole) + { + NSString *command; if (bp->enabled()) command = [NSString stringWithFormat:@"bpdisable %X", (unsigned)bp->index()]; else command = [NSString stringWithFormat:@"bpenable %X", (unsigned)bp->index()]; debug_console_execute_command(*machine, [command UTF8String], 1); - } else { + } + else + { space.device().debug()->breakpoint_enable(bp->index(), !bp->enabled()); + debug_console_printf(*machine, + "Breakpoint %X %s\n", + (UINT32)bp->index(), + bp->enabled() ? "enabled" : "disabled"); } + machine->debug_view().update_all(); + debugger_refresh_display(*machine); } } } diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.h b/src/osd/modules/debugger/osx/disassemblyviewer.h index fc2598249aa..6027d3c13da 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.h +++ b/src/osd/modules/debugger/osx/disassemblyviewer.h @@ -23,10 +23,14 @@ @interface MAMEDisassemblyViewer : MAMEExpressionAuxiliaryDebugWindowHandler { MAMEDisassemblyView *dasmView; + NSPopUpButton *subviewButton; } - (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; +- (BOOL)selectSubviewForDevice:(device_t *)device; +- (BOOL)selectSubviewForSpace:(address_space *)space; + - (IBAction)changeSubview:(id)sender; @end diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.m b/src/osd/modules/debugger/osx/disassemblyviewer.m index 6b4272202bb..0342ad83315 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.m +++ b/src/osd/modules/debugger/osx/disassemblyviewer.m @@ -11,6 +11,7 @@ #import "disassemblyviewer.h" +#import "debugconsole.h" #import "debugview.h" #import "disassemblyview.h" @@ -22,7 +23,7 @@ - (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { NSScrollView *dasmScroll; NSView *expressionContainer; - NSPopUpButton *actionButton, *subviewButton; + NSPopUpButton *actionButton; NSRect contentBounds, expressionFrame; if (!(self = [super initWithMachine:m title:@"Disassembly" console:c])) @@ -98,7 +99,7 @@ [actionButton release]; // set default state - [dasmView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)]; + [dasmView selectSubviewForDevice:debug_cpu_get_visible_cpu(*machine)]; [dasmView setExpression:@"curpc"]; [expressionField setStringValue:@"curpc"]; [expressionField selectText:self]; @@ -130,6 +131,38 @@ } +- (IBAction)debugNewMemoryWindow:(id)sender { + debug_view_disasm_source const *source = [dasmView source]; + [console debugNewMemoryWindowForSpace:&source->space() + device:&source->device() + expression:nil]; +} + + +- (IBAction)debugNewDisassemblyWindow:(id)sender { + debug_view_disasm_source const *source = [dasmView source]; + [console debugNewDisassemblyWindowForSpace:&source->space() + device:&source->device() + expression:[dasmView expression]]; +} + + +- (BOOL)selectSubviewForDevice:(device_t *)device { + BOOL const result = [dasmView selectSubviewForDevice:device]; + [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[dasmView selectedSubviewIndex]]]; + [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; + return result; +} + + +- (BOOL)selectSubviewForSpace:(address_space *)space { + BOOL const result = [dasmView selectSubviewForSpace:space]; + [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[dasmView selectedSubviewIndex]]]; + [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; + return result; +} + + - (IBAction)changeSubview:(id)sender { [dasmView selectSubviewAtIndex:[[sender selectedItem] tag]]; [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; diff --git a/src/osd/modules/debugger/osx/memoryview.h b/src/osd/modules/debugger/osx/memoryview.h index a0cb51ba7c1..c6bd9c65baf 100644 --- a/src/osd/modules/debugger/osx/memoryview.h +++ b/src/osd/modules/debugger/osx/memoryview.h @@ -14,6 +14,7 @@ #import "debugview.h" #include "emu.h" +#include "debug/dvmemory.h" #import @@ -29,11 +30,14 @@ - (NSString *)selectedSubviewName; - (int)selectedSubviewIndex; - (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; +- (BOOL)selectSubviewForDevice:(device_t *)device; +- (BOOL)selectSubviewForSpace:(address_space *)space; - (NSString *)expression; - (void)setExpression:(NSString *)exp; +- (debug_view_memory_source const *)source; + - (IBAction)showChunkSize:(id)sender; - (IBAction)showPhysicalAddresses:(id)sender; - (IBAction)showReverseView:(id)sender; diff --git a/src/osd/modules/debugger/osx/memoryview.m b/src/osd/modules/debugger/osx/memoryview.m index b35701df757..8883fc303d7 100644 --- a/src/osd/modules/debugger/osx/memoryview.m +++ b/src/osd/modules/debugger/osx/memoryview.m @@ -13,7 +13,6 @@ #include "debug/debugcpu.h" #include "debug/debugvw.h" -#include "debug/dvmemory.h" @implementation MAMEMemoryView @@ -107,13 +106,43 @@ } -- (void)selectSubviewForCPU:(device_t *)device { - debug_view_source const *selected = view->source(); - debug_view_source const *source = view->source_for_device(device); - if ( selected != source ) { - view->set_source(*source); - if ([[self window] firstResponder] != self) - view->set_cursor_visible(false); +- (BOOL)selectSubviewForDevice:(device_t *)device { + debug_view_source const *const source = view->source_for_device(device); + if (source != NULL) + { + if (view->source() != source) + { + view->set_source(*source); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } + return YES; + } + else + { + return NO; + } +} + + +- (BOOL)selectSubviewForSpace:(address_space *)space { + if (space == NULL) return NO; + debug_view_memory_source const *source = downcast(view->first_source()); + while ((source != NULL) && (source->space() != space)) + source = downcast(source->next()); + if (source != NULL) + { + if (view->source() != source) + { + view->set_source(*source); + if ([[self window] firstResponder] != self) + view->set_cursor_visible(false); + } + return YES; + } + else + { + return NO; } } @@ -128,6 +157,11 @@ } +- (debug_view_memory_source const *)source { + return downcast(view->source()); +} + + - (IBAction)showChunkSize:(id)sender { downcast(view)->set_bytes_per_chunk([sender tag]); } diff --git a/src/osd/modules/debugger/osx/memoryviewer.h b/src/osd/modules/debugger/osx/memoryviewer.h index 45db9c21051..4180f0a6ee7 100644 --- a/src/osd/modules/debugger/osx/memoryviewer.h +++ b/src/osd/modules/debugger/osx/memoryviewer.h @@ -23,10 +23,14 @@ @interface MAMEMemoryViewer : MAMEExpressionAuxiliaryDebugWindowHandler { MAMEMemoryView *memoryView; + NSPopUpButton *subviewButton; } - (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; +- (BOOL)selectSubviewForDevice:(device_t *)device; +- (BOOL)selectSubviewForSpace:(address_space *)space; + - (IBAction)changeSubview:(id)sender; @end diff --git a/src/osd/modules/debugger/osx/memoryviewer.m b/src/osd/modules/debugger/osx/memoryviewer.m index 044f0f442df..5412cc6457d 100644 --- a/src/osd/modules/debugger/osx/memoryviewer.m +++ b/src/osd/modules/debugger/osx/memoryviewer.m @@ -11,10 +11,12 @@ #import "memoryviewer.h" +#import "debugconsole.h" #import "debugview.h" #import "memoryview.h" #include "debug/debugcpu.h" +#include "debug/dvmemory.h" @implementation MAMEMemoryViewer @@ -22,7 +24,7 @@ - (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { NSScrollView *memoryScroll; NSView *expressionContainer; - NSPopUpButton *actionButton, *subviewButton; + NSPopUpButton *actionButton; NSRect contentBounds, expressionFrame; if (!(self = [super initWithMachine:m title:@"Memory" console:c])) @@ -97,7 +99,7 @@ [actionButton release]; // set default state - [memoryView selectSubviewForCPU:debug_cpu_get_visible_cpu(*machine)]; + [memoryView selectSubviewForDevice:debug_cpu_get_visible_cpu(*machine)]; [memoryView setExpression:@"0"]; [expressionField setStringValue:@"0"]; [expressionField selectText:self]; @@ -127,6 +129,38 @@ } +- (IBAction)debugNewMemoryWindow:(id)sender { + debug_view_memory_source const *source = [memoryView source]; + [console debugNewMemoryWindowForSpace:source->space() + device:source->device() + expression:[memoryView expression]]; +} + + +- (IBAction)debugNewDisassemblyWindow:(id)sender { + debug_view_memory_source const *source = [memoryView source]; + [console debugNewDisassemblyWindowForSpace:source->space() + device:source->device() + expression:[memoryView expression]]; +} + + +- (BOOL)selectSubviewForDevice:(device_t *)device { + BOOL const result = [memoryView selectSubviewForDevice:device]; + [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[memoryView selectedSubviewIndex]]]; + [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]]; + return result; +} + + +- (BOOL)selectSubviewForSpace:(address_space *)space { + BOOL const result = [memoryView selectSubviewForSpace:space]; + [subviewButton selectItemAtIndex:[subviewButton indexOfItemWithTag:[memoryView selectedSubviewIndex]]]; + [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]]; + return result; +} + + - (IBAction)changeSubview:(id)sender { [memoryView selectSubviewAtIndex:[[sender selectedItem] tag]]; [window setTitle:[NSString stringWithFormat:@"Memory: %@", [memoryView selectedSubviewName]]]; diff --git a/src/osd/modules/debugger/osx/registersview.h b/src/osd/modules/debugger/osx/registersview.h index 5b1ab6a54e5..ec6f6cca5f8 100644 --- a/src/osd/modules/debugger/osx/registersview.h +++ b/src/osd/modules/debugger/osx/registersview.h @@ -29,6 +29,6 @@ - (NSString *)selectedSubviewName; - (int)selectedSubviewIndex; - (void)selectSubviewAtIndex:(int)index; -- (void)selectSubviewForCPU:(device_t *)device; +- (void)selectSubviewForDevice:(device_t *)device; @end diff --git a/src/osd/modules/debugger/osx/registersview.m b/src/osd/modules/debugger/osx/registersview.m index ba2cf93cd09..5768635f127 100644 --- a/src/osd/modules/debugger/osx/registersview.m +++ b/src/osd/modules/debugger/osx/registersview.m @@ -64,7 +64,7 @@ } -- (void)selectSubviewForCPU:(device_t *)device { +- (void)selectSubviewForDevice:(device_t *)device { view->set_source(*view->source_for_device(device)); } -- cgit v1.2.3 From ee0309eedeaef22a3c5ac36c747657ff21f679a9 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 17 Feb 2015 03:07:30 +1100 Subject: Allow run-to-cursor and breakpoint set/clear/enable/disable for inactive CPUs --- src/osd/modules/debugger/osx/disassemblyview.m | 121 ++++++++++++++----------- 1 file changed, 69 insertions(+), 52 deletions(-) diff --git a/src/osd/modules/debugger/osx/disassemblyview.m b/src/osd/modules/debugger/osx/disassemblyview.m index 16f70404c41..9ddd31d60f5 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.m +++ b/src/osd/modules/debugger/osx/disassemblyview.m @@ -19,10 +19,10 @@ @implementation MAMEDisassemblyView -- (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address inAddressSpace:(address_space &)space { - device_debug *cpuinfo = space.device().debug(); +- (device_debug::breakpoint *)findBreakpointAtAddress:(offs_t)address forDevice:(device_t &)device { + device_debug *cpuinfo = device.debug(); device_debug::breakpoint *bp; - for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) {} + for (bp = cpuinfo->breakpoint_first(); (bp != NULL) && (address != bp->address()); bp = bp->next()) { } return bp; } @@ -90,75 +90,87 @@ - (BOOL)validateMenuItem:(NSMenuItem *)item { - SEL action = [item action]; - BOOL inContextMenu = ([item menu] == [self menu]); - BOOL haveCursor = NO, isCurrent = NO; - device_debug::breakpoint *breakpoint = NULL; - - if (view->cursor_visible()) { - if (debug_cpu_get_visible_cpu(*machine) == view->source()->device()) { - isCurrent = YES; - if (!useConsole || isCurrent) { - offs_t address = downcast(view)->selected_address(); - haveCursor = YES; - breakpoint = [self findBreakpointAtAddress:address inAddressSpace:downcast(view->source())->space()]; - } - } + SEL const action = [item action]; + BOOL const inContextMenu = ([item menu] == [self menu]); + BOOL haveCursor = view->cursor_visible(); + BOOL const isCurrent = (debug_cpu_get_visible_cpu(*machine) == view->source()->device()); + + device_debug::breakpoint *breakpoint = NULL; + if (haveCursor) + { + offs_t const address = downcast(view)->selected_address(); + breakpoint = [self findBreakpointAtAddress:address forDevice:[self source]->device()]; } - if (action == @selector(debugToggleBreakpoint:)) { - if (haveCursor) { - if (breakpoint != NULL) { + if (action == @selector(debugToggleBreakpoint:)) + { + if (haveCursor) + { + if (breakpoint != NULL) + { if (inContextMenu) [item setTitle:@"Clear Breakpoint"]; else [item setTitle:@"Clear Breakpoint at Cursor"]; - } else { + } + else + { if (inContextMenu) [item setTitle:@"Set Breakpoint"]; else [item setTitle:@"Set Breakpoint at Cursor"]; } - } else { + } + else + { if (inContextMenu) [item setTitle:@"Toggle Breakpoint"]; else [item setTitle:@"Toggle Breakpoint at Cursor"]; } - return haveCursor; - } else if (action == @selector(debugToggleBreakpointEnable:)) { - if ((breakpoint != NULL) && !breakpoint->enabled()) { + return haveCursor && (!useConsole || isCurrent); + } + else if (action == @selector(debugToggleBreakpointEnable:)) + { + if ((breakpoint != NULL) && !breakpoint->enabled()) + { if (inContextMenu) [item setTitle:@"Enable Breakpoint"]; else [item setTitle:@"Enable Breakpoint at Cursor"]; - } else { + } + else + { if (inContextMenu) [item setTitle:@"Disable Breakpoint"]; else [item setTitle:@"Disable Breakpoint at Cursor"]; } - return (breakpoint != NULL); - } else if (action == @selector(debugRunToCursor:)) { - return isCurrent; - } else if (action == @selector(showRightColumn:)) { + return (breakpoint != NULL) && (!useConsole || isCurrent); + } + else if (action == @selector(debugRunToCursor:)) + { + return !useConsole || isCurrent; + } + else if (action == @selector(showRightColumn:)) + { [item setState:((downcast(view)->right_column() == [item tag]) ? NSOnState : NSOffState)]; return YES; - } else { + } + else + { return YES; } } - (NSSize)maximumFrameSize { - debug_view_xy max; - device_t *curcpu = debug_cpu_get_visible_cpu(*machine); - const debug_view_source *source = view->source_for_device(curcpu); + debug_view_xy max(0, 0); + const debug_view_source *source = view->source(); - max.x = max.y = 0; for (const debug_view_source *source = view->source_list().first(); source != NULL; source = source->next()) { - debug_view_xy current; + debug_view_xy current; view->set_source(*source); current = view->total_size(); if (current.x > max.x) @@ -258,11 +270,11 @@ - (IBAction)debugToggleBreakpoint:(id)sender { if (view->cursor_visible()) { - address_space &space = downcast(view->source())->space(); - if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) + device_t &device = [self source]->device(); + if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) { offs_t const address = downcast(view)->selected_address(); - device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; + device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device]; // if it doesn't exist, add a new one if (useConsole) @@ -278,13 +290,13 @@ { if (bp == NULL) { - UINT32 const bpnum = space.device().debug()->breakpoint_set(address, NULL, NULL); + UINT32 const bpnum = device.debug()->breakpoint_set(address, NULL, NULL); debug_console_printf(*machine, "Breakpoint %X set\n", bpnum); } else { int const bpnum = bp->index(); - space.device().debug()->breakpoint_clear(bpnum); + device.debug()->breakpoint_clear(bpnum); debug_console_printf(*machine, "Breakpoint %X cleared\n", (UINT32)bpnum); } } @@ -300,11 +312,11 @@ - (IBAction)debugToggleBreakpointEnable:(id)sender { if (view->cursor_visible()) { - address_space &space = downcast(view->source())->space(); - if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &space.device())) + device_t &device = [self source]->device(); + if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) { offs_t const address = downcast(view)->selected_address(); - device_debug::breakpoint *bp = [self findBreakpointAtAddress:address inAddressSpace:space]; + device_debug::breakpoint *bp = [self findBreakpointAtAddress:address forDevice:device]; if (bp != NULL) { if (useConsole) @@ -318,7 +330,7 @@ } else { - space.device().debug()->breakpoint_enable(bp->index(), !bp->enabled()); + device.debug()->breakpoint_enable(bp->index(), !bp->enabled()); debug_console_printf(*machine, "Breakpoint %X %s\n", (UINT32)bp->index(), @@ -333,15 +345,20 @@ - (IBAction)debugRunToCursor:(id)sender { - if (view->cursor_visible()) { - address_space &space = downcast(view->source())->space(); - if (debug_cpu_get_visible_cpu(*machine) == &space.device()) { - offs_t address = downcast(view)->selected_address(); - if (useConsole) { + if (view->cursor_visible()) + { + device_t &device = [self source]->device(); + if (!useConsole || (debug_cpu_get_visible_cpu(*machine) == &device)) + { + offs_t const address = downcast(view)->selected_address(); + if (useConsole) + { NSString *command = [NSString stringWithFormat:@"go 0x%lX", (unsigned long)address]; debug_console_execute_command(*machine, [command UTF8String], 1); - } else { - debug_cpu_get_visible_cpu(*machine)->debug()->go(address); + } + else + { + device.debug()->go(address); } } } -- cgit v1.2.3 From 145ad17fa232f22c188c76d11fd4df75260868b7 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 17 Feb 2015 16:13:24 +1100 Subject: Add devices window to cocoa debugger --- src/osd/modules/debugger/debugosx.m | 2 +- src/osd/modules/debugger/osx/breakpointsview.h | 2 +- src/osd/modules/debugger/osx/breakpointsview.m | 2 +- src/osd/modules/debugger/osx/consoleview.h | 2 +- src/osd/modules/debugger/osx/consoleview.m | 2 +- src/osd/modules/debugger/osx/debugcommandhistory.h | 2 +- src/osd/modules/debugger/osx/debugcommandhistory.m | 2 +- src/osd/modules/debugger/osx/debugconsole.h | 3 +- src/osd/modules/debugger/osx/debugconsole.m | 11 +- src/osd/modules/debugger/osx/debugosx.h | 3 + src/osd/modules/debugger/osx/debugview.h | 2 +- src/osd/modules/debugger/osx/debugview.m | 2 +- src/osd/modules/debugger/osx/debugwindowhandler.h | 3 +- src/osd/modules/debugger/osx/debugwindowhandler.m | 162 ++++++++-------- src/osd/modules/debugger/osx/devicesviewer.h | 31 +++ src/osd/modules/debugger/osx/devicesviewer.m | 210 +++++++++++++++++++++ src/osd/modules/debugger/osx/disassemblyview.h | 2 +- src/osd/modules/debugger/osx/disassemblyview.m | 2 +- src/osd/modules/debugger/osx/disassemblyviewer.h | 2 +- src/osd/modules/debugger/osx/disassemblyviewer.m | 18 +- src/osd/modules/debugger/osx/errorlogview.h | 2 +- src/osd/modules/debugger/osx/errorlogview.m | 2 +- src/osd/modules/debugger/osx/errorlogviewer.h | 2 +- src/osd/modules/debugger/osx/errorlogviewer.m | 2 +- src/osd/modules/debugger/osx/memoryview.h | 2 +- src/osd/modules/debugger/osx/memoryview.m | 2 +- src/osd/modules/debugger/osx/memoryviewer.h | 2 +- src/osd/modules/debugger/osx/memoryviewer.m | 2 +- src/osd/modules/debugger/osx/pointsviewer.h | 2 +- src/osd/modules/debugger/osx/pointsviewer.m | 2 +- src/osd/modules/debugger/osx/registersview.h | 2 +- src/osd/modules/debugger/osx/registersview.m | 2 +- src/osd/modules/debugger/osx/watchpointsview.h | 2 +- src/osd/modules/debugger/osx/watchpointsview.m | 2 +- src/osd/sdl/sdl.mak | 1 + 35 files changed, 377 insertions(+), 117 deletions(-) create mode 100644 src/osd/modules/debugger/osx/devicesviewer.h create mode 100644 src/osd/modules/debugger/osx/devicesviewer.m diff --git a/src/osd/modules/debugger/debugosx.m b/src/osd/modules/debugger/debugosx.m index 460a666a5fb..3b9c971483b 100644 --- a/src/osd/modules/debugger/debugosx.m +++ b/src/osd/modules/debugger/debugosx.m @@ -12,7 +12,7 @@ // TODO: // * Automatic scrolling for console and log views -// * Keyboard shortcuts in error log windows +// * Keyboard shortcuts in error log and devices windows // * Don't accept keyboard input while the game is running // * Interior focus rings - standard/exterior focus rings look really ugly here // * Improve automatic window sizing - it isn't working all that well diff --git a/src/osd/modules/debugger/osx/breakpointsview.h b/src/osd/modules/debugger/osx/breakpointsview.h index f2701200e25..e31a63aebed 100644 --- a/src/osd/modules/debugger/osx/breakpointsview.h +++ b/src/osd/modules/debugger/osx/breakpointsview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxbreakpointsview.h - MacOS X Cocoa debug window handling +// breakpointsview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/breakpointsview.m b/src/osd/modules/debugger/osx/breakpointsview.m index d84f1efbce1..97545370955 100644 --- a/src/osd/modules/debugger/osx/breakpointsview.m +++ b/src/osd/modules/debugger/osx/breakpointsview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxbreakpointsview.m - MacOS X Cocoa debug window handling +// breakpointsview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/consoleview.h b/src/osd/modules/debugger/osx/consoleview.h index 9ff4f15fa9f..5538ea49f28 100644 --- a/src/osd/modules/debugger/osx/consoleview.h +++ b/src/osd/modules/debugger/osx/consoleview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxconsoleview.h - MacOS X Cocoa debug window handling +// consoleview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/consoleview.m b/src/osd/modules/debugger/osx/consoleview.m index b0777cd2a84..3e2e29b9202 100644 --- a/src/osd/modules/debugger/osx/consoleview.m +++ b/src/osd/modules/debugger/osx/consoleview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxconsoleview.m - MacOS X Cocoa debug window handling +// consoleview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugcommandhistory.h b/src/osd/modules/debugger/osx/debugcommandhistory.h index 3cb0f23d06c..1e77b1f6cfb 100644 --- a/src/osd/modules/debugger/osx/debugcommandhistory.h +++ b/src/osd/modules/debugger/osx/debugcommandhistory.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugcommandhistory.h - MacOS X Cocoa debug window handling +// debugcommandhistory.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugcommandhistory.m b/src/osd/modules/debugger/osx/debugcommandhistory.m index b7f9e4bf91d..882c313000e 100644 --- a/src/osd/modules/debugger/osx/debugcommandhistory.m +++ b/src/osd/modules/debugger/osx/debugcommandhistory.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugcommandhistory.m - MacOS X Cocoa debug window handling +// debugcommandhistory.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugconsole.h b/src/osd/modules/debugger/osx/debugconsole.h index 24ed021fcb4..bf210458ed7 100644 --- a/src/osd/modules/debugger/osx/debugconsole.h +++ b/src/osd/modules/debugger/osx/debugconsole.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugconsole.h - MacOS X Cocoa debug window handling +// debugconsole.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -41,6 +41,7 @@ - (IBAction)debugNewDisassemblyWindow:(id)sender; - (IBAction)debugNewErrorLogWindow:(id)sender; - (IBAction)debugNewPointsWindow:(id)sender; +- (IBAction)debugNewDevicesWindow:(id)sender; - (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression; - (void)debugNewDisassemblyWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression; diff --git a/src/osd/modules/debugger/osx/debugconsole.m b/src/osd/modules/debugger/osx/debugconsole.m index 3df65689e4f..bc290db2df8 100644 --- a/src/osd/modules/debugger/osx/debugconsole.m +++ b/src/osd/modules/debugger/osx/debugconsole.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugconsole.m - MacOS X Cocoa debug window handling +// debugconsole.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -14,6 +14,7 @@ #import "debugcommandhistory.h" #import "consoleview.h" #import "debugview.h" +#import "devicesviewer.h" #import "disassemblyview.h" #import "disassemblyviewer.h" #import "errorlogviewer.h" @@ -258,6 +259,14 @@ } +- (IBAction)debugNewDevicesWindow:(id)sender { + MAMEDevicesViewer *win = [[MAMEDevicesViewer alloc] initWithMachine:*machine console:self]; + [auxiliaryWindows addObject:win]; + [win release]; + [win activate]; +} + + - (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression { MAMEMemoryViewer *win = [[MAMEMemoryViewer alloc] initWithMachine:*machine console:self]; [auxiliaryWindows addObject:win]; diff --git a/src/osd/modules/debugger/osx/debugosx.h b/src/osd/modules/debugger/osx/debugosx.h index 8971955dacb..016ea752e34 100644 --- a/src/osd/modules/debugger/osx/debugosx.h +++ b/src/osd/modules/debugger/osx/debugosx.h @@ -46,6 +46,9 @@ typedef float CGFloat; @protocol NSTextFieldDelegate @end +@protocol NSOutlineViewDataSource +@end + #endif // MAC_OS_X_VERSION_MAX_ALLOWED < 1060 #endif // MAC_OS_X_VERSION_MAX_ALLOWED diff --git a/src/osd/modules/debugger/osx/debugview.h b/src/osd/modules/debugger/osx/debugview.h index 56afd03351b..abb53efb852 100644 --- a/src/osd/modules/debugger/osx/debugview.h +++ b/src/osd/modules/debugger/osx/debugview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugview.h - MacOS X Cocoa debug window handling +// debugview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugview.m b/src/osd/modules/debugger/osx/debugview.m index 2167e4321be..8ce77b59cc3 100644 --- a/src/osd/modules/debugger/osx/debugview.m +++ b/src/osd/modules/debugger/osx/debugview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugview.h - MacOS X Cocoa debug window handling +// debugview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.h b/src/osd/modules/debugger/osx/debugwindowhandler.h index 4c157d825f8..56f3c98f9df 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.h +++ b/src/osd/modules/debugger/osx/debugwindowhandler.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugwindowhandler.h - MacOS X Cocoa debug window handling +// debugwindowhandler.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -72,6 +72,7 @@ extern NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification; - (IBAction)debugNewDisassemblyWindow:(id)sender; - (IBAction)debugNewErrorLogWindow:(id)sender; - (IBAction)debugNewPointsWindow:(id)sender; +- (IBAction)debugNewDevicesWindow:(id)sender; - (void)windowWillClose:(NSNotification *)notification; diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.m b/src/osd/modules/debugger/osx/debugwindowhandler.m index d26ca25979b..ba0a0d83351 100644 --- a/src/osd/modules/debugger/osx/debugwindowhandler.m +++ b/src/osd/modules/debugger/osx/debugwindowhandler.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdebugwindowhandler.m - MacOS X Cocoa debug window handling +// debugwindowhandler.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -33,85 +33,86 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD @implementation MAMEDebugWindowHandler + (void)addCommonActionItems:(NSMenu *)menu { - { - NSMenuItem *runParentItem = [menu addItemWithTitle:@"Run" - action:@selector(debugRun:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF5FunctionKey]]; - NSMenu *runMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Run"]; - [runParentItem setSubmenu:runMenu]; - [runMenu release]; - [runParentItem setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"and Hide Debugger" - action:@selector(debugRunAndHide:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF12FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"to Next CPU" - action:@selector(debugRunToNextCPU:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF6FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"until Next Interrupt on Current CPU" - action:@selector(debugRunToNextInterrupt:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF7FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[runMenu addItemWithTitle:@"until Next VBLANK" - action:@selector(debugRunToNextVBLANK:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF8FunctionKey]] - setKeyEquivalentModifierMask:0]; - } - { - NSMenuItem *stepParentItem = [menu addItemWithTitle:@"Step" action:NULL keyEquivalent:@""]; - NSMenu *stepMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Step"]; - [stepParentItem setSubmenu:stepMenu]; - [stepMenu release]; - [[stepMenu addItemWithTitle:@"Into" - action:@selector(debugStepInto:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF11FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[stepMenu addItemWithTitle:@"Over" - action:@selector(debugStepOver:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[stepMenu addItemWithTitle:@"Out" - action:@selector(debugStepOut:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] - setKeyEquivalentModifierMask:NSShiftKeyMask]; - } - { - NSMenuItem *resetParentItem = [menu addItemWithTitle:@"Reset" action:NULL keyEquivalent:@""]; - NSMenu *resetMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Reset"]; - [resetParentItem setSubmenu:resetMenu]; - [resetMenu release]; - [[resetMenu addItemWithTitle:@"Soft" - action:@selector(debugSoftReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] - setKeyEquivalentModifierMask:0]; - [[resetMenu addItemWithTitle:@"Hard" - action:@selector(debugHardReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] - setKeyEquivalentModifierMask:NSShiftKeyMask]; - } + NSMenuItem *runParentItem = [menu addItemWithTitle:@"Run" + action:@selector(debugRun:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF5FunctionKey]]; + NSMenu *runMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Run"]; + [runParentItem setSubmenu:runMenu]; + [runMenu release]; + [runParentItem setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"and Hide Debugger" + action:@selector(debugRunAndHide:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF12FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"to Next CPU" + action:@selector(debugRunToNextCPU:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF6FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"until Next Interrupt on Current CPU" + action:@selector(debugRunToNextInterrupt:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF7FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[runMenu addItemWithTitle:@"until Next VBLANK" + action:@selector(debugRunToNextVBLANK:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF8FunctionKey]] + setKeyEquivalentModifierMask:0]; + + NSMenuItem *stepParentItem = [menu addItemWithTitle:@"Step" action:NULL keyEquivalent:@""]; + NSMenu *stepMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Step"]; + [stepParentItem setSubmenu:stepMenu]; + [stepMenu release]; + [[stepMenu addItemWithTitle:@"Into" + action:@selector(debugStepInto:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF11FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[stepMenu addItemWithTitle:@"Over" + action:@selector(debugStepOver:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[stepMenu addItemWithTitle:@"Out" + action:@selector(debugStepOut:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] + setKeyEquivalentModifierMask:NSShiftKeyMask]; + + NSMenuItem *resetParentItem = [menu addItemWithTitle:@"Reset" action:NULL keyEquivalent:@""]; + NSMenu *resetMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Reset"]; + [resetParentItem setSubmenu:resetMenu]; + [resetMenu release]; + [[resetMenu addItemWithTitle:@"Soft" + action:@selector(debugSoftReset:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] + setKeyEquivalentModifierMask:0]; + [[resetMenu addItemWithTitle:@"Hard" + action:@selector(debugHardReset:) + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] + setKeyEquivalentModifierMask:NSShiftKeyMask]; + [menu addItem:[NSMenuItem separatorItem]]; - { - NSMenuItem *newParentItem = [menu addItemWithTitle:@"New" action:NULL keyEquivalent:@""]; - NSMenu *newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"New"]; - [newParentItem setSubmenu:newMenu]; - [newMenu release]; - [newMenu addItemWithTitle:@"Memory Window" - action:@selector(debugNewMemoryWindow:) - keyEquivalent:@"d"]; - [newMenu addItemWithTitle:@"Disassembly Window" - action:@selector(debugNewDisassemblyWindow:) - keyEquivalent:@"a"]; - [newMenu addItemWithTitle:@"Error Log Window" - action:@selector(debugNewErrorLogWindow:) - keyEquivalent:@"l"]; - [newMenu addItemWithTitle:@"(Break|Watch)points Window" - action:@selector(debugNewPointsWindow:) - keyEquivalent:@"b"]; - } + + NSMenuItem *newParentItem = [menu addItemWithTitle:@"New" action:NULL keyEquivalent:@""]; + NSMenu *newMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"New"]; + [newParentItem setSubmenu:newMenu]; + [newMenu release]; + [newMenu addItemWithTitle:@"Memory Window" + action:@selector(debugNewMemoryWindow:) + keyEquivalent:@"d"]; + [newMenu addItemWithTitle:@"Disassembly Window" + action:@selector(debugNewDisassemblyWindow:) + keyEquivalent:@"a"]; + [newMenu addItemWithTitle:@"Error Log Window" + action:@selector(debugNewErrorLogWindow:) + keyEquivalent:@"l"]; + [newMenu addItemWithTitle:@"(Break|Watch)points Window" + action:@selector(debugNewPointsWindow:) + keyEquivalent:@"b"]; + [newMenu addItemWithTitle:@"Devices Window" + action:@selector(debugNewDevicesWindow:) + keyEquivalent:@"D"]; + [menu addItem:[NSMenuItem separatorItem]]; + [menu addItemWithTitle:@"Close Window" action:@selector(performClose:) keyEquivalent:@"w"]; - [menu addItemWithTitle:@"Exit" action:@selector(debugExit:) keyEquivalent:@""]; + [menu addItemWithTitle:@"Quit" action:@selector(debugExit:) keyEquivalent:@"q"]; } @@ -298,6 +299,11 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD } +- (IBAction)debugNewDevicesWindow:(id)sender { + [console debugNewDevicesWindow:sender]; +} + + - (void)windowWillClose:(NSNotification *)notification { [[NSNotificationCenter defaultCenter] postNotificationName:MAMEAuxiliaryDebugWindowWillCloseNotification object:self]; @@ -314,7 +320,7 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD windowFrame.size.width += desired.width; windowFrame.size.width = MIN(windowFrame.size.width, available.size.width); windowFrame.size.height += desired.height; - windowFrame.size.height = MIN(MIN(windowFrame.size.height, 240), available.size.height); + windowFrame.size.height = MIN(MIN(windowFrame.size.height, 320), available.size.height); windowFrame.origin.x = available.origin.x + available.size.width - windowFrame.size.width; windowFrame.origin.y = available.origin.y; [window setFrame:windowFrame display:YES]; diff --git a/src/osd/modules/debugger/osx/devicesviewer.h b/src/osd/modules/debugger/osx/devicesviewer.h new file mode 100644 index 00000000000..3737a497163 --- /dev/null +++ b/src/osd/modules/debugger/osx/devicesviewer.h @@ -0,0 +1,31 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// devicesviewer.h - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "debugosx.h" + +#import "debugwindowhandler.h" + +#include "emu.h" + +#import + + +@class MAMEDebugConsole, MAMEDeviceWrapper; + +@interface MAMEDevicesViewer : MAMEAuxiliaryDebugWindowHandler +{ + MAMEDeviceWrapper *root; + NSOutlineView *devicesView; +} + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; + +@end diff --git a/src/osd/modules/debugger/osx/devicesviewer.m b/src/osd/modules/debugger/osx/devicesviewer.m new file mode 100644 index 00000000000..29910c57c40 --- /dev/null +++ b/src/osd/modules/debugger/osx/devicesviewer.m @@ -0,0 +1,210 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +//============================================================ +// +// devicesviewer.m - MacOS X Cocoa debug window handling +// +// Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +//============================================================ + +#import "devicesviewer.h" + + +@interface MAMEDeviceWrapper : NSObject +{ + running_machine *machine; + device_t *device; + NSArray *children; +} + +- (id)initWithMachine:(running_machine &)m device:(device_t &)d; + +- (running_machine &)machine; +- (device_t &)device; +- (NSString *)tag; +- (NSString *)name; +- (NSUInteger)children; +- (MAMEDeviceWrapper *)childAtIndex:(NSUInteger)index; + +@end + + +@implementation MAMEDeviceWrapper + +- (void)wrapChildren { + NSMutableArray *const tmp = [[NSMutableArray alloc] init]; + for (device_t *child = device->first_subdevice(); child != NULL; child = child->next()) + { + MAMEDeviceWrapper *const wrap = [[MAMEDeviceWrapper alloc] initWithMachine:*machine + device:*child]; + [tmp addObject:wrap]; + [wrap release]; + } + children = [[NSArray alloc] initWithArray:tmp]; + [tmp release]; +} + + +- (id)initWithMachine:(running_machine &)m device:(device_t &)d { + if (!(self = [super init])) + return nil; + machine = &m; + device = &d; + children = nil; + return self; +} + + +- (void)dealloc { + if (children != nil) + [children release]; + [super dealloc]; +} + + +- (running_machine &)machine { + return *machine; +} + + +- (device_t &)device { + return *device; +} + + +- (NSString *)tag { + return (device == &machine->root_device()) ? @"" + : [NSString stringWithUTF8String:device->basetag()]; +} + + +- (NSString *)name { + return [NSString stringWithUTF8String:device->name()]; +} + + +- (NSUInteger)children { + if (children == nil) + [self wrapChildren]; + return [children count]; +} + + +- (MAMEDeviceWrapper *)childAtIndex:(NSUInteger)index { + if (children == nil) + [self wrapChildren]; + return (index < [children count]) ? [children objectAtIndex:index] : nil; +} + +@end + + +@implementation MAMEDevicesViewer + +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c { + NSScrollView *devicesScroll; + NSTableColumn *tagColumn, *nameColumn; + + if (!(self = [super initWithMachine:m title:@"All Devices" console:c])) + return nil; + root = [[MAMEDeviceWrapper alloc] initWithMachine:m device:m.root_device()]; + + // create the devices view + devicesView = [[NSOutlineView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]; + [devicesView setUsesAlternatingRowBackgroundColors:YES]; + [devicesView setAllowsColumnReordering:YES]; + [devicesView setAllowsColumnResizing:YES]; + [devicesView setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle]; + [devicesView setAllowsEmptySelection:YES]; + [devicesView setAllowsMultipleSelection:NO]; + [devicesView setAllowsColumnSelection:NO]; + tagColumn = [[NSTableColumn alloc] initWithIdentifier:@"tag"]; + [[tagColumn headerCell] setStringValue:@"Tag"]; + [tagColumn setEditable:NO]; + [tagColumn setMinWidth:100]; + [tagColumn setWidth:120]; + [tagColumn setResizingMask:(NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask)]; + [devicesView addTableColumn:tagColumn]; + [tagColumn release]; + nameColumn = [[NSTableColumn alloc] initWithIdentifier:@"name"]; + [[nameColumn headerCell] setStringValue:@"Name"]; + [nameColumn setEditable:NO]; + [nameColumn setMinWidth:100]; + [nameColumn setMinWidth:360]; + [nameColumn setResizingMask:(NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask)]; + [devicesView addTableColumn:nameColumn]; + [nameColumn release]; + [devicesView setOutlineTableColumn:tagColumn]; + [devicesView setAutoresizesOutlineColumn:YES]; + [devicesView setDataSource:self]; + devicesScroll = [[NSScrollView alloc] initWithFrame:[[window contentView] bounds]]; + [devicesScroll setDrawsBackground:YES]; + [devicesScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + [devicesScroll setHasHorizontalScroller:YES]; + [devicesScroll setHasVerticalScroller:YES]; + [devicesScroll setAutohidesScrollers:YES]; + [devicesScroll setBorderType:NSNoBorder]; + [devicesScroll setDocumentView:devicesView]; + [devicesView release]; + [[window contentView] addSubview:devicesScroll]; + [devicesScroll release]; + + // set default state + [devicesView expandItem:root expandChildren:YES]; + [window makeFirstResponder:devicesView]; + [window setTitle:[NSString stringWithFormat:@"All Devices"]]; + + // calculate the optimal size for everything + NSSize const desired = [NSScrollView frameSizeForContentSize:NSMakeSize(480, 320) + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[devicesScroll borderType]]; + [self cascadeWindowWithDesiredSize:desired forView:devicesScroll]; + + // don't forget the result + return self; +} + + +- (void)dealloc { + if (root != nil) + [root release]; + [super dealloc]; +} + + +- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item { + return [(MAMEDeviceWrapper *)item children] > 0; +} + + +- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { + if (item != nil) + return [(MAMEDeviceWrapper *)item children]; + else + return 1; +} + + +- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item { + if (item != nil) + return [(MAMEDeviceWrapper *)item childAtIndex:index]; + else if (index == 0) + return root; + else + return nil; +} + + +- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { + if ([[tableColumn identifier] isEqualToString:@"tag"]) + return [(MAMEDeviceWrapper *)item tag]; + else if ([[tableColumn identifier] isEqualToString:@"name"]) + return [(MAMEDeviceWrapper *)item name]; + else + return nil; +} + +@end diff --git a/src/osd/modules/debugger/osx/disassemblyview.h b/src/osd/modules/debugger/osx/disassemblyview.h index 534f6f7fb40..40d2b04f379 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.h +++ b/src/osd/modules/debugger/osx/disassemblyview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyview.h - MacOS X Cocoa debug window handling +// disassemblyview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/disassemblyview.m b/src/osd/modules/debugger/osx/disassemblyview.m index 9ddd31d60f5..f5e5864372b 100644 --- a/src/osd/modules/debugger/osx/disassemblyview.m +++ b/src/osd/modules/debugger/osx/disassemblyview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyview.m - MacOS X Cocoa debug window handling +// disassemblyview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.h b/src/osd/modules/debugger/osx/disassemblyviewer.h index 6027d3c13da..27099aa9dc7 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.h +++ b/src/osd/modules/debugger/osx/disassemblyviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyviewer.h - MacOS X Cocoa debug window handling +// disassemblyviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/disassemblyviewer.m b/src/osd/modules/debugger/osx/disassemblyviewer.m index 0342ad83315..7fcbb842b2d 100644 --- a/src/osd/modules/debugger/osx/disassemblyviewer.m +++ b/src/osd/modules/debugger/osx/disassemblyviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxdisassemblyviewer.m - MacOS X Cocoa debug window handling +// disassemblyviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. @@ -24,11 +24,11 @@ NSScrollView *dasmScroll; NSView *expressionContainer; NSPopUpButton *actionButton; - NSRect contentBounds, expressionFrame; + NSRect expressionFrame; if (!(self = [super initWithMachine:m title:@"Disassembly" console:c])) return nil; - contentBounds = [[window contentView] bounds]; + NSRect const contentBounds = [[window contentView] bounds]; // create the expression field expressionField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)]; @@ -108,13 +108,11 @@ [window setTitle:[NSString stringWithFormat:@"Disassembly: %@", [dasmView selectedSubviewName]]]; // calculate the optimal size for everything - { - NSSize desired = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] - hasHorizontalScroller:YES - hasVerticalScroller:YES - borderType:[dasmScroll borderType]]; - [self cascadeWindowWithDesiredSize:desired forView:dasmScroll]; - } + NSSize const desired = [NSScrollView frameSizeForContentSize:[dasmView maximumFrameSize] + hasHorizontalScroller:YES + hasVerticalScroller:YES + borderType:[dasmScroll borderType]]; + [self cascadeWindowWithDesiredSize:desired forView:dasmScroll]; // don't forget the result return self; diff --git a/src/osd/modules/debugger/osx/errorlogview.h b/src/osd/modules/debugger/osx/errorlogview.h index 168511c1819..bcb6a541a8c 100644 --- a/src/osd/modules/debugger/osx/errorlogview.h +++ b/src/osd/modules/debugger/osx/errorlogview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogview.h - MacOS X Cocoa debug window handling +// errorlogview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/errorlogview.m b/src/osd/modules/debugger/osx/errorlogview.m index 6ba563b071a..80380bc1e16 100644 --- a/src/osd/modules/debugger/osx/errorlogview.m +++ b/src/osd/modules/debugger/osx/errorlogview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogview.m - MacOS X Cocoa debug window handling +// errorlogview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/errorlogviewer.h b/src/osd/modules/debugger/osx/errorlogviewer.h index c2728298c14..22538f81307 100644 --- a/src/osd/modules/debugger/osx/errorlogviewer.h +++ b/src/osd/modules/debugger/osx/errorlogviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogviewer.h - MacOS X Cocoa debug window handling +// errorlogviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/errorlogviewer.m b/src/osd/modules/debugger/osx/errorlogviewer.m index 44189922f91..f049286aaa4 100644 --- a/src/osd/modules/debugger/osx/errorlogviewer.m +++ b/src/osd/modules/debugger/osx/errorlogviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxerrorlogviewer.m - MacOS X Cocoa debug window handling +// errorlogviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryview.h b/src/osd/modules/debugger/osx/memoryview.h index c6bd9c65baf..1336426c896 100644 --- a/src/osd/modules/debugger/osx/memoryview.h +++ b/src/osd/modules/debugger/osx/memoryview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryview.h - MacOS X Cocoa debug window handling +// memoryview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryview.m b/src/osd/modules/debugger/osx/memoryview.m index 8883fc303d7..0f02fac83ef 100644 --- a/src/osd/modules/debugger/osx/memoryview.m +++ b/src/osd/modules/debugger/osx/memoryview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryview.m - MacOS X Cocoa debug window handling +// memoryview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryviewer.h b/src/osd/modules/debugger/osx/memoryviewer.h index 4180f0a6ee7..63c9d4eea2b 100644 --- a/src/osd/modules/debugger/osx/memoryviewer.h +++ b/src/osd/modules/debugger/osx/memoryviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryviewer.h - MacOS X Cocoa debug window handling +// memoryviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/memoryviewer.m b/src/osd/modules/debugger/osx/memoryviewer.m index 5412cc6457d..517efa9fd0a 100644 --- a/src/osd/modules/debugger/osx/memoryviewer.m +++ b/src/osd/modules/debugger/osx/memoryviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxmemoryviewer.m - MacOS X Cocoa debug window handling +// memoryviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/pointsviewer.h b/src/osd/modules/debugger/osx/pointsviewer.h index 5df282ef850..3943f6b486f 100644 --- a/src/osd/modules/debugger/osx/pointsviewer.h +++ b/src/osd/modules/debugger/osx/pointsviewer.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxpointsviewer.h - MacOS X Cocoa debug window handling +// pointsviewer.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/pointsviewer.m b/src/osd/modules/debugger/osx/pointsviewer.m index 27c8f36417e..7c85324fd70 100644 --- a/src/osd/modules/debugger/osx/pointsviewer.m +++ b/src/osd/modules/debugger/osx/pointsviewer.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxpointsviewer.m - MacOS X Cocoa debug window handling +// pointsviewer.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/registersview.h b/src/osd/modules/debugger/osx/registersview.h index ec6f6cca5f8..90e656104fc 100644 --- a/src/osd/modules/debugger/osx/registersview.h +++ b/src/osd/modules/debugger/osx/registersview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxregistersview.h - MacOS X Cocoa debug window handling +// registersview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/registersview.m b/src/osd/modules/debugger/osx/registersview.m index 5768635f127..50191b4c9a5 100644 --- a/src/osd/modules/debugger/osx/registersview.m +++ b/src/osd/modules/debugger/osx/registersview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxregistersview.m - MacOS X Cocoa debug window handling +// registersview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/watchpointsview.h b/src/osd/modules/debugger/osx/watchpointsview.h index 23379de570c..0480c685d20 100644 --- a/src/osd/modules/debugger/osx/watchpointsview.h +++ b/src/osd/modules/debugger/osx/watchpointsview.h @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxwatchpointsview.h - MacOS X Cocoa debug window handling +// watchpointsview.h - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/modules/debugger/osx/watchpointsview.m b/src/osd/modules/debugger/osx/watchpointsview.m index 34dc5858a48..0b1ab9ae39c 100644 --- a/src/osd/modules/debugger/osx/watchpointsview.m +++ b/src/osd/modules/debugger/osx/watchpointsview.m @@ -2,7 +2,7 @@ // copyright-holders:Vas Crabb //============================================================ // -// debugosxwatchpointsview.m - MacOS X Cocoa debug window handling +// watchpointsview.m - MacOS X Cocoa debug window handling // // Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team. // Visit http://mamedev.org for licensing and usage restrictions. diff --git a/src/osd/sdl/sdl.mak b/src/osd/sdl/sdl.mak index 423e4422954..198ef34c339 100644 --- a/src/osd/sdl/sdl.mak +++ b/src/osd/sdl/sdl.mak @@ -295,6 +295,7 @@ DEBUGOBJS = \ $(OSDOBJ)/modules/debugger/osx/debugconsole.o \ $(OSDOBJ)/modules/debugger/osx/debugview.o \ $(OSDOBJ)/modules/debugger/osx/debugwindowhandler.o \ + $(OSDOBJ)/modules/debugger/osx/devicesviewer.o \ $(OSDOBJ)/modules/debugger/osx/disassemblyview.o \ $(OSDOBJ)/modules/debugger/osx/disassemblyviewer.o \ $(OSDOBJ)/modules/debugger/osx/errorlogview.o \ -- cgit v1.2.3 From 33965546d71815b675ee917a2b62c2076e340ee0 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 17 Feb 2015 18:09:50 +1100 Subject: Try not to crash on hard reset --- src/osd/modules/debugger/debugosx.m | 43 ++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/osd/modules/debugger/debugosx.m b/src/osd/modules/debugger/debugosx.m index 3b9c971483b..491aefbedda 100644 --- a/src/osd/modules/debugger/debugosx.m +++ b/src/osd/modules/debugger/debugosx.m @@ -54,14 +54,8 @@ public: [m_console release]; } - virtual int init() - { - return 0; - } - - virtual void exit() - { - } + virtual int init(); + virtual void exit(); virtual void init_debugger(running_machine &machine); virtual void wait_for_debugger(device_t &device, bool firststop); @@ -74,13 +68,41 @@ private: MODULE_DEFINITION(DEBUG_OSX, debugger_osx) +//============================================================ +// debugger_osx::init +//============================================================ + +int debugger_osx::init() +{ + return 0; +} + +//============================================================ +// debugger_osx::exit +//============================================================ + +void debugger_osx::exit() +{ + if (m_console) + { + NSDictionary *info = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:m_machine] + forKey:@"MAMEDebugMachine"]; + [[NSNotificationCenter defaultCenter] postNotificationName:MAMEHideDebuggerNotification + object:m_console + userInfo:info]; + [m_console release]; + m_console = nil; + m_machine = NULL; + } +} + //============================================================ // debugger_osx::init_debugger //============================================================ void debugger_osx::init_debugger(running_machine &machine) { - m_machine = &machine; + m_machine = &machine; } //============================================================ @@ -94,7 +116,8 @@ void debugger_osx::wait_for_debugger(device_t &device, bool firststop) m_console = [[MAMEDebugConsole alloc] initWithMachine:*m_machine]; // make sure the debug windows are visible - if (firststop) { + if (firststop) + { NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:[NSValue valueWithPointer:&device], @"MAMEDebugDevice", [NSValue valueWithPointer:m_machine], -- cgit v1.2.3