From 212810384ec1d07e4d154e8f8e4bfb23e67edf2e Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Mon, 17 Nov 2025 16:27:45 +0800 Subject: [PATCH] =?UTF-8?q?MAME:MC68000=20Register[8]=20A=E3=80=81D=20?= =?UTF-8?q?=E6=8C=87=E9=92=88=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cpu/m68000/Instructions/BitArithemetic.cs | 2 +- .../cpu/m68000/Instructions/DataMovement.cs | 2 +- .../cpu/m68000/Instructions/IntegerMath.cs | 2 +- .../cpu/m68000/Instructions/ProgramFlow.cs | 2 +- .../cpu/m68000/Instructions/Supervisor.cs | 2 +- .../Plugins/Mame.Core/cpu/m68000/MC68000.cs | 74 ++++++++++--------- .../Plugins/Mame.Core/cpu/m68000/Memory.cs | 2 +- .../Assets/Plugins/Mame.Core/emu/Memory.cs | 6 ++ 8 files changed, 50 insertions(+), 42 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/BitArithemetic.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/BitArithemetic.cs index 125e457b..93df80f0 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/BitArithemetic.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/BitArithemetic.cs @@ -2,7 +2,7 @@ using System; namespace cpu.m68000 { - partial class MC68000 + unsafe partial class MC68000 { //void AND0() // AND , Dn //{ diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/DataMovement.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/DataMovement.cs index 27ade5bc..57b1e930 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/DataMovement.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/DataMovement.cs @@ -3,7 +3,7 @@ using System.Text; namespace cpu.m68000 { - partial class MC68000 + unsafe partial class MC68000 { void MOVE() { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs index 947f82c3..7ef8ab2a 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/IntegerMath.cs @@ -2,7 +2,7 @@ using System; namespace cpu.m68000 { - partial class MC68000 + unsafe partial class MC68000 { void ADD0() { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs index 413fa95f..9a590d26 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/ProgramFlow.cs @@ -2,7 +2,7 @@ using System; namespace cpu.m68000 { - partial class MC68000 + unsafe partial class MC68000 { bool TestCondition(int condition) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs index 147218e4..9742a776 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Instructions/Supervisor.cs @@ -2,7 +2,7 @@ using System; namespace cpu.m68000 { - partial class MC68000 + unsafe partial class MC68000 { unsafe void MOVEtSR() { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs index 05cce057..444246e3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/MC68000.cs @@ -9,45 +9,45 @@ namespace cpu.m68000 { public static MC68000 m1; // Machine State - public Register[] D = new Register[8]; + //public Register[] D = new Register[8]; - //#region //指针化 D - //static Register[] D_src; - //static GCHandle D_handle; - //public static Register* D; - //public static int DLength; - //public static bool D_IsNull => D == null; - //public static Register[] D_set - //{ - // set - // { - // D_handle.ReleaseGCHandle(); - // D_src = value; - // DLength = value.Length; - // D_src.GetObjectPtr(ref D_handle, ref D); - // } - //} - //#endregion + #region //指针化 D + Register[] D_src; + GCHandle D_handle; + public Register* D; + public int DLength; + public bool D_IsNull => D == null; + public Register[] D_set + { + set + { + D_handle.ReleaseGCHandle(); + D_src = value; + DLength = value.Length; + D_src.GetObjectPtr(ref D_handle, ref D); + } + } + #endregion - public Register[] A = new Register[8]; + //public Register[] A = new Register[8]; - //#region //指针化 A - //static Register[] A_src; - //static GCHandle A_handle; - //public static Register* A; - //public static int ALength; - //public static bool A_IsNull => A == null; - //public static Register[] A_set - //{ - // set - // { - // A_handle.ReleaseGCHandle(); - // A_src = value; - // ALength = value.Length; - // A_src.GetObjectPtr(ref A_handle, ref A); - // } - //} - //#endregion + #region //指针化 A + Register[] A_src; + GCHandle A_handle; + public Register* A; + public int ALength; + public bool A_IsNull => A == null; + public Register[] A_set + { + set + { + A_handle.ReleaseGCHandle(); + A_src = value; + ALength = value.Length; + A_src.GetObjectPtr(ref A_handle, ref A); + } + } + #endregion public int PC, PPC; private ulong totalExecutedCycles; @@ -201,6 +201,8 @@ namespace cpu.m68000 public MC68000() { + A_set = new Register[8]; + D_set = new Register[8]; //还是使用Action[]吧 BuildOpcodeTable(); } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Memory.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Memory.cs index 969e1dc9..e8736eeb 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Memory.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m68000/Memory.cs @@ -2,7 +2,7 @@ namespace cpu.m68000 { - partial class MC68000 + unsafe partial class MC68000 { sbyte ReadValueB(int mode, int reg) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs index 3704a1f9..47f1c9e8 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs @@ -418,6 +418,12 @@ namespace MAME.Core set_TempBuffer = new byte[0x40000]; } + public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref cpu.m68000.Register* ptr) + { + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); + ptr = (cpu.m68000.Register*)intptr; + } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr) { IntPtr intptr;