NES: fix tracelogger for first instruction of NMI or IRQ. also make it obviously indicate that an NMI or IRQ has occurred

This commit is contained in:
goyuken 2014-02-12 22:01:23 +00:00
parent 17f17a02fd
commit 4ada3b4973
2 changed files with 30 additions and 33 deletions

View File

@ -548,40 +548,40 @@ namespace BizHawk.Emulation.Cores.Components.M6502
bool booltemp;
int tempint;
int lo, hi;
public Action FetchCallback;
public Action<string> TraceCallback;
void Fetch1()
{
my_iflag = FlagI;
FlagI = iflag_pending;
if (!branch_irq_hack)
{
if (FetchCallback != null)
FetchCallback();
my_iflag = FlagI;
FlagI = iflag_pending;
if (!branch_irq_hack)
interrupt_pending = false;
if (NMI)
{
interrupt_pending = false;
if (NMI)
{
ea = NMIVector;
opcode = VOP_NMI;
NMI = false;
mi = 0;
ExecuteOneRetry();
return;
}
else if (IRQ && !my_iflag)
{
ea = IRQVector;
opcode = VOP_IRQ;
mi = 0;
ExecuteOneRetry();
return;
}
if (TraceCallback != null)
TraceCallback("====NMI====");
ea = NMIVector;
opcode = VOP_NMI;
NMI = false;
mi = 0;
ExecuteOneRetry();
return;
}
else if (IRQ && !my_iflag)
{
if (TraceCallback != null)
TraceCallback("====IRQ====");
ea = IRQVector;
opcode = VOP_IRQ;
mi = 0;
ExecuteOneRetry();
return;
}
Fetch1_Real();
}
Fetch1_Real();
}
void Fetch1_Real()
{
rdy_freeze = !RDY;
@ -590,6 +590,8 @@ namespace BizHawk.Emulation.Cores.Components.M6502
if (debug) Console.WriteLine(State());
branch_irq_hack = false;
if (OnExecFetch != null) OnExecFetch(PC);
if (TraceCallback != null)
TraceCallback(State());
opcode = ReadMemory(PC++);
mi = -1;
}

View File

@ -151,13 +151,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//cpu = new MOS6502X_CPP((h) => DisposeList.Add(h));
//cpu = new MOS6502XDouble((h) => DisposeList.Add(h));
cpu.SetCallbacks(ReadMemory, ReadMemory, PeekMemory, WriteMemory, (h) => DisposeList.Add(h));
cpu.FetchCallback = () =>
{
if (CoreComm.Tracer.Enabled)
{
CoreComm.Tracer.Put(cpu.TraceState());
}
};
cpu.TraceCallback = (s) => { if (CoreComm.Tracer.Enabled) CoreComm.Tracer.Put(s); };
cpu.BCD_Enabled = false;
cpu.OnExecFetch = ExecFetch;
ppu = new PPU(this);