diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs index 6d6e227483..090e884a5b 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Emu.cs @@ -188,6 +188,31 @@ namespace BizHawk.Client.Common } } + [LuaMethodAttributes( + "totalexecutedcycles", + "gets the total number of executed cpu cycles" + )] + public int TotalExecutedycles() + { + try + { + if (DebuggableCore == null) + { + throw new NotImplementedException(); + } + + return DebuggableCore.TotalExecutedCycles; + } + catch (NotImplementedException) + { + Log(string.Format( + "Error: {0} does not yet implement totalexecutedcycles()", + Emulator.Attributes().CoreName)); + + return 0; + } + } + [LuaMethodAttributes( "getsystemid", "Returns the ID string of the current core loaded. Note: No ROM loaded will return the string NULL" diff --git a/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs b/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs index 9b6ae95134..590361544e 100644 --- a/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs +++ b/BizHawk.Emulation.Common/Interfaces/Services/IDebuggable.cs @@ -36,6 +36,12 @@ namespace BizHawk.Emulation.Common /// Advances the core based on the given Step type /// void Step(StepType type); + + /// + /// Total number of cpu cycles since the beginning of the core's lifecycle + /// Note that the cpu in this case is the "main" cpu, for some cores that may be somewhat subjective + /// + int TotalExecutedCycles { get; } // TODO: this should probably be a long, but most cores were using int, oh well } public class RegisterValue diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs index ff492b66ca..680aeaec49 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.IDebuggable.cs @@ -126,5 +126,10 @@ namespace BizHawk.Emulation.Cores.Calculators public void Step(StepType type) { throw new NotImplementedException(); } public bool CanStep(StepType type) { return false; } + + public int TotalExecutedCycles + { + get { return Cpu.TotalExecutedCycles; } + } } } diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs index 7ad45f73ea..9b304f5cae 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IDebuggable.cs @@ -120,6 +120,11 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII } } + public int TotalExecutedCycles + { + get { return (int)_machine.Cpu.Cycles; } + } + private void StepInto() { if (Tracer.Enabled) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs index ad389ed80b..ffc9a4bd83 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.IDebuggable.cs @@ -60,6 +60,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 _selectedDebuggable.Step(type); } + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { return _selectedDebuggable.TotalExecutedCycles; } + } + [SaveState.DoNotSave] private readonly IMemoryCallbackSystem _memoryCallbacks; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDebuggable.cs index 3db286bc80..1f3b8303b1 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip6510.IDebuggable.cs @@ -82,6 +82,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS } } + int IDebuggable.TotalExecutedCycles + { + get { return _cpu.TotalExecutedCycles; } + } + private void StepInto() { while (_cpu.AtInstructionStart()) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs index 132b181514..4c79399f3f 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/Serial/Drive1541.IDebuggable.cs @@ -82,6 +82,11 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.Serial } } + int IDebuggable.TotalExecutedCycles + { + get { return _cpu.TotalExecutedCycles; } + } + private void StepInto() { while (_cpu.AtInstructionStart()) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs index 01e67a3ae4..112bd0bdd7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IDebuggable.cs @@ -88,6 +88,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } + public int TotalExecutedCycles + { + get { return Cpu.TotalExecutedCycles; } + } + private void StepInto() { do diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs index 4f27b4289d..57d3a6496f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IDebuggable.cs @@ -64,5 +64,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + + public int TotalExecutedCycles + { + get { return (int)theMachine.CPU.Clock; } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs index 1cbb9ca6eb..5d144974ab 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.IDebuggable.cs @@ -127,5 +127,10 @@ namespace BizHawk.Emulation.Cores.ColecoVision [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + + public int TotalExecutedCycles + { + get { return Cpu.TotalExecutedCycles; } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs index 5e18c9e11d..d7538d3c7b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IDebuggable.cs @@ -30,5 +30,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles { get { throw new NotImplementedException(); } } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs index e411e24480..647861aea8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IDebuggable.cs @@ -42,6 +42,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } + public IMemoryCallbackSystem MemoryCallbacks { get { return _memorycallbacks; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs index 87934683da..0d76029738 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IDebuggable.cs @@ -44,6 +44,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } + private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(); } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs index a306054894..1bbe99cf65 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IDebuggable.cs @@ -89,6 +89,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } + private mupen64plusApi.MemoryCallback _readcb; private mupen64plusApi.MemoryCallback _writecb; private mupen64plusApi.MemoryCallback _executecb; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IDebuggable.cs index 8ec2d8685f..b152052814 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IDebuggable.cs @@ -63,5 +63,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + + public int TotalExecutedCycles + { + get { return cpu.TotalExecutedCycles; } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs index e5d5d12b63..e78ef46cb3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IDebuggable.cs @@ -37,5 +37,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES [FeatureNotImplemented] get { throw new NotImplementedException(); } } + + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index 127ef65e68..6e76771c0d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -304,6 +304,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } + public class MyScanlineHookManager : ScanlineHookManager { public MyScanlineHookManager(LibsnesCore core) diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs index 8ab9091000..82f8b2d377 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IDebuggable.cs @@ -39,5 +39,10 @@ namespace BizHawk.Emulation.Cores.PCEngine [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + + public int TotalExecutedCycles + { + get { return (int)Cpu.TotalExecutedCycles; } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs index aaf4ee4d4f..f83b6530f5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IDebuggable.cs @@ -129,5 +129,10 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem { throw new NotImplementedException(); } + + public int TotalExecutedCycles + { + get { return Cpu.TotalExecutedCycles; } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IDebuggable.cs index 671d2ff774..a1669c5111 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IDebuggable.cs @@ -46,6 +46,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } + private readonly MemoryCallbackSystem _memoryCallbacks = new MemoryCallbackSystem(); private LibGPGX.mem_cb ExecCallback; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs index f945376111..4114915e61 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs @@ -46,6 +46,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64 [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } + private readonly MemoryCallbackSystem _memoryCallbacks = new MemoryCallbackSystem(); private LibGPGX.mem_cb ExecCallback; diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs index f94fce366a..ccff867f43 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.IDebuggable.cs @@ -87,5 +87,11 @@ namespace BizHawk.Emulation.Cores.Sony.PSX [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + + [FeatureNotImplemented] + public int TotalExecutedCycles + { + get { throw new NotImplementedException(); } + } } } diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 312f6a4750..709c368159 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -138,6 +138,9 @@ namespace BizHawk.Emulation.Cores.WonderSwan [FeatureNotImplemented] public void Step(StepType type) { throw new NotImplementedException(); } + [FeatureNotImplemented] + public int TotalExecutedCycles { get { throw new NotImplementedException(); } } + BizSwan.MemoryCallback ReadCallbackD; BizSwan.MemoryCallback WriteCallbackD; BizSwan.MemoryCallback ExecCallbackD;