gameroy icon indicating copy to clipboard operation
gameroy copied to clipboard

Fix frame sync with debugger

Open parasyte opened this issue 1 year ago • 1 comments

When the debugger is enabled, the game runs at a million frames per second, making it impossible to actually play while waiting for breakpoints or doing any real work.

This PR is an attempt to fix the emulation speed by allowing the interpreter to synchronize with the host's refresh rate in a way similar to the normal emulation control flow. I had to add extra state to capture whether the debugger wants to pause emulation, rather than relying on the EmulatorState control flow.

I also adjusted the debugger CPU frequency to slow it down a bit more. It was still running way too fast (at least on my laptop) even with vsync.

Not sure if you want this patch or if you have a better solution. But it unblocked me. I was able to use the debugger to find what I needed after all of these patches.

parasyte avatar Dec 24 '24 05:12 parasyte

Yeah, being able to play the game while a breakpoint is set is indeed something the emulator should support. But your implementation is not working very well, the emulation speed is now tuned to your CPU speed and screen frame rate. On my machine, the emulator under debugger is running very slowly.

What you need to do is replicate the entire logic inside RunNoBreak (minus the if rewind branch) into Run. Or better yet, merge the modes into one, but that need more consideration to avoid the debugger performance penalty when not using the debugger.

Rodrigodd avatar Dec 24 '24 18:12 Rodrigodd