From 6d96109ff7882d5f59bbced2b6a4d7d30cf3e95c Mon Sep 17 00:00:00 2001 From: Nick Renieris Date: Wed, 1 Apr 2020 01:02:24 +0300 Subject: [PATCH] Qt/Debugger: Don't move entire list if it's not needed With 4 buffer spaces at the bottom. --- rpcs3/rpcs3qt/debugger_list.cpp | 41 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/rpcs3/rpcs3qt/debugger_list.cpp b/rpcs3/rpcs3qt/debugger_list.cpp index d14a349c3985..bc540101e4a3 100644 --- a/rpcs3/rpcs3qt/debugger_list.cpp +++ b/rpcs3/rpcs3qt/debugger_list.cpp @@ -58,22 +58,31 @@ void debugger_list::ShowAddress(u32 addr) return m_breakpoint_handler->HasBreakpoint(pc); }; - if (xgui_settings->GetValue(gui::d_centerPC).toBool()) - { - m_pc = GetCenteredAddress(addr); - } - else + const bool center_pc = xgui_settings->GetValue(gui::d_centerPC).toBool(); + + // How many spaces addr can move down without us needing to move the entire view + const u32 addr_margin = (m_item_count / (center_pc ? 2 : 1) - 4); // 4 is just a buffer of 4 spaces at the bottom + + if (s32(addr) - m_pc > addr_margin * 4) // 4 is the number of bytes in each instruction { - m_pc = addr; + if (center_pc) + { + m_pc = GetCenteredAddress(addr); + } + else + { + m_pc = addr; + } } const auto cpu = this->cpu.lock(); if (!cpu) { - for (uint i = 0; i < m_item_count; ++i, m_pc += 4) + u32 pc = m_pc; + for (uint i = 0; i < m_item_count; ++i, pc += 4) { - item(i)->setText(qstr(fmt::format(" [%08x] illegal address", m_pc))); + item(i)->setText(qstr(fmt::format(" [%08x] illegal address", pc))); } } else @@ -83,25 +92,27 @@ void debugger_list::ShowAddress(u32 addr) const u32 address_limits = (is_spu ? 0x3fffc : ~3); m_pc &= address_limits; m_disasm->offset = vm::get_super_ptr(cpu_offset); - for (uint i = 0, count = 4; isetText((IsBreakpoint(m_pc) ? ">> " : " ") + qstr(fmt::format("[%08x] illegal address", m_pc))); + item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(fmt::format("[%08x] illegal address", pc))); count = 4; continue; } - count = m_disasm->disasm(m_disasm->dump_pc = m_pc); + count = m_disasm->disasm(m_disasm->dump_pc = pc); - item(i)->setText((IsBreakpoint(m_pc) ? ">> " : " ") + qstr(m_disasm->last_opcode)); + item(i)->setText((IsBreakpoint(pc) ? ">> " : " ") + qstr(m_disasm->last_opcode)); - if (cpu->is_paused() && m_pc == GetPc()) + if (cpu->is_paused() && pc == GetPc()) { item(i)->setForeground(m_text_color_pc); item(i)->setBackground(m_color_pc); } - else if (IsBreakpoint(m_pc)) + else if (IsBreakpoint(pc)) { item(i)->setForeground(m_text_color_bp); item(i)->setBackground(m_color_bp);