From 6074f6f3c0c34833665b9825d5737b871d55291e Mon Sep 17 00:00:00 2001 From: Brendan Fletcher Date: Tue, 9 Jul 2024 02:53:43 -0400 Subject: [PATCH] Add disassembler option for tabs between the opcode and operands. Implements #462. --- gui/qt/debugger/disasm.cpp | 3 ++- gui/qt/debugger/disasm.h | 15 ++++++++------- gui/qt/mainwindow.cpp | 4 +++- gui/qt/mainwindow.h | 2 ++ gui/qt/mainwindow.ui | 16 +++++++++++++--- gui/qt/settings.cpp | 10 ++++++++++ 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/gui/qt/debugger/disasm.cpp b/gui/qt/debugger/disasm.cpp index 87c85fa89..d31e00b53 100644 --- a/gui/qt/debugger/disasm.cpp +++ b/gui/qt/debugger/disasm.cpp @@ -148,6 +148,7 @@ static bool disasmPut(struct zdis_ctx *ctx, enum zdis_put kind, int32_t val, boo *disasm.cur += static_cast(val); break; case ZDIS_PUT_MNE_SEP: + disasm.instr.operands = disasm.tab ? '\t' : ' '; disasm.cur = &disasm.instr.operands; break; case ZDIS_PUT_ARG_SEP: @@ -188,7 +189,7 @@ void disasmGet(bool useCpuMode) { static char tmpbuf[20]; size_t size = cpu.registers.PC - static_cast(disasm.base); disasm.instr.data = disasm.instr.data.substr(0, size * 2); - disasm.instr.operands.clear(); + disasm.instr.operands = disasm.tab ? '\t' : ' '; int precision; if (size % 3 == 0) { size /= 3; diff --git a/gui/qt/debugger/disasm.h b/gui/qt/debugger/disasm.h index c1f7df468..1f520fa51 100644 --- a/gui/qt/debugger/disasm.h +++ b/gui/qt/debugger/disasm.h @@ -29,13 +29,14 @@ typedef struct { } highlight; int32_t base; int32_t next; - bool adl; - bool il; - bool uppercase; - bool implicit; - bool bytes; - bool addr; - bool bold_sym; + bool adl : 1; + bool il : 1; + bool uppercase : 1; + bool implicit : 1; + bool bytes : 1; + bool addr : 1; + bool bold_sym : 1; + bool tab : 1; map_t map; map_value_t reverse; std::string comma; diff --git a/gui/qt/mainwindow.cpp b/gui/qt/mainwindow.cpp index 285dbdc0e..a34a428a9 100644 --- a/gui/qt/mainwindow.cpp +++ b/gui/qt/mainwindow.cpp @@ -188,6 +188,7 @@ MainWindow::MainWindow(CEmuOpts &cliOpts, QWidget *p) : QMainWindow(p), ui(new U connect(ui->checkCharging, &QCheckBox::toggled, this, &MainWindow::batterySetCharging); connect(ui->sliderBattery, &QSlider::valueChanged, this, &MainWindow::batterySet); connect(ui->checkAddSpace, &QCheckBox::toggled, this, &MainWindow::setDebugDisasmSpace); + connect(ui->checkOperandTab, &QCheckBox::toggled, this, &MainWindow::setDebugDisasmTab); connect(ui->checkDisableSoftCommands, &QCheckBox::toggled, this, &MainWindow::setDebugSoftCommands); connect(ui->buttonZero, &QPushButton::clicked, this, &MainWindow::debugZeroCycles); connect(ui->buttonCertID, &QPushButton::clicked, this, &MainWindow::setCalcId); @@ -585,6 +586,7 @@ MainWindow::MainWindow(CEmuOpts &cliOpts, QWidget *p) : QMainWindow(p), ui(new U ui->checkSaveRestore->setChecked(m_config->value(SETTING_SAVE_ON_CLOSE, true).toBool()); setFont(m_config->value(SETTING_DEBUGGER_TEXT_SIZE, 9).toInt()); setDebugDisasmSpace(m_config->value(SETTING_DEBUGGER_DISASM_SPACE, false).toBool()); + setDebugDisasmTab(m_config->value(SETTING_DEBUGGER_DISASM_TAB, false).toBool()); setDebugDisasmAddrCol(m_config->value(SETTING_DEBUGGER_ADDR_COL, true).toBool()); setDebugDisasmDataCol(m_config->value(SETTING_DEBUGGER_DATA_COL, true).toBool()); setDebugDisasmBoldSymbols(m_config->value(SETTING_DEBUGGER_BOLD_SYMBOLS, false).toBool()); @@ -2442,7 +2444,7 @@ void MainWindow::disasmLine() { } sit++; } else { - line = QString(QStringLiteral("%1 %2%3%4 %5 %6 %7")) + line = QString(QStringLiteral("%1 %2%3%4 %5 %6%7")) .arg(disasm.addr ? int2hex(static_cast(disasm.base), 6) : QString(), disasm.highlight.watchR ? QStringLiteral("R") : QStringLiteral(" "), disasm.highlight.watchW ? QStringLiteral("W") : QStringLiteral(" "), diff --git a/gui/qt/mainwindow.h b/gui/qt/mainwindow.h index adeaae8ce..9b2e87b58 100644 --- a/gui/qt/mainwindow.h +++ b/gui/qt/mainwindow.h @@ -459,6 +459,7 @@ class MainWindow : public QMainWindow { void setDebugDisasmDataCol(bool state); void setDebugDisasmAddrCol(bool state); void setDebugDisasmSpace(bool state); + void setDebugDisasmTab(bool state); void setDebugDisasmImplict(bool state); void setDebugDisasmUppercase(bool state); void setDebugDisasmBoldSymbols(bool state); @@ -718,6 +719,7 @@ class MainWindow : public QMainWindow { // Settings definitions static const QString SETTING_DEBUGGER_TEXT_SIZE; static const QString SETTING_DEBUGGER_DISASM_SPACE; + static const QString SETTING_DEBUGGER_DISASM_TAB; static const QString SETTING_DEBUGGER_RESTORE_ON_OPEN; static const QString SETTING_DEBUGGER_SAVE_ON_CLOSE; static const QString SETTING_DEBUGGER_RESET_OPENS; diff --git a/gui/qt/mainwindow.ui b/gui/qt/mainwindow.ui index e17087bdd..59bd343ae 100644 --- a/gui/qt/mainwindow.ui +++ b/gui/qt/mainwindow.ui @@ -9791,7 +9791,7 @@ QPushButton:pressed { Disassembly - + Qt::NoFocus @@ -9812,12 +9812,22 @@ QPushButton:pressed { + + + Qt::NoFocus + + + Tab between opcode / operands + + + + Qt::NoFocus - Opcode / operand space + Space between operands @@ -9828,7 +9838,7 @@ QPushButton:pressed { - + Show address column diff --git a/gui/qt/settings.cpp b/gui/qt/settings.cpp index 7ba16fc89..36565240c 100644 --- a/gui/qt/settings.cpp +++ b/gui/qt/settings.cpp @@ -37,6 +37,7 @@ const QString MainWindow::SETTING_DEBUGGER_RESET_OPENS = QStringLiteral("De const QString MainWindow::SETTING_DEBUGGER_ENABLE_SOFT = QStringLiteral("Debugger/enable_soft_commands"); const QString MainWindow::SETTING_DEBUGGER_BOLD_SYMBOLS = QStringLiteral("Debugger/disasm_bold_symbols"); const QString MainWindow::SETTING_DEBUGGER_DISASM_SPACE = QStringLiteral("Debugger/disasm_add_space"); +const QString MainWindow::SETTING_DEBUGGER_DISASM_TAB = QStringLiteral("Debugger/disasm_use_tab"); const QString MainWindow::SETTING_DEBUGGER_ADDR_COL = QStringLiteral("Debugger/disasm_addr_column"); const QString MainWindow::SETTING_DEBUGGER_DATA_COL = QStringLiteral("Debugger/disasm_data_column"); const QString MainWindow::SETTING_DEBUGGER_IMPLICT = QStringLiteral("Debugger/disasm_implict"); @@ -356,6 +357,15 @@ void MainWindow::setDebugDisasmSpace(bool state) { } } +void MainWindow::setDebugDisasmTab(bool state) { + ui->checkOperandTab->setChecked(state); + m_config->setValue(SETTING_DEBUGGER_DISASM_TAB, state); + disasm.tab = state; + if (guiDebug) { + disasmUpdate(); + } +} + void MainWindow::setLcdDma(bool state) { ui->checkDma->setChecked(state); ui->checkGamma->setEnabled(state);