From ace77987e46615cc2c278e7e7d300ef75bac9014 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Tue, 29 Apr 2025 19:43:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=20NesEmulator=E9=87=8D=E6=9E=84=E5=90=8E?= =?UTF-8?q?=E5=A4=84=E7=90=86=E8=BE=93=E5=85=A5=E6=95=B0=E6=8D=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Resources/IMPORTENT.prefab | 8 +++ .../Emulator/NesEmulator/CoreSupporter.cs | 53 ++----------------- .../Emulator/NesEmulator/NesEmulator.cs | 4 +- .../Assets/Script/AppMain/IEmuCore.cs | 5 +- .../VirtualNes.Core/Supporter/Supporter.cs | 2 - 5 files changed, 15 insertions(+), 57 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Resources/IMPORTENT.prefab b/AxibugEmuOnline.Client/Assets/Resources/IMPORTENT.prefab index 8e7c8dc7..8be16655 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/IMPORTENT.prefab +++ b/AxibugEmuOnline.Client/Assets/Resources/IMPORTENT.prefab @@ -1215,6 +1215,14 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 6671307062690349520, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6671307062690349520, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} - target: {fileID: 6838719776118089301, guid: 1de15a80c8c1aa94486563740a15d91c, type: 3} propertyPath: m_IsActive value: 1 diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/CoreSupporter.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/CoreSupporter.cs index 4d46cac3..eec32d97 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/CoreSupporter.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/CoreSupporter.cs @@ -10,11 +10,6 @@ namespace AxibugEmuOnline.Client { public class CoreSupporter : ISupporterImpl { - private NesControllerMapper m_controllerMapper; - public CoreSupporter(NesControllerMapper conMapper) - { - m_controllerMapper = conMapper; - } public System.IO.Stream OpenRom(string fname) { @@ -95,51 +90,9 @@ namespace AxibugEmuOnline.Client { var db = Resources.Load("NES/ROMDB"); return db.GetMapperNo(rom.GetPROM_CRC(), out mapperNo); - } - - private ControllerState m_sampledState; - public ControllerState GetControllerState() - { - return m_sampledState; - } - - uint LastTestInput = 0; - public void SampleInput(uint frameIndex) - { - if (InGameUI.Instance.IsNetPlay) - { - int targetFrame; ReplayStep replayData; int frameDiff; bool inputDiff; - if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out replayData, out frameDiff, out inputDiff)) - { - if (inputDiff) - { - App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} TryGetNextFrame remoteFrame->{App.roomMgr.netReplay.mRemoteFrameIdx} diff->{frameDiff} " + - $"frame=>{replayData.FrameStartID} InPut=>{replayData.InPut}"); - } - - m_sampledState = FromNet(replayData); - } - else - { - m_sampledState = default(ControllerState); - } - - var localState = m_controllerMapper.CreateState(); - var rawData = ToNet(localState); - if (LastTestInput != rawData) - { - LastTestInput = rawData; - App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}"); - } - App.roomMgr.SendRoomSingelPlayerInput(frameIndex, rawData); - } - //单机模式 - else - { - m_sampledState = m_controllerMapper.CreateState(); - } - } - + } + + public ControllerState FromNet(AxiReplay.ReplayStep step) { var temp = new ServerInputSnapShot(); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs index 0f706a8a..69cf14d7 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs @@ -45,7 +45,7 @@ namespace AxibugEmuOnline.Client { StopGame(); - m_coreSupporter = new CoreSupporter(ControllerMapper); + m_coreSupporter = new CoreSupporter(); Supporter.Setup(m_coreSupporter); Debuger.Setup(new CoreDebuger()); @@ -145,7 +145,7 @@ namespace AxibugEmuOnline.Client protected override ControllerState GetLocalInput() { - return m_coreSupporter.GetControllerState(); + return ControllerMapper.CreateState(); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs index aebf176c..1be8dfe4 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs @@ -99,9 +99,8 @@ namespace AxibugEmuOnline.Client App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}"); } App.roomMgr.SendRoomSingelPlayerInput(Frame, rawData); - } - //单机模式 - else + } + else//单机模式 { inputData = GetLocalInput(); result = true; diff --git a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs index 43438ef6..20b88689 100644 --- a/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs +++ b/AxibugEmuOnline.Client/Assets/VirtualNes.Core/Supporter/Supporter.cs @@ -23,7 +23,5 @@ void SaveFile(byte[] fileData, string directPath, string fileName); System.IO.Stream OpenFile(string directPath, string fileName); bool TryGetMapperNo(ROM rom, out int mapperNo); - ControllerState GetControllerState(); - void SampleInput(uint frameCount); } } \ No newline at end of file