From 1aec567eb23898319262064f3d6604777a9424d2 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Fri, 7 Nov 2025 00:30:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?MAME:=E7=BB=88=E4=BA=8E=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86MAME=E7=9A=84CPU=20Timer=E7=9A=84?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=B1=A0=EF=BC=8C=E5=BC=80=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Plugins/Mame.Core/cpu/m6800/M6800.cs | 12 +- .../Assets/Plugins/Mame.Core/emu/Cpuexec.cs | 17 +- .../Assets/Plugins/Mame.Core/emu/EmuTimer.cs | 434 +++++++++++++++--- .../Assets/Plugins/Mame.Core/emu/Mame.cs | 4 +- .../Assets/Plugins/Mame.Core/emu/Video.cs | 31 +- .../Assets/Plugins/Mame.Core/emu/Watchdog.cs | 3 +- .../Mame.Core/mame/konami68000/Konami68000.cs | 2 +- .../Plugins/Mame.Core/mame/m72/Audio.cs | 10 +- .../Assets/Plugins/Mame.Core/mame/m72/M72.cs | 2 +- .../Assets/Plugins/Mame.Core/mame/m92/M92.cs | 11 +- .../Plugins/Mame.Core/mame/m92/Video.cs | 6 +- .../Plugins/Mame.Core/mame/neogeo/Neogeo.cs | 13 +- .../Plugins/Mame.Core/mame/neogeo/Video.cs | 7 +- .../Plugins/Mame.Core/mame/taito/Opwolf.cs | 2 +- .../Plugins/Mame.Core/mame/taitob/Taitob.cs | 20 +- .../Assets/Plugins/Mame.Core/sound/ICS2115.cs | 29 +- .../Assets/Plugins/Mame.Core/sound/MSM5205.cs | 6 +- .../Assets/Plugins/Mame.Core/sound/Sound.cs | 45 +- .../Assets/Plugins/Mame.Core/sound/Upd7759.cs | 3 +- .../Assets/Plugins/Mame.Core/sound/YM2151.cs | 6 +- .../Assets/Plugins/Mame.Core/sound/YM2203.cs | 28 +- .../Assets/Plugins/Mame.Core/sound/YM2610.cs | 24 +- .../Assets/Plugins/Mame.Core/sound/YM3812.cs | 27 +- 23 files changed, 580 insertions(+), 162 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m6800/M6800.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m6800/M6800.cs index 288bd5fd..dbd25d5b 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m6800/M6800.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/m6800/M6800.cs @@ -245,8 +245,10 @@ namespace cpu.m6800 cycles = cycles_63701; clock = 1536000; irq_callback = null; - m6800_rx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_rx, false); - m6800_tx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_tx, false); + //m6800_rx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_rx, false); + EmuTimer.timer_alloc_common(ref m6800_rx_timer, EmuTimer.TIME_ACT.M6800_action_rx, false); + //m6800_tx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_tx, false); + EmuTimer.timer_alloc_common(ref m6800_tx_timer, EmuTimer.TIME_ACT.M6800_action_tx, false); } public override void Reset() { @@ -1344,8 +1346,10 @@ namespace cpu.m6800 }; clock = 1000000; irq_callback = Cpuint.cpu_3_irq_callback; - m6800_rx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_rx, false); - m6800_tx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_tx, false); + //m6800_rx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_rx, false); + EmuTimer.timer_alloc_common(ref m6800_rx_timer, EmuTimer.TIME_ACT.M6800_action_rx, false); + //m6800_tx_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M6800_action_tx, false); + EmuTimer.timer_alloc_common(ref m6800_tx_timer, EmuTimer.TIME_ACT.M6800_action_tx, false); } public override int ExecuteCycles(int cycles) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Cpuexec.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Cpuexec.cs index 2426fead..ea3236dd 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Cpuexec.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Cpuexec.cs @@ -2244,12 +2244,15 @@ namespace MAME.Core case "CPS-1(QSound)": case "CPS2": timedint_period = new Atime(0, (long)(1e18 / 250)); - timedint_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Generic_irq_1_0_line_hold, false); + //timedint_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Generic_irq_1_0_line_hold, false); + EmuTimer.timer_alloc_common(ref timedint_timer, EmuTimer.TIME_ACT.Generic_irq_1_0_line_hold, false); EmuTimer.timer_adjust_periodic(timedint_timer, timedint_period, timedint_period); break; case "Neo Geo": - interleave_boost_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_null_callback, false); - interleave_boost_timer_end = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_end_interleave_boost, false); + //interleave_boost_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_null_callback, false); + EmuTimer.timer_alloc_common(ref interleave_boost_timer, EmuTimer.TIME_ACT.Cpuexec_null_callback, false); + //interleave_boost_timer_end = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_end_interleave_boost, false); + EmuTimer.timer_alloc_common(ref interleave_boost_timer_end, EmuTimer.TIME_ACT.Cpuexec_end_interleave_boost, false); break; case "CPS1": case "Namco System 1": @@ -2295,7 +2298,7 @@ namespace MAME.Core case "bublcave11": case "bublcave10": timeslice_period = new Atime(0, Video.screenstate.frame_period / 100); - timeslice_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_cpu_timeslicecallback, false); + EmuTimer.timer_alloc_common(ref timeslice_timer, EmuTimer.TIME_ACT.Cpuexec_cpu_timeslicecallback, false); EmuTimer.timer_adjust_periodic(timeslice_timer, timeslice_period, timeslice_period); break; case "opwolf": @@ -2305,14 +2308,14 @@ namespace MAME.Core case "opwolfb": case "opwolfp": timeslice_period = new Atime(0, Video.screenstate.frame_period / 10); - timeslice_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_cpu_timeslicecallback, false); + EmuTimer.timer_alloc_common(ref timeslice_timer, EmuTimer.TIME_ACT.Cpuexec_cpu_timeslicecallback, false); EmuTimer.timer_adjust_periodic(timeslice_timer, timeslice_period, timeslice_period); break; } break; case "Taito B": timeslice_period = new Atime(0, Video.screenstate.frame_period / 10); - timeslice_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_cpu_timeslicecallback, false); + EmuTimer.timer_alloc_common(ref timeslice_timer, EmuTimer.TIME_ACT.Cpuexec_cpu_timeslicecallback, false); EmuTimer.timer_adjust_periodic(timeslice_timer, timeslice_period, timeslice_period); break; case "Capcom": @@ -2338,7 +2341,7 @@ namespace MAME.Core case "sfan": case "sfp": timedint_period = new Atime(0, (long)(1e18 / 8000)); - timedint_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Generic_irq_2_0_line_hold, false); + EmuTimer.timer_alloc_common(ref timedint_timer, EmuTimer.TIME_ACT.Generic_irq_2_0_line_hold, false); EmuTimer.timer_adjust_periodic(timedint_timer, timedint_period, timedint_period); break; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs index 4b5016d6..3a81bbf3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs @@ -2,12 +2,87 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Runtime.ConstrainedExecution; +using System.Threading; +using System.Timers; +using static MAME.Core.EmuTimer; namespace MAME.Core { + public class EmuTimerLister + { + public emu_timer this[int index] + { + get { return timerlist[index]; } + set { timerlist[index] = value; } // 如果需要设置的话 + } + public static void GetNewTimerLister(ref EmuTimerLister tlistObj) + { + //如果新旧值替换 + if (tlistObj != null) + { + tlistObj.ReleaseLister(); + ObjectPoolAuto.Release(tlistObj); + tlistObj = null; + } + + tlistObj = ObjectPoolAuto.Acquire(); + tlistObj.InitLister(); + } + + List timerlist; + + public List GetSrcList() + { + return timerlist; + } + public int Count + { + get { return timerlist.Count; } + } + + void InitLister() + { + ReleaseLister(); + timerlist = ObjectPoolAuto.AcquireList(); + } + void ReleaseLister() + { + if (timerlist != null) + { + Clear(); + ObjectPoolAuto.Release(timerlist); + timerlist = null; + } + } + + public void Clear() + { + emu_timer.ClearList(ref timerlist); + } + public void Add(emu_timer timer) + { + emu_timer.AddList(ref timerlist, ref timer); + } + public void Remove(emu_timer timer) + { + emu_timer.RemoveToList(ref timerlist, ref timer); + } + + public void Insert(int index, emu_timer timer) + { + emu_timer.InsertToList(ref timerlist, index, ref timer); + } + + public int IndexOf(emu_timer timer) + { + return timerlist.IndexOf(timer); + } + } + public class EmuTimer { - public static List lt; + public static EmuTimerLister lt; private static List lt2; public static Atime global_basetime; public static Atime global_basetime_obj; @@ -29,7 +104,8 @@ namespace MAME.Core public static void instancingTimerList() { - lt = new List(); + //lt = new List(); + EmuTimerLister.GetNewTimerLister(ref lt); } public class emu_timer @@ -49,27 +125,167 @@ namespace MAME.Core period = default; start = default; expire = default; + _refCount = 1; } + static HashSet _readyToRelease = new HashSet(); /// /// 线程安全队列(因为析构函数是额外线程来的) /// static ConcurrentQueue _failedDeletions = new ConcurrentQueue(); + + static int outTimerAllCount = 0; + static int newTimerCount = 0; public static emu_timer GetEmu_timer() { - if (_failedDeletions.TryDequeue(out emu_timer obj)) - { - obj.reset(); - return obj; + emu_timer obj; + if (!_failedDeletions.TryDequeue(out obj)) + { + obj = new emu_timer(); + newTimerCount++; } - - return new emu_timer(); + obj.reset(); + outTimerAllCount++; + return obj; } - public static void EnqueueObj(emu_timer obj) + /// + /// 释放创建的引用,这个要和GetEmu_timer成对 + /// + /// + public static void ReleaseCreateRef(emu_timer obj) + { + obj.ReleaseRef(); + } + + public static void CheckReadyRelaseAfterRun() + { + if (_readyToRelease.Count < 1) + return; + + int beforpoolcount = _failedDeletions.Count; + int releaseCount = 0; + foreach (var ready in _readyToRelease) + { + if (ready._refCount <= 0) + { + ready.ReturnToPool(); + releaseCount++; + } + } + //UnityEngine.Debug.Log($"CheckReadyRelaseAfterRun 出池数量{outTimerAllCount},其中new创建的数量{newTimerCount} 回收数量{releaseCount} ,处理前池数量{beforpoolcount},处理后池数量{_failedDeletions.Count}"); + outTimerAllCount = 0; + newTimerCount = 0; + _readyToRelease.Clear(); + } + + // 引用计数字段(线程安全) + private int _refCount = 1; // 初始为1,表示创建时的引用 + + /// + /// 增加引用计数 + /// + void AddRef() + { + int newCount = Interlocked.Increment(ref _refCount); + + //引用计数重新回到1时,移除。 + //但是还是不在这里做把注释了,在每一帧开始之前统一检测 + //if (newCount == 1) + //{ + // if (_readyToRelease.Contains(this)) + // { + // //UnityEngine.Debug.Log("移除ReadyToRelease"); + // _readyToRelease.Remove(this); + // } + //} + } + + /// + /// 减少引用计数,当计数为0时释放对象回池 + /// + void ReleaseRef() + { + int newCount = Interlocked.Decrement(ref _refCount); + if (newCount == 0) + { + // 引用计数为0,释放资源并回池 + ReadyToRelease(); + } + else if (newCount < 0) + { + // 引用计数异常,不应出现负数 + throw new InvalidOperationException("引用计数出现负数"); + } + } + + void ReadyToRelease() + { + //UnityEngine.Debug.Log("ReadyToRelease"); + if(!_readyToRelease.Contains(this)) + _readyToRelease.Add(this); + } + + /// + /// 释放资源并回池 + /// + void ReturnToPool() + { + reset(); + _failedDeletions.Enqueue(this); + } + + #region 外部操作 间接影响引用计数 + public static void SetRefUsed(ref emu_timer refattr, ref emu_timer emu_timer) + { + if (refattr == emu_timer) + return; + if (emu_timer == null) + { + SetNull(ref refattr); + return; + } + if (refattr != null) + refattr.ReleaseRef(); + + refattr = emu_timer; + refattr.AddRef(); + } + public static void SetNull(ref emu_timer timer) + { + if (timer != null) + { + timer.ReleaseRef(); + timer = null; + } + } + public static void AddList(ref List list, ref emu_timer timer) + { + list.Add(timer); + timer.AddRef(); + } + internal static void InsertToList(ref List list, int index, ref emu_timer timer) + { + list.Insert(index, timer); + timer.AddRef(); + } + public static void RemoveToList(ref List list, ref emu_timer timer) + { + list.Remove(timer); + timer.ReleaseRef(); + } + internal static void ClearList(ref List list) + { + for (int i = 0; i < list.Count; i++) + list[i].ReleaseRef(); + list.Clear(); + } + #endregion + /* + static void EnqueueObj(emu_timer obj) { _failedDeletions.Enqueue(obj); } - + ~emu_timer() { //咱也没办法,这样子来实现emu_timer的回收到对象池。只能这样实现,MAME里面对于emu_timer持有引用比较混沌,在确保没有引用计数时,再安全回池。 @@ -79,7 +295,7 @@ namespace MAME.Core //说人话,就是用析构驱动回池,而不破坏现有代码 EnqueueObj(this); GC.ReRegisterForFinalize(this);//手动注册,否则析构函数再也不会回调 - } + }*/ } public class emu_timer2 { @@ -258,7 +474,8 @@ namespace MAME.Core public static void timer_init() { global_basetime = Attotime.ATTOTIME_ZERO; - lt = new List(); + //lt = new List(); + EmuTimerLister.GetNewTimerLister(ref lt); lt2 = new List(); lt2.Add(new emu_timer2(1, TIME_ACT.Video_vblank_begin_callback)); lt2.Add(new emu_timer2(2, TIME_ACT.Mame_soft_reset)); @@ -518,12 +735,14 @@ namespace MAME.Core } public static void timer_pulse_internal(Atime period, TIME_ACT action) { - emu_timer timer = timer_alloc_common(action, false); + //emu_timer timer = timer_alloc_common(action, false); + emu_timer timer = timer_alloc_common_NoRef(action, false); timer_adjust_periodic(timer, period, period); } public static void timer_set_internal(TIME_ACT action) { - emu_timer timer = timer_alloc_common(action, true); + //emu_timer timer = timer_alloc_common(action, true); + emu_timer timer = timer_alloc_common_NoRef(action, true); timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } public static void timer_list_insert(emu_timer timer1) @@ -532,7 +751,8 @@ namespace MAME.Core int i1 = -1; if (timer1.action == TIME_ACT.Cpuint_cpunum_empty_event_queue || timer1.action == TIME_ACT.setvector) { - foreach (emu_timer et in lt) + //foreach (emu_timer et in lt) + foreach (emu_timer et in lt.GetSrcList()) { if (et.action == timer1.action && Attotime.attotime_compare(et.expire, global_basetime) <= 0) { @@ -561,7 +781,8 @@ namespace MAME.Core if (timer1.action == TIME_ACT.Cpuint_cpunum_empty_event_queue || timer1.action == TIME_ACT.setvector) { timer_list_remove_lt1.Clear(); - foreach (emu_timer et in lt) + //foreach (emu_timer et in lt) + foreach (emu_timer et in lt.GetSrcList()) { if (et.action == timer1.action && Attotime.attotime_compare(et.expire, timer1.expire) == 0) { @@ -585,7 +806,10 @@ namespace MAME.Core } else { - foreach (emu_timer et in lt) + //TODO MAME.NET原来这么foreach写删除是有问题的 + + //foreach (emu_timer et in lt) + foreach (emu_timer et in lt.GetSrcList()) { if (et.action == timer1.action) { @@ -667,10 +891,54 @@ namespace MAME.Core } } } - public static emu_timer timer_alloc_common(TIME_ACT action, bool temp) + //public static emu_timer timer_alloc_common(TIME_ACT action, bool temp) + //{ + // Atime time = get_current_time(); + // //emu_timer timer = new emu_timer(); + // emu_timer timer = emu_timer.GetEmu_timerNoRef(); + // timer.action = action; + // timer.enabled = false; + // timer.temporary = temp; + // timer.period = Attotime.ATTOTIME_ZERO; + // //timer.func = func; + // timer.start = time; + // timer.expire = Attotime.ATTOTIME_NEVER; + // timer_list_insert(timer); + // return timer; + //} + + /// + /// 申请新的timer,且直接操作引用计数 + /// + /// + /// + /// + public static void timer_alloc_common(ref emu_timer refattr, TIME_ACT action, bool temp) + { + //Atime time = get_current_time(); + //emu_timer timer = emu_timer.GetEmu_timerNoRef(); + //timer.action = action; + //timer.enabled = false; + //timer.temporary = temp; + //timer.period = Attotime.ATTOTIME_ZERO; + ////timer.func = func; + //timer.start = time; + //timer.expire = Attotime.ATTOTIME_NEVER; + //timer_list_insert(timer); + emu_timer timer = timer_alloc_common_NoRef(action, temp); + emu_timer.SetRefUsed(ref refattr, ref timer); + } + + /// + /// 申请新的timer,不操作额外引用计数,用于外部中间传递 + /// + /// + /// + /// + public static emu_timer timer_alloc_common_NoRef(TIME_ACT action, bool temp) { Atime time = get_current_time(); - //emu_timer timer = new emu_timer(); + //创建一个timer emu_timer timer = emu_timer.GetEmu_timer(); timer.action = action; timer.enabled = false; @@ -680,8 +948,11 @@ namespace MAME.Core timer.start = time; timer.expire = Attotime.ATTOTIME_NEVER; timer_list_insert(timer); + //断开创建的引用计数 + emu_timer.ReleaseCreateRef(timer); return timer; } + public static bool timer_enable(emu_timer which, bool enable) { bool old; @@ -734,10 +1005,12 @@ namespace MAME.Core { int i, i1, n; n = reader.ReadInt32(); - lt = new List(); + //lt = new List(); + EmuTimerLister.GetNewTimerLister(ref lt); for (i = 0; i < n; i++) { - emu_timer etimer = new emu_timer(); + emu_timer etimer = emu_timer.GetEmu_timer(); + #region lt.Add(etimer); i1 = reader.ReadInt32(); etimer.action = getactionbyindex(i1); @@ -753,43 +1026,49 @@ namespace MAME.Core //if (etimer.func == "vblank_begin_callback") if (etimer.action == TIME_ACT.Video_vblank_begin_callback) { - Video.vblank_begin_timer = etimer; + emu_timer.SetRefUsed(ref Video.vblank_begin_timer, ref etimer);//Video.vblank_begin_timer = etimer; lt.Remove(etimer); lt.Add(Video.vblank_begin_timer); } else if (etimer.action == TIME_ACT.Video_vblank_end_callback) { - Video.vblank_end_timer = etimer; + //Video.vblank_end_timer = etimer; + emu_timer.SetRefUsed(ref Video.vblank_end_timer, ref etimer); lt.Remove(etimer); lt.Add(Video.vblank_end_timer); } else if (etimer.action == TIME_ACT.Mame_soft_reset) { - Mame.soft_reset_timer = etimer; + //Mame.soft_reset_timer = etimer; + emu_timer.SetRefUsed(ref Mame.soft_reset_timer, ref etimer); lt.Remove(etimer); lt.Add(Mame.soft_reset_timer); } else if (etimer.action == TIME_ACT.Watchdog_watchdog_callback) { - Watchdog.watchdog_timer = etimer; + //Watchdog.watchdog_timer = etimer; + emu_timer.SetRefUsed(ref Watchdog.watchdog_timer, ref etimer); lt.Remove(etimer); lt.Add(Watchdog.watchdog_timer); } else if (etimer.action == TIME_ACT.Generic_irq_1_0_line_hold) { - Cpuexec.timedint_timer = etimer; + //Cpuexec.timedint_timer = etimer; + emu_timer.SetRefUsed(ref Cpuexec.timedint_timer, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.timedint_timer); } else if (etimer.action == TIME_ACT.YM2151_timer_callback_a) { - YM2151.PSG.timer_A = etimer; + //YM2151.PSG.timer_A = etimer; + emu_timer.SetRefUsed(ref YM2151.PSG.timer_A, ref etimer); lt.Remove(etimer); lt.Add(YM2151.PSG.timer_A); } else if (etimer.action == TIME_ACT.YM2151_timer_callback_b) { - YM2151.PSG.timer_B = etimer; + //YM2151.PSG.timer_B = etimer; + emu_timer.SetRefUsed(ref YM2151.PSG.timer_B, ref etimer); lt.Remove(etimer); lt.Add(YM2151.PSG.timer_B); } @@ -800,12 +1079,14 @@ namespace MAME.Core case "CPS2": case "IGS011": case "Konami68000": - Cpuexec.cpu[0].partial_frame_timer = etimer; + //Cpuexec.cpu[0].partial_frame_timer = etimer; + emu_timer.SetRefUsed(ref Cpuexec.cpu[0].partial_frame_timer, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.cpu[0].partial_frame_timer); break; case "M72": - Cpuexec.cpu[1].partial_frame_timer = etimer; + //Cpuexec.cpu[1].partial_frame_timer = etimer; + emu_timer.SetRefUsed(ref Cpuexec.cpu[1].partial_frame_timer, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.cpu[1].partial_frame_timer); break; @@ -823,7 +1104,8 @@ namespace MAME.Core case "makaimurc": case "makaimurg": case "diamond": - Cpuexec.cpu[1].partial_frame_timer = etimer; + //Cpuexec.cpu[1].partial_frame_timer = etimer; + emu_timer.SetRefUsed(ref Cpuexec.cpu[1].partial_frame_timer, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.cpu[1].partial_frame_timer); break; @@ -833,178 +1115,210 @@ namespace MAME.Core } else if (etimer.action == TIME_ACT.Cpuexec_null_callback) { - Cpuexec.interleave_boost_timer = etimer; + //Cpuexec.interleave_boost_timer = etimer; + emu_timer.SetRefUsed(ref Cpuexec.interleave_boost_timer, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.interleave_boost_timer); } else if (etimer.action == TIME_ACT.Cpuexec_end_interleave_boost) { - Cpuexec.interleave_boost_timer_end = etimer; + //Cpuexec.interleave_boost_timer_end = etimer; + emu_timer.SetRefUsed(ref Cpuexec.interleave_boost_timer_end, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.interleave_boost_timer_end); } else if (etimer.action == TIME_ACT.Video_scanline0_callback) { - Video.scanline0_timer = etimer; + //Video.scanline0_timer = etimer; + emu_timer.SetRefUsed(ref Video.scanline0_timer, ref etimer); lt.Remove(etimer); lt.Add(Video.scanline0_timer); } else if (etimer.action == TIME_ACT.Neogeo_display_position_interrupt_callback) { - Neogeo.display_position_interrupt_timer = etimer; + //Neogeo.display_position_interrupt_timer = etimer; + emu_timer.SetRefUsed(ref Neogeo.display_position_interrupt_timer, ref etimer); lt.Remove(etimer); lt.Add(Neogeo.display_position_interrupt_timer); } else if (etimer.action == TIME_ACT.Neogeo_display_position_vblank_callback) { - Neogeo.display_position_vblank_timer = etimer; + //Neogeo.display_position_vblank_timer = etimer; + emu_timer.SetRefUsed(ref Neogeo.display_position_vblank_timer, ref etimer); lt.Remove(etimer); lt.Add(Neogeo.display_position_vblank_timer); } else if (etimer.action == TIME_ACT.Neogeo_vblank_interrupt_callback) { - Neogeo.vblank_interrupt_timer = etimer; + //Neogeo.vblank_interrupt_timer = etimer; + emu_timer.SetRefUsed(ref Neogeo.vblank_interrupt_timer, ref etimer); lt.Remove(etimer); lt.Add(Neogeo.vblank_interrupt_timer); } else if (etimer.action == TIME_ACT.Neogeo_auto_animation_timer_callback) { - Neogeo.auto_animation_timer = etimer; + //Neogeo.auto_animation_timer = etimer; + emu_timer.SetRefUsed(ref Neogeo.auto_animation_timer, ref etimer); lt.Remove(etimer); lt.Add(Neogeo.auto_animation_timer); } else if (etimer.action == TIME_ACT.Neogeo_sprite_line_timer_callback) { - Neogeo.sprite_line_timer = etimer; + //Neogeo.sprite_line_timer = etimer; + emu_timer.SetRefUsed(ref Neogeo.sprite_line_timer, ref etimer); lt.Remove(etimer); lt.Add(Neogeo.sprite_line_timer); } else if (etimer.action == TIME_ACT.YM2610_F2610_timer_callback_0) { - YM2610.timer[0] = etimer; + //YM2610.timer[0] = etimer; + emu_timer.SetRefUsed(ref YM2610.timer[0], ref etimer); lt.Remove(etimer); lt.Add(YM2610.timer[0]); } else if (etimer.action == TIME_ACT.YM2610_F2610_timer_callback_1) { - YM2610.timer[1] = etimer; + //YM2610.timer[1] = etimer; + emu_timer.SetRefUsed(ref YM2610.timer[1], ref etimer); lt.Remove(etimer); lt.Add(YM2610.timer[1]); } else if (etimer.action == TIME_ACT.M6800_action_rx) { - M6800.m1.m6800_rx_timer = etimer; + //M6800.m1.m6800_rx_timer = etimer; + emu_timer.SetRefUsed(ref M6800.m1.m6800_rx_timer, ref etimer); lt.Remove(etimer); lt.Add(M6800.m1.m6800_rx_timer); } else if (etimer.action == TIME_ACT.M6800_action_tx) { - M6800.m1.m6800_tx_timer = etimer; + //M6800.m1.m6800_tx_timer = etimer; + emu_timer.SetRefUsed(ref M6800.m1.m6800_tx_timer, ref etimer); lt.Remove(etimer); lt.Add(M6800.m1.m6800_tx_timer); } else if (etimer.action == TIME_ACT.YM3812_timer_callback_3812_0) { - YM3812.timer[0] = etimer; + //YM3812.timer[0] = etimer; + emu_timer.SetRefUsed(ref YM3812.timer[0], ref etimer); lt.Remove(etimer); lt.Add(YM3812.timer[0]); } else if (etimer.action == TIME_ACT.YM3812_timer_callback_3812_1) { - YM3812.timer[1] = etimer; + //YM3812.timer[1] = etimer; + emu_timer.SetRefUsed(ref YM3812.timer[1], ref etimer); lt.Remove(etimer); lt.Add(YM3812.timer[1]); } else if (etimer.action == TIME_ACT.ICS2115_timer_cb_0) { - ICS2115.timer[0].timer = etimer; + //ICS2115.timer[0].timer = etimer; + emu_timer.SetRefUsed(ref ICS2115.timer[0].timer, ref etimer); lt.Remove(etimer); lt.Add(ICS2115.timer[0].timer); } else if (etimer.action == TIME_ACT.ICS2115_timer_cb_1) { - ICS2115.timer[1].timer = etimer; + //ICS2115.timer[1].timer = etimer; + emu_timer.SetRefUsed(ref ICS2115.timer[1].timer, ref etimer); lt.Remove(etimer); lt.Add(ICS2115.timer[1].timer); } else if (etimer.action == TIME_ACT.M72_m72_scanline_interrupt) { - M72.scanline_timer = etimer; + //M72.scanline_timer = etimer; + emu_timer.SetRefUsed(ref M72.scanline_timer, ref etimer); lt.Remove(etimer); lt.Add(M72.scanline_timer); } else if (etimer.action == TIME_ACT.M92_m92_scanline_interrupt) { - M92.scanline_timer = etimer; + //M92.scanline_timer = etimer; + emu_timer.SetRefUsed(ref M72.scanline_timer, ref etimer); lt.Remove(etimer); lt.Add(M92.scanline_timer); } else if (etimer.action == TIME_ACT.Cpuexec_cpu_timeslicecallback) { - Cpuexec.timeslice_timer = etimer; + //Cpuexec.timeslice_timer = etimer; + emu_timer.SetRefUsed(ref Cpuexec.timeslice_timer, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.timeslice_timer); } else if (etimer.action == TIME_ACT.Upd7759_upd7759_slave_update) { - Upd7759.chip.timer = etimer; + //Upd7759.chip.timer = etimer; + emu_timer.SetRefUsed(ref Upd7759.chip.timer, ref etimer); lt.Remove(etimer); lt.Add(Upd7759.chip.timer); } else if (etimer.action == TIME_ACT.Generic_irq_2_0_line_hold) { - Cpuexec.timedint_timer = etimer; + //Cpuexec.timedint_timer = etimer; + emu_timer.SetRefUsed(ref Cpuexec.timedint_timer, ref etimer); lt.Remove(etimer); lt.Add(Cpuexec.timedint_timer); } else if (etimer.action == TIME_ACT.MSM5205_MSM5205_vclk_callback0) { - MSM5205.timer[0] = etimer; + //MSM5205.timer[0] = etimer; + emu_timer.SetRefUsed(ref MSM5205.timer[0], ref etimer); lt.Remove(etimer); lt.Add(MSM5205.timer[0]); } else if (etimer.action == TIME_ACT.MSM5205_MSM5205_vclk_callback1) { - MSM5205.timer[1] = etimer; + //MSM5205.timer[1] = etimer; + emu_timer.SetRefUsed(ref MSM5205.timer[1], ref etimer); lt.Remove(etimer); lt.Add(MSM5205.timer[1]); } else if (etimer.action == TIME_ACT.YM2203_timer_callback_2203_0_0) { - YM2203.FF2203[0].timer[0] = etimer; + //YM2203.FF2203[0].timer[0] = etimer; + emu_timer.SetRefUsed(ref YM2203.FF2203[0].timer[0], ref etimer); lt.Remove(etimer); lt.Add(YM2203.FF2203[0].timer[0]); } else if (etimer.action == TIME_ACT.YM2203_timer_callback_2203_0_1) { - YM2203.FF2203[0].timer[1] = etimer; + //YM2203.FF2203[0].timer[1] = etimer; + emu_timer.SetRefUsed(ref YM2203.FF2203[0].timer[1], ref etimer); lt.Remove(etimer); lt.Add(YM2203.FF2203[0].timer[1]); } else if (etimer.action == TIME_ACT.YM2203_timer_callback_2203_1_0) { - YM2203.FF2203[1].timer[0] = etimer; + //YM2203.FF2203[1].timer[0] = etimer; + emu_timer.SetRefUsed(ref YM2203.FF2203[1].timer[0], ref etimer); lt.Remove(etimer); lt.Add(YM2203.FF2203[1].timer[0]); } else if (etimer.action == TIME_ACT.YM2203_timer_callback_2203_1_1) { - YM2203.FF2203[1].timer[1] = etimer; + //YM2203.FF2203[1].timer[1] = etimer; + emu_timer.SetRefUsed(ref YM2203.FF2203[1].timer[1], ref etimer); lt.Remove(etimer); lt.Add(YM2203.FF2203[1].timer[1]); } else if (etimer.action == TIME_ACT.YM3812_timer_callback_3526_0) { - YM3812.timer[0] = etimer; + //YM3812.timer[0] = etimer; + emu_timer.SetRefUsed(ref YM3812.timer[0], ref etimer); lt.Remove(etimer); lt.Add(YM3812.timer[0]); } else if (etimer.action == TIME_ACT.YM3812_timer_callback_3526_1) { - YM3812.timer[1] = etimer; + //YM3812.timer[1] = etimer; + emu_timer.SetRefUsed(ref YM3812.timer[1], ref etimer); lt.Remove(etimer); lt.Add(YM3812.timer[1]); } + #endregion + //断开创建的引用计数 + emu_timer.ReleaseCreateRef(etimer); } for (i = n; i < 32; i++) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs index 59c7968e..7a9ac40e 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs @@ -99,6 +99,7 @@ namespace MAME.Core if (exit_pending) return; + EmuTimer.emu_timer.CheckReadyRelaseAfterRun(); long lastframe = Video.screenstate.frame_number; //执行CPU命令,直到一次画面更新 while (lastframe == Video.screenstate.frame_number) @@ -167,7 +168,8 @@ namespace MAME.Core Palette.palette_init(); Generic.generic_machine_init(); EmuTimer.timer_init(); - soft_reset_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Mame_soft_reset, false); + //soft_reset_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Mame_soft_reset, false); + EmuTimer.timer_alloc_common(ref soft_reset_timer,EmuTimer.TIME_ACT.Mame_soft_reset, false); Window.osd_init(); Inptport.input_port_init(); Cpuexec.cpuexec_init(); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Video.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Video.cs index 213d69cc..7d739454 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Video.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Video.cs @@ -706,11 +706,14 @@ namespace MAME.Core - vblank_begin_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Video_vblank_begin_callback, false); + //vblank_begin_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Video_vblank_begin_callback, false); + EmuTimer.timer_alloc_common(ref vblank_begin_timer, EmuTimer.TIME_ACT.Video_vblank_begin_callback, false); EmuTimer.timer_adjust_periodic(vblank_begin_timer, video_screen_get_time_until_vblank_start(), Attotime.ATTOTIME_NEVER); - scanline0_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Video_scanline0_callback, false); + //scanline0_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Video_scanline0_callback, false); + EmuTimer.timer_alloc_common(ref scanline0_timer, EmuTimer.TIME_ACT.Video_scanline0_callback, false); EmuTimer.timer_adjust_periodic(scanline0_timer, video_screen_get_time_until_pos(0, 0), Attotime.ATTOTIME_NEVER); - vblank_end_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Video_vblank_end_callback, false); + //vblank_end_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Video_vblank_end_callback, false); + EmuTimer.timer_alloc_common(ref vblank_end_timer, EmuTimer.TIME_ACT.Video_vblank_end_callback, false); switch (Machine.sBoard) { case "CPS-1": @@ -721,19 +724,19 @@ namespace MAME.Core break; case "CPS2": Cpuexec.cpu[0].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 262); - Cpuexec.cpu[0].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[0].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; case "Tehkan": Cpuexec.cpu[1].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 2); - Cpuexec.cpu[1].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[1].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; case "Neo Geo": break; case "SunA8": Cpuexec.cpu[0].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 0x100); - Cpuexec.cpu[0].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[0].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); Cpuexec.cpu[1].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 4); - Cpuexec.cpu[1].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger2, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[1].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger2, false); break; case "IGS011": switch (Machine.sName) @@ -748,27 +751,27 @@ namespace MAME.Core case "drgnwrldv40k": case "lhb2": Cpuexec.cpu[0].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 5); - Cpuexec.cpu[0].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[0].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; case "lhb": case "lhbv33c": case "dbc": case "ryukobou": Cpuexec.cpu[0].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 4); - Cpuexec.cpu[0].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[0].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; } break; case "M72": Cpuexec.cpu[1].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 128); - Cpuexec.cpu[1].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[1].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; case "Taito": switch (Machine.sName) { case "bub68705": Cpuexec.cpu[3].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 2); - Cpuexec.cpu[3].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[3].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; } break; @@ -777,7 +780,8 @@ namespace MAME.Core { case "cuebrick": Cpuexec.cpu[0].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 10); - Cpuexec.cpu[0].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + //Cpuexec.cpu[0].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[0].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; } break; @@ -796,7 +800,8 @@ namespace MAME.Core case "makaimurg": case "diamond": Cpuexec.cpu[1].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 4); - Cpuexec.cpu[1].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + //Cpuexec.cpu[1].partial_frame_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); + EmuTimer.timer_alloc_common(ref Cpuexec.cpu[1].partial_frame_timer, EmuTimer.TIME_ACT.Cpuexec_trigger_partial_frame_interrupt, false); break; } break; diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Watchdog.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Watchdog.cs index 1b49f61b..b5a4af4f 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Watchdog.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Watchdog.cs @@ -7,7 +7,8 @@ public static Atime watchdog_time; public static void watchdog_init() { - watchdog_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Watchdog_watchdog_callback, false); + //watchdog_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Watchdog_watchdog_callback, false); + EmuTimer.timer_alloc_common(ref watchdog_timer, EmuTimer.TIME_ACT.Watchdog_watchdog_callback, false); switch (Machine.sBoard) { case "CPS-1": diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/konami68000/Konami68000.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/konami68000/Konami68000.cs index 57c6596a..7ae1de63 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/konami68000/Konami68000.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/konami68000/Konami68000.cs @@ -814,7 +814,7 @@ namespace MAME.Core public static void sound_arm_nmi_w() { Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_NMI, LineState.CLEAR_LINE); - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common( EmuTimer.TIME_ACT.Konami68000_nmi_callback, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.Konami68000_nmi_callback, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)50e12), Attotime.ATTOTIME_NEVER); } public static ushort punkshot_kludge_r() diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/Audio.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/Audio.cs index 68efbb85..8f8a0a8e 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/Audio.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/Audio.cs @@ -47,7 +47,7 @@ //Cpuint.lvec.Add(new vec(1, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(1, EmuTimer.get_current_time())); setvector_param = 1; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } else @@ -55,7 +55,7 @@ //Cpuint.lvec.Add(new vec(2, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(2, EmuTimer.get_current_time())); setvector_param = 2; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } } @@ -67,7 +67,7 @@ //Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(3, EmuTimer.get_current_time())); setvector_param = 3; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } } @@ -77,7 +77,7 @@ //Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(3, EmuTimer.get_current_time())); setvector_param = 3; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } public static void m72_sound_irq_ack_w(int offset, byte data) @@ -85,7 +85,7 @@ //Cpuint.lvec.Add(new vec(4, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(4, EmuTimer.get_current_time())); setvector_param = 4; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } public static void m72_set_sample_start(int start) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/M72.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/M72.cs index 48509fcd..239c88c5 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/M72.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m72/M72.cs @@ -297,7 +297,7 @@ namespace MAME.Core } public static void machine_start_m72() { - scanline_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M72_m72_scanline_interrupt, false); + EmuTimer.timer_alloc_common(ref scanline_timer, EmuTimer.TIME_ACT.M72_m72_scanline_interrupt, false); } public static void machine_reset_m72() { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/M92.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/M92.cs index 90fa27eb..6d68d3f3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/M92.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/M92.cs @@ -411,7 +411,8 @@ namespace MAME.Core { setvector_param = 0; setvector_callback(); - scanline_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M92_m92_scanline_interrupt, false); + //scanline_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M92_m92_scanline_interrupt, false); + EmuTimer.timer_alloc_common(ref scanline_timer,EmuTimer.TIME_ACT.M92_m92_scanline_interrupt, false); } public static void machine_reset_m92() { @@ -530,7 +531,7 @@ namespace MAME.Core //Cpuint.lvec.Add(new vec(3, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(3, EmuTimer.get_current_time())); setvector_param = 3; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); Sound.soundlatch_w((ushort)(data & 0xff)); } @@ -547,7 +548,7 @@ namespace MAME.Core //Cpuint.lvec.Add(new vec(4, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(4, EmuTimer.get_current_time())); setvector_param = 4; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } public static void m92_sound_status_w(ushort data) @@ -562,7 +563,7 @@ namespace MAME.Core //Cpuint.lvec.Add(new vec(1, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(1, EmuTimer.get_current_time())); setvector_param = 1; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } else @@ -570,7 +571,7 @@ namespace MAME.Core //Cpuint.lvec.Add(new vec(2, EmuTimer.get_current_time())); Cpuint.lvec.Add(ObjectPoolAuto.Acquire().setdata(2, EmuTimer.get_current_time())); setvector_param = 2; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.setvector, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.setvector, true); EmuTimer.timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs index 71543a2c..0a345f22 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs @@ -45,7 +45,7 @@ namespace MAME.Core { Generic.buffer_spriteram16_w(); m92_sprite_buffer_busy = 0; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M92_spritebuffer_callback, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.M92_spritebuffer_callback, true); EmuTimer.timer_adjust_periodic(timer, Attotime.attotime_mul(new Atime(0, (long)(1e18 / 26666000)), 0x400), Attotime.ATTOTIME_NEVER); } } @@ -67,7 +67,7 @@ namespace MAME.Core { Generic.buffer_spriteram16_w(); m92_sprite_buffer_busy = 0; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M92_spritebuffer_callback, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.M92_spritebuffer_callback, true); EmuTimer.timer_adjust_periodic(timer, Attotime.attotime_mul(new Atime(0, (long)(1e18 / 26666000)), 0x400), Attotime.ATTOTIME_NEVER); } } @@ -89,7 +89,7 @@ namespace MAME.Core { Generic.buffer_spriteram16_w(); m92_sprite_buffer_busy = 0; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.M92_spritebuffer_callback, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.M92_spritebuffer_callback, true); EmuTimer.timer_adjust_periodic(timer, Attotime.attotime_mul(new Atime(0, (long)(1e18 / 26666000)), 0x400), Attotime.ATTOTIME_NEVER); } } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Neogeo.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Neogeo.cs index 7e2f6854..5fa7c27c 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Neogeo.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Neogeo.cs @@ -365,9 +365,12 @@ namespace MAME.Core audio_cpu_banks[1] = 0x0e; audio_cpu_banks[2] = 0x06; audio_cpu_banks[3] = 0x02; - display_position_interrupt_timer = EmuTimer.timer_alloc_common( EmuTimer.TIME_ACT.Neogeo_display_position_interrupt_callback, false); - display_position_vblank_timer = EmuTimer.timer_alloc_common( EmuTimer.TIME_ACT.Neogeo_display_position_vblank_callback, false); - vblank_interrupt_timer = EmuTimer.timer_alloc_common( EmuTimer.TIME_ACT.Neogeo_vblank_interrupt_callback, false); + //display_position_interrupt_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Neogeo_display_position_interrupt_callback, false); + EmuTimer.timer_alloc_common(ref display_position_interrupt_timer, EmuTimer.TIME_ACT.Neogeo_display_position_interrupt_callback, false); + //display_position_vblank_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Neogeo_display_position_vblank_callback, false); + EmuTimer.timer_alloc_common(ref display_position_vblank_timer, EmuTimer.TIME_ACT.Neogeo_display_position_vblank_callback, false); + //vblank_interrupt_timer = EmuTimer.timer_alloc_common( EmuTimer.TIME_ACT.Neogeo_vblank_interrupt_callback, false); + EmuTimer.timer_alloc_common(ref vblank_interrupt_timer, EmuTimer.TIME_ACT.Neogeo_vblank_interrupt_callback, false); Pd4900a.pd4990a_init(); calendar_init(); irq3_pending = 1; @@ -393,8 +396,8 @@ namespace MAME.Core byte[] temp = new byte[0x2000]; Buffer.BlockCopy(mainram2_src, 0, temp, 0, temp.Length); using (System.IO.MemoryStream ms = new System.IO.MemoryStream(temp)) - { - MameMainMotion.IoSupport.File_WriteAllBytesFromStre("nvram\\" + Machine.sName + ".nv",ms); + { + MameMainMotion.IoSupport.File_WriteAllBytesFromStre("nvram\\" + Machine.sName + ".nv", ms); } } public static void machine_reset_neogeo() diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs index aee7fa0e..15e53f53 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/neogeo/Video.cs @@ -130,7 +130,8 @@ namespace MAME.Core } private static void create_auto_animation_timer() { - auto_animation_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Neogeo_auto_animation_timer_callback, false); + //auto_animation_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Neogeo_auto_animation_timer_callback, false); + EmuTimer.timer_alloc_common(ref auto_animation_timer, EmuTimer.TIME_ACT.Neogeo_auto_animation_timer_callback, false); } private static void start_auto_animation_timer() { @@ -516,7 +517,7 @@ namespace MAME.Core } } } - + //private static void draw_sprites(int iBitmap, int scanline) //{ // int x_2, code_2; @@ -735,7 +736,7 @@ namespace MAME.Core } private static void create_sprite_line_timer() { - sprite_line_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Neogeo_sprite_line_timer_callback, false); + EmuTimer.timer_alloc_common(ref sprite_line_timer, EmuTimer.TIME_ACT.Neogeo_sprite_line_timer_callback, false); } private static void start_sprite_line_timer() { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taito/Opwolf.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taito/Opwolf.cs index 29c25c6c..905e2943 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taito/Opwolf.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taito/Opwolf.cs @@ -981,7 +981,7 @@ namespace MAME.Core if (cchip_ram[0x7a] == 0 && cchip_last_7a != 0 && current_cmd != 0xf5) { current_cmd = 0xf5; - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Taito_opwolf_timer_callback, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(EmuTimer.TIME_ACT.Taito_opwolf_timer_callback, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(80000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); } cchip_last_7a = cchip_ram[0x7a]; diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taitob/Taitob.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taitob/Taitob.cs index 50587bb6..b0dabfe3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taitob/Taitob.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/taitob/Taitob.cs @@ -186,7 +186,7 @@ namespace MAME.Core } public static void rastansaga2_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_rsaga2_interrupt2, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_rsaga2_interrupt2, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 4, LineState.HOLD_LINE); } @@ -196,7 +196,7 @@ namespace MAME.Core } public static void crimec_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_crimec_interrupt3, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_crimec_interrupt3, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 5, LineState.HOLD_LINE); } @@ -206,7 +206,7 @@ namespace MAME.Core } public static void hitice_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_hitice_interrupt6, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_hitice_interrupt6, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 4, LineState.HOLD_LINE); } @@ -216,7 +216,7 @@ namespace MAME.Core } public static void rambo3_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_rambo3_interrupt1, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_rambo3_interrupt1, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 6, LineState.HOLD_LINE); } @@ -226,7 +226,7 @@ namespace MAME.Core } public static void pbobble_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_pbobble_interrupt5, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_pbobble_interrupt5, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 3, LineState.HOLD_LINE); } @@ -236,7 +236,7 @@ namespace MAME.Core } public static void viofight_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_viofight_interrupt1, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_viofight_interrupt1, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 4, LineState.HOLD_LINE); } @@ -246,7 +246,7 @@ namespace MAME.Core } public static void masterw_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_masterw_interrupt4, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_masterw_interrupt4, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 5, LineState.HOLD_LINE); } @@ -256,7 +256,7 @@ namespace MAME.Core } public static void silentd_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_silentd_interrupt4, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_silentd_interrupt4, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 6, LineState.HOLD_LINE); } @@ -266,7 +266,7 @@ namespace MAME.Core } public static void selfeena_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_selfeena_interrupt4, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_selfeena_interrupt4, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(5000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 6, LineState.HOLD_LINE); } @@ -276,7 +276,7 @@ namespace MAME.Core } public static void sbm_interrupt() { - EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common(TIME_ACT.Taitob_sbm_interrupt5, true); + EmuTimer.emu_timer timer = EmuTimer.timer_alloc_common_NoRef(TIME_ACT.Taitob_sbm_interrupt5, true); EmuTimer.timer_adjust_periodic(timer, new Atime(0, (long)(10000 * Cpuexec.cpu[0].attoseconds_per_cycle)), Attotime.ATTOTIME_NEVER); Cpuint.cpunum_set_input_line(0, 4, LineState.HOLD_LINE); } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/ICS2115.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/ICS2115.cs index 24a806e1..9769225f 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/ICS2115.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/ICS2115.cs @@ -328,13 +328,36 @@ namespace MAME.Core return 0; } } + + static void ReInit_timer() + { + if (timer != null) + { + if (timer[0].timer != null) EmuTimer.emu_timer.SetNull(ref timer[0].timer); + if (timer[1].timer != null) EmuTimer.emu_timer.SetNull(ref timer[1].timer); + timer[0].scale = default; + timer[0].preset = default; + timer[0].period = default; + timer[1].scale = default; + timer[1].preset = default; + timer[1].period = default; + } + else + { + timer = new timer_struct[2]; + } + } + public static void ics2115_start() { int i; voice2 = new voice_struct[32]; - timer = new timer_struct[2]; - timer[0].timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.ICS2115_timer_cb_0, false); - timer[1].timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.ICS2115_timer_cb_1, false); + //timer = new timer_struct[2]; + ReInit_timer(); + //timer[0].timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.ICS2115_timer_cb_0, false); + EmuTimer.timer_alloc_common(ref timer[0].timer,EmuTimer.TIME_ACT.ICS2115_timer_cb_0, false); + //timer[1].timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.ICS2115_timer_cb_1, false); + EmuTimer.timer_alloc_common(ref timer[1].timer,EmuTimer.TIME_ACT.ICS2115_timer_cb_1, false); ulaw = new short[256]; for (i = 0; i < 256; i++) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/MSM5205.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/MSM5205.cs index c2208f6d..9243d30f 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/MSM5205.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/MSM5205.cs @@ -176,11 +176,13 @@ namespace MAME.Core mm1[sndindex].voice.stream = new sound_stream(clock, 0, 1, mm1[sndindex].MSM5205_update); if (sndindex == 0) { - timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.MSM5205_MSM5205_vclk_callback0, false); + //timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.MSM5205_MSM5205_vclk_callback0, false); + EmuTimer.timer_alloc_common(ref timer[0], EmuTimer.TIME_ACT.MSM5205_MSM5205_vclk_callback0, false); } else if (sndindex == 1) { - timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.MSM5205_MSM5205_vclk_callback1, false); + //timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.MSM5205_MSM5205_vclk_callback1, false); + EmuTimer.timer_alloc_common(ref timer[1], EmuTimer.TIME_ACT.MSM5205_MSM5205_vclk_callback1, false); } mm1[sndindex].msm5205_reset(); } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Sound.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Sound.cs index 39f114d5..6c815b45 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Sound.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Sound.cs @@ -74,7 +74,8 @@ namespace MAME.Core latched_value = new ushort[2]; utempdata = new ushort[2]; sound_update = sound_updateC; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + //sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2151.ym2151_init(3579545); OKI6295.okim6295_start(); ym2151stream = new sound_stream(55930, 0, 2, YM2151.ym2151_update_one); @@ -84,7 +85,8 @@ namespace MAME.Core case "CPS-1(QSound)": case "CPS2": sound_update = sound_updateQ; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + //sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); QSound.qsound_start(); qsoundstream = new sound_stream(4000000 / 166, 0, 2, QSound.qsound_update); mixerstream = new sound_stream(48000, 2, 0, null); @@ -93,7 +95,8 @@ namespace MAME.Core latched_value = new ushort[1]; utempdata = new ushort[1]; sound_update = sound_updateDataeast_pcktgal; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + //sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2203.ym2203_start(0, 1500000); YM3812.ym3812_start(3000000); MSM5205.msm5205_start(0, 384000, Dataeast.pcktgal_adpcm_int, 5); @@ -104,7 +107,8 @@ namespace MAME.Core latched_value = new ushort[1]; utempdata = new ushort[1]; sound_update = sound_updateTehkan_pbaction; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + //sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); AY8910.ay8910_interface generic_ay8910 = new AY8910.ay8910_interface(); generic_ay8910.flags = 1; generic_ay8910.res_load = new int[3] { 1000, 1000, 1000 }; @@ -121,7 +125,7 @@ namespace MAME.Core latched_value = new ushort[2]; utempdata = new ushort[2]; sound_update = sound_updateN; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2610.ym2610_start(8000000); ym2610stream = new sound_stream(111111, 0, 2, YM2610.F2610.ym2610_update_one); mixerstream = new sound_stream(48000, 3, 0, null); @@ -130,7 +134,7 @@ namespace MAME.Core latched_value = new ushort[2]; utempdata = new ushort[2]; sound_update = sound_updateSunA8; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM3812.ym3812_start(4000000); AY8910.ay8910_interface starfigh_ay8910_interface = new AY8910.ay8910_interface(); starfigh_ay8910_interface.flags = 1; @@ -147,7 +151,7 @@ namespace MAME.Core break; case "Namco System 1": sound_update = sound_updateNa; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2151.ym2151_init(3579580); Namco.namco_start(); DAC.dac_start(); @@ -168,7 +172,7 @@ namespace MAME.Core case "drgnwrldv11h": case "drgnwrldv40k": sound_update = sound_updateIGS011_drgnwrld; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); OKI6295.okim6295_start(); YM3812.ym3812_start(3579545); okistream = new sound_stream(1047600 / 132, 0, 1, OKI6295.okim6295_update); @@ -182,7 +186,7 @@ namespace MAME.Core case "xymg": case "wlcc": sound_update = sound_updateIGS011_lhb; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); OKI6295.okim6295_start(); okistream = new sound_stream(1047600 / 132, 0, 1, OKI6295.okim6295_update); mixerstream = new sound_stream(48000, 1, 0, null); @@ -190,7 +194,7 @@ namespace MAME.Core case "lhb2": case "nkishusp": sound_update = sound_updateIGS011_lhb2; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); OKI6295.okim6295_start(); YM2413.ym2413_start(3579545); okistream = new sound_stream(1047600 / 132, 0, 1, OKI6295.okim6295_update); @@ -200,7 +204,7 @@ namespace MAME.Core case "vbowl": case "vbowlj": sound_update = sound_updateIGS011_vbowl; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); ICS2115.ics2115_start(); ics2115stream = new sound_stream(33075, 0, 2, ICS2115.ics2115_update); mixerstream = new sound_stream(48000, 2, 0, null); @@ -211,7 +215,7 @@ namespace MAME.Core latched_value = new ushort[3]; utempdata = new ushort[3]; sound_update = sound_updatePGM; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); ICS2115.ics2115_start(); ics2115stream = new sound_stream(33075, 0, 2, ICS2115.ics2115_update); mixerstream = new sound_stream(48000, 2, 0, null); @@ -220,7 +224,7 @@ namespace MAME.Core latched_value = new ushort[1]; utempdata = new ushort[1]; sound_update = sound_updateM72; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2151.ym2151_init(3579545); DAC.dac_start(); ym2151stream = new sound_stream(55930, 0, 2, YM2151.ym2151_update_one); @@ -231,7 +235,7 @@ namespace MAME.Core latched_value = new ushort[1]; utempdata = new ushort[1]; sound_update = sound_updateM92; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2151.ym2151_init(3579545); Iremga20.iremga20_start(); ym2151stream = new sound_stream(55930, 0, 2, YM2151.ym2151_update_one); @@ -248,7 +252,7 @@ namespace MAME.Core latched_value = new ushort[2]; utempdata = new ushort[2]; sound_update = sound_updateTaito_tokio; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2203.ym2203_start(0, 3000000); mixerstream = new sound_stream(48000, 4, 0, null); break; @@ -273,7 +277,7 @@ namespace MAME.Core latched_value = new ushort[2]; utempdata = new ushort[2]; sound_update = sound_updateTaito_bublbobl; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2203.ym2203_start(0, 3000000); YM3812.ym3526_start(3000000); ym3526stream = new sound_stream(41666, 0, 1, FMOpl.ym3526_update_one); @@ -288,7 +292,7 @@ namespace MAME.Core latched_value = new ushort[1]; utempdata = new ushort[1]; sound_update = sound_updateTaito_opwolf; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); YM2151.ym2151_init(4000000); ym2151stream = new sound_stream(62500, 0, 2, YM2151.ym2151_update_one); MSM5205.msm5205_start(0, 384000, Taito.opwolf_msm5205_vck, 5); @@ -315,7 +319,7 @@ namespace MAME.Core AY8910.AA8910[0].stream.gain = 0x100; ym2610stream.gain = 0x100; sound_update = sound_updateTaitoB; - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); mixerstream = new sound_stream(48000, 3, 0, null); break; case "Konami 68000": @@ -441,7 +445,7 @@ namespace MAME.Core mixerstream = new sound_stream(48000, 2, 0, null); break; } - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); break; case "Capcom": latched_value = new ushort[1]; @@ -480,7 +484,8 @@ namespace MAME.Core mixerstream = new sound_stream(48000, 4, 0, null); break; } - sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + //sound_update_timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Sound_sound_update, false); + EmuTimer.timer_alloc_common(ref sound_update_timer, EmuTimer.TIME_ACT.Sound_sound_update, false); break; } EmuTimer.timer_adjust_periodic(sound_update_timer, update_frequency, update_frequency); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Upd7759.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Upd7759.cs index 2c9909d3..29bc779a 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Upd7759.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/Upd7759.cs @@ -302,7 +302,8 @@ namespace MAME.Core chip.rombase = 0; if (updrom == null) { - chip.timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Upd7759_upd7759_slave_update, false); + //chip.timer = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.Upd7759_upd7759_slave_update, false); + EmuTimer.timer_alloc_common(ref chip.timer, EmuTimer.TIME_ACT.Upd7759_upd7759_slave_update, false); } chip.reset = 1; chip.start = 1; diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2151.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2151.cs index be596e71..773f2329 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2151.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2151.cs @@ -933,8 +933,10 @@ namespace MAME.Core PSG.eg_timer_add = (uint)(0x10000 * (clock / 64.0) / PSG.sampfreq); PSG.eg_timer_overflow = 0x30000; /* this must be done _before_ a call to ym2151_reset_chip() */ - PSG.timer_A = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2151_timer_callback_a, false); - PSG.timer_B = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2151_timer_callback_b, false); + //PSG.timer_A = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2151_timer_callback_a, false); + EmuTimer.timer_alloc_common(ref PSG.timer_A,EmuTimer.TIME_ACT.YM2151_timer_callback_a, false); + //PSG.timer_B = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2151_timer_callback_b, false); + EmuTimer.timer_alloc_common(ref PSG.timer_B,EmuTimer.TIME_ACT.YM2151_timer_callback_b, false); ym2151_reset_chip(); switch (Machine.sBoard) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2203.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2203.cs index d5467b94..05a73cd6 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2203.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2203.cs @@ -8,6 +8,19 @@ namespace MAME.Core public sound_stream stream; public static YM2203[] FF2203 = new YM2203[2]; public EmuTimer.emu_timer[] timer; + + public void ReInit_timer() + { + if (timer != null) + { + if (timer[0] != null) EmuTimer.emu_timer.SetNull(ref timer[0]); + if (timer[1] != null) EmuTimer.emu_timer.SetNull(ref timer[1]); + } + else + { + timer = new EmuTimer.emu_timer[2]; + } + } public static void timer_callback_2203_0_0() { FF2203[0].ym2203_timer_over(0); @@ -139,16 +152,21 @@ namespace MAME.Core FMOpl.sin_tab = new uint[0x1000]; int rate = clock / 72; AY8910.ay8910_start_ym(14, sndindex, clock, generic_2203); - FF2203[sndindex].timer = new EmuTimer.emu_timer[2]; + //FF2203[sndindex].timer = new EmuTimer.emu_timer[2]; + FF2203[sndindex].ReInit_timer(); if (sndindex == 0) { - FF2203[sndindex].timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_0_0, false); - FF2203[sndindex].timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_0_1, false); + //FF2203[sndindex].timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_0_0, false); + EmuTimer.timer_alloc_common(ref FF2203[sndindex].timer[0], EmuTimer.TIME_ACT.YM2203_timer_callback_2203_0_0, false); + //FF2203[sndindex].timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_0_1, false); + EmuTimer.timer_alloc_common(ref FF2203[sndindex].timer[1], EmuTimer.TIME_ACT.YM2203_timer_callback_2203_0_1, false); } else if (sndindex == 1) { - FF2203[sndindex].timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_1_0, false); - FF2203[sndindex].timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_1_1, false); + //FF2203[sndindex].timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_1_0, false); + EmuTimer.timer_alloc_common(ref FF2203[sndindex].timer[0], EmuTimer.TIME_ACT.YM2203_timer_callback_2203_1_0, false); + //FF2203[sndindex].timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2203_timer_callback_2203_1_1, false); + EmuTimer.timer_alloc_common(ref FF2203[sndindex].timer[1], EmuTimer.TIME_ACT.YM2203_timer_callback_2203_1_1, false); } FF2203[sndindex].stream = new sound_stream(rate, 0, 1, FF2203[sndindex].ym2203_update_one); ym2203_init(sndindex, clock, rate); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2610.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2610.cs index 105e499e..28741661 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2610.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM2610.cs @@ -85,6 +85,21 @@ namespace MAME.Core } FM.out_adpcm[FM.ipan[c]] += adpcm[c].adpcm_out; } + + + static void ReInit_timer() + { + if (timer != null) + { + if (timer[0] != null) EmuTimer.emu_timer.SetNull(ref timer[0]); + if (timer[1] != null) EmuTimer.emu_timer.SetNull(ref timer[1]); + } + else + { + timer = new EmuTimer.emu_timer[2]; + } + } + public static void ym2610_start(int clock) { F2610 = new YM2610(); @@ -98,9 +113,12 @@ namespace MAME.Core generic_ay8910.portBwrite = null; int rate = clock / 72; AY8910.ay8910_start_ym(17, 0, clock, generic_ay8910); - timer = new EmuTimer.emu_timer[2]; - timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2610_F2610_timer_callback_0, false); - timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2610_F2610_timer_callback_1, false); + ReInit_timer(); + //timer = new EmuTimer.emu_timer[2]; + //timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2610_F2610_timer_callback_0, false); + EmuTimer.timer_alloc_common(ref timer[0], EmuTimer.TIME_ACT.YM2610_F2610_timer_callback_0, false); + //timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM2610_F2610_timer_callback_1, false); + EmuTimer.timer_alloc_common(ref timer[1], EmuTimer.TIME_ACT.YM2610_F2610_timer_callback_1, false); ym2610_init(clock, rate); } public static void ym2610_init(int clock, int rate) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM3812.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM3812.cs index 658e5d6c..95f488c6 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM3812.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/sound/YM3812.cs @@ -36,11 +36,25 @@ namespace MAME.Core { Sound.ym3812stream.stream_update(); } + + static void ReInit_timer() + { + if (timer != null) + { + if (timer[0] != null) EmuTimer.emu_timer.SetNull(ref timer[0]); + if (timer[1] != null) EmuTimer.emu_timer.SetNull(ref timer[1]); + } + else + { + timer = new EmuTimer.emu_timer[2]; + } + } public static void ym3812_start(int clock) { FMOpl.tl_tab = new int[0x1800]; FMOpl.sin_tab = new uint[0x1000]; - timer = new EmuTimer.emu_timer[2]; + ReInit_timer(); + //timer = new EmuTimer.emu_timer[2]; int rate = clock / 72; switch (Machine.sName) { @@ -73,8 +87,8 @@ namespace MAME.Core FMOpl.ym3812_set_timer_handler(TimerHandler_3812); FMOpl.ym3812_set_irq_handler(IRQHandler_3812); FMOpl.ym3812_set_update_handler(_stream_update_3812); - timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM3812_timer_callback_3812_0, false); - timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM3812_timer_callback_3812_1, false); + EmuTimer.timer_alloc_common(ref timer[0], EmuTimer.TIME_ACT.YM3812_timer_callback_3812_0, false); + EmuTimer.timer_alloc_common(ref timer[1],EmuTimer.TIME_ACT.YM3812_timer_callback_3812_1, false); } public static void ym3812_control_port_0_w(byte data) { @@ -228,12 +242,13 @@ namespace MAME.Core { int rate = clock / 72; FMOpl.YM3526 = FMOpl.ym3526_init(0, clock, rate); - timer = new EmuTimer.emu_timer[2]; + ReInit_timer(); + //timer = new EmuTimer.emu_timer[2]; FMOpl.ym3526_set_timer_handler(TimerHandler_3526); FMOpl.ym3526_set_irq_handler(IRQHandler_3526); FMOpl.ym3526_set_update_handler(_stream_update_3526); - timer[0] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM3812_timer_callback_3526_0, false); - timer[1] = EmuTimer.timer_alloc_common(EmuTimer.TIME_ACT.YM3812_timer_callback_3526_1, false); + EmuTimer.timer_alloc_common(ref timer[0], EmuTimer.TIME_ACT.YM3812_timer_callback_3526_0, false); + EmuTimer.timer_alloc_common(ref timer[1], EmuTimer.TIME_ACT.YM3812_timer_callback_3526_1, false); } public static void ym3526_control_port_0_w(byte data) { -- 2.36.0.windows.1 From b30df60365355a7f8c96e23f3697d5d34155396a Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Fri, 7 Nov 2025 17:30:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?MAME:=E6=94=BE=E5=BC=83Switch=E8=B0=83?= =?UTF-8?q?=E5=BA=A6NEC=E7=9A=84CPU=E6=8C=87=E4=BB=A4,=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=A7=94=E6=89=98=E6=95=B0=E7=BB=84=20=20=20|=20=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84MAME=E7=9A=84=20cpu=20timer=E5=9B=9E=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Plugins/Mame.Core/cpu/nec/Nec.cs | 34 +- .../Plugins/Mame.Core/cpu/nec/NecInstr.cs | 36 +- .../Plugins/Mame.Core/cpu/nec/NecModrm.cs | 24 +- .../Mame.Core/cpu/nec/Nec_GetEA.OpCode.Do.cs | 74 +- .../cpu/nec/Nec_GetEA.OpCode.Enum.cs | 452 ++++---- .../cpu/nec/Nec_instruction.OpCode.Do.cs | 516 ++++----- .../cpu/nec/Nec_instruction.OpCode.Enum.cs | 1026 ++++++++--------- .../Assets/Plugins/Mame.Core/emu/EmuTimer.cs | 98 +- .../Assets/Plugins/Mame.Core/emu/Mame.cs | 2 +- .../Plugins/Mame.Core/mame/dataeast/Input.cs | 77 +- .../Plugins/Mame.Core/mame/m92/Video.cs | 250 ++-- 11 files changed, 1364 insertions(+), 1225 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec.cs index a67a8311..dc8d7ad5 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec.cs @@ -130,10 +130,10 @@ namespace cpu.nec public Action WriteIOByte; public Func ReadIOWord; public Action WriteIOWord; - //public delegate void nec_delegate(); - //public nec_delegate[] nec_instruction; - //public delegate int getea_delegate(); - //public getea_delegate[] GetEA; + public delegate void nec_delegate(); + public nec_delegate[] nec_instruction; + public delegate int getea_delegate(); + public getea_delegate[] GetEA; public Nec() { nec_init(); @@ -483,8 +483,8 @@ namespace cpu.nec } else { - //EA = GetEA[ModRM](); - EA = DoNecGetEAOpCode(ModRM); + EA = GetEA[ModRM](); + //EA = DoNecGetEAOpCode(ModRM); tmp = ReadByte(EA); } } @@ -497,8 +497,8 @@ namespace cpu.nec } else { - //EA = GetEA[ModRM](); - EA = DoNecGetEAOpCode(ModRM); + EA = GetEA[ModRM](); + //EA = DoNecGetEAOpCode(ModRM); tmp = ReadWord(EA); } } @@ -796,6 +796,7 @@ namespace cpu.nec di++; } } + public void nec_init() { mod_RM = new Mod_RM(); @@ -803,8 +804,6 @@ namespace cpu.nec mod_RM.regb = new int[256]; mod_RM.RMw = new int[256]; mod_RM.RMb = new int[256]; - //更换调度方式,不再依赖Delegate委托 - /* nec_instruction = new nec_delegate[]{ i_add_br8, i_add_wr16, @@ -1063,9 +1062,7 @@ namespace cpu.nec i_fepre, i_ffpre }; - */ - /* GetEA = new getea_delegate[192]{ EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007, @@ -1094,7 +1091,6 @@ namespace cpu.nec EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207, EA_200, EA_201, EA_202, EA_203, EA_204, EA_205, EA_206, EA_207 }; - */ } public override void Reset() { @@ -1196,8 +1192,8 @@ namespace cpu.nec } public void nec_trap() { - //nec_instruction[fetchop()](); - DoInstructionOpCode(fetchop()); + nec_instruction[fetchop()](); + //DoInstructionOpCode(fetchop()); nec_interrupt(1, false); } public void external_int() @@ -1306,8 +1302,8 @@ namespace cpu.nec I.no_interrupt--; } iNOP = fetchop(); - //nec_instruction[iNOP](); - DoInstructionOpCode(iNOP); + nec_instruction[iNOP](); + //DoInstructionOpCode(iNOP); int delta = prevCycles - pendingCycles; totalExecutedCycles += (ulong)delta; } @@ -1347,8 +1343,8 @@ namespace cpu.nec I.no_interrupt--; } iNOP = fetchop(); - //nec_instruction[iNOP](); - DoInstructionOpCode(iNOP); + nec_instruction[iNOP](); + //DoInstructionOpCode(iNOP); int delta = prevCycles - pendingCycles; totalExecutedCycles += (ulong)delta; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecInstr.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecInstr.cs index 9bd4318a..444b6a00 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecInstr.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecInstr.cs @@ -372,8 +372,8 @@ seg_prefix = 1; prefix_base = I.sregs[0] << 4; CLK(2); - //nec_instruction[fetchop()](); - DoInstructionOpCode(fetchop()); + nec_instruction[fetchop()](); + //DoInstructionOpCode(fetchop()); seg_prefix = 0; } void i_daa() @@ -442,8 +442,8 @@ seg_prefix = 1; prefix_base = I.sregs[1] << 4; CLK(2); - //nec_instruction[fetchop()](); - DoInstructionOpCode(fetchop()); + nec_instruction[fetchop()](); + //DoInstructionOpCode(fetchop()); seg_prefix = 0; } void i_das() @@ -512,8 +512,8 @@ seg_prefix = 1; prefix_base = I.sregs[2] << 4; CLK(2); - //nec_instruction[fetchop()](); - DoInstructionOpCode(fetchop()); + nec_instruction[fetchop()](); + //DoInstructionOpCode(fetchop()); seg_prefix = 0; } void i_aaa() @@ -572,8 +572,8 @@ seg_prefix = 1; prefix_base = I.sregs[3] << 4; CLK(2); - //nec_instruction[fetchop()](); - DoInstructionOpCode(fetchop()); + nec_instruction[fetchop()](); + //DoInstructionOpCode(fetchop()); seg_prefix = 0; } void i_aas() @@ -844,8 +844,8 @@ case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && !CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && !CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; default: - //nec_instruction[next](); - DoInstructionOpCode(next); + nec_instruction[next](); + //DoInstructionOpCode(next); break; } seg_prefix = 0; @@ -878,8 +878,8 @@ case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && CF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; default: - //nec_instruction[next](); - DoInstructionOpCode(next); + nec_instruction[next](); + //DoInstructionOpCode(next); break; } seg_prefix = 0; @@ -1325,8 +1325,8 @@ void i_lea() { int ModRM = FETCH(); - //GetEA[ModRM](); - DoNecGetEAOpCode(ModRM); + GetEA[ModRM](); + //DoNecGetEAOpCode(ModRM); //I.regs.w[mod_RM.regw[ModRM]] = EO; @@ -2217,8 +2217,8 @@ case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && ZF() == false); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && ZF() == false); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; default: - //nec_instruction[next](); - DoInstructionOpCode(next); + nec_instruction[next](); + //DoInstructionOpCode(next); break; } seg_prefix = 0; @@ -2251,8 +2251,8 @@ case 0xae: CLK(2); if (c != 0) do { i_scasb(); c--; } while (c > 0 && ZF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; case 0xaf: CLK(2); if (c != 0) do { i_scasw(); c--; } while (c > 0 && ZF()); I.regs.b[2] = (byte)(c % 0x100); I.regs.b[3] = (byte)(c / 0x100); break; default: - //nec_instruction[next](); - DoInstructionOpCode(next); + nec_instruction[next](); + //DoInstructionOpCode(next); break; } seg_prefix = 0; diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecModrm.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecModrm.cs index 010c423b..6ff31667 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecModrm.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/NecModrm.cs @@ -14,8 +14,8 @@ { return (ushort)(ModRM >= 0xc0 ? I.regs.b[mod_RM.RMw[ModRM] * 2] + I.regs.b[mod_RM.RMw[ModRM] * 2 + 1] * 0x100 : ReadWord( - //GetEA[ModRM]() - DoNecGetEAOpCode(ModRM) + GetEA[ModRM]() + //DoNecGetEAOpCode(ModRM) )); } void PutbackRMWord(int ModRM, ushort val) @@ -46,8 +46,8 @@ else { WriteWord( - //GetEA[ModRM]() - DoNecGetEAOpCode(ModRM) + GetEA[ModRM]() + //DoNecGetEAOpCode(ModRM) , val); } } @@ -63,8 +63,8 @@ } else { - //EA = GetEA[ModRM](); - EA = DoNecGetEAOpCode(ModRM); + EA = GetEA[ModRM](); + //EA = DoNecGetEAOpCode(ModRM); val = FETCHWORD(); WriteWord(EA, val); } @@ -72,8 +72,8 @@ byte GetRMByte(int ModRM) { return ((ModRM) >= 0xc0 ? I.regs.b[mod_RM.RMb[ModRM]] : ReadByte( - //GetEA[ModRM]() - DoNecGetEAOpCode(ModRM) + GetEA[ModRM]() + //DoNecGetEAOpCode(ModRM) )); } void PutRMByte(int ModRM, byte val) @@ -85,8 +85,8 @@ else { WriteByte( - //GetEA[ModRM]() - DoNecGetEAOpCode(ModRM) + GetEA[ModRM]() + //DoNecGetEAOpCode(ModRM) , val); } } @@ -98,8 +98,8 @@ } else { - //EA = GetEA[ModRM](); - EA = DoNecGetEAOpCode(ModRM); + EA = GetEA[ModRM](); + //EA = DoNecGetEAOpCode(ModRM); WriteByte(EA, FETCH()); } } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Do.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Do.cs index 010873a7..76b1b442 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Do.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Do.cs @@ -3,42 +3,42 @@ public partial class Nec { - /// - /// 重写的Nec GetEAOpCode指令调度 - /// - /// - public int DoNecGetEAOpCode(int op) - { - NecGetEAOpCode opType = NecGetEAOpCodeArr[op]; - switch (opType) - { - case NecGetEAOpCode.EA_000: return EA_000(); - case NecGetEAOpCode.EA_001: return EA_001(); - case NecGetEAOpCode.EA_002: return EA_002(); - case NecGetEAOpCode.EA_003: return EA_003(); - case NecGetEAOpCode.EA_004: return EA_004(); - case NecGetEAOpCode.EA_005: return EA_005(); - case NecGetEAOpCode.EA_006: return EA_006(); - case NecGetEAOpCode.EA_007: return EA_007(); - case NecGetEAOpCode.EA_100: return EA_100(); - case NecGetEAOpCode.EA_101: return EA_101(); - case NecGetEAOpCode.EA_102: return EA_102(); - case NecGetEAOpCode.EA_103: return EA_103(); - case NecGetEAOpCode.EA_104: return EA_104(); - case NecGetEAOpCode.EA_105: return EA_105(); - case NecGetEAOpCode.EA_106: return EA_106(); - case NecGetEAOpCode.EA_107: return EA_107(); - case NecGetEAOpCode.EA_200: return EA_200(); - case NecGetEAOpCode.EA_201: return EA_201(); - case NecGetEAOpCode.EA_202: return EA_202(); - case NecGetEAOpCode.EA_203: return EA_203(); - case NecGetEAOpCode.EA_204: return EA_204(); - case NecGetEAOpCode.EA_205: return EA_205(); - case NecGetEAOpCode.EA_206: return EA_206(); - case NecGetEAOpCode.EA_207: return EA_207(); - default: - throw new System.Exception("NecGetEAOpCode Err"); - } - } + ///// + ///// 重写的Nec GetEAOpCode指令调度 + ///// + ///// + //public int DoNecGetEAOpCode(int op) + //{ + // NecGetEAOpCode opType = NecGetEAOpCodeArr[op]; + // switch (opType) + // { + // case NecGetEAOpCode.EA_000: return EA_000(); + // case NecGetEAOpCode.EA_001: return EA_001(); + // case NecGetEAOpCode.EA_002: return EA_002(); + // case NecGetEAOpCode.EA_003: return EA_003(); + // case NecGetEAOpCode.EA_004: return EA_004(); + // case NecGetEAOpCode.EA_005: return EA_005(); + // case NecGetEAOpCode.EA_006: return EA_006(); + // case NecGetEAOpCode.EA_007: return EA_007(); + // case NecGetEAOpCode.EA_100: return EA_100(); + // case NecGetEAOpCode.EA_101: return EA_101(); + // case NecGetEAOpCode.EA_102: return EA_102(); + // case NecGetEAOpCode.EA_103: return EA_103(); + // case NecGetEAOpCode.EA_104: return EA_104(); + // case NecGetEAOpCode.EA_105: return EA_105(); + // case NecGetEAOpCode.EA_106: return EA_106(); + // case NecGetEAOpCode.EA_107: return EA_107(); + // case NecGetEAOpCode.EA_200: return EA_200(); + // case NecGetEAOpCode.EA_201: return EA_201(); + // case NecGetEAOpCode.EA_202: return EA_202(); + // case NecGetEAOpCode.EA_203: return EA_203(); + // case NecGetEAOpCode.EA_204: return EA_204(); + // case NecGetEAOpCode.EA_205: return EA_205(); + // case NecGetEAOpCode.EA_206: return EA_206(); + // case NecGetEAOpCode.EA_207: return EA_207(); + // default: + // throw new System.Exception("NecGetEAOpCode Err"); + // } + //} } } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Enum.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Enum.cs index 50b26469..a7b35a3d 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Enum.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_GetEA.OpCode.Enum.cs @@ -2,232 +2,230 @@ { partial class Nec { - /// - /// 自定义Nec GetEA 指令集枚举 - /// - public enum NecGetEAOpCode : byte - { - EA_000, - EA_001, - EA_002, - EA_003, - EA_004, - EA_005, - EA_006, - EA_007, - EA_100, - EA_101, - EA_102, - EA_103, - EA_104, - EA_105, - EA_106, - EA_107, - EA_200, - EA_201, - EA_202, - EA_203, - EA_204, - EA_205, - EA_206, - EA_207 - } - - - static readonly NecGetEAOpCode[] NecGetEAOpCodeArr = new NecGetEAOpCode[] - { - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_000, - NecGetEAOpCode.EA_001, - NecGetEAOpCode.EA_002, - NecGetEAOpCode.EA_003, - NecGetEAOpCode.EA_004, - NecGetEAOpCode.EA_005, - NecGetEAOpCode.EA_006, - NecGetEAOpCode.EA_007, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_100, - NecGetEAOpCode.EA_101, - NecGetEAOpCode.EA_102, - NecGetEAOpCode.EA_103, - NecGetEAOpCode.EA_104, - NecGetEAOpCode.EA_105, - NecGetEAOpCode.EA_106, - NecGetEAOpCode.EA_107, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207, - NecGetEAOpCode.EA_200, - NecGetEAOpCode.EA_201, - NecGetEAOpCode.EA_202, - NecGetEAOpCode.EA_203, - NecGetEAOpCode.EA_204, - NecGetEAOpCode.EA_205, - NecGetEAOpCode.EA_206, - NecGetEAOpCode.EA_207 - }; + ///// + ///// 自定义Nec GetEA 指令集枚举 + ///// + //public enum NecGetEAOpCode : byte + //{ + // EA_000, + // EA_001, + // EA_002, + // EA_003, + // EA_004, + // EA_005, + // EA_006, + // EA_007, + // EA_100, + // EA_101, + // EA_102, + // EA_103, + // EA_104, + // EA_105, + // EA_106, + // EA_107, + // EA_200, + // EA_201, + // EA_202, + // EA_203, + // EA_204, + // EA_205, + // EA_206, + // EA_207 + //} + //static readonly NecGetEAOpCode[] NecGetEAOpCodeArr = new NecGetEAOpCode[] + // { + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_000, + // NecGetEAOpCode.EA_001, + // NecGetEAOpCode.EA_002, + // NecGetEAOpCode.EA_003, + // NecGetEAOpCode.EA_004, + // NecGetEAOpCode.EA_005, + // NecGetEAOpCode.EA_006, + // NecGetEAOpCode.EA_007, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_100, + // NecGetEAOpCode.EA_101, + // NecGetEAOpCode.EA_102, + // NecGetEAOpCode.EA_103, + // NecGetEAOpCode.EA_104, + // NecGetEAOpCode.EA_105, + // NecGetEAOpCode.EA_106, + // NecGetEAOpCode.EA_107, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207, + // NecGetEAOpCode.EA_200, + // NecGetEAOpCode.EA_201, + // NecGetEAOpCode.EA_202, + // NecGetEAOpCode.EA_203, + // NecGetEAOpCode.EA_204, + // NecGetEAOpCode.EA_205, + // NecGetEAOpCode.EA_206, + // NecGetEAOpCode.EA_207 + // }; }; } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Do.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Do.cs index bba52641..bcf35035 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Do.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Do.cs @@ -3,263 +3,263 @@ public partial class Nec { - /// - /// 重写的Nec Instruction指令调度 - /// - /// - public void DoInstructionOpCode(int op) - { - NecInstructionOpCode opType = NecInstructionOpCodeArr[op]; - switch (opType) - { - case NecInstructionOpCode.i_add_br8: i_add_br8(); return; - case NecInstructionOpCode.i_add_wr16: i_add_wr16(); return; - case NecInstructionOpCode.i_add_r8b: i_add_r8b(); return; - case NecInstructionOpCode.i_add_r16w: i_add_r16w(); return; - case NecInstructionOpCode.i_add_ald8: i_add_ald8(); return; - case NecInstructionOpCode.i_add_axd16: i_add_axd16(); return; - case NecInstructionOpCode.i_push_es: i_push_es(); return; - case NecInstructionOpCode.i_pop_es: i_pop_es(); return; - case NecInstructionOpCode.i_or_br8: i_or_br8(); return; - case NecInstructionOpCode.i_or_wr16: i_or_wr16(); return; - case NecInstructionOpCode.i_or_r8b: i_or_r8b(); return; - case NecInstructionOpCode.i_or_r16w: i_or_r16w(); return; - case NecInstructionOpCode.i_or_ald8: i_or_ald8(); return; - case NecInstructionOpCode.i_or_axd16: i_or_axd16(); return; - case NecInstructionOpCode.i_push_cs: i_push_cs(); return; - case NecInstructionOpCode.i_pre_nec: i_pre_nec(); return; - case NecInstructionOpCode.i_adc_br8: i_adc_br8(); return; - case NecInstructionOpCode.i_adc_wr16: i_adc_wr16(); return; - case NecInstructionOpCode.i_adc_r8b: i_adc_r8b(); return; - case NecInstructionOpCode.i_adc_r16w: i_adc_r16w(); return; - case NecInstructionOpCode.i_adc_ald8: i_adc_ald8(); return; - case NecInstructionOpCode.i_adc_axd16: i_adc_axd16(); return; - case NecInstructionOpCode.i_push_ss: i_push_ss(); return; - case NecInstructionOpCode.i_pop_ss: i_pop_ss(); return; - case NecInstructionOpCode.i_sbb_br8: i_sbb_br8(); return; - case NecInstructionOpCode.i_sbb_wr16: i_sbb_wr16(); return; - case NecInstructionOpCode.i_sbb_r8b: i_sbb_r8b(); return; - case NecInstructionOpCode.i_sbb_r16w: i_sbb_r16w(); return; - case NecInstructionOpCode.i_sbb_ald8: i_sbb_ald8(); return; - case NecInstructionOpCode.i_sbb_axd16: i_sbb_axd16(); return; - case NecInstructionOpCode.i_push_ds: i_push_ds(); return; - case NecInstructionOpCode.i_pop_ds: i_pop_ds(); return; - case NecInstructionOpCode.i_and_br8: i_and_br8(); return; - case NecInstructionOpCode.i_and_wr16: i_and_wr16(); return; - case NecInstructionOpCode.i_and_r8b: i_and_r8b(); return; - case NecInstructionOpCode.i_and_r16w: i_and_r16w(); return; - case NecInstructionOpCode.i_and_ald8: i_and_ald8(); return; - case NecInstructionOpCode.i_and_axd16: i_and_axd16(); return; - case NecInstructionOpCode.i_es: i_es(); return; - case NecInstructionOpCode.i_daa: i_daa(); return; - case NecInstructionOpCode.i_sub_br8: i_sub_br8(); return; - case NecInstructionOpCode.i_sub_wr16: i_sub_wr16(); return; - case NecInstructionOpCode.i_sub_r8b: i_sub_r8b(); return; - case NecInstructionOpCode.i_sub_r16w: i_sub_r16w(); return; - case NecInstructionOpCode.i_sub_ald8: i_sub_ald8(); return; - case NecInstructionOpCode.i_sub_axd16: i_sub_axd16(); return; - case NecInstructionOpCode.i_cs: i_cs(); return; - case NecInstructionOpCode.i_das: i_das(); return; - case NecInstructionOpCode.i_xor_br8: i_xor_br8(); return; - case NecInstructionOpCode.i_xor_wr16: i_xor_wr16(); return; - case NecInstructionOpCode.i_xor_r8b: i_xor_r8b(); return; - case NecInstructionOpCode.i_xor_r16w: i_xor_r16w(); return; - case NecInstructionOpCode.i_xor_ald8: i_xor_ald8(); return; - case NecInstructionOpCode.i_xor_axd16: i_xor_axd16(); return; - case NecInstructionOpCode.i_ss: i_ss(); return; - case NecInstructionOpCode.i_aaa: i_aaa(); return; - case NecInstructionOpCode.i_cmp_br8: i_cmp_br8(); return; - case NecInstructionOpCode.i_cmp_wr16: i_cmp_wr16(); return; - case NecInstructionOpCode.i_cmp_r8b: i_cmp_r8b(); return; - case NecInstructionOpCode.i_cmp_r16w: i_cmp_r16w(); return; - case NecInstructionOpCode.i_cmp_ald8: i_cmp_ald8(); return; - case NecInstructionOpCode.i_cmp_axd16: i_cmp_axd16(); return; - case NecInstructionOpCode.i_ds: i_ds(); return; - case NecInstructionOpCode.i_aas: i_aas(); return; - case NecInstructionOpCode.i_inc_ax: i_inc_ax(); return; - case NecInstructionOpCode.i_inc_cx: i_inc_cx(); return; - case NecInstructionOpCode.i_inc_dx: i_inc_dx(); return; - case NecInstructionOpCode.i_inc_bx: i_inc_bx(); return; - case NecInstructionOpCode.i_inc_sp: i_inc_sp(); return; - case NecInstructionOpCode.i_inc_bp: i_inc_bp(); return; - case NecInstructionOpCode.i_inc_si: i_inc_si(); return; - case NecInstructionOpCode.i_inc_di: i_inc_di(); return; - case NecInstructionOpCode.i_dec_ax: i_dec_ax(); return; - case NecInstructionOpCode.i_dec_cx: i_dec_cx(); return; - case NecInstructionOpCode.i_dec_dx: i_dec_dx(); return; - case NecInstructionOpCode.i_dec_bx: i_dec_bx(); return; - case NecInstructionOpCode.i_dec_sp: i_dec_sp(); return; - case NecInstructionOpCode.i_dec_bp: i_dec_bp(); return; - case NecInstructionOpCode.i_dec_si: i_dec_si(); return; - case NecInstructionOpCode.i_dec_di: i_dec_di(); return; - case NecInstructionOpCode.i_push_ax: i_push_ax(); return; - case NecInstructionOpCode.i_push_cx: i_push_cx(); return; - case NecInstructionOpCode.i_push_dx: i_push_dx(); return; - case NecInstructionOpCode.i_push_bx: i_push_bx(); return; - case NecInstructionOpCode.i_push_sp: i_push_sp(); return; - case NecInstructionOpCode.i_push_bp: i_push_bp(); return; - case NecInstructionOpCode.i_push_si: i_push_si(); return; - case NecInstructionOpCode.i_push_di: i_push_di(); return; - case NecInstructionOpCode.i_pop_ax: i_pop_ax(); return; - case NecInstructionOpCode.i_pop_cx: i_pop_cx(); return; - case NecInstructionOpCode.i_pop_dx: i_pop_dx(); return; - case NecInstructionOpCode.i_pop_bx: i_pop_bx(); return; - case NecInstructionOpCode.i_pop_sp: i_pop_sp(); return; - case NecInstructionOpCode.i_pop_bp: i_pop_bp(); return; - case NecInstructionOpCode.i_pop_si: i_pop_si(); return; - case NecInstructionOpCode.i_pop_di: i_pop_di(); return; - case NecInstructionOpCode.i_pusha: i_pusha(); return; - case NecInstructionOpCode.i_popa: i_popa(); return; - case NecInstructionOpCode.i_chkind: i_chkind(); return; - case NecInstructionOpCode.i_brkn: i_brkn(); return; - case NecInstructionOpCode.i_repnc: i_repnc(); return; - case NecInstructionOpCode.i_repc: i_repc(); return; - case NecInstructionOpCode.i_invalid: i_invalid(); return; - case NecInstructionOpCode.i_push_d16: i_push_d16(); return; - case NecInstructionOpCode.i_imul_d16: i_imul_d16(); return; - case NecInstructionOpCode.i_push_d8: i_push_d8(); return; - case NecInstructionOpCode.i_imul_d8: i_imul_d8(); return; - case NecInstructionOpCode.i_insb: i_insb(); return; - case NecInstructionOpCode.i_insw: i_insw(); return; - case NecInstructionOpCode.i_outsb: i_outsb(); return; - case NecInstructionOpCode.i_outsw: i_outsw(); return; - case NecInstructionOpCode.i_jo: i_jo(); return; - case NecInstructionOpCode.i_jno: i_jno(); return; - case NecInstructionOpCode.i_jc: i_jc(); return; - case NecInstructionOpCode.i_jnc: i_jnc(); return; - case NecInstructionOpCode.i_jz: i_jz(); return; - case NecInstructionOpCode.i_jnz: i_jnz(); return; - case NecInstructionOpCode.i_jce: i_jce(); return; - case NecInstructionOpCode.i_jnce: i_jnce(); return; - case NecInstructionOpCode.i_js: i_js(); return; - case NecInstructionOpCode.i_jns: i_jns(); return; - case NecInstructionOpCode.i_jp: i_jp(); return; - case NecInstructionOpCode.i_jnp: i_jnp(); return; - case NecInstructionOpCode.i_jl: i_jl(); return; - case NecInstructionOpCode.i_jnl: i_jnl(); return; - case NecInstructionOpCode.i_jle: i_jle(); return; - case NecInstructionOpCode.i_jnle: i_jnle(); return; - case NecInstructionOpCode.i_80pre: i_80pre(); return; - case NecInstructionOpCode.i_81pre: i_81pre(); return; - case NecInstructionOpCode.i_82pre: i_82pre(); return; - case NecInstructionOpCode.i_83pre: i_83pre(); return; - case NecInstructionOpCode.i_test_br8: i_test_br8(); return; - case NecInstructionOpCode.i_test_wr16: i_test_wr16(); return; - case NecInstructionOpCode.i_xchg_br8: i_xchg_br8(); return; - case NecInstructionOpCode.i_xchg_wr16: i_xchg_wr16(); return; - case NecInstructionOpCode.i_mov_br8: i_mov_br8(); return; - case NecInstructionOpCode.i_mov_wr16: i_mov_wr16(); return; - case NecInstructionOpCode.i_mov_r8b: i_mov_r8b(); return; - case NecInstructionOpCode.i_mov_r16w: i_mov_r16w(); return; - case NecInstructionOpCode.i_mov_wsreg: i_mov_wsreg(); return; - case NecInstructionOpCode.i_lea: i_lea(); return; - case NecInstructionOpCode.i_mov_sregw: i_mov_sregw(); return; - case NecInstructionOpCode.i_popw: i_popw(); return; - case NecInstructionOpCode.i_nop: i_nop(); return; - case NecInstructionOpCode.i_xchg_axcx: i_xchg_axcx(); return; - case NecInstructionOpCode.i_xchg_axdx: i_xchg_axdx(); return; - case NecInstructionOpCode.i_xchg_axbx: i_xchg_axbx(); return; - case NecInstructionOpCode.i_xchg_axsp: i_xchg_axsp(); return; - case NecInstructionOpCode.i_xchg_axbp: i_xchg_axbp(); return; - case NecInstructionOpCode.i_xchg_axsi: i_xchg_axsi(); return; - case NecInstructionOpCode.i_xchg_axdi: i_xchg_axdi(); return; - case NecInstructionOpCode.i_cbw: i_cbw(); return; - case NecInstructionOpCode.i_cwd: i_cwd(); return; - case NecInstructionOpCode.i_call_far: i_call_far(); return; - case NecInstructionOpCode.i_wait: i_wait(); return; - case NecInstructionOpCode.i_pushf: i_pushf(); return; - case NecInstructionOpCode.i_popf: i_popf(); return; - case NecInstructionOpCode.i_sahf: i_sahf(); return; - case NecInstructionOpCode.i_lahf: i_lahf(); return; - case NecInstructionOpCode.i_mov_aldisp: i_mov_aldisp(); return; - case NecInstructionOpCode.i_mov_axdisp: i_mov_axdisp(); return; - case NecInstructionOpCode.i_mov_dispal: i_mov_dispal(); return; - case NecInstructionOpCode.i_mov_dispax: i_mov_dispax(); return; - case NecInstructionOpCode.i_movsb: i_movsb(); return; - case NecInstructionOpCode.i_movsw: i_movsw(); return; - case NecInstructionOpCode.i_cmpsb: i_cmpsb(); return; - case NecInstructionOpCode.i_cmpsw: i_cmpsw(); return; - case NecInstructionOpCode.i_test_ald8: i_test_ald8(); return; - case NecInstructionOpCode.i_test_axd16: i_test_axd16(); return; - case NecInstructionOpCode.i_stosb: i_stosb(); return; - case NecInstructionOpCode.i_stosw: i_stosw(); return; - case NecInstructionOpCode.i_lodsb: i_lodsb(); return; - case NecInstructionOpCode.i_lodsw: i_lodsw(); return; - case NecInstructionOpCode.i_scasb: i_scasb(); return; - case NecInstructionOpCode.i_scasw: i_scasw(); return; - case NecInstructionOpCode.i_mov_ald8: i_mov_ald8(); return; - case NecInstructionOpCode.i_mov_cld8: i_mov_cld8(); return; - case NecInstructionOpCode.i_mov_dld8: i_mov_dld8(); return; - case NecInstructionOpCode.i_mov_bld8: i_mov_bld8(); return; - case NecInstructionOpCode.i_mov_ahd8: i_mov_ahd8(); return; - case NecInstructionOpCode.i_mov_chd8: i_mov_chd8(); return; - case NecInstructionOpCode.i_mov_dhd8: i_mov_dhd8(); return; - case NecInstructionOpCode.i_mov_bhd8: i_mov_bhd8(); return; - case NecInstructionOpCode.i_mov_axd16: i_mov_axd16(); return; - case NecInstructionOpCode.i_mov_cxd16: i_mov_cxd16(); return; - case NecInstructionOpCode.i_mov_dxd16: i_mov_dxd16(); return; - case NecInstructionOpCode.i_mov_bxd16: i_mov_bxd16(); return; - case NecInstructionOpCode.i_mov_spd16: i_mov_spd16(); return; - case NecInstructionOpCode.i_mov_bpd16: i_mov_bpd16(); return; - case NecInstructionOpCode.i_mov_sid16: i_mov_sid16(); return; - case NecInstructionOpCode.i_mov_did16: i_mov_did16(); return; - case NecInstructionOpCode.i_rotshft_bd8: i_rotshft_bd8(); return; - case NecInstructionOpCode.i_rotshft_wd8: i_rotshft_wd8(); return; - case NecInstructionOpCode.i_ret_d16: i_ret_d16(); return; - case NecInstructionOpCode.i_ret: i_ret(); return; - case NecInstructionOpCode.i_les_dw: i_les_dw(); return; - case NecInstructionOpCode.i_lds_dw: i_lds_dw(); return; - case NecInstructionOpCode.i_mov_bd8: i_mov_bd8(); return; - case NecInstructionOpCode.i_mov_wd16: i_mov_wd16(); return; - case NecInstructionOpCode.i_enter: i_enter(); return; - case NecInstructionOpCode.i_leave: i_leave(); return; - case NecInstructionOpCode.i_retf_d16: i_retf_d16(); return; - case NecInstructionOpCode.i_retf: i_retf(); return; - case NecInstructionOpCode.i_int3: i_int3(); return; - case NecInstructionOpCode.i_int: i_int(); return; - case NecInstructionOpCode.i_into: i_into(); return; - case NecInstructionOpCode.i_iret: i_iret(); return; - case NecInstructionOpCode.i_rotshft_b: i_rotshft_b(); return; - case NecInstructionOpCode.i_rotshft_w: i_rotshft_w(); return; - case NecInstructionOpCode.i_rotshft_bcl: i_rotshft_bcl(); return; - case NecInstructionOpCode.i_rotshft_wcl: i_rotshft_wcl(); return; - case NecInstructionOpCode.i_aam: i_aam(); return; - case NecInstructionOpCode.i_aad: i_aad(); return; - case NecInstructionOpCode.i_setalc: i_setalc(); return; - case NecInstructionOpCode.i_trans: i_trans(); return; - case NecInstructionOpCode.i_fpo: i_fpo(); return; - case NecInstructionOpCode.i_loopne: i_loopne(); return; - case NecInstructionOpCode.i_loope: i_loope(); return; - case NecInstructionOpCode.i_loop: i_loop(); return; - case NecInstructionOpCode.i_jcxz: i_jcxz(); return; - case NecInstructionOpCode.i_inal: i_inal(); return; - case NecInstructionOpCode.i_inax: i_inax(); return; - case NecInstructionOpCode.i_outal: i_outal(); return; - case NecInstructionOpCode.i_outax: i_outax(); return; - case NecInstructionOpCode.i_call_d16: i_call_d16(); return; - case NecInstructionOpCode.i_jmp_d16: i_jmp_d16(); return; - case NecInstructionOpCode.i_jmp_far: i_jmp_far(); return; - case NecInstructionOpCode.i_jmp_d8: i_jmp_d8(); return; - case NecInstructionOpCode.i_inaldx: i_inaldx(); return; - case NecInstructionOpCode.i_inaxdx: i_inaxdx(); return; - case NecInstructionOpCode.i_outdxal: i_outdxal(); return; - case NecInstructionOpCode.i_outdxax: i_outdxax(); return; - case NecInstructionOpCode.i_lock: i_lock(); return; - case NecInstructionOpCode.i_repne: i_repne(); return; - case NecInstructionOpCode.i_repe: i_repe(); return; - case NecInstructionOpCode.i_hlt: i_hlt(); return; - case NecInstructionOpCode.i_cmc: i_cmc(); return; - case NecInstructionOpCode.i_f6pre: i_f6pre(); return; - case NecInstructionOpCode.i_f7pre: i_f7pre(); return; - case NecInstructionOpCode.i_clc: i_clc(); return; - case NecInstructionOpCode.i_stc: i_stc(); return; - case NecInstructionOpCode.i_di: i_di(); return; - case NecInstructionOpCode.i_ei: i_ei(); return; - case NecInstructionOpCode.i_cld: i_cld(); return; - case NecInstructionOpCode.i_std: i_std(); return; - case NecInstructionOpCode.i_fepre: i_fepre(); return; - case NecInstructionOpCode.i_ffpre: i_ffpre(); return; - } - } + ///// + ///// 重写的Nec Instruction指令调度 + ///// + ///// + //public void DoInstructionOpCode(int op) + //{ + // NecInstructionOpCode opType = NecInstructionOpCodeArr[op]; + // switch (opType) + // { + // case NecInstructionOpCode.i_add_br8: i_add_br8(); return; + // case NecInstructionOpCode.i_add_wr16: i_add_wr16(); return; + // case NecInstructionOpCode.i_add_r8b: i_add_r8b(); return; + // case NecInstructionOpCode.i_add_r16w: i_add_r16w(); return; + // case NecInstructionOpCode.i_add_ald8: i_add_ald8(); return; + // case NecInstructionOpCode.i_add_axd16: i_add_axd16(); return; + // case NecInstructionOpCode.i_push_es: i_push_es(); return; + // case NecInstructionOpCode.i_pop_es: i_pop_es(); return; + // case NecInstructionOpCode.i_or_br8: i_or_br8(); return; + // case NecInstructionOpCode.i_or_wr16: i_or_wr16(); return; + // case NecInstructionOpCode.i_or_r8b: i_or_r8b(); return; + // case NecInstructionOpCode.i_or_r16w: i_or_r16w(); return; + // case NecInstructionOpCode.i_or_ald8: i_or_ald8(); return; + // case NecInstructionOpCode.i_or_axd16: i_or_axd16(); return; + // case NecInstructionOpCode.i_push_cs: i_push_cs(); return; + // case NecInstructionOpCode.i_pre_nec: i_pre_nec(); return; + // case NecInstructionOpCode.i_adc_br8: i_adc_br8(); return; + // case NecInstructionOpCode.i_adc_wr16: i_adc_wr16(); return; + // case NecInstructionOpCode.i_adc_r8b: i_adc_r8b(); return; + // case NecInstructionOpCode.i_adc_r16w: i_adc_r16w(); return; + // case NecInstructionOpCode.i_adc_ald8: i_adc_ald8(); return; + // case NecInstructionOpCode.i_adc_axd16: i_adc_axd16(); return; + // case NecInstructionOpCode.i_push_ss: i_push_ss(); return; + // case NecInstructionOpCode.i_pop_ss: i_pop_ss(); return; + // case NecInstructionOpCode.i_sbb_br8: i_sbb_br8(); return; + // case NecInstructionOpCode.i_sbb_wr16: i_sbb_wr16(); return; + // case NecInstructionOpCode.i_sbb_r8b: i_sbb_r8b(); return; + // case NecInstructionOpCode.i_sbb_r16w: i_sbb_r16w(); return; + // case NecInstructionOpCode.i_sbb_ald8: i_sbb_ald8(); return; + // case NecInstructionOpCode.i_sbb_axd16: i_sbb_axd16(); return; + // case NecInstructionOpCode.i_push_ds: i_push_ds(); return; + // case NecInstructionOpCode.i_pop_ds: i_pop_ds(); return; + // case NecInstructionOpCode.i_and_br8: i_and_br8(); return; + // case NecInstructionOpCode.i_and_wr16: i_and_wr16(); return; + // case NecInstructionOpCode.i_and_r8b: i_and_r8b(); return; + // case NecInstructionOpCode.i_and_r16w: i_and_r16w(); return; + // case NecInstructionOpCode.i_and_ald8: i_and_ald8(); return; + // case NecInstructionOpCode.i_and_axd16: i_and_axd16(); return; + // case NecInstructionOpCode.i_es: i_es(); return; + // case NecInstructionOpCode.i_daa: i_daa(); return; + // case NecInstructionOpCode.i_sub_br8: i_sub_br8(); return; + // case NecInstructionOpCode.i_sub_wr16: i_sub_wr16(); return; + // case NecInstructionOpCode.i_sub_r8b: i_sub_r8b(); return; + // case NecInstructionOpCode.i_sub_r16w: i_sub_r16w(); return; + // case NecInstructionOpCode.i_sub_ald8: i_sub_ald8(); return; + // case NecInstructionOpCode.i_sub_axd16: i_sub_axd16(); return; + // case NecInstructionOpCode.i_cs: i_cs(); return; + // case NecInstructionOpCode.i_das: i_das(); return; + // case NecInstructionOpCode.i_xor_br8: i_xor_br8(); return; + // case NecInstructionOpCode.i_xor_wr16: i_xor_wr16(); return; + // case NecInstructionOpCode.i_xor_r8b: i_xor_r8b(); return; + // case NecInstructionOpCode.i_xor_r16w: i_xor_r16w(); return; + // case NecInstructionOpCode.i_xor_ald8: i_xor_ald8(); return; + // case NecInstructionOpCode.i_xor_axd16: i_xor_axd16(); return; + // case NecInstructionOpCode.i_ss: i_ss(); return; + // case NecInstructionOpCode.i_aaa: i_aaa(); return; + // case NecInstructionOpCode.i_cmp_br8: i_cmp_br8(); return; + // case NecInstructionOpCode.i_cmp_wr16: i_cmp_wr16(); return; + // case NecInstructionOpCode.i_cmp_r8b: i_cmp_r8b(); return; + // case NecInstructionOpCode.i_cmp_r16w: i_cmp_r16w(); return; + // case NecInstructionOpCode.i_cmp_ald8: i_cmp_ald8(); return; + // case NecInstructionOpCode.i_cmp_axd16: i_cmp_axd16(); return; + // case NecInstructionOpCode.i_ds: i_ds(); return; + // case NecInstructionOpCode.i_aas: i_aas(); return; + // case NecInstructionOpCode.i_inc_ax: i_inc_ax(); return; + // case NecInstructionOpCode.i_inc_cx: i_inc_cx(); return; + // case NecInstructionOpCode.i_inc_dx: i_inc_dx(); return; + // case NecInstructionOpCode.i_inc_bx: i_inc_bx(); return; + // case NecInstructionOpCode.i_inc_sp: i_inc_sp(); return; + // case NecInstructionOpCode.i_inc_bp: i_inc_bp(); return; + // case NecInstructionOpCode.i_inc_si: i_inc_si(); return; + // case NecInstructionOpCode.i_inc_di: i_inc_di(); return; + // case NecInstructionOpCode.i_dec_ax: i_dec_ax(); return; + // case NecInstructionOpCode.i_dec_cx: i_dec_cx(); return; + // case NecInstructionOpCode.i_dec_dx: i_dec_dx(); return; + // case NecInstructionOpCode.i_dec_bx: i_dec_bx(); return; + // case NecInstructionOpCode.i_dec_sp: i_dec_sp(); return; + // case NecInstructionOpCode.i_dec_bp: i_dec_bp(); return; + // case NecInstructionOpCode.i_dec_si: i_dec_si(); return; + // case NecInstructionOpCode.i_dec_di: i_dec_di(); return; + // case NecInstructionOpCode.i_push_ax: i_push_ax(); return; + // case NecInstructionOpCode.i_push_cx: i_push_cx(); return; + // case NecInstructionOpCode.i_push_dx: i_push_dx(); return; + // case NecInstructionOpCode.i_push_bx: i_push_bx(); return; + // case NecInstructionOpCode.i_push_sp: i_push_sp(); return; + // case NecInstructionOpCode.i_push_bp: i_push_bp(); return; + // case NecInstructionOpCode.i_push_si: i_push_si(); return; + // case NecInstructionOpCode.i_push_di: i_push_di(); return; + // case NecInstructionOpCode.i_pop_ax: i_pop_ax(); return; + // case NecInstructionOpCode.i_pop_cx: i_pop_cx(); return; + // case NecInstructionOpCode.i_pop_dx: i_pop_dx(); return; + // case NecInstructionOpCode.i_pop_bx: i_pop_bx(); return; + // case NecInstructionOpCode.i_pop_sp: i_pop_sp(); return; + // case NecInstructionOpCode.i_pop_bp: i_pop_bp(); return; + // case NecInstructionOpCode.i_pop_si: i_pop_si(); return; + // case NecInstructionOpCode.i_pop_di: i_pop_di(); return; + // case NecInstructionOpCode.i_pusha: i_pusha(); return; + // case NecInstructionOpCode.i_popa: i_popa(); return; + // case NecInstructionOpCode.i_chkind: i_chkind(); return; + // case NecInstructionOpCode.i_brkn: i_brkn(); return; + // case NecInstructionOpCode.i_repnc: i_repnc(); return; + // case NecInstructionOpCode.i_repc: i_repc(); return; + // case NecInstructionOpCode.i_invalid: i_invalid(); return; + // case NecInstructionOpCode.i_push_d16: i_push_d16(); return; + // case NecInstructionOpCode.i_imul_d16: i_imul_d16(); return; + // case NecInstructionOpCode.i_push_d8: i_push_d8(); return; + // case NecInstructionOpCode.i_imul_d8: i_imul_d8(); return; + // case NecInstructionOpCode.i_insb: i_insb(); return; + // case NecInstructionOpCode.i_insw: i_insw(); return; + // case NecInstructionOpCode.i_outsb: i_outsb(); return; + // case NecInstructionOpCode.i_outsw: i_outsw(); return; + // case NecInstructionOpCode.i_jo: i_jo(); return; + // case NecInstructionOpCode.i_jno: i_jno(); return; + // case NecInstructionOpCode.i_jc: i_jc(); return; + // case NecInstructionOpCode.i_jnc: i_jnc(); return; + // case NecInstructionOpCode.i_jz: i_jz(); return; + // case NecInstructionOpCode.i_jnz: i_jnz(); return; + // case NecInstructionOpCode.i_jce: i_jce(); return; + // case NecInstructionOpCode.i_jnce: i_jnce(); return; + // case NecInstructionOpCode.i_js: i_js(); return; + // case NecInstructionOpCode.i_jns: i_jns(); return; + // case NecInstructionOpCode.i_jp: i_jp(); return; + // case NecInstructionOpCode.i_jnp: i_jnp(); return; + // case NecInstructionOpCode.i_jl: i_jl(); return; + // case NecInstructionOpCode.i_jnl: i_jnl(); return; + // case NecInstructionOpCode.i_jle: i_jle(); return; + // case NecInstructionOpCode.i_jnle: i_jnle(); return; + // case NecInstructionOpCode.i_80pre: i_80pre(); return; + // case NecInstructionOpCode.i_81pre: i_81pre(); return; + // case NecInstructionOpCode.i_82pre: i_82pre(); return; + // case NecInstructionOpCode.i_83pre: i_83pre(); return; + // case NecInstructionOpCode.i_test_br8: i_test_br8(); return; + // case NecInstructionOpCode.i_test_wr16: i_test_wr16(); return; + // case NecInstructionOpCode.i_xchg_br8: i_xchg_br8(); return; + // case NecInstructionOpCode.i_xchg_wr16: i_xchg_wr16(); return; + // case NecInstructionOpCode.i_mov_br8: i_mov_br8(); return; + // case NecInstructionOpCode.i_mov_wr16: i_mov_wr16(); return; + // case NecInstructionOpCode.i_mov_r8b: i_mov_r8b(); return; + // case NecInstructionOpCode.i_mov_r16w: i_mov_r16w(); return; + // case NecInstructionOpCode.i_mov_wsreg: i_mov_wsreg(); return; + // case NecInstructionOpCode.i_lea: i_lea(); return; + // case NecInstructionOpCode.i_mov_sregw: i_mov_sregw(); return; + // case NecInstructionOpCode.i_popw: i_popw(); return; + // case NecInstructionOpCode.i_nop: i_nop(); return; + // case NecInstructionOpCode.i_xchg_axcx: i_xchg_axcx(); return; + // case NecInstructionOpCode.i_xchg_axdx: i_xchg_axdx(); return; + // case NecInstructionOpCode.i_xchg_axbx: i_xchg_axbx(); return; + // case NecInstructionOpCode.i_xchg_axsp: i_xchg_axsp(); return; + // case NecInstructionOpCode.i_xchg_axbp: i_xchg_axbp(); return; + // case NecInstructionOpCode.i_xchg_axsi: i_xchg_axsi(); return; + // case NecInstructionOpCode.i_xchg_axdi: i_xchg_axdi(); return; + // case NecInstructionOpCode.i_cbw: i_cbw(); return; + // case NecInstructionOpCode.i_cwd: i_cwd(); return; + // case NecInstructionOpCode.i_call_far: i_call_far(); return; + // case NecInstructionOpCode.i_wait: i_wait(); return; + // case NecInstructionOpCode.i_pushf: i_pushf(); return; + // case NecInstructionOpCode.i_popf: i_popf(); return; + // case NecInstructionOpCode.i_sahf: i_sahf(); return; + // case NecInstructionOpCode.i_lahf: i_lahf(); return; + // case NecInstructionOpCode.i_mov_aldisp: i_mov_aldisp(); return; + // case NecInstructionOpCode.i_mov_axdisp: i_mov_axdisp(); return; + // case NecInstructionOpCode.i_mov_dispal: i_mov_dispal(); return; + // case NecInstructionOpCode.i_mov_dispax: i_mov_dispax(); return; + // case NecInstructionOpCode.i_movsb: i_movsb(); return; + // case NecInstructionOpCode.i_movsw: i_movsw(); return; + // case NecInstructionOpCode.i_cmpsb: i_cmpsb(); return; + // case NecInstructionOpCode.i_cmpsw: i_cmpsw(); return; + // case NecInstructionOpCode.i_test_ald8: i_test_ald8(); return; + // case NecInstructionOpCode.i_test_axd16: i_test_axd16(); return; + // case NecInstructionOpCode.i_stosb: i_stosb(); return; + // case NecInstructionOpCode.i_stosw: i_stosw(); return; + // case NecInstructionOpCode.i_lodsb: i_lodsb(); return; + // case NecInstructionOpCode.i_lodsw: i_lodsw(); return; + // case NecInstructionOpCode.i_scasb: i_scasb(); return; + // case NecInstructionOpCode.i_scasw: i_scasw(); return; + // case NecInstructionOpCode.i_mov_ald8: i_mov_ald8(); return; + // case NecInstructionOpCode.i_mov_cld8: i_mov_cld8(); return; + // case NecInstructionOpCode.i_mov_dld8: i_mov_dld8(); return; + // case NecInstructionOpCode.i_mov_bld8: i_mov_bld8(); return; + // case NecInstructionOpCode.i_mov_ahd8: i_mov_ahd8(); return; + // case NecInstructionOpCode.i_mov_chd8: i_mov_chd8(); return; + // case NecInstructionOpCode.i_mov_dhd8: i_mov_dhd8(); return; + // case NecInstructionOpCode.i_mov_bhd8: i_mov_bhd8(); return; + // case NecInstructionOpCode.i_mov_axd16: i_mov_axd16(); return; + // case NecInstructionOpCode.i_mov_cxd16: i_mov_cxd16(); return; + // case NecInstructionOpCode.i_mov_dxd16: i_mov_dxd16(); return; + // case NecInstructionOpCode.i_mov_bxd16: i_mov_bxd16(); return; + // case NecInstructionOpCode.i_mov_spd16: i_mov_spd16(); return; + // case NecInstructionOpCode.i_mov_bpd16: i_mov_bpd16(); return; + // case NecInstructionOpCode.i_mov_sid16: i_mov_sid16(); return; + // case NecInstructionOpCode.i_mov_did16: i_mov_did16(); return; + // case NecInstructionOpCode.i_rotshft_bd8: i_rotshft_bd8(); return; + // case NecInstructionOpCode.i_rotshft_wd8: i_rotshft_wd8(); return; + // case NecInstructionOpCode.i_ret_d16: i_ret_d16(); return; + // case NecInstructionOpCode.i_ret: i_ret(); return; + // case NecInstructionOpCode.i_les_dw: i_les_dw(); return; + // case NecInstructionOpCode.i_lds_dw: i_lds_dw(); return; + // case NecInstructionOpCode.i_mov_bd8: i_mov_bd8(); return; + // case NecInstructionOpCode.i_mov_wd16: i_mov_wd16(); return; + // case NecInstructionOpCode.i_enter: i_enter(); return; + // case NecInstructionOpCode.i_leave: i_leave(); return; + // case NecInstructionOpCode.i_retf_d16: i_retf_d16(); return; + // case NecInstructionOpCode.i_retf: i_retf(); return; + // case NecInstructionOpCode.i_int3: i_int3(); return; + // case NecInstructionOpCode.i_int: i_int(); return; + // case NecInstructionOpCode.i_into: i_into(); return; + // case NecInstructionOpCode.i_iret: i_iret(); return; + // case NecInstructionOpCode.i_rotshft_b: i_rotshft_b(); return; + // case NecInstructionOpCode.i_rotshft_w: i_rotshft_w(); return; + // case NecInstructionOpCode.i_rotshft_bcl: i_rotshft_bcl(); return; + // case NecInstructionOpCode.i_rotshft_wcl: i_rotshft_wcl(); return; + // case NecInstructionOpCode.i_aam: i_aam(); return; + // case NecInstructionOpCode.i_aad: i_aad(); return; + // case NecInstructionOpCode.i_setalc: i_setalc(); return; + // case NecInstructionOpCode.i_trans: i_trans(); return; + // case NecInstructionOpCode.i_fpo: i_fpo(); return; + // case NecInstructionOpCode.i_loopne: i_loopne(); return; + // case NecInstructionOpCode.i_loope: i_loope(); return; + // case NecInstructionOpCode.i_loop: i_loop(); return; + // case NecInstructionOpCode.i_jcxz: i_jcxz(); return; + // case NecInstructionOpCode.i_inal: i_inal(); return; + // case NecInstructionOpCode.i_inax: i_inax(); return; + // case NecInstructionOpCode.i_outal: i_outal(); return; + // case NecInstructionOpCode.i_outax: i_outax(); return; + // case NecInstructionOpCode.i_call_d16: i_call_d16(); return; + // case NecInstructionOpCode.i_jmp_d16: i_jmp_d16(); return; + // case NecInstructionOpCode.i_jmp_far: i_jmp_far(); return; + // case NecInstructionOpCode.i_jmp_d8: i_jmp_d8(); return; + // case NecInstructionOpCode.i_inaldx: i_inaldx(); return; + // case NecInstructionOpCode.i_inaxdx: i_inaxdx(); return; + // case NecInstructionOpCode.i_outdxal: i_outdxal(); return; + // case NecInstructionOpCode.i_outdxax: i_outdxax(); return; + // case NecInstructionOpCode.i_lock: i_lock(); return; + // case NecInstructionOpCode.i_repne: i_repne(); return; + // case NecInstructionOpCode.i_repe: i_repe(); return; + // case NecInstructionOpCode.i_hlt: i_hlt(); return; + // case NecInstructionOpCode.i_cmc: i_cmc(); return; + // case NecInstructionOpCode.i_f6pre: i_f6pre(); return; + // case NecInstructionOpCode.i_f7pre: i_f7pre(); return; + // case NecInstructionOpCode.i_clc: i_clc(); return; + // case NecInstructionOpCode.i_stc: i_stc(); return; + // case NecInstructionOpCode.i_di: i_di(); return; + // case NecInstructionOpCode.i_ei: i_ei(); return; + // case NecInstructionOpCode.i_cld: i_cld(); return; + // case NecInstructionOpCode.i_std: i_std(); return; + // case NecInstructionOpCode.i_fepre: i_fepre(); return; + // case NecInstructionOpCode.i_ffpre: i_ffpre(); return; + // } + //} } } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Enum.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Enum.cs index b0507efb..989fe685 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Enum.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/cpu/nec/Nec_instruction.OpCode.Enum.cs @@ -2,519 +2,517 @@ { partial class Nec { - /// - /// 自定义Nec指令集枚举 - /// - public enum NecInstructionOpCode : byte - { - i_add_br8, - i_add_wr16, - i_add_r8b, - i_add_r16w, - i_add_ald8, - i_add_axd16, - i_push_es, - i_pop_es, - i_or_br8, - i_or_wr16, - i_or_r8b, - i_or_r16w, - i_or_ald8, - i_or_axd16, - i_push_cs, - i_pre_nec, - i_adc_br8, - i_adc_wr16, - i_adc_r8b, - i_adc_r16w, - i_adc_ald8, - i_adc_axd16, - i_push_ss, - i_pop_ss, - i_sbb_br8, - i_sbb_wr16, - i_sbb_r8b, - i_sbb_r16w, - i_sbb_ald8, - i_sbb_axd16, - i_push_ds, - i_pop_ds, - i_and_br8, - i_and_wr16, - i_and_r8b, - i_and_r16w, - i_and_ald8, - i_and_axd16, - i_es, - i_daa, - i_sub_br8, - i_sub_wr16, - i_sub_r8b, - i_sub_r16w, - i_sub_ald8, - i_sub_axd16, - i_cs, - i_das, - i_xor_br8, - i_xor_wr16, - i_xor_r8b, - i_xor_r16w, - i_xor_ald8, - i_xor_axd16, - i_ss, - i_aaa, - i_cmp_br8, - i_cmp_wr16, - i_cmp_r8b, - i_cmp_r16w, - i_cmp_ald8, - i_cmp_axd16, - i_ds, - i_aas, - i_inc_ax, - i_inc_cx, - i_inc_dx, - i_inc_bx, - i_inc_sp, - i_inc_bp, - i_inc_si, - i_inc_di, - i_dec_ax, - i_dec_cx, - i_dec_dx, - i_dec_bx, - i_dec_sp, - i_dec_bp, - i_dec_si, - i_dec_di, - i_push_ax, - i_push_cx, - i_push_dx, - i_push_bx, - i_push_sp, - i_push_bp, - i_push_si, - i_push_di, - i_pop_ax, - i_pop_cx, - i_pop_dx, - i_pop_bx, - i_pop_sp, - i_pop_bp, - i_pop_si, - i_pop_di, - i_pusha, - i_popa, - i_chkind, - i_brkn, - i_repnc, - i_repc, - i_invalid, - i_push_d16, - i_imul_d16, - i_push_d8, - i_imul_d8, - i_insb, - i_insw, - i_outsb, - i_outsw, - i_jo, - i_jno, - i_jc, - i_jnc, - i_jz, - i_jnz, - i_jce, - i_jnce, - i_js, - i_jns, - i_jp, - i_jnp, - i_jl, - i_jnl, - i_jle, - i_jnle, - i_80pre, - i_81pre, - i_82pre, - i_83pre, - i_test_br8, - i_test_wr16, - i_xchg_br8, - i_xchg_wr16, - i_mov_br8, - i_mov_wr16, - i_mov_r8b, - i_mov_r16w, - i_mov_wsreg, - i_lea, - i_mov_sregw, - i_popw, - i_nop, - i_xchg_axcx, - i_xchg_axdx, - i_xchg_axbx, - i_xchg_axsp, - i_xchg_axbp, - i_xchg_axsi, - i_xchg_axdi, - i_cbw, - i_cwd, - i_call_far, - i_wait, - i_pushf, - i_popf, - i_sahf, - i_lahf, - i_mov_aldisp, - i_mov_axdisp, - i_mov_dispal, - i_mov_dispax, - i_movsb, - i_movsw, - i_cmpsb, - i_cmpsw, - i_test_ald8, - i_test_axd16, - i_stosb, - i_stosw, - i_lodsb, - i_lodsw, - i_scasb, - i_scasw, - i_mov_ald8, - i_mov_cld8, - i_mov_dld8, - i_mov_bld8, - i_mov_ahd8, - i_mov_chd8, - i_mov_dhd8, - i_mov_bhd8, - i_mov_axd16, - i_mov_cxd16, - i_mov_dxd16, - i_mov_bxd16, - i_mov_spd16, - i_mov_bpd16, - i_mov_sid16, - i_mov_did16, - i_rotshft_bd8, - i_rotshft_wd8, - i_ret_d16, - i_ret, - i_les_dw, - i_lds_dw, - i_mov_bd8, - i_mov_wd16, - i_enter, - i_leave, - i_retf_d16, - i_retf, - i_int3, - i_int, - i_into, - i_iret, - i_rotshft_b, - i_rotshft_w, - i_rotshft_bcl, - i_rotshft_wcl, - i_aam, - i_aad, - i_setalc, - i_trans, - i_fpo, - i_loopne, - i_loope, - i_loop, - i_jcxz, - i_inal, - i_inax, - i_outal, - i_outax, - i_call_d16, - i_jmp_d16, - i_jmp_far, - i_jmp_d8, - i_inaldx, - i_inaxdx, - i_outdxal, - i_outdxax, - i_lock, - i_repne, - i_repe, - i_hlt, - i_cmc, - i_f6pre, - i_f7pre, - i_clc, - i_stc, - i_di, - i_ei, - i_cld, - i_std, - i_fepre, - i_ffpre - } - - - static readonly NecInstructionOpCode[] NecInstructionOpCodeArr = new NecInstructionOpCode[] - { - NecInstructionOpCode.i_add_br8, - NecInstructionOpCode.i_add_wr16, - NecInstructionOpCode.i_add_r8b, - NecInstructionOpCode.i_add_r16w, - NecInstructionOpCode.i_add_ald8, - NecInstructionOpCode.i_add_axd16, - NecInstructionOpCode.i_push_es, - NecInstructionOpCode.i_pop_es, - NecInstructionOpCode.i_or_br8, - NecInstructionOpCode.i_or_wr16, - NecInstructionOpCode.i_or_r8b, - NecInstructionOpCode.i_or_r16w, - NecInstructionOpCode.i_or_ald8, - NecInstructionOpCode.i_or_axd16, - NecInstructionOpCode.i_push_cs, - NecInstructionOpCode.i_pre_nec, - NecInstructionOpCode.i_adc_br8, - NecInstructionOpCode.i_adc_wr16, - NecInstructionOpCode.i_adc_r8b, - NecInstructionOpCode.i_adc_r16w, - NecInstructionOpCode.i_adc_ald8, - NecInstructionOpCode.i_adc_axd16, - NecInstructionOpCode.i_push_ss, - NecInstructionOpCode.i_pop_ss, - NecInstructionOpCode.i_sbb_br8, - NecInstructionOpCode.i_sbb_wr16, - NecInstructionOpCode.i_sbb_r8b, - NecInstructionOpCode.i_sbb_r16w, - NecInstructionOpCode.i_sbb_ald8, - NecInstructionOpCode.i_sbb_axd16, - NecInstructionOpCode.i_push_ds, - NecInstructionOpCode.i_pop_ds, - NecInstructionOpCode.i_and_br8, - NecInstructionOpCode.i_and_wr16, - NecInstructionOpCode.i_and_r8b, - NecInstructionOpCode.i_and_r16w, - NecInstructionOpCode.i_and_ald8, - NecInstructionOpCode.i_and_axd16, - NecInstructionOpCode.i_es, - NecInstructionOpCode.i_daa, - NecInstructionOpCode.i_sub_br8, - NecInstructionOpCode.i_sub_wr16, - NecInstructionOpCode.i_sub_r8b, - NecInstructionOpCode.i_sub_r16w, - NecInstructionOpCode.i_sub_ald8, - NecInstructionOpCode.i_sub_axd16, - NecInstructionOpCode.i_cs, - NecInstructionOpCode.i_das, - NecInstructionOpCode.i_xor_br8, - NecInstructionOpCode.i_xor_wr16, - NecInstructionOpCode.i_xor_r8b, - NecInstructionOpCode.i_xor_r16w, - NecInstructionOpCode.i_xor_ald8, - NecInstructionOpCode.i_xor_axd16, - NecInstructionOpCode.i_ss, - NecInstructionOpCode.i_aaa, - NecInstructionOpCode.i_cmp_br8, - NecInstructionOpCode.i_cmp_wr16, - NecInstructionOpCode.i_cmp_r8b, - NecInstructionOpCode.i_cmp_r16w, - NecInstructionOpCode.i_cmp_ald8, - NecInstructionOpCode.i_cmp_axd16, - NecInstructionOpCode.i_ds, - NecInstructionOpCode.i_aas, - NecInstructionOpCode.i_inc_ax, - NecInstructionOpCode.i_inc_cx, - NecInstructionOpCode.i_inc_dx, - NecInstructionOpCode.i_inc_bx, - NecInstructionOpCode.i_inc_sp, - NecInstructionOpCode.i_inc_bp, - NecInstructionOpCode.i_inc_si, - NecInstructionOpCode.i_inc_di, - NecInstructionOpCode.i_dec_ax, - NecInstructionOpCode.i_dec_cx, - NecInstructionOpCode.i_dec_dx, - NecInstructionOpCode.i_dec_bx, - NecInstructionOpCode.i_dec_sp, - NecInstructionOpCode.i_dec_bp, - NecInstructionOpCode.i_dec_si, - NecInstructionOpCode.i_dec_di, - NecInstructionOpCode.i_push_ax, - NecInstructionOpCode.i_push_cx, - NecInstructionOpCode.i_push_dx, - NecInstructionOpCode.i_push_bx, - NecInstructionOpCode.i_push_sp, - NecInstructionOpCode.i_push_bp, - NecInstructionOpCode.i_push_si, - NecInstructionOpCode.i_push_di, - NecInstructionOpCode.i_pop_ax, - NecInstructionOpCode.i_pop_cx, - NecInstructionOpCode.i_pop_dx, - NecInstructionOpCode.i_pop_bx, - NecInstructionOpCode.i_pop_sp, - NecInstructionOpCode.i_pop_bp, - NecInstructionOpCode.i_pop_si, - NecInstructionOpCode.i_pop_di, - NecInstructionOpCode.i_pusha, - NecInstructionOpCode.i_popa, - NecInstructionOpCode.i_chkind, - NecInstructionOpCode.i_brkn, - NecInstructionOpCode.i_repnc, - NecInstructionOpCode.i_repc, - NecInstructionOpCode.i_invalid, - NecInstructionOpCode.i_invalid, - NecInstructionOpCode.i_push_d16, - NecInstructionOpCode.i_imul_d16, - NecInstructionOpCode.i_push_d8, - NecInstructionOpCode.i_imul_d8, - NecInstructionOpCode.i_insb, - NecInstructionOpCode.i_insw, - NecInstructionOpCode.i_outsb, - NecInstructionOpCode.i_outsw, - NecInstructionOpCode.i_jo, - NecInstructionOpCode.i_jno, - NecInstructionOpCode.i_jc, - NecInstructionOpCode.i_jnc, - NecInstructionOpCode.i_jz, - NecInstructionOpCode.i_jnz, - NecInstructionOpCode.i_jce, - NecInstructionOpCode.i_jnce, - NecInstructionOpCode.i_js, - NecInstructionOpCode.i_jns, - NecInstructionOpCode.i_jp, - NecInstructionOpCode.i_jnp, - NecInstructionOpCode.i_jl, - NecInstructionOpCode.i_jnl, - NecInstructionOpCode.i_jle, - NecInstructionOpCode.i_jnle, - NecInstructionOpCode.i_80pre, - NecInstructionOpCode.i_81pre, - NecInstructionOpCode.i_82pre, - NecInstructionOpCode.i_83pre, - NecInstructionOpCode.i_test_br8, - NecInstructionOpCode.i_test_wr16, - NecInstructionOpCode.i_xchg_br8, - NecInstructionOpCode.i_xchg_wr16, - NecInstructionOpCode.i_mov_br8, - NecInstructionOpCode.i_mov_wr16, - NecInstructionOpCode.i_mov_r8b, - NecInstructionOpCode.i_mov_r16w, - NecInstructionOpCode.i_mov_wsreg, - NecInstructionOpCode.i_lea, - NecInstructionOpCode.i_mov_sregw, - NecInstructionOpCode.i_popw, - NecInstructionOpCode.i_nop, - NecInstructionOpCode.i_xchg_axcx, - NecInstructionOpCode.i_xchg_axdx, - NecInstructionOpCode.i_xchg_axbx, - NecInstructionOpCode.i_xchg_axsp, - NecInstructionOpCode.i_xchg_axbp, - NecInstructionOpCode.i_xchg_axsi, - NecInstructionOpCode.i_xchg_axdi, - NecInstructionOpCode.i_cbw, - NecInstructionOpCode.i_cwd, - NecInstructionOpCode.i_call_far, - NecInstructionOpCode.i_wait, - NecInstructionOpCode.i_pushf, - NecInstructionOpCode.i_popf, - NecInstructionOpCode.i_sahf, - NecInstructionOpCode.i_lahf, - NecInstructionOpCode.i_mov_aldisp, - NecInstructionOpCode.i_mov_axdisp, - NecInstructionOpCode.i_mov_dispal, - NecInstructionOpCode.i_mov_dispax, - NecInstructionOpCode.i_movsb, - NecInstructionOpCode.i_movsw, - NecInstructionOpCode.i_cmpsb, - NecInstructionOpCode.i_cmpsw, - NecInstructionOpCode.i_test_ald8, - NecInstructionOpCode.i_test_axd16, - NecInstructionOpCode.i_stosb, - NecInstructionOpCode.i_stosw, - NecInstructionOpCode.i_lodsb, - NecInstructionOpCode.i_lodsw, - NecInstructionOpCode.i_scasb, - NecInstructionOpCode.i_scasw, - NecInstructionOpCode.i_mov_ald8, - NecInstructionOpCode.i_mov_cld8, - NecInstructionOpCode.i_mov_dld8, - NecInstructionOpCode.i_mov_bld8, - NecInstructionOpCode.i_mov_ahd8, - NecInstructionOpCode.i_mov_chd8, - NecInstructionOpCode.i_mov_dhd8, - NecInstructionOpCode.i_mov_bhd8, - NecInstructionOpCode.i_mov_axd16, - NecInstructionOpCode.i_mov_cxd16, - NecInstructionOpCode.i_mov_dxd16, - NecInstructionOpCode.i_mov_bxd16, - NecInstructionOpCode.i_mov_spd16, - NecInstructionOpCode.i_mov_bpd16, - NecInstructionOpCode.i_mov_sid16, - NecInstructionOpCode.i_mov_did16, - NecInstructionOpCode.i_rotshft_bd8, - NecInstructionOpCode.i_rotshft_wd8, - NecInstructionOpCode.i_ret_d16, - NecInstructionOpCode.i_ret, - NecInstructionOpCode.i_les_dw, - NecInstructionOpCode.i_lds_dw, - NecInstructionOpCode.i_mov_bd8, - NecInstructionOpCode.i_mov_wd16, - NecInstructionOpCode.i_enter, - NecInstructionOpCode.i_leave, - NecInstructionOpCode.i_retf_d16, - NecInstructionOpCode.i_retf, - NecInstructionOpCode.i_int3, - NecInstructionOpCode.i_int, - NecInstructionOpCode.i_into, - NecInstructionOpCode.i_iret, - NecInstructionOpCode.i_rotshft_b, - NecInstructionOpCode.i_rotshft_w, - NecInstructionOpCode.i_rotshft_bcl, - NecInstructionOpCode.i_rotshft_wcl, - NecInstructionOpCode.i_aam, - NecInstructionOpCode.i_aad, - NecInstructionOpCode.i_setalc, - NecInstructionOpCode.i_trans, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_fpo, - NecInstructionOpCode.i_loopne, - NecInstructionOpCode.i_loope, - NecInstructionOpCode.i_loop, - NecInstructionOpCode.i_jcxz, - NecInstructionOpCode.i_inal, - NecInstructionOpCode.i_inax, - NecInstructionOpCode.i_outal, - NecInstructionOpCode.i_outax, - NecInstructionOpCode.i_call_d16, - NecInstructionOpCode.i_jmp_d16, - NecInstructionOpCode.i_jmp_far, - NecInstructionOpCode.i_jmp_d8, - NecInstructionOpCode.i_inaldx, - NecInstructionOpCode.i_inaxdx, - NecInstructionOpCode.i_outdxal, - NecInstructionOpCode.i_outdxax, - NecInstructionOpCode.i_lock, - NecInstructionOpCode.i_invalid, - NecInstructionOpCode.i_repne, - NecInstructionOpCode.i_repe, - NecInstructionOpCode.i_hlt, - NecInstructionOpCode.i_cmc, - NecInstructionOpCode.i_f6pre, - NecInstructionOpCode.i_f7pre, - NecInstructionOpCode.i_clc, - NecInstructionOpCode.i_stc, - NecInstructionOpCode.i_di, - NecInstructionOpCode.i_ei, - NecInstructionOpCode.i_cld, - NecInstructionOpCode.i_std, - NecInstructionOpCode.i_fepre, - NecInstructionOpCode.i_ffpre - }; + ///// + ///// 自定义Nec指令集枚举 + ///// + //public enum NecInstructionOpCode : byte + //{ + // i_add_br8, + // i_add_wr16, + // i_add_r8b, + // i_add_r16w, + // i_add_ald8, + // i_add_axd16, + // i_push_es, + // i_pop_es, + // i_or_br8, + // i_or_wr16, + // i_or_r8b, + // i_or_r16w, + // i_or_ald8, + // i_or_axd16, + // i_push_cs, + // i_pre_nec, + // i_adc_br8, + // i_adc_wr16, + // i_adc_r8b, + // i_adc_r16w, + // i_adc_ald8, + // i_adc_axd16, + // i_push_ss, + // i_pop_ss, + // i_sbb_br8, + // i_sbb_wr16, + // i_sbb_r8b, + // i_sbb_r16w, + // i_sbb_ald8, + // i_sbb_axd16, + // i_push_ds, + // i_pop_ds, + // i_and_br8, + // i_and_wr16, + // i_and_r8b, + // i_and_r16w, + // i_and_ald8, + // i_and_axd16, + // i_es, + // i_daa, + // i_sub_br8, + // i_sub_wr16, + // i_sub_r8b, + // i_sub_r16w, + // i_sub_ald8, + // i_sub_axd16, + // i_cs, + // i_das, + // i_xor_br8, + // i_xor_wr16, + // i_xor_r8b, + // i_xor_r16w, + // i_xor_ald8, + // i_xor_axd16, + // i_ss, + // i_aaa, + // i_cmp_br8, + // i_cmp_wr16, + // i_cmp_r8b, + // i_cmp_r16w, + // i_cmp_ald8, + // i_cmp_axd16, + // i_ds, + // i_aas, + // i_inc_ax, + // i_inc_cx, + // i_inc_dx, + // i_inc_bx, + // i_inc_sp, + // i_inc_bp, + // i_inc_si, + // i_inc_di, + // i_dec_ax, + // i_dec_cx, + // i_dec_dx, + // i_dec_bx, + // i_dec_sp, + // i_dec_bp, + // i_dec_si, + // i_dec_di, + // i_push_ax, + // i_push_cx, + // i_push_dx, + // i_push_bx, + // i_push_sp, + // i_push_bp, + // i_push_si, + // i_push_di, + // i_pop_ax, + // i_pop_cx, + // i_pop_dx, + // i_pop_bx, + // i_pop_sp, + // i_pop_bp, + // i_pop_si, + // i_pop_di, + // i_pusha, + // i_popa, + // i_chkind, + // i_brkn, + // i_repnc, + // i_repc, + // i_invalid, + // i_push_d16, + // i_imul_d16, + // i_push_d8, + // i_imul_d8, + // i_insb, + // i_insw, + // i_outsb, + // i_outsw, + // i_jo, + // i_jno, + // i_jc, + // i_jnc, + // i_jz, + // i_jnz, + // i_jce, + // i_jnce, + // i_js, + // i_jns, + // i_jp, + // i_jnp, + // i_jl, + // i_jnl, + // i_jle, + // i_jnle, + // i_80pre, + // i_81pre, + // i_82pre, + // i_83pre, + // i_test_br8, + // i_test_wr16, + // i_xchg_br8, + // i_xchg_wr16, + // i_mov_br8, + // i_mov_wr16, + // i_mov_r8b, + // i_mov_r16w, + // i_mov_wsreg, + // i_lea, + // i_mov_sregw, + // i_popw, + // i_nop, + // i_xchg_axcx, + // i_xchg_axdx, + // i_xchg_axbx, + // i_xchg_axsp, + // i_xchg_axbp, + // i_xchg_axsi, + // i_xchg_axdi, + // i_cbw, + // i_cwd, + // i_call_far, + // i_wait, + // i_pushf, + // i_popf, + // i_sahf, + // i_lahf, + // i_mov_aldisp, + // i_mov_axdisp, + // i_mov_dispal, + // i_mov_dispax, + // i_movsb, + // i_movsw, + // i_cmpsb, + // i_cmpsw, + // i_test_ald8, + // i_test_axd16, + // i_stosb, + // i_stosw, + // i_lodsb, + // i_lodsw, + // i_scasb, + // i_scasw, + // i_mov_ald8, + // i_mov_cld8, + // i_mov_dld8, + // i_mov_bld8, + // i_mov_ahd8, + // i_mov_chd8, + // i_mov_dhd8, + // i_mov_bhd8, + // i_mov_axd16, + // i_mov_cxd16, + // i_mov_dxd16, + // i_mov_bxd16, + // i_mov_spd16, + // i_mov_bpd16, + // i_mov_sid16, + // i_mov_did16, + // i_rotshft_bd8, + // i_rotshft_wd8, + // i_ret_d16, + // i_ret, + // i_les_dw, + // i_lds_dw, + // i_mov_bd8, + // i_mov_wd16, + // i_enter, + // i_leave, + // i_retf_d16, + // i_retf, + // i_int3, + // i_int, + // i_into, + // i_iret, + // i_rotshft_b, + // i_rotshft_w, + // i_rotshft_bcl, + // i_rotshft_wcl, + // i_aam, + // i_aad, + // i_setalc, + // i_trans, + // i_fpo, + // i_loopne, + // i_loope, + // i_loop, + // i_jcxz, + // i_inal, + // i_inax, + // i_outal, + // i_outax, + // i_call_d16, + // i_jmp_d16, + // i_jmp_far, + // i_jmp_d8, + // i_inaldx, + // i_inaxdx, + // i_outdxal, + // i_outdxax, + // i_lock, + // i_repne, + // i_repe, + // i_hlt, + // i_cmc, + // i_f6pre, + // i_f7pre, + // i_clc, + // i_stc, + // i_di, + // i_ei, + // i_cld, + // i_std, + // i_fepre, + // i_ffpre + //} + //static readonly NecInstructionOpCode[] NecInstructionOpCodeArr = new NecInstructionOpCode[] + // { + // NecInstructionOpCode.i_add_br8, + // NecInstructionOpCode.i_add_wr16, + // NecInstructionOpCode.i_add_r8b, + // NecInstructionOpCode.i_add_r16w, + // NecInstructionOpCode.i_add_ald8, + // NecInstructionOpCode.i_add_axd16, + // NecInstructionOpCode.i_push_es, + // NecInstructionOpCode.i_pop_es, + // NecInstructionOpCode.i_or_br8, + // NecInstructionOpCode.i_or_wr16, + // NecInstructionOpCode.i_or_r8b, + // NecInstructionOpCode.i_or_r16w, + // NecInstructionOpCode.i_or_ald8, + // NecInstructionOpCode.i_or_axd16, + // NecInstructionOpCode.i_push_cs, + // NecInstructionOpCode.i_pre_nec, + // NecInstructionOpCode.i_adc_br8, + // NecInstructionOpCode.i_adc_wr16, + // NecInstructionOpCode.i_adc_r8b, + // NecInstructionOpCode.i_adc_r16w, + // NecInstructionOpCode.i_adc_ald8, + // NecInstructionOpCode.i_adc_axd16, + // NecInstructionOpCode.i_push_ss, + // NecInstructionOpCode.i_pop_ss, + // NecInstructionOpCode.i_sbb_br8, + // NecInstructionOpCode.i_sbb_wr16, + // NecInstructionOpCode.i_sbb_r8b, + // NecInstructionOpCode.i_sbb_r16w, + // NecInstructionOpCode.i_sbb_ald8, + // NecInstructionOpCode.i_sbb_axd16, + // NecInstructionOpCode.i_push_ds, + // NecInstructionOpCode.i_pop_ds, + // NecInstructionOpCode.i_and_br8, + // NecInstructionOpCode.i_and_wr16, + // NecInstructionOpCode.i_and_r8b, + // NecInstructionOpCode.i_and_r16w, + // NecInstructionOpCode.i_and_ald8, + // NecInstructionOpCode.i_and_axd16, + // NecInstructionOpCode.i_es, + // NecInstructionOpCode.i_daa, + // NecInstructionOpCode.i_sub_br8, + // NecInstructionOpCode.i_sub_wr16, + // NecInstructionOpCode.i_sub_r8b, + // NecInstructionOpCode.i_sub_r16w, + // NecInstructionOpCode.i_sub_ald8, + // NecInstructionOpCode.i_sub_axd16, + // NecInstructionOpCode.i_cs, + // NecInstructionOpCode.i_das, + // NecInstructionOpCode.i_xor_br8, + // NecInstructionOpCode.i_xor_wr16, + // NecInstructionOpCode.i_xor_r8b, + // NecInstructionOpCode.i_xor_r16w, + // NecInstructionOpCode.i_xor_ald8, + // NecInstructionOpCode.i_xor_axd16, + // NecInstructionOpCode.i_ss, + // NecInstructionOpCode.i_aaa, + // NecInstructionOpCode.i_cmp_br8, + // NecInstructionOpCode.i_cmp_wr16, + // NecInstructionOpCode.i_cmp_r8b, + // NecInstructionOpCode.i_cmp_r16w, + // NecInstructionOpCode.i_cmp_ald8, + // NecInstructionOpCode.i_cmp_axd16, + // NecInstructionOpCode.i_ds, + // NecInstructionOpCode.i_aas, + // NecInstructionOpCode.i_inc_ax, + // NecInstructionOpCode.i_inc_cx, + // NecInstructionOpCode.i_inc_dx, + // NecInstructionOpCode.i_inc_bx, + // NecInstructionOpCode.i_inc_sp, + // NecInstructionOpCode.i_inc_bp, + // NecInstructionOpCode.i_inc_si, + // NecInstructionOpCode.i_inc_di, + // NecInstructionOpCode.i_dec_ax, + // NecInstructionOpCode.i_dec_cx, + // NecInstructionOpCode.i_dec_dx, + // NecInstructionOpCode.i_dec_bx, + // NecInstructionOpCode.i_dec_sp, + // NecInstructionOpCode.i_dec_bp, + // NecInstructionOpCode.i_dec_si, + // NecInstructionOpCode.i_dec_di, + // NecInstructionOpCode.i_push_ax, + // NecInstructionOpCode.i_push_cx, + // NecInstructionOpCode.i_push_dx, + // NecInstructionOpCode.i_push_bx, + // NecInstructionOpCode.i_push_sp, + // NecInstructionOpCode.i_push_bp, + // NecInstructionOpCode.i_push_si, + // NecInstructionOpCode.i_push_di, + // NecInstructionOpCode.i_pop_ax, + // NecInstructionOpCode.i_pop_cx, + // NecInstructionOpCode.i_pop_dx, + // NecInstructionOpCode.i_pop_bx, + // NecInstructionOpCode.i_pop_sp, + // NecInstructionOpCode.i_pop_bp, + // NecInstructionOpCode.i_pop_si, + // NecInstructionOpCode.i_pop_di, + // NecInstructionOpCode.i_pusha, + // NecInstructionOpCode.i_popa, + // NecInstructionOpCode.i_chkind, + // NecInstructionOpCode.i_brkn, + // NecInstructionOpCode.i_repnc, + // NecInstructionOpCode.i_repc, + // NecInstructionOpCode.i_invalid, + // NecInstructionOpCode.i_invalid, + // NecInstructionOpCode.i_push_d16, + // NecInstructionOpCode.i_imul_d16, + // NecInstructionOpCode.i_push_d8, + // NecInstructionOpCode.i_imul_d8, + // NecInstructionOpCode.i_insb, + // NecInstructionOpCode.i_insw, + // NecInstructionOpCode.i_outsb, + // NecInstructionOpCode.i_outsw, + // NecInstructionOpCode.i_jo, + // NecInstructionOpCode.i_jno, + // NecInstructionOpCode.i_jc, + // NecInstructionOpCode.i_jnc, + // NecInstructionOpCode.i_jz, + // NecInstructionOpCode.i_jnz, + // NecInstructionOpCode.i_jce, + // NecInstructionOpCode.i_jnce, + // NecInstructionOpCode.i_js, + // NecInstructionOpCode.i_jns, + // NecInstructionOpCode.i_jp, + // NecInstructionOpCode.i_jnp, + // NecInstructionOpCode.i_jl, + // NecInstructionOpCode.i_jnl, + // NecInstructionOpCode.i_jle, + // NecInstructionOpCode.i_jnle, + // NecInstructionOpCode.i_80pre, + // NecInstructionOpCode.i_81pre, + // NecInstructionOpCode.i_82pre, + // NecInstructionOpCode.i_83pre, + // NecInstructionOpCode.i_test_br8, + // NecInstructionOpCode.i_test_wr16, + // NecInstructionOpCode.i_xchg_br8, + // NecInstructionOpCode.i_xchg_wr16, + // NecInstructionOpCode.i_mov_br8, + // NecInstructionOpCode.i_mov_wr16, + // NecInstructionOpCode.i_mov_r8b, + // NecInstructionOpCode.i_mov_r16w, + // NecInstructionOpCode.i_mov_wsreg, + // NecInstructionOpCode.i_lea, + // NecInstructionOpCode.i_mov_sregw, + // NecInstructionOpCode.i_popw, + // NecInstructionOpCode.i_nop, + // NecInstructionOpCode.i_xchg_axcx, + // NecInstructionOpCode.i_xchg_axdx, + // NecInstructionOpCode.i_xchg_axbx, + // NecInstructionOpCode.i_xchg_axsp, + // NecInstructionOpCode.i_xchg_axbp, + // NecInstructionOpCode.i_xchg_axsi, + // NecInstructionOpCode.i_xchg_axdi, + // NecInstructionOpCode.i_cbw, + // NecInstructionOpCode.i_cwd, + // NecInstructionOpCode.i_call_far, + // NecInstructionOpCode.i_wait, + // NecInstructionOpCode.i_pushf, + // NecInstructionOpCode.i_popf, + // NecInstructionOpCode.i_sahf, + // NecInstructionOpCode.i_lahf, + // NecInstructionOpCode.i_mov_aldisp, + // NecInstructionOpCode.i_mov_axdisp, + // NecInstructionOpCode.i_mov_dispal, + // NecInstructionOpCode.i_mov_dispax, + // NecInstructionOpCode.i_movsb, + // NecInstructionOpCode.i_movsw, + // NecInstructionOpCode.i_cmpsb, + // NecInstructionOpCode.i_cmpsw, + // NecInstructionOpCode.i_test_ald8, + // NecInstructionOpCode.i_test_axd16, + // NecInstructionOpCode.i_stosb, + // NecInstructionOpCode.i_stosw, + // NecInstructionOpCode.i_lodsb, + // NecInstructionOpCode.i_lodsw, + // NecInstructionOpCode.i_scasb, + // NecInstructionOpCode.i_scasw, + // NecInstructionOpCode.i_mov_ald8, + // NecInstructionOpCode.i_mov_cld8, + // NecInstructionOpCode.i_mov_dld8, + // NecInstructionOpCode.i_mov_bld8, + // NecInstructionOpCode.i_mov_ahd8, + // NecInstructionOpCode.i_mov_chd8, + // NecInstructionOpCode.i_mov_dhd8, + // NecInstructionOpCode.i_mov_bhd8, + // NecInstructionOpCode.i_mov_axd16, + // NecInstructionOpCode.i_mov_cxd16, + // NecInstructionOpCode.i_mov_dxd16, + // NecInstructionOpCode.i_mov_bxd16, + // NecInstructionOpCode.i_mov_spd16, + // NecInstructionOpCode.i_mov_bpd16, + // NecInstructionOpCode.i_mov_sid16, + // NecInstructionOpCode.i_mov_did16, + // NecInstructionOpCode.i_rotshft_bd8, + // NecInstructionOpCode.i_rotshft_wd8, + // NecInstructionOpCode.i_ret_d16, + // NecInstructionOpCode.i_ret, + // NecInstructionOpCode.i_les_dw, + // NecInstructionOpCode.i_lds_dw, + // NecInstructionOpCode.i_mov_bd8, + // NecInstructionOpCode.i_mov_wd16, + // NecInstructionOpCode.i_enter, + // NecInstructionOpCode.i_leave, + // NecInstructionOpCode.i_retf_d16, + // NecInstructionOpCode.i_retf, + // NecInstructionOpCode.i_int3, + // NecInstructionOpCode.i_int, + // NecInstructionOpCode.i_into, + // NecInstructionOpCode.i_iret, + // NecInstructionOpCode.i_rotshft_b, + // NecInstructionOpCode.i_rotshft_w, + // NecInstructionOpCode.i_rotshft_bcl, + // NecInstructionOpCode.i_rotshft_wcl, + // NecInstructionOpCode.i_aam, + // NecInstructionOpCode.i_aad, + // NecInstructionOpCode.i_setalc, + // NecInstructionOpCode.i_trans, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_fpo, + // NecInstructionOpCode.i_loopne, + // NecInstructionOpCode.i_loope, + // NecInstructionOpCode.i_loop, + // NecInstructionOpCode.i_jcxz, + // NecInstructionOpCode.i_inal, + // NecInstructionOpCode.i_inax, + // NecInstructionOpCode.i_outal, + // NecInstructionOpCode.i_outax, + // NecInstructionOpCode.i_call_d16, + // NecInstructionOpCode.i_jmp_d16, + // NecInstructionOpCode.i_jmp_far, + // NecInstructionOpCode.i_jmp_d8, + // NecInstructionOpCode.i_inaldx, + // NecInstructionOpCode.i_inaxdx, + // NecInstructionOpCode.i_outdxal, + // NecInstructionOpCode.i_outdxax, + // NecInstructionOpCode.i_lock, + // NecInstructionOpCode.i_invalid, + // NecInstructionOpCode.i_repne, + // NecInstructionOpCode.i_repe, + // NecInstructionOpCode.i_hlt, + // NecInstructionOpCode.i_cmc, + // NecInstructionOpCode.i_f6pre, + // NecInstructionOpCode.i_f7pre, + // NecInstructionOpCode.i_clc, + // NecInstructionOpCode.i_stc, + // NecInstructionOpCode.i_di, + // NecInstructionOpCode.i_ei, + // NecInstructionOpCode.i_cld, + // NecInstructionOpCode.i_std, + // NecInstructionOpCode.i_fepre, + // NecInstructionOpCode.i_ffpre + // }; } } \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs index 3a81bbf3..9fcb9402 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/EmuTimer.cs @@ -125,18 +125,19 @@ namespace MAME.Core period = default; start = default; expire = default; - _refCount = 1; + _refCount = 0; } - static HashSet _readyToRelease = new HashSet(); + static Queue _readyToRelease = new Queue(); /// /// 线程安全队列(因为析构函数是额外线程来的) /// - static ConcurrentQueue _failedDeletions = new ConcurrentQueue(); + static Queue _failedDeletions = new Queue(); + static HashSet _tempCheck = new HashSet(); static int outTimerAllCount = 0; static int newTimerCount = 0; - public static emu_timer GetEmu_timer() + public static emu_timer GetEmu_timerNoRef() { emu_timer obj; if (!_failedDeletions.TryDequeue(out obj)) @@ -144,38 +145,36 @@ namespace MAME.Core obj = new emu_timer(); newTimerCount++; } + //这里引用计数为0,直接放入带Ready里,等待下一帧检测 obj.reset(); + _readyToRelease.Enqueue(obj); outTimerAllCount++; return obj; } - /// - /// 释放创建的引用,这个要和GetEmu_timer成对 - /// - /// - public static void ReleaseCreateRef(emu_timer obj) - { - obj.ReleaseRef(); - } - public static void CheckReadyRelaseAfterRun() + public static void CheckReadyRelaseBeforeFrameRun() { if (_readyToRelease.Count < 1) return; - + int checkcount = _readyToRelease.Count; int beforpoolcount = _failedDeletions.Count; int releaseCount = 0; - foreach (var ready in _readyToRelease) + while(_readyToRelease.TryDequeue(out emu_timer ready)) { + if (_tempCheck.Contains(ready)) + continue; + _tempCheck.Add(ready); if (ready._refCount <= 0) { ready.ReturnToPool(); releaseCount++; } } - //UnityEngine.Debug.Log($"CheckReadyRelaseAfterRun 出池数量{outTimerAllCount},其中new创建的数量{newTimerCount} 回收数量{releaseCount} ,处理前池数量{beforpoolcount},处理后池数量{_failedDeletions.Count}"); + //UnityEngine.Debug.Log($"CheckReadyRelaseAfterRun 检查数量{checkcount}| 出池数量{outTimerAllCount},其中new创建的数量{newTimerCount} 回收数量{releaseCount} ,处理前池数量{beforpoolcount},处理后池数量{_failedDeletions.Count}"); outTimerAllCount = 0; newTimerCount = 0; _readyToRelease.Clear(); + _tempCheck.Clear(); } // 引用计数字段(线程安全) @@ -188,15 +187,16 @@ namespace MAME.Core { int newCount = Interlocked.Increment(ref _refCount); - //引用计数重新回到1时,移除。 - //但是还是不在这里做把注释了,在每一帧开始之前统一检测 + ////引用计数重新回到1时,移除。 + ////但是还是不在这里做把注释了,在每一帧开始之前统一检测 //if (newCount == 1) //{ - // if (_readyToRelease.Contains(this)) - // { - // //UnityEngine.Debug.Log("移除ReadyToRelease"); - // _readyToRelease.Remove(this); - // } + // UnityEngine.Debug.Log("CheckReadyRelaseAfterRun AddRef 复活"); + // //if (_readyToRelease.Contains(this)) + // //{ + // // //UnityEngine.Debug.Log("移除ReadyToRelease"); + // // _readyToRelease.Remove(this); + // //} //} } @@ -208,6 +208,7 @@ namespace MAME.Core int newCount = Interlocked.Decrement(ref _refCount); if (newCount == 0) { + //UnityEngine.Debug.Log("CheckReadyRelaseAfterRun ReleaseRef 预回收"); // 引用计数为0,释放资源并回池 ReadyToRelease(); } @@ -221,8 +222,7 @@ namespace MAME.Core void ReadyToRelease() { //UnityEngine.Debug.Log("ReadyToRelease"); - if(!_readyToRelease.Contains(this)) - _readyToRelease.Add(this); + _readyToRelease.Enqueue(this); } /// @@ -230,7 +230,6 @@ namespace MAME.Core /// void ReturnToPool() { - reset(); _failedDeletions.Enqueue(this); } @@ -699,14 +698,14 @@ namespace MAME.Core } return global_basetime; } - public static void timer_remove(emu_timer timer1) + /*public static void timer_remove(emu_timer timer1) { if (timer1 == callback_timer) { callback_timer_modified = true; } timer_list_remove(timer1); - } + }*/ public static void timer_adjust_periodic(emu_timer which, Atime start_delay, Atime period) { Atime time = get_current_time(); @@ -722,8 +721,11 @@ namespace MAME.Core which.start = time; which.expire = Attotime.attotime_add(time, start_delay); which.period = period; - timer_list_remove(which); - timer_list_insert(which); + + timer_list_remove_and_insert(which); + //timer_list_remove(which); + //timer_list_insert(which); + //if (lt.IndexOf(which) == 0) if (lt[0] == which) { @@ -745,7 +747,20 @@ namespace MAME.Core emu_timer timer = timer_alloc_common_NoRef(action, true); timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER); } - public static void timer_list_insert(emu_timer timer1) + + static void timer_list_remove_and_insert(emu_timer timer) + { + //包一层引用避免引用计数中间丢失,进等待检测队列(减少这样的情况) + { + emu_timer tempref = null; + emu_timer.SetRefUsed(ref tempref, ref timer); + timer_list_remove(timer); + timer_list_insert(timer); + emu_timer.SetNull(ref tempref); + } + } + + static void timer_list_insert(emu_timer timer1) { int i; int i1 = -1; @@ -885,8 +900,10 @@ namespace MAME.Core { timer.start = timer.expire; timer.expire = Attotime.attotime_add(timer.expire, timer.period); - timer_list_remove(timer); - timer_list_insert(timer); + + timer_list_remove_and_insert(timer); + //timer_list_remove(timer); + //timer_list_insert(timer); } } } @@ -939,7 +956,7 @@ namespace MAME.Core { Atime time = get_current_time(); //创建一个timer - emu_timer timer = emu_timer.GetEmu_timer(); + emu_timer timer = emu_timer.GetEmu_timerNoRef(); timer.action = action; timer.enabled = false; timer.temporary = temp; @@ -948,8 +965,6 @@ namespace MAME.Core timer.start = time; timer.expire = Attotime.ATTOTIME_NEVER; timer_list_insert(timer); - //断开创建的引用计数 - emu_timer.ReleaseCreateRef(timer); return timer; } @@ -958,8 +973,11 @@ namespace MAME.Core bool old; old = which.enabled; which.enabled = enable; - timer_list_remove(which); - timer_list_insert(which); + + timer_list_remove_and_insert(which); + //timer_list_remove(which); + //timer_list_insert(which); + return old; } public static bool timer_enabled(emu_timer which) @@ -1009,7 +1027,7 @@ namespace MAME.Core EmuTimerLister.GetNewTimerLister(ref lt); for (i = 0; i < n; i++) { - emu_timer etimer = emu_timer.GetEmu_timer(); + emu_timer etimer = emu_timer.GetEmu_timerNoRef(); #region lt.Add(etimer); i1 = reader.ReadInt32(); @@ -1317,8 +1335,6 @@ namespace MAME.Core lt.Add(YM3812.timer[1]); } #endregion - //断开创建的引用计数 - emu_timer.ReleaseCreateRef(etimer); } for (i = n; i < 32; i++) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs index 7a9ac40e..b8ba4d3f 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mame.cs @@ -99,7 +99,7 @@ namespace MAME.Core if (exit_pending) return; - EmuTimer.emu_timer.CheckReadyRelaseAfterRun(); + EmuTimer.emu_timer.CheckReadyRelaseBeforeFrameRun(); long lastframe = Video.screenstate.frame_number; //执行CPU命令,直到一次画面更新 while (lastframe == Video.screenstate.frame_number) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/dataeast/Input.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/dataeast/Input.cs index 6612783c..a592cbad 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/dataeast/Input.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/dataeast/Input.cs @@ -9,14 +9,44 @@ namespace MAME.Core { public int fr; public byte by; - public fr1(int i1, byte b1) + //public fr1(int i1, byte b1) + //{ + // fr = i1; + // by = b1; + //} + public void reset() { - fr = i1; - by = b1; + fr = default; + by = default; + } + public static fr1 getnew(int i1, byte b1) + { + fr1 obj = ObjectPoolAuto.Acquire(); + obj.fr = i1; + obj.by = b1; + return obj; } } public static int i3 = 70; - public static List lfr = new List(); + static List lfr = resetlfr_list();//= new List(); + + static List resetlfr_list() + { + if (lfr == null) + { + lfr = ObjectPoolAuto.AcquireList(); + } + else + { + for (int i = 0; i < lfr.Count; i++) + { + lfr[i].reset(); + ObjectPoolAuto.Release(lfr[i]); + } + lfr.Clear(); + } + return lfr; + } public static void loop_inputports_dataeast_pcktgal() { if (Keyboard.IsPressed(MotionKey.P1_INSERT_COIN))//if (Keyboard.IsPressed(Corekey.D5)) @@ -149,36 +179,41 @@ namespace MAME.Core } if (Keyboard.IsPressed(MotionKey.UNKNOW_N))//if (Keyboard.IsPressed(Corekey.N)) { - lfr = new List(); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0x7f)); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2 + i3), 0x7f)); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2 + i3 + 1), 0xff)); + //lfr = new List(); + resetlfr_list(); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0x7f)); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff)); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2 + i3), 0x7f)); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2 + i3 + 1), 0xff)); } if (Keyboard.IsPressed(MotionKey.P1_BTN_3))//if (Keyboard.IsPressed(Corekey.U)) { - lfr = new List(); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xf7)); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); + //lfr = new List(); + resetlfr_list(); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xf7)); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff)); } if (Keyboard.IsPressed(MotionKey.P1_BTN_4))//if (Keyboard.IsPressed(Corekey.I)) { - lfr = new List(); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xfb)); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); + //lfr = new List(); + resetlfr_list(); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xfb)); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff)); } if (Keyboard.IsPressed(MotionKey.UNKNOW_V))//if (Keyboard.IsPressed(Corekey.V)) { - lfr = new List(); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xfd)); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); + //lfr = new List(); + resetlfr_list(); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xfd)); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff)); } if (Keyboard.IsPressed(MotionKey.UNKNOW_B))//if (Keyboard.IsPressed(Corekey.B)) { - lfr = new List(); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 1), 0xfe)); - lfr.Add(new fr1((int)(Video.screenstate.frame_number + 2), 0xff)); + //lfr = new List(); + resetlfr_list(); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 1), 0xfe)); + lfr.Add(fr1.getnew((int)(Video.screenstate.frame_number + 2), 0xff)); } foreach (fr1 f in lfr) { diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs index 0a345f22..66ca3425 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/mame/m92/Video.cs @@ -274,109 +274,205 @@ namespace MAME.Core } public static void draw_sprites(RECT cliprect) { - int offs, k; - for (k = 0; k < 8; k++) + // 预计算不变的值 + bool flip_screen = Generic.flip_screen_get() != 0; + int sprite_count = m92_sprite_list; + + // 预先计算常用值避免重复计算 + const int SCREEN_WIDTH = 512; + const int SCREEN_HEIGHT = 384; + const int X_OFFSET = 16; + const int Y_BASE = SCREEN_HEIGHT - X_OFFSET; + + for (int k = 0; k < 8; k++) { - for (offs = 0; offs < m92_sprite_list;) + int offs = 0; + + // 使用while循环避免for循环的额外开销 + while (offs < sprite_count) { - int x, y, sprite, colour, fx, fy, x_multi, y_multi, i, j, s_ptr, pri_back, pri_sprite; - y = Generic.buffered_spriteram16[offs + 0] & 0x1ff; - x = Generic.buffered_spriteram16[offs + 3] & 0x1ff; - if ((Generic.buffered_spriteram16[offs + 2] & 0x0080) != 0) - { - pri_back = 0; - } - else - { - pri_back = 2; - } - sprite = Generic.buffered_spriteram16[offs + 1]; - colour = Generic.buffered_spriteram16[offs + 2] & 0x007f; - pri_sprite = (Generic.buffered_spriteram16[offs + 0] & 0xe000) >> 13; - fx = (Generic.buffered_spriteram16[offs + 2] >> 8) & 1; - fy = (Generic.buffered_spriteram16[offs + 2] >> 9) & 1; - y_multi = (Generic.buffered_spriteram16[offs + 0] >> 9) & 3; - x_multi = (Generic.buffered_spriteram16[offs + 0] >> 11) & 3; - y_multi = 1 << y_multi; - x_multi = 1 << x_multi; - offs += 4 * x_multi; + // 一次性读取所有需要的数据到局部变量[7](@ref) + ushort data0 = Generic.buffered_spriteram16[offs]; + ushort data1 = Generic.buffered_spriteram16[offs + 1]; + ushort data2 = Generic.buffered_spriteram16[offs + 2]; + ushort data3 = Generic.buffered_spriteram16[offs + 3]; + + // 提前进行优先级检查,避免不必要的计算[8](@ref) + int pri_sprite = (data0 & 0xe000) >> 13; if (pri_sprite != k) { + offs += 4; continue; } - x = x - 16; - y = 384 - 16 - y; + + // 提取精灵属性(使用局部变量避免重复内存访问) + int y = data0 & 0x1ff; + int x = data3 & 0x1ff; + int sprite = data1; + int colour = data2 & 0x007f; + int fx = (data2 >> 8) & 1; + int fy = (data2 >> 9) & 1; + int y_multi = 1 << ((data0 >> 9) & 3); + int x_multi = 1 << ((data0 >> 11) & 3); + bool high_priority = (data2 & 0x0080) != 0; + int pri_back = high_priority ? 0 : 2; + + // 计算基础坐标变换 + x = x - X_OFFSET; + y = Y_BASE - y; + + // 处理水平翻转的偏移 if (fx != 0) { x += 16 * (x_multi - 1); } - for (j = 0; j < x_multi; j++) + + // 预先计算绘制参数 + uint draw_flags = (uint)(pri_back | (1 << 31)); + int x_step = fx != 0 ? -16 : 16; + + // 内层循环优化:减少重复计算 + for (int j = 0; j < x_multi; j++) { - s_ptr = 8 * j; + int s_ptr = 8 * j; if (fy == 0) { s_ptr += y_multi - 1; } - x &= 0x1ff; - for (i = 0; i < y_multi; i++) + + int current_x = x & 0x1ff; + + for (int i = 0; i < y_multi; i++) { - if (Generic.flip_screen_get() != 0) + if (flip_screen) { - int i1 = 1; - /*pdrawgfx(bitmap,machine->gfx[1], - sprite + s_ptr, - colour, - !fx,!fy, - 464-x,240-(y-i*16), - cliprect,TRANSPARENCY_PEN,0,pri_back); - - pdrawgfx(bitmap,machine->gfx[1], - sprite + s_ptr, - colour, - !fx,!fy, - 464-x+512,240-(y-i*16), - cliprect,TRANSPARENCY_PEN,0,pri_back);*/ - + // 翻转屏幕的绘制逻辑(已注释,保持原样) } else { - /*pdrawgfx(bitmap,machine->gfx[1], - sprite + s_ptr, - colour, - fx,fy, - x,y-i*16, - cliprect,TRANSPARENCY_PEN,0,pri_back); + // 直接调用绘制函数,避免中间计算[3](@ref) + Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, + current_x, y - i * 16, cliprect, draw_flags); + Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, + current_x - SCREEN_WIDTH, y - i * 16, cliprect, draw_flags); + } - pdrawgfx(bitmap,machine->gfx[1], - sprite + s_ptr, - colour, - fx,fy, - x-512,y-i*16, - cliprect,TRANSPARENCY_PEN,0,pri_back);*/ - Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x, y - i * 16, cliprect, (uint)(pri_back | (1 << 31))); - Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x - 512, y - i * 16, cliprect, (uint)(pri_back | (1 << 31))); - } - if (fy != 0) - { - s_ptr++; - } - else - { - s_ptr--; - } - } - if (fx != 0) - { - x -= 16; - } - else - { - x += 16; + // 优化指针更新 + s_ptr += fy != 0 ? 1 : -1; } + + current_x += x_step; } + + offs += 4 * x_multi; } } } + //public static void draw_sprites(RECT cliprect) + //{ + // int offs, k; + // for (k = 0; k < 8; k++) + // { + // for (offs = 0; offs < m92_sprite_list;) + // { + // int x, y, sprite, colour, fx, fy, x_multi, y_multi, i, j, s_ptr, pri_back, pri_sprite; + // y = Generic.buffered_spriteram16[offs + 0] & 0x1ff; + // x = Generic.buffered_spriteram16[offs + 3] & 0x1ff; + // if ((Generic.buffered_spriteram16[offs + 2] & 0x0080) != 0) + // { + // pri_back = 0; + // } + // else + // { + // pri_back = 2; + // } + // sprite = Generic.buffered_spriteram16[offs + 1]; + // colour = Generic.buffered_spriteram16[offs + 2] & 0x007f; + // pri_sprite = (Generic.buffered_spriteram16[offs + 0] & 0xe000) >> 13; + // fx = (Generic.buffered_spriteram16[offs + 2] >> 8) & 1; + // fy = (Generic.buffered_spriteram16[offs + 2] >> 9) & 1; + // y_multi = (Generic.buffered_spriteram16[offs + 0] >> 9) & 3; + // x_multi = (Generic.buffered_spriteram16[offs + 0] >> 11) & 3; + // y_multi = 1 << y_multi; + // x_multi = 1 << x_multi; + // offs += 4 * x_multi; + // if (pri_sprite != k) + // { + // continue; + // } + // x = x - 16; + // y = 384 - 16 - y; + // if (fx != 0) + // { + // x += 16 * (x_multi - 1); + // } + // for (j = 0; j < x_multi; j++) + // { + // s_ptr = 8 * j; + // if (fy == 0) + // { + // s_ptr += y_multi - 1; + // } + // x &= 0x1ff; + // for (i = 0; i < y_multi; i++) + // { + // if (Generic.flip_screen_get() != 0) + // { + // int i1 = 1; + // /*pdrawgfx(bitmap,machine->gfx[1], + // sprite + s_ptr, + // colour, + // !fx,!fy, + // 464-x,240-(y-i*16), + // cliprect,TRANSPARENCY_PEN,0,pri_back); + // + // pdrawgfx(bitmap,machine->gfx[1], + // sprite + s_ptr, + // colour, + // !fx,!fy, + // 464-x+512,240-(y-i*16), + // cliprect,TRANSPARENCY_PEN,0,pri_back);*/ + // + // } + // else + // { + // /*pdrawgfx(bitmap,machine->gfx[1], + // sprite + s_ptr, + // colour, + // fx,fy, + // x,y-i*16, + // cliprect,TRANSPARENCY_PEN,0,pri_back); + // + // pdrawgfx(bitmap,machine->gfx[1], + // sprite + s_ptr, + // colour, + // fx,fy, + // x-512,y-i*16, + // cliprect,TRANSPARENCY_PEN,0,pri_back);*/ + // Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x, y - i * 16, cliprect, (uint)(pri_back | (1 << 31))); + // Drawgfx.common_drawgfx_m92(gfx21rom, sprite + s_ptr, colour, fx, fy, x - 512, y - i * 16, cliprect, (uint)(pri_back | (1 << 31))); + // } + // if (fy != 0) + // { + // s_ptr++; + // } + // else + // { + // s_ptr--; + // } + // } + // if (fx != 0) + // { + // x -= 16; + // } + // else + // { + // x += 16; + // } + // } + // } + // } + //} public static void m92_update_scroll_positions() { int laynum; -- 2.36.0.windows.1