mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.72k stars 790 forks source link

Shrek 2 (GBA): less lag than real console #2969

Open RetroEdit opened 1 year ago

RetroEdit commented 1 year ago

I recently created a TAS of the GBA game Shrek 2.

While TASing, I began to suspect that mGBA had less lag than real console. To try and compare, I created a sort of console-verification by embedding the TAS inputs into the game itself. Here's a patch: Shrek_2_GBA_TASHack_0.2.0.bps.zip.

Using BizHawk 2.9.1, which seems to use mGBA 1306cfe15e61f7f25913a5770850439d761aa005, the game plays back in 21:20.850 (video, BizHawk movie file). The video has a timer in the bottom right based on GBA frame rate. It is played back using BizHawk's TAS playback functionality, but my modified game takes the exact same amount of time.

I've also tested this on mGBA standalone, and got these results:

On real console, it played back in approximately 21:38.783, an almost 18-second difference (video). Watching some of the real-console playback, it's clear that some levels have more lag (e.g., end of 3-2), but I haven't done an exhaustive side-by-side comparison.

I played back the movie two additional times on real console, and the times I got were 21:38.783 and 21:38.750, so all within a few frames. The times are also slightly inaccurate because the GBA screen, the video quality, and the frame rate makes discerning the exact start and end a bit imprecise.

Lag differences

Here are some approximate differences between real console and mGBA:

1-1: +0.046, 1-2: +0.143, 1-3: +0.273, 1-4: +1.244, 1-5: -0.356
2-1: -0.154, 2-2: +0.071, 2-3: +1.466, 2-4: +1.137, 2-5: +0.340
3-1: +0.214, 3-2: +6.730, 3-3: +2.018, 3-4: +0.102, 3-5: +0.148
4-1: +1.224, 4-2: +0.081, 4-3: -0.249, 4-4: +0.028, 4-5: +0.487
5-1: -0.070, 5-2: +0.168, 5-3: +1.775, 5-4: +1.525, 5-5: -0.122
Total: +18.277

Generally, multi-character levels have significantly more lag on real console than on mGBA. 3-2 is a particularly extreme case, with 6.7 extra seconds due to lag.

Some of the smaller differences are probably measurement error. I'd be a bit surprised if any level was actually faster on real console than mGBA. For instance, 1-5 is supposedly 0.356 seconds faster on real console, but it already has no lag on emulator. But it's also possible there's a separate issue.

RetroEdit commented 1 year ago

I've been working on some patches that remove saving, and I was also interested whether prefetch played a noteworthy role in the differences between mGBA and real console for this game. So I modified the game so it wouldn't enable prefetch and wouldn't save. Here's my results from this:

At the end of 3-2:
- mGBA (1306cfe; BizHawk 2.9.1)
  - With prefetch: -730 frames (-12.222 seconds)
  - Without prefetch: +302 frames (5.056 seconds)
- SkyEmu 752d340
  - With prefetch: -15 frames (-0.251 seconds)
  - Without prefetch: +58 frames (0.971 seconds)
- NanoBoyAdvance e170695
  - With prefetch: -36 frames (-0.602 seconds)
  - Without prefetch: 0 frames (equal)

I'm going to try and consolidate some of this information and the game modifications I've done in a separate Github repo in the next few weeks.