6502: improve tracelog to only disassemble actual opcodes, and also enable it on 2600

This commit is contained in:
goyuken 2012-11-02 22:27:22 +00:00
parent 323caaaff7
commit 6ffd71973a
4 changed files with 12 additions and 3 deletions

View File

@ -38,10 +38,10 @@ namespace BizHawk.Emulation.CPUs.M6502
FlagI = true;
}
public string State()
public string State(bool disassemble = true)
{
int notused;
string a = string.Format("{0:X4} {1:X2} {2} ", PC, PeekMemory(PC), Disassemble(PC, out notused)).PadRight(30);
string a = string.Format("{0:X4} {1:X2} {2} ", PC, PeekMemory(PC), disassemble ? Disassemble(PC, out notused) : "---").PadRight(30);
string b = string.Format("A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5}", A, X, Y, P, S, TotalExecutedCycles);
string val = a + b + " ";
if (FlagN) val = val + "N";
@ -55,6 +55,12 @@ namespace BizHawk.Emulation.CPUs.M6502
return val;
}
public string TraceState()
{
// only disassemble when we're at the beginning of an opcode
return State(opcode == VOP_Fetch1 || Microcode[opcode][mi] >= Uop.End);
}
public const ushort NMIVector = 0xFFFA;
public const ushort ResetVector = 0xFFFC;
public const ushort BRKVector = 0xFFFE;

View File

@ -215,6 +215,8 @@ namespace BizHawk
tia.execute(1);
m6532.timer.tick();
if (CoreInputComm.Tracer.Enabled)
CoreInputComm.Tracer.Put(cpu.TraceState());
cpu.ExecuteOne();
//if (cpu.PendingCycles <= 0)
//{

View File

@ -23,6 +23,7 @@ namespace BizHawk
domains.Add(new MemoryDomain("Main RAM", 128, Endian.Little, addr => ram[addr & 127], (addr, value) => ram[addr & 127] = value));
memoryDomains = domains.AsReadOnly();
CoreOutputComm = new CoreOutputComm();
CoreOutputComm.CpuTraceAvailable = true;
CoreInputComm = new CoreInputComm();
this.rom = rom;
this.game = game;

View File

@ -269,7 +269,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
cpu.IRQ = _irq_apu || board.IRQSignal;
if (CoreInputComm.Tracer.Enabled)
{
CoreInputComm.Tracer.Put(cpu.State());
CoreInputComm.Tracer.Put(cpu.TraceState());
}
cpu.ExecuteOne();
}