diff --git a/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs index 712b8ae5c7..c75a64c17e 100644 --- a/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs +++ b/src/BizHawk.Emulation.Cores/CPUs/65x02/vr6502.cs @@ -1,4 +1,6 @@  +using BizHawk.Common; + namespace BizHawk.Emulation.Cores.Components.vr6502 { public partial class vr6502 @@ -6,6 +8,8 @@ namespace BizHawk.Emulation.Cores.Components.vr6502 private VrEmu6502State _6502s; private readonly VrEmu6502Model _model; + public long TotalExecutedCycles; + public vr6502(VrEmu6502Model model, VrEmu6502MemRead readFn, VrEmu6502MemWrite writeFn) { _model = model; @@ -21,13 +25,24 @@ namespace BizHawk.Emulation.Cores.Components.vr6502 } public void ExecuteTick() - { + { VrEmu6502Interop.vrEmu6502Tick(ref _6502s); + TotalExecutedCycles++; } - public void ExecuteInstruction() + public byte ExecuteInstruction() { - VrEmu6502Interop.vrEmu6502InstCycle(ref _6502s); + int cycles = VrEmu6502Interop.vrEmu6502InstCycle(ref _6502s); + TotalExecutedCycles += cycles; + return (byte)cycles; + } + + + public void SyncState(Serializer ser) + { + ser.BeginSection("vrEmu6502"); + ser.Sync(nameof(TotalExecutedCycles), ref TotalExecutedCycles); + ser.EndSection(); } } }