added workaround for highlighting non-disassembled code

This commit is contained in:
thrust26 2021-01-01 11:42:34 +01:00
parent ec8beeac63
commit 7cb3c46704
1 changed files with 21 additions and 0 deletions

View File

@ -75,6 +75,27 @@ void RomWidget::loadConfig()
// Update romlist to point to current PC (if it has changed) // Update romlist to point to current PC (if it has changed)
int pcline = cart.addressToLine(dbg.cpuDebug().pc()); int pcline = cart.addressToLine(dbg.cpuDebug().pc());
if(pcline < 0)
{
// If tentative code detection is disabled, the code where PC points to is
// not disassembled the first time it is executed. Therefore the rom list
// highlight would never be updated!
// The following code tries to fix that and moves the highlight to the
// line following the last know dissassembled code.
const CpuState& oldCpuState = static_cast<const CpuState&>(dbg.cpuDebug().getOldState());
int oldPc = oldCpuState.PC;
if(dbg.cpuDebug().pc() > oldPc && dbg.cpuDebug().pc() - oldPc <= 3)
// we assume the code moved forward by one instruction
pcline = cart.addressToLine(oldPc);
else
// code jumped, try to find previous line
for(int i = 1; i <= 3 && pcline < 0; ++i)
pcline = cart.addressToLine(dbg.cpuDebug().pc() - i);
if(pcline >= 0)
pcline++;
}
if(pcline >= 0 && pcline != myRomList->getHighlighted()) if(pcline >= 0 && pcline != myRomList->getHighlighted())
myRomList->setHighlighted(pcline); myRomList->setHighlighted(pcline);