RetroAchievements/RAEmus

RAGens is dropping frames

Closed this issue · 11 comments

I've been examining an achievment that requires a frame perfect trigger point and I've found that at least on my system the required frame was skipped about 20% of the time, and I'm not the only one. I came to this discovery while resolving tickets for Advanced Busterhawk Gleylancer.

This only seems to occur when frame skip is not set to 0. Requiring a frame skip of 0 will certainly affect performance for some users. For most games if I set frame skip to 0 the game runs super far too fast, like between 150% and 250% speed.

I knew frames were being skipped, but didn't realize it affects the memory as well. I wonder how many issues this has caused...

Related: Issue #10

This comment doesn't make sense:

For most games if I set frame skip to 0 the game runs super far too fast, like between 150% and 250% speed.

Frame Skip tells the emulators to not render every frame to allow the emulator to run faster. This feature was originally added for older machines that couldn't process every frame in a reasonable amount of time. You can see this behavior by increasing Frame Skip - the emulator runs faster. This is Gens' version of Speed Up/Slow Down. A Frame Skip of 0 says "render every frame even if it affects performance". A Frame Skip of 9 says only render every 9th frame, allowing the time that would normally be spent rendering the other 8 frames to do more emulation.

However, the description of the problem seems correct. When skipping frames, the toolkit may not be getting notified due to where the toolkit API call is occurring. I will investigate.

I ran a quick test using Sonic 3 & Knuckles. Time was measured using a stopwatch on my phone from game reset (hitting Tab) to when the game returns to the title screen after the first level demo.

At Auto Frame Skip, it took 52.9 seconds
With Frame Skip 0, it took 53.6 seconds

I'm assuming the discrepancy is due to me starting/stopping the stopwatch, which is one of the reasons I used a longer period of measurement. In any case, it's certainly not a noticeable amount (~1%).

@Jamiras I suggest loading Tiny Toon Adventures: Buster's Hidden Treasure (Mega Drive) (with which I keep having related issues recently). Specifically 0xf9c8 will bring values lasting a frame for some SFX (while picking up power ups for example), when you use RALib, But int RAGens none of them are displayed. This is actually critical issue, which could make achievements based on single frame change unstable.

I'm getting a large amount of speedup in many (but not all) games when I turn frameskip to 0. I assume now that it's a localized issue, and wonder how common of an issue it is.

Here's a video illustrating the issue:
(https://youtu.be/qn65c1d0NU4)

Appears that "super far too fast" occurs when vsync is off and frameskip is not auto.

I see. So removing frameskip is probably a good solution.

Frameskip is the only way to "fast forward" in this emulator. With VSync on, it provides a reasonable speed increase, and can be moderated using F3/F4 similar to +/- in RANes.

I'm not going to get into whether or not fast forward should be allowed, that's been hashed out many times in other places. For consistency between emulators, I'm not going to remove frameskip. I'm also not going to remove "vsync off". Both features only allow the emulator to run faster (assuming you're not running on a potato where the computer can't keep up with the default 60 frames per second).

#54 ensures that skipped frames still get processed by the toolkit. I'm just doing some final testing, and assuming this week's AotW is not a Genesis title, plan to publish the updated emulator this weekend.

seems resolved via #54 . Closing. Feel free to reopen.

@JuliaWolska - The issue you're reporting with Tiny Toons is not related to dropped frames. There is definitely a difference in behavior between RAGens and RALibRetro. I put a memory bookmark on 32-bit $F9C8 and played through stage S-1 and the secret stage on RAGens and RALibRetro

RAGens:
image

RALibRetro:
image

In RAGens, the Changes for $F9C8 never increments - even with Frame Skip 0 - which eliminates the bug where skipped frames weren't being handled by the toolkit. Also note, I've included a counter for carrots collected - In RALibRetro every collected carrot and every jump and several other things all cause $F9C8 to change, nothing caused it to change in RAGens. That's statistically improbable assuming the issue is at all related to skipped frames.

My best guess is that the libretro core is calling the toolkit at either the beginning or the end of the VBLANK period and RAGens is calling it at the other end. It's clear from this test that address is not compatible between the two emulators. Unfortunately, I believe you're going to have to find a different address to use in your achievement. As best as I can tell, you're only using it in two of the Wacky Life achievements - the third is already looking at delta lives. I'd recommend updating the other two to also look at delta lives.

Is there a way to change when GenS is calling the toolkit? (Or something to make these values visible and usable)

I think it's likely there's a lot of useful values that are hidden due to this behavior.

As I mentioned in my previous post, the explanation is merely a guess. I don't know the inner workings of the emulator or core well enough to say exactly why things are different. And I'd want to know exactly why things are different before trying to make them behave the same.