summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2022-10-21 00:44:18 +0300
committerOxore <oxore@protonmail.com>2022-10-21 00:44:18 +0300
commitb46a4c109a845cd64a8dbc6f51bcbbe6fe2f6378 (patch)
treeaa3f1a193b9243c7f2d2e186d1985073f4b391e6
parent911f72b2299ec654178af0b4e4fbbd3f870779b3 (diff)
Add global cycles counter
-rw-r--r--emulator.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/emulator.cpp b/emulator.cpp
index 7ce5f60..c6557a2 100644
--- a/emulator.cpp
+++ b/emulator.cpp
@@ -41,6 +41,8 @@ unsigned char g_psg[PSG_SIZE] = {};
VDP g_vdp(VDP_START);
std::vector<Breakpoint> code_bkpts{}, read_bkpts{}, write_bkpts{}, access_bkpts{};
+uint64_t g_cycles_counter = 0;
+
template<typename T, size_t S>
struct Backtrace {
static_assert(S > 0, "Backtrace size cannot be zero");
@@ -290,7 +292,7 @@ static std::string CreateResponse(
return "OK";
}
case PacketType::kStep:
- m68k_execute(1);
+ g_cycles_counter += m68k_execute(1);
return "S05"; // TODO real reason
case PacketType::kSetBreakpoint:
{
@@ -484,9 +486,10 @@ int emulator(M68KDebuggingControl& m68k_debug, Graphics& graphics)
}
if (m68k_debug.IsRunning()) {
do {
- m68k_execute(10000);
+ g_cycles_counter += m68k_execute(1000);
} while(!g_vdp.Scanline());
graphics.Render(g_vdp);
+ g_cycles_counter += m68k_execute(8000);
}
if (m68k_debug.HasBreakpoint()) {
m68k_debug.SetRunning(false);
@@ -535,7 +538,7 @@ int main(int argc, char* argv[])
m68k_init();
m68k_set_cpu_type(M68K_CPU_TYPE_68000);
m68k_pulse_reset();
- m68k_execute(1); // Skip reset cycles
+ g_cycles_counter += m68k_execute(1); // Skip reset cycles
emulator(g_m68k_debug, graphics);