mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-01 09:45:25 +00:00
Adding a goto to the memory debugger
This commit is contained in:
@@ -19,7 +19,6 @@ void usage(char *bin)
|
||||
void parseArguments(int argc, char **argv, SNES &snes)
|
||||
{
|
||||
while (true) {
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{"cpu", no_argument, 0, 'c' },
|
||||
@@ -57,6 +56,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
QApplication app(argc, argv);
|
||||
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
||||
Renderer::QtSFML renderer(600, 800);
|
||||
SNES snes(std::make_shared<Memory::MemoryBus>(), argv[1], renderer);
|
||||
renderer.createWindow(snes, 60);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <QtWidgets/QInputDialog>
|
||||
#include <QtWidgets/QSpinBox>
|
||||
#include "MemoryViewer.hpp"
|
||||
#include "../SNES.hpp"
|
||||
#include "../Utility/Utility.hpp"
|
||||
@@ -58,7 +60,6 @@ void MemoryViewerModel::setMemory(std::shared_ptr<Ram> memory)
|
||||
emit this->layoutChanged();
|
||||
}
|
||||
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
MemoryViewer::MemoryViewer(ComSquare::SNES &snes) :
|
||||
@@ -77,6 +78,7 @@ namespace ComSquare::Debugger
|
||||
this->_ui.tabs->addTab("&SRam");
|
||||
this->_ui.tabs->addTab("&Rom");
|
||||
// this->_ui.tabs->addTab("&VRam");
|
||||
QMainWindow::connect(this->_ui.actionGoto, &QAction::triggered, this, &MemoryViewer::gotoAddr);
|
||||
QObject::connect(this->_ui.tabs, &QTabBar::currentChanged, this, &MemoryViewer::changeRam);
|
||||
this->show();
|
||||
}
|
||||
@@ -99,4 +101,28 @@ namespace ComSquare::Debugger
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MemoryViewer::gotoAddr()
|
||||
{
|
||||
QInputDialog dialog(this, Qt::WindowFlags());
|
||||
dialog.setWindowTitle("Go to:");
|
||||
dialog.setLabelText("Address");
|
||||
dialog.setIntRange(0, 0xFFFFFF);
|
||||
dialog.setIntValue(0);
|
||||
dialog.setIntStep(1);
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
QSpinBox *spinbox = dialog.findChild<QSpinBox*>();
|
||||
spinbox->setDisplayIntegerBase(16);
|
||||
QFont font = spinbox->font();
|
||||
font.setCapitalization(QFont::AllUppercase);
|
||||
spinbox->setFont(font);
|
||||
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
long value = std::strtol(spinbox->text().toStdString().c_str(), nullptr, 16);
|
||||
QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F);
|
||||
this->_ui.tableView->scrollTo(index);
|
||||
this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,8 @@ namespace ComSquare
|
||||
public:
|
||||
//! @brief Callback called when a memory tab is selected.
|
||||
void changeRam(int id);
|
||||
//! @brief Create a popup asking you where you want to jump to.
|
||||
void gotoAddr();
|
||||
|
||||
explicit MemoryViewer(SNES &snes);
|
||||
MemoryViewer(const MemoryViewer &) = delete;
|
||||
|
||||
+33
-3
@@ -19,6 +19,9 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabBar" name="tabs" native="true">
|
||||
<property name="minimumSize">
|
||||
@@ -29,12 +32,39 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionGoto"/>
|
||||
</widget>
|
||||
<action name="actionGoto">
|
||||
<property name="text">
|
||||
<string>Goto</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Go to an address</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+G</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QTabBar</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qtabbar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../resources/appResources.qrc"/>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user