NES Debugger: fixed disassembler to print addresses correctly

This commit is contained in:
taotao54321 2012-03-10 19:42:20 +00:00
parent c6fcda4418
commit 3687b8d803
1 changed files with 16 additions and 4 deletions

View File

@ -19,9 +19,15 @@ namespace BizHawk.MultiClient
int defaultHeight; int defaultHeight;
NES Nes; NES Nes;
private struct DisasmOp
{
public int size;
public string mnemonic;
public DisasmOp(int s, string m) { size = s; mnemonic = m; }
}
int pc; int pc;
int addr; int addr;
List<string> lines = new List<string>(); List<DisasmOp> lines = new List<DisasmOp>();
public NESDebugger() public NESDebugger()
{ {
@ -67,7 +73,7 @@ namespace BizHawk.MultiClient
{ {
int advance; int advance;
string line = Nes.cpu.Disassemble((ushort)a, out advance); string line = Nes.cpu.Disassemble((ushort)a, out advance);
lines.Add(line); lines.Add(new DisasmOp(advance, line));
a += advance; a += advance;
if (a > ADDR_MAX) break; if (a > ADDR_MAX) break;
} }
@ -111,12 +117,18 @@ namespace BizHawk.MultiClient
text = ""; text = "";
if (column == 0) if (column == 0)
{ {
text = String.Format("{0:X4}", index); if (addr <= index && index < addr+lines.Count)
{
int a = addr;
for (int i = 0; i < index-addr; ++i)
a += lines[i].size;
text = String.Format("{0:X4}", a);
}
} }
else if (column == 1) else if (column == 1)
{ {
if (addr <= index && index < addr+lines.Count) if (addr <= index && index < addr+lines.Count)
text = lines[index-addr]; text = lines[index-addr].mnemonic;
} }
} }