mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
Fix instructions editor, implement preview for to-be-edited instructions
This commit is contained in:
parent
7329fa9cf5
commit
08ebc59db0
2 changed files with 9 additions and 10 deletions
|
@ -18,7 +18,7 @@ extern bool ppu_patch(u32 addr, u32 value);
|
||||||
instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, CPUDisAsm* _disasm, std::function<cpu_thread*()> func)
|
instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, CPUDisAsm* _disasm, std::function<cpu_thread*()> func)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_pc(_pc)
|
, m_pc(_pc)
|
||||||
, m_disasm(_disasm)
|
, m_disasm(_disasm->copy_type_erased())
|
||||||
, m_get_cpu(std::move(func))
|
, m_get_cpu(std::move(func))
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Edit instruction"));
|
setWindowTitle(tr("Edit instruction"));
|
||||||
|
@ -28,7 +28,6 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C
|
||||||
const auto cpu = m_get_cpu();
|
const auto cpu = m_get_cpu();
|
||||||
|
|
||||||
m_cpu_offset = cpu && cpu->id_type() == 2 ? static_cast<spu_thread&>(*cpu).ls : vm::g_sudo_addr;
|
m_cpu_offset = cpu && cpu->id_type() == 2 ? static_cast<spu_thread&>(*cpu).ls : vm::g_sudo_addr;
|
||||||
const QString instruction = qstr(fmt::format("%08x", *reinterpret_cast<be_t<u32>*>(m_cpu_offset + m_pc)));
|
|
||||||
|
|
||||||
QVBoxLayout* vbox_panel(new QVBoxLayout());
|
QVBoxLayout* vbox_panel(new QVBoxLayout());
|
||||||
QHBoxLayout* hbox_panel(new QHBoxLayout());
|
QHBoxLayout* hbox_panel(new QHBoxLayout());
|
||||||
|
@ -43,12 +42,12 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C
|
||||||
|
|
||||||
m_instr = new QLineEdit(this);
|
m_instr = new QLineEdit(this);
|
||||||
m_instr->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
m_instr->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||||
m_instr->setPlaceholderText(instruction);
|
|
||||||
m_instr->setText(instruction);
|
|
||||||
m_instr->setMaxLength(8);
|
m_instr->setMaxLength(8);
|
||||||
m_instr->setMaximumWidth(65);
|
m_instr->setMaximumWidth(65);
|
||||||
|
|
||||||
m_preview = new QLabel("", this);
|
m_disasm->change_mode(cpu_disasm_mode::normal);
|
||||||
|
m_disasm->disasm(m_pc);
|
||||||
|
m_preview = new QLabel(qstr(m_disasm->last_opcode), this);
|
||||||
|
|
||||||
// Layouts
|
// Layouts
|
||||||
vbox_left_panel->addWidget(new QLabel(tr("Address: ")));
|
vbox_left_panel->addWidget(new QLabel(tr("Address: ")));
|
||||||
|
@ -141,12 +140,12 @@ instruction_editor_dialog::instruction_editor_dialog(QWidget *parent, u32 _pc, C
|
||||||
void instruction_editor_dialog::updatePreview() const
|
void instruction_editor_dialog::updatePreview() const
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
ulong opcode = m_instr->text().toULong(&ok, 16);
|
const be_t<u32> opcode{static_cast<u32>(m_instr->text().toULong(&ok, 16))};
|
||||||
Q_UNUSED(opcode)
|
m_disasm->change_ptr(reinterpret_cast<const u8*>(&opcode) - std::intptr_t{m_pc});
|
||||||
|
|
||||||
if (ok)
|
if (ok && m_disasm->disasm(m_pc))
|
||||||
{
|
{
|
||||||
m_preview->setText(tr("Preview disabled."));
|
m_preview->setText(qstr(m_disasm->last_opcode));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ class instruction_editor_dialog : public QDialog
|
||||||
private:
|
private:
|
||||||
u32 m_pc;
|
u32 m_pc;
|
||||||
u8* m_cpu_offset;
|
u8* m_cpu_offset;
|
||||||
CPUDisAsm* m_disasm;
|
std::shared_ptr<CPUDisAsm> m_disasm; // shared in order to allow an incomplete type
|
||||||
QLineEdit* m_instr;
|
QLineEdit* m_instr;
|
||||||
QLabel* m_preview;
|
QLabel* m_preview;
|
||||||
QCheckBox* m_apply_for_spu_group = nullptr;
|
QCheckBox* m_apply_for_spu_group = nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue