From f492c2914655f3cc80ce27b1122c6ca00118120d Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Wed, 8 Oct 2025 01:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E9=81=BF=E4=B8=80=E4=BA=9B=E5=8D=B1?= =?UTF-8?q?=E9=99=A9=E9=A1=B9=E7=9B=AE=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Plugins/AxiReplay/ReplayReader.cs | 4 +- .../Assets/Plugins/AxiReplay/ReplayWriter.cs | 4 +- .../Assets/Plugins/Essgee.Unity/AxiMemory.cs | 32 +++++------ .../Essgee.Unity/Emulation/CartridgeLoader.cs | 3 +- .../Scripts/DebugLogManager.cs | 4 +- .../Plugins/Mame.Core/sound/WavWrite.cs | 5 +- .../Plugins/StoicGooseUnity/AxiMemory.cs | 4 +- .../Materials/UI-Effect-Shiny.mat | 5 +- .../Materials/UI-Effect-Shiny.mat.meta | 4 +- .../Scripts/Common/MaterialResolver.cs | 4 ++ .../AppMain/Emulator/MameEmulator/UMAME.cs | 10 ++-- .../MameEmulator/UniInterface/UniKeyboard.cs | 53 ++++++++++--------- 12 files changed, 72 insertions(+), 60 deletions(-) diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayReader.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayReader.cs index 679d0b4c..dfb7ca75 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayReader.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayReader.cs @@ -1,4 +1,5 @@ -using System; +#if !UNITY_SWITCH +using System; using System.Collections.Generic; using System.IO; using System.Text; @@ -172,3 +173,4 @@ namespace AxiReplay } } +#endif \ No newline at end of file diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayWriter.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayWriter.cs index 950767ee..2d18d46b 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayWriter.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/AxiReplay/ReplayWriter.cs @@ -1,4 +1,5 @@ -using System; +#if !UNITY_SWITCH +using System; using System.Collections.Generic; using System.IO; using System.Text; @@ -156,3 +157,4 @@ namespace AxiReplay } } +#endif \ No newline at end of file diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/AxiMemory.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/AxiMemory.cs index ce03876d..159b9fa8 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/AxiMemory.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/AxiMemory.cs @@ -82,7 +82,6 @@ namespace Essgee.Utilities } } #endregion - public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count) { // 使用指针复制数据到临时数组 @@ -90,21 +89,22 @@ namespace Essgee.Utilities // 使用BinaryWriter写入临时数组 bw.Write(TempBuffer_src, 0, count); } - public static void Write(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count) - { - // 使用指针复制数据到临时数组 - Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count); - // 使用BinaryWriter写入临时数组 - fs.Write(TempBuffer_src, 0, count); - } - public static int Read(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count) - { - // 使用BinaryWriter写入临时数组 - count = fs.Read(TempBuffer_src, offset, count); - // 使用指针复制数据到临时数组 - Buffer.MemoryCopy(TempBuffer, bufferPtr + offset, 0, count); - return count; - } + + //public static void Write(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count) + //{ + // // 使用指针复制数据到临时数组 + // Buffer.MemoryCopy(bufferPtr + offset, TempBuffer, 0, count); + // // 使用BinaryWriter写入临时数组 + // fs.Write(TempBuffer_src, 0, count); + //} + //public static int Read(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count) + //{ + // // 使用BinaryWriter写入临时数组 + // count = fs.Read(TempBuffer_src, offset, count); + // // 使用指针复制数据到临时数组 + // Buffer.MemoryCopy(TempBuffer, bufferPtr + offset, 0, count); + // return count; + //} } internal unsafe static class AxiArray diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/Emulation/CartridgeLoader.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/Emulation/CartridgeLoader.cs index 1bd992b1..4bd9b3e3 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/Emulation/CartridgeLoader.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/Essgee.Unity/Emulation/CartridgeLoader.cs @@ -39,6 +39,7 @@ namespace Essgee.Emulation var fileExtension = System.IO.Path.GetExtension(fileName); if (fileExtension == ".zip") { + UnityEngine.Debug.Log("使用ZipFile.Open解压Zip:"+fileName); using (var zip = ZipFile.Open(fileName, ZipArchiveMode.Read)) { foreach (var entry in zip.Entries) @@ -60,7 +61,7 @@ namespace Essgee.Emulation else if (fileExtensionSystemDictionary.ContainsKey(fileExtension)) { machineType = fileExtensionSystemDictionary[fileExtension]; - romData = System.IO.File.ReadAllBytes(fileName); + romData = EmulatorHandler.io.File_ReadAllBytes(fileName); } } catch (Exception ex) when (!AppEnvironment.DebugMode) diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/IngameDebugConsole/Scripts/DebugLogManager.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/IngameDebugConsole/Scripts/DebugLogManager.cs index 0237a95e..388dcbe4 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/IngameDebugConsole/Scripts/DebugLogManager.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/IngameDebugConsole/Scripts/DebugLogManager.cs @@ -1805,7 +1805,9 @@ namespace IngameDebugConsole public void SaveLogsToFile( string filePath ) { +#if !UNITY_SWITCH File.WriteAllText( filePath, GetAllLogs() ); +#endif Debug.Log( "Logs saved to: " + filePath ); } @@ -1815,7 +1817,7 @@ namespace IngameDebugConsole if( !avoidScreenCutout ) return; -#if UNITY_2017_2_OR_NEWER && ( UNITY_EDITOR || UNITY_ANDROID || UNITY_IOS ) +#if UNITY_2017_2_OR_NEWER && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IOS) // Check if there is a cutout at the top of the screen int screenHeight = Screen.height; float safeYMax = Screen.safeArea.yMax; diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/Mame.Core/sound/WavWrite.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/Mame.Core/sound/WavWrite.cs index e1afab9a..f269c3af 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/Mame.Core/sound/WavWrite.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/Mame.Core/sound/WavWrite.cs @@ -1,4 +1,4 @@ - +#if !UNITY_SWITCH using System.IO; namespace MAME.Core @@ -81,4 +81,5 @@ namespace MAME.Core mWriter.Flush(); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/StoicGooseUnity/AxiMemory.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/StoicGooseUnity/AxiMemory.cs index 839268b8..ea12178c 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/StoicGooseUnity/AxiMemory.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/StoicGooseUnity/AxiMemory.cs @@ -93,7 +93,6 @@ namespace StoicGooseUnity } } #endregion - public static void Write(this System.IO.BinaryWriter bw, byte* bufferPtr, int offset, int count) { // 使用指针复制数据到临时数组 @@ -101,6 +100,7 @@ namespace StoicGooseUnity // 使用BinaryWriter写入临时数组 bw.Write(TempBuffer_src, 0, count); } + /* public static void Write(this System.IO.FileStream fs, byte* bufferPtr, int offset, int count) { // 使用指针复制数据到临时数组 @@ -115,7 +115,7 @@ namespace StoicGooseUnity // 使用指针复制数据到临时数组 Buffer.MemoryCopy(TempBuffer, bufferPtr + offset, 0, count); return count; - } + }*/ } internal unsafe static class AxiArray diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat b/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat index 45a05a66..c76eb18e 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat @@ -3,7 +3,7 @@ --- !u!21 &2100000 Material: serializedVersion: 8 - m_ObjectHideFlags: 0 + m_ObjectHideFlags: 8 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} @@ -13,7 +13,7 @@ Material: m_ModifiedSerializedProperties: 0 m_ValidKeywords: [] m_InvalidKeywords: [] - m_LightmapFlags: 1 + m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 @@ -43,4 +43,3 @@ Material: m_Colors: - _Color: {r: 1, g: 1, b: 1, a: 1} m_BuildTextureStacks: [] - m_AllowLocking: 1 diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat.meta b/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat.meta index 32817128..53f84812 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat.meta +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Materials/UI-Effect-Shiny.mat.meta @@ -1,8 +1,8 @@ fileFormatVersion: 2 guid: 9dc7e810a87b444ab96919f3215c2fe5 -timeCreated: 1523859834 -licenseType: Pro NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 userData: assetBundleName: assetBundleVariant: diff --git a/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Scripts/Common/MaterialResolver.cs b/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Scripts/Common/MaterialResolver.cs index 821b8a80..3640bb41 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Scripts/Common/MaterialResolver.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Plugins/UIEffect_v2018/Scripts/Common/MaterialResolver.cs @@ -66,6 +66,10 @@ namespace Coffee.UIExtensions static void SaveMaterial(Material mat, Shader shader, bool isMainAsset) { +#if !UNITY_EDITOR + return; +#endif + string materialPath = GetDefaultMaterialPath(shader); #if UIEFFECT_SEPARATE diff --git a/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs b/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs index 60bd8e8c..b3fd789d 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs @@ -29,8 +29,8 @@ public class UMAME : EmuCore public UniTimeSpan mTimeSpan; public bool bQuickTestRom = false; public string mQuickTestRom = string.Empty; - public ReplayWriter mReplayWriter; - public ReplayReader mReplayReader; + //public ReplayWriter mReplayWriter; + //public ReplayReader mReplayReader; public long currEmuFrame => emu.currEmuFrame; public static System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); public static bool bInGame { get; private set; } @@ -125,7 +125,7 @@ public class UMAME : EmuCore { emu.ResetRomRoot(RomPath); //Application.targetFrameRate = 60; - mReplayWriter = new ReplayWriter(mChangeRomName, "fuck", ReplayData.ReplayFormat.FM32IP64, Encoding.UTF8); + //mReplayWriter = new ReplayWriter(mChangeRomName, "fuck", ReplayData.ReplayFormat.FM32IP64, Encoding.UTF8); mChangeRomName = loadRom; StopGame(); //读取ROM @@ -161,7 +161,7 @@ public class UMAME : EmuCore mUniKeyboard.SyncInput(InputData); emu.UpdateFrame(); //写入replay - UMAME.instance.mReplayWriter.NextFramebyFrameIdx((int)UMAME.instance.mUniVideoPlayer.mFrame, InputData); + //UMAME.instance.mReplayWriter.NextFramebyFrameIdx((int)UMAME.instance.mUniVideoPlayer.mFrame, InputData); return true; } @@ -188,7 +188,7 @@ public class UMAME : EmuCore { string Path = SavePath + Machine.sName + ".rp"; string dbgPath = SavePath + Machine.sName + ".rpwrite"; - mReplayWriter.SaveData(Path, true, dbgPath); + //mReplayWriter.SaveData(Path, true, dbgPath); } public void StopGame() { diff --git a/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs b/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs index 698ee9cc..11760691 100644 --- a/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs +++ b/AxibugEmuOnline.Client.Switch/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs @@ -121,34 +121,35 @@ public class UniKeyboard : MonoBehaviour, IKeyboard } } - public class ReplayMode - { - ulong currInputData; +// public class ReplayMode +// { +// ulong currInputData; - public ReplayMode() - { - } +// public ReplayMode() +// { +// } - public ulong GetPressedKeys() - { - int targetFrame = (int)UMAME.instance.mUniVideoPlayer.mFrame; - AxiReplay.ReplayStep stepData; - //有变化 - if (UMAME.instance.mReplayReader.NextFramebyFrameIdx(targetFrame, out stepData)) - { -#if UNITY_EDITOR - string ShowKeyNames = string.Empty; - foreach (string keyname in GetInputpDataToMotionKey(currInputData)) - { - ShowKeyNames += keyname + " |"; - } - Debug.Log("GetPressedKeys=>" + ShowKeyNames); -#endif - currInputData = stepData.InPut; - } - return currInputData; - } - } +// public ulong GetPressedKeys() +// { +// int targetFrame = (int)UMAME.instance.mUniVideoPlayer.mFrame; +// AxiReplay.ReplayStep stepData; + +// //有变化 +// if (UMAME.instance.mReplayReader.NextFramebyFrameIdx(targetFrame, out stepData)) +// { +//#if UNITY_EDITOR +// string ShowKeyNames = string.Empty; +// foreach (string keyname in GetInputpDataToMotionKey(currInputData)) +// { +// ShowKeyNames += keyname + " |"; +// } +// Debug.Log("GetPressedKeys=>" + ShowKeyNames); +//#endif +// currInputData = stepData.InPut; +// } +// return currInputData; +// } +// } #endregion }