Debugger: Add boilerplate stuff.

This commit is contained in:
Tyler Stachecki 2015-01-15 16:36:44 -05:00
parent b6df46c51d
commit 9e5c02c3e7
25 changed files with 666 additions and 85 deletions

9
.gitignore vendored
View file

@ -8,5 +8,12 @@
*.swp
# Qt files.
/debugger/*.pro.user*
/debugger/cen64d
/debugger/*.o
/debugger/moc*_*.cpp
/debugger/*.pro.user*
/debugger/Makefile
/debugger/ui_main_window.h

View file

@ -12,13 +12,29 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = cen64d
TEMPLATE = app
TARGET = cen64d
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
SOURCES += disassembly_view.cpp \
main.cpp\
main_window.cpp \
memory_view.cpp \
memory_window.cpp \
rdp_window.cpp \
register_view.cpp \
rsp_window.cpp \
toggle_window.cpp \
vr4300_window.cpp
HEADERS += mainwindow.h
HEADERS += disassembly_view.h \
main_window.h \
memory_view.h \
memory_window.h \
rdp_window.h \
register_view.h \
rsp_window.h \
toggle_window.h \
vr4300_window.h
FORMS += mainwindow.ui
FORMS += main_window.ui

View file

@ -0,0 +1,28 @@
//
// disassembly_view.cpp: CEN64D disassembly view (MVC).
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "disassembly_view.h"
#include <QBrush>
#include <QPainter>
#include <QSize>
DisassemblyView::DisassemblyView() {
}
DisassemblyView::~DisassemblyView() {
}
void DisassemblyView::paintEvent(QPaintEvent* event) {
QPainter painter(viewport());
QSize area = viewport()->size();
painter.fillRect(0, 0, area.width(), area.height(), QBrush(Qt::blue));
}

View file

@ -0,0 +1,26 @@
//
// disassembly_view.h: CEN64D disassembly view (MVC).
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef DISASSEMBLY_VIEW_H
#define DISASSEMBLY_VIEW_H
#include <QAbstractScrollArea>
class DisassemblyView : public QAbstractScrollArea {
Q_OBJECT
public:
explicit DisassemblyView();
virtual ~DisassemblyView();
void paintEvent(QPaintEvent* event);
};
#endif

View file

@ -8,7 +8,7 @@
// 'LICENSE', which is part of this source code package.
//
#include "mainwindow.h"
#include "main_window.h"
#include <QApplication>
int main(int argc, char *argv[]) {

85
debugger/main_window.cpp Normal file
View file

@ -0,0 +1,85 @@
//
// main_window.cpp: CEN64D main window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "main_window.h"
#include "ui_main_window.h"
#include <QMessageBox>
#include <QKeySequence>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
setupActions();
setupMenuBar(menuBar());
memoryWindow = new MemoryWindow(viewMemoryWindowAction, false);
rdpWindow = new RDPWindow(viewRDPWindowAction, false);
rspWindow = new RSPWindow(viewRSPWindowAction, false);
vr4300Window = new VR4300Window(viewVR4300WindowAction, true);
// Prevent any of the non-critical windows from keeping us alive.
memoryWindow->setAttribute(Qt::WA_QuitOnClose, false);
rdpWindow->setAttribute(Qt::WA_QuitOnClose, false);
rspWindow->setAttribute(Qt::WA_QuitOnClose, false);
vr4300Window->setAttribute(Qt::WA_QuitOnClose, false);
statusBar()->showMessage(tr("Debugger ready."));
}
void MainWindow::setupActions() {
fileQuitAction = new QAction(tr("&Quit"), this);
fileQuitAction->setShortcuts(QKeySequence::Quit);
fileQuitAction->setStatusTip("Quit the application.");
connect(fileQuitAction, SIGNAL(triggered()), this, SLOT(close()));
viewMemoryWindowAction = new QAction(tr("&Memory"), this);
viewMemoryWindowAction->setStatusTip("Toggle the memory view window.");
viewMemoryWindowAction->setCheckable(true);
viewRDPWindowAction = new QAction(tr("R&DP"), this);
viewRDPWindowAction->setStatusTip("Toggle the RDP view window.");
viewRDPWindowAction->setCheckable(true);
viewRSPWindowAction = new QAction(tr("R&SP"), this);
viewRSPWindowAction->setStatusTip("Toggle the RSP view window.");
viewRSPWindowAction->setCheckable(true);
viewVR4300WindowAction = new QAction(tr("&VR4300"), this);
viewVR4300WindowAction->setStatusTip("Toggle the VR4300 view window.");
viewVR4300WindowAction->setCheckable(true);
helpAboutAction = new QAction(tr("&About"), this);
helpAboutAction->setStatusTip("Show the about window.");
connect(helpAboutAction, SIGNAL(triggered()), this, SLOT(showAboutWindow()));
}
void MainWindow::setupMenuBar(QMenuBar *menuBar) {
fileMenu = menuBar->addMenu(tr("&File"));
viewMenu = menuBar->addMenu(tr("&View"));
helpMenu = menuBar->addMenu(tr("&Help"));
fileMenu->addAction(fileQuitAction);
viewMenu->addAction(viewMemoryWindowAction);
viewMenu->addAction(viewRDPWindowAction);
viewMenu->addAction(viewRSPWindowAction);
viewMenu->addAction(viewVR4300WindowAction);
helpMenu->addAction(helpAboutAction);
}
void MainWindow::showAboutWindow() {
QMessageBox::about(this, tr("About CEN64 Debugger"),
tr("This is <b>CEN64</b>'s official debugger."));
}
MainWindow::~MainWindow() {
delete ui;
}

58
debugger/main_window.h Normal file
View file

@ -0,0 +1,58 @@
//
// main_window.h: CEN64D main window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <QAction>
#include <QMainWindow>
#include <QMenuBar>
#include "memory_window.h"
#include "rdp_window.h"
#include "rsp_window.h"
#include "vr4300_window.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
Ui::MainWindow *ui;
MemoryWindow *memoryWindow;
RDPWindow *rdpWindow;
RSPWindow *rspWindow;
VR4300Window *vr4300Window;
QMenu *fileMenu;
QAction *fileQuitAction;
QMenu *viewMenu;
QAction *viewMemoryWindowAction;
QAction *viewRDPWindowAction;
QAction *viewRSPWindowAction;
QAction *viewVR4300WindowAction;
QMenu *helpMenu;
QAction *helpAboutAction;
void setupActions();
void setupMenuBar(QMenuBar *menuBar);
private slots:
void showAboutWindow();
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
};
#endif

32
debugger/main_window.ui Normal file
View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>CEN64D</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

View file

@ -1,22 +0,0 @@
//
// mainwindow.cpp: CEN64D main window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
}
MainWindow::~MainWindow() {
delete ui;
}

View file

@ -1,30 +0,0 @@
//
// mainwindow.h: CEN64D main window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
Ui::MainWindow *ui;
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
};
#endif

View file

@ -1,25 +0,0 @@
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

28
debugger/memory_view.cpp Normal file
View file

@ -0,0 +1,28 @@
//
// memory_view.cpp: CEN64D memory view (MVC).
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "memory_view.h"
#include <QBrush>
#include <QPainter>
#include <QSize>
MemoryView::MemoryView() {
}
MemoryView::~MemoryView() {
}
void MemoryView::paintEvent(QPaintEvent* event) {
QPainter painter(viewport());
QSize area = viewport()->size();
painter.fillRect(0, 0, area.width(), area.height(), QBrush(Qt::green));
}

26
debugger/memory_view.h Normal file
View file

@ -0,0 +1,26 @@
//
// memory_view.h: CEN64D memory view (MVC).
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef MEMORY_VIEW_H
#define MEMORY_VIEW_H
#include <QAbstractScrollArea>
class MemoryView : public QAbstractScrollArea {
Q_OBJECT
public:
explicit MemoryView();
virtual ~MemoryView();
void paintEvent(QPaintEvent* event);
};
#endif

View file

@ -0,0 +1,19 @@
//
// memory_window.cpp: Memory view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "memory_window.h"
MemoryWindow::MemoryWindow(QAction *toggleAction, bool initiallyVisible)
: ToggleWindow(tr("CEN64D: Memory"), toggleAction, initiallyVisible) {
}
MemoryWindow::~MemoryWindow() {
}

25
debugger/memory_window.h Normal file
View file

@ -0,0 +1,25 @@
//
// memory_window.h: Memory view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef MEMORY_WINDOW_H
#define MEMORY_WINDOW_H
#include "toggle_window.h"
class MemoryWindow : public ToggleWindow {
Q_OBJECT
public:
explicit MemoryWindow(QAction *toggleAction, bool initiallyVisible);
~MemoryWindow();
};
#endif

19
debugger/rdp_window.cpp Normal file
View file

@ -0,0 +1,19 @@
//
// rdp_window.cpp: RDP view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "rdp_window.h"
RDPWindow::RDPWindow(QAction *toggleAction, bool initiallyVisible)
: ToggleWindow(tr("CEN64D: RDP"), toggleAction, initiallyVisible) {
}
RDPWindow::~RDPWindow() {
}

25
debugger/rdp_window.h Normal file
View file

@ -0,0 +1,25 @@
//
// rdp_window.h: RDP view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef RDP_WINDOW_H
#define RDP_WINDOW_H
#include "toggle_window.h"
class RDPWindow : public ToggleWindow {
Q_OBJECT
public:
explicit RDPWindow(QAction *toggleAction, bool initiallyVisible);
~RDPWindow();
};
#endif

View file

@ -0,0 +1,28 @@
//
// register_view.cpp: CEN64D register view (MVC).
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "register_view.h"
#include <QBrush>
#include <QPainter>
#include <QSize>
RegisterView::RegisterView() {
}
RegisterView::~RegisterView() {
}
void RegisterView::paintEvent(QPaintEvent* event) {
QPainter painter(viewport());
QSize area = viewport()->size();
painter.fillRect(0, 0, area.width(), area.height(), QBrush(Qt::red));
}

26
debugger/register_view.h Normal file
View file

@ -0,0 +1,26 @@
//
// register_view.h: CEN64D register view (MVC).
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef REGISTER_VIEW_H
#define REGISTER_VIEW_H
#include <QAbstractScrollArea>
class RegisterView : public QAbstractScrollArea {
Q_OBJECT
public:
explicit RegisterView();
virtual ~RegisterView();
void paintEvent(QPaintEvent* event);
};
#endif

29
debugger/rsp_window.cpp Normal file
View file

@ -0,0 +1,29 @@
//
// rsp_window.cpp: RSP view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "rsp_window.h"
RSPWindow::RSPWindow(QAction *toggleAction, bool initiallyVisible)
: ToggleWindow(tr("CEN64D: RSP"), toggleAction, initiallyVisible) {
setLayout(&layout);
layout.addWidget(&disassemblyView, 0, 1);
layout.addWidget(&registerView, 0, 2);
layout.addWidget(&memoryView, 1, 1, 1, 2);
layout.setColumnStretch(1, 25);
layout.setColumnStretch(2, 10);
layout.setRowStretch(0, 20);
layout.setRowStretch(1, 10);
}
RSPWindow::~RSPWindow() {
}

34
debugger/rsp_window.h Normal file
View file

@ -0,0 +1,34 @@
//
// rsp_window.h: RSP view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef RSP_WINDOW_H
#define RSP_WINDOW_H
#include <QGridLayout>
#include "disassembly_view.h"
#include "memory_view.h"
#include "register_view.h"
#include "toggle_window.h"
class RSPWindow : public ToggleWindow {
Q_OBJECT
QGridLayout layout;
DisassemblyView disassemblyView;
MemoryView memoryView;
RegisterView registerView;
public:
explicit RSPWindow(QAction *toggleAction, bool initiallyVisible);
~RSPWindow();
};
#endif

View file

@ -0,0 +1,46 @@
//
// toggle_window.cpp: Toggle-able window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "toggle_window.h"
ToggleWindow::ToggleWindow(const QString &windowTitle,
QAction *toggleAction, bool initiallyVisible) : toggleAction(toggleAction) {
setWindowTitle(windowTitle);
// Create states and connect signals to slots.
windowHiddenState.addTransition(toggleAction,
SIGNAL(triggered()), &windowExposedState);
windowExposedState.addTransition(toggleAction,
SIGNAL(triggered()), &windowHiddenState);
QObject::connect(&windowHiddenState, SIGNAL(entered()), this, SLOT(hide()));
QObject::connect(&windowExposedState, SIGNAL(entered()), this, SLOT(show()));
if (toggleAction->isCheckable())
toggleAction->setChecked(initiallyVisible);
// Setup the state machine.
windowMachine.addState(&windowHiddenState);
windowMachine.addState(&windowExposedState);
windowMachine.setInitialState(initiallyVisible
? &windowExposedState
: &windowHiddenState);
windowMachine.start();
}
ToggleWindow::~ToggleWindow() {
}
void ToggleWindow::closeEvent(QCloseEvent *event) {
toggleAction->trigger();
event->accept();
}

38
debugger/toggle_window.h Normal file
View file

@ -0,0 +1,38 @@
//
// toggle_window.h: Toggle-able window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef TOGGLE_WINDOW_H
#define TOGGLE_WINDOW_H
#include <QAction>
#include <QCloseEvent>
#include <QState>
#include <QStateMachine>
#include <QWidget>
class ToggleWindow : public QWidget {
Q_OBJECT
QAction *toggleAction;
QStateMachine windowMachine;
QState windowHiddenState;
QState windowExposedState;
virtual void closeEvent(QCloseEvent *event);
public:
explicit ToggleWindow(const QString &windowTitle,
QAction *toggleAction, bool initiallyVisible);
~ToggleWindow();
};
#endif

View file

@ -0,0 +1,29 @@
//
// vr4300_window.cpp: VR4300 view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#include "vr4300_window.h"
VR4300Window::VR4300Window(QAction *toggleAction, bool initiallyVisible)
: ToggleWindow(tr("CEN64D: VR4300"), toggleAction, initiallyVisible) {
setLayout(&layout);
layout.addWidget(&disassemblyView, 0, 1);
layout.addWidget(&registerView, 0, 2);
layout.addWidget(&memoryView, 1, 1, 1, 2);
layout.setColumnStretch(1, 25);
layout.setColumnStretch(2, 10);
layout.setRowStretch(0, 20);
layout.setRowStretch(1, 10);
}
VR4300Window::~VR4300Window() {
}

34
debugger/vr4300_window.h Normal file
View file

@ -0,0 +1,34 @@
//
// vr4300_window.h: VR4300 view window.
//
// CEN64D: Cycle-Accurate Nintendo 64 Debugger
// Copyright (C) 2014, Tyler J. Stachecki.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//
#ifndef VR4300_WINDOW_H
#define VR4300_WINDOW_H
#include <QGridLayout>
#include "disassembly_view.h"
#include "memory_view.h"
#include "register_view.h"
#include "toggle_window.h"
class VR4300Window : public ToggleWindow {
Q_OBJECT
QGridLayout layout;
DisassemblyView disassemblyView;
MemoryView memoryView;
RegisterView registerView;
public:
explicit VR4300Window(QAction *toggleAction, bool initiallyVisible);
~VR4300Window();
};
#endif