From 8e99908c4776c36ab7f3ab4dcbc39cd4074c2524 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sat, 19 Jan 2019 09:23:22 -0600 Subject: [PATCH] SubNESHawk: Add ppu cycle to tracer --- BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs | 9 +++++++-- .../Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs | 2 ++ .../Consoles/Nintendo/SubNESHawk/SubNESHawk.cs | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs index 83d94aad78..2b0965e0ed 100644 --- a/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs +++ b/BizHawk.Emulation.Cores/CPUs/MOS 6502X/MOS6502X.cs @@ -74,7 +74,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 "{0:X4}: {1,-9} {2} ", PC, rawbytes, disasm).PadRight(32), RegisterInfo = string.Format( - "A:{0:X2} X:{1:X2} Y:{2:X2} SP:{4:X2} P:{3:X2} {6}{7}{8}{9}{10}{11}{12}{13} Cy:{5}", + "A:{0:X2} X:{1:X2} Y:{2:X2} SP:{4:X2} P:{3:X2} {6}{7}{8}{9}{10}{11}{12}{13} Cy:{5} PPU-Cy:{15}", A, X, Y, P, S, TotalExecutedCycles, FlagN ? "N" : "n", FlagV ? "V" : "v", @@ -84,7 +84,8 @@ namespace BizHawk.Emulation.Cores.Components.M6502 FlagI ? "I" : "i", FlagZ ? "Z" : "z", FlagC ? "C" : "c", - !RDY ? "R" : "r") + !RDY ? "R" : "r", + ext_ppu_cycle) }; } @@ -120,6 +121,9 @@ namespace BizHawk.Emulation.Cores.Components.M6502 public bool NMI; public bool RDY; + // ppu cycle (used with SubNESHawk) + public int ext_ppu_cycle = 0; + public void SyncState(Serializer ser) { ser.BeginSection("MOS6502X"); @@ -143,6 +147,7 @@ namespace BizHawk.Emulation.Cores.Components.M6502 ser.Sync("interrupt_pending", ref interrupt_pending); ser.Sync("branch_irq_hack", ref branch_irq_hack); ser.Sync("rdy_freeze", ref rdy_freeze); + ser.Sync("ext_ppu_cycle", ref ext_ppu_cycle); ser.EndSection(); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs index 25a5a0b632..ba5b1c0638 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.IEmulator.cs @@ -52,6 +52,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk { subnes.videoProvider.FillFrameBuffer(); current_cycle = 0; + subnes.cpu.ext_ppu_cycle = current_cycle; } _islag = subnes.alt_lag; @@ -86,6 +87,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk } subnes.do_single_step(controller, out pass_new_input, out pass_a_frame); current_cycle++; + subnes.cpu.ext_ppu_cycle = current_cycle; stop_cur_frame |= pass_a_frame; stop_cur_frame |= pass_new_input; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs index 2bbf28d1fb..d74af9ed40 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SubNESHawk/SubNESHawk.cs @@ -36,7 +36,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk ser.Register(subnes.videoProvider); ser.Register(subnes.magicSoundProvider); - _tracer = new TraceBuffer { Header = subnes.cpu.TraceHeader }; + _tracer = new TraceBuffer { Header = "6502: PC, machine code, mnemonic, operands, registers (A, X, Y, P, SP), flags (NVTBDIZCR), CPU Cycle, PPU Cycle" }; ser.Register(_tracer); ServiceProvider = ser; @@ -46,6 +46,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk subnes.using_reset_timing = true; HardReset(); current_cycle = 0; + subnes.cpu.ext_ppu_cycle = current_cycle; VBL_CNT = 0; } @@ -61,6 +62,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk subnes.apu.NESSoftReset(); subnes.ppu.NESSoftReset(); current_cycle = 0; + subnes.cpu.ext_ppu_cycle = current_cycle; } public DisplayType Region => DisplayType.NTSC;