From ebb38363593e9c2c2921509b717ea0c6f052639e Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Sat, 25 Jan 2025 01:43:50 +0800 Subject: [PATCH] =?UTF-8?q?motionkey=E9=87=8D=E6=96=B0=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MAME.Unity/Assets/Plugins/UMAME/MAMEEmu.cs | 10 +- .../Plugins/UMAME/Motion/MameMainMotion.cs | 9 +- .../Assets/Plugins/UMAME/emu/Generic.cs | 2 + .../Assets/Plugins/UMAME/emu/Inptport.cs | 4 +- .../Assets/Plugins/UMAME/emu/Keyboard.cs | 205 +++++++- MAME.Unity/Assets/Plugins/UMAME/emu/Memory.cs | 2 - MAME.Unity/Assets/Plugins/UMAME/emu/Motion.cs | 8 +- .../Assets/Plugins/UMAME/mame/capcom/Gng.cs | 4 + .../Assets/Plugins/UMAME/mame/capcom/Input.cs | 24 +- .../Assets/Plugins/UMAME/mame/cps/Input.cs | 44 +- .../Assets/Plugins/UMAME/mame/igs011/Input.cs | 8 +- .../Plugins/UMAME/mame/konami68000/Input.cs | 28 +- .../Assets/Plugins/UMAME/mame/m72/M72.cs | 4 + .../Plugins/UMAME/mame/namcos1/Input.cs | 16 +- .../Assets/Plugins/UMAME/mame/neogeo/Input.cs | 8 +- .../Assets/Plugins/UMAME/mame/pgm/Input.cs | 8 +- .../Assets/Plugins/UMAME/mame/suna8/SunA8.cs | 2 + .../Assets/Plugins/UMAME/mame/taitob/Input.cs | 8 +- .../Assets/Plugins/UMAME/mame/tehkan/Input.cs | 4 +- .../Plugins/UMAME/run_interface/IKeyboard.cs | 2 +- .../Plugins/UMAME/run_interface/MotionKey.cs | 456 ++++++++++++++++-- .../Assets/Plugins/UMAME/sound/Sample.cs | 2 + MAME.Unity/Assets/Scenes/SampleScene.unity | 112 ++++- MAME.Unity/Assets/Script/UMAME/UMAME.cs | 2 +- .../Script/UMAME/UniInterface/UniKeyboard.cs | 125 ++--- .../UMAME/UniInterface/UniVideoPlayer.cs | 4 +- 26 files changed, 854 insertions(+), 247 deletions(-) diff --git a/MAME.Unity/Assets/Plugins/UMAME/MAMEEmu.cs b/MAME.Unity/Assets/Plugins/UMAME/MAMEEmu.cs index 1a8f20a..29dc7b9 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/MAMEEmu.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/MAMEEmu.cs @@ -28,6 +28,8 @@ namespace MAME.Core ITimeSpan itime ) => mameMainMotion.Init(RomDir, ilog, iRes, ivp, isp, ikb, imou, itime); + public void ResetRomRoot(string RomDir) => mameMainMotion.ResetRomRoot(RomDir); + public Dictionary GetGameList() => mameMainMotion.GetGameList(); public void LoadRom(string Name) => mameMainMotion.LoadRom(Name); public void GetGameScreenSize(out int _width, out int _height, out IntPtr _framePtr) => mameMainMotion.GetGameScreenSize(out _width, out _height, out _framePtr); @@ -37,7 +39,7 @@ namespace MAME.Core public void UnlockNextFreme(int moreTick = 1) => mameMainMotion.UnlockNextFreme(moreTick); public void StopGame() => mameMainMotion.StopGame(); public long currEmuFrame => Video.screenstate.frame_number; - + public bool IsPaused => Mame.paused; public void LoadState(BinaryReader sr) { Mame.paused = true; @@ -62,6 +64,12 @@ namespace MAME.Core mameMainMotion.StopGame(); mameMainMotion = null; GC.Collect(); + AxiMemoryEx.FreeAllGCHandle(); + } + + public void SetPaused(bool ispaused) + { + Mame.paused = ispaused; } } } diff --git a/MAME.Unity/Assets/Plugins/UMAME/Motion/MameMainMotion.cs b/MAME.Unity/Assets/Plugins/UMAME/Motion/MameMainMotion.cs index 27b372e..a298817 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/Motion/MameMainMotion.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/Motion/MameMainMotion.cs @@ -46,6 +46,9 @@ namespace MAME.Core ) { AxiMemoryEx.Init(); + + AxiTimeSpan.Init(itime); + Mame.RomRoot = RomDir; EmuLogger.BindFunc(ilog); Video.BindFunc(ivp); @@ -58,7 +61,11 @@ namespace MAME.Core MAMEDBHelper.LoadROMXML(resource.mame); Keyboard.InitializeInput(ikb); Mouse.InitialMouse(imou); - AxiTimeSpan.Init(itime); + } + + public void ResetRomRoot(string RomDir) + { + Mame.RomRoot = RomDir; } diff --git a/MAME.Unity/Assets/Plugins/UMAME/emu/Generic.cs b/MAME.Unity/Assets/Plugins/UMAME/emu/Generic.cs index 6d84d97..ece271a 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/emu/Generic.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/emu/Generic.cs @@ -167,6 +167,8 @@ namespace MAME.Core set { spriteram_handle.ReleaseGCHandle(); + if (value == null) + return; spriteram_src = value; spriteramLength = value.Length; spriteram_src.GetObjectPtr(ref spriteram_handle, ref spriteram); diff --git a/MAME.Unity/Assets/Plugins/UMAME/emu/Inptport.cs b/MAME.Unity/Assets/Plugins/UMAME/emu/Inptport.cs index 72091fd..bc7f1fc 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/emu/Inptport.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/emu/Inptport.cs @@ -649,7 +649,7 @@ namespace MAME.Core delta -= analog.delta * 0x200; analog.lastdigital = 1; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { keypressed = true; delta += analog.delta * 0x200; @@ -684,7 +684,7 @@ namespace MAME.Core delta -= analog.delta * 0x200; analog.lastdigital = 1; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { keypressed = true; delta += analog.delta * 0x200; diff --git a/MAME.Unity/Assets/Plugins/UMAME/emu/Keyboard.cs b/MAME.Unity/Assets/Plugins/UMAME/emu/Keyboard.cs index e3564da..7db9b90 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/emu/Keyboard.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/emu/Keyboard.cs @@ -18,49 +18,212 @@ namespace MAME.Core public bool IsTriggered; public bool WasPressed; }; - private static Dictionary m_KeyStates = new Dictionary(); + private static Dictionary m_KeyStates = new Dictionary(); - static MotionKey[] mKeyName; + static ulong[] mKeysValue; public static void InitializeInput(IKeyboard ikb) { mKeyboard = ikb; - List temp = new List(); - foreach (MotionKey mkey in Enum.GetValues(typeof(MotionKey))) - { - //if (mkey > MotionKey.FinalKey) - // break; - m_KeyStates[mkey] = new KeyState(); - temp.Add(mkey); - } - mKeyName = temp.ToArray(); + List temp = new List(); + + #region 初始化m_KeyStates + m_KeyStates[MotionKey.None] = new KeyState(); + m_KeyStates[MotionKey.P1_INSERT_COIN] = new KeyState(); + m_KeyStates[MotionKey.P1_GAMESTART] = new KeyState(); + m_KeyStates[MotionKey.P1_UP] = new KeyState(); + m_KeyStates[MotionKey.P1_DOWN] = new KeyState(); + m_KeyStates[MotionKey.P1_LEFT] = new KeyState(); + m_KeyStates[MotionKey.P1_RIGHT] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_1] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_2] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_3] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_4] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_5] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_6] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_E] = new KeyState(); + m_KeyStates[MotionKey.P1_BTN_F] = new KeyState(); + m_KeyStates[MotionKey.P2_INSERT_COIN] = new KeyState(); + m_KeyStates[MotionKey.P2_GAMESTART] = new KeyState(); + m_KeyStates[MotionKey.P2_UP] = new KeyState(); + m_KeyStates[MotionKey.P2_DOWN] = new KeyState(); + m_KeyStates[MotionKey.P2_LEFT] = new KeyState(); + m_KeyStates[MotionKey.P2_RIGHT] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_1] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_2] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_3] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_4] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_5] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_6] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_E] = new KeyState(); + m_KeyStates[MotionKey.P2_BTN_F] = new KeyState(); + m_KeyStates[MotionKey.P3_INSERT_COIN] = new KeyState(); + m_KeyStates[MotionKey.P3_GAMESTART] = new KeyState(); + m_KeyStates[MotionKey.P3_UP] = new KeyState(); + m_KeyStates[MotionKey.P3_DOWN] = new KeyState(); + m_KeyStates[MotionKey.P3_LEFT] = new KeyState(); + m_KeyStates[MotionKey.P3_RIGHT] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_1] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_2] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_3] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_4] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_5] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_6] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_E] = new KeyState(); + m_KeyStates[MotionKey.P3_BTN_F] = new KeyState(); + m_KeyStates[MotionKey.P4_INSERT_COIN] = new KeyState(); + m_KeyStates[MotionKey.P4_GAMESTART] = new KeyState(); + m_KeyStates[MotionKey.P4_UP] = new KeyState(); + m_KeyStates[MotionKey.P4_DOWN] = new KeyState(); + m_KeyStates[MotionKey.P4_LEFT] = new KeyState(); + m_KeyStates[MotionKey.P4_RIGHT] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_1] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_2] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_3] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_4] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_5] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_6] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_E] = new KeyState(); + m_KeyStates[MotionKey.P4_BTN_F] = new KeyState(); + m_KeyStates[MotionKey.EMU_PAUSED] = new KeyState(); + m_KeyStates[MotionKey.Escape] = new KeyState(); + m_KeyStates[MotionKey.LeftShift] = new KeyState(); + m_KeyStates[MotionKey.RightShift] = new KeyState(); + m_KeyStates[MotionKey.FinalKey] = new KeyState(); + m_KeyStates[MotionKey.F10] = new KeyState(); + m_KeyStates[MotionKey.F9] = new KeyState(); + m_KeyStates[MotionKey.F8] = new KeyState(); + m_KeyStates[MotionKey.F7] = new KeyState(); + m_KeyStates[MotionKey.F6] = new KeyState(); + m_KeyStates[MotionKey.F5] = new KeyState(); + m_KeyStates[MotionKey.F4] = new KeyState(); + m_KeyStates[MotionKey.F3] = new KeyState(); + m_KeyStates[MotionKey.F2] = new KeyState(); + m_KeyStates[MotionKey.F1] = new KeyState(); + m_KeyStates[MotionKey.UNKNOW_Q] = new KeyState(); + m_KeyStates[MotionKey.UNKNOW_N] = new KeyState(); + m_KeyStates[MotionKey.UNKNOW_R] = new KeyState(); + m_KeyStates[MotionKey.UNKNOW_T] = new KeyState(); + m_KeyStates[MotionKey.UNKNOW_M] = new KeyState(); + m_KeyStates[MotionKey.UNKNOW_V] = new KeyState(); + m_KeyStates[MotionKey.UNKNOW_B] = new KeyState(); + + + + temp.Add(MotionKey.None); + temp.Add(MotionKey.P1_INSERT_COIN); + temp.Add(MotionKey.P1_GAMESTART); + temp.Add(MotionKey.P1_UP); + temp.Add(MotionKey.P1_DOWN); + temp.Add(MotionKey.P1_LEFT); + temp.Add(MotionKey.P1_RIGHT); + temp.Add(MotionKey.P1_BTN_1); + temp.Add(MotionKey.P1_BTN_2); + temp.Add(MotionKey.P1_BTN_3); + temp.Add(MotionKey.P1_BTN_4); + temp.Add(MotionKey.P1_BTN_5); + temp.Add(MotionKey.P1_BTN_6); + temp.Add(MotionKey.P1_BTN_E); + temp.Add(MotionKey.P1_BTN_F); + temp.Add(MotionKey.P2_INSERT_COIN); + temp.Add(MotionKey.P2_GAMESTART); + temp.Add(MotionKey.P2_UP); + temp.Add(MotionKey.P2_DOWN); + temp.Add(MotionKey.P2_LEFT); + temp.Add(MotionKey.P2_RIGHT); + temp.Add(MotionKey.P2_BTN_1); + temp.Add(MotionKey.P2_BTN_2); + temp.Add(MotionKey.P2_BTN_3); + temp.Add(MotionKey.P2_BTN_4); + temp.Add(MotionKey.P2_BTN_5); + temp.Add(MotionKey.P2_BTN_6); + temp.Add(MotionKey.P2_BTN_E); + temp.Add(MotionKey.P2_BTN_F); + temp.Add(MotionKey.P3_INSERT_COIN); + temp.Add(MotionKey.P3_GAMESTART); + temp.Add(MotionKey.P3_UP); + temp.Add(MotionKey.P3_DOWN); + temp.Add(MotionKey.P3_LEFT); + temp.Add(MotionKey.P3_RIGHT); + temp.Add(MotionKey.P3_BTN_1); + temp.Add(MotionKey.P3_BTN_2); + temp.Add(MotionKey.P3_BTN_3); + temp.Add(MotionKey.P3_BTN_4); + temp.Add(MotionKey.P3_BTN_5); + temp.Add(MotionKey.P3_BTN_6); + temp.Add(MotionKey.P3_BTN_E); + temp.Add(MotionKey.P3_BTN_F); + temp.Add(MotionKey.P4_INSERT_COIN); + temp.Add(MotionKey.P4_GAMESTART); + temp.Add(MotionKey.P4_UP); + temp.Add(MotionKey.P4_DOWN); + temp.Add(MotionKey.P4_LEFT); + temp.Add(MotionKey.P4_RIGHT); + temp.Add(MotionKey.P4_BTN_1); + temp.Add(MotionKey.P4_BTN_2); + temp.Add(MotionKey.P4_BTN_3); + temp.Add(MotionKey.P4_BTN_4); + temp.Add(MotionKey.P4_BTN_5); + temp.Add(MotionKey.P4_BTN_6); + temp.Add(MotionKey.P4_BTN_E); + temp.Add(MotionKey.P4_BTN_F); + temp.Add(MotionKey.EMU_PAUSED); + temp.Add(MotionKey.Escape); + temp.Add(MotionKey.LeftShift); + temp.Add(MotionKey.RightShift); + temp.Add(MotionKey.FinalKey); + temp.Add(MotionKey.F10); + temp.Add(MotionKey.F9); + temp.Add(MotionKey.F8); + temp.Add(MotionKey.F7); + temp.Add(MotionKey.F6); + temp.Add(MotionKey.F5); + temp.Add(MotionKey.F4); + temp.Add(MotionKey.F3); + temp.Add(MotionKey.F2); + temp.Add(MotionKey.F1); + temp.Add(MotionKey.UNKNOW_Q); + temp.Add(MotionKey.UNKNOW_N); + temp.Add(MotionKey.UNKNOW_R); + temp.Add(MotionKey.UNKNOW_T); + temp.Add(MotionKey.UNKNOW_M); + temp.Add(MotionKey.UNKNOW_V); + temp.Add(MotionKey.UNKNOW_B); + + mKeysValue = temp.ToArray(); + #endregion } - public static bool IsPressed(MotionKey key) + public static bool IsPressed(ulong key) { return m_KeyStates[key].IsPressed; } - public static bool IsTriggered(MotionKey key) + public static bool IsTriggered(ulong key) { return m_KeyStates[key].IsTriggered; } public static void Update() { - for (byte i = 0; i < mKeyName.Length; i++) + ulong currKeys = mKeyboard.GetPressedKeys(); + for (byte i = 0; i < mKeysValue.Length; i++) { - m_KeyStates[mKeyName[i]].IsPressed = false; + //m_KeyStates[mKeyName[i]].IsPressed = false; + m_KeyStates[mKeysValue[i]].IsPressed = (currKeys & (ulong)mKeysValue[i]) > 0; } //等待放行帧 Machine.mainMotion.WaitNextFrame(); - foreach (MotionKey key in mKeyboard.GetPressedKeys()) + //foreach (MotionKey key in mKeyboard.GetPressedKeys()) + //{ + // m_KeyStates[key].IsPressed = true; + //} + + + + for (int i = 0; i < mKeysValue.Length; i++) { - m_KeyStates[key].IsPressed = true; - } - for (int i = 0; i < mKeyName.Length; i++) - { - MotionKey key = mKeyName[i]; + ulong key = mKeysValue[i]; if (m_KeyStates[key].IsPressed) { if (m_KeyStates[key].WasPressed) diff --git a/MAME.Unity/Assets/Plugins/UMAME/emu/Memory.cs b/MAME.Unity/Assets/Plugins/UMAME/emu/Memory.cs index 166fb7f..6d99416 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/emu/Memory.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/emu/Memory.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Runtime.InteropServices; -using UnityEngine; namespace MAME.Core { diff --git a/MAME.Unity/Assets/Plugins/UMAME/emu/Motion.cs b/MAME.Unity/Assets/Plugins/UMAME/emu/Motion.cs index 308719c..afd81e1 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/emu/Motion.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/emu/Motion.cs @@ -1,10 +1,4 @@ -using MAME.Core; -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using UnityEngine.UIElements; - -namespace MAME.Core +namespace MAME.Core { /// /// 原依赖Form的内容 diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Gng.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Gng.cs index d0e2156..b6b43d2 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Gng.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Gng.cs @@ -55,6 +55,8 @@ namespace MAME.Core set { scrollx_handle.ReleaseGCHandle(); + if (value == null) + return; scrollx_src = value; scrollxLength = value.Length; scrollx_src.GetObjectPtr(ref scrollx_handle, ref scrollx); @@ -73,6 +75,8 @@ namespace MAME.Core set { scrolly_handle.ReleaseGCHandle(); + if (value == null) + return; scrolly_src = value; scrollyLength = value.Length; scrolly_src.GetObjectPtr(ref scrolly_handle, ref scrolly); diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Input.cs index 1970abd..c6828b5 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/capcom/Input.cs @@ -300,7 +300,7 @@ namespace MAME.Core { short1 |= 0x0020; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short0 &= ~0x0200; } @@ -324,7 +324,7 @@ namespace MAME.Core { short1 |= 0x0080; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { short0 &= ~0x0004; } @@ -380,7 +380,7 @@ namespace MAME.Core { short1 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short0 &= ~0x0400; } @@ -404,7 +404,7 @@ namespace MAME.Core { short1 |= unchecked((short)0x8000); } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { short0 &= ~0x0100; } @@ -511,7 +511,7 @@ namespace MAME.Core { short1 |= 0x0200; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short1 &= ~0x0400; } @@ -535,7 +535,7 @@ namespace MAME.Core { short1 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { short1 &= ~0x4000; } @@ -591,7 +591,7 @@ namespace MAME.Core { short2 |= 0x0200; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short2 &= ~0x0400; } @@ -615,7 +615,7 @@ namespace MAME.Core { short2 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { short2 &= ~0x4000; } @@ -722,7 +722,7 @@ namespace MAME.Core { sbyte1 &= ~0x02; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { sbyte1 |= 0x04; } @@ -746,7 +746,7 @@ namespace MAME.Core { sbyte2 &= ~0x02; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { sbyte2 |= 0x04; } @@ -802,7 +802,7 @@ namespace MAME.Core { sbyte3 &= ~0x02; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { sbyte3 |= 0x04; } @@ -826,7 +826,7 @@ namespace MAME.Core { sbyte4 |= 0x02; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { sbyte4 |= 0x04; } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/cps/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/cps/Input.cs index e36a466..75b765a 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/cps/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/cps/Input.cs @@ -86,7 +86,7 @@ namespace MAME.Core { short1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short1 &= ~0x40; } @@ -110,7 +110,7 @@ namespace MAME.Core { short2 |= 0x02; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { short2 &= ~0x04; } @@ -166,7 +166,7 @@ namespace MAME.Core { short1 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short1 &= ~0x4000; } @@ -190,7 +190,7 @@ namespace MAME.Core { short2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { short2 &= ~0x40; } @@ -430,7 +430,7 @@ namespace MAME.Core { short1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short1 &= ~0x40; } @@ -454,7 +454,7 @@ namespace MAME.Core { short2 |= 0x0200; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { short2 &= ~0x0400; } @@ -510,7 +510,7 @@ namespace MAME.Core { short1 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short1 &= ~0x4000; } @@ -534,7 +534,7 @@ namespace MAME.Core { short2 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { short2 &= ~0x4000; } @@ -609,7 +609,7 @@ namespace MAME.Core { short1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short1 &= ~0x40; } @@ -641,7 +641,7 @@ namespace MAME.Core { short1 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short1 &= ~0x4000; } @@ -756,7 +756,7 @@ namespace MAME.Core { short0 |= 0x0020; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short0 &= ~0x0040; } @@ -780,7 +780,7 @@ namespace MAME.Core { short1 |= 0x0002; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { short1 &= ~0x0004; } @@ -836,7 +836,7 @@ namespace MAME.Core { short0 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short0 &= ~0x4000; } @@ -860,7 +860,7 @@ namespace MAME.Core { short1 |= 0x0020; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { short2 &= ~0x4000; } @@ -975,7 +975,7 @@ namespace MAME.Core { short0 |= 0x0020; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short0 &= ~0x0040; } @@ -999,7 +999,7 @@ namespace MAME.Core { short1 |= 0x0002; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { short1 &= ~0x0004; } @@ -1063,7 +1063,7 @@ namespace MAME.Core { short0 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short0 &= ~0x4000; } @@ -1087,7 +1087,7 @@ namespace MAME.Core { short1 |= 0x0020; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { short2 &= ~0x4000; } @@ -1194,7 +1194,7 @@ namespace MAME.Core { short0 |= 0x0020; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short0 &= ~0x0040; } @@ -1250,7 +1250,7 @@ namespace MAME.Core { short0 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short0 &= ~0x4000; } @@ -1327,7 +1327,7 @@ namespace MAME.Core { short0 |= 0x0004; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short0 &= ~0x0002; } @@ -1359,7 +1359,7 @@ namespace MAME.Core { short0 |= 0x0400; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short0 &= ~0x0200; } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/igs011/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/igs011/Input.cs index 228ab14..e0affd8 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/igs011/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/igs011/Input.cs @@ -87,7 +87,7 @@ namespace MAME.Core { sbyte0 |= 0x40; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { sbyte2 &= ~0x08; } @@ -111,7 +111,7 @@ namespace MAME.Core { } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { } @@ -167,7 +167,7 @@ namespace MAME.Core { sbyte2 |= unchecked((sbyte)0x80); } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { sbyte1 &= unchecked((sbyte)~0x80); } @@ -191,7 +191,7 @@ namespace MAME.Core { } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/konami68000/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/konami68000/Input.cs index 6cf32fa..6cfe74d 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/konami68000/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/konami68000/Input.cs @@ -90,7 +90,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { sbyte1 &= ~0x40; } @@ -146,7 +146,7 @@ namespace MAME.Core { sbyte2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { sbyte2 &= ~0x40; } @@ -237,7 +237,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { //sbyte1 &= ~0x04; } @@ -293,7 +293,7 @@ namespace MAME.Core { sbyte2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { //sbyte1 &= ~0x40; } @@ -400,7 +400,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { //sbyte1 &= ~0x04; } @@ -456,7 +456,7 @@ namespace MAME.Core { sbyte2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { //sbyte1 &= ~0x40; } @@ -563,7 +563,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { sbyte1 &= ~0x40; } @@ -627,7 +627,7 @@ namespace MAME.Core { sbyte2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { sbyte2 &= ~0x40; } @@ -905,7 +905,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { //sbyte1 &= ~0x04; } @@ -961,7 +961,7 @@ namespace MAME.Core { sbyte2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { //sbyte1 &= ~0x40; } @@ -1076,7 +1076,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { //sbyte1 &= ~0x04; } @@ -1140,7 +1140,7 @@ namespace MAME.Core { sbyte2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { //sbyte1 &= ~0x40; } @@ -1247,7 +1247,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { //sbyte1 &= ~0x04; } @@ -1303,7 +1303,7 @@ namespace MAME.Core { sbyte2 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { //sbyte1 &= ~0x40; } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/m72/M72.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/m72/M72.cs index b042a35..48509fc 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/m72/M72.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/m72/M72.cs @@ -65,6 +65,8 @@ namespace MAME.Core set { samplesrom_handle.ReleaseGCHandle(); + if (value == null) + return; samplesrom_src = value; samplesromLength = value.Length; samplesrom_src.GetObjectPtr(ref samplesrom_handle, ref samplesrom); @@ -121,6 +123,8 @@ namespace MAME.Core set { gfx3rom_handle.ReleaseGCHandle(); + if (value == null) + return; gfx3rom_src = value; gfx3romLength = value.Length; gfx3rom_src.GetObjectPtr(ref gfx3rom_handle, ref gfx3rom); diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/namcos1/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/namcos1/Input.cs index 29473ad..56a2d1b 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/namcos1/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/namcos1/Input.cs @@ -86,7 +86,7 @@ namespace MAME.Core { byte0 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { byte0 &= unchecked((byte)~0x40); } @@ -142,7 +142,7 @@ namespace MAME.Core { byte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { byte1 &= unchecked((byte)~0x40); } @@ -217,7 +217,7 @@ namespace MAME.Core { byte0 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { byte0 &= unchecked((byte)~0x40); } @@ -241,7 +241,7 @@ namespace MAME.Core { byte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { byte1 &= unchecked((byte)~0x40); } @@ -350,7 +350,7 @@ namespace MAME.Core { byte01 &= unchecked((byte)~0x02); } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { byte01 |= 0x04; } @@ -374,7 +374,7 @@ namespace MAME.Core { byte00 &= unchecked((byte)~0x02); } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { byte00 |= 0x04; } @@ -430,7 +430,7 @@ namespace MAME.Core { byte03 &= unchecked((byte)~0x02); } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { byte03 |= 0x04; } @@ -454,7 +454,7 @@ namespace MAME.Core { byte02 &= unchecked((byte)~0x02); } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { byte02 |= 0x04; } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/neogeo/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/neogeo/Input.cs index ada5a86..f8ff4e8 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/neogeo/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/neogeo/Input.cs @@ -89,7 +89,7 @@ namespace MAME.Core { short0 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { } @@ -113,7 +113,7 @@ namespace MAME.Core { short0 |= unchecked((short)0x8000); } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { } @@ -169,7 +169,7 @@ namespace MAME.Core { short1 |= 0x2000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { } @@ -194,7 +194,7 @@ namespace MAME.Core short1 |= unchecked((short)0x8000); } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/pgm/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/pgm/Input.cs index 4406830..f3b1129 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/pgm/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/pgm/Input.cs @@ -86,7 +86,7 @@ namespace MAME.Core { short0 |= 0x0040; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { short0 &= ~0x0080; } @@ -110,7 +110,7 @@ namespace MAME.Core { } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.O)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.O)) { } @@ -166,7 +166,7 @@ namespace MAME.Core { short0 |= 0x4000; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { short0 &= unchecked((short)~0x8000); } @@ -190,7 +190,7 @@ namespace MAME.Core { } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_F))//if (Keyboard.IsPressed(Corekey.NumPad6)) { } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/suna8/SunA8.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/suna8/SunA8.cs index f7bef21..8945992 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/suna8/SunA8.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/suna8/SunA8.cs @@ -85,6 +85,8 @@ namespace MAME.Core set { samplesrom_handle.ReleaseGCHandle(); + if (value == null) + return; samplesrom_src = value; samplesromLength = value.Length; samplesrom_src.GetObjectPtr(ref samplesrom_handle, ref samplesrom); diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/taitob/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/taitob/Input.cs index 99ecba5..626c0f4 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/taitob/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/taitob/Input.cs @@ -90,7 +90,7 @@ namespace MAME.Core { sbyte1 |= 0x02; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { sbyte1 &= ~0x04; } @@ -146,7 +146,7 @@ namespace MAME.Core { sbyte1 |= 0x20; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { sbyte1 &= ~0x40; } @@ -253,7 +253,7 @@ namespace MAME.Core { sbyte0 |= 0x02; } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { sbyte0 &= ~0x04; } @@ -309,7 +309,7 @@ namespace MAME.Core { sbyte0 |= 0x10; } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { sbyte0 &= ~0x20; } diff --git a/MAME.Unity/Assets/Plugins/UMAME/mame/tehkan/Input.cs b/MAME.Unity/Assets/Plugins/UMAME/mame/tehkan/Input.cs index e26d802..0a01c91 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/mame/tehkan/Input.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/mame/tehkan/Input.cs @@ -54,7 +54,7 @@ namespace MAME.Core { byte0 &= unchecked((byte)~0x10); } - if (Keyboard.IsPressed(MotionKey.P1_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.L)) + if (Keyboard.IsPressed(MotionKey.P1_BTN_E))//if (Keyboard.IsPressed(Corekey.L)) { byte0 |= 0x01; } @@ -86,7 +86,7 @@ namespace MAME.Core { byte1 &= unchecked((byte)~0x10); } - if (Keyboard.IsPressed(MotionKey.P2_UNKNOW_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) + if (Keyboard.IsPressed(MotionKey.P2_BTN_E))//if (Keyboard.IsPressed(Corekey.NumPad3)) { byte1 |= 0x01; } diff --git a/MAME.Unity/Assets/Plugins/UMAME/run_interface/IKeyboard.cs b/MAME.Unity/Assets/Plugins/UMAME/run_interface/IKeyboard.cs index de5ac8f..527dba3 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/run_interface/IKeyboard.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/run_interface/IKeyboard.cs @@ -2,6 +2,6 @@ { public interface IKeyboard { - MotionKey[] GetPressedKeys(); + ulong GetPressedKeys(); } } diff --git a/MAME.Unity/Assets/Plugins/UMAME/run_interface/MotionKey.cs b/MAME.Unity/Assets/Plugins/UMAME/run_interface/MotionKey.cs index 234a9d0..f485628 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/run_interface/MotionKey.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/run_interface/MotionKey.cs @@ -1,62 +1,278 @@ using System; +using System.Collections.Generic; +using UnityEngine; namespace MAME.Core { - [Flags] - public enum MotionKey : long + public static class MotionKey { - None = (0), - P1_INSERT_COIN = (1), - P1_GAMESTART = (1 << 1), - P1_UP = (1 << 2), - P1_DOWN = (1 << 3), - P1_LEFT = (1 << 4), - P1_RIGHT = (1 << 5), - P1_BTN_1 = (1 << 6), - P1_BTN_2 = (1 << 7), - P1_BTN_3 = (1 << 8), - P1_BTN_4 = (1 << 9), - P1_BTN_5 = (1 << 10), - P1_BTN_6 = (1 << 11), - P1_UNKNOW_E = (1 << 12), - P1_UNKNOW_F = (1 << 13), - P2_INSERT_COIN = (1 << 14), - P2_GAMESTART = (1 << 15), - P2_UP = (1 << 16), - P2_DOWN = (1 << 17), - P2_LEFT = (1 << 18), - P2_RIGHT = (1 << 19), - P2_BTN_1 = (1 << 20), - P2_BTN_2 = (1 << 21), - P2_BTN_3 = (1 << 22), - P2_BTN_4 = (1 << 23), - P2_BTN_5 = (1 << 24), - P2_BTN_6 = (1 << 25), - P2_UNKNOW_E = (1 << 26), - P2_UNKNOW_F = (1 << 27), - Escape = (1 << 28), - LeftShift = (1 << 29), - RightShift = (1 << 30), - FinalKey = (1 << 31), - EMU_PAUSED = 1<< 31, - F10 = 1<< 31, - F9 = 1<< 31, - F8 = 1<< 31, - F7 = 1<< 31, - F6 = 1<< 31, - F5 = 1<< 31, - F4 = 1<< 31, - F3 = 1<< 31, - F2 = 1<< 31, - F1 = 1<< 31, - UNKNOW_Q = 1<< 31, - UNKNOW_N = 1<< 31, - UNKNOW_R = 1<< 31, - UNKNOW_T = 1<< 31, - UNKNOW_M = 1<< 31, - UNKNOW_V = 1<< 31, - UNKNOW_B = 1<< 31 + public const ulong None = (0L); + public const ulong P1_INSERT_COIN = (1L); + public const ulong P1_GAMESTART = (1L << 1); + public const ulong P1_UP = (1L << 2); + public const ulong P1_DOWN = (1L << 3); + public const ulong P1_LEFT = (1L << 4); + public const ulong P1_RIGHT = (1L << 5); + public const ulong P1_BTN_1 = (1L << 6); + public const ulong P1_BTN_2 = (1L << 7); + public const ulong P1_BTN_3 = (1L << 8); + public const ulong P1_BTN_4 = (1L << 9); + public const ulong P1_BTN_5 = (1L << 10); + public const ulong P1_BTN_6 = (1L << 11); + public const ulong P1_BTN_E = (1L << 12); + public const ulong P1_BTN_F = (1L << 13); + + + public const ulong P2_INSERT_COIN = (1L << (16)); + public const ulong P2_GAMESTART = (1L << (16 + 1)); + public const ulong P2_UP = (1L << (16 + 2)); + public const ulong P2_DOWN = (1L << (16 + 3)); + public const ulong P2_LEFT = (1L << (16 + 4)); + public const ulong P2_RIGHT = (1L << (16 + 5)); + public const ulong P2_BTN_1 = (1L << (16 + 6)); + public const ulong P2_BTN_2 = (1L << (16 + 7)); + public const ulong P2_BTN_3 = (1L << (16 + 8)); + public const ulong P2_BTN_4 = (1L << (16 + 9)); + public const ulong P2_BTN_5 = (1L << (16 + 10)); + public const ulong P2_BTN_6 = (1L << (16 + 11)); + public const ulong P2_BTN_E = (1L << (16 + 12)); + public const ulong P2_BTN_F = (1L << (16 + 13)); + + + public const ulong P3_INSERT_COIN = (1L << (32)); + public const ulong P3_GAMESTART = (1L << (32 + 1)); + public const ulong P3_UP = (1L << (32 + 2)); + public const ulong P3_DOWN = (1L << (32 + 3)); + public const ulong P3_LEFT = (1L << (32 + 4)); + public const ulong P3_RIGHT = (1L << (32 + 5)); + public const ulong P3_BTN_1 = (1L << (32 + 6)); + public const ulong P3_BTN_2 = (1L << (32 + 7)); + public const ulong P3_BTN_3 = (1L << (32 + 8)); + public const ulong P3_BTN_4 = (1L << (32 + 9)); + public const ulong P3_BTN_5 = (1L << (32 + 10)); + public const ulong P3_BTN_6 = (1L << (32 + 11)); + public const ulong P3_BTN_E = (1L << (32 + 12)); + public const ulong P3_BTN_F = (1L << (32 + 13)); + + + public const ulong P4_INSERT_COIN = (1L << (48)); + public const ulong P4_GAMESTART = (1L << (48 + 1)); + public const ulong P4_UP = (1L << (48 + 2)); + public const ulong P4_DOWN = (1L << (48 + 3)); + public const ulong P4_LEFT = (1L << (48 + 4)); + public const ulong P4_RIGHT = (1L << (48 + 5)); + public const ulong P4_BTN_1 = (1L << (48 + 6)); + public const ulong P4_BTN_2 = (1L << (48 + 7)); + public const ulong P4_BTN_3 = (1L << (48 + 8)); + public const ulong P4_BTN_4 = (1L << (48 + 9)); + public const ulong P4_BTN_5 = (1L << (48 + 10)); + public const ulong P4_BTN_6 = (1L << (48 + 11)); + public const ulong P4_BTN_E = (1L << (48 + 12)); + public const ulong P4_BTN_F = (1L << (48 + 13)); + + //预留按键 + //(1L << 14) + //(1L << 15) + //(1L << (16 + 14)) + //(1L << (16 + 15)) + //(1L << (32 + 14)) + //(1L << (32 + 15)) + //(1L << (48 + 14)) + //这个应该是不能用了-->(1L << (48 + 15)) + + public const ulong EMU_PAUSED = (1L << 14); + public const ulong Escape = (1L << 15); + public const ulong LeftShift = (1L << (16 + 14)); + public const ulong RightShift = (1L << (16 + 15)); + public const ulong FinalKey = (1L << (32 + 14)); + public const ulong F10 = (1L << (32 + 14)); + public const ulong F9 = (1L << (32 + 14)); + public const ulong F8 = (1L << (32 + 14)); + public const ulong F7 = (1L << (32 + 14)); + public const ulong F6 = (1L << (32 + 14)); + public const ulong F5 = (1L << (32 + 14)); + public const ulong F4 = (1L << (32 + 14)); + public const ulong F3 = (1L << (32 + 14)); + public const ulong F2 = (1L << (32 + 14)); + public const ulong F1 = (1L << (32 + 14)); + public const ulong UNKNOW_Q = (1L << (32 + 14)); + public const ulong UNKNOW_N = (1L << (32 + 14)); + public const ulong UNKNOW_R = (1L << (32 + 14)); + public const ulong UNKNOW_T = (1L << (32 + 14)); + public const ulong UNKNOW_M = (1L << (32 + 14)); + public const ulong UNKNOW_V = (1L << (32 + 14)); + public const ulong UNKNOW_B = (1L << (32 + 14)); + + public readonly static ulong[] AllNeedCheckList = new ulong[] + { + None, + P1_INSERT_COIN, + P1_GAMESTART, + P1_UP, + P1_DOWN, + P1_LEFT, + P1_RIGHT, + P1_BTN_1, + P1_BTN_2, + P1_BTN_3, + P1_BTN_4, + P1_BTN_5, + P1_BTN_6, + P1_BTN_E, + P1_BTN_F, + P2_INSERT_COIN, + P2_GAMESTART, + P2_UP, + P2_DOWN, + P2_LEFT, + P2_RIGHT, + P2_BTN_1, + P2_BTN_2, + P2_BTN_3, + P2_BTN_4, + P2_BTN_5, + P2_BTN_6, + P2_BTN_E, + P2_BTN_F, + P3_INSERT_COIN, + P3_GAMESTART, + P3_UP, + P3_DOWN, + P3_LEFT, + P3_RIGHT, + P3_BTN_1, + P3_BTN_2, + P3_BTN_3, + P3_BTN_4, + P3_BTN_5, + P3_BTN_6, + P3_BTN_E, + P3_BTN_F, + P4_INSERT_COIN, + P4_GAMESTART, + P4_UP, + P4_DOWN, + P4_LEFT, + P4_RIGHT, + P4_BTN_1, + P4_BTN_2, + P4_BTN_3, + P4_BTN_4, + P4_BTN_5, + P4_BTN_6, + P4_BTN_E, + P4_BTN_F, + EMU_PAUSED, + Escape, + LeftShift, + RightShift, + FinalKey, + F10, + F9, + F8, + F7, + F6, + F5, + F4, + F3, + F2, + F1, + UNKNOW_Q, + UNKNOW_N, + UNKNOW_R, + UNKNOW_T, + UNKNOW_M, + UNKNOW_V, + UNKNOW_B, + }; + + public static string GetKeyName(ulong key) + { + switch (key) + { + case MotionKey.None: return "None"; + case MotionKey.P1_INSERT_COIN: return "P1_INSERT_COIN"; + case MotionKey.P1_GAMESTART: return "P1_GAMESTART"; + case MotionKey.P1_UP: return "P1_UP"; + case MotionKey.P1_DOWN: return "P1_DOWN"; + case MotionKey.P1_LEFT: return "P1_LEFT"; + case MotionKey.P1_RIGHT: return "P1_RIGHT"; + case MotionKey.P1_BTN_1: return "P1_BTN_1"; + case MotionKey.P1_BTN_2: return "P1_BTN_2"; + case MotionKey.P1_BTN_3: return "P1_BTN_3"; + case MotionKey.P1_BTN_4: return "P1_BTN_4"; + case MotionKey.P1_BTN_5: return "P1_BTN_5"; + case MotionKey.P1_BTN_6: return "P1_BTN_6"; + case MotionKey.P1_BTN_E: return "P1_BTN_E"; + case MotionKey.P1_BTN_F: return "P1_BTN_F"; + case MotionKey.P2_INSERT_COIN: return "P2_INSERT_COIN"; + case MotionKey.P2_GAMESTART: return "P2_GAMESTART"; + case MotionKey.P2_UP: return "P2_UP"; + case MotionKey.P2_DOWN: return "P2_DOWN"; + case MotionKey.P2_LEFT: return "P2_LEFT"; + case MotionKey.P2_RIGHT: return "P2_RIGHT"; + case MotionKey.P2_BTN_1: return "P2_BTN_1"; + case MotionKey.P2_BTN_2: return "P2_BTN_2"; + case MotionKey.P2_BTN_3: return "P2_BTN_3"; + case MotionKey.P2_BTN_4: return "P2_BTN_4"; + case MotionKey.P2_BTN_5: return "P2_BTN_5"; + case MotionKey.P2_BTN_6: return "P2_BTN_6"; + case MotionKey.P2_BTN_E: return "P2_BTN_E"; + case MotionKey.P2_BTN_F: return "P2_BTN_F"; + case MotionKey.P3_INSERT_COIN: return "P3_INSERT_COIN"; + case MotionKey.P3_GAMESTART: return "P3_GAMESTART"; + case MotionKey.P3_UP: return "P3_UP"; + case MotionKey.P3_DOWN: return "P3_DOWN"; + case MotionKey.P3_LEFT: return "P3_LEFT"; + case MotionKey.P3_RIGHT: return "P3_RIGHT"; + case MotionKey.P3_BTN_1: return "P3_BTN_1"; + case MotionKey.P3_BTN_2: return "P3_BTN_2"; + case MotionKey.P3_BTN_3: return "P3_BTN_3"; + case MotionKey.P3_BTN_4: return "P3_BTN_4"; + case MotionKey.P3_BTN_5: return "P3_BTN_5"; + case MotionKey.P3_BTN_6: return "P3_BTN_6"; + case MotionKey.P3_BTN_E: return "P3_BTN_E"; + case MotionKey.P3_BTN_F: return "P3_BTN_F"; + case MotionKey.P4_INSERT_COIN: return "P4_INSERT_COIN"; + case MotionKey.P4_GAMESTART: return "P4_GAMESTART"; + case MotionKey.P4_UP: return "P4_UP"; + case MotionKey.P4_DOWN: return "P4_DOWN"; + case MotionKey.P4_LEFT: return "P4_LEFT"; + case MotionKey.P4_RIGHT: return "P4_RIGHT"; + case MotionKey.P4_BTN_1: return "P4_BTN_1"; + case MotionKey.P4_BTN_2: return "P4_BTN_2"; + case MotionKey.P4_BTN_3: return "P4_BTN_3"; + case MotionKey.P4_BTN_4: return "P4_BTN_4"; + case MotionKey.P4_BTN_5: return "P4_BTN_5"; + case MotionKey.P4_BTN_6: return "P4_BTN_6"; + case MotionKey.P4_BTN_E: return "P4_BTN_E"; + case MotionKey.P4_BTN_F: return "P4_BTN_F"; + case MotionKey.EMU_PAUSED: return "EMU_PAUSED"; + case MotionKey.Escape: return "Escape"; + case MotionKey.LeftShift: return "LeftShift"; + case MotionKey.RightShift: return "RightShift"; + case MotionKey.FinalKey: return "FinalKey"; + default: return "None"; + //case MotionKey.F10:return "F10"; + //case MotionKey.F9:return "F9"; + //case MotionKey.F8:return "F8"; + //case MotionKey.F7:return "F7"; + //case MotionKey.F6:return "F6"; + //case MotionKey.F5:return "F5"; + //case MotionKey.F4:return "F4"; + //case MotionKey.F3:return "F3"; + //case MotionKey.F2:return "F2"; + //case MotionKey.F1:return "F1"; + //case MotionKey.UNKNOW_Q:return "UNKNOW_Q"; + //case MotionKey.UNKNOW_N:return "UNKNOW_N"; + //case MotionKey.UNKNOW_R:return "UNKNOW_R"; + //case MotionKey.UNKNOW_T:return "UNKNOW_T"; + //case MotionKey.UNKNOW_M:return "UNKNOW_M"; + //case MotionKey.UNKNOW_V:return "UNKNOW_V"; + //case MotionKey.UNKNOW_B: return "UNKNOW_B"; + } + } //EMU_PAUSED = (1 << 36), //F10 = (1 << 37), @@ -133,5 +349,139 @@ namespace MAME.Core //EMU_PAUSED, + } + + //[Flags] + //public enum MotionKey : long + //{ + // None = (0), + // P1_INSERT_COIN = (1), + // P1_GAMESTART = (1 << 1), + // P1_UP = (1 << 2), + // P1_DOWN = (1 << 3), + // P1_LEFT = (1 << 4), + // P1_RIGHT = (1 << 5), + // P1_BTN_1 = (1 << 6), + // P1_BTN_2 = (1 << 7), + // P1_BTN_3 = (1 << 8), + // P1_BTN_4 = (1 << 9), + // P1_BTN_5 = (1 << 10), + // P1_BTN_6 = (1 << 11), + // P1_UNKNOW_E = (1 << 12), + // P1_UNKNOW_F = (1 << 13), + // P2_INSERT_COIN = (1 << 14), + // P2_GAMESTART = (1 << 15), + // P2_UP = (1 << 16), + // P2_DOWN = (1 << 17), + // P2_LEFT = (1 << 18), + // P2_RIGHT = (1 << 19), + // P2_BTN_1 = (1 << 20), + // P2_BTN_2 = (1 << 21), + // P2_BTN_3 = (1 << 22), + // P2_BTN_4 = (1 << 23), + // P2_BTN_5 = (1 << 24), + // P2_BTN_6 = (1 << 25), + // P2_UNKNOW_E = (1 << 26), + // P2_UNKNOW_F = (1 << 27), + // Escape = (1 << 28), + // LeftShift = (1 << 29), + // RightShift = (1 << 30), + // FinalKey = (1 << 31), + + // EMU_PAUSED = 1<< 31, + // F10 = 1<< 31, + // F9 = 1<< 31, + // F8 = 1<< 31, + // F7 = 1<< 31, + // F6 = 1<< 31, + // F5 = 1<< 31, + // F4 = 1<< 31, + // F3 = 1<< 31, + // F2 = 1<< 31, + // F1 = 1<< 31, + // UNKNOW_Q = 1<< 31, + // UNKNOW_N = 1<< 31, + // UNKNOW_R = 1<< 31, + // UNKNOW_T = 1<< 31, + // UNKNOW_M = 1<< 31, + // UNKNOW_V = 1<< 31, + // UNKNOW_B = 1<< 31 + + // //EMU_PAUSED = (1 << 36), + // //F10 = (1 << 37), + // //F9 = (1 << 38), + // //F8 = (1 << 39), + // //F7 = (1 << 40), + // //F6 = (1 << 41), + // //F5 = (1 << 42), + // //F4 = (1 << 43), + // //F3 = (1 << 44), + // //F2 = (1 << 45), + // //F1 = (1 << 46), + // //UNKNOW_Q = (1 << 47), + // //UNKNOW_N = (1 << 48), + // //UNKNOW_R = (1 << 49), + // //UNKNOW_T = (1 << 50), + // //UNKNOW_M = (1 << 51), + // //UNKNOW_V = (1 << 52), + // //UNKNOW_B = (1 << 53), + // //None = 0, + // //P1_INSERT_COIN = 1, + // //P1_GAMESTART = 2 << 1, + // //P1_UP = 4, + // //P1_DOWN = 8, + // //P1_LEFT = 16, + // //P1_RIGHT = 32, + // //P1_BTN_1 = 64, + // //P1_BTN_2 = 128, + // //P1_BTN_3 = 256, + // //P1_BTN_4 = 512, + // //P1_BTN_5 = 1024, + // //P1_BTN_6 = 4096, + // //P1_UNKNOW_E = 8192, + // //P1_UNKNOW_F, + // //P2_INSERT_COIN, + // //P2_GAMESTART, + // //P2_UP, + // //P2_DOWN, + // //P2_LEFT, + // //P2_RIGHT, + // //P2_BTN_1, + // //P2_BTN_2, + // //P2_BTN_3, + // //P2_BTN_4, + // //P2_BTN_5, + // //P2_BTN_6, + // //P2_UNKNOW_E, + // //P2_UNKNOW_F, + // //UNKNOW_Q, + // //UNKNOW_N, + // //UNKNOW_R, + // //UNKNOW_T, + // //UNKNOW_M, + // //UNKNOW_V, + // //UNKNOW_B, + // //F10, + // //F9, + // //F8, + // //F7, + // //F6, + // //F5, + // //F4, + // //F3, + // //F2, + // //F1, + // //Escape, + // //LeftShift, + // //RightShift, + // ///// + // ///// 用于标记最后一个 + // ///// + // //FinalKey, + + + + // //EMU_PAUSED, + //} } diff --git a/MAME.Unity/Assets/Plugins/UMAME/sound/Sample.cs b/MAME.Unity/Assets/Plugins/UMAME/sound/Sample.cs index f17f46f..641232e 100644 --- a/MAME.Unity/Assets/Plugins/UMAME/sound/Sample.cs +++ b/MAME.Unity/Assets/Plugins/UMAME/sound/Sample.cs @@ -21,6 +21,8 @@ namespace MAME.Core set { source_handle.ReleaseGCHandle(); + if (value == null) + return; source_src = value; sourceLength = value.Length; source_src.GetObjectPtr(ref source_handle, ref source); diff --git a/MAME.Unity/Assets/Scenes/SampleScene.unity b/MAME.Unity/Assets/Scenes/SampleScene.unity index 2218fe2..81d8d32 100644 --- a/MAME.Unity/Assets/Scenes/SampleScene.unity +++ b/MAME.Unity/Assets/Scenes/SampleScene.unity @@ -213,6 +213,38 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 97142682492627208, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 97142682492627208, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 97142682492627208, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 97142682492627208, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1553850566392038418, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1553850566392038418, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1553850566392038418, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1553850566392038418, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3471319444242429640, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} propertyPath: m_IsActive value: 1 @@ -267,19 +299,95 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3471319444260926877, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} propertyPath: bQuickTestRom - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 3471319444260926877, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} propertyPath: mQuickTestRom - value: 1944 + value: kof10th objectReference: {fileID: 0} - target: {fileID: 3471319444260926877, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} propertyPath: mChangeRomName value: opwolf objectReference: {fileID: 0} + - target: {fileID: 3471319444260926879, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3471319445208116032, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3471319445208116032, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3471319445208116032, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3471319445208116032, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 3471319445309129982, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} propertyPath: m_IsActive value: 1 objectReference: {fileID: 0} + - target: {fileID: 4817073881051249870, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4817073881051249870, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4817073881051249870, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4817073881051249870, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6218974894225195416, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6218974894225195416, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6847488682063653578, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6847488682063653578, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6847488682063653578, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6847488682063653578, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8635128341793952131, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8635128341793952131, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8635128341793952131, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8635128341793952131, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1cb6308e67105bf48aea153ebcdb2d76, type: 3} diff --git a/MAME.Unity/Assets/Script/UMAME/UMAME.cs b/MAME.Unity/Assets/Script/UMAME/UMAME.cs index bcefaad..516536a 100644 --- a/MAME.Unity/Assets/Script/UMAME/UMAME.cs +++ b/MAME.Unity/Assets/Script/UMAME/UMAME.cs @@ -110,7 +110,7 @@ public class UMAME : MonoBehaviour void LoadGame(bool bReplay = false) { - //Application.targetFrameRate = 60; + Application.targetFrameRate = 60; mReplayWriter = new ReplayWriter(mChangeRomName, "fuck", ReplayData.ReplayFormat.FM32IP64, Encoding.UTF8); mChangeRomName = HadGameList[optionDropdown.value].Name; diff --git a/MAME.Unity/Assets/Script/UMAME/UniInterface/UniKeyboard.cs b/MAME.Unity/Assets/Script/UMAME/UniInterface/UniKeyboard.cs index 17bd580..ae46db3 100644 --- a/MAME.Unity/Assets/Script/UMAME/UniInterface/UniKeyboard.cs +++ b/MAME.Unity/Assets/Script/UMAME/UniInterface/UniKeyboard.cs @@ -1,6 +1,7 @@ using MAME.Core; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices.ComTypes; using UnityEngine; public class UniKeyboard : MonoBehaviour, IKeyboard @@ -22,13 +23,14 @@ public class UniKeyboard : MonoBehaviour, IKeyboard public List mUIBtns = new List(); #endregion - public static Dictionary dictKeyCfgs = new Dictionary(); - public static KeyCode[] CheckList; + public static Dictionary dictKeyCfgs = new Dictionary(); bool bReplayMode; PlayMode mPlayMode; ReplayMode mReplayMode; ulong last_CurryInpuAllData_test = 0; + public static KeyCode[] CheckList; + void Awake() { mJoystick = GameObject.Find("tfJoystick").GetComponent(); @@ -72,27 +74,15 @@ public class UniKeyboard : MonoBehaviour, IKeyboard Init(false); } - public MotionKey[] GetPressedKeys() + public ulong GetPressedKeys() { - MotionKey[] currkey; ulong InputData; if (!bReplayMode) - currkey = mPlayMode.GetPressedKeys(out InputData); + InputData = mPlayMode.GetPressedKeys(); else - currkey = mReplayMode.GetPressedKeys(out InputData); -#if UNITY_EDITOR - if (last_CurryInpuAllData_test != InputData) - { - string TempStr = ""; - foreach (var item in currkey) - { - TempStr += $"{item.ToString()}|"; - } - Debug.Log($"{UMAME.instance.mUniVideoPlayer.mFrame} | {EmuTimer.get_current_time().attoseconds} |{EmuTimer.get_current_time().seconds} | {InputData} | {TempStr}"); - last_CurryInpuAllData_test = InputData; - } -#endif - return currkey; + InputData = mReplayMode.GetPressedKeys(); + + return InputData; } public void UpdateInputKey() @@ -157,13 +147,9 @@ public class UniKeyboard : MonoBehaviour, IKeyboard } public class PlayMode { - Dictionary dictKeyCfgs => UniKeyboard.dictKeyCfgs; UniKeyboard mUniKeyboard; - KeyCode[] CheckList => UniKeyboard.CheckList; ulong tempInputAllData = 0; - List temp = new List(); public ulong CurryInpuAllData = 0; - public MotionKey[] mCurrKey = new MotionKey[0]; public PlayMode(UniKeyboard uniKeyboard) { @@ -173,13 +159,12 @@ public class UniKeyboard : MonoBehaviour, IKeyboard public void UpdateLogic() { tempInputAllData = 0; - temp.Clear(); + for (int i = 0; i < CheckList.Length; i++) { if (Input.GetKey(CheckList[i])) { - MotionKey mk = dictKeyCfgs[CheckList[i]]; - temp.Add(mk); + ulong mk = dictKeyCfgs[CheckList[i]]; tempInputAllData |= (ulong)mk; } } @@ -190,110 +175,90 @@ public class UniKeyboard : MonoBehaviour, IKeyboard { for (int j = 0; j < mUniKeyboard.mUIBtns[i].Key.Length; j++) { - MotionKey mk = (MotionKey)mUniKeyboard.mUIBtns[i].Key[j]; - temp.Add(mk); + ulong mk = (ulong)mUniKeyboard.mUIBtns[i].Key[j]; tempInputAllData |= (ulong)mk; } } } Vector2Int inputV2 = mUniKeyboard.mJoystick.RawInputV2; - //Debug.Log($"{inputV2.x},{inputV2.y}"); if (inputV2.x > 0) { - temp.Add(MotionKey.P1_RIGHT); tempInputAllData |= (ulong)MotionKey.P1_RIGHT; } else if (inputV2.x < 0) { - temp.Add(MotionKey.P1_LEFT); tempInputAllData |= (ulong)MotionKey.P1_LEFT; } if (inputV2.y > 0) { - temp.Add(MotionKey.P1_UP); tempInputAllData |= (ulong)MotionKey.P1_UP; } else if (inputV2.y < 0) { - temp.Add(MotionKey.P1_DOWN); tempInputAllData |= (ulong)MotionKey.P1_DOWN; } CurryInpuAllData = tempInputAllData; - mCurrKey = temp.ToArray(); } - public MotionKey[] GetPressedKeys(out ulong InputData) + public ulong GetPressedKeys() { - //UMAME.instance.mReplayWriter.NextFramebyFrameIdx((int)UMAME.instance.mUniVideoPlayer.mFrame, CurryInpuAllData); UMAME.instance.mReplayWriter.NextFramebyFrameIdx((int)UMAME.instance.mUniVideoPlayer.mFrame, CurryInpuAllData); - InputData = CurryInpuAllData; - return mCurrKey; + +#if UNITY_EDITOR + string ShowKeyNames = string.Empty; + foreach (string keyname in GetInputpDataToMotionKey(CurryInpuAllData)) + { + ShowKeyNames += keyname + " |"; + } + Debug.Log("GetPressedKeys=>" + ShowKeyNames); +#endif + return CurryInpuAllData; } } public class ReplayMode { - public MotionKey[] mCurrKey = new MotionKey[0]; - MotionKey[] ReplayCheckKey; ulong currInputData; - List temp = new List(); public ReplayMode() { - ReplayCheckKey = dictKeyCfgs.Values.ToArray(); + currInputData = 0; } - public MotionKey[] GetPressedKeys(out ulong InputData) + public ulong GetPressedKeys() { //б仯 - //if (UMAME.instance.mReplayReader.NextFrame(out AxiReplay.ReplayStep stepData)) int targetFrame = (int)UMAME.instance.mUniVideoPlayer.mFrame; - //if (UMAME.instance.mReplayReader.NextFramebyFrameIdx(targetFrame, out AxiReplay.ReplayStep stepData)) - //{ - // temp.Clear(); - // // - // for (int i = 0; i < ReplayCheckKey.Length; i++) - // { - // if ((stepData.InPut & (ulong)ReplayCheckKey[i]) > 0) - // temp.Add(ReplayCheckKey[i]); - // } - // mCurrKey = temp.ToArray(); - //} AxiReplay.ReplayStep stepData; if (UMAME.instance.mReplayReader.NextFramebyFrameIdx(targetFrame, out stepData)) { - temp.Clear(); - //List temp = new List(); - //temp.Clear(); - //// - //for (int i = 0; i < ReplayCheckKey.Length; i++) - //{ - // if ((stepData.InPut & (ulong)ReplayCheckKey[i]) > 0) - // temp.Add(ReplayCheckKey[i]); - //} - //mCurrKey = temp.ToArray(); - foreach (MotionKey key in GetStepDataToMotionKey(stepData)) +#if UNITY_EDITOR + string ShowKeyNames = string.Empty; + foreach (string keyname in GetInputpDataToMotionKey(stepData.InPut)) { - temp.Add(key); + ShowKeyNames += keyname + " |"; } - mCurrKey = temp.ToArray(); + Debug.Log("GetPressedKeys=>" + ShowKeyNames); +#endif currInputData = stepData.InPut; } - InputData = currInputData; - return mCurrKey; - } - - IEnumerable GetStepDataToMotionKey(AxiReplay.ReplayStep stepData) - { - // - for (int i = 0; i < ReplayCheckKey.Length; i++) - { - if ((stepData.InPut & (ulong)ReplayCheckKey[i]) > 0) - yield return ReplayCheckKey[i]; - } + return currInputData; } } + + + + public static IEnumerable GetInputpDataToMotionKey(ulong inputdata) + { + if (inputdata == 0) + yield break; + for (int i = 0; i < MotionKey.AllNeedCheckList.Length; i++) + { + if ((inputdata & MotionKey.AllNeedCheckList[i]) > 0) + yield return MotionKey.GetKeyName(MotionKey.AllNeedCheckList[i]); + } + } #endregion } \ No newline at end of file diff --git a/MAME.Unity/Assets/Script/UMAME/UniInterface/UniVideoPlayer.cs b/MAME.Unity/Assets/Script/UMAME/UniInterface/UniVideoPlayer.cs index 4759f6e..c571409 100644 --- a/MAME.Unity/Assets/Script/UMAME/UniInterface/UniVideoPlayer.cs +++ b/MAME.Unity/Assets/Script/UMAME/UniInterface/UniVideoPlayer.cs @@ -64,8 +64,6 @@ public class UniVideoPlayer : MonoBehaviour, IVideoPlayer void Update() { if (!bInit) return; - m_rawBufferWarper.LoadRawTextureData(mFrameDataPtr, mDataLenght); - m_rawBufferWarper.Apply(); } public void SubmitVideo(int[] data, long frame_number) @@ -79,6 +77,8 @@ public class UniVideoPlayer : MonoBehaviour, IVideoPlayer //mFrameData = data; //Debug.Log($"frame_number -> {frame_number}"); + m_rawBufferWarper.LoadRawTextureData(mFrameDataPtr, mDataLenght); + m_rawBufferWarper.Apply(); } public byte[] GetScreenImg()