From 55703a083821736b1869ce868aa16f814d6f5255 Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Wed, 13 Jan 2021 23:04:30 -0500 Subject: [PATCH] trying to improve resume after debug --- nix/debugger.cpp | 10 +++++----- sdl/aiie.cpp | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/nix/debugger.cpp b/nix/debugger.cpp index 31e2e67..494f5b9 100644 --- a/nix/debugger.cpp +++ b/nix/debugger.cpp @@ -73,13 +73,13 @@ Debugger::Debugger() Debugger::~Debugger() { - struct _history *h = history; - while (h) { + while (history) { struct _history *n = history->next; - free(h->msg); - delete(h); - h = n; + free(history->msg); + delete(history); + history = n; } + history = NULL; } bool getAddress(const char *buf, unsigned int *addrOut) diff --git a/sdl/aiie.cpp b/sdl/aiie.cpp index 34002a1..4b66a80 100644 --- a/sdl/aiie.cpp +++ b/sdl/aiie.cpp @@ -160,14 +160,21 @@ static struct timespec runCPU(struct timespec now) // Run the CPU uint8_t executed = 0; + bool debuggerWasActive = false; if (debugger.active()) { // With the debugger running, we need to single-step through // instructions. executed = g_cpu->Run(1); + debuggerWasActive = true; } else { // Otherwise we can run a bunch of instructions at once to // save on the overhead. executed = g_cpu->Run(24); + if (debuggerWasActive) { + cpuClockInitialized = false; + g_cpu->cycles = 0; + debuggerWasActive = false; + } } // The paddles need to be triggered in real-time on the CPU @@ -176,9 +183,6 @@ static struct timespec runCPU(struct timespec now) if (debugger.active()) { debugger.step(); - // reset time flags - cpuClockInitialized = false; - g_cpu->cycles = 0; } if (send_rst) {