diff --git a/sources/Debugger/MemoryViewer.cpp b/sources/Debugger/MemoryViewer.cpp index bb4eee8..10091fb 100644 --- a/sources/Debugger/MemoryViewer.cpp +++ b/sources/Debugger/MemoryViewer.cpp @@ -79,6 +79,7 @@ namespace ComSquare::Debugger this->_ui.tabs->addTab("&Rom"); // this->_ui.tabs->addTab("&VRam"); QMainWindow::connect(this->_ui.actionGoto, &QAction::triggered, this, &MemoryViewer::gotoAddr); + QMainWindow::connect(this->_ui.actionGoto_Absolute, &QAction::triggered, this, &MemoryViewer::gotoAbsoluteAddr); QObject::connect(this->_ui.tabs, &QTabBar::currentChanged, this, &MemoryViewer::changeRam); this->show(); } @@ -102,22 +103,40 @@ namespace ComSquare::Debugger } } - void MemoryViewer::gotoAddr() + { + this->_internalGoto(false); + } + + void MemoryViewer::gotoAbsoluteAddr() + { + this->_internalGoto(true); + } + + void MemoryViewer::_internalGoto(bool isAbsolute) { QDialog dialog(this); + dialog.setWindowModality(Qt::WindowModal); Ui::GotoDialog dialogUI; dialogUI.setupUi(&dialog); QFont font = dialogUI.spinBox->font(); font.setCapitalization(QFont::AllUppercase); dialogUI.spinBox->setFont(font); dialogUI.spinBox->selectAll(); + dialogUI.checkBox->setChecked(isAbsolute); if (dialog.exec() != QDialog::Accepted) return; long value = std::strtol(dialogUI.spinBox->text().toStdString().c_str() + 1, nullptr, 16); + if (dialogUI.checkBox->isChecked()) + this->switchToAddrTab(value); QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F); this->_ui.tableView->scrollTo(index); this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); } + + void MemoryViewer::switchToAddrTab(uint24_t addr) + { + + } } \ No newline at end of file diff --git a/sources/Debugger/MemoryViewer.hpp b/sources/Debugger/MemoryViewer.hpp index d7cb568..1cd6b5b 100644 --- a/sources/Debugger/MemoryViewer.hpp +++ b/sources/Debugger/MemoryViewer.hpp @@ -56,11 +56,18 @@ namespace ComSquare Ui::RamView _ui; //! @brief The Ram visualizer model for QT. MemoryViewerModel _model; + //! @brief Helper function to create the goto dialog. + void _internalGoto(bool isAbsolute); public: + //! @brief Select the memory tab corresponding to a 24 bit address (map the address via the bus). + void switchToAddrTab(uint24_t addr); + //! @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(); + //! @brief Create a popup asking you where you want to jump to with the absolute mode selected. + void gotoAbsoluteAddr(); explicit MemoryViewer(SNES &snes); MemoryViewer(const MemoryViewer &) = delete; diff --git a/ui/ramView.ui b/ui/ramView.ui index 6171f04..2991ca4 100644 --- a/ui/ramView.ui +++ b/ui/ramView.ui @@ -45,6 +45,7 @@ false + @@ -57,6 +58,17 @@ Ctrl+G + + + Goto Absolute + + + Go to an absolute address + + + Ctrl+Shift+G + +