From 1635cf9b30bce5cad7deab817761dbad468f56dc Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 24 Feb 2016 20:41:55 -0500 Subject: [PATCH] Trace logging support for ColecoVision --- .../Consoles/Coleco/ColecoVision.cs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index 9899c08e5e..734a332446 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; - -using BizHawk.Common; -using BizHawk.Common.NumberExtensions; - -using BizHawk.Emulation.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.Components; using BizHawk.Emulation.Cores.Components.Z80; @@ -31,6 +24,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision public TMS9918A VDP; public SN76489 PSG; public byte[] Ram = new byte[1024]; + private readonly TraceBuffer Tracer = new TraceBuffer(); [CoreConstructor("Coleco")] public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object SyncSettings) @@ -39,7 +33,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision MemoryCallbacks = new MemoryCallbackSystem(); CoreComm = comm; _syncSettings = (ColecoSyncSettings)SyncSettings ?? new ColecoSyncSettings(); - bool skipbios = this._syncSettings.SkipBiosIntro; + bool skipbios = _syncSettings.SkipBiosIntro; Cpu = new Z80A(); Cpu.ReadMemory = ReadMemory; @@ -61,7 +55,10 @@ namespace BizHawk.Emulation.Cores.ColecoVision LoadRom(rom, skipbios); this.game = game; SetupMemoryDomains(); - (ServiceProvider as BasicServiceProvider).Register(new Disassembler()); + + var serviceProvider = ServiceProvider as BasicServiceProvider; + serviceProvider.Register(new Disassembler()); + serviceProvider.Register(Tracer); } public IEmulatorServiceProvider ServiceProvider { get; private set; } @@ -70,9 +67,16 @@ namespace BizHawk.Emulation.Cores.ColecoVision public void FrameAdvance(bool render, bool renderSound) { + Cpu.Debug = Tracer.Enabled; Frame++; _isLag = true; PSG.BeginFrame(Cpu.TotalExecutedCycles); + + if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first + { + Cpu.Logger = (s) => Tracer.Put(s); + } + VDP.ExecuteFrame(); PSG.EndFrame(Cpu.TotalExecutedCycles);