diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs index 5301e634..90b0d9dc 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs @@ -42,10 +42,18 @@ namespace MAME.Core public bool IsPaused => Mame.paused; public void LoadState(System.IO.BinaryReader sr) { + //热机逻辑:主要解决NEOGEO问题,避免加入其他人房间自动联机时,加载流程,cpu一次都没执行,部分逻辑没有初始化。 + //再加载数据之前,推若干帧,确保所有组件充分初始化 + for (int i = 0; i < 5; i++) + { + UpdateFrame(); + } Mame.paused = true; Thread.Sleep(20); - State.loadstate_callback.Invoke(sr); + Mame.soft_reset();//软重启一次,确保没有脏数据 + State.loadstate_callback(sr); Mame.postload(); + Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2; mameMainMotion.ResetFreameIndex(); Thread.Sleep(20); Mame.paused = false; @@ -55,7 +63,7 @@ namespace MAME.Core { Mame.paused = true; Thread.Sleep(20); - State.savestate_callback.Invoke(sw); + State.savestate_callback(sw); Thread.Sleep(20); Mame.paused = false; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Streams.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Streams.cs index 32407a9b..4f345e2f 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Streams.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Streams.cs @@ -119,8 +119,8 @@ namespace MAME.Core //} //这是一个Monkey Patch, 这里一维数组是0~2,二位数组可能不正常 - int maxcount = Math.Min(streamoutput[i].Length, max_samples_per_update); - for (j = 0; j < maxcount; j++) + max_samples_per_update = Math.Min(max_samples_per_update, streamoutput[i].Length - samples_to_lose); + for (j = 0; j < max_samples_per_update; j++) { streamoutput[i][j] = streamoutput[i][samples_to_lose + j]; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs index caa455ce..bbca725e 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using UnityEngine; using static AxibugEmuOnline.Client.HttpAPI; using static AxibugEmuOnline.Client.Manager.LogManager; -using static AxibugEmuOnline.Client.SaveFile; namespace AxibugEmuOnline.Client.ClientCore {