diff --git a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
index 8e87aa0..086e06a 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
@@ -12,6 +12,10 @@ namespace AxiReplay
/// 服务器远端当前帧
///
public int mRemoteFrameIdx { get; private set; } = int.MinValue;
+ ///
+ /// Remote 2 Client Frame Gap
+ ///
+ public int mDiffFrameCount => mRemoteFrameIdx - mCurrClientFrameIdx;
///
/// 网络数据队列
///
diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
index 1dff67b..a703ad2 100644
--- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/NesEmulator.cs
@@ -56,14 +56,9 @@ namespace AxibugEmuOnline.Client
if (NesCore != null)
{
- Supporter.SampleInput();
- var controlState = Supporter.GetControllerState();
-
- //δյInput,֡ƽ
- if (!controlState.valid) return;
-
- NesCore.pad.Sync(controlState);
- NesCore.EmulateFrame(true);
+ PushEmulatorFrame();
+ if (InGameUI.Instance.IsNetPlay)
+ FixEmulatorFrame();
var screenBuffer = NesCore.ppu.GetScreenPtr();
var lineColorMode = NesCore.ppu.GetLineColorMode();
@@ -71,6 +66,38 @@ namespace AxibugEmuOnline.Client
}
}
+ private void FixEmulatorFrame()
+ {
+ int skipFrameCount = 0;
+ var frameGap = App.roomMgr.netReplay.mDiffFrameCount;
+ if (frameGap > 10000) return;
+
+ if (frameGap > 3 && frameGap < 6) skipFrameCount = 1;
+ else if (frameGap > 7 && frameGap < 12) skipFrameCount = 2;
+ else if (frameGap > 13 && frameGap < 20) skipFrameCount = 3;
+ else skipFrameCount = frameGap - 3;
+
+ if (skipFrameCount > 0) App.log.Debug($"SKIP FRAME : {skipFrameCount}");
+ for (int i = 0; i < skipFrameCount; i++)
+ {
+ if (!PushEmulatorFrame()) break;
+ }
+ }
+
+ private bool PushEmulatorFrame()
+ {
+ Supporter.SampleInput();
+ var controlState = Supporter.GetControllerState();
+
+ //δյInput,֡ƽ
+ if (!controlState.valid) return false;
+
+ NesCore.pad.Sync(controlState);
+ NesCore.EmulateFrame(true);
+
+ return true;
+ }
+
public void Pause()
{
m_bPause = true;