Debugger - diassembler - an attempt to implement scrolling up (only works on small increment for now), but busted, arg

This commit is contained in:
adelikat 2014-12-20 20:33:54 +00:00
parent 8fb7d3ea9d
commit 1d0b623d88
3 changed files with 75 additions and 10 deletions

View File

@ -277,6 +277,7 @@
this.DisassemblerView.UseCompatibleStateImageBehavior = false;
this.DisassemblerView.UseCustomBackground = true;
this.DisassemblerView.View = System.Windows.Forms.View.Details;
this.DisassemblerView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.DisassemblerView_Scroll);
//
// Address
//

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk
{
@ -40,24 +41,27 @@ namespace BizHawk.Client.EmuHawk
if (CanDisassemble)
{
DisassemblerView.BlazingFast = true;
currentDisassemblerAddress = PC;
Disassemble(DISASM_LINE_COUNT);
DisassemblerView.ensureVisible(BusMaxValue);
DisassemblerView.ensureVisible(PC);
DisassemblerView.ensureVisible((int)PC);
DisassemblerView.Refresh();
DisassemblerView.BlazingFast = false;
}
}
uint currentDisassemblerAddress = 0;
private void Disassemble(int line_count)
{
DisassemblyLines.Clear();
int a = PC;
uint a = currentDisassemblerAddress;
for (int i = 0; i < line_count; ++i)
{
int advance;
string line = Disassembler.Disassemble(MemoryDomains.SystemBus, (ushort)a, out advance);
DisassemblyLines.Add(new DisasmOp(advance, line));
a += advance;
a += (uint)advance;
if (a > BusMaxValue)
{
break;
@ -70,10 +74,11 @@ namespace BizHawk.Client.EmuHawk
text = "";
if (column == 0)
{
if (PC <= index && index < PC + DisassemblyLines.Count)
//if (PC <= index && index < PC + DisassemblyLines.Count)
if (currentDisassemblerAddress <= index && index < currentDisassemblerAddress + DisassemblyLines.Count)
{
int a = PC;
for (int i = 0; i < index - PC; ++i)
int a = (int)currentDisassemblerAddress;
for (int i = 0; i < index - currentDisassemblerAddress; ++i)
{
a += DisassemblyLines[i].Size;
}
@ -83,9 +88,10 @@ namespace BizHawk.Client.EmuHawk
}
else if (column == 1)
{
if (PC <= index && index < PC + DisassemblyLines.Count)
//if (PC <= index && index < PC + DisassemblyLines.Count)
if (currentDisassemblerAddress <= index && index < currentDisassemblerAddress + DisassemblyLines.Count)
{
text = DisassemblyLines[index - PC].Mnemonic;
text = DisassemblyLines[index - (int)currentDisassemblerAddress].Mnemonic;
}
}
}
@ -97,5 +103,63 @@ namespace BizHawk.Client.EmuHawk
color = Color.LightCyan;
}
}
private void DecrementCurrentAddress()
{
uint newaddress = currentDisassemblerAddress;
while (true)
{
int bytestoadvance;
Disassembler.Disassemble(MemoryDomains.SystemBus, newaddress, out bytestoadvance);
if (newaddress + bytestoadvance == currentDisassemblerAddress)
{
break;
}
newaddress--;
// Just in case
if (currentDisassemblerAddress - newaddress > 5)
{
newaddress = currentDisassemblerAddress - 1;
break;
}
}
currentDisassemblerAddress = newaddress;
}
private void IncrementCurrentAddress()
{
currentDisassemblerAddress++;
}
private void DisassemblerView_Scroll(object sender, ScrollEventArgs e)
{
if (e.Type == ScrollEventType.SmallIncrement)
{
IncrementCurrentAddress();
Disassemble(DISASM_LINE_COUNT);
}
if (e.Type == ScrollEventType.SmallDecrement)
{
DecrementCurrentAddress();
Disassemble(DISASM_LINE_COUNT);
}
//int oldv = e.OldValue;
//int newv = e.NewValue;
//int diff = oldv - newv;
//if (e.OldValue > e.NewValue) // Scrolled Up
//{
// Disassemble(DISASM_LINE_COUNT, PC - (e.OldValue - e.NewValue));
//}
//else if (e.OldValue < e.NewValue) // Scrolled Down
//{
// Disassemble(DISASM_LINE_COUNT, PC - (e.OldValue - e.NewValue));
//}
//}
}
}
}

View File

@ -20,10 +20,10 @@ namespace BizHawk.Client.EmuHawk
private MemoryDomainList MemoryDomains { get { return MemoryDomainSource.MemoryDomains; } }
private int PC
private uint PC
{
// TODO: is this okay for N64?
get { return (int)Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].Value; }
get { return (uint)Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].Value; }
}
#region Implementation checking