From c0a8127d6acde49d4a815872d29c7a07736207cc Mon Sep 17 00:00:00 2001
From: sin365 <353374337@qq.com>
Date: Thu, 23 Oct 2025 10:33:52 +0800
Subject: [PATCH] =?UTF-8?q?MAME=E9=81=BF=E5=85=8D=E5=B7=B2=E7=BB=8F?=
=?UTF-8?q?=E5=9C=A8=E6=88=BF=E9=97=B4=E5=86=85=E7=9A=84=E7=8E=A9=E5=AE=B6?=
=?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=83=AD=E6=9C=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Assets/Plugins/Mame.Core/MAMEEmu.cs | 29 +++++++++++++++----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs
index 90b0d9dc..6e252a02 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs
@@ -14,6 +14,18 @@ namespace MAME.Core
mameMainMotion = new MameMainMotion();
}
+ #region 热机
+ //是否需要预热
+ bool bNeedPreheat { get
+ {
+ return historyUpdateCount < 5;
+ } }
+ ///
+ /// 推帧计数,(记录本次加载Rom之后推帧的计数)
+ ///
+ ulong historyUpdateCount = 0;
+ #endregion
+
public bool bRom => mameMainMotion.bRom;
public void Init(
@@ -31,11 +43,20 @@ namespace MAME.Core
public void ResetRomRoot(string RomDir) => mameMainMotion.ResetRomRoot(RomDir);
public Dictionary GetGameList() => mameMainMotion.GetGameList();
- public void LoadRom(string Name) => mameMainMotion.LoadRom(Name);
+ public void LoadRom(string Name)
+ {
+ historyUpdateCount = 0;
+ mameMainMotion.LoadRom(Name);
+ }
+
public void GetGameScreenSize(out int _width, out int _height, out IntPtr _framePtr) => mameMainMotion.GetGameScreenSize(out _width, out _height, out _framePtr);
public void StartGame() => mameMainMotion.StartGame();
public void StartGame_WithNewThread() => mameMainMotion.StartGame_WithNewThread();
- public void UpdateFrame() => Mame.mame_execute_UpdateMode_NextFrame();
+ public void UpdateFrame()
+ {
+ historyUpdateCount++;
+ Mame.mame_execute_UpdateMode_NextFrame();
+ }
public void UnlockNextFreme(int moreTick = 1) => mameMainMotion.UnlockNextFreme(moreTick);
public void StopGame() => mameMainMotion.StopGame();
public long currEmuFrame => Video.screenstate.frame_number;
@@ -44,10 +65,8 @@ namespace MAME.Core
{
//热机逻辑:主要解决NEOGEO问题,避免加入其他人房间自动联机时,加载流程,cpu一次都没执行,部分逻辑没有初始化。
//再加载数据之前,推若干帧,确保所有组件充分初始化
- for (int i = 0; i < 5; i++)
- {
+ while(bNeedPreheat)
UpdateFrame();
- }
Mame.paused = true;
Thread.Sleep(20);
Mame.soft_reset();//软重启一次,确保没有脏数据