diff --git a/src/duckstation-qt/cheatmanagerdialog.cpp b/src/duckstation-qt/cheatmanagerdialog.cpp index 736300f70..56c4d68b3 100644 --- a/src/duckstation-qt/cheatmanagerdialog.cpp +++ b/src/duckstation-qt/cheatmanagerdialog.cpp @@ -644,7 +644,7 @@ void CheatManagerDialog::addToWatchClicked() void CheatManagerDialog::addManualWatchAddressClicked() { - std::optional address = QtUtils::PromptForAddress(this, windowTitle(), tr("Enter memory address:")); + std::optional address = QtUtils::PromptForAddress(this, windowTitle(), tr("Enter manual address:"), false); if (!address.has_value()) return; diff --git a/src/duckstation-qt/debuggerwindow.cpp b/src/duckstation-qt/debuggerwindow.cpp index 0220e3c87..44c37282d 100644 --- a/src/duckstation-qt/debuggerwindow.cpp +++ b/src/duckstation-qt/debuggerwindow.cpp @@ -104,7 +104,7 @@ void DebuggerWindow::onGoToPCTriggered() void DebuggerWindow::onGoToAddressTriggered() { std::optional address = - QtUtils::PromptForAddress(this, windowTitle(), tr("Enter code address:")); + QtUtils::PromptForAddress(this, windowTitle(), tr("Enter code address:"), true); if (!address.has_value()) return; @@ -114,7 +114,7 @@ void DebuggerWindow::onGoToAddressTriggered() void DebuggerWindow::onDumpAddressTriggered() { std::optional address = - QtUtils::PromptForAddress(this, windowTitle(), tr("Enter memory address:")); + QtUtils::PromptForAddress(this, windowTitle(), tr("Enter memory address:"), false); if (!address.has_value()) return; @@ -129,7 +129,7 @@ void DebuggerWindow::onFollowAddressTriggered() void DebuggerWindow::onAddBreakpointTriggered() { std::optional address = - QtUtils::PromptForAddress(this, windowTitle(), tr("Enter code address:")); + QtUtils::PromptForAddress(this, windowTitle(), tr("Enter code address:") , true); if (!address.has_value()) return; diff --git a/src/duckstation-qt/qtutils.cpp b/src/duckstation-qt/qtutils.cpp index c68b63e4a..74cac9393 100644 --- a/src/duckstation-qt/qtutils.cpp +++ b/src/duckstation-qt/qtutils.cpp @@ -737,7 +737,7 @@ void FillComboBoxWithEmulationSpeeds(QComboBox* cb) } } -std::optional PromptForAddress(QWidget* parent, const QString& title, const QString& label) +std::optional PromptForAddress(QWidget* parent, const QString& title, const QString& label, bool code) { const QString address_str( QInputDialog::getText(parent, title, qApp->translate("DebuggerWindow", "Enter memory address:"))); @@ -748,16 +748,16 @@ std::optional PromptForAddress(QWidget* parent, const QString& title, uint address; if (address_str.startsWith("0x")) address = address_str.midRef(2).toUInt(&ok, 16); - else if (address_str[0] == '0' && address_str.length() > 1) - address = address_str.midRef(1).toUInt(&ok, 8); else - address = address_str.toUInt(&ok, 10); - + address = address_str.toUInt(&ok, 16); + if ( code == true ) + address = address & 0xFFFFFFFC; //disassembly address should be divisible by 4 so make sure + if (!ok) { QMessageBox::critical( parent, title, - qApp->translate("DebuggerWindow", "Invalid address. It should be in hex (0x12345678) or decimal (12345678)")); + qApp->translate("DebuggerWindow", "Invalid address. It should be in hex (0x12345678 or 12345678)")); return std::nullopt; } diff --git a/src/duckstation-qt/qtutils.h b/src/duckstation-qt/qtutils.h index 77025002a..1e47e8aa5 100644 --- a/src/duckstation-qt/qtutils.h +++ b/src/duckstation-qt/qtutils.h @@ -71,7 +71,7 @@ void FillComboBoxWithMSAAModes(QComboBox* cb); /// Fills a combo box with emulation speed options. void FillComboBoxWithEmulationSpeeds(QComboBox* cb); -/// Prompts for an address in decimal, octal, or hex. -std::optional PromptForAddress(QWidget* parent, const QString& title, const QString& label); +/// Prompts for an address in hex. +std::optional PromptForAddress(QWidget* parent, const QString& title, const QString& label, bool code); } // namespace QtUtils \ No newline at end of file diff --git a/src/duckstation-qt/translations/duckstation-qt_fr.ts b/src/duckstation-qt/translations/duckstation-qt_fr.ts index 3d8f7a8c6..ba5747d1e 100644 --- a/src/duckstation-qt/translations/duckstation-qt_fr.ts +++ b/src/duckstation-qt/translations/duckstation-qt_fr.ts @@ -2156,7 +2156,7 @@ Cet avertissement ne sera affiché qu'une seule fois. - Invalid address. It should be in hex (0x12345678) or decimal (12345678) + Invalid address. It should be in hex (0x12345678 or 12345678) diff --git a/src/duckstation-qt/translations/duckstation-qt_pt-br.ts b/src/duckstation-qt/translations/duckstation-qt_pt-br.ts index c1ea791ce..fcdaa5c68 100644 --- a/src/duckstation-qt/translations/duckstation-qt_pt-br.ts +++ b/src/duckstation-qt/translations/duckstation-qt_pt-br.ts @@ -2252,8 +2252,8 @@ This warning will only be shown once. - Invalid address. It should be in hex (0x12345678) or decimal (12345678) - Endereço inválido! Valores devem ser: hexa (0x12345678) ou decimal (12345678) + Invalid address. It should be in hex (0x12345678 or 12345678) + Endereço inválido! Valores devem ser: hexa (0x12345678 ou 12345678) diff --git a/src/duckstation-qt/translations/duckstation-qt_zh-cn.ts b/src/duckstation-qt/translations/duckstation-qt_zh-cn.ts index a0e2c5265..ba5c428ea 100644 --- a/src/duckstation-qt/translations/duckstation-qt_zh-cn.ts +++ b/src/duckstation-qt/translations/duckstation-qt_zh-cn.ts @@ -2213,8 +2213,8 @@ This warning will only be shown once. - Invalid address. It should be in hex (0x12345678) or decimal (12345678) - 无效的地址。它应该是十六进制(0x12345678)或十进制(12345678) + Invalid address. It should be in hex (0x12345678 or 12345678) + 无效的地址。它应该是十六进制(0x12345678或12345678)